@gmx-io/sdk 1.6.2 → 1.6.4
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/README.md +1 -1
- package/build/cjs/scripts/generate-synthetics-abis.js +181 -0
- package/build/cjs/scripts/subsquid-codegen.js +1 -1
- package/build/cjs/src/abis/AbstractSubaccountApprovalNonceable.js +23 -0
- package/build/cjs/src/abis/CustomErrors.js +198 -88
- package/build/cjs/src/abis/ExchangeRouter.js +155 -272
- package/build/cjs/src/abis/GelatoRelayRouter.js +331 -0
- package/build/cjs/src/abis/SimulationRouter.js +583 -0
- package/build/cjs/src/abis/SubaccountGelatoRelayRouter.js +393 -0
- package/build/cjs/src/abis/SyntheticsReader.js +40 -0
- package/build/cjs/src/abis/index.js +4 -24
- package/build/cjs/src/clients/v1/modules/markets/index.js +10 -6
- package/build/cjs/src/clients/v1/modules/orders/utils.js +1 -0
- package/build/cjs/src/clients/v1/modules/orders/utils.spec.js +66 -0
- package/build/cjs/src/clients/v1/modules/positions/positions.js +2 -10
- package/build/cjs/src/clients/v1/modules/positions/positions.spec.js +1 -1
- package/build/cjs/src/clients/v1/modules/trades/trades.js +5 -1
- package/build/cjs/src/clients/v1/simulateExecuteOrder.js +33 -54
- package/build/cjs/src/clients/v1/testUtil.js +1 -1
- package/build/cjs/src/clients/v2/__tests__/editCancel.spec.js +3 -1
- package/build/cjs/src/clients/v2/__tests__/increase.spec.js +8 -6
- package/build/cjs/src/clients/v2/__tests__/subaccount.spec.js +270 -0
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +92 -1
- package/build/cjs/src/clients/v2/index.js +40 -57
- package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +0 -26
- package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +1692 -561
- package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +0 -47
- package/build/cjs/src/codegen/subsquid.js +101 -2
- package/build/cjs/src/configs/__tests__/tokens.spec.js +0 -1
- package/build/cjs/src/configs/api.js +0 -4
- package/build/cjs/src/configs/batch.js +0 -1
- package/build/cjs/src/configs/chainIds.js +1 -2
- package/build/cjs/src/configs/chains.js +2 -57
- package/build/cjs/src/configs/contracts.js +77 -133
- package/build/cjs/src/configs/dataStore.js +23 -8
- package/build/cjs/src/configs/express.js +0 -2
- package/build/cjs/src/configs/gasLimits.js +0 -7
- package/build/cjs/src/configs/markets.js +0 -23
- package/build/cjs/src/configs/multichainTokens.js +1 -1
- package/build/cjs/src/configs/oracleKeeper.js +0 -2
- package/build/cjs/src/configs/tokens.js +2 -104
- package/build/cjs/src/test/fixtures/arbitrumMarkets.json +1210 -0
- package/build/cjs/src/test/fixtures/arbitrumTickers.json +1002 -0
- package/build/cjs/src/test/fixtures/arbitrumTokens.json +136 -0
- package/build/cjs/src/test/mockCrossFetch.js +28 -0
- package/build/cjs/src/utils/__tests__/fees.spec.js +264 -0
- package/build/cjs/src/utils/__tests__/marketsRisk.spec.js +80 -0
- package/build/cjs/src/utils/__tests__/numbers.spec.js +49 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +6 -25
- package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +6 -25
- package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +3 -13
- package/build/cjs/src/utils/__tests__/parseError.spec.js +23 -0
- package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +159 -58
- package/build/cjs/src/utils/errors/parseError.js +13 -1
- package/build/cjs/src/utils/errors/transactionsErrors.js +2 -0
- package/build/cjs/src/utils/express/utils/batchOrderUtils.js +1 -2
- package/build/cjs/src/utils/express/utils/estimateExpressParams.js +2 -0
- package/build/cjs/src/utils/express/utils/estimateExpressParams.spec.js +81 -0
- package/build/cjs/src/utils/express/utils/expressParamsUtils.js +5 -1
- package/build/cjs/src/utils/express/utils/expressParamsUtils.spec.js +27 -0
- package/build/cjs/src/utils/fees/executionFee.js +0 -1
- package/build/cjs/src/utils/fees/priceImpact.js +61 -20
- package/build/cjs/src/utils/http/validation.js +33 -0
- package/build/cjs/src/utils/markets/__tests__/api.spec.js +168 -0
- package/build/cjs/src/utils/markets/__tests__/mockMarkets.js +14 -5
- package/build/cjs/src/utils/markets/api.js +45 -3
- package/build/cjs/src/utils/markets/hashKeys.js +34 -6
- package/build/cjs/src/utils/markets/multicall.js +110 -11
- package/build/cjs/src/utils/markets/types.js +23 -0
- package/build/cjs/src/utils/markets/utils.js +15 -1
- package/build/cjs/src/utils/numbers/utils.js +26 -5
- package/build/cjs/src/utils/orderTransactions/simulation.js +13 -0
- package/build/cjs/src/utils/orderTransactions/utils.js +21 -8
- package/build/cjs/src/utils/positions/__tests__/api.spec.js +50 -0
- package/build/cjs/src/utils/positions/api.js +7 -1
- package/build/cjs/src/utils/positions/utils.js +7 -1
- package/build/cjs/src/utils/prices/utils.js +2 -0
- package/build/cjs/src/utils/subaccount/index.js +11 -1
- package/build/cjs/src/utils/subaccount/sdkClient.js +366 -0
- package/build/cjs/src/utils/subaccount/state.js +76 -0
- package/build/cjs/src/utils/swap/buildSwapStrategy.js +6 -123
- package/build/cjs/src/utils/swap/index.js +0 -3
- package/build/cjs/src/utils/swap/swapValues.js +0 -67
- package/build/cjs/src/utils/tokens/utils.js +9 -10
- package/build/cjs/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +44 -0
- package/build/cjs/src/utils/trade/decrease.js +47 -23
- package/build/cjs/src/utils/trade/increase.js +22 -6
- package/build/cjs/src/utils/trade/types.js +0 -1
- package/build/cjs/src/utils/tradeHistory/types.js +3 -1
- package/build/cjs/src/utils/tradeHistory/utils.js +7 -0
- package/build/cjs/src/utils/twap/uiFeeReceiver.js +134 -47
- package/build/esm/scripts/generate-synthetics-abis.js +153 -0
- package/build/esm/scripts/subsquid-codegen.js +1 -1
- package/build/esm/src/abis/AbstractSubaccountApprovalNonceable.js +21 -0
- package/build/esm/src/abis/CustomErrors.js +198 -88
- package/build/esm/src/abis/ExchangeRouter.js +155 -272
- package/build/esm/src/abis/GelatoRelayRouter.js +331 -0
- package/build/esm/src/abis/SimulationRouter.js +581 -0
- package/build/esm/src/abis/SubaccountGelatoRelayRouter.js +393 -0
- package/build/esm/src/abis/SyntheticsReader.js +40 -0
- package/build/esm/src/abis/index.js +3 -23
- package/build/esm/src/clients/v1/modules/markets/index.js +10 -6
- package/build/esm/src/clients/v1/modules/orders/utils.js +1 -0
- package/build/esm/src/clients/v1/modules/orders/utils.spec.js +64 -0
- package/build/esm/src/clients/v1/modules/positions/positions.js +2 -10
- package/build/esm/src/clients/v1/modules/positions/positions.spec.js +1 -1
- package/build/esm/src/clients/v1/modules/trades/trades.js +5 -1
- package/build/esm/src/clients/v1/simulateExecuteOrder.js +35 -55
- package/build/esm/src/clients/v1/testUtil.js +1 -1
- package/build/esm/src/clients/v2/__tests__/editCancel.spec.js +3 -1
- package/build/esm/src/clients/v2/__tests__/increase.spec.js +8 -6
- package/build/esm/src/clients/v2/__tests__/subaccount.spec.js +271 -1
- package/build/esm/src/clients/v2/__tests__/swap.spec.js +1 -1
- package/build/esm/src/clients/v2/__tests__/testUtil.js +87 -0
- package/build/esm/src/clients/v2/index.js +40 -57
- package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +0 -26
- package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +1692 -561
- package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +0 -47
- package/build/esm/src/codegen/subsquid.js +99 -0
- package/build/esm/src/configs/__tests__/multichainTokens.spec.js +1 -1
- package/build/esm/src/configs/__tests__/tokens.spec.js +1 -2
- package/build/esm/src/configs/api.js +1 -5
- package/build/esm/src/configs/batch.js +1 -2
- package/build/esm/src/configs/chainIds.js +0 -1
- package/build/esm/src/configs/chains.js +3 -57
- package/build/esm/src/configs/contracts.js +76 -133
- package/build/esm/src/configs/dataStore.js +16 -4
- package/build/esm/src/configs/express.js +1 -3
- package/build/esm/src/configs/gasLimits.js +1 -8
- package/build/esm/src/configs/markets.js +1 -24
- package/build/esm/src/configs/multichainTokens.js +1 -1
- package/build/esm/src/configs/oracleKeeper.js +1 -3
- package/build/esm/src/configs/tokens.js +3 -105
- package/build/esm/src/test/fixtures/arbitrumMarkets.json +1210 -0
- package/build/esm/src/test/fixtures/arbitrumTickers.json +1002 -0
- package/build/esm/src/test/fixtures/arbitrumTokens.json +136 -0
- package/build/esm/src/test/mockCrossFetch.js +23 -0
- package/build/esm/src/utils/__tests__/fees.spec.js +266 -2
- package/build/esm/src/utils/__tests__/marketsRisk.spec.js +78 -0
- package/build/esm/src/utils/__tests__/numbers.spec.js +50 -1
- package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +6 -25
- package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +6 -25
- package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +3 -13
- package/build/esm/src/utils/__tests__/parseError.spec.js +25 -2
- package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +161 -60
- package/build/esm/src/utils/errors/parseError.js +12 -1
- package/build/esm/src/utils/errors/transactionsErrors.js +2 -0
- package/build/esm/src/utils/express/utils/batchOrderUtils.js +2 -3
- package/build/esm/src/utils/express/utils/estimateExpressParams.js +2 -0
- package/build/esm/src/utils/express/utils/estimateExpressParams.spec.js +79 -0
- package/build/esm/src/utils/express/utils/expressParamsUtils.js +3 -0
- package/build/esm/src/utils/express/utils/expressParamsUtils.spec.js +25 -0
- package/build/esm/src/utils/fees/executionFee.js +0 -1
- package/build/esm/src/utils/fees/priceImpact.js +54 -13
- package/build/esm/src/utils/http/validation.js +28 -0
- package/build/esm/src/utils/markets/__tests__/api.spec.js +166 -0
- package/build/esm/src/utils/markets/__tests__/mockMarkets.js +15 -6
- package/build/esm/src/utils/markets/api.js +42 -2
- package/build/esm/src/utils/markets/hashKeys.js +35 -7
- package/build/esm/src/utils/markets/multicall.js +108 -11
- package/build/esm/src/utils/markets/types.js +22 -1
- package/build/esm/src/utils/markets/utils.js +13 -0
- package/build/esm/src/utils/numbers/utils.js +21 -3
- package/build/esm/src/utils/orderTransactions/simulation.js +9 -0
- package/build/esm/src/utils/orderTransactions/utils.js +22 -9
- package/build/esm/src/utils/positions/__tests__/api.spec.js +48 -0
- package/build/esm/src/utils/positions/api.js +7 -1
- package/build/esm/src/utils/positions/utils.js +7 -1
- package/build/esm/src/utils/prices/utils.js +2 -0
- package/build/esm/src/utils/subaccount/index.js +1 -0
- package/build/esm/src/utils/subaccount/sdkClient.js +351 -0
- package/build/esm/src/utils/subaccount/state.js +64 -0
- package/build/esm/src/utils/swap/buildSwapStrategy.js +7 -124
- package/build/esm/src/utils/swap/index.js +0 -3
- package/build/esm/src/utils/swap/swapValues.js +1 -68
- package/build/esm/src/utils/tokens/utils.js +8 -8
- package/build/esm/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +45 -1
- package/build/esm/src/utils/trade/decrease.js +44 -22
- package/build/esm/src/utils/trade/increase.js +23 -7
- package/build/esm/src/utils/trade/types.js +0 -1
- package/build/esm/src/utils/tradeHistory/types.js +2 -0
- package/build/esm/src/utils/tradeHistory/utils.js +7 -0
- package/build/esm/src/utils/twap/uiFeeReceiver.js +127 -42
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/scripts/generate-synthetics-abis.d.ts +17 -0
- package/build/types/src/abis/AbstractSubaccountApprovalNonceable.d.ts +16 -0
- package/build/types/src/abis/CustomErrors.d.ts +331 -139
- package/build/types/src/abis/ExchangeRouter.d.ts +121 -209
- package/build/types/src/abis/GelatoRelayRouter.d.ts +258 -0
- package/build/types/src/abis/SimulationRouter.d.ts +448 -0
- package/build/types/src/abis/SubaccountGelatoRelayRouter.d.ts +307 -0
- package/build/types/src/abis/SyntheticsReader.d.ts +32 -0
- package/build/types/src/abis/index.d.ts +8108 -7891
- package/build/types/src/clients/v1/index.d.ts +1 -1
- package/build/types/src/clients/v1/modules/base.d.ts +1 -1
- package/build/types/src/clients/v1/modules/orders/utils.spec.d.ts +1 -0
- package/build/types/src/clients/v1/multicall.d.ts +1 -1
- package/build/types/src/clients/v1/simulateExecuteOrder.d.ts +0 -1
- package/build/types/src/clients/v2/__tests__/testUtil.d.ts +37 -1
- package/build/types/src/clients/v2/index.d.ts +10 -2
- package/build/types/src/codegen/prebuilt/index.d.ts +1692 -634
- package/build/types/src/codegen/subsquid.d.ts +368 -0
- package/build/types/src/configs/chainIds.d.ts +0 -1
- package/build/types/src/configs/chains.d.ts +9 -34
- package/build/types/src/configs/contracts.d.ts +5 -66
- package/build/types/src/configs/dataStore.d.ts +8 -2
- package/build/types/src/configs/multichainTokens.d.ts +1 -1
- package/build/types/src/test/mockCrossFetch.d.ts +2 -0
- package/build/types/src/utils/__tests__/marketsRisk.spec.d.ts +1 -0
- package/build/types/src/utils/errors/parseError.d.ts +1 -0
- package/build/types/src/utils/errors/transactionsErrors.d.ts +2 -0
- package/build/types/src/utils/express/types.d.ts +2 -1
- package/build/types/src/utils/express/utils/batchOrderUtils.d.ts +1 -1
- package/build/types/src/utils/express/utils/estimateExpressParams.spec.d.ts +1 -0
- package/build/types/src/utils/express/utils/expressParamsUtils.d.ts +1 -0
- package/build/types/src/utils/express/utils/expressParamsUtils.spec.d.ts +1 -0
- package/build/types/src/utils/express/utils/globalExpressParams.d.ts +1 -1
- package/build/types/src/utils/fees/priceImpact.d.ts +2 -0
- package/build/types/src/utils/http/validation.d.ts +7 -0
- package/build/types/src/utils/markets/__tests__/api.spec.d.ts +1 -0
- package/build/types/src/utils/markets/api.d.ts +7 -1
- package/build/types/src/utils/markets/hashKeys.d.ts +1 -1
- package/build/types/src/utils/markets/multicall.d.ts +13 -2
- package/build/types/src/utils/markets/types.d.ts +18 -4
- package/build/types/src/utils/markets/utils.d.ts +2 -1
- package/build/types/src/utils/numbers/utils.d.ts +5 -1
- package/build/types/src/utils/orderTransactions/simulation.d.ts +1 -0
- package/build/types/src/utils/orders/types.d.ts +2 -0
- package/build/types/src/utils/positions/__tests__/api.spec.d.ts +1 -0
- package/build/types/src/utils/positions/types.d.ts +1 -0
- package/build/types/src/utils/positions/utils.d.ts +1 -0
- package/build/types/src/utils/prices/utils.d.ts +1 -0
- package/build/types/src/utils/subaccount/index.d.ts +1 -0
- package/build/types/src/utils/subaccount/sdkClient.d.ts +36 -0
- package/build/types/src/utils/subaccount/state.d.ts +11 -0
- package/build/types/src/utils/subaccount/types.d.ts +18 -0
- package/build/types/src/utils/swap/buildSwapStrategy.d.ts +3 -5
- package/build/types/src/utils/swap/index.d.ts +0 -3
- package/build/types/src/utils/swap/swapValues.d.ts +1 -1
- package/build/types/src/utils/swap/types.d.ts +2 -7
- package/build/types/src/utils/tokens/types.d.ts +0 -1
- package/build/types/src/utils/tokens/utils.d.ts +1 -2
- package/build/types/src/utils/trade/decrease.d.ts +11 -0
- package/build/types/src/utils/trade/types.d.ts +2 -8
- package/build/types/src/utils/tradeHistory/types.d.ts +7 -0
- package/build/types/src/utils/twap/types.d.ts +1 -1
- package/build/types/src/utils/twap/uiFeeReceiver.d.ts +23 -22
- package/package.json +10 -7
- package/build/cjs/src/abis/StBTC.js +0 -513
- package/build/cjs/src/utils/swap/botanixStaking.js +0 -90
- package/build/cjs/src/utils/swap/externalSwapPath.js +0 -41
- package/build/cjs/src/utils/swap/externalSwapQuoteByPath.js +0 -27
- package/build/esm/src/abis/StBTC.js +0 -511
- package/build/esm/src/utils/swap/botanixStaking.js +0 -83
- package/build/esm/src/utils/swap/externalSwapPath.js +0 -37
- package/build/esm/src/utils/swap/externalSwapQuoteByPath.js +0 -23
- package/build/types/src/abis/StBTC.d.ts +0 -932
- package/build/types/src/utils/swap/botanixStaking.d.ts +0 -11
- package/build/types/src/utils/swap/externalSwapPath.d.ts +0 -13
- package/build/types/src/utils/swap/externalSwapQuoteByPath.d.ts +0 -6
|
@@ -41,6 +41,7 @@ export declare const CONTRACTS: {
|
|
|
41
41
|
ShiftVault: string;
|
|
42
42
|
SyntheticsReader: string;
|
|
43
43
|
SyntheticsRouter: string;
|
|
44
|
+
SimulationRouter: string;
|
|
44
45
|
GlvReader: string;
|
|
45
46
|
GlvRouter: string;
|
|
46
47
|
GlvVault: string;
|
|
@@ -103,6 +104,7 @@ export declare const CONTRACTS: {
|
|
|
103
104
|
ShiftVault: string;
|
|
104
105
|
SyntheticsReader: string;
|
|
105
106
|
SyntheticsRouter: string;
|
|
107
|
+
SimulationRouter: string;
|
|
106
108
|
GlvReader: string;
|
|
107
109
|
GlvRouter: string;
|
|
108
110
|
GlvVault: string;
|
|
@@ -125,72 +127,6 @@ export declare const CONTRACTS: {
|
|
|
125
127
|
LayerZeroEndpoint: string;
|
|
126
128
|
GelatoRelayAddress: string;
|
|
127
129
|
};
|
|
128
|
-
3637: {
|
|
129
|
-
DataStore: string;
|
|
130
|
-
EventEmitter: string;
|
|
131
|
-
SubaccountRouter: string;
|
|
132
|
-
ExchangeRouter: string;
|
|
133
|
-
DepositVault: string;
|
|
134
|
-
WithdrawalVault: string;
|
|
135
|
-
OrderVault: string;
|
|
136
|
-
ShiftVault: string;
|
|
137
|
-
SyntheticsReader: string;
|
|
138
|
-
SyntheticsRouter: string;
|
|
139
|
-
GlvReader: string;
|
|
140
|
-
GlvRouter: string;
|
|
141
|
-
GlvVault: string;
|
|
142
|
-
GelatoRelayRouter: string;
|
|
143
|
-
SubaccountGelatoRelayRouter: string;
|
|
144
|
-
MultichainClaimsRouter: string;
|
|
145
|
-
MultichainGlvRouter: string;
|
|
146
|
-
MultichainGmRouter: string;
|
|
147
|
-
MultichainOrderRouter: string;
|
|
148
|
-
MultichainSubaccountRouter: string;
|
|
149
|
-
MultichainTransferRouter: string;
|
|
150
|
-
MultichainVault: string;
|
|
151
|
-
LayerZeroProvider: string;
|
|
152
|
-
ChainlinkPriceFeedProvider: string;
|
|
153
|
-
ClaimHandler: string;
|
|
154
|
-
ExternalHandler: string;
|
|
155
|
-
KyberSwapRouter: "0x0000000000000000000000000000000000000000";
|
|
156
|
-
Multicall: string;
|
|
157
|
-
LayerZeroEndpoint: string;
|
|
158
|
-
ArbitrumNodeInterface: "0x0000000000000000000000000000000000000000";
|
|
159
|
-
GelatoRelayAddress: string;
|
|
160
|
-
Vault: "0x0000000000000000000000000000000000000000";
|
|
161
|
-
Reader: "0x0000000000000000000000000000000000000000";
|
|
162
|
-
PositionRouter: "0x0000000000000000000000000000000000000000";
|
|
163
|
-
ReferralStorage: "0x0000000000000000000000000000000000000000";
|
|
164
|
-
VaultReader: "0x0000000000000000000000000000000000000000";
|
|
165
|
-
GlpManager: "0x0000000000000000000000000000000000000000";
|
|
166
|
-
RewardRouter: "0x0000000000000000000000000000000000000000";
|
|
167
|
-
RewardReader: "0x0000000000000000000000000000000000000000";
|
|
168
|
-
GlpRewardRouter: "0x0000000000000000000000000000000000000000";
|
|
169
|
-
StakedGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
170
|
-
FeeGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
171
|
-
GLP: "0x0000000000000000000000000000000000000000";
|
|
172
|
-
GMX: "0x0000000000000000000000000000000000000000";
|
|
173
|
-
ES_GMX: "0x0000000000000000000000000000000000000000";
|
|
174
|
-
BN_GMX: "0x0000000000000000000000000000000000000000";
|
|
175
|
-
USDG: "0x0000000000000000000000000000000000000000";
|
|
176
|
-
BonusGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
177
|
-
StakedGlpTracker: "0x0000000000000000000000000000000000000000";
|
|
178
|
-
FeeGlpTracker: "0x0000000000000000000000000000000000000000";
|
|
179
|
-
ExtendedGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
180
|
-
StakedGmxDistributor: "0x0000000000000000000000000000000000000000";
|
|
181
|
-
StakedGlpDistributor: "0x0000000000000000000000000000000000000000";
|
|
182
|
-
GmxVester: "0x0000000000000000000000000000000000000000";
|
|
183
|
-
GlpVester: "0x0000000000000000000000000000000000000000";
|
|
184
|
-
AffiliateVester: "0x0000000000000000000000000000000000000000";
|
|
185
|
-
Router: "0x0000000000000000000000000000000000000000";
|
|
186
|
-
GovToken: "0x0000000000000000000000000000000000000000";
|
|
187
|
-
ES_GMX_IOU: "0x0000000000000000000000000000000000000000";
|
|
188
|
-
OrderBook: "0x0000000000000000000000000000000000000000";
|
|
189
|
-
UniswapGmxEthPool: "0x0000000000000000000000000000000000000000";
|
|
190
|
-
NATIVE_TOKEN: string;
|
|
191
|
-
StBTC: string;
|
|
192
|
-
PBTC: string;
|
|
193
|
-
};
|
|
194
130
|
4326: {
|
|
195
131
|
DataStore: string;
|
|
196
132
|
EventEmitter: string;
|
|
@@ -202,6 +138,7 @@ export declare const CONTRACTS: {
|
|
|
202
138
|
ShiftVault: string;
|
|
203
139
|
SyntheticsReader: string;
|
|
204
140
|
SyntheticsRouter: string;
|
|
141
|
+
SimulationRouter: string;
|
|
205
142
|
GlvReader: string;
|
|
206
143
|
GlvRouter: string;
|
|
207
144
|
GlvVault: string;
|
|
@@ -327,6 +264,7 @@ export declare const CONTRACTS: {
|
|
|
327
264
|
ShiftVault: string;
|
|
328
265
|
SyntheticsReader: string;
|
|
329
266
|
SyntheticsRouter: string;
|
|
267
|
+
SimulationRouter: string;
|
|
330
268
|
GlvReader: string;
|
|
331
269
|
GlvRouter: string;
|
|
332
270
|
GlvVault: string;
|
|
@@ -383,4 +321,5 @@ type ExtractContractNames<T extends object> = {
|
|
|
383
321
|
}[keyof T];
|
|
384
322
|
export type ContractName = ExtractContractNames<typeof CONTRACTS>;
|
|
385
323
|
export declare function getContract(chainId: ContractsChainId, name: ContractName): Address;
|
|
324
|
+
export declare function tryGetContract(chainId: ContractsChainId, name: ContractName): Address | undefined;
|
|
386
325
|
export {};
|
|
@@ -20,6 +20,7 @@ export declare const MAX_POOL_AMOUNT_KEY: string;
|
|
|
20
20
|
export declare const RESERVE_FACTOR_KEY: string;
|
|
21
21
|
export declare const OPEN_INTEREST_RESERVE_FACTOR_KEY: string;
|
|
22
22
|
export declare const MAX_OPEN_INTEREST_KEY: string;
|
|
23
|
+
export declare const MAX_COLLATERAL_SUM_KEY: string;
|
|
23
24
|
export declare const NONCE_KEY: string;
|
|
24
25
|
export declare const BORROWING_FACTOR_KEY: string;
|
|
25
26
|
export declare const BORROWING_EXPONENT_FACTOR_KEY: string;
|
|
@@ -28,6 +29,7 @@ export declare const TOTAL_BORROWING_KEY: string;
|
|
|
28
29
|
export declare const FUNDING_FACTOR_KEY: string;
|
|
29
30
|
export declare const FUNDING_EXPONENT_FACTOR_KEY: string;
|
|
30
31
|
export declare const FUNDING_INCREASE_FACTOR_PER_SECOND: string;
|
|
32
|
+
export declare const MIN_FUNDING_INCREASE_RATE_PER_SECOND: string;
|
|
31
33
|
export declare const FUNDING_DECREASE_FACTOR_PER_SECOND: string;
|
|
32
34
|
export declare const MIN_FUNDING_FACTOR_PER_SECOND: string;
|
|
33
35
|
export declare const MAX_FUNDING_FACTOR_PER_SECOND: string;
|
|
@@ -74,6 +76,7 @@ export declare const CLAIMABLE_FUNDING_AMOUNT: string;
|
|
|
74
76
|
export declare const VIRTUAL_TOKEN_ID_KEY: string;
|
|
75
77
|
export declare const VIRTUAL_MARKET_ID_KEY: string;
|
|
76
78
|
export declare const VIRTUAL_INVENTORY_FOR_POSITIONS_KEY: string;
|
|
79
|
+
export declare const VIRTUAL_INVENTORY_FOR_POSITIONS_IN_TOKENS_KEY: string;
|
|
77
80
|
export declare const VIRTUAL_INVENTORY_FOR_SWAPS_KEY: string;
|
|
78
81
|
export declare const AFFILIATE_REWARD_KEY: string;
|
|
79
82
|
export declare const IS_MARKET_DISABLED_KEY: string;
|
|
@@ -128,6 +131,7 @@ export declare function poolAmountKey(market: string, token: string): string;
|
|
|
128
131
|
export declare function reserveFactorKey(market: string, isLong: boolean): string;
|
|
129
132
|
export declare function openInterestReserveFactorKey(market: string, isLong: boolean): string;
|
|
130
133
|
export declare function maxOpenInterestKey(market: string, isLong: boolean): string;
|
|
134
|
+
export declare function maxCollateralSumKey(market: string, collateralToken: string, isLong: boolean): string;
|
|
131
135
|
export declare function borrowingFactorKey(market: string, isLong: boolean): string;
|
|
132
136
|
export declare function borrowingExponentFactorKey(market: string, isLong: boolean): string;
|
|
133
137
|
export declare function cumulativeBorrowingFactorKey(market: string, isLong: boolean): string;
|
|
@@ -135,9 +139,10 @@ export declare function totalBorrowingKey(market: string, isLong: boolean): stri
|
|
|
135
139
|
export declare function fundingFactorKey(market: string): string;
|
|
136
140
|
export declare function fundingExponentFactorKey(market: string): string;
|
|
137
141
|
export declare function fundingIncreaseFactorPerSecondKey(market: string): string;
|
|
142
|
+
export declare function minFundingIncreaseRatePerSecondKey(market: string): string;
|
|
138
143
|
export declare function fundingDecreaseFactorPerSecondKey(market: string): string;
|
|
139
|
-
export declare function minFundingFactorPerSecondKey(market: string): string;
|
|
140
|
-
export declare function maxFundingFactorPerSecondKey(market: string): string;
|
|
144
|
+
export declare function minFundingFactorPerSecondKey(market: string, isLong: boolean): string;
|
|
145
|
+
export declare function maxFundingFactorPerSecondKey(market: string, isLong: boolean): string;
|
|
141
146
|
export declare function thresholdForStableFundingKey(market: string): string;
|
|
142
147
|
export declare function thresholdForDecreaseFundingKey(market: string): string;
|
|
143
148
|
export declare function maxPnlFactorKey(pnlFactorType: string, market: string, isLong: boolean): string;
|
|
@@ -164,6 +169,7 @@ export declare function virtualTokenIdKey(token: string): string;
|
|
|
164
169
|
export declare function virtualMarketIdKey(market: string): string;
|
|
165
170
|
export declare function virtualInventoryForSwapsKey(virtualMarketId: string, token: string): string;
|
|
166
171
|
export declare function virtualInventoryForPositionsKey(virtualTokenId: string): string;
|
|
172
|
+
export declare function virtualInventoryForPositionsInTokensKey(virtualTokenId: string): string;
|
|
167
173
|
export declare function affiliateRewardKey(market: string, token: string, account: string): string;
|
|
168
174
|
export declare function isMarketDisabledKey(market: string): string;
|
|
169
175
|
export declare function maxPoolUsdForDepositKey(market: string, token: string): string;
|
|
@@ -14,7 +14,7 @@ export type MultichainTokenGroups = Partial<Record<string, Partial<Record<Settle
|
|
|
14
14
|
* Returns the full multichain token registry. By default returns mainnet-only;
|
|
15
15
|
* pass `includeTestnets: true` to also expose Sepolia/Fuji/USDC.SG entries.
|
|
16
16
|
*/
|
|
17
|
-
export declare function getMultichainTokenGroups({ includeTestnets }?: {
|
|
17
|
+
export declare function getMultichainTokenGroups({ includeTestnets, }?: {
|
|
18
18
|
includeTestnets?: boolean;
|
|
19
19
|
}): MultichainTokenGroups;
|
|
20
20
|
export declare function getMultichainTokenId(groups: MultichainTokenGroups, chainId: number, tokenAddress: string): MultichainTokenId | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -74,3 +74,4 @@ export type ParsedCustomError = {
|
|
|
74
74
|
};
|
|
75
75
|
export declare function tryDecodeCustomError(reasonBytes: string): ParsedCustomError | undefined;
|
|
76
76
|
export declare function decodeErrorFromViemError(error: any): ParsedCustomError | undefined;
|
|
77
|
+
export declare function decodeSimulationErrorFromViemError(error: any): ParsedCustomError | undefined;
|
|
@@ -31,9 +31,11 @@ export declare enum CustomErrorName {
|
|
|
31
31
|
LiquidatablePosition = "LiquidatablePosition",
|
|
32
32
|
MarketNotFound = "MarketNotFound",
|
|
33
33
|
MaxOpenInterestExceeded = "MaxOpenInterestExceeded",
|
|
34
|
+
MaxCollateralSumExceeded = "MaxCollateralSumExceeded",
|
|
34
35
|
MaxPoolAmountExceeded = "MaxPoolAmountExceeded",
|
|
35
36
|
MaxPoolUsdForDepositExceeded = "MaxPoolUsdForDepositExceeded",
|
|
36
37
|
MaxPriceAgeExceeded = "MaxPriceAgeExceeded",
|
|
38
|
+
MaxRelayFeeSwapExceeded = "MaxRelayFeeSwapExceeded",
|
|
37
39
|
MinPositionSize = "MinPositionSize",
|
|
38
40
|
NegativeExecutionPrice = "NegativeExecutionPrice",
|
|
39
41
|
OrderNotFound = "OrderNotFound",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExternalCallsPayload } from "../orderTransactions";
|
|
2
2
|
import type { Subaccount, SubaccountValidations } from "../subaccount";
|
|
3
3
|
import type { SignedTokenPermit, TokenData } from "../tokens/types";
|
|
4
|
-
export type { Subaccount, SubaccountOnchainData, SubaccountSerializedConfig, SignedSubaccountApproval, SubaccountValidations } from "../subaccount";
|
|
4
|
+
export type { Subaccount, SubaccountOnchainData, SubaccountSerializedConfig, SignedSubaccountApproval, SubaccountValidations, } from "../subaccount";
|
|
5
5
|
export type OracleParamsPayload = {
|
|
6
6
|
tokens: string[];
|
|
7
7
|
providers: string[];
|
|
@@ -36,6 +36,7 @@ export type GasPaymentParams = {
|
|
|
36
36
|
gasPaymentTokenAsCollateralAmount: bigint;
|
|
37
37
|
};
|
|
38
38
|
export type GasPaymentValidations = {
|
|
39
|
+
isGasPaymentTokenBalanceLoaded: boolean;
|
|
39
40
|
isOutGasTokenBalance: boolean;
|
|
40
41
|
needGasPaymentTokenApproval: boolean;
|
|
41
42
|
isValid: boolean;
|
|
@@ -33,9 +33,9 @@ export declare function getBatchParamsLists(batchParams: BatchOrderTxnParams): {
|
|
|
33
33
|
createOrderParamsList: {
|
|
34
34
|
addresses: {
|
|
35
35
|
receiver: string;
|
|
36
|
-
uiFeeReceiver: string;
|
|
37
36
|
cancellationReceiver: string;
|
|
38
37
|
callbackContract: string;
|
|
38
|
+
uiFeeReceiver: string;
|
|
39
39
|
market: string;
|
|
40
40
|
initialCollateralToken: import("../../tokens").ERC20Address;
|
|
41
41
|
swapPath: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,3 +17,4 @@ export declare function getIsValidExpressParams({ gasPaymentValidations, }: {
|
|
|
17
17
|
gasPaymentValidations: GasPaymentValidations;
|
|
18
18
|
[key: string]: unknown;
|
|
19
19
|
}): boolean;
|
|
20
|
+
export declare function getIsConfirmedOutOfGasPaymentTokenBalance(gasPaymentValidations: Pick<GasPaymentValidations, "isOutGasTokenBalance" | "isGasPaymentTokenBalanceLoaded"> | undefined): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,7 +14,7 @@ export type GlobalExpressParams = {
|
|
|
14
14
|
bufferBps?: number;
|
|
15
15
|
};
|
|
16
16
|
export declare function buildGlobalExpressParams({ chainId, gasLimits, gasPrice, tokensData, marketsInfoData, gasPaymentTokenAddress, tokenPermits, l1Reference, bufferBps, }: GlobalExpressParams): {
|
|
17
|
-
chainId: 43114 | 42161 |
|
|
17
|
+
chainId: 43114 | 42161 | 4326 | 43113 | 421614;
|
|
18
18
|
gasLimits: GasLimitsConfig;
|
|
19
19
|
gasPrice: bigint;
|
|
20
20
|
tokensData: TokensData;
|
|
@@ -20,6 +20,7 @@ export declare function applySwapImpactWithCap(marketInfo: MarketInfo, token: To
|
|
|
20
20
|
export declare function getCappedPositionImpactUsd(marketInfo: MarketInfo, sizeDeltaUsd: bigint, isLong: boolean, isIncrease: boolean, opts?: {
|
|
21
21
|
fallbackToZero?: boolean;
|
|
22
22
|
shouldCapNegativeImpact?: boolean;
|
|
23
|
+
sizeDeltaInTokens?: bigint;
|
|
23
24
|
}): {
|
|
24
25
|
priceImpactDeltaUsd: bigint;
|
|
25
26
|
balanceWasImproved: boolean;
|
|
@@ -32,6 +33,7 @@ export declare function getMaxPositionImpactFactors(marketInfo: MarketInfo): {
|
|
|
32
33
|
};
|
|
33
34
|
export declare function getPriceImpactForPosition(marketInfo: MarketInfo, sizeDeltaUsd: bigint, isLong: boolean, opts?: {
|
|
34
35
|
fallbackToZero?: boolean;
|
|
36
|
+
sizeDeltaInTokens?: bigint;
|
|
35
37
|
}): {
|
|
36
38
|
priceImpactDeltaUsd: bigint;
|
|
37
39
|
balanceWasImproved: boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ApiFieldType = "bigint" | "boolean" | "number" | "numberOrNull" | "string";
|
|
2
|
+
export type ApiFieldSpec = {
|
|
3
|
+
name: string;
|
|
4
|
+
type: ApiFieldType;
|
|
5
|
+
};
|
|
6
|
+
export declare function assertApiRecords(value: unknown, endpoint: string): asserts value is Record<string, unknown>[];
|
|
7
|
+
export declare function assertApiFields(record: Record<string, unknown>, fields: readonly ApiFieldSpec[], endpoint: string, index: number): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { IHttp } from "../http/types";
|
|
2
2
|
import { TokenData } from "../tokens/types";
|
|
3
|
-
import { MarketTicker, MarketWithTiers, RawMarketInfo } from "./types";
|
|
3
|
+
import { MarketTicker, MarketWithTiers, RawMarketConfig, RawMarketInfo, RawMarketValues } from "./types";
|
|
4
4
|
export declare function fetchApiMarketsInfo(ctx: {
|
|
5
5
|
api: IHttp;
|
|
6
6
|
}): Promise<RawMarketInfo[]>;
|
|
7
|
+
export declare function fetchApiMarketsConfig(ctx: {
|
|
8
|
+
api: IHttp;
|
|
9
|
+
}): Promise<RawMarketConfig[]>;
|
|
10
|
+
export declare function fetchApiMarketsValues(ctx: {
|
|
11
|
+
api: IHttp;
|
|
12
|
+
}): Promise<RawMarketValues[]>;
|
|
7
13
|
export declare function fetchApiTokensData(ctx: {
|
|
8
14
|
api: IHttp;
|
|
9
15
|
}): Promise<TokenData[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarketConfig as MarketConfigInput } from "../../configs/markets";
|
|
2
2
|
import type { MarketConfig, MarketValues, RawOpenInterestValues } from "./types";
|
|
3
3
|
export type MarketConfigKeysHash = {
|
|
4
|
-
[K in keyof MarketConfig]: string;
|
|
4
|
+
[K in Exclude<keyof MarketConfig, "virtualIndexTokenId">]: string;
|
|
5
5
|
};
|
|
6
6
|
type RawMarketValuesKeys = Pick<MarketValues, "longPoolAmount" | "shortPoolAmount" | "positionImpactPoolAmount" | "swapImpactPoolAmountLong" | "swapImpactPoolAmountShort">;
|
|
7
7
|
export type MarketValuesKeysHash = {
|
|
@@ -6,20 +6,31 @@ type MulticallResponse = {
|
|
|
6
6
|
data: Record<string, any>;
|
|
7
7
|
errors: Record<string, any>;
|
|
8
8
|
};
|
|
9
|
+
export type MarketRiskInput = {
|
|
10
|
+
marketTokenAddress: string;
|
|
11
|
+
longTokenAddress: string;
|
|
12
|
+
shortTokenAddress: string;
|
|
13
|
+
virtualIndexTokenId: string;
|
|
14
|
+
};
|
|
15
|
+
export type MarketRiskValues = Pick<MarketConfig & MarketValues, "maxCollateralSumLongTokenLong" | "maxCollateralSumLongTokenShort" | "maxCollateralSumShortTokenLong" | "maxCollateralSumShortTokenShort" | "virtualInventoryForPositionsInTokens">;
|
|
16
|
+
export declare function buildMarketsRiskValuesRequest(chainId: ContractsChainId, markets: MarketRiskInput[]): Record<string, ContractCallsConfig<any>>;
|
|
17
|
+
export declare function parseMarketsRiskValuesResponse(res: MulticallResponse, markets: MarketRiskInput[]): Record<string, MarketRiskValues>;
|
|
9
18
|
export declare function buildClaimableFundingDataRequest({ marketsAddresses, marketsData, chainId, account, }: {
|
|
10
19
|
marketsAddresses: string[] | undefined;
|
|
11
20
|
marketsData: MarketsData | undefined;
|
|
12
21
|
account: string;
|
|
13
22
|
chainId: ContractsChainId;
|
|
14
23
|
}): Record<string, ContractCallsConfig<any>>;
|
|
15
|
-
export declare function buildMarketsValuesRequest(chainId: ContractsChainId, { marketsAddresses, marketsData, tokensData, }: {
|
|
24
|
+
export declare function buildMarketsValuesRequest(chainId: ContractsChainId, { marketsAddresses, marketsData, marketsConfigsData, tokensData, }: {
|
|
16
25
|
marketsAddresses: string[] | undefined;
|
|
17
26
|
marketsData: MarketsData | undefined;
|
|
27
|
+
marketsConfigsData: Record<string, MarketConfig> | undefined;
|
|
18
28
|
tokensData: TokensData | undefined;
|
|
19
29
|
}): Promise<Record<string, ContractCallsConfig<any>>>;
|
|
20
30
|
export declare function parseMarketsValuesResponse(res: MulticallResponse, marketsAddresses: string[], marketsData: MarketsData | undefined, getMarketDivisor: (market: any) => bigint): Record<string, MarketValues>;
|
|
21
|
-
export declare function buildMarketsConfigsRequest(chainId: ContractsChainId, { marketsAddresses, }: {
|
|
31
|
+
export declare function buildMarketsConfigsRequest(chainId: ContractsChainId, { marketsAddresses, marketsData, }: {
|
|
22
32
|
marketsAddresses: string[] | undefined;
|
|
33
|
+
marketsData: MarketsData | undefined;
|
|
23
34
|
}): Promise<Record<string, ContractCallsConfig<any>>>;
|
|
24
35
|
export declare function parseMarketsConfigsResponse(res: MulticallResponse, marketsAddresses: string[]): Record<string, MarketConfig>;
|
|
25
36
|
export {};
|
|
@@ -38,6 +38,10 @@ export type MarketInfo = Market & MarketPoolTokens & {
|
|
|
38
38
|
openInterestReserveFactorShort: bigint;
|
|
39
39
|
maxOpenInterestLong: bigint;
|
|
40
40
|
maxOpenInterestShort: bigint;
|
|
41
|
+
maxCollateralSumLongTokenLong: bigint;
|
|
42
|
+
maxCollateralSumLongTokenShort: bigint;
|
|
43
|
+
maxCollateralSumShortTokenLong: bigint;
|
|
44
|
+
maxCollateralSumShortTokenShort: bigint;
|
|
41
45
|
borrowingFactorLong: bigint;
|
|
42
46
|
borrowingFactorShort: bigint;
|
|
43
47
|
borrowingExponentFactorLong: bigint;
|
|
@@ -45,11 +49,14 @@ export type MarketInfo = Market & MarketPoolTokens & {
|
|
|
45
49
|
fundingFactor: bigint;
|
|
46
50
|
fundingExponentFactor: bigint;
|
|
47
51
|
fundingIncreaseFactorPerSecond: bigint;
|
|
52
|
+
minFundingIncreaseRatePerSecond: bigint;
|
|
48
53
|
fundingDecreaseFactorPerSecond: bigint;
|
|
49
54
|
thresholdForStableFunding: bigint;
|
|
50
55
|
thresholdForDecreaseFunding: bigint;
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
minFundingFactorPerSecondLong: bigint;
|
|
57
|
+
minFundingFactorPerSecondShort: bigint;
|
|
58
|
+
maxFundingFactorPerSecondLong: bigint;
|
|
59
|
+
maxFundingFactorPerSecondShort: bigint;
|
|
53
60
|
totalBorrowingFees: bigint;
|
|
54
61
|
positionImpactPoolAmount: bigint;
|
|
55
62
|
minPositionImpactPoolAmount: bigint;
|
|
@@ -101,7 +108,9 @@ export type MarketInfo = Market & MarketPoolTokens & {
|
|
|
101
108
|
virtualPoolAmountForLongToken: bigint;
|
|
102
109
|
virtualPoolAmountForShortToken: bigint;
|
|
103
110
|
virtualInventoryForPositions: bigint;
|
|
111
|
+
virtualInventoryForPositionsInTokens: bigint;
|
|
104
112
|
virtualMarketId: string;
|
|
113
|
+
virtualIndexTokenId: string;
|
|
105
114
|
virtualLongTokenId: string;
|
|
106
115
|
virtualShortTokenId: string;
|
|
107
116
|
};
|
|
@@ -115,14 +124,15 @@ export type RawOpenInterestValues = {
|
|
|
115
124
|
shortInterestInTokensUsingLongToken: bigint;
|
|
116
125
|
shortInterestInTokensUsingShortToken: bigint;
|
|
117
126
|
};
|
|
127
|
+
export declare const MARKET_VALUES_KEYS: readonly ["longInterestUsd", "shortInterestUsd", "longInterestInTokens", "shortInterestInTokens", "longPoolAmount", "shortPoolAmount", "poolValueMin", "poolValueMax", "totalBorrowingFees", "positionImpactPoolAmount", "swapImpactPoolAmountLong", "swapImpactPoolAmountShort", "borrowingFactorPerSecondForLongs", "borrowingFactorPerSecondForShorts", "fundingFactorPerSecond", "longsPayShorts", "virtualPoolAmountForLongToken", "virtualPoolAmountForShortToken", "virtualInventoryForPositions", "virtualInventoryForPositionsInTokens"];
|
|
118
128
|
/**
|
|
119
129
|
* Updates frequently
|
|
120
130
|
*/
|
|
121
|
-
export type MarketValues = Pick<MarketInfo,
|
|
131
|
+
export type MarketValues = Pick<MarketInfo, (typeof MARKET_VALUES_KEYS)[number]>;
|
|
122
132
|
/**
|
|
123
133
|
* Updates seldom
|
|
124
134
|
*/
|
|
125
|
-
export type MarketConfig = Pick<MarketInfo, "isDisabled" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "maxLongPoolAmount" | "maxShortPoolAmount" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForDecreaseFunding" | "thresholdForStableFunding" | "
|
|
135
|
+
export type MarketConfig = Pick<MarketInfo, "isDisabled" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "maxLongPoolAmount" | "maxShortPoolAmount" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "maxCollateralSumLongTokenLong" | "maxCollateralSumLongTokenShort" | "maxCollateralSumShortTokenLong" | "maxCollateralSumShortTokenShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "minFundingIncreaseRatePerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForDecreaseFunding" | "thresholdForStableFunding" | "minFundingFactorPerSecondLong" | "minFundingFactorPerSecondShort" | "maxFundingFactorPerSecondLong" | "maxFundingFactorPerSecondShort" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "maxPnlFactorForDepositsLong" | "maxPnlFactorForDepositsShort" | "maxPnlFactorForWithdrawalsLong" | "maxPnlFactorForWithdrawalsShort" | "minCollateralFactor" | "minCollateralFactorForLiquidation" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionFeeFactorForBalanceWasImproved" | "positionFeeFactorForBalanceWasNotImproved" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "maxLendableImpactFactor" | "maxLendableImpactFactorForWithdrawals" | "maxLendableImpactUsd" | "lentPositionImpactPoolAmount" | "positionImpactExponentFactorPositive" | "positionImpactExponentFactorNegative" | "swapFeeFactorForBalanceWasImproved" | "swapFeeFactorForBalanceWasNotImproved" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "atomicSwapFeeFactor" | "withdrawalFeeFactorBalanceWasImproved" | "withdrawalFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualIndexTokenId" | "virtualLongTokenId" | "virtualShortTokenId">;
|
|
126
136
|
export type MarketsData = {
|
|
127
137
|
[marketTokenAddress: string]: Market;
|
|
128
138
|
};
|
|
@@ -130,6 +140,10 @@ export type RawMarketInfo = Omit<MarketInfo, "longToken" | "shortToken" | "index
|
|
|
130
140
|
export type RawMarketsInfoData = {
|
|
131
141
|
[marketAddress: string]: RawMarketInfo;
|
|
132
142
|
};
|
|
143
|
+
export type RawMarketValues = Pick<RawMarketInfo, "marketTokenAddress" | keyof MarketValues> & {
|
|
144
|
+
updatedAt: number | null;
|
|
145
|
+
};
|
|
146
|
+
export type RawMarketConfig = Omit<RawMarketInfo, keyof MarketValues>;
|
|
133
147
|
export type MarketsInfoData = {
|
|
134
148
|
[marketAddress: string]: MarketInfo;
|
|
135
149
|
};
|
|
@@ -2,7 +2,7 @@ import type { ContractsChainId } from "../../configs/chains";
|
|
|
2
2
|
import { type MarketConfig as ConfigMarketConfig } from "../../configs/markets";
|
|
3
3
|
import type { DayPriceCandle } from "../24h/types";
|
|
4
4
|
import type { Token, TokenPrices, TokensData } from "../tokens/types";
|
|
5
|
-
import type { ClaimableFundingData, ContractMarketPrices, Market, MarketConfig, MarketInfo, MarketsData, MarketsInfoData, MarketTicker, MarketValues, MarketWithTiers, RawMarketInfo, RawMarketsInfoData } from "./types";
|
|
5
|
+
import type { ClaimableFundingData, ContractMarketPrices, Market, MarketConfig, MarketInfo, MarketsData, MarketsInfoData, MarketTicker, MarketValues, MarketWithTiers, RawMarketConfig, RawMarketInfo, RawMarketsInfoData, RawMarketValues } from "./types";
|
|
6
6
|
export declare function getMarketFullName(p: {
|
|
7
7
|
longToken: Token;
|
|
8
8
|
shortToken: Token;
|
|
@@ -108,6 +108,7 @@ export declare function composeRawMarketsInfoData({ marketsAddresses, marketsDat
|
|
|
108
108
|
useOpenInterestInTokensForBalance: boolean;
|
|
109
109
|
};
|
|
110
110
|
}): RawMarketsInfoData;
|
|
111
|
+
export declare function mergeMarketsConfigValues(configs: RawMarketConfig[], values: RawMarketValues[]): RawMarketsInfoData;
|
|
111
112
|
export declare function hydrateMarketInfo({ chainId, rawMarketInfo, tokensData, claimableFundingData, }: {
|
|
112
113
|
chainId: ContractsChainId;
|
|
113
114
|
rawMarketInfo: RawMarketInfo;
|
|
@@ -26,7 +26,10 @@ export declare function expandDecimals(n: BigNumberish, decimals: number): bigin
|
|
|
26
26
|
export declare function toBigInt(value: BigNumberish | undefined | null): bigint | undefined;
|
|
27
27
|
export declare function basisPointsToFloat(basisPoints: bigint): bigint;
|
|
28
28
|
export declare function getBasisPoints(numerator: bigint, denominator: bigint, shouldRoundUp?: boolean): bigint;
|
|
29
|
+
export declare function formatBasisPoints(bpsValue: bigint | undefined): string | undefined;
|
|
30
|
+
export declare function formatPriceImpactBps(priceImpactUsd: bigint | undefined, sizeUsd: bigint): string | undefined;
|
|
29
31
|
export declare function roundUpMagnitudeDivision(a: bigint, b: bigint): bigint;
|
|
32
|
+
export declare function roundsToZero(amount: bigint, decimals: number, displayDecimals: number): boolean;
|
|
30
33
|
export declare function applyFactor(value: bigint, factor: bigint): bigint;
|
|
31
34
|
export declare function numberToBigint(value: number, decimals: number): bigint;
|
|
32
35
|
export declare const trimZeroDecimals: (amount: string) => string;
|
|
@@ -55,6 +58,7 @@ export declare function formatPercentage(percentage?: bigint, opts?: {
|
|
|
55
58
|
displayDecimals?: number;
|
|
56
59
|
bps?: boolean;
|
|
57
60
|
showPlus?: boolean;
|
|
61
|
+
useCommas?: boolean;
|
|
58
62
|
}): string | undefined;
|
|
59
63
|
export declare function formatTokenAmount(amount?: bigint, tokenDecimals?: number, symbol?: string, opts?: {
|
|
60
64
|
showAllSignificant?: boolean;
|
|
@@ -139,7 +143,7 @@ export declare function serializeBigIntsInObject<T extends object>(obj: T): Seri
|
|
|
139
143
|
export declare function deserializeBigIntsInObject<T extends object>(obj: T, opts?: {
|
|
140
144
|
handleInts?: boolean;
|
|
141
145
|
}): DeserializeBigIntInObject<T>;
|
|
142
|
-
export declare function calculateDisplayDecimals(price?: bigint, decimals?: number, visualMultiplier?: number, isStable?: boolean):
|
|
146
|
+
export declare function calculateDisplayDecimals(price?: bigint, decimals?: number, visualMultiplier?: number, isStable?: boolean): 2 | 8 | 4 | 3 | 5 | 6 | 7 | 9;
|
|
143
147
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
144
148
|
export declare function absDiffBps(value: bigint, base: bigint): bigint;
|
|
145
149
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodeSimulationRouterExternalCall(simulationRouterAddress: string, simulateExecuteData: string): string;
|
|
@@ -55,6 +55,7 @@ export type Order = {
|
|
|
55
55
|
autoCancel: boolean;
|
|
56
56
|
data: string[];
|
|
57
57
|
uiFeeReceiver: string;
|
|
58
|
+
uiFeeFactor: bigint | undefined;
|
|
58
59
|
validFromTime: bigint;
|
|
59
60
|
title?: string;
|
|
60
61
|
};
|
|
@@ -130,5 +131,6 @@ export type ApiOrderInfo = {
|
|
|
130
131
|
shouldUnwrapNativeToken: boolean;
|
|
131
132
|
isFrozen: boolean;
|
|
132
133
|
autoCancel: boolean;
|
|
134
|
+
dataList: string[];
|
|
133
135
|
};
|
|
134
136
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -108,6 +108,7 @@ export declare function getMinCollateralFactorForPosition(position: PositionInfo
|
|
|
108
108
|
export declare function getContractPositionDynamicFees({ position, marketInfo, marketFeeState, referralInfo, }: {
|
|
109
109
|
position: {
|
|
110
110
|
sizeInUsd: bigint;
|
|
111
|
+
sizeInTokens: bigint;
|
|
111
112
|
collateralTokenAddress: string;
|
|
112
113
|
isLong: boolean;
|
|
113
114
|
borrowingFactor: bigint;
|
|
@@ -3,5 +3,6 @@ export { generateSubaccount, decryptSubaccountPrivateKey, createSubaccountSigner
|
|
|
3
3
|
export { hashSubaccountApproval } from "./hashSubaccountApproval";
|
|
4
4
|
export { getEmptySubaccountApproval } from "./getEmptySubaccountApproval";
|
|
5
5
|
export { getSubaccountApprovalTypedData, type SubaccountApprovalTypedData } from "./getSubaccountApprovalTypedData";
|
|
6
|
+
export { isEmptySubaccountApproval, isSameSubaccountApproval, isSubaccountApprovalExpired, isSubaccountApprovalNonceExpired, isSubaccountApprovalSynced, isSubaccountStatusUsable, parseSubaccountStatus, shouldRefreshExplicitSubaccountApproval, toSignedSubaccountApproval, } from "./state";
|
|
6
7
|
export { fetchSubaccountStatus, prepareSubaccountApproval, signSubaccountApproval } from "./api";
|
|
7
8
|
export type { SubaccountStatusRequest, SubaccountStatusResponse, SubaccountApprovalPrepareRequest, SubaccountApprovalPrepareResponse, } from "./api";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import type { IHttp } from "../http/types";
|
|
3
|
+
import type { PrepareCancelOrderRequest, PrepareCollateralRequest, PrepareEditOrderRequest, PrepareOrderRequest, PrepareOrderResponse, SubmitOrderRequest, SubmitOrderResponse } from "../orderTransactions/api";
|
|
4
|
+
import type { IAbstractSigner } from "../signer";
|
|
5
|
+
import type { SdkSubaccountApproval, SdkSubaccountStatus, SubaccountState } from "./types";
|
|
6
|
+
export type SdkSubaccountClientContext = {
|
|
7
|
+
ctx: {
|
|
8
|
+
chainId: ContractsChainId;
|
|
9
|
+
api: IHttp;
|
|
10
|
+
};
|
|
11
|
+
owner: object;
|
|
12
|
+
preparedSubaccountApprovals: Map<string, SdkSubaccountApproval>;
|
|
13
|
+
getSubaccount: () => SubaccountState | undefined;
|
|
14
|
+
setSubaccount: (subaccount: SubaccountState | undefined) => void;
|
|
15
|
+
};
|
|
16
|
+
export type SubaccountPrepareRequest = PrepareOrderRequest | PrepareEditOrderRequest | PrepareCancelOrderRequest | PrepareCollateralRequest;
|
|
17
|
+
export type PrepareWithContext<TRequest extends SubaccountPrepareRequest> = (ctx: {
|
|
18
|
+
api: IHttp;
|
|
19
|
+
}, request: TRequest) => Promise<PrepareOrderResponse>;
|
|
20
|
+
export declare function hasActiveSdkSubaccount(client: SdkSubaccountClientContext): boolean;
|
|
21
|
+
export declare function getSdkSubaccountApprovalMessage(client: SdkSubaccountClientContext): SdkSubaccountApproval | undefined;
|
|
22
|
+
export declare function generateSdkSubaccount(client: SdkSubaccountClientContext, mainSigner: IAbstractSigner): Promise<string>;
|
|
23
|
+
export declare function reconcileSdkSubaccountApproval(subaccount: SubaccountState | undefined): void;
|
|
24
|
+
export declare function refreshSdkSubaccountState(client: SdkSubaccountClientContext, account: string): Promise<SdkSubaccountStatus | undefined>;
|
|
25
|
+
export declare function activateSdkSubaccount(client: SdkSubaccountClientContext, mainSigner: IAbstractSigner, options?: {
|
|
26
|
+
expiresInSeconds?: number;
|
|
27
|
+
maxAllowedCount?: number | bigint;
|
|
28
|
+
}, knownStatus?: SdkSubaccountStatus): Promise<string>;
|
|
29
|
+
export declare function getSdkSubaccountApprovalForOrder(client: SdkSubaccountClientContext, account: string, mainSigner?: IAbstractSigner, options?: {
|
|
30
|
+
forceRefresh?: boolean;
|
|
31
|
+
}): Promise<SdkSubaccountApproval | undefined>;
|
|
32
|
+
export declare function prepareWithSubaccount<TRequest extends SubaccountPrepareRequest>(client: SdkSubaccountClientContext, request: TRequest, prepareFn: PrepareWithContext<TRequest>, mainSigner?: IAbstractSigner): Promise<PrepareOrderResponse>;
|
|
33
|
+
export declare function signOrderWithSubaccount(client: SdkSubaccountClientContext, prepared: PrepareOrderResponse, signer: IAbstractSigner): Promise<string>;
|
|
34
|
+
export declare function submitOrderWithSubaccount(client: SdkSubaccountClientContext, request: SubmitOrderRequest): Promise<SubmitOrderResponse>;
|
|
35
|
+
export declare function executeExpressOrderWithSubaccount(client: SdkSubaccountClientContext, request: PrepareOrderRequest, signer: IAbstractSigner): Promise<SubmitOrderResponse>;
|
|
36
|
+
export declare function clearSdkSubaccount(client: SdkSubaccountClientContext): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SubaccountApprovalPrepareResponse, SubaccountStatusResponse } from "./api";
|
|
2
|
+
import type { SdkSubaccountApproval, SdkSubaccountStatus, SignedSubaccountApproval, StoredSubaccountApproval } from "./types";
|
|
3
|
+
export declare function parseSubaccountStatus(status: SubaccountStatusResponse): SdkSubaccountStatus;
|
|
4
|
+
export declare function isSubaccountStatusUsable(status: SdkSubaccountStatus | undefined): boolean;
|
|
5
|
+
export declare function isEmptySubaccountApproval(approval: SdkSubaccountApproval): boolean;
|
|
6
|
+
export declare function isSameSubaccountApproval(a: SdkSubaccountApproval, b: SdkSubaccountApproval): boolean;
|
|
7
|
+
export declare function shouldRefreshExplicitSubaccountApproval(approval: SdkSubaccountApproval, status: SdkSubaccountStatus | undefined, pendingApproval: StoredSubaccountApproval | undefined): boolean;
|
|
8
|
+
export declare function isSubaccountApprovalNonceExpired(approval: SdkSubaccountApproval, status: SdkSubaccountStatus): boolean;
|
|
9
|
+
export declare function isSubaccountApprovalSynced(approval: SdkSubaccountApproval, status: SdkSubaccountStatus): boolean;
|
|
10
|
+
export declare function isSubaccountApprovalExpired(approval: SdkSubaccountApproval): boolean;
|
|
11
|
+
export declare function toSignedSubaccountApproval(prepared: SubaccountApprovalPrepareResponse, signature: string): SignedSubaccountApproval;
|
|
@@ -31,6 +31,24 @@ export type SignedSubaccountApproval = SubaccountApproval & {
|
|
|
31
31
|
signatureChainId: AnyChainId;
|
|
32
32
|
subaccountRouterAddress: string;
|
|
33
33
|
};
|
|
34
|
+
export type EmptySubaccountApproval = SubaccountApproval & {
|
|
35
|
+
signature: string;
|
|
36
|
+
};
|
|
37
|
+
export type SdkSubaccountApproval = SignedSubaccountApproval | EmptySubaccountApproval;
|
|
38
|
+
export type SdkSubaccountStatus = SubaccountOnchainData & {
|
|
39
|
+
remainingActions: bigint;
|
|
40
|
+
};
|
|
41
|
+
export type StoredSubaccountApproval = {
|
|
42
|
+
message: SignedSubaccountApproval;
|
|
43
|
+
submittedRequestId?: string;
|
|
44
|
+
};
|
|
45
|
+
export type SubaccountState = {
|
|
46
|
+
account?: string;
|
|
47
|
+
address: string;
|
|
48
|
+
approval?: StoredSubaccountApproval;
|
|
49
|
+
onchainData?: SdkSubaccountStatus;
|
|
50
|
+
lastStatusFetchedAt?: number;
|
|
51
|
+
};
|
|
34
52
|
export type Subaccount = {
|
|
35
53
|
address: string;
|
|
36
54
|
chainId: ContractsChainId;
|