@dhedge/trading-widget 5.9.0 → 5.11.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 +17 -20
- package/complex-withdraw-asset-data-DKDPznHy.cjs +1 -0
- package/{complex-withdraw-asset-data-D8GMw8ql.js → complex-withdraw-asset-data-DzhKTztw.js} +119 -144
- package/const.cjs +1 -1
- package/const.js +32 -32
- package/core-kit/const/logger.d.ts +2 -5
- package/core-kit/const/storage.d.ts +0 -1
- package/core-kit/hooks/state/action.d.ts +0 -1
- package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-deposit-common.d.ts +1 -1
- package/core-kit/hooks/trading/deposit-v2/use-get-vault-deposit-transaction-arguments.d.ts +1 -1
- package/core-kit/hooks/trading/deposit-v2/use-vault-deposit-tokens.d.ts +5 -1
- package/core-kit/hooks/trading/index.d.ts +0 -1
- package/core-kit/hooks/web3/index.d.ts +0 -1
- package/core-kit/types/state.types.d.ts +0 -1
- package/core-kit/types/trading-panel.types.d.ts +2 -3
- package/core-kit/utils/deposit.d.ts +1 -1
- package/core-kit/utils/index.d.ts +0 -1
- package/{storage-C0zg_Mfy.js → gmx-BroDb_q_.js} +156 -160
- package/gmx-CLiWBUH_.cjs +1 -0
- package/index.cjs +1 -1
- package/index.d.ts +4 -2
- package/index.js +6592 -5772
- package/limit-orders/common/network-check-button.d.ts +7 -0
- package/limit-orders/common/network-check-button.hooks.d.ts +4 -0
- package/limit-orders/common/utils.d.ts +2 -0
- package/limit-orders/index.d.ts +9 -5
- package/limit-orders/limit-buys/component/input-group/input-amount-field.d.ts +2 -0
- package/limit-orders/limit-buys/component/input-group/input-amount-field.hooks.d.ts +11 -0
- package/limit-orders/limit-buys/component/input-group/input-group.d.ts +2 -0
- package/limit-orders/limit-buys/component/input-group/input-group.hooks.d.ts +15 -0
- package/limit-orders/limit-buys/component/input-group/slippage-deadline-fields.d.ts +2 -0
- package/limit-orders/limit-buys/component/input-group/slippage-deadline-fields.hooks.d.ts +5 -0
- package/limit-orders/limit-buys/component/input-group/token-select-overlay.d.ts +10 -0
- package/limit-orders/limit-buys/component/limit-buy-button/sign-limit-buy-button.d.ts +6 -0
- package/limit-orders/limit-buys/component/limit-buy-button/sign-limit-buy-button.hooks.d.ts +6 -0
- package/limit-orders/limit-buys/component/limit-buy-content.d.ts +6 -0
- package/limit-orders/limit-buys/component/limit-buy-order-modal.d.ts +14 -0
- package/limit-orders/limit-buys/component/limit-buy-overlay.d.ts +11 -0
- package/limit-orders/limit-buys/component/terms-confirmation.d.ts +8 -0
- package/limit-orders/limit-buys/constants.d.ts +55 -0
- package/limit-orders/limit-buys/hooks/state.d.ts +2 -0
- package/limit-orders/limit-buys/hooks/use-approve-and-sign-limit-buy.d.ts +7 -0
- package/limit-orders/limit-buys/hooks/use-is-permit2-approved.d.ts +1 -0
- package/limit-orders/limit-buys/hooks/use-permit2-approve-transaction.d.ts +5 -0
- package/limit-orders/limit-buys/hooks/use-sign-limit-buy-order.d.ts +3 -0
- package/limit-orders/limit-buys/providers/state-provider/reducer.d.ts +3 -0
- package/limit-orders/limit-buys/providers/state-provider/state-provider.d.ts +6 -0
- package/limit-orders/limit-buys/providers/state-provider/state-provider.types.d.ts +69 -0
- package/limit-orders/limit-buys/providers/translation-provider/index.d.ts +3 -0
- package/limit-orders/limit-buys/providers/translation-provider/translation-provider.d.ts +4 -0
- package/limit-orders/limit-buys/providers/translation-provider/translation-provider.defaults.d.ts +2 -0
- package/limit-orders/limit-buys/providers/translation-provider/translation-provider.hooks.d.ts +1 -0
- package/limit-orders/limit-buys/providers/translation-provider/translation-provider.types.d.ts +29 -0
- package/limit-orders/limit-buys/types.d.ts +27 -0
- package/limit-orders/limit-buys/utils.d.ts +4 -0
- package/limit-orders/{component → limit-sells/component}/input-group/input-group.hooks.d.ts +0 -2
- package/limit-orders/{component → limit-sells/component}/limit-order-button/approve-and-create-limit-order-button.d.ts +1 -0
- package/limit-orders/{component → limit-sells/component}/limit-order-content.d.ts +1 -1
- package/limit-orders/{component → limit-sells/component}/limit-order-overlay.d.ts +3 -3
- package/limit-orders/{component/limit-order-modal.d.ts → limit-sells/component/limit-sell-order-modal.d.ts} +5 -5
- package/limit-orders/limit-sells/component/terms-confirmation.d.ts +8 -0
- package/limit-orders/{constants.d.ts → limit-sells/constants.d.ts} +2 -2
- package/limit-orders/limit-sells/hooks/use-invalidate-limit-sell-order-query.d.ts +1 -0
- package/limit-orders/{hooks → limit-sells/hooks}/use-on-limit-order-settled.d.ts +1 -1
- package/limit-orders/{hooks/use-user-limit-order.d.ts → limit-sells/hooks/use-user-limit-sell-order.d.ts} +3 -3
- package/limit-orders/{providers → limit-sells/providers}/state-provider/reducer.d.ts +1 -1
- package/limit-orders/{providers → limit-sells/providers}/state-provider/state-provider.d.ts +1 -1
- package/limit-orders/{providers → limit-sells/providers}/state-provider/state-provider.types.d.ts +1 -1
- package/limit-orders/{utils.d.ts → limit-sells/utils.d.ts} +3 -3
- package/limit-orders/providers/translation-provider/translation-provider.types.d.ts +1 -0
- package/package.json +1 -1
- package/{derive-BmKPodpX.js → storage-CSc9iE5L.js} +6 -2
- package/storage-DHoO5PX_.cjs +1 -0
- package/style.css +1 -1
- package/trading-widget/components/deposit/button/valid-deposit-button/valid-deposit-button.hooks.d.ts +0 -2
- package/trading-widget/components/widget/widget-buttons/index.d.ts +1 -0
- package/trading-widget/components/widget/widget-buttons/limit-buy-button/limit-buy-button.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/hyper-evm-warning-overlay/hyper-evm-warning-overlay.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/index.d.ts +2 -0
- package/trading-widget/components/widget/widget-overlay/limit-buys-overlay/limit-buys-overlay.d.ts +3 -0
- package/trading-widget/components/widget/widget-overlay/limit-buys-overlay/limit-buys-overlay.hooks.d.ts +17 -0
- package/trading-widget/components/widget/widget-settings/index.d.ts +0 -1
- package/trading-widget/components/widget/widget-settings/slippage-selector/slippage-selector.hooks.d.ts +0 -1
- package/trading-widget/hooks/index.d.ts +3 -1
- package/trading-widget/hooks/use-display-limit-buy-overlay.d.ts +1 -0
- package/trading-widget/hooks/use-open-limit-buys-overlay.d.ts +4 -0
- package/trading-widget/hooks/use-show-hyper-evm-deposit-warning.d.ts +1 -0
- package/trading-widget/providers/config-provider/config-provider.types.d.ts +3 -0
- package/trading-widget/providers/translation-provider/translation-provider.types.d.ts +7 -5
- package/trading-widget/types/overlay.types.d.ts +2 -0
- package/utils.cjs +1 -1
- package/utils.js +32 -34
- package/complex-withdraw-asset-data-DSjzOaBD.cjs +0 -1
- package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-batch-approve-transaction.d.ts +0 -141
- package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-batch-deposit.d.ts +0 -1
- package/core-kit/hooks/trading/trade-handlers/use-batch-trading-settle-handler.d.ts +0 -5
- package/core-kit/hooks/trading/use-is-batch-contract-writes-trading.d.ts +0 -1
- package/core-kit/hooks/web3/use-custom-send-calls.d.ts +0 -14
- package/core-kit/hooks/web3/use-is-batch-contract-writes-supported.d.ts +0 -1
- package/core-kit/utils/batch-transactions.d.ts +0 -2
- package/derive-CsdqSZEg.cjs +0 -1
- package/limit-orders/component/input-group/terms-content.d.ts +0 -6
- package/limit-orders/component/limit-order-button/network-check-button.d.ts +0 -2
- package/limit-orders/component/limit-order-button/network-check-button.hooks.d.ts +0 -4
- package/limit-orders/hooks/use-invalidate-limit-order-query.d.ts +0 -1
- package/storage-B9jNfIvl.cjs +0 -1
- package/trading-widget/components/deposit/button/batch-trade-button.d.ts +0 -2
- package/trading-widget/components/widget/widget-settings/batch-transactions-switch/batch-transactions-switch.d.ts +0 -2
- package/trading-widget/components/widget/widget-settings/batch-transactions-switch/batch-transactions-switch.hooks.d.ts +0 -1
- package/trading-widget/hooks/use-trading-type-name.d.ts +0 -2
- /package/limit-orders/{component/common → common}/action-button.d.ts +0 -0
- /package/limit-orders/{component/common → common}/asset-price-panel.d.ts +0 -0
- /package/limit-orders/{component/common → common}/modal-content.d.ts +0 -0
- /package/limit-orders/{component/common → common}/modal-dialog.d.ts +0 -0
- /package/limit-orders/{component/common → common}/percentage-input.d.ts +0 -0
- /package/limit-orders/{component/common → common}/price-input.d.ts +0 -0
- /package/limit-orders/{component/common → common}/switch-panel.d.ts +0 -0
- /package/limit-orders/{component → limit-sells/component}/input-group/input-group.d.ts +0 -0
- /package/limit-orders/{component → limit-sells/component}/limit-order-button/approve-and-create-limit-order-button.hooks.d.ts +0 -0
- /package/limit-orders/{component → limit-sells/component}/limit-order-button/limit-order-delete-button.d.ts +0 -0
- /package/limit-orders/{component → limit-sells/component}/limit-order-button/limit-order-delete-button.hooks.d.ts +0 -0
- /package/limit-orders/{component → limit-sells/component}/limit-order-content.hooks.d.ts +0 -0
- /package/limit-orders/{component → limit-sells/component}/limit-order-modal.hooks.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/state.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-approve-and-create-limit-order.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-create-limit-order-transaction.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-existing-limit-order-default-prices.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-is-limit-order-approved.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-limit-order-approve-transaction.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-limit-order-covered-vault-amount.d.ts +0 -0
- /package/limit-orders/{hooks → limit-sells/hooks}/use-listen-limit-order-execution.d.ts +0 -0
package/README.md
CHANGED
|
@@ -54,21 +54,21 @@ Top level provider component. Headless part of trading logic. API handles params
|
|
|
54
54
|
<details>
|
|
55
55
|
<summary><code>actions</code> <code><b>/</b></code> <code>Optional General callbacks to interact with 3rd party services</code></summary>
|
|
56
56
|
|
|
57
|
-
> | name | type
|
|
58
|
-
> | ------------------------------ |
|
|
59
|
-
> | `onUpdateSendTokenInput` | (payload: Partial\<{ address: `Address`; symbol: `string`; value: `string`; decimals: `number`; isLoading?: `boolean` }\>) => void
|
|
60
|
-
> | `onUpdateTradingSettings` | (payload: Partial\<{ slippage: `number \| 'auto'`; minSlippage?: `number` isInfiniteAllowance: `boolean`; isMultiAssetWithdrawalEnabled: `boolean`; isCustomDepositOptionsDisabled?: `boolean`; isMaxSlippageLoading: `boolean` }\>) => void
|
|
61
|
-
> | `onSetTradingType` | (payload: `'deposit' \| 'withdraw'`) => void
|
|
62
|
-
> | `onUpdateTradingModal` | (payload: Partial\<{ isOpen: `boolean`; status: `'Success' \| 'None' \| 'Mining' \| 'Wallet'` }\>) => void
|
|
63
|
-
> | `onUpdateTransactions` | (payload: AddTransaction \| UpdateTransaction \| RemoveTransaction) => void
|
|
64
|
-
> | `onTradingSettleError` | (error: `Error`) => void
|
|
65
|
-
> | `onTransactionError` | (error: `Error`, action: `TransactionAction` \| `undefined`, chainId?: `ChainId`, txHash?: `Address`) => void
|
|
66
|
-
> | `onTransactionSuccess` | (data: `WaitForTransactionReceiptReturnType`, action: `TransactionAction` \| `undefined`, link?: `string`) => void
|
|
67
|
-
> | `onTransactionEstimationError` | (error: `EstimationError`, address: `Address`, chainId?: `ChainId`, account?: `Address`) => void
|
|
68
|
-
> | `onTokenSelector` | (payload: { isOpen: `boolean`; entity: `'token' \| 'pool'` }) => void
|
|
69
|
-
> | `onLog` | (eventName: `string`, payload?: `Record<string, unknown>`) => void
|
|
70
|
-
> | `onSimulateTransaction` | (payload: { chainId: `ChainId`; from: `Address`: to: `Address`; input: `string`; gas: `number`; value?: `string` }) => Promise<{ link?: `string`; simulation: { status: `boolean`; error_message: `string` } } \| null>
|
|
71
|
-
> | `getSwapQuotes` | ({ signal: `AbortSignal`, variables: { chainId: `number`; sourceAddress: `Address`; destinationAddress: `Address`; walletAddress: `Address`; fromAddress: `Address`; amount: `string`; slippage: `string` } }) => Promise<Array <{ destinationAmount: `string`; rawTransaction: `{ data: string }` ; routerKey: `'ONE_INCH' / '
|
|
57
|
+
> | name | type | default value | description |
|
|
58
|
+
> | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------- |
|
|
59
|
+
> | `onUpdateSendTokenInput` | (payload: Partial\<{ address: `Address`; symbol: `string`; value: `string`; decimals: `number`; isLoading?: `boolean` }\>) => void | undefined | triggers on send token change |
|
|
60
|
+
> | `onUpdateTradingSettings` | (payload: Partial\<{ slippage: `number \| 'auto'`; minSlippage?: `number` isInfiniteAllowance: `boolean`; isMultiAssetWithdrawalEnabled: `boolean`; isCustomDepositOptionsDisabled?: `boolean`; isMaxSlippageLoading: `boolean` }\>) => void | undefined | triggers on trading settings change |
|
|
61
|
+
> | `onSetTradingType` | (payload: `'deposit' \| 'withdraw'`) => void | undefined | triggers on trading type change |
|
|
62
|
+
> | `onUpdateTradingModal` | (payload: Partial\<{ isOpen: `boolean`; status: `'Success' \| 'None' \| 'Mining' \| 'Wallet'` }\>) => void | undefined | triggers on trading modal change |
|
|
63
|
+
> | `onUpdateTransactions` | (payload: AddTransaction \| UpdateTransaction \| RemoveTransaction) => void | undefined | triggers on transaction action change |
|
|
64
|
+
> | `onTradingSettleError` | (error: `Error`) => void | undefined | triggers on trading settle error |
|
|
65
|
+
> | `onTransactionError` | (error: `Error`, action: `TransactionAction` \| `undefined`, chainId?: `ChainId`, txHash?: `Address`) => void | undefined | triggers on transaction error |
|
|
66
|
+
> | `onTransactionSuccess` | (data: `WaitForTransactionReceiptReturnType`, action: `TransactionAction` \| `undefined`, link?: `string`) => void | undefined | triggers on transaction success |
|
|
67
|
+
> | `onTransactionEstimationError` | (error: `EstimationError`, address: `Address`, chainId?: `ChainId`, account?: `Address`) => void | undefined | triggers on transaction estimation error |
|
|
68
|
+
> | `onTokenSelector` | (payload: { isOpen: `boolean`; entity: `'token' \| 'pool'` }) => void | undefined | triggers on token selector change |
|
|
69
|
+
> | `onLog` | (eventName: `string`, payload?: `Record<string, unknown>`) => void | undefined | triggers on log event |
|
|
70
|
+
> | `onSimulateTransaction` | (payload: { chainId: `ChainId`; from: `Address`: to: `Address`; input: `string`; gas: `number`; value?: `string` }) => Promise<{ link?: `string`; simulation: { status: `boolean`; error_message: `string` } } \| null> | undefined | triggers to simulate transaction and get error details after failed tx estimation |
|
|
71
|
+
> | `getSwapQuotes` | ({ signal: `AbortSignal`, variables: { chainId: `number`; sourceAddress: `Address`; destinationAddress: `Address`; walletAddress: `Address`; fromAddress: `Address`; amount: `string`; slippage: `string` } }) => Promise<Array <{ destinationAmount: `string`; rawTransaction: `{ data: string }` ; routerKey: `'ONE_INCH' / 'PARASWAP_V6' / 'KYBER_SWAP_V2'` } }> \| null> | undefined | provides off chain swap quotes based on send token value |
|
|
72
72
|
|
|
73
73
|
###### Source: `packages/trading-widget/src/core-kit/providers/index.tsx`
|
|
74
74
|
|
|
@@ -154,8 +154,8 @@ The optional `settings.aggregatorLimitPerChain` field allows restricting which a
|
|
|
154
154
|
<TradingPanelProvider
|
|
155
155
|
initialState={{
|
|
156
156
|
settings: {
|
|
157
|
-
availableAggregators: ['
|
|
158
|
-
selectedAggregators: ['
|
|
157
|
+
availableAggregators: ['ParaSwap', '1inch', 'KyberSwap'],
|
|
158
|
+
selectedAggregators: ['ParaSwap', '1inch', 'KyberSwap'],
|
|
159
159
|
aggregatorLimitPerChain: {
|
|
160
160
|
[hyperEvm.id]: ['KyberSwap'], // hyperEVM only uses KyberSwap
|
|
161
161
|
},
|
|
@@ -665,9 +665,6 @@ path: `component.meta[name]`
|
|
|
665
665
|
> | `proceedWithNextStep` | string | Please proceed with the next step. | |
|
|
666
666
|
> | `aggregatorsLabel` | string | Swap source | |
|
|
667
667
|
> | `aggregatorsTooltip` | string | Choose which aggregators to use for your trades. | |
|
|
668
|
-
> | `batchTransactionsLabel` | string | Batch transactions | |
|
|
669
|
-
> | `batchTransactionsSwitchLabel` | string | Batch | |
|
|
670
|
-
> | `batchTransactionsTooltip` | string | Group approve and trade calls into a single batch transaction. Disable if you prefer separate prompts. | |
|
|
671
668
|
> | `openLimitOrderAfterBuySwitchLabel` | string | Add Stop Order | |
|
|
672
669
|
> | `openNotificationsSettingsLabel` | string | Enable alerts | |
|
|
673
670
|
> | `addToWallet` | string | add to wallet | |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("bignumber.js"),s=require("./gmx-CLiWBUH_.cjs"),m=require("viem"),M=()=>typeof window<"u";function P(){return M()&&typeof window.ethereum<"u"}async function x(t){try{if(P())return window.ethereum.request({method:"wallet_watchAsset",params:{type:"ERC20",options:t}})}catch{return!1}return!1}const l=(t,e)=>t?.toLowerCase()===e?.toLowerCase(),U=t=>l(t,s.AddressZero$1),f=(t,e)=>s.contractsAddressesMap[e]?.[t]??s.AddressZero,$=t=>s.contractsAbisMap[t],W=t=>t&&`${t.substring(0,6)}...${t.substring(t.length-4,t.length)}`,G=({address:t,chainId:e})=>{const r=f("aaveLendingPoolV3",e);return l(t,r)},N=({sourceAddress:t,amount:e})=>`${t}_${e}`,K=(t,e)=>{const r=t.slice(0,e),n=t.slice(e);return{firstPart:r,secondPart:n}},y=(t,e)=>t/e*100,V=t=>t<1?4:t<10?3:2,Y=(t,e=s.DEFAULT_PRECISION)=>new c(t.toString()).shiftedBy(e).toFixed(0),Z=(t,e,r,n)=>new c(e).dividedBy(r).multipliedBy(t).shiftedBy(-(n||s.DEFAULT_PRECISION)).toNumber(),k=t=>BigInt(new c(t||"0").shiftedBy(s.DEFAULT_PRECISION).toFixed(0,c.ROUND_DOWN)),H=t=>{const e=new c(.01),r=new c(t),n=!r.isZero()&&r.lt(e)?e:r;return BigInt(n.multipliedBy(100).toFixed(0))},Q=({vaultAddress:t,swapData:e,sendTokenAddress:r,sendTokenAmount:n,vaultDepositTokenAddress:o,minVaultTokensReceivedAmount:a,routerKey:i="ONE_INCH",swapDestinationAmount:d,swapSlippage:u})=>{const A=new c(d).multipliedBy(1-u/100).toFixed(0),g=[m.stringToHex(i,{size:32}),e];return[t,[[r,n,g],[o,A]],a]},q=({receiveAssetAddress:t,assets:e,swapData:r})=>{const n={srcData:[],destAmount:new c("0")},{srcData:o}=e?.reduce((a,i)=>{const d=r?.[i.address];if(!d)return a;const u=[m.stringToHex(d.routerKey,{size:32}),d.rawTransaction.data],A=[i.address,i.rawBalance,u];return{srcData:[...a.srcData,A],destAmount:a.destAmount.plus(d.destinationAmount)}},n)??n;return[o,[t,"0"]]},w=({assetAddress:t,swapQuotes:e,swapParams:r,slippageToleranceForContractTransaction:n,routerKey:o})=>{if(!r)return{supportedAsset:t,withdrawData:"",slippageTolerance:BigInt(0)};const{srcData:a,dstData:i}=r,d=a.map(({asset:g,amount:T})=>{const p=e?.[N({sourceAddress:g,amount:T.toString()})]?.find(v=>v.routerKey===o);return{asset:g,amount:T,swapData:{routerKey:m.stringToHex(p?.routerKey??"",{size:32}),txData:p?.rawTransaction.data??"0x"}}}),u=m.encodeAbiParameters(s.ComplexWithdrawalAssetSrcDataAbiItem,[d]),A=m.encodeAbiParameters(s.ComplexWithdrawalDataAbiItem,[{encodedSrcData:u,dstData:{dstAddress:i.asset,dstAmount:i.amount},slippage:n}]);return{supportedAsset:t,withdrawData:A,slippageTolerance:n}},z=(t,e)=>s.CHAIN_NATIVE_TOKENS[e]?.nativeTokenSymbol===t,j=({nativeTokenBalance:t,tokenDecimals:e,gasPrice:r})=>{const n=new c(r).multipliedBy(s.NATIVE_TOKEN_DEPOSIT_GAS_LIMIT).shiftedBy(-e),o=new c(t).minus(n);return o.gt("0")?o:new c("0")},X=t=>s.STABLE_TOKEN_SYMBOLS.includes(t),J=t=>{const e=Object.values(t).reduce((r,{type:n})=>(r[n]=r[n]+1,r),{string:0,number:0});if(e.string>10)throw new Error("logger params must contain up to 10 string values");if(e.number>40)throw new Error("logger params must contain up to 40 numeric values");return!0},tt=(t,e=150)=>t.length>e?t.substring(0,e):t,S=(t,e=s.TRANSACTION_ERROR_KEYS)=>{const r=t.toLowerCase();return e.sort((n,o)=>o.length-n.length).find(n=>r.includes(n.toLowerCase()))},_=t=>s.TRANSACTION_ERRORS[t]??s.LIMIT_ORDER_TRANSACTION_ERRORS[t],et=({errorMessage:t,abiErrors:e})=>{if(!t||t.includes("User rejected"))return null;const r=e.find(a=>t.includes(a));if(r&&S(r))return _(r);const n=S(t);if(n)return _(n);const[o]=t.split(r?".":"Contract").map(a=>a.trim());return{title:"Transaction failed",hint:`${tt(o??"")} ${r?`: ${r}`:""}`}},rt=t=>typeof t=="number"&&Number.isFinite(t),nt=t=>typeof t=="bigint"&&t!==BigInt(0),h=(t,e=s.DEFAULT_PRECISION$1)=>new c(t).shiftedBy(-e).toNumber(),I=t=>!isNaN(parseFloat(t))&&!isNaN(t),L=({value:t,minimumFractionDigits:e=2,maximumFractionDigits:r=2,compact:n=!1,normalize:o=!1})=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:n?"compact":void 0,minimumFractionDigits:e,maximumFractionDigits:r}).format(o?h(t):Number(t)),D=t=>I(t)?new c(t).toFixed():"",E=["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉"],B=({value:t,decimals:e=4})=>{const r=new c(t);if(r.isGreaterThan(1)||r.isZero())return D(r.toFixed(e));const o=(/e/i.test(t.toString())?parseFloat(t.toString()).toFixed(s.DEFAULT_PRECISION$1):t.toString()).match(/^0\.(0+)(\d+)$/);if(o){const[,a,i]=o;if(a.length>=e&&a.length<E.length)return`0.0${E[a.length]}${i.slice(0,3)}`}return D(r.toFixed(e))},R=(t,e=0)=>`${t.toLocaleString("en-US",{maximumFractionDigits:e})}%`,st=t=>t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),ot=(t,e,r=0)=>{const n=y(+t,e);return R(n,r)},at=({currency:t,value:e})=>t==="USD"?L({value:e}):`${s.CURRENCY_SYMBOL_MAP[t]} ${B({value:e,decimals:s.CURRENCY_DECIMALS_MAP[t]})}`,b=(t,e)=>new c(new c(t).toFixed(e,c.ROUND_DOWN)).toString(),C=(t,e=3,r=2)=>{if(t.length<=5)return t;const n="...";return t.length<=e+r+n.length?t:`${t.slice(0,e)}${n}${t.slice(-r)}`},it=({balance:t,symbol:e,precision:r,truncateSymbol:n})=>`${b(t,r)} ${n?C(e):e}`,ct=t=>{if(!t)return;const e=t.match(/0x[a-fA-F0-9]{64}/);if(!e)return;const r=e[0];return`${r.slice(0,4)}...${r.slice(-3)}`},dt=typeof window<"u",ut=t=>l(s.FLATMONEY_EARLY_DEPOSITOR_VAULT_ADDRESS_BASE,t)||l(s.FLATMONEY_DHT_STAKING_VAULT_ADDRESS_BASE,t),lt=t=>s.FLAT_MONEY_LEVERAGED_ASSET_ADDRESSES.some(e=>l(e,t)),At=t=>s.FLAT_MONEY_COLLATERAL_MAP[t.toLowerCase()]??{symbol:"",decimals:18,address:s.AddressZero},mt=t=>l(t,s.FLAT_MONEY_V1_UNIT_ADDRESS)?s.FLAT_MONEY_V1_UNIT_LINK:s.FLAT_MONEY_UNIT_LINK,F=t=>`eth_${t}`,gt=({action:t,log:e,symbol:r,vaultAddress:n,chainId:o})=>{const a={[s.TRADING_LOG_EVENT_PARAM.SYMBOL.NAME]:r,[s.TRADING_LOG_EVENT_PARAM.CHAIN_ID.NAME]:o,[s.TRADING_LOG_EVENT_PARAM.ADDRESS.NAME]:F(n)};s.LOG_EVENT_BY_TRANSACTION_ACTION_MAP[t].forEach(i=>{e?.(i,a)})},Tt=t=>s.GMX_MARKET_ASSETS.some(e=>l(e,t)),pt=t=>s.GMX_WITHDRAW_ASSET_MAP[t.toLowerCase()]??{symbol:"",decimals:18,address:s.AddressZero},St=t=>s.GMX_WITHDRAW_ASSET_MAP_BY_VAULT_ADDRESS[t.toLowerCase()],Dt=t=>{const e=t.find(({swapQuotes:r})=>r);return e?.swapQuotes?Object.values(e.swapQuotes)[0]?.map(({routerKey:r})=>r)??[]:[]},O=(t,e,r)=>t.map(({asset:n,swapParams:o,swapQuotes:a})=>!o||!a?{supportedAsset:n,withdrawData:"",slippageTolerance:r}:w({assetAddress:n,swapQuotes:a,swapParams:o,slippageToleranceForContractTransaction:r,routerKey:e})),_t=async(t,e,r,n,o)=>{for(const a of t){const i=O(e,a,r),{error:d}=await n(...o,i);if(!d)return i}return null},Et=(t,e)=>(t??[]).map(r=>({supportedAsset:r,withdrawData:"",slippageTolerance:e})),ft=async(t,e,{fetchAaveSwapParams:r,fetchAaveSwapQuotes:n,withdrawAmountD18:o,slippage:a})=>Promise.all((t??[]).map(async i=>{if(!l(i,e))return{asset:i};try{const u=await r({withdrawAmountD18:o,slippage:a});if(u?.srcData.length){const A=await n({swapParams:u,slippage:a});return{asset:i,swapParams:u,swapQuotes:A}}return{asset:i}}catch(u){return console.error(u),{asset:i}}}));exports.addTokenToWallet=x;exports.buildAaveWithdrawAssetTransactionData=w;exports.buildComplexAssetDataForRouter=O;exports.buildSwapQuoteKeyForAave=N;exports.buildSwapWithdrawTransactionData=q;exports.buildZapDepositTransactionArguments=Q;exports.clientSide=dt;exports.commify=st;exports.createDefaultComplexAssetData=Et;exports.enrichAssetsWithSwapQuotes=ft;exports.extractAvailableRouterKeys=Dt;exports.formatBalance=b;exports.formatByCurrency=at;exports.formatNumberToLimitedDecimals=B;exports.formatNumeratorToPercentage=ot;exports.formatPercentage=R;exports.formatToUsd=L;exports.formatTokenBalance=it;exports.getContractAbiById=$;exports.getContractAddressById=f;exports.getConventionalTokenPriceDecimals=V;exports.getErrorKey=S;exports.getFlatMoneyCollateralByLeverageAddress=At;exports.getFlatMoneyLinkByUnitAddress=mt;exports.getGmxWithdrawAssetByLeverageAddress=pt;exports.getGmxWithdrawAssetByVaultAddress=St;exports.getNativeTokenInvestableBalance=j;exports.getPercent=y;exports.getPoolFraction=Z;exports.getSlippageToleranceForContractTransaction=H;exports.getTxHashShort=ct;exports.isAaveLendAndBorrowAsset=G;exports.isEqualAddress=l;exports.isFlatMoneyLeveragedAsset=lt;exports.isFmpAirdropVaultAddress=ut;exports.isGmxLeveragedAsset=Tt;exports.isNativeToken=z;exports.isNumberType=rt;exports.isNumeric=I;exports.isStableSymbol=X;exports.isZeroAddress=U;exports.logTransactionByActionType=gt;exports.nonZeroBigInt=nt;exports.normalizeNumber=h;exports.parseAmountToD18=k;exports.parseContractErrorMessage=et;exports.removeInsignificantTrailingZeros=D;exports.shiftBy=Y;exports.shortenAddress=W;exports.sliceByIndex=K;exports.transformAddressForAnalytics=F;exports.truncateString=C;exports.tryEstimateWithRouters=_t;exports.validateLoggerEventParams=J;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import i from "bignumber.js";
|
|
2
|
-
import {
|
|
3
|
-
import { stringToHex as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return
|
|
2
|
+
import { aj as L, ah as I, ai as R, b as S, q as T, ak as B, al as b, a3 as C, c as O, a7 as F, ad as M, ac as P, Z as x, am as h, f as $, e as v, M as U, R as K, P as W, an as V, ao as Y, Q as G, N as Z, aa as p, _ as H, W as k, X as Q, U as j } from "./gmx-BroDb_q_.js";
|
|
3
|
+
import { stringToHex as _, encodeAbiParameters as f } from "viem";
|
|
4
|
+
const z = () => typeof window < "u";
|
|
5
|
+
function X() {
|
|
6
|
+
return z() && typeof window.ethereum < "u";
|
|
7
7
|
}
|
|
8
|
-
async function
|
|
8
|
+
async function pt(t) {
|
|
9
9
|
try {
|
|
10
|
-
if (
|
|
10
|
+
if (X())
|
|
11
11
|
return window.ethereum.request({
|
|
12
12
|
method: "wallet_watchAsset",
|
|
13
13
|
params: {
|
|
@@ -20,30 +20,30 @@ async function _t(t) {
|
|
|
20
20
|
}
|
|
21
21
|
return !1;
|
|
22
22
|
}
|
|
23
|
-
const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(),
|
|
23
|
+
const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), St = (t) => d(t, L), q = (t, e) => R[e]?.[t] ?? S, Tt = (t) => I[t], _t = (t) => t && `${t.substring(0, 6)}...${t.substring(
|
|
24
24
|
t.length - 4,
|
|
25
25
|
t.length
|
|
26
|
-
)}`,
|
|
26
|
+
)}`, ft = ({
|
|
27
27
|
address: t,
|
|
28
28
|
chainId: e
|
|
29
29
|
}) => {
|
|
30
|
-
const s =
|
|
30
|
+
const s = q(
|
|
31
31
|
"aaveLendingPoolV3",
|
|
32
32
|
e
|
|
33
33
|
);
|
|
34
34
|
return d(t, s);
|
|
35
|
-
},
|
|
35
|
+
}, J = ({
|
|
36
36
|
sourceAddress: t,
|
|
37
37
|
amount: e
|
|
38
38
|
}) => `${t}_${e}`, Dt = (t, e) => {
|
|
39
39
|
const s = t.slice(0, e), a = t.slice(e);
|
|
40
40
|
return { firstPart: s, secondPart: a };
|
|
41
|
-
},
|
|
42
|
-
new i(t || "0").shiftedBy(
|
|
43
|
-
),
|
|
41
|
+
}, tt = (t, e) => t / e * 100, wt = (t) => t < 1 ? 4 : t < 10 ? 3 : 2, Et = (t, e = T) => new i(t.toString()).shiftedBy(e).toFixed(0), Nt = (t, e, s, a) => new i(e).dividedBy(s).multipliedBy(t).shiftedBy(-(a || T)).toNumber(), ht = (t) => BigInt(
|
|
42
|
+
new i(t || "0").shiftedBy(T).toFixed(0, i.ROUND_DOWN)
|
|
43
|
+
), yt = (t) => {
|
|
44
44
|
const e = new i(0.01), s = new i(t), a = !s.isZero() && s.lt(e) ? e : s;
|
|
45
45
|
return BigInt(a.multipliedBy(100).toFixed(0));
|
|
46
|
-
},
|
|
46
|
+
}, Lt = ({
|
|
47
47
|
vaultAddress: t,
|
|
48
48
|
swapData: e,
|
|
49
49
|
sendTokenAddress: s,
|
|
@@ -54,9 +54,9 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
54
54
|
swapDestinationAmount: c,
|
|
55
55
|
swapSlippage: u
|
|
56
56
|
}) => {
|
|
57
|
-
const l = new i(c).multipliedBy(1 - u / 100).toFixed(0), A = [
|
|
57
|
+
const l = new i(c).multipliedBy(1 - u / 100).toFixed(0), A = [_(o, { size: 32 }), e];
|
|
58
58
|
return [t, [[s, a, A], [n, l]], r];
|
|
59
|
-
},
|
|
59
|
+
}, It = ({
|
|
60
60
|
receiveAssetAddress: t,
|
|
61
61
|
assets: e,
|
|
62
62
|
swapData: s
|
|
@@ -69,7 +69,7 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
69
69
|
if (!c)
|
|
70
70
|
return r;
|
|
71
71
|
const u = [
|
|
72
|
-
|
|
72
|
+
_(c.routerKey, { size: 32 }),
|
|
73
73
|
c.rawTransaction.data
|
|
74
74
|
], l = [o.address, o.rawBalance, u];
|
|
75
75
|
return {
|
|
@@ -86,7 +86,7 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
86
86
|
"0"
|
|
87
87
|
]
|
|
88
88
|
];
|
|
89
|
-
},
|
|
89
|
+
}, et = ({
|
|
90
90
|
assetAddress: t,
|
|
91
91
|
swapQuotes: e,
|
|
92
92
|
swapParams: s,
|
|
@@ -100,22 +100,22 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
100
100
|
slippageTolerance: BigInt(0)
|
|
101
101
|
};
|
|
102
102
|
const { srcData: r, dstData: o } = s, c = r.map(({ asset: A, amount: m }) => {
|
|
103
|
-
const
|
|
103
|
+
const g = e?.[J({
|
|
104
104
|
sourceAddress: A,
|
|
105
105
|
amount: m.toString()
|
|
106
|
-
})]?.find((
|
|
106
|
+
})]?.find((y) => y.routerKey === n);
|
|
107
107
|
return {
|
|
108
108
|
asset: A,
|
|
109
109
|
amount: m,
|
|
110
110
|
swapData: {
|
|
111
|
-
routerKey:
|
|
112
|
-
txData:
|
|
111
|
+
routerKey: _(g?.routerKey ?? "", { size: 32 }),
|
|
112
|
+
txData: g?.rawTransaction.data ?? "0x"
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}), u = f(
|
|
116
|
-
|
|
116
|
+
B,
|
|
117
117
|
[c]
|
|
118
|
-
), l = f(
|
|
118
|
+
), l = f(b, [
|
|
119
119
|
{
|
|
120
120
|
encodedSrcData: u,
|
|
121
121
|
dstData: {
|
|
@@ -130,16 +130,16 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
130
130
|
withdrawData: l,
|
|
131
131
|
slippageTolerance: a
|
|
132
132
|
};
|
|
133
|
-
},
|
|
133
|
+
}, Rt = (t, e) => O[e]?.nativeTokenSymbol === t, Bt = ({
|
|
134
134
|
nativeTokenBalance: t,
|
|
135
135
|
tokenDecimals: e,
|
|
136
136
|
gasPrice: s
|
|
137
137
|
}) => {
|
|
138
|
-
const a = new i(s).multipliedBy(
|
|
138
|
+
const a = new i(s).multipliedBy(C).shiftedBy(-e), n = new i(t).minus(
|
|
139
139
|
a
|
|
140
140
|
);
|
|
141
141
|
return n.gt("0") ? n : new i("0");
|
|
142
|
-
},
|
|
142
|
+
}, bt = (t) => F.includes(t), Ct = (t) => {
|
|
143
143
|
const e = Object.values(t).reduce(
|
|
144
144
|
(s, { type: a }) => (s[a] = s[a] + 1, s),
|
|
145
145
|
{ string: 0, number: 0 }
|
|
@@ -149,27 +149,27 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
149
149
|
if (e.number > 40)
|
|
150
150
|
throw new Error("logger params must contain up to 40 numeric values");
|
|
151
151
|
return !0;
|
|
152
|
-
},
|
|
152
|
+
}, st = (t, e = 150) => t.length > e ? t.substring(0, e) : t, D = (t, e = M) => {
|
|
153
153
|
const s = t.toLowerCase();
|
|
154
154
|
return e.sort((a, n) => n.length - a.length).find((a) => s.includes(a.toLowerCase()));
|
|
155
|
-
},
|
|
155
|
+
}, w = (t) => P[t] ?? x[t], Ot = ({
|
|
156
156
|
errorMessage: t,
|
|
157
157
|
abiErrors: e
|
|
158
158
|
}) => {
|
|
159
159
|
if (!t || t.includes("User rejected"))
|
|
160
160
|
return null;
|
|
161
161
|
const s = e.find((r) => t.includes(r));
|
|
162
|
-
if (s &&
|
|
163
|
-
return
|
|
164
|
-
const a =
|
|
162
|
+
if (s && D(s))
|
|
163
|
+
return w(s);
|
|
164
|
+
const a = D(t);
|
|
165
165
|
if (a)
|
|
166
|
-
return
|
|
166
|
+
return w(a);
|
|
167
167
|
const [n] = t.split(s ? "." : "Contract").map((r) => r.trim());
|
|
168
168
|
return {
|
|
169
169
|
title: "Transaction failed",
|
|
170
|
-
hint: `${
|
|
170
|
+
hint: `${st(n ?? "")} ${s ? `: ${s}` : ""}`
|
|
171
171
|
};
|
|
172
|
-
},
|
|
172
|
+
}, Ft = (t) => typeof t == "number" && Number.isFinite(t), Mt = (t) => typeof t == "bigint" && t !== BigInt(0), at = (t, e = h) => new i(t).shiftedBy(-e).toNumber(), nt = (t) => !isNaN(parseFloat(t)) && !isNaN(t), rt = ({
|
|
173
173
|
value: t,
|
|
174
174
|
minimumFractionDigits: e = 2,
|
|
175
175
|
maximumFractionDigits: s = 2,
|
|
@@ -181,42 +181,42 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
181
181
|
notation: a ? "compact" : void 0,
|
|
182
182
|
minimumFractionDigits: e,
|
|
183
183
|
maximumFractionDigits: s
|
|
184
|
-
}).format(n ?
|
|
184
|
+
}).format(n ? at(t) : Number(t)), E = (t) => nt(t) ? new i(t).toFixed() : "", N = ["₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"], ot = ({
|
|
185
185
|
value: t,
|
|
186
186
|
decimals: e = 4
|
|
187
187
|
}) => {
|
|
188
188
|
const s = new i(t);
|
|
189
189
|
if (s.isGreaterThan(1) || s.isZero())
|
|
190
|
-
return
|
|
190
|
+
return E(s.toFixed(e));
|
|
191
191
|
const n = (/e/i.test(t.toString()) ? parseFloat(t.toString()).toFixed(h) : t.toString()).match(/^0\.(0+)(\d+)$/);
|
|
192
192
|
if (n) {
|
|
193
193
|
const [, r, o] = n;
|
|
194
|
-
if (r.length >= e && r.length <
|
|
195
|
-
return `0.0${
|
|
194
|
+
if (r.length >= e && r.length < N.length)
|
|
195
|
+
return `0.0${N[r.length]}${o.slice(0, 3)}`;
|
|
196
196
|
}
|
|
197
|
-
return
|
|
198
|
-
},
|
|
199
|
-
const a =
|
|
200
|
-
return
|
|
201
|
-
},
|
|
197
|
+
return E(s.toFixed(e));
|
|
198
|
+
}, it = (t, e = 0) => `${t.toLocaleString("en-US", { maximumFractionDigits: e })}%`, Pt = (t) => t.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), xt = (t, e, s = 0) => {
|
|
199
|
+
const a = tt(+t, e);
|
|
200
|
+
return it(a, s);
|
|
201
|
+
}, $t = ({
|
|
202
202
|
currency: t,
|
|
203
203
|
value: e
|
|
204
|
-
}) => t === "USD" ?
|
|
204
|
+
}) => t === "USD" ? rt({ value: e }) : `${$[t]} ${ot({
|
|
205
205
|
value: e,
|
|
206
|
-
decimals:
|
|
207
|
-
})}`,
|
|
206
|
+
decimals: v[t]
|
|
207
|
+
})}`, ct = (t, e) => new i(
|
|
208
208
|
new i(t).toFixed(e, i.ROUND_DOWN)
|
|
209
|
-
).toString(),
|
|
209
|
+
).toString(), ut = (t, e = 3, s = 2) => {
|
|
210
210
|
if (t.length <= 5)
|
|
211
211
|
return t;
|
|
212
212
|
const a = "...";
|
|
213
213
|
return t.length <= e + s + a.length ? t : `${t.slice(0, e)}${a}${t.slice(-s)}`;
|
|
214
|
-
},
|
|
214
|
+
}, vt = ({
|
|
215
215
|
balance: t,
|
|
216
216
|
symbol: e,
|
|
217
217
|
precision: s,
|
|
218
218
|
truncateSymbol: a
|
|
219
|
-
}) => `${
|
|
219
|
+
}) => `${ct(t, s)} ${a ? ut(e) : e}`, Ut = (t) => {
|
|
220
220
|
if (!t)
|
|
221
221
|
return;
|
|
222
222
|
const e = t.match(/0x[a-fA-F0-9]{64}/);
|
|
@@ -224,13 +224,13 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
224
224
|
return;
|
|
225
225
|
const s = e[0];
|
|
226
226
|
return `${s.slice(0, 4)}...${s.slice(-3)}`;
|
|
227
|
-
},
|
|
227
|
+
}, Kt = typeof window < "u", Wt = (t) => d(V, t) || d(Y, t), Vt = (t) => Z.some(
|
|
228
228
|
(e) => d(e, t)
|
|
229
|
-
),
|
|
229
|
+
), Yt = (t) => U[t.toLowerCase()] ?? {
|
|
230
230
|
symbol: "",
|
|
231
231
|
decimals: 18,
|
|
232
|
-
address:
|
|
233
|
-
},
|
|
232
|
+
address: S
|
|
233
|
+
}, Gt = (t) => d(t, G) ? K : W, dt = (t) => `eth_${t}`, Zt = ({
|
|
234
234
|
action: t,
|
|
235
235
|
log: e,
|
|
236
236
|
symbol: s,
|
|
@@ -238,60 +238,37 @@ const d = (t, e) => t?.toLowerCase() === e?.toLowerCase(), pt = (t) => d(t, B),
|
|
|
238
238
|
chainId: n
|
|
239
239
|
}) => {
|
|
240
240
|
const r = {
|
|
241
|
-
[
|
|
242
|
-
[
|
|
243
|
-
[
|
|
241
|
+
[p.SYMBOL.NAME]: s,
|
|
242
|
+
[p.CHAIN_ID.NAME]: n,
|
|
243
|
+
[p.ADDRESS.NAME]: dt(a)
|
|
244
244
|
};
|
|
245
|
-
|
|
245
|
+
H[t].forEach((o) => {
|
|
246
246
|
e?.(o, r);
|
|
247
247
|
});
|
|
248
|
-
},
|
|
248
|
+
}, Ht = (t) => j.some((e) => d(e, t)), kt = (t) => k[t.toLowerCase()] ?? {
|
|
249
249
|
symbol: "",
|
|
250
250
|
decimals: 18,
|
|
251
|
-
address:
|
|
252
|
-
},
|
|
253
|
-
function zt() {
|
|
254
|
-
if (I)
|
|
255
|
-
try {
|
|
256
|
-
const t = localStorage.getItem(
|
|
257
|
-
y.IS_BATCH_TRANSACTIONS_ENABLED
|
|
258
|
-
);
|
|
259
|
-
return t ? JSON.parse(t) : void 0;
|
|
260
|
-
} catch {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function Xt(t) {
|
|
265
|
-
if (I)
|
|
266
|
-
try {
|
|
267
|
-
localStorage.setItem(
|
|
268
|
-
y.IS_BATCH_TRANSACTIONS_ENABLED,
|
|
269
|
-
JSON.stringify(t)
|
|
270
|
-
);
|
|
271
|
-
} catch (e) {
|
|
272
|
-
console.error("[core-kit]: Failed to persist batch transactions setting", e);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const qt = (t) => {
|
|
251
|
+
address: S
|
|
252
|
+
}, Qt = (t) => Q[t.toLowerCase()], jt = (t) => {
|
|
276
253
|
const e = t.find(
|
|
277
254
|
({ swapQuotes: s }) => s
|
|
278
255
|
);
|
|
279
256
|
return e?.swapQuotes ? Object.values(e.swapQuotes)[0]?.map(
|
|
280
257
|
({ routerKey: s }) => s
|
|
281
258
|
) ?? [] : [];
|
|
282
|
-
},
|
|
259
|
+
}, lt = (t, e, s) => t.map(({ asset: a, swapParams: n, swapQuotes: r }) => !n || !r ? {
|
|
283
260
|
supportedAsset: a,
|
|
284
261
|
withdrawData: "",
|
|
285
262
|
slippageTolerance: s
|
|
286
|
-
} :
|
|
263
|
+
} : et({
|
|
287
264
|
assetAddress: a,
|
|
288
265
|
swapQuotes: r,
|
|
289
266
|
swapParams: n,
|
|
290
267
|
slippageToleranceForContractTransaction: s,
|
|
291
268
|
routerKey: e
|
|
292
|
-
})),
|
|
269
|
+
})), zt = async (t, e, s, a, n) => {
|
|
293
270
|
for (const r of t) {
|
|
294
|
-
const o =
|
|
271
|
+
const o = lt(
|
|
295
272
|
e,
|
|
296
273
|
r,
|
|
297
274
|
s
|
|
@@ -300,11 +277,11 @@ const qt = (t) => {
|
|
|
300
277
|
return o;
|
|
301
278
|
}
|
|
302
279
|
return null;
|
|
303
|
-
},
|
|
280
|
+
}, Xt = (t, e) => (t ?? []).map((s) => ({
|
|
304
281
|
supportedAsset: s,
|
|
305
282
|
withdrawData: "",
|
|
306
283
|
slippageTolerance: e
|
|
307
|
-
})),
|
|
284
|
+
})), qt = async (t, e, {
|
|
308
285
|
fetchAaveSwapParams: s,
|
|
309
286
|
fetchAaveSwapQuotes: a,
|
|
310
287
|
withdrawAmountD18: n,
|
|
@@ -332,60 +309,58 @@ const qt = (t) => {
|
|
|
332
309
|
})
|
|
333
310
|
);
|
|
334
311
|
export {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
312
|
+
E as $,
|
|
313
|
+
ft as A,
|
|
314
|
+
Vt as B,
|
|
315
|
+
Wt as C,
|
|
316
|
+
Ht as D,
|
|
317
|
+
Rt as E,
|
|
318
|
+
bt as F,
|
|
319
|
+
Zt as G,
|
|
320
|
+
ht as H,
|
|
321
|
+
Ot as I,
|
|
322
|
+
Et as J,
|
|
323
|
+
_t as K,
|
|
324
|
+
Dt as L,
|
|
325
|
+
dt as M,
|
|
326
|
+
ut as N,
|
|
327
|
+
zt as O,
|
|
328
|
+
Ct as P,
|
|
329
|
+
St as Q,
|
|
353
330
|
Ft as R,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
dt as j,
|
|
375
|
-
Ut as k,
|
|
331
|
+
d as S,
|
|
332
|
+
rt as T,
|
|
333
|
+
Mt as U,
|
|
334
|
+
at as V,
|
|
335
|
+
ot as W,
|
|
336
|
+
pt as X,
|
|
337
|
+
it as Y,
|
|
338
|
+
nt as Z,
|
|
339
|
+
Pt as _,
|
|
340
|
+
lt as a,
|
|
341
|
+
et as b,
|
|
342
|
+
J as c,
|
|
343
|
+
It as d,
|
|
344
|
+
Lt as e,
|
|
345
|
+
Kt as f,
|
|
346
|
+
Xt as g,
|
|
347
|
+
qt as h,
|
|
348
|
+
jt as i,
|
|
349
|
+
ct as j,
|
|
350
|
+
$t as k,
|
|
376
351
|
xt as l,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
352
|
+
vt as m,
|
|
353
|
+
Tt as n,
|
|
354
|
+
q as o,
|
|
380
355
|
wt as p,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
356
|
+
D as q,
|
|
357
|
+
Yt as r,
|
|
358
|
+
Gt as s,
|
|
359
|
+
kt as t,
|
|
360
|
+
Qt as u,
|
|
361
|
+
Bt as v,
|
|
362
|
+
tt as w,
|
|
363
|
+
Nt as x,
|
|
364
|
+
yt as y,
|
|
365
|
+
Ut as z
|
|
391
366
|
};
|
package/const.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./
|
|
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});
|