@dhedge/trading-widget 5.11.0 → 5.12.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/README.md CHANGED
@@ -176,6 +176,35 @@ The `useEffectiveAggregators` hook (exported from the widget) can be used to rea
176
176
 
177
177
  ---
178
178
 
179
+ #### Auto Slippage Simulation
180
+
181
+ When `settings.slippage` is set to `'auto'`, the widget runs a **simulation-based search** at transaction-build time to find the minimum slippage value that allows the transaction to pass gas estimation. This replaces the pre-existing heuristic (price-diff calculation) for the actual on-chain call, while the displayed value in the UI still comes from the heuristic.
182
+
183
+ The mechanism mirrors the existing **router selection loop** (`tryEstimateWithRouters`): candidate slippage values are tried from lowest to highest, and the first one whose `estimate()` call succeeds is used for the transaction.
184
+
185
+ **Candidate generation:**
186
+
187
+ The full candidate pool is exported as `SLIPPAGE_AUTO_SIMULATION_CANDIDATES` from `core-kit/const`:
188
+
189
+ At runtime, `getAutoSlippageSimulationCandidates({ maxSlippage })` filters this list to values ≤ the resolved max slippage (from `useAppliedDepositSlippage` / `useAppliedWithdrawSlippage`), rounds to two decimals, and always includes the resolved max itself as the final candidate.
190
+
191
+ **Flows covered:**
192
+
193
+ | Flow | Simulation shape | Fallback when all candidates fail |
194
+ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
195
+ | Zap deposit — single (`useDeposit`) | Outer slippage loop × inner swap-quote router loop in `buildZapDepositArguments` | Falls through to the standard router loop with the resolved `depositSlippage` |
196
+ | Init withdraw — Aave vaults | Outer slippage loop (`tryEstimateWithSlippageValues`) re-fetches swap quotes per candidate × inner `tryEstimateWithRouters` in `useFetchInitWithdrawComplexAssetData` | `createDefaultComplexAssetData` with the resolved `slippageTolerance` (pre-simulation default) |
197
+ | Complete withdraw — swap | Outer slippage loop × inner router loop in `useCompleteWithdrawTransaction` | Returns empty args (no transaction sent) |
198
+
199
+ **Not covered / by design:**
200
+
201
+ - **Zap deposit — batch** (`useBatchDeposit`): batch path uses a fixed quote index with no `estimate`, by design.
202
+ - **Non-zap deposit** (`deposit`, `nativeDeposit`): slippage here is a min-vault-tokens gap, not a DEX swap tolerance — no estimation loop is possible.
203
+ - **Init withdraw — non-Aave vaults**: no swap quotes involved; the `complexAssetData` is built with a single `slippageTolerance` value via `createDefaultComplexAssetData` — no estimation loop.
204
+ - **Limit order withdraw**: uses price bounds, not DEX slippage.
205
+
206
+ ---
207
+
179
208
  <details>
180
209
  <summary><code>PoolConfig</code> <code><b>/</b></code> <code>Vault configuration schema</code></summary>
181
210
 
@@ -208,28 +237,28 @@ UI configuration provider. Manages params to configure custom styling, component
208
237
 
209
238
  ##### params
210
239
 
