@swapkit/helpers 4.0.26 → 4.1.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/dist/api/index.cjs +2 -2
- package/dist/api/index.cjs.map +7 -8
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +7 -8
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +12 -13
- package/dist/index.js +3 -3
- package/dist/index.js.map +12 -13
- package/dist/types/api/index.d.ts +0 -4
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/types.d.ts +145 -22
- package/dist/types/api/swapkitApi/types.d.ts.map +1 -1
- package/dist/types/api/thornode/endpoints.d.ts.map +1 -1
- package/dist/types/modules/assetValue.d.ts +2 -0
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/modules/feeMultiplier.d.ts.map +1 -1
- package/dist/types/modules/swapKitConfig.d.ts +41 -22
- package/dist/types/modules/swapKitConfig.d.ts.map +1 -1
- package/dist/types/modules/swapKitError.d.ts +28 -0
- package/dist/types/modules/swapKitError.d.ts.map +1 -1
- package/dist/types/types/derivationPath.d.ts +3 -15
- package/dist/types/types/derivationPath.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utils/asset.d.ts +6 -3
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/dist/types/utils/chains.d.ts.map +1 -1
- package/dist/types/utils/derivationPath.d.ts +2 -2
- package/dist/types/utils/derivationPath.d.ts.map +1 -1
- package/dist/types/utils/explorerUrls.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/types/api/thorswapStatic/endpoints.d.ts +0 -5
- package/dist/types/api/thorswapStatic/endpoints.d.ts.map +0 -1
- package/dist/types/api/thorswapStatic/types.d.ts +0 -21
- package/dist/types/api/thorswapStatic/types.d.ts.map +0 -1
- package/dist/types/types/chains.d.ts +0 -34
- package/dist/types/types/chains.d.ts.map +0 -1
- package/dist/types/types/radix.d.ts +0 -15
- package/dist/types/types/radix.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as V0,c as U0}from"./chunk-pfmeq01a.js";export*from"@swapkit/tokens";export*from"@swapkit/types";import{Chain as X,EVMChains as XF,getChainConfig as T0}from"@swapkit/types";import{getAddress as E0}from"ethers";import{match as G0}from"ts-pattern";import{Chain as _,EVMChains as k0,getChainConfig as O,UTXOChains as LF}from"@swapkit/types";import{match as n}from"ts-pattern";import{Chain as i0}from"@swapkit/types";import{createStore as a0}from"zustand/vanilla";import{Chain as x,getChainConfig as $0,StagenetChain as w}from"@swapkit/types";var z0={[x.Arbitrum]:"https://arb1.arbitrum.io/rpc",[x.Aurora]:"https://aurora-rpc.publicnode.com",[x.Avalanche]:"https://api.avax.network/ext/bc/C/rpc",[x.Base]:"https://base-rpc.publicnode.com",[x.Berachain]:"https://berachain-rpc.publicnode.com",[x.BinanceSmartChain]:"https://bsc-dataseed.binance.org",[x.BitcoinCash]:"https://node-router.thorswap.net/bitcoin-cash",[x.Bitcoin]:"https://bitcoin-rpc.publicnode.com",[x.Chainflip]:"wss://mainnet-archive.chainflip.io",[x.Cosmos]:"https://cosmos-rpc.publicnode.com:443",[x.Dash]:"https://dash-rpc.publicnode.com",[x.Dogecoin]:"https://node-router.thorswap.net/dogecoin",[x.Ethereum]:"https://ethereum-rpc.publicnode.com",[x.Gnosis]:"https://gnosis-rpc.publicnode.com",[x.Harbor]:$0(x.Harbor).rpcUrl,[x.Kujira]:"https://kujira-rpc.ibs.team",[x.Litecoin]:"https://node-router.thorswap.net/litecoin",[x.Maya]:"https://tendermint.mayachain.info",[x.Near]:"https://rpc.mainnet.near.org",[x.Noble]:"https://noble-rpc.polkachu.com",[x.Optimism]:"https://mainnet.optimism.io",[x.Polkadot]:"wss://rpc.polkadot.io",[x.Polygon]:"https://polygon-rpc.com",[x.Radix]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",[x.Ripple]:"wss://xrpl.ws/",[x.Solana]:"https://solana-rpc.publicnode.com",[x.THORChain]:"https://rpc.ninerealms.com",[x.Tron]:"https://tron-rpc.publicnode.com",[x.Zcash]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",[w.Maya]:"",[w.THORChain]:"https://stagenet-rpc.ninerealms.com",[w.Harbor]:$0(x.Harbor).rpcUrl},A0={[x.THORChain]:"https://thornode.ninerealms.com",[x.Maya]:"https://mayanode.mayachain.info",[x.Harbor]:$0(x.Harbor).rpcUrl,[w.THORChain]:"https://stagenet-thornode.ninerealms.com",[w.Maya]:"https://stagenet.mayanode.mayachain.info"},Y0={[x.Arbitrum]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],[x.Aurora]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],[x.Avalanche]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],[x.Base]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],[x.BinanceSmartChain]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],[x.Berachain]:["https://rpc.berachain.com","https://berachain.drpc.org"],[x.Bitcoin]:["https://bitcoin.publicnode.com"],[x.BitcoinCash]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],[x.Chainflip]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],[x.Cosmos]:["https://cosmos-rpc.publicnode.com"],[x.Dash]:["https://dash-rpc.publicnode.com"],[x.Dogecoin]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],[x.Ethereum]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],[x.Gnosis]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],[x.Harbor]:[],[x.Kujira]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],[x.Litecoin]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],[x.Maya]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],[w.Maya]:[],[x.Near]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],[x.Noble]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],[x.Optimism]:["https://optimism.llamarpc.com","https://1rpc.io/op"],[x.Polkadot]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],[x.Polygon]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],[x.Radix]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],[x.Ripple]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],[x.THORChain]:["https://thornode.ninerealms.com",A0[x.THORChain]],[w.THORChain]:[],[w.Harbor]:[],[x.Solana]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],[x.Tron]:["https://api.tronstack.io","https://api.tron.network"],[x.Zcash]:[]},J0={[x.Arbitrum]:"https://arbiscan.io",[x.Aurora]:"https://explorer.mainnet.aurora.dev",[x.Avalanche]:"https://snowtrace.io",[x.Base]:"https://basescan.org",[x.Berachain]:"https://berascan.com",[x.BinanceSmartChain]:"https://bscscan.com",[x.Bitcoin]:"https://blockchair.com/bitcoin",[x.BitcoinCash]:"https://www.blockchair.com/bitcoin-cash",[x.Chainflip]:"https://explorer.polkascan.io/polkadot",[x.Cosmos]:"https://www.mintscan.io/cosmos",[x.Dash]:"https://blockchair.com/dash",[x.Dogecoin]:"https://blockchair.com/dogecoin",[x.Ethereum]:"https://etherscan.io",[x.Gnosis]:"https://gnosisscan.io",[x.Harbor]:"",[x.Kujira]:"https://finder.kujira.network/kaiyo-1",[x.Litecoin]:"https://blockchair.com/litecoin",[x.Maya]:"https://www.mayascan.org",[x.Near]:"https://nearblocks.io",[x.Noble]:"https://www.mintscan.io/noble",[x.Optimism]:"https://optimistic.etherscan.io",[x.Polkadot]:"https://polkadot.subscan.io",[x.Polygon]:"https://polygonscan.com",[x.Radix]:"https://dashboard.radixdlt.com",[x.Ripple]:"https://livenet.xrpl.org/",[x.THORChain]:"https://runescan.io",[x.Solana]:"https://solscan.io",[x.Tron]:"https://tronscan.org",[x.Zcash]:"https://blockchair.com/zcash"};var c0;((Y)=>{Y.ARB="0x0000000000000000000000000000000000000000";Y.AURORA="0x0000000000000000000000000000000000000000";Y.AVAX="0x0000000000000000000000000000000000000000";Y.BASE="0x0000000000000000000000000000000000000000";Y.BERA="0x0000000000000000000000000000000000000000";Y.ETH="0x0000000000000000000000000000000000000000";Y.BSC="0x0000000000000000000000000000000000000000";Y.GNO="0x0000000000000000000000000000000000000000";Y.MATIC="0x0000000000000000000000000000000000001010";Y.OP="0x4200000000000000000000000000000000000042"})(c0||={});var y={ARB:[44,60,0,0,0],AURORA:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BERA:[44,60,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],DOT:[0,0,0,0,0],ETH:[44,60,0,0,0],FLIP:[0,0,0,0,0],GAIA:[44,118,0,0,0],GNO:[44,60,0,0,0],HARBOR:[44,931,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],NOBLE:[44,118,0,0,0],OP:[44,60,0,0,0],POL:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRON:[44,195,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0],ZEC:[44,133,0,0,0]};var h0;((P)=>{P.unknownError="unknownError";P.test_error="test_error";P.providerDetailsError="providerDetailsError";P.blockHeaderNotFound="blockHeaderNotFound";P.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";P.blockHashNotFoundAtHash="blockHashNotFoundAtHash";P.txHashMissing="txHashMissing";P.assetValueMissingInfo="assetValueMissingInfo";P.invalidAsset="invalidAsset";P.blockIsRequired="blockIsRequired";P.currentBlockHeaderNotFound="currentBlockHeaderNotFound";P.failedToRetrieveBalance="failedToRetrieveBalance";P.failedToRetrieveBlock="failedToRetrieveBlock";P.failedToRetrieveFees="failedToRetrieveFees";P.notImplementedBCH="notImplementedBCH";P.notImplementedDoge="notImplementedDoge";P.noPoolsFound="noPoolsFound";P.noVaultsFound="noVaultsFound";P.noTxFound="noTxFound";P.noInputCoinFound="noInputCoinFound";P.noBlockDataFound="noBlockDataFound";P.multipleCosmosMessages="multipleCosmosMessages";P.heightOrHashNotProvided="heightOrHashNotProvided";P.unknownDenom="unknownDenom";P.invalidBlockHeight="invalidBlockHeight";P.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";P.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";P.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";P.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";P.txMemoUndefined="txMemoUndefined";P.txMemoIncorrect="txMemoIncorrect";P.txTypeNotFound="txTypeNotFound";P.txNoMessage="txNoMessage";P.txNotFound="txNotFound";P.txReceiptNotFound="txReceiptNotFound";P.txParsingError="txParsingError";P.txLogsParsingError="txLogsParsingError";P.blockNotFound="blockNotFound";P.balanceNotFound="balanceNotFound";P.configError="configError";P.synthSwapDisallowed="synthSwapDisallowed";P.providerQuoteTimeout="providerQuoteTimeout";P.noQuoteResponse="noQuoteResponse";P.noPoolAssetsFound="noPoolAssetsFound";P.noThorchainPools="noThorchainPools";P.noMayachainPools="noMayachainPools";P.noThorchainNetworkInfo="noThorchainNetworkInfo";P.invalidAffiliateFee="invalidAffiliateFee";P.invalidBuyAssetAddress="invalidBuyAssetAddress";P.invalidSellAssetAddress="invalidSellAssetAddress";P.invalidSourceAddress="invalidSourceAddress";P.invalidDestinationAddress="invalidDestinationAddress";P.sourceAddressIsSmartContract="sourceAddressIsSmartContract";P.destinationAddressIsSmartContract="destinationAddressIsSmartContract";P.invalidChainId="invalidChainId";P.unsupportedChainId="unsupportedChainId";P.unsupportedEVMChainId="unsupportedEVMChainId";P.unsupportedMethod="unsupportedMethod";P.unsupportedProvider="unsupportedProvider";P.invalidParamsForMethod="invalidParamsForMethod";P.unsupportedAdapter="unsupportedAdapter";P.noWhitelistTokens="noWhitelistTokens";P.failedFetchGasPrice="failedFetchGasPrice";P.failedToCreateDepositChannel="failedToCreateDepositChannel";P.noProviderDetailsFound="noProviderDetailsFound";P.noTokenListsFound="noTokenListsFound";P.tokenNotFound="tokenNotFound";P.tokenPriceNotFound="tokenPriceNotFound";P.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";P.swapAmountTooSmall="swapAmountTooSmall";P.legsArrayIsEmpty="legsArrayIsEmpty";P.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";P.noBlockHeaderFound="noBlockHeaderFound";P.failedToSimulateSwap="failedToSimulateSwap";P.addressScreeningFailed="addressScreeningFailed";P.noLiquidtyProvidersFound="noLiquidtyProvidersFound";P.insufficientLiquidity="insufficientLiquidity";P.noInboundDataFound="noInbounDataFound";P.noInboundAddressesFound="noInboundAddressesFound";P.noInboundAddressFoundForChain="noInboundAddressFoundForChain";P.noLastBlocksFound="noLastBlocksFound";P.noVersionFound="noVersionFound";P.noConstantsFound="noConstantsFound";P.noMimirsFound="noMimirsFound";P.noRoutesFound="noRoutesFound";P.quoteNotFound="quoteNotFound";P.ledgerSignFailed="ledgerSignFailed";P.ledgerWrongPayload="ledgerWrongPayload";P.ledgerFetchSwapFailed="ledgerFetchSwapFailed";P.failedToFetchTx="failedToFetchTx";P.failedBuildTransactionDetails="failedBuildTransactionDetails";P.noLegsForRoute="noLegsForRoute";P.noRouterAddressFound="noRouterAddressFound";P.noAggregatorAddressFound="noAggregatorAddressFound";P.noContractInstanceFound="noContractInstanceFound";P.noContractAddressFound="noContractAddressFound";P.invalidAffiliate="invalidAffiliate";P.thornameAffiliate="thornameAffiliate";P.providerNotfound="No provider found";P.noRecordFound="No Record found";P.slippageTooLow="Slippage too low";P.tradingHalted="tradingHalted";P.noWrappedGasAsset="noWrappedGasAsset";P.aggregatorAddressNotFound="aggregatorAddressNotFound";P.routerAddressNotFound="routerAddressNotFound";P.dummyAddressNotFound="dummyAddressNotFound";P.trackerError="trackerError";P.thorchainPoolUnavailable="thorchainPoolUnavailable";P.noOhlcvDataFound="noOhlcvDataFound";P.noTradingPairs="noTradingPairs";P.noLendingAvailability="noLendingAvailability";P.lendingRepayTooSmall="lendingRepayTooSmall";P.missingState="missingState";P.ledgerSwapNotFound="ledgerSwapNotFound";P.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";P.errorEstimatingGas="errorEstimatingGas";P.apiKeyInvalid="apiKeyInvalid";P.apiKeyFailedToUpdate="apiKeyFailedToUpdate";P.apiKeyExpired="apiKeyExpired";P.unauthorized="unauthorized";P.failedToCreateMemo="failedToCreateMemo";P.radixIncorrectInstructions="radixIncorrectInstructions";P.radixTxMissedParam="radixTxMissedParam";P.radixTxMissedAccount="radixTxMissedAccount";P.radixManifestParseError="radixManifestParseError";P.radixManifestBuildError="radixManifestBuildError";P.invalidAddressForChain="invalidAddressForChain";P.riskyAddress="riskyAddress";P.noRoutesToProcess="noRoutesToProcess";P.sellAssetAmountTooSmall="sellAssetAmountTooSmall";P.missingPrivateKey="missingPrivateKey";P.noMemoPriceProtection="noMemoPriceProtection"})(h0||={});var l0;((A)=>{A.highSlippage="highSlippage";A.highPriceImpact="highPriceImpact"})(l0||={});var n0;((z)=>{z.CAVIAR_V1="CAVIAR_V1";z.CAMELOT_V3="CAMELOT_V3";z.CHAINFLIP="CHAINFLIP";z.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";z.JUPITER="JUPITER";z.MAYACHAIN="MAYACHAIN";z.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";z.OCISWAP_V1="OCISWAP_V1";z.ONEINCH="ONEINCH";z.OPENOCEAN_V2="OPENOCEAN_V2";z.PANCAKESWAP="PANCAKESWAP";z.PANGOLIN_V1="PANGOLIN_V1";z.SUSHISWAP_V2="SUSHISWAP_V2";z.THORCHAIN="THORCHAIN";z.THORCHAIN_STREAMING="THORCHAIN_STREAMING";z.TRADERJOE_V2="TRADERJOE_V2";z.UNISWAP_V2="UNISWAP_V2";z.UNISWAP_V3="UNISWAP_V3";z.NEAR="NEAR"})(n0||={});var s0;((T)=>{T.LIQUIDITY="liquidity";T.NETWORK="network";T.INBOUND="inbound";T.OUTBOUND="outbound";T.AFFILIATE="affiliate";T.TAX="tax";T.PRIORITY="priority"})(s0||={});var X0;((R)=>{R.Average="average";R.Fast="fast";R.Fastest="fastest"})(X0||={});var t0;((A)=>{A.Approve="approve";A.CheckOnly="checkOnly"})(t0||={});var I0;((Z)=>{Z.NAME_REGISTER="~";Z.BOND="BOND";Z.DEPOSIT="+";Z.LEAVE="LEAVE";Z.UNBOND="UNBOND";Z.WITHDRAW="-";Z.RUNEPOOL_DEPOSIT="POOL+";Z.RUNEPOOL_WITHDRAW="POOL-";Z.CLAIM_TCY="tcy";Z.STAKE_TCY="tcy+";Z.UNSTAKE_TCY="tcy-"})(I0||={});var c;((M)=>{M.BITGET="BITGET";M.BRAVE="BRAVE";M.COINBASE_MOBILE="COINBASE_MOBILE";M.COINBASE_WEB="COINBASE_WEB";M.COSMOSTATION="COSMOSTATION";M.CTRL="CTRL";M.EIP6963="EIP6963";M.EXODUS="EXODUS";M.KEEPKEY="KEEPKEY";M.KEEPKEY_BEX="KEEPKEY_BEX";M.KEPLR="KEPLR";M.KEYSTORE="KEYSTORE";M.LEAP="LEAP";M.LEDGER="LEDGER";M.LEDGER_LIVE="LEDGER_LIVE";M.METAMASK="METAMASK";M.OKX="OKX";M.OKX_MOBILE="OKX_MOBILE";M.ONEKEY="ONEKEY";M.PHANTOM="PHANTOM";M.POLKADOT_JS="POLKADOT_JS";M.RADIX_WALLET="RADIX_WALLET";M.TREZOR="TREZOR";M.TALISMAN="TALISMAN";M.TRONLINK="TRONLINK";M.TRUSTWALLET_WEB="TRUSTWALLET_WEB";M.VULTISIG="VULTISIG";M.WALLETCONNECT="WALLETCONNECT";M.XAMAN="XAMAN"})(c||={});var r0;((R)=>{R[R.NoError=36864]="NoError";R[R.LockedDevice=21781]="LockedDevice";R[R.TC_NotFound=65535]="TC_NotFound"})(r0||={});var e0={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:Object.values(i0),envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},explorerUrls:J0,fallbackRpcUrls:Y0,feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},nodeUrls:A0,requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:z0,wallets:Object.values(c)},j=a0((F)=>({...e0,setApiKey:($,A)=>F((R)=>({apiKeys:{...R.apiKeys,[$]:A}})),setConfig:($)=>F((A)=>({apiKeys:{...A.apiKeys,...$.apiKeys},chains:A.chains.concat($.chains||[]),envs:{...A.envs,...$.envs},explorerUrls:{...A.explorerUrls,...$.explorerUrls},feeMultipliers:$.feeMultipliers||A.feeMultipliers,integrations:{...A.integrations,...$.integrations},nodeUrls:{...A.nodeUrls,...$.nodeUrls},rpcUrls:{...A.rpcUrls,...$.rpcUrls},wallets:A.wallets.concat($.wallets||[])})),setEnv:($,A)=>F((R)=>({envs:{...R.envs,[$]:A}})),setExplorerUrl:($,A)=>F((R)=>({explorerUrls:{...R.explorerUrls,[$]:A}})),setFallbackRpcUrls:($,A)=>F((R)=>({fallbackRpcUrls:{...R.fallbackRpcUrls,[$]:A}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,A)=>F((R)=>({integrations:{...R.integrations,[$]:A}})),setNodeUrl:($,A)=>F((R)=>({nodeUrls:{...R.nodeUrls,[$]:A}})),setRequestOptions:($)=>F((A)=>({requestOptions:{retry:{...A.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||A.requestOptions.timeoutMs}})),setRpcUrl:($,A)=>F((R)=>({rpcUrls:{...R.rpcUrls,[$]:A}}))})),W={get:(F)=>j.getState()[F],getState:j.getState,set:(F)=>j.getState().setConfig(F),setApiKey:(F,$)=>j.getState().setApiKey(F,$),setEnv:(F,$)=>j.getState().setEnv(F,$),setExplorerUrl:(F,$)=>j.getState().setExplorerUrl(F,$),setFallbackRpcUrls:(F,$)=>j.getState().setFallbackRpcUrls(F,$),setFeeMultipliers:(F)=>j.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>j.getState().setIntegrationConfig(F,$),setNodeUrl:(F,$)=>j.getState().setNodeUrl(F,$),setRequestOptions:(F)=>j.getState().setRequestOptions(F),setRpcUrl:(F,$)=>j.getState().setRpcUrl(F,$)};var FF={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,wallet_vultisig_not_found:22101,wallet_vultisig_contract_address_not_provided:22102,wallet_vultisig_asset_not_defined:22103,wallet_vultisig_send_transaction_no_address:22104,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,wallet_tronlink_request_accounts_failed:24001,wallet_tronlink_locked:24002,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_substrate_transfer_error:50502,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class J extends Error{static ErrorCode=FF;constructor(F,$){let A=typeof F==="string",R=A?F:F.errorKey,N=A?void 0:F.info,H=`${R}${N?`: ${JSON.stringify(N)}`:""}`;super(H);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${R}]:`,$);else if(N)console.error(`SwapKitError [${R}]:`,N)}}var $F=(F)=>new Promise(($)=>setTimeout($,F)),AF=(F,{baseDelay:$,backoffMultiplier:A,maxDelay:R})=>Math.min($*A**F,R),RF=async(F,$)=>{let A=await fetch(F,$);if(!A.ok){let N={message:await A.text(),status:A.status,statusText:A.statusText};throw new J({errorKey:"helpers_invalid_response",info:N},N)}return A.json()};function h(F,$={}){return async function(R,N={}){let{searchParams:H,json:B,body:T,headers:G,dynamicHeader:Q,retry:Y,timeoutMs:Z,abortController:S,onError:q,onSuccess:f,responseHandler:v,...m}={...$,...N},V=W.get("requestOptions"),K={...V.retry,...Y},z=!!B||R.endsWith(".json"),m0=PF(R,H),C0=NF(z,{...G,...Q?.()}),o0=z?JSON.stringify(B):T,F0;for(let o=0;o<=K.maxRetries;o++){let M0=S||new AbortController,Z0=setTimeout(()=>M0.abort(),Z||V.timeoutMs);try{let E=await RF(m0,{...m,body:o0,headers:C0,method:F,signal:M0.signal});return clearTimeout(Z0),f?.(E)||v?.(E)||E}catch(E){if(clearTimeout(Z0),F0=E,o>=K.maxRetries)return q?q(E):Promise.reject(E);await $F(AF(o,K))}}return q?q(F0):Promise.reject(F0)}}function NF(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function PF(F,$){let A=new URL(F);if($)A.search=new URLSearchParams($).toString();return A.toString()}var l={extend:(F)=>({extend:($)=>l.extend({...F,...$}),get:h("GET",F),post:h("POST",F)}),get:h("GET"),post:h("POST")};import{Chain as U,CosmosChains as xF,EVMChains as HF,StagenetChains as BF,UTXOChains as TF}from"@swapkit/types";import{match as q0}from"ts-pattern";import{Chain as R0}from"@swapkit/types";function L$(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function M$(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function Z$(F,$){try{return F()}catch(A){if($)throw new J($,A);return}}function z$(F){switch(F){case R0.THORChain:return`${F}.RUNE`;case R0.Cosmos:return`${F}.ATOM`;case R0.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var j0=new Set;function u({condition:F,id:$,warning:A}){if(F){if(j0.has($))return;console.warn(A),j0.add($)}}function _F(F){return q0(F).with(...HF,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...TF,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...xF,...BF,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(U.Polkadot,U.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(U.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(U.Tron,U.Radix,()=>"").with(U.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(U.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:F})})}function GF(F){return q0(F).with(U.Radix,()=>"/status/network-configuration").with(U.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function W0(F,$){try{let A=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${A}${GF(F)}`,{body:JSON.stringify(_F(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var N0=new Map,QF=120000;async function P0(F){let{isStagenet:$}=W.get("envs"),A=W.get("rpcUrls"),R=W.get("fallbackRpcUrls");if($)return A[F];let N=N0.get(F);if(N&&Date.now()-N.timestamp<QF)return N.url;let H=A[F];if(!await W0(F,H)){for(let T of R[F])if(await W0(F,T))return N0.set(F,{timestamp:Date.now(),url:T}),T}return N0.set(F,{timestamp:Date.now(),url:H}),H}function q$(F){u({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}var O$=[`${_.Maya}.MAYA`,`${_.Maya}.CACAO`,`${_.Ethereum}.THOR`,`${_.Ethereum}.vTHOR`,`${_.Kujira}.USK`,`${_.Ethereum}.FLIP`,`${_.Radix}.XRD`],K0=[_.Arbitrum,_.Aurora,_.Base,_.Ethereum,_.Optimism];async function MF({chain:F,to:$}){let{baseDecimal:R}=O(F);try{let N=await P0(F),{result:H}=await l.post(N,{body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{data:"0x313ce567",to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}});return Number.parseInt(BigInt(H||R).toString(),10)}catch(N){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,N),R}}async function ZF(F){let{baseDecimal:$}=O(_.Radix);if(F===_.Radix)return $;try{let A=F.split("-")[1]?.toLowerCase(),R=await P0(_.Radix),{manager:N}=await l.post(`${R}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:A}),headers:{Accept:"*/*","Content-Type":"application/json"}});return N.divisibility.value.divisibility}catch(A){return console.error(`Failed to fetch Radix asset decimal for ${F}:`,A),$}}async function zF({chain:F,symbol:$}){let{baseDecimal:A}=O(F);if(k0.includes($))return A;let R=$.split("-"),N=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(N?.startsWith("0x")?MF({chain:F,to:N}):A)}function w0({chain:F,symbol:$}){let{baseDecimal:A}=O(F);return n(F).with(...k0,(R)=>zF({chain:R,symbol:$})).with(_.Radix,()=>ZF($)).otherwise(()=>A)}function O0({chain:F,symbol:$}){return n(F).with(...K0,()=>$==="ETH").with(_.Avalanche,()=>$==="AVAX").with(_.Berachain,()=>$==="BERA").with(_.BinanceSmartChain,()=>$==="BNB").with(_.Gnosis,()=>$==="XDAI").with(_.Maya,()=>$==="CACAO").with(_.Cosmos,()=>$==="ATOM").with(_.THORChain,()=>$==="RUNE").with(_.Tron,()=>$==="TRX").with(_.Radix,()=>`${F}.${$}`===s(F).identifier).otherwise(()=>$===F)}var s=(F)=>{let{baseDecimal:$}=O(F);return n(F.toUpperCase()).with(...K0,(R)=>({decimal:$,identifier:`${R}.ETH`})).with(_.THORChain,(R)=>({decimal:$,identifier:`${R}.RUNE`})).with(_.Cosmos,(R)=>({decimal:$,identifier:`${R}.ATOM`})).with(_.Maya,(R)=>({decimal:10,identifier:`${R}.CACAO`})).with(_.BinanceSmartChain,(R)=>({decimal:$,identifier:`${R}.BNB`})).with(_.Avalanche,(R)=>({decimal:$,identifier:`${R}.AVAX`})).with(_.Gnosis,(R)=>({decimal:$,identifier:`${R}.XDAI`})).with(_.Berachain,(R)=>({decimal:$,identifier:`${R}.BERA`})).with(_.Tron,(R)=>({decimal:$,identifier:`${R}.TRX`})).with(_.Solana,_.Chainflip,_.Kujira,_.Ripple,_.Polkadot,_.Near,...LF,(R)=>({decimal:$,identifier:`${R}.${R}`})).with(_.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(_.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(R)=>({decimal:6,identifier:R})).with("ETH.FLIP",()=>({decimal:O(_.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:O(_.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:O(_.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(R)=>({decimal:10,identifier:R})).with("MAYA.MAYA",(R)=>({decimal:4,identifier:R})).otherwise(()=>({decimal:$,identifier:F}))};function x0({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return n(F).with(_.Radix,()=>$===_.Radix||`${F}.${$}`===s(F).identifier).with(_.Arbitrum,_.Optimism,_.Base,_.Aurora,()=>$===_.Ethereum).with(_.Cosmos,()=>$==="ATOM").with(_.BinanceSmartChain,()=>$==="BNB").with(_.Maya,()=>$==="CACAO").with(_.THORChain,()=>$==="RUNE").with(_.Tron,()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var H0=(F)=>{let[$,...A]=F.split("."),R=F.includes("/"),N=A.join("."),H=N?.split("-"),B=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:$,symbol:N,synth:R,ticker:B}};async function D$(F){let{loadTokenLists:$}=await import("./tokens.js"),A=await $();for(let R of Object.values(A))for(let{identifier:N,chain:H,...B}of R.tokens){if("identifier"in F&&N===F.identifier)return N;if("address"in B&&"chain"in F&&H===F.chain&&B.address&&B.address.toLowerCase()===F.contract.toLowerCase())return N}return}var D0=["TERRA",...W.get("chains")];function S0(F=""){let $=F.toUpperCase(),[A]=$.split(".");if(D0.includes(A))return!0;let[R]=$.split("/");if(D0.includes(R))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function b$(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var b=(F)=>10n**BigInt(F),C=(F)=>Math.log10(Number.parseFloat(F.toString()));function p({value:F,bigIntDecimal:$=8,decimal:A=8}){if(A===0)return F.toString();let R=F<0n,N=F.toString().substring(R?1:0),H=A-(N.length-1);if(H>0)N="0".repeat(H)+N;let B=N.length-A,T=N.slice(-A);if(Number.parseInt(T[$]||"0",10)>=5)T=`${T.substring(0,$-1)}${(Number.parseInt(T[$-1]||"0",10)+1).toString()}`;else T=T.substring(0,$);return`${R?"-":""}${N.slice(0,B)}.${T}`.replace(/\.?0*$/,"")}function YF(F,$){if($===0n)throw Error("Cannot divide by zero");let A=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+A)/$;return(F-A)/$}class D{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new D({decimal:$,value:p({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:A}){return D.fromBigInt(F.getBaseValue("bigint")*b(A)/b($),A)}constructor(F){let $=B0(F),A=typeof F==="object";this.decimal=A?F.decimal:void 0,this.decimalMultiplier=A&&"decimalMultiplier"in F?F.decimalMultiplier:b(Math.max(v0(t($)),this.decimal||0)),this.#N($)}set(F){return new this.constructor({decimal:this.decimal,identifier:this.toString({includeSynthProtocol:!0}),value:F})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let A=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||C(this.decimalMultiplier));switch(F){case"number":return Number(A);case"string":return A;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return A}}getBaseValue(F,$){let A=this.decimalMultiplier/b($||this.decimal||8),R=YF(this.bigIntValue,A);switch(F){case"number":return Number(R);case"string":return R.toString();case"bigint":return R;default:return R}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let A=B0(F),R=t(A);if(R==="0"||R==="undefined")return 0n;return this.#R(R,$)}toSignificant(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",N=A||"";if((Number.parseInt(R,10)?R.length+N.length:N.length)<=F)return this.getValue("string");if(R.length>=F)return R.slice(0,F).padEnd(R.length,"0");if(Number.parseInt(R,10))return`${R}.${N.slice(0,F-R.length)}`.padEnd(F-R.length,"0");let B=Number.parseInt(N,10),T=`${B}`.slice(0,F);return`0.${T.padStart(N.length-`${B}`.length+T.length,"0")}`}toFixed(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",N=A||"";if(Number.parseInt(R,10))return`${R}.${N.slice(0,F)}`.padEnd(F,"0");let H=Number.parseInt(N,10),B=`${H}`.slice(0,F);return`0.${B.padStart(N.length-`${H}`.length+B.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),A=["","K","M","B","T","Q","Qi","S"],R=Math.floor(Math.log10(Math.abs($))/3),N=A[R];if(!N)return this.getValue("string");let H=10**(R*3);return`${($/H).toFixed(F)}${N}`}toCurrency(F="$",{currencyPosition:$="start",decimal:A=2,decimalSeparator:R=".",thousandSeparator:N=","}={}){let H=this.getValue("number"),[B="",T=""]=H.toFixed(6).split("."),G=B.replace(/\B(?=(\d{3})+(?!\d))/g,N),Q=B||T?B==="0"?`${Number.parseFloat(`0.${T}`)}`.replace(".",R):`${G}${Number.parseInt(T,10)?`${R}${T.slice(0,A)}`:""}`:"0.00";return`${$==="start"?F:""}${Q}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let A=$||this.decimal||8,R=Math.max(A,C(this.decimalMultiplier)),N=F<0n,H=F.toString().substring(N?1:0),B=R-(H.length-1),T=B>0?"0".repeat(B)+H:H,G=T.length-R,Q=T.slice(-R);if(Number.parseInt(Q[A]||"0",10)>=5)Q=`${Q.substring(0,A-1)}${(Number.parseInt(Q[A-1]||"0",10)+1).toString()}`;else Q=Q.substring(0,A);return`${N?"-":""}${T.slice(0,G)}.${Q}`.replace(/\.?0*$/,"")}#$(F,...$){let A=this.#A(this,...$),R=Math.max(A,C(this.decimalMultiplier)),N=b(R),H=$.reduce((T,G)=>{let Q=this.getBigIntValue(G,R);switch(F){case"add":return T+Q;case"sub":return T-Q;case"mul":return T*Q/N;case"div":{if(Q===0n)throw RangeError("Division by zero");return T*N/Q}default:return T}},this.bigIntValue*N/this.decimalMultiplier),B=p({bigIntDecimal:R,decimal:R,value:H});return new this.constructor({decimal:this.decimal,decimalMultiplier:b(R),identifier:this.toString(),value:B})}#F(F,...$){let A=this.#A(this,...$),R=this.getBigIntValue($[0]||"0",A),N=this.getBigIntValue(this,A);switch(F){case"gt":return N>R;case"gte":return N>=R;case"lt":return N<R;case"lte":return N<=R;case"eqValue":return N===R;default:return!1}}#N(F){let $=t(F)||"0";this.bigIntValue=this.#R($)}#A(...F){let $=F.map((A)=>{return typeof A==="object"?A.decimal||C(A.decimalMultiplier):v0(t(A))}).filter(Boolean);return Math.max(...$,8)}#R(F,$){let A=$?b($):this.decimalMultiplier,R=C(A),[N="",H=""]=F.split(".");return BigInt(`${N}${H.padEnd(R,"0")}`)}}var JF=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function t(F){let A=`${typeof F==="number"?JF.format(F):B0(F)}`.replaceAll(",",".").split(".");return A.length>1?`${A.slice(0,-1).join("")}.${A.at(-1)}`:A[0]||"0"}function v0(F){let $=F.split(".")[1]?.length||0;return Math.max($,8)}function B0(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var r=[X.Solana,X.Tron,X.Near],Q0=[X.THORChain,X.Maya],g=new Map;class d extends D{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:A,chain:R,symbol:N,identifier:H}){super(typeof F==="object"?F:{decimal:$,value:F});let B=_0(H||`${R}.${N}`);this.type=x0(B),this.tax=A,this.chain=B.chain,this.ticker=B.ticker,this.symbol=B.symbol,this.address=B.address,this.isSynthetic=B.isSynthetic,this.isTradeAsset=B.isTradeAsset,this.isGasAsset=B.isGasAsset,this.chainId=T0(B.chain).chainId}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){if(this.isSynthetic)return`${this.chain}.${this.symbol.replace(/\//g,".")}`;if(this.isTradeAsset)return`${this.chain}.${this.symbol.replace(/~/g,"..")}`;let F=this.symbol.replace(/\./g,"__");return`${this.chain}.${F}`}getIconUrl(){return g.get(this.toString())?.logoURI}eqAsset({chain:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let A=F.indexOf(".");if(A===-1)throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let R=F.slice(0,A),N=F.slice(A+1),H=G0({chain:R,rest:N}).when(({rest:B})=>B.includes(".."),({chain:B,rest:T})=>`${B}.${T.replace(/\.\./g,"~")}`).when(({chain:B,rest:T})=>Q0.includes(B)&&T.includes("."),({chain:B,rest:T})=>`${B}.${T.replace(/\./g,"/")}`).otherwise(({chain:B,rest:T})=>`${B}.${T.replace(/__/g,".")}`);return d.from({asset:H,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:A,...R}){let N=F instanceof D?F.getValue("string"):F,H=qF(R),{identifier:B,decimal:T}=s(H),{chain:G,isSynthetic:Q,isTradeAsset:Y}=_0(B),{baseDecimal:Z}=T0(G),S=g.get(r.includes(G)?B:B.toUpperCase()),q=S?.decimal||T;u({condition:!(A||q),id:`assetValue_static_decimal_not_found_${G}`,warning:`Couldn't find static decimal for one or more tokens on ${G} (Using default ${Z} decimal as fallback).
|
|
1
|
+
import{a as h,c as o}from"./chunk-pfmeq01a.js";export*from"@swapkit/tokens";export*from"@swapkit/types";import{AllChains as w$,Chain as Y,EVMChains as K$,getChainConfig as HF}from"@swapkit/types";import{getAddress as EF}from"ethers";import{match as zF}from"ts-pattern";import{Chain as _,EVMChains as T$,getChainConfig as b,UTXOChains as Y$}from"@swapkit/types";import{match as FF}from"ts-pattern";import{AllChains as qF,getChainConfig as aF,StagenetChain as WF,StagenetMAYAConfig as eF,StagenetTHORConfig as F$}from"@swapkit/types";import{createStore as $$}from"zustand/vanilla";import{AllChains as dF,getChainConfig as cF}from"@swapkit/types";var C=dF.reduce((F,$)=>{return F[$]=cF($).networkDerivationPath,F},{});var nF;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(nF||={});var lF;((P)=>{P.highSlippage="highSlippage";P.highPriceImpact="highPriceImpact"})(lF||={});var tF;((J)=>{J.CAVIAR_V1="CAVIAR_V1";J.CAMELOT_V3="CAMELOT_V3";J.CHAINFLIP="CHAINFLIP";J.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";J.JUPITER="JUPITER";J.MAYACHAIN="MAYACHAIN";J.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";J.OCISWAP_V1="OCISWAP_V1";J.ONEINCH="ONEINCH";J.OPENOCEAN_V2="OPENOCEAN_V2";J.PANCAKESWAP="PANCAKESWAP";J.PANGOLIN_V1="PANGOLIN_V1";J.SUSHISWAP_V2="SUSHISWAP_V2";J.THORCHAIN="THORCHAIN";J.THORCHAIN_STREAMING="THORCHAIN_STREAMING";J.TRADERJOE_V2="TRADERJOE_V2";J.UNISWAP_V2="UNISWAP_V2";J.UNISWAP_V3="UNISWAP_V3";J.NEAR="NEAR"})(tF||={});var sF;((G)=>{G.LIQUIDITY="liquidity";G.NETWORK="network";G.INBOUND="inbound";G.OUTBOUND="outbound";G.AFFILIATE="affiliate";G.TAX="tax";G.PRIORITY="priority"})(sF||={});var XF;((N)=>{N.Average="average";N.Fast="fast";N.Fastest="fastest"})(XF||={});var rF;((P)=>{P.Approve="approve";P.CheckOnly="checkOnly"})(rF||={});var jF;((Z)=>{Z.NAME_REGISTER="~";Z.BOND="BOND";Z.DEPOSIT="+";Z.LEAVE="LEAVE";Z.UNBOND="UNBOND";Z.WITHDRAW="-";Z.RUNEPOOL_DEPOSIT="POOL+";Z.RUNEPOOL_WITHDRAW="POOL-";Z.CLAIM_TCY="tcy";Z.STAKE_TCY="tcy+";Z.UNSTAKE_TCY="tcy-"})(jF||={});var a;((z)=>{z.BITGET="BITGET";z.BRAVE="BRAVE";z.COINBASE_MOBILE="COINBASE_MOBILE";z.COINBASE_WEB="COINBASE_WEB";z.COSMOSTATION="COSMOSTATION";z.CTRL="CTRL";z.EIP6963="EIP6963";z.EXODUS="EXODUS";z.KEEPKEY="KEEPKEY";z.KEEPKEY_BEX="KEEPKEY_BEX";z.KEPLR="KEPLR";z.KEYSTORE="KEYSTORE";z.LEAP="LEAP";z.LEDGER="LEDGER";z.LEDGER_LIVE="LEDGER_LIVE";z.METAMASK="METAMASK";z.OKX="OKX";z.OKX_MOBILE="OKX_MOBILE";z.ONEKEY="ONEKEY";z.PHANTOM="PHANTOM";z.POLKADOT_JS="POLKADOT_JS";z.RADIX_WALLET="RADIX_WALLET";z.TREZOR="TREZOR";z.TALISMAN="TALISMAN";z.TRONLINK="TRONLINK";z.TRUSTWALLET_WEB="TRUSTWALLET_WEB";z.VULTISIG="VULTISIG";z.WALLETCONNECT="WALLETCONNECT";z.XAMAN="XAMAN"})(a||={});var iF;((N)=>{N[N.NoError=36864]="NoError";N[N.LockedDevice=21781]="LockedDevice";N[N.TC_NotFound=65535]="TC_NotFound"})(iF||={});var P$=qF.reduce((F,$)=>{if(!F.THOR_STAGENET)F[WF.Maya]=eF.rpcUrls,F[WF.THORChain]=F$.rpcUrls;return F[$]=aF($).rpcUrls,F},{}),UF={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:qF,rpcUrls:P$,envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},wallets:Object.values(a)},q=$$((F)=>({...UF,setApiKey:($,P)=>F((N)=>({apiKeys:{...N.apiKeys,[$]:P}})),setConfig:($)=>F((P)=>({apiKeys:{...P.apiKeys,...$.apiKeys},chains:P.chains.concat($.chains||[]),envs:{...P.envs,...$.envs},feeMultipliers:$.feeMultipliers||P.feeMultipliers,integrations:{...P.integrations,...$.integrations},rpcUrls:{...P.rpcUrls,...$.rpcUrls},wallets:P.wallets.concat($.wallets||[])})),setEnv:($,P)=>F((N)=>({envs:{...N.envs,[$]:P}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,P)=>F((N)=>({integrations:{...N.integrations,[$]:P}})),setRequestOptions:($)=>F((P)=>({requestOptions:{retry:{...P.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||P.requestOptions.timeoutMs}})),setRpcUrl:($,P)=>F((N)=>({rpcUrls:{...N.rpcUrls,[$]:P}}))})),U={get:(F)=>q.getState()[F],getState:q.getState,reinitialize:()=>q.setState(UF),set:(F)=>q.getState().setConfig(F),setApiKey:(F,$)=>q.getState().setApiKey(F,$),setEnv:(F,$)=>q.getState().setEnv(F,$),setFeeMultipliers:(F)=>q.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>q.getState().setIntegrationConfig(F,$),setRequestOptions:(F)=>q.getState().setRequestOptions(F),setRpcUrl:(F,$)=>q.getState().setRpcUrl(F,$)};var N$={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_wallet_create_not_supported:10115,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,wallet_vultisig_not_found:22101,wallet_vultisig_contract_address_not_provided:22102,wallet_vultisig_asset_not_defined:22103,wallet_vultisig_send_transaction_no_address:22104,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,wallet_tronlink_request_accounts_failed:24001,wallet_tronlink_locked:24002,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_substrate_transfer_error:50502,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_near_no_public_key_found:90613,toolbox_sui_address_required:90701,toolbox_sui_keypair_required:90702,toolbox_sui_balance_error:90703,toolbox_sui_transaction_creation_error:90704,toolbox_sui_signing_error:90705,toolbox_sui_broadcast_error:90706,toolbox_sui_no_signer:90707,toolbox_sui_no_sender:90708,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,helpers_chain_no_public_or_set_rpc_url:70012,not_implemented:99999};class T extends Error{static ErrorCode=N$;constructor(F,$){let P=typeof F==="string",N=P?F:F.errorKey,H=P?void 0:F.info,A=`${N}${H?`: ${JSON.stringify(H)}`:""}`;super(A);if(Object.setPrototypeOf(this,T.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${N}]:`,$);else if(H)console.error(`SwapKitError [${N}]:`,H)}}var H$=(F)=>new Promise(($)=>setTimeout($,F)),R$=(F,{baseDelay:$,backoffMultiplier:P,maxDelay:N})=>Math.min($*P**F,N),B$=async(F,$)=>{let P=await fetch(F,$);if(!P.ok){let H={message:await P.text(),status:P.status,statusText:P.statusText};throw new T({errorKey:"helpers_invalid_response",info:H},H)}return P.json()};function e(F,$={}){return async function(N,H={}){let{searchParams:A,json:B,body:G,headers:x,dynamicHeader:L,retry:M,timeoutMs:Z,abortController:S,onError:V,onSuccess:f,responseHandler:v,...u}={...$,...H},w=U.get("requestOptions"),W={...w.retry,...M},J=!!B||N.endsWith(".json"),i=G$(N,A),TF=A$(J,{...x,...L?.()}),l=J?JSON.stringify(B):G,K;for(let g=0;g<=W.maxRetries;g++){let YF=S||new AbortController,MF=setTimeout(()=>YF.abort(),Z||w.timeoutMs);try{let E=await B$(i,{...u,body:l,headers:TF,method:F,signal:YF.signal});return clearTimeout(MF),f?.(E)||v?.(E)||E}catch(E){if(clearTimeout(MF),K=E,g>=W.maxRetries)return V?V(E):Promise.reject(E);await H$(R$(g,W))}}return V?V(K):Promise.reject(K)}}function A$(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function G$(F,$){let P=new URL(F);if($)P.search=new URLSearchParams($).toString();return P.toString()}var p={extend:(F)=>({extend:($)=>p.extend({...F,...$}),get:e("GET",F),post:e("POST",F)}),get:e("GET"),post:e("POST")};import{Chain as j,CosmosChains as _$,EVMChains as x$,StagenetChains as L$,UTXOChains as Q$}from"@swapkit/types";import{match as wF}from"ts-pattern";import{Chain as GF}from"@swapkit/types";function jP(F){if(F<0)throw new T({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function WP(F){if(F<0)throw new T({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function qP(F,$){try{return F()}catch(P){if($)throw new T($,P);return}}function UP(F){switch(F){case GF.THORChain:return`${F}.RUNE`;case GF.Cosmos:return`${F}.ATOM`;case GF.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var IF=new Set;function O({condition:F,id:$,warning:P}){if(F){if(IF.has($))return;console.warn(P),IF.add($)}}function z$(F){return wF(F).with(...x$,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...Q$,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(..._$,...L$,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(j.Polkadot,j.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(j.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(j.Sui,()=>({id:1,jsonrpc:"2.0",method:"sui_getSystemState",params:[]})).with(j.Ton,()=>({id:1,jsonrpc:"2.0",method:"getAddressInformation",params:{address:""}})).with(j.Tron,j.Radix,()=>"").with(j.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(j.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new T("helpers_chain_not_supported",{chain:F})})}function Z$(F){return wF(F).with(j.Radix,()=>"/status/network-configuration").with(j.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function VF(F,$){try{let P=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${P}${Z$(F)}`,{body:JSON.stringify(z$(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var _F=new Map,J$=120000;async function m(F){let{isStagenet:$}=U.get("envs"),[P="",...N]=U.get("rpcUrls")[F];if(!P)throw O({condition:!0,id:"helpers_chain_no_public_or_set_rpc_url",warning:`No public or set RPC URL found for chain. Please ensure you configured rpcUrls for ${F}.`}),new T("helpers_chain_no_public_or_set_rpc_url",{chain:F});if($)return P;let H=_F.get(F);if(H&&Date.now()-H.timestamp<J$)return H.url;if(!await VF(F,P)){for(let B of N)if(await VF(F,B))return _F.set(F,{timestamp:Date.now(),url:B}),B}return _F.set(F,{timestamp:Date.now(),url:P}),P}function kP(F){O({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}var yP=[`${_.Maya}.MAYA`,`${_.Maya}.CACAO`,`${_.Ethereum}.THOR`,`${_.Ethereum}.vTHOR`,`${_.Kujira}.USK`,`${_.Ethereum}.FLIP`,`${_.Radix}.XRD`],KF=[_.Arbitrum,_.Aurora,_.Base,_.Ethereum,_.Optimism];async function M$(F){let{baseDecimal:$}=b(_.Radix);try{let P=await m(_.Radix),{manager:N}=await p.post(`${P}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:F}),headers:{Accept:"*/*","Content-Type":"application/json"}});return N?.divisibility?.value?.divisibility}catch(P){return console.warn(`Failed to fetch Radix asset decimals for ${F}:`,P),$}}async function X$(F){try{let $=await m(_.Radix);return(await p.post(`${$}/state/entity/details`,{body:JSON.stringify({addresses:[F],opt_ins:{explicit_metadata:["symbol"]}}),headers:{Accept:"*/*","Content-Type":"application/json"}})).items[0]?.explicit_metadata?.items.find((H)=>H.key==="symbol")?.value.typed.value||void 0}catch($){console.warn(`Failed to fetch Radix asset symbol for ${F}:`,$);return}}async function OF({chain:F,address:$,methodHex:P,id:N}){let H=await m(F);return p.post(H,{body:JSON.stringify({id:N,jsonrpc:"2.0",method:"eth_call",params:[{data:P,to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}})}async function j$(F){if(!F||F==="0x")return"UNKNOWN";try{let{AbiCoder:$}=await import("ethers");return $.defaultAbiCoder().decode(["string"],F)[0].trim()}catch($){return console.warn(`Failed to decode ABI string from ${F}: ${$}`),"UNKNOWN"}}function W$(F,$){if(!F||F==="0x")return $;try{return Number(F)}catch(P){return console.warn(`Failed to decode ABI uint8 from ${F}: ${P}`),$}}async function q$({chain:F,address:$}){let{baseDecimal:P}=b(F),N=$.toLowerCase();if($===""||!N.startsWith("0x"))return P;let H=await OF({address:$,chain:F,id:2,methodHex:"0x313ce567"}).catch((B)=>{return console.warn(`Could not fetch decimals for ${$} on ${F}: ${B.message}`),{result:""}});return W$(H.result,P)}async function U$({chain:F,address:$}){let P=$.toLowerCase();if(P===""||!P.startsWith("0x"))return;let N=await OF({address:$,chain:F,id:1,methodHex:"0x95d89b41"}).catch((A)=>{return console.warn(`Could not fetch symbol for ${$} on ${F}: ${A.message}`),{result:""}});return await j$(N.result)}function DF({chain:F,address:$}){let{baseDecimal:P}=b(F);return FF(F).with(...T$,async()=>{try{let{isAddress:N,getAddress:H}=await import("ethers");if(!N(H($.replace(/^0X/,"0x"))))return{decimals:P,ticker:void 0};let[A,B]=await Promise.all([U$({address:$,chain:F}),q$({address:$,chain:F})]);return{decimals:B,ticker:A}}catch(N){return console.warn(`Failed to fetch token info for ${$} on ${F}:`,N),{decimals:P,ticker:void 0}}}).with(_.Solana,async()=>{if(!$)return{decimals:P,ticker:void 0};try{let N=await fetch(`https://lite-api.jup.ag/tokens/v2/search?query=${$}`);if(N.ok){let H=await N.json(),A=Array.isArray(H)?H[0]:H;if(A)return{decimals:A.decimals??P,ticker:A.symbol||void 0}}}catch(N){console.warn(`Failed to fetch Solana token info for ${$}:`,N)}return{decimals:P,ticker:void 0}}).with(_.Tron,async()=>{if(!$)return{decimals:P,ticker:void 0};try{let{TronWeb:N}=await import("tronweb"),H=await m(_.Tron),B=await new N({fullHost:H,privateKey:"0000000000000000000000000000000000000000000000000000000000000001"}).contract().at($),[G,x]=await Promise.all([B.symbol().call().catch((L)=>{console.warn(`Could not fetch symbol for ${$} on Tron:`,L);return}),B.decimals().call().catch((L)=>{return console.warn(`Could not fetch decimals for ${$} on Tron:`,L),P})]);return{decimals:typeof x==="number"?x:Number(x||P),ticker:G||void 0}}catch(N){return console.warn(`Failed to fetch Tron token info for ${$}:`,N),{decimals:P,ticker:void 0}}}).with(_.Near,async()=>{if(!$)return{decimals:P,ticker:"UNKNOWN"};try{let{providers:N}=await import("near-api-js"),H=await m(_.Near),B=await new N.JsonRpcProvider({url:H}).query({account_id:$,args_base64:Buffer.from("{}").toString("base64"),finality:"final",method_name:"ft_metadata",request_type:"call_function"}),G=JSON.parse(Buffer.from(B.result).toString());return{decimals:G?.decimals||P,ticker:G?.symbol}}catch(N){return console.warn(`Failed to fetch Near token info for ${$}:`,N),{decimals:P,ticker:void 0}}}).with(_.Radix,async()=>{if(!$)return{decimals:P,ticker:void 0};try{let[N,H]=await Promise.all([X$($),M$($)]);return{decimals:H,ticker:N}}catch(N){return console.warn(`Failed to fetch Radix token info for ${$}:`,N),{decimals:P,ticker:void 0}}}).otherwise(async()=>({decimals:P,ticker:void 0}))}function kF({chain:F,symbol:$}){return FF(F).with(...KF,()=>$==="ETH").with(_.Avalanche,()=>$==="AVAX").with(_.Berachain,()=>$==="BERA").with(_.BinanceSmartChain,()=>$==="BNB").with(_.Gnosis,()=>$==="XDAI").with(_.Maya,()=>$==="CACAO").with(_.Cosmos,()=>$==="ATOM").with(_.THORChain,()=>$==="RUNE").with(_.Tron,()=>$==="TRX").with(_.Radix,()=>`${F}.${$}`===$F(F).identifier).otherwise(()=>$===F)}var $F=(F)=>{let{baseDecimal:$}=b(F);return FF(F.toUpperCase()).with(...KF,(N)=>({decimal:$,identifier:`${N}.ETH`})).with(_.THORChain,(N)=>({decimal:$,identifier:`${N}.RUNE`})).with(_.Cosmos,(N)=>({decimal:$,identifier:`${N}.ATOM`})).with(_.Maya,(N)=>({decimal:10,identifier:`${N}.CACAO`})).with(_.BinanceSmartChain,(N)=>({decimal:$,identifier:`${N}.BNB`})).with(_.Avalanche,(N)=>({decimal:$,identifier:`${N}.AVAX`})).with(_.Gnosis,(N)=>({decimal:$,identifier:`${N}.XDAI`})).with(_.Berachain,(N)=>({decimal:$,identifier:`${N}.BERA`})).with(_.Tron,(N)=>({decimal:$,identifier:`${N}.TRX`})).with(_.Solana,_.Chainflip,_.Kujira,_.Ripple,_.Polkadot,_.Near,...Y$,(N)=>({decimal:$,identifier:`${N}.${N}`})).with(_.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(_.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(N)=>({decimal:6,identifier:N})).with("ETH.FLIP",()=>({decimal:b(_.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:b(_.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:b(_.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(N)=>({decimal:10,identifier:N})).with("MAYA.MAYA",(N)=>({decimal:4,identifier:N})).otherwise(()=>({decimal:$,identifier:F}))};function xF({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return FF(F).with(_.Radix,()=>$===_.Radix||`${F}.${$}`===$F(F).identifier).with(_.Arbitrum,_.Optimism,_.Base,_.Aurora,()=>$===_.Ethereum).with(_.Cosmos,()=>$==="ATOM").with(_.BinanceSmartChain,()=>$==="BNB").with(_.Maya,()=>$==="CACAO").with(_.THORChain,()=>$==="RUNE").with(_.Tron,()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var PF=(F)=>{let[$,...P]=F.split("."),N=F.includes("/"),H=P.join("."),A=H?.split("-"),B=A?.length?A.length===1?A[0]:A.slice(0,-1).join("-"):void 0;return{chain:$,symbol:H,synth:N,ticker:B}};async function fP(F){let{loadTokenLists:$}=await import("./tokens.js"),P=await $();for(let N of Object.values(P))for(let{identifier:H,chain:A,...B}of N.tokens){if("identifier"in F&&H===F.identifier)return H;if("address"in B&&"chain"in F&&A===F.chain&&B.address&&B.address.toLowerCase()===F.contract.toLowerCase())return H}return}var SF=["TERRA",...U.get("chains")];function vF(F=""){let $=F.toUpperCase(),[P]=$.split(".");if(SF.includes(P))return!0;let[N]=$.split("/");if(SF.includes(N))return!0;throw new T({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function mP(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var y=(F)=>10n**BigInt(F),t=(F)=>Math.log10(Number.parseFloat(F.toString()));function d({value:F,bigIntDecimal:$=8,decimal:P=8}){if(P===0)return F.toString();let N=F<0n,H=F.toString().substring(N?1:0),A=P-(H.length-1);if(A>0)H="0".repeat(A)+H;let B=H.length-P,G=H.slice(-P);if(Number.parseInt(G[$]||"0",10)>=5)G=`${G.substring(0,$-1)}${(Number.parseInt(G[$-1]||"0",10)+1).toString()}`;else G=G.substring(0,$);return`${N?"-":""}${H.slice(0,B)}.${G}`.replace(/\.?0*$/,"")}function I$(F,$){if($===0n)throw Error("Cannot divide by zero");let P=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+P)/$;return(F-P)/$}class D{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new D({decimal:$,value:d({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:P}){return D.fromBigInt(F.getBaseValue("bigint")*y(P)/y($),P)}constructor(F){let $=LF(F),P=typeof F==="object";this.decimal=P?F.decimal:void 0,this.decimalMultiplier=P&&"decimalMultiplier"in F?F.decimalMultiplier:y(Math.max(gF(NF($)),this.decimal||0)),this.#H($)}set(F){return new this.constructor({decimal:this.decimal,identifier:this.toString({includeSynthProtocol:!0}),value:F})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let P=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||t(this.decimalMultiplier));switch(F){case"number":return Number(P);case"string":return P;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return P}}getBaseValue(F,$){let P=this.decimalMultiplier/y($||this.decimal||8),N=I$(this.bigIntValue,P);switch(F){case"number":return Number(N);case"string":return N.toString();case"bigint":return N;default:return N}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let P=LF(F),N=NF(P);if(N==="0"||N==="undefined")return 0n;return this.#N(N,$)}toSignificant(F=6){let[$,P]=this.getValue("string").split("."),N=$||"",H=P||"";if((Number.parseInt(N,10)?N.length+H.length:H.length)<=F)return this.getValue("string");if(N.length>=F)return N.slice(0,F).padEnd(N.length,"0");if(Number.parseInt(N,10))return`${N}.${H.slice(0,F-N.length)}`.padEnd(F-N.length,"0");let B=Number.parseInt(H,10),G=`${B}`.slice(0,F);return`0.${G.padStart(H.length-`${B}`.length+G.length,"0")}`}toFixed(F=6){let[$,P]=this.getValue("string").split("."),N=$||"",H=P||"";if(Number.parseInt(N,10))return`${N}.${H.slice(0,F)}`.padEnd(F,"0");let A=Number.parseInt(H,10),B=`${A}`.slice(0,F);return`0.${B.padStart(H.length-`${A}`.length+B.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),P=["","K","M","B","T","Q","Qi","S"],N=Math.floor(Math.log10(Math.abs($))/3),H=P[N];if(!H)return this.getValue("string");let A=10**(N*3);return`${($/A).toFixed(F)}${H}`}toCurrency(F="$",{currencyPosition:$="start",decimal:P=2,decimalSeparator:N=".",thousandSeparator:H=","}={}){let A=this.getValue("number"),[B="",G=""]=A.toFixed(6).split("."),x=B.replace(/\B(?=(\d{3})+(?!\d))/g,H),L=B||G?B==="0"?`${Number.parseFloat(`0.${G}`)}`.replace(".",N):`${x}${Number.parseInt(G,10)?`${N}${G.slice(0,P)}`:""}`:"0.00";return`${$==="start"?F:""}${L}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let P=$||this.decimal||8,N=Math.max(P,t(this.decimalMultiplier)),H=F<0n,A=F.toString().substring(H?1:0),B=N-(A.length-1),G=B>0?"0".repeat(B)+A:A,x=G.length-N,L=G.slice(-N);if(Number.parseInt(L[P]||"0",10)>=5)L=`${L.substring(0,P-1)}${(Number.parseInt(L[P-1]||"0",10)+1).toString()}`;else L=L.substring(0,P);return`${H?"-":""}${G.slice(0,x)}.${L}`.replace(/\.?0*$/,"")}#$(F,...$){let P=this.#P(this,...$),N=Math.max(P,t(this.decimalMultiplier)),H=y(N),A=$.reduce((G,x)=>{let L=this.getBigIntValue(x,N);switch(F){case"add":return G+L;case"sub":return G-L;case"mul":return G*L/H;case"div":{if(L===0n)throw RangeError("Division by zero");return G*H/L}default:return G}},this.bigIntValue*H/this.decimalMultiplier),B=d({bigIntDecimal:N,decimal:N,value:A});return new this.constructor({decimal:this.decimal,decimalMultiplier:y(N),identifier:this.toString(),value:B})}#F(F,...$){let P=this.#P(this,...$),N=this.getBigIntValue($[0]||"0",P),H=this.getBigIntValue(this,P);switch(F){case"gt":return H>N;case"gte":return H>=N;case"lt":return H<N;case"lte":return H<=N;case"eqValue":return H===N;default:return!1}}#H(F){let $=NF(F)||"0";this.bigIntValue=this.#N($)}#P(...F){let $=F.map((P)=>{return typeof P==="object"?P.decimal||t(P.decimalMultiplier):gF(NF(P))}).filter(Boolean);return Math.max(...$,8)}#N(F,$){let P=$?y($):this.decimalMultiplier,N=t(P),[H="",A=""]=F.split(".");return BigInt(`${H}${A.padEnd(N,"0")}`)}}var V$=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function NF(F){let P=`${typeof F==="number"?V$.format(F):LF(F)}`.replaceAll(",",".").split(".");return P.length>1?`${P.slice(0,-1).join("")}.${P.at(-1)}`:P[0]||"0"}function gF(F){let $=F.split(".")[1]?.length||0;return Math.max($,8)}function LF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var k=[Y.Solana,Y.Tron,Y.Near],ZF=[Y.THORChain,Y.Maya],s=new Map,RF=new Map,c=new Map,O$=3600000;function D$(F){let $=c.get(F);if($?.timestamp&&Date.now()-$.timestamp>O$){c.delete(F);return}return $}function k$(F,$){if(c.size>1000){let P=c.keys().next().value;if(P)c.delete(P)}c.set(F,{...$,timestamp:Date.now()})}class r extends D{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:P,chain:N,symbol:H,identifier:A}){super(typeof F==="object"?F:{decimal:$,value:F});let B=yF(A||`${N}.${H}`);this.type=xF(B),this.tax=P,this.chain=B.chain,this.ticker=B.ticker,this.symbol=B.symbol,this.address=B.address,this.isSynthetic=B.isSynthetic,this.isTradeAsset=B.isTradeAsset,this.isGasAsset=B.isGasAsset,this.chainId=HF(B.chain).chainId}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){if(this.isSynthetic)return`${this.chain}.${this.symbol.replace(/\//g,".")}`;if(this.isTradeAsset)return`${this.chain}.${this.symbol.replace(/~/g,"..")}`;let F=this.symbol.replace(/\./g,"__");return`${this.chain}.${F}`}getIconUrl(){return s.get(this.toString())?.logoURI}eqAsset({chain:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let P=F.indexOf(".");if(P===-1)throw new T({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let N=F.slice(0,P),H=F.slice(P+1),A=zF({chain:N,rest:H}).when(({rest:B})=>B.includes(".."),({chain:B,rest:G})=>`${B}.${G.replace(/\.\./g,"~")}`).when(({chain:B,rest:G})=>ZF.includes(B)&&G.includes("."),({chain:B,rest:G})=>`${B}.${G.replace(/\./g,"/")}`).otherwise(({chain:B,rest:G})=>`${B}.${G.replace(/__/g,".")}`);return r.from({asset:A,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:P,...N}){let H=F instanceof D?F.getValue("string"):F,A=g$(N),B=A.includes(":");if(P&&B){let[l,K]=A.split(":");return(async()=>{let g=await bF({address:K,chain:l});return QF({decimal:g.decimals,identifier:g.identifier,value:$?n(BigInt(H),$):H})})()}let G=B?A.split(":").join(".UNKNOWN-"):A,{identifier:x,decimal:L}=$F(G),{chain:M,isSynthetic:Z,isTradeAsset:S,address:V}=yF(x),{baseDecimal:f}=HF(M),v=s.get(k.includes(M)?x:x.toUpperCase());if(!v&&P&&!Z&&!S)return(async()=>{let{ticker:l}=PF(x),K=await bF({address:V,chain:M,ticker:l});return QF({decimal:K.decimals,identifier:K.identifier,value:$?n(BigInt(H),$):H})})();let u=v?.decimal||L;O({condition:!u&&!P,id:`assetValue_static_decimal_not_found_${M}`,warning:`Couldn't find static decimal for one or more tokens on ${M} (Using default ${f} decimal as fallback).
|
|
2
2
|
This can result in incorrect calculations and mess with amount sent on transactions.
|
|
3
3
|
You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
|
|
4
|
-
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`});let{decimal:f,identifier:v,tax:m}=S||{decimal:q||Z,identifier:B},V=$?i(BigInt(N),$):i(N,f);return A?IF(v,$?V:N):Q||Y?jF(v,V):new d({decimal:f,identifier:v,tax:m,value:V})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),A=await $(F);for(let{tokens:R}of Object.values(A))for(let{identifier:N,chain:H,...B}of R){let T=T0(H),G=r.includes(T.chain)?N:N.toUpperCase(),Q="decimals"in B?B.decimals:T.baseDecimal;g.set(G,{decimal:Q,identifier:N})}return!0}static setStaticAssets(F){g.clear();for(let[$,A]of F.entries()){let R=r.includes(A.chain)?A.identifier:A.identifier.toUpperCase(),N="decimals"in A?A.decimals:A.decimal;g.set($,{...A,decimal:N,identifier:R})}return!0}}function h$(F){let $=d.from({chain:F});return G0(F).with(X.Bitcoin,X.Litecoin,X.BitcoinCash,X.Dash,()=>$.set(0.00010001)).with(X.Dogecoin,()=>$.set(1.00000001)).with(X.Avalanche,X.Ethereum,X.Arbitrum,X.BinanceSmartChain,()=>$.set(0.00000001)).with(X.THORChain,X.Maya,()=>$.set(0)).with(X.Cosmos,X.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function IF(F,$=0){S0(F);let R=F.includes("SOL.")?F:F.toUpperCase(),N=g.get(R),H=N?.decimal||await w0(_0(F));if(!N)g.set(R,{decimal:H,identifier:F});return new d({decimal:H,identifier:F,value:i($,H)})}function jF(F,$=0){let A=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,R=A?Q0.includes(A):!1,N=F.slice(0,14).includes("~")?"~":"/",[H,B]=R?F.split(".").slice(1).join().split(N):F.split(N);if(!(H&&B))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new d({decimal:8,identifier:`${A||X.THORChain}.${H}${N}${B}`,value:i($,8)})}function i(F,$){return typeof F==="bigint"?p({bigIntDecimal:$,decimal:$,value:F}):F}function WF(F){let $=G0(F).when((A)=>("chain"in A)&&A.chain!==void 0,({chain:A})=>A).otherwise((A)=>{let R=H0(A.asset);return R.synth?X.THORChain:R.chain});if(!Object.values(X).includes($.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function qF(F){if(WF(F),"chain"in F)return F.chain;let{chain:$,symbol:A}=H0(F.asset);return x0({chain:$,symbol:A})==="Native"?$:F.asset}function VF(F,$,A){let R=F.split("."),N=R[0]?.toUpperCase(),H=Q0.includes(N),B=A?"~":"/",[T,G=""]=H?R.slice(1).join(".").split(B):F.split(B);if(!(T&&G))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:Q,address:Y}=b0({chain:T,symbol:G}),Z=`${T}${B}${G}`;return{address:Y,chain:N,isGasAsset:!1,isSynthetic:$,isTradeAsset:A,symbol:Z,ticker:Q}}function UF(F){let $=F.indexOf("."),A=($===-1?F:F.slice(0,$)).toUpperCase(),R=$===-1?F:F.slice($+1),{address:N,ticker:H}=b0({chain:A,symbol:R}),B;try{B=N&&XF.includes(A)&&E0(N)?E0(N):N}catch(G){B=N}let T=B?`${H}-${B}`:R;return{address:B,chain:A,isGasAsset:O0({chain:A,symbol:R}),isSynthetic:!1,isTradeAsset:!1,symbol:T,ticker:H}}function _0(F){let $=F.slice(0,14),A=$.includes("/"),R=$.includes("~");if(A||R)return VF(F,A,R);return UF(F)}function kF(F,$=!1){let A=$?F.indexOf("-"):F.lastIndexOf("-");if(A===-1)return{address:void 0,ticker:F};let R=F.slice(0,A);return{address:F.slice(A+1),ticker:R}}function b0({symbol:F,chain:$}){let{ticker:A,address:R}=kF(F,$===X.Near);return{address:R&&!r.includes($)?R.toLowerCase():R,ticker:A}}var KF={average:1,fast:1.5,fastest:2};function g0(F="average"){let $=W.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return KF[F]}function wF(F="average"){let $=g0(F),A=10n,R=BigInt(Math.round($*10));return{denominator:A,numerator:R}}function t$(F,$="average"){let{numerator:A,denominator:R}=wF($);return F*A/R}function r$(F,$="average",A=!1){let R=g0($),N=F*R;return A?Math.floor(N):N}class k extends D{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new k({decimal:$,value:p({bigIntDecimal:$,decimal:$,value:F})})}}import{Chain as f0,EVMChains as OF}from"@swapkit/types";function L0(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[A,R,N,,H]=F;return[A,R,N,$.change,H]}if("account"in $){let[A,R,,N,H]=F;return[A,R,$.account,N,H]}return F}function DF([F,$,A,R,N]){let H=typeof N!=="number";if(typeof R!=="number")return`m/${F}'/${$}'/${A}'`;return`m/${F}'/${$}'/${A}'/${R}${H?"":`/${N}`}`}function AA({chain:F,index:$,addressIndex:A=0,type:R}){if(OF.includes(F)){if(R&&["legacy","account"].includes(R))return[44,60,0,$];if(R==="ledgerLive")return[44,60,$,0,A];return L0(y[F],{index:$})}if(F===f0.Solana){if(R==="account")return[44,501,0,$];return L0(y[F],{index:$})}let N=F===f0.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,N,$,0,A];case"segwit":return[49,N,0,0,$];case"legacy":return[44,N,0,0,$];default:return L0(y[F],{index:$})}}function RA(F){let[$,A,R]=F.split("/").map((N)=>Number.parseInt(N,10));switch(A){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var NA=Object.keys(y).reduce((F,$)=>{return F[$]=DF(y[$]),F},{});import{Chain as L,getChainConfig as y0}from"@swapkit/types";import{match as u0}from"ts-pattern";function BA({chain:F,txHash:$}){let{explorerUrl:A}=y0(F);return u0(F).with(L.Maya,L.Kujira,L.Noble,L.Cosmos,L.THORChain,L.Harbor,L.Solana,()=>`${A}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(L.Arbitrum,L.Aurora,L.Avalanche,L.BinanceSmartChain,L.Base,L.Berachain,L.Ethereum,L.Gnosis,L.Optimism,L.Polkadot,L.Polygon,()=>`${A}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(L.Litecoin,L.Bitcoin,L.BitcoinCash,L.Dogecoin,L.Zcash,L.Radix,()=>`${A}/transaction/${$.toLowerCase()}`).with(L.Near,()=>`${A}/txns/${$}`).with(L.Ripple,()=>`${A}/transactions/${$}`).with(L.Tron,()=>`${A}/#/transaction/${$}`).otherwise(()=>"")}function TA({chain:F,address:$}){let{explorerUrl:A}=y0(F);return u0(F).with(L.Solana,L.Radix,()=>`${A}/account/${$}`).with(L.Tron,()=>`${A}/#/address/${$}`).otherwise(()=>`${A}/address/${$}`)}import{Chain as SF,getChainConfig as vF}from"@swapkit/types";function EF({liquidityUnits:F,poolUnits:$,runeDepth:A}){let R=I(F),N=I($),H=I(A),B=R.mul(H),T=N.mul(N).mul(2),G=N.mul(R).mul(2),Q=R.mul(R),Y=N.mul(N).mul(N);return B.mul(T.sub(G).add(Q)).div(Y)}function bF({liquidityUnits:F,poolUnits:$,assetDepth:A}){let R=I(F),N=I($),H=I(A),B=R.mul(H),T=N.mul(N).mul(2),G=N.mul(R).mul(2),Q=R.mul(R),Y=B.mul(T.sub(G).add(Q)),Z=N.mul(N).mul(N);return Y.div(Z)}function LA({percent:F,runeDepth:$,liquidityUnits:A,poolUnits:R}){return EF({liquidityUnits:A,poolUnits:R,runeDepth:$}).mul(F)}function MA({percent:F,assetDepth:$,liquidityUnits:A,poolUnits:R}){return bF({assetDepth:$,liquidityUnits:A,poolUnits:R}).mul(F)}function I(F){return k.fromBigInt(BigInt(F),vF(SF.THORChain).baseDecimal)}function gF({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R}){return{assetAmount:I(R).mul(F).div($),runeAmount:I(A).mul(F).div($)}}function ZA({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R,percent:N}){return Object.fromEntries(Object.entries(gF({assetDepth:R,liquidityUnits:F,poolUnits:$,runeDepth:A})).map(([H,B])=>[H,B.mul(N)]))}function zA({runeDepth:F,poolUnits:$,assetDepth:A,liquidityUnits:R,runeAmount:N,assetAmount:H}){let B=new k({decimal:8,value:F}),T=new k({decimal:8,value:A}),G=new k({decimal:8,value:$}),Q=new k({decimal:8,value:N}),Y=new k({decimal:8,value:H}),Z=Q.mul(T),S=Y.mul(B),q=Q.mul(Y),f=B.mul(T),v=G.mul(Z.add(S.add(q.mul(2)))),m=Z.add(S.add(f.mul(2))),V=v.div(m),K=I(R).add(V);if(V.getBaseValue("number")===0)return K.div(G).getBaseValue("number");let z=G.add(K);return K.div(z).getBaseValue("number")}function YA({runeAmount:F,assetAmount:$,runeDepth:A,assetDepth:R}){if(F==="0"||$==="0"||A==="0"||R==="0")return 0;let N=I(A),H=I(R),B=I($),T=I(F),G=B.mul(N).sub(H.mul(T)),Q=H.mul(T).add(N.mul(H));return Math.abs(G.div(Q).getBaseValue("number"))}import{Chain as a}from"@swapkit/types";import{match as fF}from"ts-pattern";function WA({type:F,address:$}){return`${F}:${$}`}function qA({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function VA(F){return e("POOL+",F)}function UA({chain:F,symbol:$,address:A,...R}){let N=yF({chain:F,symbol:$}),H=A?`:${A}:`:":";return e(`${"+"}:${N}${H}`,R)}function kA({chain:F,symbol:$,ticker:A,basisPoints:R,targetAsset:N}){let H=F==="ETH"&&A!=="ETH"?`${A}-${$.slice(-3)}`:$,B=N?`:${N}`:"";return`${"-"}:${F}.${H}:${R}${B}`}function KA({basisPoints:F,...$}){return e(`${"POOL-"}:${F}`,$)}function wA({name:F,chain:$,address:A,owner:R}){let N=`${"~"}:${F}:${$}:${A}`,H=R?`:${R}`:"";return`${N}${H}`}function OA({name:F,chain:$,asset:A,payout:R,owner:N}){return`${"~"}:${F}:${$}:${R}:${N}:${A}`}function DA(F,{address:$}){return`${F}:${$}`}function SA(F,{unstakeBps:$,...A}){let R=$?`:${$}`:"",N=`${F}${R}`;return e(`${N}`,A)}function e(F,{affiliateAddress:$,affiliateBasisPoints:A}={}){let R=`${F}${$?`:${$}:${A||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function yF({chain:F,symbol:$}){return fF(F).with(a.Bitcoin,a.Dogecoin,a.Litecoin,()=>F.slice(0,1).toLowerCase()).with(a.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}import{getChainConfig as p0}from"@swapkit/types";function yA(){return typeof window.ethereum<"u"}function uA(F){return uF().includes(F)}function uF(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,A=window?.vultisig,R=window?.ethereum?.isBraveWallet,N=window?.ethereum?.isTrust||window?.trustwallet,H=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,B=window?.bitkeep?.ethereum,T=window?.$onekey?.ethereum,G=[];if(F)G.push("METAMASK");if($)G.push("CTRL");if(A)G.push("VULTISIG");if(R)G.push("BRAVE");if(N)G.push("TRUSTWALLET_WEB");if(H)G.push("COINBASE_WEB");if(CF())G.push("OKX_MOBILE");if(B)G.push("BITGET");if(T)G.push("ONEKEY");return G}async function pF(F,$,A){let R=p0($);try{await d0({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:F})}catch(N){if(!A)throw new J("helpers_failed_to_switch_network",{error:N,reason:"networkParams not provided"});await mF(F,A)}}function pA({chains:F,supportedChains:$,walletType:A}){let R=F.filter((H)=>!H||$.includes(H));if(R.length===0)throw new J("wallet_chain_not_supported",{chain:F.join(", "),wallet:A});let N=F.filter((H)=>!$.includes(H));return u({condition:N.length>0,id:`wallet_chain_not_supported_${A}`,warning:`${A} wallet does not support the following chains: ${N.join(", ")}. These chains will be ignored.`}),R}function dF(F,$,A){return async(...R)=>{let{chainIdHex:N}=p0(A);if((await $.getNetwork()).chainId.toString()===N)return F(...R);try{await pF($,A)}catch(H){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:H}})}return F(...R)}}function dA({toolbox:F,chain:$,provider:A=window.ethereum,methodNames:R=[]}){let H=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((B,T)=>{if(!F[T])return B;let G=F[T];if(typeof G!=="function")return B;let Q=dF(G,A,$);return{...B,[T]:Q}},{});return{...F,...H}}function mF(F,$){return d0({method:"wallet_addEthereumChain",params:[$],provider:F})}function mA(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function CA(){let{isTrust:F,isBraveWallet:$,__XDEFI:A,overrideIsMetaMask:R,selectedProvider:N}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(R&&N?.isCoinbaseWallet)return"COINBASE_WEB";if(A)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function oA(){let F=[];function $(R){if(F.map((N)=>N.info.uuid).includes(R.detail.info.uuid))return;F.push(R.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function A(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:A}}function CF(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),A=/android|XiaoMi|MiuiBrowser/i.test(F),R=$||A,N=/OKApp/i.test(F);return R&&N}function d0({provider:F,params:$,method:A}){if(!F?.send)throw new J("helpers_not_found_provider");let R=$?Array.isArray($)?$:[$]:[];return F.send(A,R)}export{Z$ as wrapWithThrow,dF as wrapMethodWithNetworkSwitch,u as warnOnce,b$ as validateTNS,S0 as validateIdentifier,L0 as updateDerivationPath,pF as switchEVMWalletNetwork,d0 as providerRequest,dA as prepareNetworkSwitch,CF as okxMobileEnabled,uF as listWeb3EVMWallets,yA as isWeb3Detected,O0 as isGasAsset,uA as isDetected,q$ as initializeRPCUrlsWithFallback,RA as getWalletFormatFor,L$ as getTHORNameCost,ZA as getSymmetricWithdraw,gF as getSymmetricPoolShare,P0 as getRPCUrl,h$ as getMinAmountByChain,kA as getMemoForWithdraw,qA as getMemoForUnbond,SA as getMemoForTcyStake,DA as getMemoForTcyClaim,KA as getMemoForRunePoolWithdraw,VA as getMemoForRunePoolDeposit,wA as getMemoForNameRegister,OA as getMemoForNamePreferredAssetRegister,WA as getMemoForLeaveAndBond,UA as getMemoForDeposit,M$ as getMAYANameCost,YA as getLiquiditySlippage,wF as getFeeMultiplierAsBigInt,g0 as getFeeMultiplier,BA as getExplorerTxUrl,TA as getExplorerAddressUrl,zA as getEstimatedPoolShare,CA as getETHDefaultWallet,oA as getEIP6963Wallets,AA as getDerivationPathFor,w0 as getDecimal,s as getCommonAssetInfo,z$ as getChainIdentifier,LA as getAsymmetricRuneWithdrawAmount,EF as getAsymmetricRuneShare,MA as getAsymmetricAssetWithdrawAmount,bF as getAsymmetricAssetShare,x0 as getAssetType,p as formatBigIntToSafeValue,D$ as findAssetBy,pA as filterSupportedChains,DF as derivationPathToString,H0 as assetFromString,t$ as applyFeeMultiplierToBigInt,r$ as applyFeeMultiplier,mF as addEVMWalletNetwork,mA as addAccountsChangedCallback,l0 as WarningCodeEnum,c as WalletOption,k as SwapKitNumber,J as SwapKitError,W as SKConfig,l as RequestClient,z0 as RPC_URLS,n0 as ProviderName,y as NetworkDerivationPath,A0 as NODE_URLS,I0 as MemoType,r0 as LedgerErrorCode,s0 as FeeTypeEnum,X0 as FeeOption,Y0 as FALLBACK_URLS,h0 as ErrorCode,J0 as EXPLORER_URLS,NA as DerivationPath,KF as DEFAULT_FEE_MULTIPLIERS,c0 as ContractAddress,O$ as CommonAssetStrings,D as BigIntArithmetics,d as AssetValue,t0 as ApproveMode};
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`});let{decimal:w,identifier:W,tax:J}=v||{decimal:u||f,identifier:x},i=$?n(BigInt(H),$):n(H,w);return Z||S?S$(W,i):QF({decimal:w,identifier:W,tax:J,value:i})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),P=await $(F);for(let{tokens:N}of Object.values(P))for(let{identifier:H,chain:A,...B}of N){let G=HF(A),x=k.includes(G.chain)?H:H.toUpperCase(),M={decimal:"decimals"in B?B.decimals:G.baseDecimal,identifier:H,logoURI:"logoURI"in B?B.logoURI:void 0,tax:"tax"in B?B.tax:void 0};if(s.set(x,M),"address"in B&&B.address){let Z=k.includes(G.chain)?`${G.chain}:${B.address}`:`${G.chain}:${B.address.toUpperCase()}`;RF.set(Z,H)}}return!0}static setStaticAssets(F){s.clear(),RF.clear();for(let[$,P]of F.entries()){let N=k.includes(P.chain)?P.identifier:P.identifier.toUpperCase(),H="decimals"in P?P.decimals:P.decimal,A={...P,decimal:H,identifier:N};if(s.set($,A),P.address){let B=k.includes(P.chain)?`${P.chain}:${P.address}`:`${P.chain}:${P.address.toUpperCase()}`;RF.set(B,P.identifier)}}return!0}}function aP(F){let $=r.from({chain:F});return zF(F).with(Y.Bitcoin,Y.Litecoin,Y.BitcoinCash,Y.Dash,()=>$.set(0.00010001)).with(Y.Dogecoin,()=>$.set(1.00000001)).with(Y.Avalanche,Y.Ethereum,Y.Arbitrum,Y.BinanceSmartChain,()=>$.set(0.00000001)).with(Y.THORChain,Y.Maya,()=>$.set(0)).with(Y.Cosmos,Y.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function bF({chain:F,address:$,ticker:P}){let H=k.includes(F)?`${F}:${$||P}`:`${F}:${$||P}`.toUpperCase(),A=D$(H);if(A)return A;if(!$){let{baseDecimal:x}=HF(F);return{decimals:x,identifier:`${F}.${P||"UNKNOWN"}`}}let B=await DF({address:$,chain:F}),G=`${F}.${B.ticker||P||"UNKNOWN"}-${$}`;return O({condition:!!(!B.ticker&&P),id:`async_token_lookup_failed_${F}_${$}`,warning:`Could not fetch token metadata for ${F}:${$} from chain. Using user-provided ticker (${P}) with baseDecimal (${B.decimals}).`}),B.ticker&&k$(H,{decimals:B.decimals,identifier:G}),{decimals:B.decimals,identifier:G}}function QF({identifier:F,decimal:$,value:P,tax:N}){return vF(F),new r({decimal:$,identifier:F,tax:N,value:n(P,$)})}function S$(F,$=0){let P=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,N=P?ZF.includes(P):!1,H=F.slice(0,14).includes("~")?"~":"/",[A,B]=N?F.split(".").slice(1).join().split(H):F.split(H);if(!(A&&B))throw new T({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new r({decimal:8,identifier:`${P||Y.THORChain}.${A}${H}${B}`,value:n($,8)})}function n(F,$){return typeof F==="bigint"?d({bigIntDecimal:$,decimal:$,value:F}):F}function v$(F){let $=zF(F).when((P)=>("chain"in P)&&P.chain!==void 0,({chain:P})=>P).otherwise((P)=>{let N=PF(P.asset);return N.synth?Y.THORChain:N.chain});if(!w$.includes($.toUpperCase()))throw new T({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function g$(F){if(v$(F),"chain"in F){let{chain:H,address:A}=F;if(A){let B=k.includes(H)?`${H}:${A}`:`${H}:${A.toUpperCase()}`,G=RF.get(B);if(G)return G;return B}return H}let{chain:$,symbol:P}=PF(F.asset);return xF({chain:$,symbol:P})==="Native"?$:F.asset}function E$(F,$,P){let N=F.split("."),H=N[0]?.toUpperCase(),A=ZF.includes(H),B=P?"~":"/",[G,x=""]=A?N.slice(1).join(".").split(B):F.split(B);if(!(G&&x))throw new T({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:L,address:M}=fF({chain:G,symbol:x}),Z=`${G}${B}${x}`;return{address:M,chain:H,isGasAsset:!1,isSynthetic:$,isTradeAsset:P,symbol:Z,ticker:L}}function b$(F){let $=F.indexOf("."),P=($===-1?F:F.slice(0,$)).toUpperCase(),N=$===-1?F:F.slice($+1),{address:H,ticker:A}=fF({chain:P,symbol:N}),B;try{B=H&&K$.includes(P)&&EF(H)?EF(H):H}catch{B=H}let G=B?`${A}-${B}`:N;return{address:B,chain:P,isGasAsset:kF({chain:P,symbol:N}),isSynthetic:!1,isTradeAsset:!1,symbol:G,ticker:A}}function yF(F){let $=F.slice(0,14),P=$.includes("/"),N=$.includes("~");if(P||N)return E$(F,P,N);return b$(F)}function y$(F,$=!1){let P=$?F.indexOf("-"):F.lastIndexOf("-");if(P===-1)return{address:void 0,ticker:F};let N=F.slice(0,P);return{address:F.slice(P+1),ticker:N}}function fF({symbol:F,chain:$}){let{ticker:P,address:N}=y$(F,$===Y.Near);return{address:N&&!k.includes($)?N.toLowerCase():N,ticker:P}}var f$={average:1,fast:1.5,fastest:2};function uF(F="average"){let $=U.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return f$[F]}function u$(F="average"){let $=uF(F),P=10n,N=BigInt(Math.round($*10));return{denominator:P,numerator:N}}function PN(F,$="average"){let{numerator:P,denominator:N}=u$($);return F*P/N}function NN(F,$="average",P=!1){let N=uF($),H=F*N;return P?Math.floor(H):H}class I extends D{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new I({decimal:$,value:d({bigIntDecimal:$,decimal:$,value:F})})}}import{Chain as CF,EVMChains as C$}from"@swapkit/types";function JF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[P,N,H,,A]=F;return[P,N,H,$.change,A]}if("account"in $){let[P,N,,H,A]=F;return[P,N,$.account,H,A]}return F}function p$([F,$,P,N,H]){let A=typeof H!=="number";if(typeof N!=="number")return`m/${F}'/${$}'/${P}'`;return`m/${F}'/${$}'/${P}'/${N}${A?"":`/${H}`}`}function _N({chain:F,index:$,addressIndex:P=0,type:N}){if(C$.includes(F)){if(N&&["legacy","account"].includes(N))return[44,60,0,$];if(N==="ledgerLive")return[44,60,$,0,P];return JF(C[F],{index:$})}if(F===CF.Solana){if(N==="account")return[44,501,0,$];return JF(C[F],{index:$})}let H=F===CF.Litecoin?2:0;switch(N){case"nativeSegwitMiddleAccount":return[84,H,$,0,P];case"segwit":return[49,H,0,0,$];case"legacy":return[44,H,0,0,$];default:return JF(C[F],{index:$})}}function xN(F){let[$,P,N]=F.split("/").map((H)=>Number.parseInt(H,10));switch(P){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var LN=Object.keys(C).reduce((F,$)=>{return F[$]=p$(C[$]),F},{});import{Chain as Q,getChainConfig as pF}from"@swapkit/types";import{match as mF}from"ts-pattern";function JN({chain:F,txHash:$}){let{explorerUrl:P}=pF(F);return mF(F).with(Q.Maya,Q.Kujira,Q.Noble,Q.Cosmos,Q.THORChain,Q.Harbor,Q.Solana,()=>`${P}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(Q.Arbitrum,Q.Aurora,Q.Avalanche,Q.BinanceSmartChain,Q.Base,Q.Berachain,Q.Ethereum,Q.Gnosis,Q.Optimism,Q.Polkadot,Q.Polygon,()=>`${P}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(Q.Litecoin,Q.Bitcoin,Q.BitcoinCash,Q.Dogecoin,Q.Zcash,Q.Radix,Q.Tron,()=>`${P}/transaction/${$.toLowerCase()}`).with(Q.Near,()=>`${P}/txns/${$}`).with(Q.Ripple,()=>`${P}/transactions/${$}`).with(Q.Sui,()=>`${P}/txblock/${$}`).with(Q.Cardano,Q.Ton,()=>`${P}/tx/${$}`).otherwise(()=>"")}function TN({chain:F,address:$}){let{explorerUrl:P}=pF(F);return mF(F).with(Q.Solana,Q.Sui,Q.Radix,()=>`${P}/account/${$}`).otherwise(()=>`${P}/address/${$}`)}import{Chain as m$,getChainConfig as h$}from"@swapkit/types";function o$({liquidityUnits:F,poolUnits:$,runeDepth:P}){let N=X(F),H=X($),A=X(P),B=N.mul(A),G=H.mul(H).mul(2),x=H.mul(N).mul(2),L=N.mul(N),M=H.mul(H).mul(H);return B.mul(G.sub(x).add(L)).div(M)}function d$({liquidityUnits:F,poolUnits:$,assetDepth:P}){let N=X(F),H=X($),A=X(P),B=N.mul(A),G=H.mul(H).mul(2),x=H.mul(N).mul(2),L=N.mul(N),M=B.mul(G.sub(x).add(L)),Z=H.mul(H).mul(H);return M.div(Z)}function jN({percent:F,runeDepth:$,liquidityUnits:P,poolUnits:N}){return o$({liquidityUnits:P,poolUnits:N,runeDepth:$}).mul(F)}function WN({percent:F,assetDepth:$,liquidityUnits:P,poolUnits:N}){return d$({assetDepth:$,liquidityUnits:P,poolUnits:N}).mul(F)}function X(F){return I.fromBigInt(BigInt(F),h$(m$.THORChain).baseDecimal)}function c$({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N}){return{assetAmount:X(N).mul(F).div($),runeAmount:X(P).mul(F).div($)}}function qN({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N,percent:H}){return Object.fromEntries(Object.entries(c$({assetDepth:N,liquidityUnits:F,poolUnits:$,runeDepth:P})).map(([A,B])=>[A,B.mul(H)]))}function UN({runeDepth:F,poolUnits:$,assetDepth:P,liquidityUnits:N,runeAmount:H,assetAmount:A}){let B=new I({decimal:8,value:F}),G=new I({decimal:8,value:P}),x=new I({decimal:8,value:$}),L=new I({decimal:8,value:H}),M=new I({decimal:8,value:A}),Z=L.mul(G),S=M.mul(B),V=L.mul(M),f=B.mul(G),v=x.mul(Z.add(S.add(V.mul(2)))),u=Z.add(S.add(f.mul(2))),w=v.div(u),W=X(N).add(w);if(w.getBaseValue("number")===0)return W.div(x).getBaseValue("number");let J=x.add(W);return W.div(J).getBaseValue("number")}function IN({runeAmount:F,assetAmount:$,runeDepth:P,assetDepth:N}){if(F==="0"||$==="0"||P==="0"||N==="0")return 0;let H=X(P),A=X(N),B=X($),G=X(F),x=B.mul(H).sub(A.mul(G)),L=A.mul(G).add(H.mul(A));return Math.abs(x.div(L).getBaseValue("number"))}import{Chain as BF}from"@swapkit/types";import{match as n$}from"ts-pattern";function DN({type:F,address:$}){return`${F}:${$}`}function kN({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function SN(F){return AF("POOL+",F)}function vN({chain:F,symbol:$,address:P,...N}){let H=l$({chain:F,symbol:$}),A=P?`:${P}:`:":";return AF(`${"+"}:${H}${A}`,N)}function gN({chain:F,symbol:$,ticker:P,basisPoints:N,targetAsset:H}){let A=F==="ETH"&&P!=="ETH"?`${P}-${$.slice(-3)}`:$,B=H?`:${H}`:"";return`${"-"}:${F}.${A}:${N}${B}`}function EN({basisPoints:F,...$}){return AF(`${"POOL-"}:${F}`,$)}function bN({name:F,chain:$,address:P,owner:N}){let H=`${"~"}:${F}:${$}:${P}`,A=N?`:${N}`:"";return`${H}${A}`}function yN({name:F,chain:$,asset:P,payout:N,owner:H}){return`${"~"}:${F}:${$}:${N}:${H}:${P}`}function fN(F,{address:$}){return`${F}:${$}`}function uN(F,{unstakeBps:$,...P}){let N=$?`:${$}`:"",H=`${F}${N}`;return AF(`${H}`,P)}function AF(F,{affiliateAddress:$,affiliateBasisPoints:P}={}){let N=`${F}${$?`:${$}:${P||0}`:""}`;return N.endsWith(":")?N.slice(0,-1):N}function l$({chain:F,symbol:$}){return n$(F).with(BF.Bitcoin,BF.Dogecoin,BF.Litecoin,()=>F.slice(0,1).toLowerCase()).with(BF.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}import{getChainConfig as hF}from"@swapkit/types";function dN(){return typeof window.ethereum<"u"}function cN(F){return t$().includes(F)}function t$(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,P=window?.vultisig,N=window?.ethereum?.isBraveWallet,H=window?.ethereum?.isTrust||window?.trustwallet,A=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,B=window?.bitkeep?.ethereum,G=window?.$onekey?.ethereum,x=[];if(F)x.push("METAMASK");if($)x.push("CTRL");if(P)x.push("VULTISIG");if(N)x.push("BRAVE");if(H)x.push("TRUSTWALLET_WEB");if(A)x.push("COINBASE_WEB");if(a$())x.push("OKX_MOBILE");if(B)x.push("BITGET");if(G)x.push("ONEKEY");return x}async function s$(F,$,P){let N=hF($);try{await oF({method:"wallet_switchEthereumChain",params:[{chainId:N.chainIdHex}],provider:F})}catch(H){if(!P)throw new T("helpers_failed_to_switch_network",{error:H,reason:"networkParams not provided"});await i$(F,P)}}function nN({chains:F,supportedChains:$,walletType:P}){let N=F.filter((A)=>!A||$.includes(A));if(N.length===0)throw new T("wallet_chain_not_supported",{chain:F.join(", "),wallet:P});let H=F.filter((A)=>!$.includes(A));return O({condition:H.length>0,id:`wallet_chain_not_supported_${P}`,warning:`${P} wallet does not support the following chains: ${H.join(", ")}. These chains will be ignored.`}),N}function r$(F,$,P){return async(...N)=>{let{chainIdHex:H}=hF(P);if((await $.getNetwork()).chainId.toString()===H)return F(...N);try{await s$($,P)}catch(A){throw new T({errorKey:"helpers_failed_to_switch_network",info:{error:A}})}return F(...N)}}function lN({toolbox:F,chain:$,provider:P=window.ethereum,methodNames:N=[]}){let A=[...N,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((B,G)=>{if(!F[G])return B;let x=F[G];if(typeof x!=="function")return B;let L=r$(x,P,$);return{...B,[G]:L}},{});return{...F,...A}}function i$(F,$){return oF({method:"wallet_addEthereumChain",params:[$],provider:F})}function tN(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function sN(){let{isTrust:F,isBraveWallet:$,__XDEFI:P,overrideIsMetaMask:N,selectedProvider:H}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(N&&H?.isCoinbaseWallet)return"COINBASE_WEB";if(P)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function rN(){let F=[];function $(N){if(F.map((H)=>H.info.uuid).includes(N.detail.info.uuid))return;F.push(N.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function P(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:P}}function a$(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),P=/android|XiaoMi|MiuiBrowser/i.test(F),N=$||P,H=/OKApp/i.test(F);return N&&H}function oF({provider:F,params:$,method:P}){if(!F?.send)throw new T("helpers_not_found_provider");let N=$?Array.isArray($)?$:[$]:[];return F.send(P,N)}export{qP as wrapWithThrow,r$ as wrapMethodWithNetworkSwitch,O as warnOnce,mP as validateTNS,vF as validateIdentifier,JF as updateDerivationPath,s$ as switchEVMWalletNetwork,oF as providerRequest,lN as prepareNetworkSwitch,a$ as okxMobileEnabled,t$ as listWeb3EVMWallets,dN as isWeb3Detected,kF as isGasAsset,cN as isDetected,kP as initializeRPCUrlsWithFallback,xN as getWalletFormatFor,jP as getTHORNameCost,qN as getSymmetricWithdraw,c$ as getSymmetricPoolShare,m as getRPCUrl,aP as getMinAmountByChain,gN as getMemoForWithdraw,kN as getMemoForUnbond,uN as getMemoForTcyStake,fN as getMemoForTcyClaim,EN as getMemoForRunePoolWithdraw,SN as getMemoForRunePoolDeposit,bN as getMemoForNameRegister,yN as getMemoForNamePreferredAssetRegister,DN as getMemoForLeaveAndBond,vN as getMemoForDeposit,WP as getMAYANameCost,IN as getLiquiditySlippage,u$ as getFeeMultiplierAsBigInt,uF as getFeeMultiplier,JN as getExplorerTxUrl,TN as getExplorerAddressUrl,UN as getEstimatedPoolShare,sN as getETHDefaultWallet,rN as getEIP6963Wallets,_N as getDerivationPathFor,$F as getCommonAssetInfo,UP as getChainIdentifier,jN as getAsymmetricRuneWithdrawAmount,o$ as getAsymmetricRuneShare,WN as getAsymmetricAssetWithdrawAmount,d$ as getAsymmetricAssetShare,xF as getAssetType,d as formatBigIntToSafeValue,fP as findAssetBy,nN as filterSupportedChains,DF as fetchTokenInfo,p$ as derivationPathToString,PF as assetFromString,PN as applyFeeMultiplierToBigInt,NN as applyFeeMultiplier,i$ as addEVMWalletNetwork,tN as addAccountsChangedCallback,lF as WarningCodeEnum,a as WalletOption,I as SwapKitNumber,T as SwapKitError,U as SKConfig,p as RequestClient,tF as ProviderName,C as NetworkDerivationPath,jF as MemoType,iF as LedgerErrorCode,sF as FeeTypeEnum,XF as FeeOption,nF as ErrorCode,LN as DerivationPath,f$ as DEFAULT_FEE_MULTIPLIERS,yP as CommonAssetStrings,D as BigIntArithmetics,r as AssetValue,rF as ApproveMode};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=22BD4EE34630CEF364756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|