@gmx-io/sdk 1.2.0 → 1.3.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/ClaimHandler.json +424 -0
- package/build/cjs/src/abis/CustomErrors.json +642 -61
- package/build/cjs/src/abis/DataStore.json +25 -6
- package/build/cjs/src/abis/EventEmitter.json +1 -6
- package/build/cjs/src/abis/ExchangeRouter.json +195 -290
- package/build/cjs/src/abis/GelatoRelayRouter.json +251 -98
- package/build/cjs/src/abis/GlvReader.json +60 -3
- package/build/cjs/src/abis/GlvRouter.json +144 -86
- package/build/cjs/src/abis/GovToken.json +1 -354
- package/build/cjs/src/abis/LayerZeroProvider.json +372 -0
- package/build/cjs/src/abis/Multicall.json +134 -38
- package/build/cjs/src/abis/MultichainClaimsRouter.json +1266 -0
- package/build/cjs/src/abis/MultichainGlvRouter.json +1150 -0
- package/build/cjs/src/abis/MultichainGmRouter.json +1449 -0
- package/build/cjs/src/abis/MultichainOrderRouter.json +1820 -0
- package/build/cjs/src/abis/MultichainSubaccountRouter.json +2069 -0
- package/build/cjs/src/abis/MultichainTransferRouter.json +915 -0
- package/build/cjs/src/abis/MultichainUtils.json +133 -0
- package/build/cjs/src/abis/MultichainVault.json +275 -0
- package/build/cjs/src/abis/ReferralStorage.json +69 -19
- package/build/cjs/src/abis/RelayParams.json +85 -48
- package/build/cjs/src/abis/SmartAccount.json +28 -0
- package/build/cjs/src/abis/SubaccountGelatoRelayRouter.json +282 -148
- package/build/cjs/src/abis/SubaccountRouter.json +62 -118
- package/build/cjs/src/abis/SyntheticsReader.json +342 -474
- package/build/cjs/src/abis/SyntheticsRouter.json +1 -6
- package/build/cjs/src/abis/index.js +53 -5
- package/build/cjs/src/configs/__tests__/markets.spec.js +2 -2
- package/build/cjs/src/configs/__tests__/permits.spec.js +1 -1
- package/build/cjs/src/configs/__tests__/tokens.spec.js +2 -2
- package/build/cjs/src/configs/batch.js +60 -0
- package/build/cjs/src/configs/chains.js +41 -8
- package/build/cjs/src/configs/contracts.js +151 -39
- package/build/cjs/src/configs/dataStore.js +49 -5
- package/build/cjs/src/configs/express.js +6 -1
- package/build/cjs/src/configs/factors.js +1 -1
- package/build/cjs/src/configs/markets.js +163 -0
- package/build/cjs/src/configs/oracleKeeper.js +21 -35
- package/build/cjs/src/configs/tokens.js +272 -2
- package/build/cjs/src/index.js +3 -3
- package/build/cjs/src/modules/markets/index.js +9 -4
- package/build/cjs/src/modules/markets/query-builders.js +28 -8
- package/build/cjs/src/modules/orders/helpers.js +11 -2
- package/build/cjs/src/modules/orders/helpers.spec.js +2 -2
- package/build/cjs/src/modules/orders/orders.js +3 -3
- package/build/cjs/src/modules/orders/utils.js +4 -5
- package/build/cjs/src/modules/positions/positions.js +38 -5
- package/build/cjs/src/modules/utils/utils.js +4 -3
- package/build/cjs/src/prebuilt/hashedKinkModelMarketRatesKeys.json +186 -0
- package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +2442 -512
- package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +347 -0
- package/build/cjs/src/test/mock.js +9 -4
- package/build/cjs/src/types/subsquid.js +597 -1
- package/build/cjs/src/types/swapStrategy.js +2 -0
- package/build/cjs/src/types/trade.js +1 -0
- package/build/cjs/src/utils/LruCache.js +4 -0
- package/build/cjs/src/utils/__tests__/LruCache.spec.js +18 -0
- package/build/cjs/src/utils/__tests__/numbers.spec.js +18 -16
- package/build/cjs/src/utils/__tests__/orderTransactions/batchUtils.spec.js +0 -1
- package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +8 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +40 -30
- package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +12 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +6 -0
- package/build/cjs/src/utils/__tests__/positions.spec.js +23 -6
- package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +10 -0
- package/build/cjs/src/utils/bigmath.js +9 -2
- package/build/cjs/src/utils/errors/parseError.js +35 -1
- package/build/cjs/src/utils/errors/transactionsErrors.js +7 -1
- package/build/cjs/src/utils/fees/executionFee.js +5 -3
- package/build/cjs/src/utils/fees/index.js +8 -6
- package/build/cjs/src/utils/fees/priceImpact.js +94 -32
- package/build/cjs/src/utils/gelatoRelay.js +5 -0
- package/build/cjs/src/utils/marketKeysAndConfigs.js +24 -4
- package/build/cjs/src/utils/markets.js +10 -3
- package/build/cjs/src/utils/numbers.js +18 -17
- package/build/cjs/src/utils/orderTransactions.js +5 -2
- package/build/cjs/src/utils/positions.js +77 -9
- package/build/cjs/src/utils/prices.js +19 -13
- package/build/cjs/src/utils/swap/__tests__/mockRouting.spec.js +1 -0
- package/build/cjs/src/utils/swap/botanixStaking.js +90 -0
- package/build/cjs/src/utils/swap/buildSwapStrategy.js +224 -0
- package/build/cjs/src/utils/swap/externalSwapPath.js +41 -0
- package/build/cjs/src/utils/swap/externalSwapQuoteByPath.js +27 -0
- package/build/cjs/src/utils/swap/swapStats.js +6 -3
- package/build/cjs/src/utils/swap/swapValues.js +250 -11
- package/build/cjs/src/utils/trade/decrease.js +470 -0
- package/build/cjs/src/utils/trade/{amounts.js → increase.js} +175 -72
- package/build/cjs/src/utils/trade/trade.js +2 -2
- package/build/cjs/src/utils/tradeHistory.js +3 -0
- package/build/cjs/src/utils/twap/uiFeeReceiver.js +9 -9
- package/build/esm/src/abis/ClaimHandler.json +424 -0
- package/build/esm/src/abis/CustomErrors.json +642 -61
- package/build/esm/src/abis/DataStore.json +25 -6
- package/build/esm/src/abis/EventEmitter.json +1 -6
- package/build/esm/src/abis/ExchangeRouter.json +195 -290
- package/build/esm/src/abis/GelatoRelayRouter.json +251 -98
- package/build/esm/src/abis/GlvReader.json +60 -3
- package/build/esm/src/abis/GlvRouter.json +144 -86
- package/build/esm/src/abis/GovToken.json +1 -354
- package/build/esm/src/abis/LayerZeroProvider.json +372 -0
- package/build/esm/src/abis/Multicall.json +134 -38
- package/build/esm/src/abis/MultichainClaimsRouter.json +1266 -0
- package/build/esm/src/abis/MultichainGlvRouter.json +1150 -0
- package/build/esm/src/abis/MultichainGmRouter.json +1449 -0
- package/build/esm/src/abis/MultichainOrderRouter.json +1820 -0
- package/build/esm/src/abis/MultichainSubaccountRouter.json +2069 -0
- package/build/esm/src/abis/MultichainTransferRouter.json +915 -0
- package/build/esm/src/abis/MultichainUtils.json +133 -0
- package/build/esm/src/abis/MultichainVault.json +275 -0
- package/build/esm/src/abis/ReferralStorage.json +69 -19
- package/build/esm/src/abis/RelayParams.json +85 -48
- package/build/esm/src/abis/SmartAccount.json +28 -0
- package/build/esm/src/abis/SubaccountGelatoRelayRouter.json +282 -148
- package/build/esm/src/abis/SubaccountRouter.json +62 -118
- package/build/esm/src/abis/SyntheticsReader.json +342 -474
- package/build/esm/src/abis/SyntheticsRouter.json +1 -6
- package/build/esm/src/abis/index.js +53 -5
- package/build/esm/src/configs/__tests__/markets.spec.js +4 -4
- package/build/esm/src/configs/__tests__/permits.spec.js +2 -2
- package/build/esm/src/configs/__tests__/tokens.spec.js +3 -3
- package/build/esm/src/configs/batch.js +61 -1
- package/build/esm/src/configs/chains.js +40 -7
- package/build/esm/src/configs/contracts.js +152 -40
- package/build/esm/src/configs/dataStore.js +37 -1
- package/build/esm/src/configs/express.js +6 -1
- package/build/esm/src/configs/factors.js +1 -1
- package/build/esm/src/configs/markets.js +164 -1
- package/build/esm/src/configs/oracleKeeper.js +20 -30
- package/build/esm/src/configs/tokens.js +271 -2
- package/build/esm/src/index.js +3 -3
- package/build/esm/src/modules/markets/index.js +9 -4
- package/build/esm/src/modules/markets/query-builders.js +28 -8
- package/build/esm/src/modules/orders/helpers.js +10 -1
- package/build/esm/src/modules/orders/helpers.spec.js +2 -2
- package/build/esm/src/modules/orders/orders.js +3 -3
- package/build/esm/src/modules/orders/utils.js +4 -5
- package/build/esm/src/modules/positions/positions.js +40 -7
- package/build/esm/src/modules/utils/utils.js +4 -3
- package/build/esm/src/prebuilt/hashedKinkModelMarketRatesKeys.json +186 -0
- package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +2442 -512
- package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +347 -0
- package/build/esm/src/test/mock.js +9 -4
- package/build/esm/src/types/subsquid.js +596 -0
- package/build/esm/src/types/swapStrategy.js +1 -0
- package/build/esm/src/types/trade.js +1 -0
- package/build/esm/src/utils/LruCache.js +4 -0
- package/build/esm/src/utils/__tests__/LruCache.spec.js +18 -0
- package/build/esm/src/utils/__tests__/numbers.spec.js +18 -16
- package/build/esm/src/utils/__tests__/orderTransactions/batchUtils.spec.js +0 -1
- package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +8 -0
- package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +40 -30
- package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +12 -0
- package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +7 -1
- package/build/esm/src/utils/__tests__/positions.spec.js +23 -6
- package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +11 -1
- package/build/esm/src/utils/bigmath.js +9 -2
- package/build/esm/src/utils/errors/parseError.js +31 -0
- package/build/esm/src/utils/errors/transactionsErrors.js +7 -1
- package/build/esm/src/utils/fees/executionFee.js +5 -3
- package/build/esm/src/utils/fees/index.js +8 -6
- package/build/esm/src/utils/fees/priceImpact.js +88 -30
- package/build/esm/src/utils/gelatoRelay.js +2 -0
- package/build/esm/src/utils/marketKeysAndConfigs.js +25 -5
- package/build/esm/src/utils/markets.js +7 -1
- package/build/esm/src/utils/numbers.js +18 -17
- package/build/esm/src/utils/orderTransactions.js +5 -2
- package/build/esm/src/utils/positions.js +75 -11
- package/build/esm/src/utils/prices.js +20 -14
- package/build/esm/src/utils/swap/__tests__/mockRouting.spec.js +1 -0
- package/build/esm/src/utils/swap/botanixStaking.js +83 -0
- package/build/esm/src/utils/swap/buildSwapStrategy.js +219 -0
- package/build/esm/src/utils/swap/externalSwapPath.js +37 -0
- package/build/esm/src/utils/swap/externalSwapQuoteByPath.js +23 -0
- package/build/esm/src/utils/swap/swapStats.js +6 -3
- package/build/esm/src/utils/swap/swapValues.js +248 -9
- package/build/esm/src/utils/trade/decrease.js +460 -0
- package/build/esm/src/utils/trade/{amounts.js → increase.js} +176 -74
- package/build/esm/src/utils/trade/trade.js +2 -2
- package/build/esm/src/utils/tradeHistory.js +3 -0
- package/build/esm/src/utils/twap/uiFeeReceiver.js +9 -9
- package/build/types/src/abis/index.d.ts +1 -1
- package/build/types/src/configs/batch.d.ts +2 -1
- package/build/types/src/configs/chains.d.ts +25 -20
- package/build/types/src/configs/contracts.d.ts +118 -8
- package/build/types/src/configs/dataStore.d.ts +20 -0
- package/build/types/src/configs/express.d.ts +1 -0
- package/build/types/src/configs/factors.d.ts +1 -1
- package/build/types/src/configs/markets.d.ts +2 -2
- package/build/types/src/configs/oracleKeeper.d.ts +2 -3
- package/build/types/src/configs/tokens.d.ts +1 -0
- package/build/types/src/index.d.ts +1 -1
- package/build/types/src/modules/base.d.ts +1 -1
- package/build/types/src/modules/markets/query-builders.d.ts +3 -2
- package/build/types/src/modules/markets/types.d.ts +2 -2
- package/build/types/src/modules/orders/utils.d.ts +6 -5
- package/build/types/src/types/fees.d.ts +1 -0
- package/build/types/src/types/markets.d.ts +10 -5
- package/build/types/src/types/orders.d.ts +1 -1
- package/build/types/src/types/positions.d.ts +26 -2
- package/build/types/src/types/sdk.d.ts +2 -2
- package/build/types/src/types/subsquid.d.ts +1562 -9
- package/build/types/src/types/swapStrategy.d.ts +33 -0
- package/build/types/src/types/tokens.d.ts +12 -0
- package/build/types/src/types/trade.d.ts +32 -7
- package/build/types/src/types/tradeHistory.d.ts +3 -0
- package/build/types/src/utils/LruCache.d.ts +1 -0
- package/build/types/src/utils/bigmath.d.ts +2 -1
- package/build/types/src/utils/errors/parseError.d.ts +11 -0
- package/build/types/src/utils/fees/executionFee.d.ts +6 -3
- package/build/types/src/utils/fees/index.d.ts +2 -2
- package/build/types/src/utils/fees/priceImpact.d.ts +33 -5
- package/build/types/src/utils/marketKeysAndConfigs.d.ts +9 -4
- package/build/types/src/utils/markets.d.ts +7 -0
- package/build/types/src/utils/multicall.d.ts +1 -1
- package/build/types/src/utils/numbers.d.ts +6 -3
- package/build/types/src/utils/orderTransactions.d.ts +6 -4
- package/build/types/src/utils/positions.d.ts +30 -0
- package/build/types/src/utils/prices.d.ts +4 -0
- package/build/types/src/utils/swap/botanixStaking.d.ts +11 -0
- package/build/types/src/utils/swap/buildSwapStrategy.d.ts +22 -0
- package/build/types/src/utils/swap/externalSwapPath.d.ts +13 -0
- package/build/types/src/utils/swap/externalSwapQuoteByPath.d.ts +6 -0
- package/build/types/src/utils/swap/swapValues.d.ts +11 -4
- package/build/types/src/utils/trade/decrease.d.ts +77 -0
- package/build/types/src/utils/trade/{amounts.d.ts → increase.d.ts} +20 -2
- package/build/types/src/utils/twap/uiFeeReceiver.d.ts +7 -7
- package/package.json +2 -2
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import { maxUint256 } from "viem";
|
|
2
|
-
import { BASIS_POINTS_DIVISOR_BIGINT } from "../../configs/factors";
|
|
2
|
+
import { BASIS_POINTS_DIVISOR_BIGINT, DEFAULT_ACCEPTABLE_PRICE_IMPACT_BUFFER } from "../../configs/factors";
|
|
3
3
|
import { OrderType } from "../../types/orders";
|
|
4
4
|
import { bigMath } from "../bigmath";
|
|
5
|
-
import { getPositionFee, getPriceImpactForPosition, getTotalSwapVolumeFromSwapStats } from "../fees";
|
|
5
|
+
import { capPositionImpactUsdByMaxImpactPool, capPositionImpactUsdByMaxPriceImpactFactor, getPositionFee, getPriceImpactForPosition, getTotalSwapVolumeFromSwapStats, } from "../fees";
|
|
6
6
|
import { applyFactor } from "../numbers";
|
|
7
|
-
import { getLeverage } from "../positions";
|
|
7
|
+
import { getEntryPrice, getLeverage, getLiquidationPrice, getPositionPnlUsd, getPriceImpactDiffUsd, } from "../positions";
|
|
8
8
|
import { getAcceptablePriceInfo, getDefaultAcceptablePriceImpactBps, getMarkPrice, getOrderThresholdType, } from "../prices";
|
|
9
9
|
import { getSwapAmountsByFromValue, getSwapAmountsByToValue } from "../swap";
|
|
10
10
|
import { convertToTokenAmount, convertToUsd, getIsEquivalentTokens, getTokensRatioByPrice } from "../tokens";
|
|
11
11
|
export function getIncreasePositionAmounts(p) {
|
|
12
|
-
const { marketInfo, indexToken, initialCollateralToken, collateralToken, initialCollateralAmount, indexTokenAmount, isLong, leverage, triggerPrice, limitOrderType, position, fixedAcceptablePriceImpactBps, acceptablePriceImpactBuffer, externalSwapQuote, findSwapPath, userReferralInfo, uiFeeFactor, strategy, } = p;
|
|
12
|
+
const { marketInfo, indexToken, initialCollateralToken, collateralToken, initialCollateralAmount, indexTokenAmount, isLong, leverage, triggerPrice, limitOrderType, position, fixedAcceptablePriceImpactBps, acceptablePriceImpactBuffer, externalSwapQuote, findSwapPath, userReferralInfo, uiFeeFactor, strategy, marketsInfoData, chainId, externalSwapQuoteParams, } = p;
|
|
13
|
+
const swapStrategy = {
|
|
14
|
+
type: "noSwap",
|
|
15
|
+
externalSwapQuote: undefined,
|
|
16
|
+
swapPathStats: undefined,
|
|
17
|
+
amountIn: 0n,
|
|
18
|
+
amountOut: 0n,
|
|
19
|
+
usdIn: 0n,
|
|
20
|
+
usdOut: 0n,
|
|
21
|
+
priceIn: 0n,
|
|
22
|
+
priceOut: 0n,
|
|
23
|
+
feesUsd: 0n,
|
|
24
|
+
};
|
|
13
25
|
const values = {
|
|
14
26
|
initialCollateralAmount: 0n,
|
|
15
27
|
initialCollateralUsd: 0n,
|
|
16
28
|
collateralDeltaAmount: 0n,
|
|
17
29
|
collateralDeltaUsd: 0n,
|
|
18
|
-
|
|
19
|
-
externalSwapQuote: undefined,
|
|
30
|
+
swapStrategy,
|
|
20
31
|
indexTokenAmount: 0n,
|
|
21
32
|
sizeDeltaUsd: 0n,
|
|
22
33
|
sizeDeltaInTokens: 0n,
|
|
@@ -27,6 +38,7 @@ export function getIncreasePositionAmounts(p) {
|
|
|
27
38
|
triggerPrice: 0n,
|
|
28
39
|
acceptablePrice: 0n,
|
|
29
40
|
acceptablePriceDeltaBps: 0n,
|
|
41
|
+
recommendedAcceptablePriceDeltaBps: 0n,
|
|
30
42
|
positionFeeUsd: 0n,
|
|
31
43
|
uiFeeUsd: 0n,
|
|
32
44
|
swapUiFeeUsd: 0n,
|
|
@@ -65,30 +77,41 @@ export function getIncreasePositionAmounts(p) {
|
|
|
65
77
|
values.estimatedLeverage = leverage;
|
|
66
78
|
values.initialCollateralAmount = initialCollateralAmount;
|
|
67
79
|
values.initialCollateralUsd = convertToUsd(initialCollateralAmount, initialCollateralToken.decimals, values.initialCollateralPrice);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
if (externalSwapQuote) {
|
|
81
|
+
const swapStrategy = {
|
|
82
|
+
type: "externalSwap",
|
|
83
|
+
externalSwapQuote,
|
|
84
|
+
swapPathStats: undefined,
|
|
85
|
+
...externalSwapQuote,
|
|
86
|
+
};
|
|
87
|
+
values.swapStrategy = swapStrategy;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const swapAmounts = getSwapAmountsByFromValue({
|
|
91
|
+
tokenIn: initialCollateralToken,
|
|
92
|
+
tokenOut: collateralToken,
|
|
93
|
+
amountIn: initialCollateralAmount,
|
|
94
|
+
isLimit: false,
|
|
95
|
+
findSwapPath,
|
|
96
|
+
uiFeeFactor,
|
|
97
|
+
swapOptimizationOrder,
|
|
98
|
+
marketsInfoData,
|
|
99
|
+
chainId,
|
|
100
|
+
externalSwapQuoteParams,
|
|
101
|
+
});
|
|
102
|
+
values.swapStrategy = swapAmounts.swapStrategy;
|
|
103
|
+
}
|
|
104
|
+
const swapAmountOut = values.swapStrategy.amountOut;
|
|
80
105
|
const baseCollateralUsd = convertToUsd(swapAmountOut, collateralToken.decimals, values.collateralPrice);
|
|
81
106
|
const baseSizeDeltaUsd = bigMath.mulDiv(baseCollateralUsd, leverage, BASIS_POINTS_DIVISOR_BIGINT);
|
|
82
|
-
const
|
|
83
|
-
const basePositionFeeInfo = getPositionFee(marketInfo, baseSizeDeltaUsd,
|
|
107
|
+
const { balanceWasImproved } = getPriceImpactForPosition(marketInfo, baseSizeDeltaUsd, isLong);
|
|
108
|
+
const basePositionFeeInfo = getPositionFee(marketInfo, baseSizeDeltaUsd, balanceWasImproved, userReferralInfo);
|
|
84
109
|
const baseUiFeeUsd = applyFactor(baseSizeDeltaUsd, uiFeeFactor);
|
|
85
|
-
const totalSwapVolumeUsd =
|
|
86
|
-
? getTotalSwapVolumeFromSwapStats(values.swapPathStats?.swapSteps)
|
|
87
|
-
: 0n;
|
|
110
|
+
const totalSwapVolumeUsd = getTotalSwapVolumeFromSwapStats(values.swapStrategy.swapPathStats?.swapSteps);
|
|
88
111
|
values.swapUiFeeUsd = applyFactor(totalSwapVolumeUsd, uiFeeFactor);
|
|
89
112
|
values.sizeDeltaUsd = bigMath.mulDiv(baseCollateralUsd - basePositionFeeInfo.positionFeeUsd - baseUiFeeUsd - values.swapUiFeeUsd, leverage, BASIS_POINTS_DIVISOR_BIGINT);
|
|
90
113
|
values.indexTokenAmount = convertToTokenAmount(values.sizeDeltaUsd, indexToken.decimals, values.indexPrice);
|
|
91
|
-
const positionFeeInfo = getPositionFee(marketInfo, values.sizeDeltaUsd,
|
|
114
|
+
const positionFeeInfo = getPositionFee(marketInfo, values.sizeDeltaUsd, balanceWasImproved, userReferralInfo);
|
|
92
115
|
values.positionFeeUsd = positionFeeInfo.positionFeeUsd;
|
|
93
116
|
values.feeDiscountUsd = positionFeeInfo.discountUsd;
|
|
94
117
|
values.uiFeeUsd = applyFactor(values.sizeDeltaUsd, uiFeeFactor);
|
|
@@ -108,8 +131,8 @@ export function getIncreasePositionAmounts(p) {
|
|
|
108
131
|
values.estimatedLeverage = leverage;
|
|
109
132
|
values.indexTokenAmount = indexTokenAmount;
|
|
110
133
|
values.sizeDeltaUsd = convertToUsd(indexTokenAmount, indexToken.decimals, values.indexPrice);
|
|
111
|
-
const
|
|
112
|
-
const positionFeeInfo = getPositionFee(marketInfo, values.sizeDeltaUsd,
|
|
134
|
+
const { balanceWasImproved } = getPriceImpactForPosition(marketInfo, values.sizeDeltaUsd, isLong);
|
|
135
|
+
const positionFeeInfo = getPositionFee(marketInfo, values.sizeDeltaUsd, balanceWasImproved, userReferralInfo);
|
|
113
136
|
values.positionFeeUsd = positionFeeInfo.positionFeeUsd;
|
|
114
137
|
values.feeDiscountUsd = positionFeeInfo.discountUsd;
|
|
115
138
|
values.uiFeeUsd = applyFactor(values.sizeDeltaUsd, uiFeeFactor);
|
|
@@ -127,17 +150,30 @@ export function getIncreasePositionAmounts(p) {
|
|
|
127
150
|
});
|
|
128
151
|
values.collateralDeltaUsd = collateralDeltaUsd;
|
|
129
152
|
values.collateralDeltaAmount = collateralDeltaAmount;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
if (externalSwapQuote) {
|
|
154
|
+
const swapStrategy = {
|
|
155
|
+
type: "externalSwap",
|
|
156
|
+
externalSwapQuote,
|
|
157
|
+
swapPathStats: undefined,
|
|
158
|
+
...externalSwapQuote,
|
|
159
|
+
};
|
|
160
|
+
values.swapStrategy = swapStrategy;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const swapAmounts = getSwapAmountsByToValue({
|
|
164
|
+
tokenIn: initialCollateralToken,
|
|
165
|
+
tokenOut: collateralToken,
|
|
166
|
+
amountOut: baseCollateralAmount,
|
|
167
|
+
isLimit: false,
|
|
168
|
+
findSwapPath,
|
|
169
|
+
uiFeeFactor,
|
|
170
|
+
marketsInfoData,
|
|
171
|
+
chainId,
|
|
172
|
+
externalSwapQuoteParams,
|
|
173
|
+
});
|
|
174
|
+
values.swapStrategy = swapAmounts.swapStrategy;
|
|
175
|
+
}
|
|
176
|
+
const swapAmountIn = values.swapStrategy.amountIn;
|
|
141
177
|
values.initialCollateralAmount = swapAmountIn;
|
|
142
178
|
values.initialCollateralUsd = convertToUsd(values.initialCollateralAmount, initialCollateralToken.decimals, values.initialCollateralPrice);
|
|
143
179
|
}
|
|
@@ -145,8 +181,8 @@ export function getIncreasePositionAmounts(p) {
|
|
|
145
181
|
if (indexTokenAmount !== undefined && indexTokenAmount > 0) {
|
|
146
182
|
values.indexTokenAmount = indexTokenAmount;
|
|
147
183
|
values.sizeDeltaUsd = convertToUsd(indexTokenAmount, indexToken.decimals, values.indexPrice);
|
|
148
|
-
const
|
|
149
|
-
const positionFeeInfo = getPositionFee(marketInfo, values.sizeDeltaUsd,
|
|
184
|
+
const { balanceWasImproved } = getPriceImpactForPosition(marketInfo, values.sizeDeltaUsd, isLong);
|
|
185
|
+
const positionFeeInfo = getPositionFee(marketInfo, values.sizeDeltaUsd, balanceWasImproved, userReferralInfo);
|
|
150
186
|
values.positionFeeUsd = positionFeeInfo.positionFeeUsd;
|
|
151
187
|
values.feeDiscountUsd = positionFeeInfo.discountUsd;
|
|
152
188
|
values.uiFeeUsd = applyFactor(values.sizeDeltaUsd, uiFeeFactor);
|
|
@@ -154,18 +190,31 @@ export function getIncreasePositionAmounts(p) {
|
|
|
154
190
|
if (initialCollateralAmount !== undefined && initialCollateralAmount > 0) {
|
|
155
191
|
values.initialCollateralAmount = initialCollateralAmount;
|
|
156
192
|
values.initialCollateralUsd = convertToUsd(initialCollateralAmount, initialCollateralToken.decimals, values.initialCollateralPrice);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
193
|
+
if (externalSwapQuote) {
|
|
194
|
+
const swapStrategy = {
|
|
195
|
+
type: "externalSwap",
|
|
196
|
+
externalSwapQuote,
|
|
197
|
+
swapPathStats: undefined,
|
|
198
|
+
...externalSwapQuote,
|
|
199
|
+
};
|
|
200
|
+
values.swapStrategy = swapStrategy;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const swapAmounts = getSwapAmountsByFromValue({
|
|
204
|
+
tokenIn: initialCollateralToken,
|
|
205
|
+
tokenOut: collateralToken,
|
|
206
|
+
amountIn: initialCollateralAmount,
|
|
207
|
+
isLimit: false,
|
|
208
|
+
findSwapPath,
|
|
209
|
+
uiFeeFactor,
|
|
210
|
+
swapOptimizationOrder,
|
|
211
|
+
marketsInfoData,
|
|
212
|
+
chainId,
|
|
213
|
+
externalSwapQuoteParams,
|
|
214
|
+
});
|
|
215
|
+
values.swapStrategy = swapAmounts.swapStrategy;
|
|
216
|
+
}
|
|
217
|
+
const swapAmountIn = values.swapStrategy.amountIn;
|
|
169
218
|
const baseCollateralUsd = convertToUsd(swapAmountIn, initialCollateralToken.decimals, values.initialCollateralPrice);
|
|
170
219
|
values.collateralDeltaUsd =
|
|
171
220
|
baseCollateralUsd -
|
|
@@ -187,6 +236,7 @@ export function getIncreasePositionAmounts(p) {
|
|
|
187
236
|
const acceptablePriceInfo = getAcceptablePriceInfo({
|
|
188
237
|
marketInfo,
|
|
189
238
|
isIncrease: true,
|
|
239
|
+
isLimit,
|
|
190
240
|
isLong,
|
|
191
241
|
indexPrice: values.indexPrice,
|
|
192
242
|
sizeDeltaUsd: values.sizeDeltaUsd,
|
|
@@ -205,19 +255,21 @@ export function getIncreasePositionAmounts(p) {
|
|
|
205
255
|
}
|
|
206
256
|
else {
|
|
207
257
|
let maxNegativePriceImpactBps = fixedAcceptablePriceImpactBps;
|
|
258
|
+
values.recommendedAcceptablePriceDeltaBps = getDefaultAcceptablePriceImpactBps({
|
|
259
|
+
isIncrease: true,
|
|
260
|
+
isLong,
|
|
261
|
+
indexPrice: values.indexPrice,
|
|
262
|
+
sizeDeltaUsd: values.sizeDeltaUsd,
|
|
263
|
+
priceImpactDeltaUsd: values.positionPriceImpactDeltaUsd,
|
|
264
|
+
acceptablePriceImapctBuffer: acceptablePriceImpactBuffer || DEFAULT_ACCEPTABLE_PRICE_IMPACT_BUFFER,
|
|
265
|
+
});
|
|
208
266
|
if (maxNegativePriceImpactBps === undefined) {
|
|
209
|
-
maxNegativePriceImpactBps =
|
|
210
|
-
isIncrease: true,
|
|
211
|
-
isLong,
|
|
212
|
-
indexPrice: values.indexPrice,
|
|
213
|
-
sizeDeltaUsd: values.sizeDeltaUsd,
|
|
214
|
-
priceImpactDeltaUsd: values.positionPriceImpactDeltaUsd,
|
|
215
|
-
acceptablePriceImapctBuffer: acceptablePriceImpactBuffer,
|
|
216
|
-
});
|
|
267
|
+
maxNegativePriceImpactBps = values.recommendedAcceptablePriceDeltaBps;
|
|
217
268
|
}
|
|
218
269
|
const limitAcceptablePriceInfo = getAcceptablePriceInfo({
|
|
219
270
|
marketInfo,
|
|
220
271
|
isIncrease: true,
|
|
272
|
+
isLimit,
|
|
221
273
|
isLong,
|
|
222
274
|
indexPrice: values.indexPrice,
|
|
223
275
|
sizeDeltaUsd: values.sizeDeltaUsd,
|
|
@@ -227,22 +279,7 @@ export function getIncreasePositionAmounts(p) {
|
|
|
227
279
|
values.acceptablePriceDeltaBps = limitAcceptablePriceInfo.acceptablePriceDeltaBps;
|
|
228
280
|
}
|
|
229
281
|
}
|
|
230
|
-
let priceImpactAmount = 0n;
|
|
231
|
-
if (values.positionPriceImpactDeltaUsd > 0) {
|
|
232
|
-
const price = triggerPrice !== undefined && triggerPrice > 0 ? triggerPrice : indexToken.prices.maxPrice;
|
|
233
|
-
priceImpactAmount = convertToTokenAmount(values.positionPriceImpactDeltaUsd, indexToken.decimals, price);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
const price = triggerPrice !== undefined && triggerPrice > 0 ? triggerPrice : indexToken.prices.minPrice;
|
|
237
|
-
priceImpactAmount = convertToTokenAmount(values.positionPriceImpactDeltaUsd, indexToken.decimals, price);
|
|
238
|
-
}
|
|
239
282
|
values.sizeDeltaInTokens = convertToTokenAmount(values.sizeDeltaUsd, indexToken.decimals, values.indexPrice);
|
|
240
|
-
if (isLong) {
|
|
241
|
-
values.sizeDeltaInTokens = values.sizeDeltaInTokens + priceImpactAmount;
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
values.sizeDeltaInTokens = values.sizeDeltaInTokens - priceImpactAmount;
|
|
245
|
-
}
|
|
246
283
|
return values;
|
|
247
284
|
}
|
|
248
285
|
export function getTokensRatio({ fromToken, toToken, triggerRatioValue, markPrice, }) {
|
|
@@ -308,3 +345,68 @@ export function getIncreasePositionPrices({ triggerPrice, indexToken, initialCol
|
|
|
308
345
|
triggerPrice,
|
|
309
346
|
};
|
|
310
347
|
}
|
|
348
|
+
export function getNextPositionValuesForIncreaseTrade(p) {
|
|
349
|
+
const { existingPosition, marketInfo, collateralToken, sizeDeltaUsd, sizeDeltaInTokens, collateralDeltaUsd, collateralDeltaAmount, indexPrice, isLong, showPnlInLeverage, minCollateralUsd, userReferralInfo, positionPriceImpactDeltaUsd, } = p;
|
|
350
|
+
const nextCollateralUsd = existingPosition ? existingPosition.collateralUsd + collateralDeltaUsd : collateralDeltaUsd;
|
|
351
|
+
const nextCollateralAmount = existingPosition
|
|
352
|
+
? existingPosition.collateralAmount + collateralDeltaAmount
|
|
353
|
+
: collateralDeltaAmount;
|
|
354
|
+
const nextSizeUsd = existingPosition ? existingPosition.sizeInUsd + sizeDeltaUsd : sizeDeltaUsd;
|
|
355
|
+
const nextSizeInTokens = existingPosition ? existingPosition.sizeInTokens + sizeDeltaInTokens : sizeDeltaInTokens;
|
|
356
|
+
const nextEntryPrice = getEntryPrice({
|
|
357
|
+
sizeInUsd: nextSizeUsd,
|
|
358
|
+
sizeInTokens: nextSizeInTokens,
|
|
359
|
+
indexToken: marketInfo.indexToken,
|
|
360
|
+
}) ?? indexPrice;
|
|
361
|
+
const nextPnl = existingPosition
|
|
362
|
+
? getPositionPnlUsd({
|
|
363
|
+
marketInfo,
|
|
364
|
+
sizeInUsd: nextSizeUsd,
|
|
365
|
+
sizeInTokens: nextSizeInTokens,
|
|
366
|
+
markPrice: indexPrice,
|
|
367
|
+
isLong,
|
|
368
|
+
})
|
|
369
|
+
: undefined;
|
|
370
|
+
const nextLeverage = getLeverage({
|
|
371
|
+
sizeInUsd: nextSizeUsd,
|
|
372
|
+
collateralUsd: nextCollateralUsd,
|
|
373
|
+
pnl: showPnlInLeverage ? nextPnl : undefined,
|
|
374
|
+
pendingBorrowingFeesUsd: 0n, // deducted on order
|
|
375
|
+
pendingFundingFeesUsd: 0n, // deducted on order
|
|
376
|
+
});
|
|
377
|
+
const nextLiqPrice = getLiquidationPrice({
|
|
378
|
+
marketInfo,
|
|
379
|
+
collateralToken,
|
|
380
|
+
sizeInUsd: nextSizeUsd,
|
|
381
|
+
sizeInTokens: nextSizeInTokens,
|
|
382
|
+
collateralUsd: nextCollateralUsd,
|
|
383
|
+
collateralAmount: nextCollateralAmount,
|
|
384
|
+
minCollateralUsd,
|
|
385
|
+
pendingBorrowingFeesUsd: 0n, // deducted on order
|
|
386
|
+
pendingFundingFeesUsd: 0n, // deducted on order
|
|
387
|
+
pendingImpactAmount: existingPosition?.pendingImpactAmount ?? 0n,
|
|
388
|
+
isLong: isLong,
|
|
389
|
+
userReferralInfo,
|
|
390
|
+
});
|
|
391
|
+
let nextPendingImpactDeltaUsd = existingPosition?.pendingImpactUsd !== undefined
|
|
392
|
+
? existingPosition.pendingImpactUsd + positionPriceImpactDeltaUsd
|
|
393
|
+
: positionPriceImpactDeltaUsd;
|
|
394
|
+
const potentialPriceImpactDiffUsd = getPriceImpactDiffUsd({
|
|
395
|
+
totalImpactDeltaUsd: nextPendingImpactDeltaUsd,
|
|
396
|
+
marketInfo,
|
|
397
|
+
sizeDeltaUsd: nextSizeUsd,
|
|
398
|
+
});
|
|
399
|
+
if (nextPendingImpactDeltaUsd > 0) {
|
|
400
|
+
nextPendingImpactDeltaUsd = capPositionImpactUsdByMaxPriceImpactFactor(marketInfo, nextSizeUsd, nextPendingImpactDeltaUsd);
|
|
401
|
+
}
|
|
402
|
+
nextPendingImpactDeltaUsd = capPositionImpactUsdByMaxImpactPool(marketInfo, nextPendingImpactDeltaUsd);
|
|
403
|
+
return {
|
|
404
|
+
nextSizeUsd,
|
|
405
|
+
nextCollateralUsd,
|
|
406
|
+
nextEntryPrice,
|
|
407
|
+
nextLeverage,
|
|
408
|
+
nextLiqPrice,
|
|
409
|
+
nextPendingImpactDeltaUsd,
|
|
410
|
+
potentialPriceImpactDiffUsd,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
@@ -18,12 +18,12 @@ export function getSwapCount({ isSwap, isIncrease, increaseAmounts, decreaseAmou
|
|
|
18
18
|
if (isSwap) {
|
|
19
19
|
if (!swapAmounts)
|
|
20
20
|
return undefined;
|
|
21
|
-
return swapAmounts.swapPathStats?.swapPath.length ?? 0;
|
|
21
|
+
return swapAmounts.swapStrategy.swapPathStats?.swapPath.length ?? 0;
|
|
22
22
|
}
|
|
23
23
|
else if (isIncrease) {
|
|
24
24
|
if (!increaseAmounts)
|
|
25
25
|
return undefined;
|
|
26
|
-
return increaseAmounts.swapPathStats?.swapPath.length ?? 0;
|
|
26
|
+
return increaseAmounts.swapStrategy.swapPathStats?.swapPath.length ?? 0;
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
if (decreaseAmounts?.decreaseSwapType === undefined)
|
|
@@ -24,6 +24,7 @@ export function createRawTradeActionTransformer(marketsInfoData, wrappedToken, t
|
|
|
24
24
|
}
|
|
25
25
|
const tradeAction = {
|
|
26
26
|
id: rawAction.id,
|
|
27
|
+
srcChainId: rawAction.srcChainId ? Number(rawAction.srcChainId) : undefined,
|
|
27
28
|
eventName: rawAction.eventName,
|
|
28
29
|
account: rawAction.account,
|
|
29
30
|
swapPath,
|
|
@@ -74,6 +75,7 @@ export function createRawTradeActionTransformer(marketsInfoData, wrappedToken, t
|
|
|
74
75
|
account: rawAction.account,
|
|
75
76
|
marketAddress,
|
|
76
77
|
marketInfo,
|
|
78
|
+
srcChainId: rawAction.srcChainId ? Number(rawAction.srcChainId) : undefined,
|
|
77
79
|
indexToken,
|
|
78
80
|
swapPath,
|
|
79
81
|
initialCollateralTokenAddress,
|
|
@@ -108,6 +110,7 @@ export function createRawTradeActionTransformer(marketsInfoData, wrappedToken, t
|
|
|
108
110
|
basePnlUsd: rawAction.basePnlUsd ? BigInt(rawAction.basePnlUsd) : undefined,
|
|
109
111
|
priceImpactDiffUsd: rawAction.priceImpactDiffUsd ? BigInt(rawAction.priceImpactDiffUsd) : undefined,
|
|
110
112
|
priceImpactUsd: rawAction.priceImpactUsd ? BigInt(rawAction.priceImpactUsd) : undefined,
|
|
113
|
+
totalImpactUsd: rawAction.totalImpactUsd ? BigInt(rawAction.totalImpactUsd) : undefined,
|
|
111
114
|
positionFeeAmount: rawAction.positionFeeAmount ? BigInt(rawAction.positionFeeAmount) : undefined,
|
|
112
115
|
borrowingFeeAmount: rawAction.borrowingFeeAmount ? BigInt(rawAction.borrowingFeeAmount) : undefined,
|
|
113
116
|
fundingFeeAmount: rawAction.fundingFeeAmount ? BigInt(rawAction.fundingFeeAmount) : undefined,
|
|
@@ -3,14 +3,14 @@ const VERSION = "01";
|
|
|
3
3
|
const PREFIX = "0xff0000";
|
|
4
4
|
/**
|
|
5
5
|
* Ui fee receiver structure:
|
|
6
|
-
* 0
|
|
7
|
-
* 4
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* 19
|
|
11
|
-
* 20 byte (
|
|
6
|
+
* 0-3 (4) bytes (0-7 chars) - PREFIX
|
|
7
|
+
* 4-15 (12) bytes (8-32 chars) - 12 bytes buffer
|
|
8
|
+
* 16 (1) byte (33-34 chars) - isExpress flag
|
|
9
|
+
* 17 (1) byte (35-36 chars) - numberOfParts (hex encoded)
|
|
10
|
+
* 18-19 (2) bytes (37-40 chars) - twapId
|
|
11
|
+
* 20 (1) byte (41-42 chars) - VERSION
|
|
12
12
|
*
|
|
13
|
-
* Total: 20 bytes (
|
|
13
|
+
* Total: 0x + 20 bytes (41 hex characters)
|
|
14
14
|
*/
|
|
15
15
|
export function generateTwapId() {
|
|
16
16
|
return Math.floor(Math.random() * 256 * 256)
|
|
@@ -20,8 +20,8 @@ export function generateTwapId() {
|
|
|
20
20
|
export function createTwapUiFeeReceiver({ numberOfParts }) {
|
|
21
21
|
const twapId = generateTwapId();
|
|
22
22
|
const numberOfPartsInHex = numberOfParts.toString(16).padStart(2, "0");
|
|
23
|
-
const isExpressHex = "00";
|
|
24
23
|
const buffer = "00".repeat(12);
|
|
24
|
+
const isExpressHex = "00";
|
|
25
25
|
return `${PREFIX}${buffer}${isExpressHex}${numberOfPartsInHex}${twapId}${VERSION}`;
|
|
26
26
|
}
|
|
27
27
|
export function decodeTwapUiFeeReceiver(address) {
|
|
@@ -39,5 +39,5 @@ export function isValidTwapUiFeeReceiver(address) {
|
|
|
39
39
|
}
|
|
40
40
|
export function setUiFeeReceiverIsExpress(uiFeeReceiver, isExpress) {
|
|
41
41
|
const isExpressInHex = isExpress ? "01" : "00";
|
|
42
|
-
return `${uiFeeReceiver.slice(0,
|
|
42
|
+
return `${uiFeeReceiver.slice(0, 16 * 2)}${isExpressInHex}${uiFeeReceiver.slice(17 * 2)}`;
|
|
43
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Abi } from "viem";
|
|
2
|
-
export type AbiId = "CustomErrors" | "DataStore" | "
|
|
2
|
+
export type AbiId = "AbstractSubaccountApprovalNonceable" | "ArbitrumNodeInterface" | "ClaimHandler" | "CustomErrors" | "DataStore" | "ERC20" | "ERC20PermitInterface" | "ERC20PermitInterface" | "ERC721" | "EventEmitter" | "ExchangeRouter" | "GelatoRelayRouter" | "GelatoRelayRouter" | "GlpManager" | "GlvReader" | "GlvRouter" | "GMT" | "GmxMigrator" | "GovToken" | "LayerZeroProvider" | "MintableBaseToken" | "Multicall" | "MultichainClaimsRouter" | "MultichainGlvRouter" | "MultichainGmRouter" | "MultichainOrderRouter" | "MultichainSubaccountRouter" | "MultichainTransferRouter" | "MultichainUtils" | "MultichainVault" | "OrderBook" | "OrderBookReader" | "OrderExecutor" | "PositionManager" | "PositionRouter" | "Reader" | "ReaderV2" | "ReferralStorage" | "RelayParams" | "RewardReader" | "RewardRouter" | "RewardTracker" | "Router" | "RouterV2" | "SmartAccount" | "StBTC" | "SubaccountGelatoRelayRouter" | "SubaccountGelatoRelayRouter" | "SubaccountRouter" | "SyntheticsReader" | "SyntheticsRouter" | "Timelock" | "Token" | "Treasury" | "UniPool" | "UniswapV2" | "Vault" | "VaultReader" | "VaultV2" | "VaultV2b" | "Vester" | "WETH" | "YieldFarm" | "YieldToken";
|
|
3
3
|
/** Copied from ethers to enable compatibility with GMX UI */
|
|
4
4
|
interface JsonFragmentType {
|
|
5
5
|
readonly name?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClientConfig, MulticallBatchOptions } from "viem";
|
|
2
|
-
|
|
2
|
+
import { AnyChainId } from "./chains";
|
|
3
|
+
export declare const BATCH_CONFIGS: Record<AnyChainId, {
|
|
3
4
|
http: MulticallBatchOptions;
|
|
4
5
|
client: ClientConfig["batch"];
|
|
5
6
|
}>;
|
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
import { Chain } from "viem/chains";
|
|
2
|
+
import type { GasLimitsConfig } from "../types/fees";
|
|
3
|
+
export declare const ETH_MAINNET = 1;
|
|
2
4
|
export declare const AVALANCHE = 43114;
|
|
3
|
-
export declare const AVALANCHE_FUJI = 43113;
|
|
4
5
|
export declare const ARBITRUM = 42161;
|
|
5
|
-
export declare const ETH_MAINNET = 1;
|
|
6
6
|
export declare const BOTANIX = 3637;
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
7
|
+
export declare const SOURCE_BASE_MAINNET = 8453;
|
|
8
|
+
export declare const AVALANCHE_FUJI = 43113;
|
|
9
|
+
export declare const ARBITRUM_SEPOLIA = 421614;
|
|
10
|
+
export declare const SOURCE_OPTIMISM_SEPOLIA = 11155420;
|
|
11
|
+
export declare const SOURCE_SEPOLIA = 11155111;
|
|
12
|
+
export declare const CONTRACTS_CHAIN_IDS: ContractsChainId[];
|
|
13
|
+
export declare const CONTRACTS_CHAIN_IDS_DEV: ContractsChainId[];
|
|
14
|
+
export type ContractsChainId = typeof ARBITRUM | typeof AVALANCHE | typeof AVALANCHE_FUJI | typeof BOTANIX | typeof ARBITRUM_SEPOLIA;
|
|
15
|
+
export type SettlementChainId = typeof ARBITRUM_SEPOLIA | typeof ARBITRUM | typeof AVALANCHE;
|
|
16
|
+
export type SourceChainId = typeof SOURCE_OPTIMISM_SEPOLIA | typeof SOURCE_SEPOLIA | typeof SOURCE_BASE_MAINNET;
|
|
17
|
+
export type AnyChainId = ContractsChainId | SettlementChainId | SourceChainId;
|
|
18
|
+
export type ChainName = "Arbitrum" | "Avalanche" | "Avalanche Fuji" | "Arbitrum Sepolia" | "Optimism Sepolia" | "Sepolia" | "Botanix" | "Base";
|
|
19
|
+
export declare const CHAIN_NAMES_MAP: Record<AnyChainId, ChainName>;
|
|
20
|
+
export declare const HIGH_EXECUTION_FEES_MAP: Record<ContractsChainId, number>;
|
|
13
21
|
export declare const MAX_FEE_PER_GAS_MAP: Record<number, bigint>;
|
|
14
22
|
export declare const GAS_PRICE_PREMIUM_MAP: Record<number, bigint>;
|
|
15
|
-
export declare const MAX_PRIORITY_FEE_PER_GAS_MAP: Record<
|
|
16
|
-
export declare const EXCESSIVE_EXECUTION_FEES_MAP: Record<
|
|
17
|
-
export declare const MIN_EXECUTION_FEE_USD: Record<
|
|
23
|
+
export declare const MAX_PRIORITY_FEE_PER_GAS_MAP: Record<ContractsChainId, bigint | undefined>;
|
|
24
|
+
export declare const EXCESSIVE_EXECUTION_FEES_MAP: Partial<Record<ContractsChainId, number>>;
|
|
25
|
+
export declare const MIN_EXECUTION_FEE_USD: Partial<Record<ContractsChainId, bigint | undefined>>;
|
|
18
26
|
export declare const GAS_PRICE_BUFFER_MAP: Record<number, bigint>;
|
|
19
27
|
export declare const botanix: Chain;
|
|
20
|
-
export declare function getChainName(chainId: number):
|
|
28
|
+
export declare function getChainName(chainId: number): ChainName;
|
|
21
29
|
export declare const getViemChain: (chainId: number) => Chain;
|
|
22
30
|
export declare function getHighExecutionFee(chainId: number): any;
|
|
23
31
|
export declare function getExcessiveExecutionFee(chainId: number): any;
|
|
24
|
-
export declare function
|
|
32
|
+
export declare function isContractsChain(chainId: number, dev?: boolean): chainId is ContractsChainId;
|
|
25
33
|
export declare const EXECUTION_FEE_CONFIG_V2: {
|
|
26
|
-
[chainId in
|
|
34
|
+
[chainId in ContractsChainId]: {
|
|
27
35
|
shouldUseMaxPriorityFeePerGas: boolean;
|
|
28
36
|
defaultBufferBps?: number;
|
|
29
37
|
};
|
|
30
38
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
cancelOrderGasLimit: bigint;
|
|
35
|
-
tokenPermitGasLimit: bigint;
|
|
36
|
-
}>;
|
|
39
|
+
type StaticGasLimitsConfig = Pick<GasLimitsConfig, "createOrderGasLimit" | "updateOrderGasLimit" | "cancelOrderGasLimit" | "tokenPermitGasLimit" | "gmxAccountCollateralGasLimit">;
|
|
40
|
+
export declare const GAS_LIMITS_STATIC_CONFIG: Record<ContractsChainId, StaticGasLimitsConfig>;
|
|
41
|
+
export {};
|