211
- > | name | type | default value | description |
212
- > | ---------------------------------- | -------------------------------------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
213
- > | `isGeoBlocked` | `boolean` | `false` | Restricts depositing action button and conditionally renders GeoBlockAlert component |
214
- > | `isSanctioned` | `boolean` | `false` | Restricts depositing action button and conditionally renders SanctionedAlert component |
215
- > | `depositQuoteDiffWarningThreshold` | `number` | `1.5` | Deposit slippage absolute percent value warning threshold, Affects styling to warn user |
216
- > | `depositQuoteDiffErrorThreshold` | `number` | `3` | Deposit slippage absolute percent value error threshold, Affects styling to warn user |
217
- > | `defaultWithdrawSlippage` | `number` | `[0.1, 0.3, 0.5, 1, 1.5, 3]` | Initial withdraw slippage absolute percent. Further adjustments are available in panel settings |
218
- > | `defaultSwapTransactionSlippage` | `number` | `0.75` | Default slippage (%) applied to swap transaction. |
219
- > | `defaultNoSwapMinDepositAmountGap` | `number` | `0.1` | Default gap (%) for min received vault tokens during no swap deposits. |
220
- > | `defaultNotificationDuration` | `number` | `10000` | Notification duration in ms |
221
- > | `defaultLockTime` | `string` | `'24 hours'` | Formatted default deposit lock time to be displayed in panel (Long lockup period is used to bypass entry fee and can be managed in panel settings) |
222
- > | `customLockTime` | `string` | `'15 minutes'` | Formatted custom deposit lock time alternative to be displayed in panel |
223
- > | `stablePrecision` | `number` | `3` | Number of decimals to be displayed in stables (e.g USDC balance) |
224
- > | `defaultPrecision` | `number` | `6` | Number of decimals to be displayed in token values |
225
- > | `termsOfUseAccepted` | `boolean` | `true` | Requires user to confirm terms of use by rendering DepositTermsOfUse component before deposit action |
226
- > | `standalone` | `boolean` | `true` | Handles token selection in SPA mode |
227
- > | `isAllAssetsWithdrawOptionDefault` | `boolean` | `false` | Sets "All Assets" withdraw option by default |
228
- > | `isCustomDepositOptionsDisabled` | `boolean` | `false` | When enabled, excludes custom deposit tokens and native tokens from deposit options. Only vault's default deposit tokens are available. |
229
- > | `chainConfig` | `Partial<Record<ChainId, { name: string; iconPath: string }>>` | `{}` | Sets map of chain `name` and `iconPath` |
230
- > | `getFallbackIconPath` | `(tokenName: string) => string` | `buildIconLink` | Fallback token icon path getter |
231
- > | `minLimitOrderValue` | `number` | `0` | Minimum USD value required to create a limit sell order |
232
- > | `limitOrderThemeConfig` | `ThemeProviderConfigProps` | `{}` | Limit sell overlay content theme config |
240
+ > | name | type | default value | description |
241
+ > | ---------------------------------- | -------------------------------------------------------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
242
+ > | `isGeoBlocked` | `boolean` | `false` | Restricts depositing action button and conditionally renders GeoBlockAlert component |
243
+ > | `isSanctioned` | `boolean` | `false` | Restricts depositing action button and conditionally renders SanctionedAlert component |
244
+ > | `depositQuoteDiffWarningThreshold` | `number` | `1.5` | Deposit slippage absolute percent value warning threshold, Affects styling to warn user |
245
+ > | `depositQuoteDiffErrorThreshold` | `number` | `3` | Deposit slippage absolute percent value error threshold, Affects styling to warn user |
246
+ > | `defaultWithdrawSlippage` | `number \| Partial<Record<ChainId, number>>` | `0.5` | Initial withdraw slippage absolute percent. Accepts a single number or a per-chain map. Further adjustments are available in panel settings |
247
+ > | `defaultSwapTransactionSlippage` | `number \| Partial<Record<ChainId, number>>` | `0.5` | Default slippage (%) applied to swap transaction. Accepts a single number or a per-chain map. |
248
+ > | `defaultNoSwapMinDepositAmountGap` | `number` | `0.1` | Default gap (%) for min received vault tokens during no swap deposits. |
249
+ > | `defaultNotificationDuration` | `number` | `10000` | Notification duration in ms |
250
+ > | `defaultLockTime` | `string` | `'24 hours'` | Formatted default deposit lock time to be displayed in panel (Long lockup period is used to bypass entry fee and can be managed in panel settings) |
251
+ > | `customLockTime` | `string` | `'15 minutes'` | Formatted custom deposit lock time alternative to be displayed in panel |
252
+ > | `stablePrecision` | `number` | `3` | Number of decimals to be displayed in stables (e.g USDC balance) |
253
+ > | `defaultPrecision` | `number` | `6` | Number of decimals to be displayed in token values |
254
+ > | `termsOfUseAccepted` | `boolean` | `true` | Requires user to confirm terms of use by rendering DepositTermsOfUse component before deposit action |
255
+ > | `standalone` | `boolean` | `true` | Handles token selection in SPA mode |
256
+ > | `isAllAssetsWithdrawOptionDefault` | `boolean` | `false` | Sets "All Assets" withdraw option by default |
257
+ > | `isCustomDepositOptionsDisabled` | `boolean` | `false` | When enabled, excludes custom deposit tokens and native tokens from deposit options. Only vault's default deposit tokens are available. |
258
+ > | `chainConfig` | `Partial<Record<ChainId, { name: string; iconPath: string }>>` | `{}` | Sets map of chain `name` and `iconPath` |
259
+ > | `getFallbackIconPath` | `(tokenName: string) => string` | `buildIconLink` | Fallback token icon path getter |
260
+ > | `minLimitOrderValue` | `number` | `0` | Minimum USD value required to create a limit sell order |
261
+ > | `limitOrderThemeConfig` | `ThemeProviderConfigProps` | `{}` | Limit sell overlay content theme config |
233
262
 
234
263
  ##### actions
235
264
 
package/const.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./gmx-CLiWBUH_.cjs"),A=require("./storage-DHoO5PX_.cjs"),E=require("wagmi/chains");exports.ALCHEMY_RPC_URL_MAP=_.ALCHEMY_RPC_URL_MAP;exports.AUTO_TRANSACTION_PUSH_DELAY=_.AUTO_TRANSACTION_PUSH_DELAY;exports.AddressZero=_.AddressZero;exports.BRIDGED_TOKENS_SYMBOLS=_.BRIDGED_TOKENS_SYMBOLS;exports.CHAIN_MAP=_.CHAIN_MAP;exports.CHAIN_NATIVE_TOKENS=_.CHAIN_NATIVE_TOKENS;exports.COMPLETE_WITHDRAW_ACTIONS=_.COMPLETE_WITHDRAW_ACTIONS;exports.CURRENCY_DECIMALS_MAP=_.CURRENCY_DECIMALS_MAP;exports.CURRENCY_SYMBOL_MAP=_.CURRENCY_SYMBOL_MAP;exports.DEFAULT_DEBOUNCE_TIME=_.DEFAULT_DEBOUNCE_TIME;exports.DEFAULT_DEPOSIT_METHOD=_.DEFAULT_DEPOSIT_METHOD;exports.DEFAULT_DEPOSIT_SLIPPAGE=_.DEFAULT_DEPOSIT_SLIPPAGE;exports.DEFAULT_DEPOSIT_SLIPPAGE_SCALE=_.DEFAULT_DEPOSIT_SLIPPAGE_SCALE;exports.DEFAULT_ERROR_MESSAGE=_.DEFAULT_ERROR_MESSAGE;exports.DEFAULT_LOCK_TIME=_.DEFAULT_LOCK_TIME;exports.DEFAULT_MAX_GAS_LIMIT=_.DEFAULT_MAX_GAS_LIMIT;exports.DEFAULT_MULTI_ASSET_WITHDRAW_METHOD=_.DEFAULT_MULTI_ASSET_WITHDRAW_METHOD;exports.DEFAULT_NOTIFICATION_DURATION_MS=_.DEFAULT_NOTIFICATION_DURATION_MS;exports.DEFAULT_NO_SWAP_MIN_DEPOSIT_AMOUNT_GAP=_.DEFAULT_NO_SWAP_MIN_DEPOSIT_AMOUNT_GAP;exports.DEFAULT_POLLING_INTERVAL=_.DEFAULT_POLLING_INTERVAL;exports.DEFAULT_PRECISION=_.DEFAULT_PRECISION;exports.DEFAULT_PROMISE_TIMEOUT_MS=_.DEFAULT_PROMISE_TIMEOUT_MS;exports.DEFAULT_RECEIVED_VALUE_GAP=_.DEFAULT_RECEIVED_VALUE_GAP;exports.DEFAULT_SIMULATION_ERROR=_.DEFAULT_SIMULATION_ERROR;exports.DEFAULT_SWAP_TRANSACTION_SLIPPAGE=_.DEFAULT_SWAP_TRANSACTION_SLIPPAGE;exports.DEFAULT_VAULT_TOKEN_PRICE=_.DEFAULT_VAULT_TOKEN_PRICE;exports.DEFAULT_VISIBLE_ASSETS_LIMIT=_.DEFAULT_VISIBLE_ASSETS_LIMIT;exports.DEFAULT_WITHDRAW_SLIPPAGE=_.DEFAULT_WITHDRAW_SLIPPAGE;exports.DEPOSIT_SWAP_DATA_ERROR=_.DEPOSIT_SWAP_DATA_ERROR;exports.EASY_SWAPPER_V2_COMPLETE_WITHDRAW_METHOD=_.EASY_SWAPPER_V2_COMPLETE_WITHDRAW_METHOD;exports.EASY_SWAPPER_V2_DEPOSIT_METHODS=_.EASY_SWAPPER_V2_DEPOSIT_METHODS;exports.EASY_SWAPPER_V2_INITIATE_WITHDRAW_METHOD=_.EASY_SWAPPER_V2_INITIATE_WITHDRAW_METHOD;exports.EASY_SWAPPER_V2_UNROLL_AND_CLAIM_METHOD=_.EASY_SWAPPER_V2_UNROLL_AND_CLAIM_METHOD;exports.EMPTY_POOL_CONFIG=_.EMPTY_POOL_CONFIG;exports.EXTENDED_DEBOUNCE_TIME=_.EXTENDED_DEBOUNCE_TIME;exports.EXTENDED_POLLING_INTERVAL=_.EXTENDED_POLLING_INTERVAL;exports.EXTREMELY_SHORT_POLLING_INTERVAL=_.EXTREMELY_SHORT_POLLING_INTERVAL;exports.FALLBACK_ASSETS_MAP=_.FALLBACK_ASSETS_MAP;exports.FLAT_MONEY_COLLATERAL_MAP=_.FLAT_MONEY_COLLATERAL_MAP;exports.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES=_.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES;exports.FLAT_MONEY_UNIT_ADDRESSES=_.FLAT_MONEY_UNIT_ADDRESSES;exports.FLAT_MONEY_UNIT_LINK=_.FLAT_MONEY_UNIT_LINK;exports.FLAT_MONEY_V1_UNIT_ADDRESS=_.FLAT_MONEY_V1_UNIT_ADDRESS;exports.FLAT_MONEY_V1_UNIT_LINK=_.FLAT_MONEY_V1_UNIT_LINK;exports.GAS_ESTIMATION_ERROR=_.GAS_ESTIMATION_ERROR;exports.GAS_LIMIT_BUFFER_COEFF=_.GAS_LIMIT_BUFFER_COEFF;exports.GMX_MARKET_ASSETS=_.GMX_MARKET_ASSETS;exports.GMX_MARKET_ASSETS_MAP=_.GMX_MARKET_ASSETS_MAP;exports.GMX_WITHDRAW_ASSET_MAP=_.GMX_WITHDRAW_ASSET_MAP;exports.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS=_.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS;exports.INVALID_PRICES_LIMIT_ORDER_TITLE=_.INVALID_PRICES_LIMIT_ORDER_TITLE;exports.LIMIT_ORDER_TRANSACTION_ERRORS=_.LIMIT_ORDER_TRANSACTION_ERRORS;exports.LOG_EVENT_BY_TRANSACTION_ACTION_MAP=_.LOG_EVENT_BY_TRANSACTION_ACTION_MAP;exports.MANAGER_FEE_DENOMINATOR=_.MANAGER_FEE_DENOMINATOR;exports.MAX_GAS_LIMIT_MAP=_.MAX_GAS_LIMIT_MAP;exports.MULTI_ASSET_TOKEN=_.MULTI_ASSET_TOKEN;exports.MaxUint256=_.MaxUint256;exports.NATIVE_TOKEN_DEPOSIT_GAS_LIMIT=_.NATIVE_TOKEN_DEPOSIT_GAS_LIMIT;exports.PYTH_API_LINK=_.PYTH_API_LINK;exports.SHORTEN_POLLING_INTERVAL=_.SHORTEN_POLLING_INTERVAL;exports.SIMULATION_TIMEOUT_ERROR=_.SIMULATION_TIMEOUT_ERROR;exports.STABLE_TOKEN_SYMBOLS=_.STABLE_TOKEN_SYMBOLS;exports.SWAP_FAILED_ERROR=_.SWAP_FAILED_ERROR;exports.SWAP_QUOTE_REFRESH_INTERVAL_MS=_.SWAP_QUOTE_REFRESH_INTERVAL_MS;exports.TRADING_LOG_EVENT_PARAM=_.TRADING_LOG_EVENT_PARAM;exports.TRADING_PANEL_LOG_EVENT=_.TRADING_PANEL_LOG_EVENT;exports.TRANSACTION_ERRORS=_.TRANSACTION_ERRORS;exports.TRANSACTION_ERROR_KEYS=_.TRANSACTION_ERROR_KEYS;exports.WBTC_BY_CHAIN_ID=_.WBTC_BY_CHAIN_ID;exports.WETH_BY_CHAIN_ID=_.WETH_BY_CHAIN_ID;exports.WITHDRAW_SWAP_DATA_ERROR=_.WITHDRAW_SWAP_DATA_ERROR;exports.contractsAbisMap=_.contractsAbisMap;exports.contractsAddressesMap=_.contractsAddressesMap;exports.COVERED_CALL_VAULT_ADDRESSES=A.COVERED_CALL_VAULT_ADDRESSES;exports.LOCAL_STORAGE_KEYS=A.LOCAL_STORAGE_KEYS;Object.defineProperty(exports,"arbitrum",{enumerable:!0,get:()=>E.arbitrum});Object.defineProperty(exports,"base",{enumerable:!0,get:()=>E.base});Object.defineProperty(exports,"hyperEvm",{enumerable:!0,get:()=>E.hyperEvm});Object.defineProperty(exports,"mainnet",{enumerable:!0,get:()=>E.mainnet});Object.defineProperty(exports,"optimism",{enumerable:!0,get:()=>E.optimism});Object.defineProperty(exports,"polygon",{enumerable:!0,get:()=>E.polygon});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./gmx-Bmop5mtI.cjs"),A=require("./storage-DHoO5PX_.cjs"),E=require("wagmi/chains");exports.ALCHEMY_RPC_URL_MAP=_.ALCHEMY_RPC_URL_MAP;exports.AUTO_TRANSACTION_PUSH_DELAY=_.AUTO_TRANSACTION_PUSH_DELAY;exports.AddressZero=_.AddressZero;exports.BRIDGED_TOKENS_SYMBOLS=_.BRIDGED_TOKENS_SYMBOLS;exports.CHAIN_MAP=_.CHAIN_MAP;exports.CHAIN_NATIVE_TOKENS=_.CHAIN_NATIVE_TOKENS;exports.COMPLETE_WITHDRAW_ACTIONS=_.COMPLETE_WITHDRAW_ACTIONS;exports.CURRENCY_DECIMALS_MAP=_.CURRENCY_DECIMALS_MAP;exports.CURRENCY_SYMBOL_MAP=_.CURRENCY_SYMBOL_MAP;exports.DEFAULT_DEBOUNCE_TIME=_.DEFAULT_DEBOUNCE_TIME;exports.DEFAULT_DEPOSIT_METHOD=_.DEFAULT_DEPOSIT_METHOD;exports.DEFAULT_DEPOSIT_SLIPPAGE=_.DEFAULT_DEPOSIT_SLIPPAGE;exports.DEFAULT_DEPOSIT_SLIPPAGE_SCALE=_.DEFAULT_DEPOSIT_SLIPPAGE_SCALE;exports.DEFAULT_ERROR_MESSAGE=_.DEFAULT_ERROR_MESSAGE;exports.DEFAULT_LOCK_TIME=_.DEFAULT_LOCK_TIME;exports.DEFAULT_MAX_GAS_LIMIT=_.DEFAULT_MAX_GAS_LIMIT;exports.DEFAULT_MULTI_ASSET_WITHDRAW_METHOD=_.DEFAULT_MULTI_ASSET_WITHDRAW_METHOD;exports.DEFAULT_NOTIFICATION_DURATION_MS=_.DEFAULT_NOTIFICATION_DURATION_MS;exports.DEFAULT_NO_SWAP_MIN_DEPOSIT_AMOUNT_GAP=_.DEFAULT_NO_SWAP_MIN_DEPOSIT_AMOUNT_GAP;exports.DEFAULT_POLLING_INTERVAL=_.DEFAULT_POLLING_INTERVAL;exports.DEFAULT_PRECISION=_.DEFAULT_PRECISION;exports.DEFAULT_PROMISE_TIMEOUT_MS=_.DEFAULT_PROMISE_TIMEOUT_MS;exports.DEFAULT_RECEIVED_VALUE_GAP=_.DEFAULT_RECEIVED_VALUE_GAP;exports.DEFAULT_SIMULATION_ERROR=_.DEFAULT_SIMULATION_ERROR;exports.DEFAULT_SWAP_TRANSACTION_SLIPPAGE=_.DEFAULT_SWAP_TRANSACTION_SLIPPAGE;exports.DEFAULT_VAULT_TOKEN_PRICE=_.DEFAULT_VAULT_TOKEN_PRICE;exports.DEFAULT_VISIBLE_ASSETS_LIMIT=_.DEFAULT_VISIBLE_ASSETS_LIMIT;exports.DEFAULT_WITHDRAW_SLIPPAGE=_.DEFAULT_WITHDRAW_SLIPPAGE;exports.DEPOSIT_SWAP_DATA_ERROR=_.DEPOSIT_SWAP_DATA_ERROR;exports.EASY_SWAPPER_V2_COMPLETE_WITHDRAW_METHOD=_.EASY_SWAPPER_V2_COMPLETE_WITHDRAW_METHOD;exports.EASY_SWAPPER_V2_DEPOSIT_METHODS=_.EASY_SWAPPER_V2_DEPOSIT_METHODS;exports.EASY_SWAPPER_V2_INITIATE_WITHDRAW_METHOD=_.EASY_SWAPPER_V2_INITIATE_WITHDRAW_METHOD;exports.EASY_SWAPPER_V2_UNROLL_AND_CLAIM_METHOD=_.EASY_SWAPPER_V2_UNROLL_AND_CLAIM_METHOD;exports.EMPTY_POOL_CONFIG=_.EMPTY_POOL_CONFIG;exports.EXTENDED_DEBOUNCE_TIME=_.EXTENDED_DEBOUNCE_TIME;exports.EXTENDED_POLLING_INTERVAL=_.EXTENDED_POLLING_INTERVAL;exports.EXTREMELY_SHORT_POLLING_INTERVAL=_.EXTREMELY_SHORT_POLLING_INTERVAL;exports.FALLBACK_ASSETS_MAP=_.FALLBACK_ASSETS_MAP;exports.FLAT_MONEY_COLLATERAL_MAP=_.FLAT_MONEY_COLLATERAL_MAP;exports.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES=_.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES;exports.FLAT_MONEY_UNIT_ADDRESSES=_.FLAT_MONEY_UNIT_ADDRESSES;exports.FLAT_MONEY_UNIT_LINK=_.FLAT_MONEY_UNIT_LINK;exports.FLAT_MONEY_V1_UNIT_ADDRESS=_.FLAT_MONEY_V1_UNIT_ADDRESS;exports.FLAT_MONEY_V1_UNIT_LINK=_.FLAT_MONEY_V1_UNIT_LINK;exports.GAS_ESTIMATION_ERROR=_.GAS_ESTIMATION_ERROR;exports.GAS_LIMIT_BUFFER_COEFF=_.GAS_LIMIT_BUFFER_COEFF;exports.GMX_MARKET_ASSETS=_.GMX_MARKET_ASSETS;exports.GMX_MARKET_ASSETS_MAP=_.GMX_MARKET_ASSETS_MAP;exports.GMX_WITHDRAW_ASSET_MAP=_.GMX_WITHDRAW_ASSET_MAP;exports.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS=_.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS;exports.INVALID_PRICES_LIMIT_ORDER_TITLE=_.INVALID_PRICES_LIMIT_ORDER_TITLE;exports.LIMIT_ORDER_TRANSACTION_ERRORS=_.LIMIT_ORDER_TRANSACTION_ERRORS;exports.LOG_EVENT_BY_TRANSACTION_ACTION_MAP=_.LOG_EVENT_BY_TRANSACTION_ACTION_MAP;exports.MANAGER_FEE_DENOMINATOR=_.MANAGER_FEE_DENOMINATOR;exports.MAX_GAS_LIMIT_MAP=_.MAX_GAS_LIMIT_MAP;exports.MULTI_ASSET_TOKEN=_.MULTI_ASSET_TOKEN;exports.MaxUint256=_.MaxUint256;exports.NATIVE_TOKEN_DEPOSIT_GAS_LIMIT=_.NATIVE_TOKEN_DEPOSIT_GAS_LIMIT;exports.PYTH_API_LINK=_.PYTH_API_LINK;exports.SHORTEN_POLLING_INTERVAL=_.SHORTEN_POLLING_INTERVAL;exports.SIMULATION_TIMEOUT_ERROR=_.SIMULATION_TIMEOUT_ERROR;exports.SLIPPAGE_AUTO_SIMULATION_CANDIDATES=_.SLIPPAGE_AUTO_SIMULATION_CANDIDATES;exports.STABLE_TOKEN_SYMBOLS=_.STABLE_TOKEN_SYMBOLS;exports.SWAP_FAILED_ERROR=_.SWAP_FAILED_ERROR;exports.SWAP_QUOTE_REFRESH_INTERVAL_MS=_.SWAP_QUOTE_REFRESH_INTERVAL_MS;exports.TRADING_LOG_EVENT_PARAM=_.TRADING_LOG_EVENT_PARAM;exports.TRADING_PANEL_LOG_EVENT=_.TRADING_PANEL_LOG_EVENT;exports.TRANSACTION_ERRORS=_.TRANSACTION_ERRORS;exports.TRANSACTION_ERROR_KEYS=_.TRANSACTION_ERROR_KEYS;exports.WBTC_BY_CHAIN_ID=_.WBTC_BY_CHAIN_ID;exports.WETH_BY_CHAIN_ID=_.WETH_BY_CHAIN_ID;exports.WITHDRAW_SWAP_DATA_ERROR=_.WITHDRAW_SWAP_DATA_ERROR;exports.contractsAbisMap=_.contractsAbisMap;exports.contractsAddressesMap=_.contractsAddressesMap;exports.COVERED_CALL_VAULT_ADDRESSES=A.COVERED_CALL_VAULT_ADDRESSES;exports.LOCAL_STORAGE_KEYS=A.LOCAL_STORAGE_KEYS;Object.defineProperty(exports,"arbitrum",{enumerable:!0,get:()=>E.arbitrum});Object.defineProperty(exports,"base",{enumerable:!0,get:()=>E.base});Object.defineProperty(exports,"hyperEvm",{enumerable:!0,get:()=>E.hyperEvm});Object.defineProperty(exports,"mainnet",{enumerable:!0,get:()=>E.mainnet});Object.defineProperty(exports,"optimism",{enumerable:!0,get:()=>E.optimism});Object.defineProperty(exports,"polygon",{enumerable:!0,get:()=>E.polygon});
package/const.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A, a as T, b as I, B as S, C as a, c as L, d as R, e as O, f as s, D as N, g as D, h as M, i as P, j as U, k as C, l as F, m as G, n as W, o as Y, p as H, q as V, r as B, s as K, t as r, u as o, v as e, w as t, x as X, y as m, E as p, z as i, F as n, G as c, H as d, I as b, J as f, K as x, L as g, M as h, N as y, O as l, P as u, Q as v, R as Q, S as Z, T as j, U as k, V as q, W as w, X as z, Y as J, Z as $, _ as __, $ as E_, a0 as A_, a1 as T_, a2 as I_, a3 as S_, a4 as a_, a5 as L_, a6 as R_, a7 as O_, a8 as s_, a9 as N_, aa as D_, ab as M_, ac as P_, ad as U_, ae as C_, af as F_, ag as G_, ah as W_, ai as Y_ } from "./gmx-BroDb_q_.js";
2
- import { C as V_, L as B_ } from "./storage-CSc9iE5L.js";
3
- import { arbitrum as r_, base as o_, hyperEvm as e_, mainnet as t_, optimism as X_, polygon as m_ } from "wagmi/chains";
1
+ import { A, a as T, b as I, B as S, C as a, c as L, d as R, e as O, f as s, D as N, g as D, h as M, i as P, j as U, k as C, l as F, m as G, n as W, o as Y, p as H, q as V, r as B, s as K, t as r, u as o, v as e, w as t, x as X, y as m, E as p, z as i, F as n, G as c, H as d, I as b, J as f, K as x, L as g, M as h, N as y, O as j, P as l, Q as u, R as v, S as Q, T as Z, U as k, V as q, W as w, X as z, Y as J, Z as $, _ as __, $ as E_, a0 as A_, a1 as T_, a2 as I_, a3 as S_, a4 as a_, a5 as L_, a6 as R_, a7 as O_, a8 as s_, a9 as N_, aa as D_, ab as M_, ac as P_, ad as U_, ae as C_, af as F_, ag as G_, ah as W_, ai as Y_, aj as H_ } from "./gmx-3UudxpaT.js";
2
+ import { C as B_, L as K_ } from "./storage-CSc9iE5L.js";
3
+ import { arbitrum as o_, base as e_, hyperEvm as t_, mainnet as X_, optimism as m_, polygon as p_ } from "wagmi/chains";
4
4
  export {
5
5
  A as ALCHEMY_RPC_URL_MAP,
6
6
  T as AUTO_TRANSACTION_PUSH_DELAY,
@@ -9,7 +9,7 @@ export {
9
9
  a as CHAIN_MAP,
10
10
  L as CHAIN_NATIVE_TOKENS,
11
11
  R as COMPLETE_WITHDRAW_ACTIONS,
12
- V_ as COVERED_CALL_VAULT_ADDRESSES,
12
+ B_ as COVERED_CALL_VAULT_ADDRESSES,
13
13
  O as CURRENCY_DECIMALS_MAP,
14
14
  s as CURRENCY_SYMBOL_MAP,
15
15
  N as DEFAULT_DEBOUNCE_TIME,
@@ -43,19 +43,19 @@ export {
43
43
  g as FALLBACK_ASSETS_MAP,
44
44
  h as FLAT_MONEY_COLLATERAL_MAP,
45
45
  y as FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES,
46
- l as FLAT_MONEY_UNIT_ADDRESSES,
47
- u as FLAT_MONEY_UNIT_LINK,
48
- v as FLAT_MONEY_V1_UNIT_ADDRESS,
49
- Q as FLAT_MONEY_V1_UNIT_LINK,
50
- Z as GAS_ESTIMATION_ERROR,
51
- j as GAS_LIMIT_BUFFER_COEFF,
46
+ j as FLAT_MONEY_UNIT_ADDRESSES,
47
+ l as FLAT_MONEY_UNIT_LINK,
48
+ u as FLAT_MONEY_V1_UNIT_ADDRESS,
49
+ v as FLAT_MONEY_V1_UNIT_LINK,
50
+ Q as GAS_ESTIMATION_ERROR,
51
+ Z as GAS_LIMIT_BUFFER_COEFF,
52
52
  k as GMX_MARKET_ASSETS,
53
53
  q as GMX_MARKET_ASSETS_MAP,
54
54
  w as GMX_WITHDRAW_ASSET_MAP,
55
55
  z as GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS,
56
56
  J as INVALID_PRICES_LIMIT_ORDER_TITLE,
57
57
  $ as LIMIT_ORDER_TRANSACTION_ERRORS,
58
- B_ as LOCAL_STORAGE_KEYS,
58
+ K_ as LOCAL_STORAGE_KEYS,
59
59
  __ as LOG_EVENT_BY_TRANSACTION_ACTION_MAP,
60
60
  E_ as MANAGER_FEE_DENOMINATOR,
61
61
  A_ as MAX_GAS_LIMIT_MAP,
@@ -65,22 +65,23 @@ export {
65
65
  a_ as PYTH_API_LINK,
66
66
  L_ as SHORTEN_POLLING_INTERVAL,
67
67
  R_ as SIMULATION_TIMEOUT_ERROR,
68
- O_ as STABLE_TOKEN_SYMBOLS,
69
- s_ as SWAP_FAILED_ERROR,
70
- N_ as SWAP_QUOTE_REFRESH_INTERVAL_MS,
71
- D_ as TRADING_LOG_EVENT_PARAM,
72
- M_ as TRADING_PANEL_LOG_EVENT,
73
- P_ as TRANSACTION_ERRORS,
74
- U_ as TRANSACTION_ERROR_KEYS,
75
- C_ as WBTC_BY_CHAIN_ID,
76
- F_ as WETH_BY_CHAIN_ID,
77
- G_ as WITHDRAW_SWAP_DATA_ERROR,
78
- r_ as arbitrum,
79
- o_ as base,
80
- W_ as contractsAbisMap,
81
- Y_ as contractsAddressesMap,
82
- e_ as hyperEvm,
83
- t_ as mainnet,
84
- X_ as optimism,
85
- m_ as polygon
68
+ O_ as SLIPPAGE_AUTO_SIMULATION_CANDIDATES,
69
+ s_ as STABLE_TOKEN_SYMBOLS,
70
+ N_ as SWAP_FAILED_ERROR,
71
+ D_ as SWAP_QUOTE_REFRESH_INTERVAL_MS,
72
+ M_ as TRADING_LOG_EVENT_PARAM,
73
+ P_ as TRADING_PANEL_LOG_EVENT,
74
+ U_ as TRANSACTION_ERRORS,
75
+ C_ as TRANSACTION_ERROR_KEYS,
76
+ F_ as WBTC_BY_CHAIN_ID,
77
+ G_ as WETH_BY_CHAIN_ID,
78
+ W_ as WITHDRAW_SWAP_DATA_ERROR,
79
+ o_ as arbitrum,
80
+ e_ as base,
81
+ Y_ as contractsAbisMap,
82
+ H_ as contractsAddressesMap,
83
+ t_ as hyperEvm,
84
+ X_ as mainnet,
85
+ m_ as optimism,
86
+ p_ as polygon
86
87
  };
@@ -17,6 +17,7 @@ export declare const DEFAULT_NO_SWAP_MIN_DEPOSIT_AMOUNT_GAP = 0.5;
17
17
  export declare const DEFAULT_RECEIVED_VALUE_GAP = 0.02;
18
18
  export declare const DEFAULT_SWAP_TRANSACTION_SLIPPAGE = 0.5;
19
19
  export declare const DEFAULT_DEPOSIT_SLIPPAGE_SCALE: number[];
20
+ export declare const SLIPPAGE_AUTO_SIMULATION_CANDIDATES: number[];
20
21
  export declare const DEFAULT_MULTI_ASSET_WITHDRAW_METHOD = "withdrawSafe";
21
22
  export declare const EASY_SWAPPER_V2_INITIATE_WITHDRAW_METHOD = "initWithdrawal";
22
23
  export declare const EASY_SWAPPER_V2_UNROLL_AND_CLAIM_METHOD = "unrollAndClaim";
@@ -4,6 +4,7 @@ export type CommonWithdrawTransactionArgs = [bigint] | [Address, bigint];
4
4
  type FetchInitWithdrawComplexAssetDataParams = FetchAaveSwapParamsProps & {
5
5
  estimate: EstimateCall;
6
6
  transactionArgs: CommonWithdrawTransactionArgs;
7
+ isAutoSlippage: boolean;
7
8
  };
8
- export declare const useFetchInitWithdrawComplexAssetData: ({ address, chainId, }: Pick<PoolConfig, 'address' | 'chainId'>) => ({ withdrawAmountD18, slippage, estimate, transactionArgs, }: FetchInitWithdrawComplexAssetDataParams) => Promise<ComplexWithdrawAssetData[]>;
9
+ export declare const useFetchInitWithdrawComplexAssetData: ({ address, chainId, }: Pick<PoolConfig, 'address' | 'chainId'>) => ({ withdrawAmountD18, slippage, isAutoSlippage, estimate, transactionArgs, }: FetchInitWithdrawComplexAssetDataParams) => Promise<ComplexWithdrawAssetData[]>;
9
10
  export {};
@@ -18,5 +18,11 @@ export declare const extractAvailableRouterKeys: (vaultAssetsWithSwapQuotes: Vau
18
18
  export declare const buildComplexAssetDataForRouter: (vaultAssetsWithSwapQuotes: VaultAssetWithSwapQuotes[], routerKey: SwapDataResponse['routerKey'], slippageTolerance: bigint) => ComplexWithdrawAssetData[];
19
19
  export declare const tryEstimateWithRouters: (availableRouterKeys: Array<SwapDataResponse['routerKey']>, vaultAssetsWithSwapQuotes: VaultAssetWithSwapQuotes[], slippageTolerance: bigint, estimate: EstimateCall, transactionArgs: unknown[]) => Promise<ComplexWithdrawAssetData[] | null>;
20
20
  export declare const createDefaultComplexAssetData: (supportedVaultAssets: Address[] | undefined, slippageTolerance: bigint) => ComplexWithdrawAssetData[];
21
+ /**
22
+ * Tries slippage candidates from lowest to highest.
23
+ * For each candidate, re-fetches swap quotes at that slippage, then tries all routers.
24
+ * Returns the first complexAssetData that passes estimation, or null if all candidates fail.
25
+ */
26
+ export declare const tryEstimateWithSlippageValues: (slippageCandidates: number[], fetchQuotesForSlippage: (candidateSlippage: number) => Promise<VaultAssetWithSwapQuotes[]>, estimate: EstimateCall, transactionArgs: unknown[]) => Promise<ComplexWithdrawAssetData[] | null>;
21
27
  export declare const enrichAssetsWithSwapQuotes: (supportedVaultAssets: Address[] | undefined, aaveLendingPoolV3Address: Address, { fetchAaveSwapParams, fetchAaveSwapQuotes, withdrawAmountD18, slippage, }: EnrichAssetParams) => Promise<VaultAssetWithSwapQuotes[]>;
22
28
  export {};
@@ -17,10 +17,12 @@ export interface BuildZapDepositArgsParams {
17
17
  swapQuotes: SwapDataResponse[] | undefined;
18
18
  estimate: EstimateCall;
19
19
  depositSlippage: number;
20
+ isAutoSlippage?: boolean;
21
+ autoSlippageCandidates?: number[];
20
22
  sendTokenAddress: Address;
21
23
  depositMethod: VaultDepositParams['depositMethod'];
22
24
  referralData?: Hex;
23
25
  }
24
26
  export declare const buildDepositTransactionArgumentsForMethod: (depositMethod: VaultDepositParams['depositMethod'], baseArgs: BuildZapDepositArgsParams['baseArgs'], zapArguments?: unknown[], referralData?: Hex) => DepositArguments;
25
- export declare const buildZapDepositArguments: ({ baseArgs, swapQuotes, estimate, depositSlippage, sendTokenAddress, depositMethod, referralData, }: BuildZapDepositArgsParams) => Promise<DepositArguments>;
27
+ export declare const buildZapDepositArguments: ({ baseArgs, swapQuotes, estimate, depositSlippage, isAutoSlippage, autoSlippageCandidates, sendTokenAddress, depositMethod, referralData, }: BuildZapDepositArgsParams) => Promise<DepositArguments>;
26
28
  export declare const isZapDepositMethod: (depositMethod: DepositMethodName) => boolean;
@@ -11,3 +11,4 @@ export * from '../utils/flat-money';
11
11
  export * from '../utils/logger';
12
12
  export * from '../utils/gmx';
13
13
  export * from '../utils/complex-withdraw-asset-data';
14
+ export * from '../utils/slippage-auto-simulation';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns slippage candidates (low → high) clamped by a maximum (resolved) slippage.
3
+ * Ensures the max value itself is always included (rounded to 2 decimals) when > 0.
4
+ */
5
+ export declare const getAutoSlippageSimulationCandidates: ({ maxSlippage, candidates, }: {
6
+ maxSlippage: number;
7
+ candidates?: number[] | undefined;
8
+ }) => number[];
@@ -22,10 +22,11 @@ export declare const buildZapDepositTransactionArguments: ({ vaultAddress, swapD
22
22
  swapDestinationAmount: string;
23
23
  swapSlippage: number;
24
24
  }) => (string | (string | `0x${string}`[])[][])[];
25
- export declare const buildSwapWithdrawTransactionData: ({ receiveAssetAddress, assets, swapData, }: {
25
+ export declare const buildSwapWithdrawTransactionData: ({ receiveAssetAddress, assets, swapData, slippage, }: {
26
26
  receiveAssetAddress: Address;
27
27
  assets: ReturnType<typeof useCompleteWithdrawTrackedAssets>['data'];
28
28
  swapData: SwapDataMap;
29
+ slippage: number;
29
30
  }) => unknown[][];
30
31
  export declare const buildAaveWithdrawAssetTransactionData: ({ assetAddress, swapQuotes, swapParams, slippageToleranceForContractTransaction, routerKey, }: {
31
32
  assetAddress: Address;