@swapkit/helpers 4.0.24 → 4.0.25
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.js +1 -1
- package/dist/{chunk-mvp796yg.js → chunk-pfmeq01a.js} +2 -2
- package/dist/{chunk-mvp796yg.js.map → chunk-pfmeq01a.js.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +4 -4
- package/dist/types/modules/swapKitConfig.d.ts +1 -0
- package/dist/types/modules/swapKitConfig.d.ts.map +1 -1
- package/dist/types/types/chains.d.ts +1 -0
- package/dist/types/types/chains.d.ts.map +1 -1
- package/dist/types/types/derivationPath.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as q0,c as U0}from"./chunk-mvp796yg.js";export*from"@swapkit/tokens";export*from"@swapkit/types";import{Chain as X,EVMChains as JF,getChainConfig as B0}from"@swapkit/types";import{getAddress as v0}from"ethers";import{match as _0}from"ts-pattern";import{Chain as _,EVMChains as V0,getChainConfig as w,UTXOChains as LF}from"@swapkit/types";import{match as n}from"ts-pattern";import{Chain as r0}from"@swapkit/types";import{createStore as i0}from"zustand/vanilla";import{Chain as B,StagenetChain as f}from"@swapkit/types";var Z0={[B.Arbitrum]:"https://arb1.arbitrum.io/rpc",[B.Aurora]:"https://aurora-rpc.publicnode.com",[B.Avalanche]:"https://api.avax.network/ext/bc/C/rpc",[B.Base]:"https://base-rpc.publicnode.com",[B.Berachain]:"https://berachain-rpc.publicnode.com",[B.BinanceSmartChain]:"https://bsc-dataseed.binance.org",[B.BitcoinCash]:"https://node-router.thorswap.net/bitcoin-cash",[B.Bitcoin]:"https://bitcoin-rpc.publicnode.com",[B.Chainflip]:"wss://mainnet-archive.chainflip.io",[B.Cosmos]:"https://cosmos-rpc.publicnode.com:443",[B.Dash]:"https://dash-rpc.publicnode.com",[B.Dogecoin]:"https://node-router.thorswap.net/dogecoin",[B.Ethereum]:"https://ethereum-rpc.publicnode.com",[B.Gnosis]:"https://gnosis-rpc.publicnode.com",[B.Kujira]:"https://kujira-rpc.ibs.team",[B.Litecoin]:"https://node-router.thorswap.net/litecoin",[B.Maya]:"https://tendermint.mayachain.info",[B.Near]:"https://rpc.mainnet.near.org",[B.Noble]:"https://noble-rpc.polkachu.com",[B.Optimism]:"https://mainnet.optimism.io",[B.Polkadot]:"wss://rpc.polkadot.io",[B.Polygon]:"https://polygon-rpc.com",[B.Radix]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",[B.Ripple]:"wss://xrpl.ws/",[B.Solana]:"https://solana-rpc.publicnode.com",[B.THORChain]:"https://rpc.ninerealms.com",[B.Tron]:"https://tron-rpc.publicnode.com",[B.Zcash]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",[f.Maya]:"",[f.THORChain]:"https://stagenet-rpc.ninerealms.com"},$0={[B.THORChain]:"https://thornode.ninerealms.com",[B.Maya]:"https://mayanode.mayachain.info",[f.THORChain]:"https://stagenet-thornode.ninerealms.com",[f.Maya]:"https://stagenet.mayanode.mayachain.info"},z0={[B.Arbitrum]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],[B.Aurora]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],[B.Avalanche]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],[B.Base]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],[B.BinanceSmartChain]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],[B.Berachain]:["https://rpc.berachain.com","https://berachain.drpc.org"],[B.Bitcoin]:["https://bitcoin.publicnode.com"],[B.BitcoinCash]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],[B.Chainflip]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],[B.Cosmos]:["https://cosmos-rpc.publicnode.com"],[B.Dash]:["https://dash-rpc.publicnode.com"],[B.Dogecoin]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],[B.Ethereum]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],[B.Gnosis]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],[B.Kujira]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],[B.Litecoin]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],[B.Maya]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],[f.Maya]:[],[B.Near]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],[B.Noble]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],[B.Optimism]:["https://optimism.llamarpc.com","https://1rpc.io/op"],[B.Polkadot]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],[B.Polygon]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],[B.Radix]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],[B.Ripple]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],[B.THORChain]:["https://thornode.ninerealms.com",$0[B.THORChain]],[f.THORChain]:[],[B.Solana]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],[B.Tron]:["https://api.tronstack.io","https://api.tron.network"],[B.Zcash]:[]},Y0={[B.Arbitrum]:"https://arbiscan.io",[B.Aurora]:"https://explorer.mainnet.aurora.dev",[B.Avalanche]:"https://snowtrace.io",[B.Base]:"https://basescan.org",[B.Berachain]:"https://berascan.com",[B.BinanceSmartChain]:"https://bscscan.com",[B.Bitcoin]:"https://blockchair.com/bitcoin",[B.BitcoinCash]:"https://www.blockchair.com/bitcoin-cash",[B.Chainflip]:"https://explorer.polkascan.io/polkadot",[B.Cosmos]:"https://www.mintscan.io/cosmos",[B.Dash]:"https://blockchair.com/dash",[B.Dogecoin]:"https://blockchair.com/dogecoin",[B.Ethereum]:"https://etherscan.io",[B.Gnosis]:"https://gnosisscan.io",[B.Kujira]:"https://finder.kujira.network/kaiyo-1",[B.Litecoin]:"https://blockchair.com/litecoin",[B.Maya]:"https://www.mayascan.org",[B.Near]:"https://nearblocks.io",[B.Noble]:"https://www.mintscan.io/noble",[B.Optimism]:"https://optimistic.etherscan.io",[B.Polkadot]:"https://polkadot.subscan.io",[B.Polygon]:"https://polygonscan.com",[B.Radix]:"https://dashboard.radixdlt.com",[B.Ripple]:"https://livenet.xrpl.org/",[B.THORChain]:"https://runescan.io",[B.Solana]:"https://solscan.io",[B.Tron]:"https://tronscan.org",[B.Zcash]:"https://blockchair.com/zcash"};var o0;((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"})(o0||={});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],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 c0;((x)=>{x.unknownError="unknownError";x.test_error="test_error";x.providerDetailsError="providerDetailsError";x.blockHeaderNotFound="blockHeaderNotFound";x.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";x.blockHashNotFoundAtHash="blockHashNotFoundAtHash";x.txHashMissing="txHashMissing";x.assetValueMissingInfo="assetValueMissingInfo";x.invalidAsset="invalidAsset";x.blockIsRequired="blockIsRequired";x.currentBlockHeaderNotFound="currentBlockHeaderNotFound";x.failedToRetrieveBalance="failedToRetrieveBalance";x.failedToRetrieveBlock="failedToRetrieveBlock";x.failedToRetrieveFees="failedToRetrieveFees";x.notImplementedBCH="notImplementedBCH";x.notImplementedDoge="notImplementedDoge";x.noPoolsFound="noPoolsFound";x.noVaultsFound="noVaultsFound";x.noTxFound="noTxFound";x.noInputCoinFound="noInputCoinFound";x.noBlockDataFound="noBlockDataFound";x.multipleCosmosMessages="multipleCosmosMessages";x.heightOrHashNotProvided="heightOrHashNotProvided";x.unknownDenom="unknownDenom";x.invalidBlockHeight="invalidBlockHeight";x.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";x.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";x.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";x.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";x.txMemoUndefined="txMemoUndefined";x.txMemoIncorrect="txMemoIncorrect";x.txTypeNotFound="txTypeNotFound";x.txNoMessage="txNoMessage";x.txNotFound="txNotFound";x.txReceiptNotFound="txReceiptNotFound";x.txParsingError="txParsingError";x.txLogsParsingError="txLogsParsingError";x.blockNotFound="blockNotFound";x.balanceNotFound="balanceNotFound";x.configError="configError";x.synthSwapDisallowed="synthSwapDisallowed";x.providerQuoteTimeout="providerQuoteTimeout";x.noQuoteResponse="noQuoteResponse";x.noPoolAssetsFound="noPoolAssetsFound";x.noThorchainPools="noThorchainPools";x.noMayachainPools="noMayachainPools";x.noThorchainNetworkInfo="noThorchainNetworkInfo";x.invalidAffiliateFee="invalidAffiliateFee";x.invalidBuyAssetAddress="invalidBuyAssetAddress";x.invalidSellAssetAddress="invalidSellAssetAddress";x.invalidSourceAddress="invalidSourceAddress";x.invalidDestinationAddress="invalidDestinationAddress";x.sourceAddressIsSmartContract="sourceAddressIsSmartContract";x.destinationAddressIsSmartContract="destinationAddressIsSmartContract";x.invalidChainId="invalidChainId";x.unsupportedChainId="unsupportedChainId";x.unsupportedEVMChainId="unsupportedEVMChainId";x.unsupportedMethod="unsupportedMethod";x.unsupportedProvider="unsupportedProvider";x.invalidParamsForMethod="invalidParamsForMethod";x.unsupportedAdapter="unsupportedAdapter";x.noWhitelistTokens="noWhitelistTokens";x.failedFetchGasPrice="failedFetchGasPrice";x.failedToCreateDepositChannel="failedToCreateDepositChannel";x.noProviderDetailsFound="noProviderDetailsFound";x.noTokenListsFound="noTokenListsFound";x.tokenNotFound="tokenNotFound";x.tokenPriceNotFound="tokenPriceNotFound";x.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";x.swapAmountTooSmall="swapAmountTooSmall";x.legsArrayIsEmpty="legsArrayIsEmpty";x.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";x.noBlockHeaderFound="noBlockHeaderFound";x.failedToSimulateSwap="failedToSimulateSwap";x.addressScreeningFailed="addressScreeningFailed";x.noLiquidtyProvidersFound="noLiquidtyProvidersFound";x.insufficientLiquidity="insufficientLiquidity";x.noInboundDataFound="noInbounDataFound";x.noInboundAddressesFound="noInboundAddressesFound";x.noInboundAddressFoundForChain="noInboundAddressFoundForChain";x.noLastBlocksFound="noLastBlocksFound";x.noVersionFound="noVersionFound";x.noConstantsFound="noConstantsFound";x.noMimirsFound="noMimirsFound";x.noRoutesFound="noRoutesFound";x.quoteNotFound="quoteNotFound";x.ledgerSignFailed="ledgerSignFailed";x.ledgerWrongPayload="ledgerWrongPayload";x.ledgerFetchSwapFailed="ledgerFetchSwapFailed";x.failedToFetchTx="failedToFetchTx";x.failedBuildTransactionDetails="failedBuildTransactionDetails";x.noLegsForRoute="noLegsForRoute";x.noRouterAddressFound="noRouterAddressFound";x.noAggregatorAddressFound="noAggregatorAddressFound";x.noContractInstanceFound="noContractInstanceFound";x.noContractAddressFound="noContractAddressFound";x.invalidAffiliate="invalidAffiliate";x.thornameAffiliate="thornameAffiliate";x.providerNotfound="No provider found";x.noRecordFound="No Record found";x.slippageTooLow="Slippage too low";x.tradingHalted="tradingHalted";x.noWrappedGasAsset="noWrappedGasAsset";x.aggregatorAddressNotFound="aggregatorAddressNotFound";x.routerAddressNotFound="routerAddressNotFound";x.dummyAddressNotFound="dummyAddressNotFound";x.trackerError="trackerError";x.thorchainPoolUnavailable="thorchainPoolUnavailable";x.noOhlcvDataFound="noOhlcvDataFound";x.noTradingPairs="noTradingPairs";x.noLendingAvailability="noLendingAvailability";x.lendingRepayTooSmall="lendingRepayTooSmall";x.missingState="missingState";x.ledgerSwapNotFound="ledgerSwapNotFound";x.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";x.errorEstimatingGas="errorEstimatingGas";x.apiKeyInvalid="apiKeyInvalid";x.apiKeyFailedToUpdate="apiKeyFailedToUpdate";x.apiKeyExpired="apiKeyExpired";x.unauthorized="unauthorized";x.failedToCreateMemo="failedToCreateMemo";x.radixIncorrectInstructions="radixIncorrectInstructions";x.radixTxMissedParam="radixTxMissedParam";x.radixTxMissedAccount="radixTxMissedAccount";x.radixManifestParseError="radixManifestParseError";x.radixManifestBuildError="radixManifestBuildError";x.invalidAddressForChain="invalidAddressForChain";x.riskyAddress="riskyAddress";x.noRoutesToProcess="noRoutesToProcess";x.sellAssetAmountTooSmall="sellAssetAmountTooSmall";x.missingPrivateKey="missingPrivateKey";x.noMemoPriceProtection="noMemoPriceProtection"})(c0||={});var h0;((A)=>{A.highSlippage="highSlippage";A.highPriceImpact="highPriceImpact"})(h0||={});var l0;((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"})(l0||={});var n0;((T)=>{T.LIQUIDITY="liquidity";T.NETWORK="network";T.INBOUND="inbound";T.OUTBOUND="outbound";T.AFFILIATE="affiliate";T.TAX="tax";T.PRIORITY="priority"})(n0||={});var J0;((R)=>{R.Average="average";R.Fast="fast";R.Fastest="fastest"})(J0||={});var s0;((A)=>{A.Approve="approve";A.CheckOnly="checkOnly"})(s0||={});var X0;((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-"})(X0||={});var c;((Q)=>{Q.BITGET="BITGET";Q.BRAVE="BRAVE";Q.COINBASE_MOBILE="COINBASE_MOBILE";Q.COINBASE_WEB="COINBASE_WEB";Q.COSMOSTATION="COSMOSTATION";Q.CTRL="CTRL";Q.EIP6963="EIP6963";Q.EXODUS="EXODUS";Q.KEEPKEY="KEEPKEY";Q.KEEPKEY_BEX="KEEPKEY_BEX";Q.KEPLR="KEPLR";Q.KEYSTORE="KEYSTORE";Q.LEAP="LEAP";Q.LEDGER="LEDGER";Q.LEDGER_LIVE="LEDGER_LIVE";Q.METAMASK="METAMASK";Q.OKX="OKX";Q.OKX_MOBILE="OKX_MOBILE";Q.ONEKEY="ONEKEY";Q.PHANTOM="PHANTOM";Q.POLKADOT_JS="POLKADOT_JS";Q.RADIX_WALLET="RADIX_WALLET";Q.TREZOR="TREZOR";Q.TALISMAN="TALISMAN";Q.TRONLINK="TRONLINK";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.VULTISIG="VULTISIG";Q.WALLETCONNECT="WALLETCONNECT";Q.XAMAN="XAMAN"})(c||={});var t0;((R)=>{R[R.NoError=36864]="NoError";R[R.LockedDevice=21781]="LockedDevice";R[R.TC_NotFound=65535]="TC_NotFound"})(t0||={});var a0={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:Object.values(r0),envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},explorerUrls:Y0,fallbackRpcUrls:z0,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:$0,requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:Z0,wallets:Object.values(c)},j=i0((F)=>({...a0,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 e0={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=e0;constructor(F,$){let A=typeof F==="string",R=A?F:F.errorKey,P=A?void 0:F.info,N=`${R}${P?`: ${JSON.stringify(P)}`:""}`;super(N);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${R}]:`,$);else if(P)console.error(`SwapKitError [${R}]:`,P)}}var FF=(F)=>new Promise(($)=>setTimeout($,F)),$F=(F,{baseDelay:$,backoffMultiplier:A,maxDelay:R})=>Math.min($*A**F,R),AF=async(F,$)=>{let A=await fetch(F,$);if(!A.ok){let P={message:await A.text(),status:A.status,statusText:A.statusText};throw new J({errorKey:"helpers_invalid_response",info:P},P)}return A.json()};function h(F,$={}){return async function(R,P={}){let{searchParams:N,json:H,body:T,headers:G,dynamicHeader:L,retry:Y,timeoutMs:Z,abortController:D,onError:q,onSuccess:b,responseHandler:S,...m}={...$,...P},U=W.get("requestOptions"),K={...U.retry,...Y},z=!!H||R.endsWith(".json"),d0=PF(R,N),m0=RF(z,{...G,...L?.()}),C0=z?JSON.stringify(H):T,F0;for(let o=0;o<=K.maxRetries;o++){let Q0=D||new AbortController,M0=setTimeout(()=>Q0.abort(),Z||U.timeoutMs);try{let v=await AF(d0,{...m,body:C0,headers:m0,method:F,signal:Q0.signal});return clearTimeout(M0),b?.(v)||S?.(v)||v}catch(v){if(clearTimeout(M0),F0=v,o>=K.maxRetries)return q?q(v):Promise.reject(v);await FF($F(o,K))}}return q?q(F0):Promise.reject(F0)}}function RF(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 V,CosmosChains as xF,EVMChains as NF,StagenetChains as HF,UTXOChains as BF}from"@swapkit/types";import{match as W0}from"ts-pattern";import{Chain as A0}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 Q$(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 M$(F,$){try{return F()}catch(A){if($)throw new J($,A);return}}function Z$(F){switch(F){case A0.THORChain:return`${F}.RUNE`;case A0.Cosmos:return`${F}.ATOM`;case A0.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var I0=new Set;function u({condition:F,id:$,warning:A}){if(F){if(I0.has($))return;console.warn(A),I0.add($)}}function TF(F){return W0(F).with(...NF,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...BF,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...xF,...HF,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(V.Polkadot,V.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(V.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(V.Tron,V.Radix,()=>"").with(V.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(V.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:F})})}function _F(F){return W0(F).with(V.Radix,()=>"/status/network-configuration").with(V.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function j0(F,$){try{let A=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${A}${_F(F)}`,{body:JSON.stringify(TF(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var R0=new Map,GF=120000;async function P0(F){let{isStagenet:$}=W.get("envs"),A=W.get("rpcUrls"),R=W.get("fallbackRpcUrls");if($)return A[F];let P=R0.get(F);if(P&&Date.now()-P.timestamp<GF)return P.url;let N=A[F];if(!await j0(F,N)){for(let T of R[F])if(await j0(F,T))return R0.set(F,{timestamp:Date.now(),url:T}),T}return R0.set(F,{timestamp:Date.now(),url:N}),N}function W$(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 w$=[`${_.Maya}.MAYA`,`${_.Maya}.CACAO`,`${_.Ethereum}.THOR`,`${_.Ethereum}.vTHOR`,`${_.Kujira}.USK`,`${_.Ethereum}.FLIP`,`${_.Radix}.XRD`],k0=[_.Arbitrum,_.Aurora,_.Base,_.Ethereum,_.Optimism];async function QF({chain:F,to:$}){let{baseDecimal:R}=w(F);try{let P=await P0(F),{result:N}=await l.post(P,{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(N||R).toString(),10)}catch(P){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,P),R}}async function MF(F){let{baseDecimal:$}=w(_.Radix);if(F===_.Radix)return $;try{let A=F.split("-")[1]?.toLowerCase(),R=await P0(_.Radix),{manager:P}=await l.post(`${R}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:A}),headers:{Accept:"*/*","Content-Type":"application/json"}});return P.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}=w(F);if(V0.includes($))return A;let R=$.split("-"),P=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(P?.startsWith("0x")?QF({chain:F,to:P}):A)}function K0({chain:F,symbol:$}){let{baseDecimal:A}=w(F);return n(F).with(...V0,(R)=>ZF({chain:R,symbol:$})).with(_.Radix,()=>MF($)).otherwise(()=>A)}function w0({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:$}=w(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:w(_.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:w(_.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:w(_.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 N0=(F)=>{let[$,...A]=F.split("."),R=F.includes("/"),P=A.join("."),N=P?.split("-"),H=N?.length?N.length===1?N[0]:N.slice(0,-1).join("-"):void 0;return{chain:$,symbol:P,synth:R,ticker:H}};async function O$(F){let{loadTokenLists:$}=await import("./tokens.js"),A=await $();for(let R of Object.values(A))for(let{identifier:P,chain:N,...H}of R.tokens){if("identifier"in F&&P===F.identifier)return P;if("address"in H&&"chain"in F&&N===F.chain&&H.address&&H.address.toLowerCase()===F.contract.toLowerCase())return P}return}var O0=["TERRA",...W.get("chains")];function D0(F=""){let $=F.toUpperCase(),[A]=$.split(".");if(O0.includes(A))return!0;let[R]=$.split("/");if(O0.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 E$(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var E=(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,P=F.toString().substring(R?1:0),N=A-(P.length-1);if(N>0)P="0".repeat(N)+P;let H=P.length-A,T=P.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?"-":""}${P.slice(0,H)}.${T}`.replace(/\.?0*$/,"")}function zF(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 O{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new O({decimal:$,value:p({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:A}){return O.fromBigInt(F.getBaseValue("bigint")*E(A)/E($),A)}constructor(F){let $=H0(F),A=typeof F==="object";this.decimal=A?F.decimal:void 0,this.decimalMultiplier=A&&"decimalMultiplier"in F?F.decimalMultiplier:E(Math.max(S0(t($)),this.decimal||0)),this.#P($)}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/E($||this.decimal||8),R=zF(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=H0(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=$||"",P=A||"";if((Number.parseInt(R,10)?R.length+P.length:P.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}.${P.slice(0,F-R.length)}`.padEnd(F-R.length,"0");let H=Number.parseInt(P,10),T=`${H}`.slice(0,F);return`0.${T.padStart(P.length-`${H}`.length+T.length,"0")}`}toFixed(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",P=A||"";if(Number.parseInt(R,10))return`${R}.${P.slice(0,F)}`.padEnd(F,"0");let N=Number.parseInt(P,10),H=`${N}`.slice(0,F);return`0.${H.padStart(P.length-`${N}`.length+H.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),P=A[R];if(!P)return this.getValue("string");let N=10**(R*3);return`${($/N).toFixed(F)}${P}`}toCurrency(F="$",{currencyPosition:$="start",decimal:A=2,decimalSeparator:R=".",thousandSeparator:P=","}={}){let N=this.getValue("number"),[H="",T=""]=N.toFixed(6).split("."),G=H.replace(/\B(?=(\d{3})+(?!\d))/g,P),L=H||T?H==="0"?`${Number.parseFloat(`0.${T}`)}`.replace(".",R):`${G}${Number.parseInt(T,10)?`${R}${T.slice(0,A)}`:""}`:"0.00";return`${$==="start"?F:""}${L}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let A=$||this.decimal||8,R=Math.max(A,C(this.decimalMultiplier)),P=F<0n,N=F.toString().substring(P?1:0),H=R-(N.length-1),T=H>0?"0".repeat(H)+N:N,G=T.length-R,L=T.slice(-R);if(Number.parseInt(L[A]||"0",10)>=5)L=`${L.substring(0,A-1)}${(Number.parseInt(L[A-1]||"0",10)+1).toString()}`;else L=L.substring(0,A);return`${P?"-":""}${T.slice(0,G)}.${L}`.replace(/\.?0*$/,"")}#$(F,...$){let A=this.#A(this,...$),R=Math.max(A,C(this.decimalMultiplier)),P=E(R),N=$.reduce((T,G)=>{let L=this.getBigIntValue(G,R);switch(F){case"add":return T+L;case"sub":return T-L;case"mul":return T*L/P;case"div":{if(L===0n)throw RangeError("Division by zero");return T*P/L}default:return T}},this.bigIntValue*P/this.decimalMultiplier),H=p({bigIntDecimal:R,decimal:R,value:N});return new this.constructor({decimal:this.decimal,decimalMultiplier:E(R),identifier:this.toString(),value:H})}#F(F,...$){let A=this.#A(this,...$),R=this.getBigIntValue($[0]||"0",A),P=this.getBigIntValue(this,A);switch(F){case"gt":return P>R;case"gte":return P>=R;case"lt":return P<R;case"lte":return P<=R;case"eqValue":return P===R;default:return!1}}#P(F){let $=t(F)||"0";this.bigIntValue=this.#R($)}#A(...F){let $=F.map((A)=>{return typeof A==="object"?A.decimal||C(A.decimalMultiplier):S0(t(A))}).filter(Boolean);return Math.max(...$,8)}#R(F,$){let A=$?E($):this.decimalMultiplier,R=C(A),[P="",N=""]=F.split(".");return BigInt(`${P}${N.padEnd(R,"0")}`)}}var YF=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function t(F){let A=`${typeof F==="number"?YF.format(F):H0(F)}`.replaceAll(",",".").split(".");return A.length>1?`${A.slice(0,-1).join("")}.${A.at(-1)}`:A[0]||"0"}function S0(F){let $=F.split(".")[1]?.length||0;return Math.max($,8)}function H0(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var r=[X.Solana,X.Tron,X.Near],G0=[X.THORChain,X.Maya],g=new Map;class d extends O{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:A,chain:R,symbol:P,identifier:N}){super(typeof F==="object"?F:{decimal:$,value:F});let H=T0(N||`${R}.${P}`);this.type=x0(H),this.tax=A,this.chain=H.chain,this.ticker=H.ticker,this.symbol=H.symbol,this.address=H.address,this.isSynthetic=H.isSynthetic,this.isTradeAsset=H.isTradeAsset,this.isGasAsset=H.isGasAsset,this.chainId=B0(H.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),P=F.slice(A+1),N=_0({chain:R,rest:P}).when(({rest:H})=>H.includes(".."),({chain:H,rest:T})=>`${H}.${T.replace(/\.\./g,"~")}`).when(({chain:H,rest:T})=>G0.includes(H)&&T.includes("."),({chain:H,rest:T})=>`${H}.${T.replace(/\./g,"/")}`).otherwise(({chain:H,rest:T})=>`${H}.${T.replace(/__/g,".")}`);return d.from({asset:N,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:A,...R}){let P=F instanceof O?F.getValue("string"):F,N=WF(R),{identifier:H,decimal:T}=s(N),{chain:G,isSynthetic:L,isTradeAsset:Y}=T0(H),{baseDecimal:Z}=B0(G),D=g.get(r.includes(G)?H:H.toUpperCase()),q=D?.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 U0,c as V0}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 QF}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 N,getChainConfig as $0,StagenetChain as w}from"@swapkit/types";var z0={[N.Arbitrum]:"https://arb1.arbitrum.io/rpc",[N.Aurora]:"https://aurora-rpc.publicnode.com",[N.Avalanche]:"https://api.avax.network/ext/bc/C/rpc",[N.Base]:"https://base-rpc.publicnode.com",[N.Berachain]:"https://berachain-rpc.publicnode.com",[N.BinanceSmartChain]:"https://bsc-dataseed.binance.org",[N.BitcoinCash]:"https://node-router.thorswap.net/bitcoin-cash",[N.Bitcoin]:"https://bitcoin-rpc.publicnode.com",[N.Chainflip]:"wss://mainnet-archive.chainflip.io",[N.Cosmos]:"https://cosmos-rpc.publicnode.com:443",[N.Dash]:"https://dash-rpc.publicnode.com",[N.Dogecoin]:"https://node-router.thorswap.net/dogecoin",[N.Ethereum]:"https://ethereum-rpc.publicnode.com",[N.Gnosis]:"https://gnosis-rpc.publicnode.com",[N.Harbor]:$0(N.Harbor).rpcUrl,[N.Kujira]:"https://kujira-rpc.ibs.team",[N.Litecoin]:"https://node-router.thorswap.net/litecoin",[N.Maya]:"https://tendermint.mayachain.info",[N.Near]:"https://rpc.mainnet.near.org",[N.Noble]:"https://noble-rpc.polkachu.com",[N.Optimism]:"https://mainnet.optimism.io",[N.Polkadot]:"wss://rpc.polkadot.io",[N.Polygon]:"https://polygon-rpc.com",[N.Radix]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",[N.Ripple]:"wss://xrpl.ws/",[N.Solana]:"https://solana-rpc.publicnode.com",[N.THORChain]:"https://rpc.ninerealms.com",[N.Tron]:"https://tron-rpc.publicnode.com",[N.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(N.Harbor).rpcUrl},A0={[N.THORChain]:"https://thornode.ninerealms.com",[N.Maya]:"https://mayanode.mayachain.info",[N.Harbor]:$0(N.Harbor).rpcUrl,[w.THORChain]:"https://stagenet-thornode.ninerealms.com",[w.Maya]:"https://stagenet.mayanode.mayachain.info"},Y0={[N.Arbitrum]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],[N.Aurora]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],[N.Avalanche]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],[N.Base]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],[N.BinanceSmartChain]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],[N.Berachain]:["https://rpc.berachain.com","https://berachain.drpc.org"],[N.Bitcoin]:["https://bitcoin.publicnode.com"],[N.BitcoinCash]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],[N.Chainflip]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],[N.Cosmos]:["https://cosmos-rpc.publicnode.com"],[N.Dash]:["https://dash-rpc.publicnode.com"],[N.Dogecoin]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],[N.Ethereum]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],[N.Gnosis]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],[N.Harbor]:[],[N.Kujira]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],[N.Litecoin]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],[N.Maya]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],[w.Maya]:[],[N.Near]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],[N.Noble]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],[N.Optimism]:["https://optimism.llamarpc.com","https://1rpc.io/op"],[N.Polkadot]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],[N.Polygon]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],[N.Radix]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],[N.Ripple]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],[N.THORChain]:["https://thornode.ninerealms.com",A0[N.THORChain]],[w.THORChain]:[],[w.Harbor]:[],[N.Solana]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],[N.Tron]:["https://api.tronstack.io","https://api.tron.network"],[N.Zcash]:[]},J0={[N.Arbitrum]:"https://arbiscan.io",[N.Aurora]:"https://explorer.mainnet.aurora.dev",[N.Avalanche]:"https://snowtrace.io",[N.Base]:"https://basescan.org",[N.Berachain]:"https://berascan.com",[N.BinanceSmartChain]:"https://bscscan.com",[N.Bitcoin]:"https://blockchair.com/bitcoin",[N.BitcoinCash]:"https://www.blockchair.com/bitcoin-cash",[N.Chainflip]:"https://explorer.polkascan.io/polkadot",[N.Cosmos]:"https://www.mintscan.io/cosmos",[N.Dash]:"https://blockchair.com/dash",[N.Dogecoin]:"https://blockchair.com/dogecoin",[N.Ethereum]:"https://etherscan.io",[N.Gnosis]:"https://gnosisscan.io",[N.Harbor]:"",[N.Kujira]:"https://finder.kujira.network/kaiyo-1",[N.Litecoin]:"https://blockchair.com/litecoin",[N.Maya]:"https://www.mayascan.org",[N.Near]:"https://nearblocks.io",[N.Noble]:"https://www.mintscan.io/noble",[N.Optimism]:"https://optimistic.etherscan.io",[N.Polkadot]:"https://polkadot.subscan.io",[N.Polygon]:"https://polygonscan.com",[N.Radix]:"https://dashboard.radixdlt.com",[N.Ripple]:"https://livenet.xrpl.org/",[N.THORChain]:"https://runescan.io",[N.Solana]:"https://solscan.io",[N.Tron]:"https://tronscan.org",[N.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;((x)=>{x.unknownError="unknownError";x.test_error="test_error";x.providerDetailsError="providerDetailsError";x.blockHeaderNotFound="blockHeaderNotFound";x.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";x.blockHashNotFoundAtHash="blockHashNotFoundAtHash";x.txHashMissing="txHashMissing";x.assetValueMissingInfo="assetValueMissingInfo";x.invalidAsset="invalidAsset";x.blockIsRequired="blockIsRequired";x.currentBlockHeaderNotFound="currentBlockHeaderNotFound";x.failedToRetrieveBalance="failedToRetrieveBalance";x.failedToRetrieveBlock="failedToRetrieveBlock";x.failedToRetrieveFees="failedToRetrieveFees";x.notImplementedBCH="notImplementedBCH";x.notImplementedDoge="notImplementedDoge";x.noPoolsFound="noPoolsFound";x.noVaultsFound="noVaultsFound";x.noTxFound="noTxFound";x.noInputCoinFound="noInputCoinFound";x.noBlockDataFound="noBlockDataFound";x.multipleCosmosMessages="multipleCosmosMessages";x.heightOrHashNotProvided="heightOrHashNotProvided";x.unknownDenom="unknownDenom";x.invalidBlockHeight="invalidBlockHeight";x.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";x.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";x.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";x.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";x.txMemoUndefined="txMemoUndefined";x.txMemoIncorrect="txMemoIncorrect";x.txTypeNotFound="txTypeNotFound";x.txNoMessage="txNoMessage";x.txNotFound="txNotFound";x.txReceiptNotFound="txReceiptNotFound";x.txParsingError="txParsingError";x.txLogsParsingError="txLogsParsingError";x.blockNotFound="blockNotFound";x.balanceNotFound="balanceNotFound";x.configError="configError";x.synthSwapDisallowed="synthSwapDisallowed";x.providerQuoteTimeout="providerQuoteTimeout";x.noQuoteResponse="noQuoteResponse";x.noPoolAssetsFound="noPoolAssetsFound";x.noThorchainPools="noThorchainPools";x.noMayachainPools="noMayachainPools";x.noThorchainNetworkInfo="noThorchainNetworkInfo";x.invalidAffiliateFee="invalidAffiliateFee";x.invalidBuyAssetAddress="invalidBuyAssetAddress";x.invalidSellAssetAddress="invalidSellAssetAddress";x.invalidSourceAddress="invalidSourceAddress";x.invalidDestinationAddress="invalidDestinationAddress";x.sourceAddressIsSmartContract="sourceAddressIsSmartContract";x.destinationAddressIsSmartContract="destinationAddressIsSmartContract";x.invalidChainId="invalidChainId";x.unsupportedChainId="unsupportedChainId";x.unsupportedEVMChainId="unsupportedEVMChainId";x.unsupportedMethod="unsupportedMethod";x.unsupportedProvider="unsupportedProvider";x.invalidParamsForMethod="invalidParamsForMethod";x.unsupportedAdapter="unsupportedAdapter";x.noWhitelistTokens="noWhitelistTokens";x.failedFetchGasPrice="failedFetchGasPrice";x.failedToCreateDepositChannel="failedToCreateDepositChannel";x.noProviderDetailsFound="noProviderDetailsFound";x.noTokenListsFound="noTokenListsFound";x.tokenNotFound="tokenNotFound";x.tokenPriceNotFound="tokenPriceNotFound";x.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";x.swapAmountTooSmall="swapAmountTooSmall";x.legsArrayIsEmpty="legsArrayIsEmpty";x.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";x.noBlockHeaderFound="noBlockHeaderFound";x.failedToSimulateSwap="failedToSimulateSwap";x.addressScreeningFailed="addressScreeningFailed";x.noLiquidtyProvidersFound="noLiquidtyProvidersFound";x.insufficientLiquidity="insufficientLiquidity";x.noInboundDataFound="noInbounDataFound";x.noInboundAddressesFound="noInboundAddressesFound";x.noInboundAddressFoundForChain="noInboundAddressFoundForChain";x.noLastBlocksFound="noLastBlocksFound";x.noVersionFound="noVersionFound";x.noConstantsFound="noConstantsFound";x.noMimirsFound="noMimirsFound";x.noRoutesFound="noRoutesFound";x.quoteNotFound="quoteNotFound";x.ledgerSignFailed="ledgerSignFailed";x.ledgerWrongPayload="ledgerWrongPayload";x.ledgerFetchSwapFailed="ledgerFetchSwapFailed";x.failedToFetchTx="failedToFetchTx";x.failedBuildTransactionDetails="failedBuildTransactionDetails";x.noLegsForRoute="noLegsForRoute";x.noRouterAddressFound="noRouterAddressFound";x.noAggregatorAddressFound="noAggregatorAddressFound";x.noContractInstanceFound="noContractInstanceFound";x.noContractAddressFound="noContractAddressFound";x.invalidAffiliate="invalidAffiliate";x.thornameAffiliate="thornameAffiliate";x.providerNotfound="No provider found";x.noRecordFound="No Record found";x.slippageTooLow="Slippage too low";x.tradingHalted="tradingHalted";x.noWrappedGasAsset="noWrappedGasAsset";x.aggregatorAddressNotFound="aggregatorAddressNotFound";x.routerAddressNotFound="routerAddressNotFound";x.dummyAddressNotFound="dummyAddressNotFound";x.trackerError="trackerError";x.thorchainPoolUnavailable="thorchainPoolUnavailable";x.noOhlcvDataFound="noOhlcvDataFound";x.noTradingPairs="noTradingPairs";x.noLendingAvailability="noLendingAvailability";x.lendingRepayTooSmall="lendingRepayTooSmall";x.missingState="missingState";x.ledgerSwapNotFound="ledgerSwapNotFound";x.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";x.errorEstimatingGas="errorEstimatingGas";x.apiKeyInvalid="apiKeyInvalid";x.apiKeyFailedToUpdate="apiKeyFailedToUpdate";x.apiKeyExpired="apiKeyExpired";x.unauthorized="unauthorized";x.failedToCreateMemo="failedToCreateMemo";x.radixIncorrectInstructions="radixIncorrectInstructions";x.radixTxMissedParam="radixTxMissedParam";x.radixTxMissedAccount="radixTxMissedAccount";x.radixManifestParseError="radixManifestParseError";x.radixManifestBuildError="radixManifestBuildError";x.invalidAddressForChain="invalidAddressForChain";x.riskyAddress="riskyAddress";x.noRoutesToProcess="noRoutesToProcess";x.sellAssetAmountTooSmall="sellAssetAmountTooSmall";x.missingPrivateKey="missingPrivateKey";x.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;((Q)=>{Q.BITGET="BITGET";Q.BRAVE="BRAVE";Q.COINBASE_MOBILE="COINBASE_MOBILE";Q.COINBASE_WEB="COINBASE_WEB";Q.COSMOSTATION="COSMOSTATION";Q.CTRL="CTRL";Q.EIP6963="EIP6963";Q.EXODUS="EXODUS";Q.KEEPKEY="KEEPKEY";Q.KEEPKEY_BEX="KEEPKEY_BEX";Q.KEPLR="KEPLR";Q.KEYSTORE="KEYSTORE";Q.LEAP="LEAP";Q.LEDGER="LEDGER";Q.LEDGER_LIVE="LEDGER_LIVE";Q.METAMASK="METAMASK";Q.OKX="OKX";Q.OKX_MOBILE="OKX_MOBILE";Q.ONEKEY="ONEKEY";Q.PHANTOM="PHANTOM";Q.POLKADOT_JS="POLKADOT_JS";Q.RADIX_WALLET="RADIX_WALLET";Q.TREZOR="TREZOR";Q.TALISMAN="TALISMAN";Q.TRONLINK="TRONLINK";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.VULTISIG="VULTISIG";Q.WALLETCONNECT="WALLETCONNECT";Q.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,P=A?void 0:F.info,H=`${R}${P?`: ${JSON.stringify(P)}`:""}`;super(H);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${R}]:`,$);else if(P)console.error(`SwapKitError [${R}]:`,P)}}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 P={message:await A.text(),status:A.status,statusText:A.statusText};throw new J({errorKey:"helpers_invalid_response",info:P},P)}return A.json()};function h(F,$={}){return async function(R,P={}){let{searchParams:H,json:B,body:T,headers:G,dynamicHeader:L,retry:Y,timeoutMs:Z,abortController:S,onError:q,onSuccess:f,responseHandler:v,...m}={...$,...P},U=W.get("requestOptions"),K={...U.retry,...Y},z=!!B||R.endsWith(".json"),m0=xF(R,H),C0=PF(z,{...G,...L?.()}),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||U.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 PF(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function xF(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 V,CosmosChains as NF,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 Q$(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(...NF,...BF,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(V.Polkadot,V.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(V.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(V.Tron,V.Radix,()=>"").with(V.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(V.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(V.Radix,()=>"/status/network-configuration").with(V.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 P0=new Map,LF=120000;async function x0(F){let{isStagenet:$}=W.get("envs"),A=W.get("rpcUrls"),R=W.get("fallbackRpcUrls");if($)return A[F];let P=P0.get(F);if(P&&Date.now()-P.timestamp<LF)return P.url;let H=A[F];if(!await W0(F,H)){for(let T of R[F])if(await W0(F,T))return P0.set(F,{timestamp:Date.now(),url:T}),T}return P0.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 P=await x0(F),{result:H}=await l.post(P,{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(P){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,P),R}}async function ZF(F){let{baseDecimal:$}=O(_.Radix);if(F===_.Radix)return $;try{let A=F.split("-")[1]?.toLowerCase(),R=await x0(_.Radix),{manager:P}=await l.post(`${R}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:A}),headers:{Accept:"*/*","Content-Type":"application/json"}});return P.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("-"),P=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(P?.startsWith("0x")?MF({chain:F,to:P}):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,...QF,(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 N0({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("/"),P=A.join("."),H=P?.split("-"),B=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:$,symbol:P,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:P,chain:H,...B}of R.tokens){if("identifier"in F&&P===F.identifier)return P;if("address"in B&&"chain"in F&&H===F.chain&&B.address&&B.address.toLowerCase()===F.contract.toLowerCase())return P}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,P=F.toString().substring(R?1:0),H=A-(P.length-1);if(H>0)P="0".repeat(H)+P;let B=P.length-A,T=P.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?"-":""}${P.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.#P($)}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=$||"",P=A||"";if((Number.parseInt(R,10)?R.length+P.length:P.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}.${P.slice(0,F-R.length)}`.padEnd(F-R.length,"0");let B=Number.parseInt(P,10),T=`${B}`.slice(0,F);return`0.${T.padStart(P.length-`${B}`.length+T.length,"0")}`}toFixed(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",P=A||"";if(Number.parseInt(R,10))return`${R}.${P.slice(0,F)}`.padEnd(F,"0");let H=Number.parseInt(P,10),B=`${H}`.slice(0,F);return`0.${B.padStart(P.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),P=A[R];if(!P)return this.getValue("string");let H=10**(R*3);return`${($/H).toFixed(F)}${P}`}toCurrency(F="$",{currencyPosition:$="start",decimal:A=2,decimalSeparator:R=".",thousandSeparator:P=","}={}){let H=this.getValue("number"),[B="",T=""]=H.toFixed(6).split("."),G=B.replace(/\B(?=(\d{3})+(?!\d))/g,P),L=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:""}${L}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let A=$||this.decimal||8,R=Math.max(A,C(this.decimalMultiplier)),P=F<0n,H=F.toString().substring(P?1:0),B=R-(H.length-1),T=B>0?"0".repeat(B)+H:H,G=T.length-R,L=T.slice(-R);if(Number.parseInt(L[A]||"0",10)>=5)L=`${L.substring(0,A-1)}${(Number.parseInt(L[A-1]||"0",10)+1).toString()}`;else L=L.substring(0,A);return`${P?"-":""}${T.slice(0,G)}.${L}`.replace(/\.?0*$/,"")}#$(F,...$){let A=this.#A(this,...$),R=Math.max(A,C(this.decimalMultiplier)),P=b(R),H=$.reduce((T,G)=>{let L=this.getBigIntValue(G,R);switch(F){case"add":return T+L;case"sub":return T-L;case"mul":return T*L/P;case"div":{if(L===0n)throw RangeError("Division by zero");return T*P/L}default:return T}},this.bigIntValue*P/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),P=this.getBigIntValue(this,A);switch(F){case"gt":return P>R;case"gte":return P>=R;case"lt":return P<R;case"lte":return P<=R;case"eqValue":return P===R;default:return!1}}#P(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),[P="",H=""]=F.split(".");return BigInt(`${P}${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],L0=[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:P,identifier:H}){super(typeof F==="object"?F:{decimal:$,value:F});let B=_0(H||`${R}.${P}`);this.type=N0(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),P=F.slice(A+1),H=G0({chain:R,rest:P}).when(({rest:B})=>B.includes(".."),({chain:B,rest:T})=>`${B}.${T.replace(/\.\./g,"~")}`).when(({chain:B,rest:T})=>L0.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 P=F instanceof D?F.getValue("string"):F,H=qF(R),{identifier:B,decimal:T}=s(H),{chain:G,isSynthetic:L,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).
|
|
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:b,identifier:S,tax:m}=D||{decimal:q||Z,identifier:H},U=$?i(BigInt(P),$):i(P,b);return A?XF(S,$?U:P):L||Y?IF(S,U):new d({decimal:b,identifier:S,tax:m,value:U})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),A=await $(F);for(let{tokens:R}of Object.values(A))for(let{identifier:P,chain:N,...H}of R){let T=B0(N),G=r.includes(T.chain)?P:P.toUpperCase(),L="decimals"in H?H.decimals:T.baseDecimal;g.set(G,{decimal:L,identifier:P})}return!0}static setStaticAssets(F){g.clear();for(let[$,A]of F.entries()){let R=r.includes(A.chain)?A.identifier:A.identifier.toUpperCase(),P="decimals"in A?A.decimals:A.decimal;g.set($,{...A,decimal:P,identifier:R})}return!0}}function c$(F){let $=d.from({chain:F});return _0(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 XF(F,$=0){D0(F);let R=F.includes("SOL.")?F:F.toUpperCase(),P=g.get(R),N=P?.decimal||await K0(T0(F));if(!P)g.set(R,{decimal:N,identifier:F});return new d({decimal:N,identifier:F,value:i($,N)})}function IF(F,$=0){let A=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,R=A?G0.includes(A):!1,P=F.slice(0,14).includes("~")?"~":"/",[N,H]=R?F.split(".").slice(1).join().split(P):F.split(P);if(!(N&&H))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new d({decimal:8,identifier:`${A||X.THORChain}.${N}${P}${H}`,value:i($,8)})}function i(F,$){return typeof F==="bigint"?p({bigIntDecimal:$,decimal:$,value:F}):F}function jF(F){let $=_0(F).when((A)=>("chain"in A)&&A.chain!==void 0,({chain:A})=>A).otherwise((A)=>{let R=N0(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 WF(F){if(jF(F),"chain"in F)return F.chain;let{chain:$,symbol:A}=N0(F.asset);return x0({chain:$,symbol:A})==="Native"?$:F.asset}function qF(F,$,A){let R=F.split("."),P=R[0]?.toUpperCase(),N=G0.includes(P),H=A?"~":"/",[T,G=""]=N?R.slice(1).join(".").split(H):F.split(H);if(!(T&&G))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:L,address:Y}=E0({chain:T,symbol:G}),Z=`${T}${H}${G}`;return{address:Y,chain:P,isGasAsset:!1,isSynthetic:$,isTradeAsset:A,symbol:Z,ticker:L}}function UF(F){let $=F.indexOf("."),A=($===-1?F:F.slice(0,$)).toUpperCase(),R=$===-1?F:F.slice($+1),{address:P,ticker:N}=E0({chain:A,symbol:R}),H;try{H=P&&JF.includes(A)&&v0(P)?v0(P):P}catch(G){H=P}let T=H?`${N}-${H}`:R;return{address:H,chain:A,isGasAsset:w0({chain:A,symbol:R}),isSynthetic:!1,isTradeAsset:!1,symbol:T,ticker:N}}function T0(F){let $=F.slice(0,14),A=$.includes("/"),R=$.includes("~");if(A||R)return qF(F,A,R);return UF(F)}function VF(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 E0({symbol:F,chain:$}){let{ticker:A,address:R}=VF(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 KF(F="average"){let $=g0(F),A=10n,R=BigInt(Math.round($*10));return{denominator:A,numerator:R}}function s$(F,$="average"){let{numerator:A,denominator:R}=KF($);return F*A/R}function t$(F,$="average",A=!1){let R=g0($),P=F*R;return A?Math.floor(P):P}class k extends O{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new k({decimal:$,value:p({bigIntDecimal:$,decimal:$,value:F})})}}import{Chain as b0,EVMChains as wF}from"@swapkit/types";function L0(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[A,R,P,,N]=F;return[A,R,P,$.change,N]}if("account"in $){let[A,R,,P,N]=F;return[A,R,$.account,P,N]}return F}function OF([F,$,A,R,P]){let N=typeof P!=="number";if(typeof R!=="number")return`m/${F}'/${$}'/${A}'`;return`m/${F}'/${$}'/${A}'/${R}${N?"":`/${P}`}`}function $A({chain:F,index:$,addressIndex:A=0,type:R}){if(wF.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===b0.Solana){if(R==="account")return[44,501,0,$];return L0(y[F],{index:$})}let P=F===b0.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,P,$,0,A];case"segwit":return[49,P,0,0,$];case"legacy":return[44,P,0,0,$];default:return L0(y[F],{index:$})}}function AA(F){let[$,A,R]=F.split("/").map((P)=>Number.parseInt(P,10));switch(A){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var RA=Object.keys(y).reduce((F,$)=>{return F[$]=OF(y[$]),F},{});import{Chain as M,getChainConfig as f0}from"@swapkit/types";import{match as y0}from"ts-pattern";function HA({chain:F,txHash:$}){let{blockExplorerUrl:A}=f0(F);return y0(F).with(M.Maya,M.Kujira,M.Noble,M.Cosmos,M.THORChain,M.Solana,()=>`${A}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(M.Arbitrum,M.Aurora,M.Avalanche,M.BinanceSmartChain,M.Base,M.Berachain,M.Ethereum,M.Gnosis,M.Optimism,M.Polkadot,M.Polygon,()=>`${A}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(M.Litecoin,M.Bitcoin,M.BitcoinCash,M.Dogecoin,M.Zcash,M.Radix,()=>`${A}/transaction/${$.toLowerCase()}`).with(M.Near,()=>`${A}/txns/${$}`).with(M.Ripple,()=>`${A}/transactions/${$}`).with(M.Tron,()=>`${A}/#/transaction/${$}`).otherwise(()=>"")}function BA({chain:F,address:$}){let{blockExplorerUrl:A}=f0(F);return y0(F).with(M.Solana,M.Radix,()=>`${A}/account/${$}`).with(M.Tron,()=>`${A}/#/address/${$}`).otherwise(()=>`${A}/address/${$}`)}import{Chain as DF,getChainConfig as SF}from"@swapkit/types";function vF({liquidityUnits:F,poolUnits:$,runeDepth:A}){let R=I(F),P=I($),N=I(A),H=R.mul(N),T=P.mul(P).mul(2),G=P.mul(R).mul(2),L=R.mul(R),Y=P.mul(P).mul(P);return H.mul(T.sub(G).add(L)).div(Y)}function EF({liquidityUnits:F,poolUnits:$,assetDepth:A}){let R=I(F),P=I($),N=I(A),H=R.mul(N),T=P.mul(P).mul(2),G=P.mul(R).mul(2),L=R.mul(R),Y=H.mul(T.sub(G).add(L)),Z=P.mul(P).mul(P);return Y.div(Z)}function LA({percent:F,runeDepth:$,liquidityUnits:A,poolUnits:R}){return vF({liquidityUnits:A,poolUnits:R,runeDepth:$}).mul(F)}function QA({percent:F,assetDepth:$,liquidityUnits:A,poolUnits:R}){return EF({assetDepth:$,liquidityUnits:A,poolUnits:R}).mul(F)}function I(F){return k.fromBigInt(BigInt(F),SF(DF.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 MA({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R,percent:P}){return Object.fromEntries(Object.entries(gF({assetDepth:R,liquidityUnits:F,poolUnits:$,runeDepth:A})).map(([N,H])=>[N,H.mul(P)]))}function ZA({runeDepth:F,poolUnits:$,assetDepth:A,liquidityUnits:R,runeAmount:P,assetAmount:N}){let H=new k({decimal:8,value:F}),T=new k({decimal:8,value:A}),G=new k({decimal:8,value:$}),L=new k({decimal:8,value:P}),Y=new k({decimal:8,value:N}),Z=L.mul(T),D=Y.mul(H),q=L.mul(Y),b=H.mul(T),S=G.mul(Z.add(D.add(q.mul(2)))),m=Z.add(D.add(b.mul(2))),U=S.div(m),K=I(R).add(U);if(U.getBaseValue("number")===0)return K.div(G).getBaseValue("number");let z=G.add(K);return K.div(z).getBaseValue("number")}function zA({runeAmount:F,assetAmount:$,runeDepth:A,assetDepth:R}){if(F==="0"||$==="0"||A==="0"||R==="0")return 0;let P=I(A),N=I(R),H=I($),T=I(F),G=H.mul(P).sub(N.mul(T)),L=N.mul(T).add(P.mul(N));return Math.abs(G.div(L).getBaseValue("number"))}import{Chain as a}from"@swapkit/types";import{match as bF}from"ts-pattern";function jA({type:F,address:$}){return`${F}:${$}`}function WA({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function qA(F){return e("POOL+",F)}function UA({chain:F,symbol:$,address:A,...R}){let P=fF({chain:F,symbol:$}),N=A?`:${A}:`:":";return e(`${"+"}:${P}${N}`,R)}function VA({chain:F,symbol:$,ticker:A,basisPoints:R,targetAsset:P}){let N=F==="ETH"&&A!=="ETH"?`${A}-${$.slice(-3)}`:$,H=P?`:${P}`:"";return`${"-"}:${F}.${N}:${R}${H}`}function kA({basisPoints:F,...$}){return e(`${"POOL-"}:${F}`,$)}function KA({name:F,chain:$,address:A,owner:R}){let P=`${"~"}:${F}:${$}:${A}`,N=R?`:${R}`:"";return`${P}${N}`}function wA({name:F,chain:$,asset:A,payout:R,owner:P}){return`${"~"}:${F}:${$}:${R}:${P}:${A}`}function OA(F,{address:$}){return`${F}:${$}`}function DA(F,{unstakeBps:$,...A}){let R=$?`:${$}`:"",P=`${F}${R}`;return e(`${P}`,A)}function e(F,{affiliateAddress:$,affiliateBasisPoints:A}={}){let R=`${F}${$?`:${$}:${A||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function fF({chain:F,symbol:$}){return bF(F).with(a.Bitcoin,a.Dogecoin,a.Litecoin,()=>F.slice(0,1).toLowerCase()).with(a.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}import{getChainConfig as u0}from"@swapkit/types";function fA(){return typeof window.ethereum<"u"}function yA(F){return yF().includes(F)}function yF(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,A=window?.vultisig,R=window?.ethereum?.isBraveWallet,P=window?.ethereum?.isTrust||window?.trustwallet,N=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=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(P)G.push("TRUSTWALLET_WEB");if(N)G.push("COINBASE_WEB");if(mF())G.push("OKX_MOBILE");if(H)G.push("BITGET");if(T)G.push("ONEKEY");return G}async function uF(F,$,A){let R=u0($);try{await p0({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:F})}catch(P){if(!A)throw new J("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await dF(F,A)}}function uA({chains:F,supportedChains:$,walletType:A}){let R=F.filter((N)=>!N||$.includes(N));if(R.length===0)throw new J("wallet_chain_not_supported",{chain:F.join(", "),wallet:A});let P=F.filter((N)=>!$.includes(N));return u({condition:P.length>0,id:`wallet_chain_not_supported_${A}`,warning:`${A} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`}),R}function pF(F,$,A){return async(...R)=>{let{chainIdHex:P}=u0(A);if((await $.getNetwork()).chainId.toString()===P)return F(...R);try{await uF($,A)}catch(N){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:N}})}return F(...R)}}function pA({toolbox:F,chain:$,provider:A=window.ethereum,methodNames:R=[]}){let N=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((H,T)=>{if(!F[T])return H;let G=F[T];if(typeof G!=="function")return H;let L=pF(G,A,$);return{...H,[T]:L}},{});return{...F,...N}}function dF(F,$){return p0({method:"wallet_addEthereumChain",params:[$],provider:F})}function dA(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function mA(){let{isTrust:F,isBraveWallet:$,__XDEFI:A,overrideIsMetaMask:R,selectedProvider:P}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(R&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(A)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function CA(){let F=[];function $(R){if(F.map((P)=>P.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 mF(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),A=/android|XiaoMi|MiuiBrowser/i.test(F),R=$||A,P=/OKApp/i.test(F);return R&&P}function p0({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{M$ as wrapWithThrow,pF as wrapMethodWithNetworkSwitch,u as warnOnce,E$ as validateTNS,D0 as validateIdentifier,L0 as updateDerivationPath,uF as switchEVMWalletNetwork,p0 as providerRequest,pA as prepareNetworkSwitch,mF as okxMobileEnabled,yF as listWeb3EVMWallets,fA as isWeb3Detected,w0 as isGasAsset,yA as isDetected,W$ as initializeRPCUrlsWithFallback,AA as getWalletFormatFor,L$ as getTHORNameCost,MA as getSymmetricWithdraw,gF as getSymmetricPoolShare,P0 as getRPCUrl,c$ as getMinAmountByChain,VA as getMemoForWithdraw,WA as getMemoForUnbond,DA as getMemoForTcyStake,OA as getMemoForTcyClaim,kA as getMemoForRunePoolWithdraw,qA as getMemoForRunePoolDeposit,KA as getMemoForNameRegister,wA as getMemoForNamePreferredAssetRegister,jA as getMemoForLeaveAndBond,UA as getMemoForDeposit,Q$ as getMAYANameCost,zA as getLiquiditySlippage,KF as getFeeMultiplierAsBigInt,g0 as getFeeMultiplier,HA as getExplorerTxUrl,BA as getExplorerAddressUrl,ZA as getEstimatedPoolShare,mA as getETHDefaultWallet,CA as getEIP6963Wallets,$A as getDerivationPathFor,K0 as getDecimal,s as getCommonAssetInfo,Z$ as getChainIdentifier,LA as getAsymmetricRuneWithdrawAmount,vF as getAsymmetricRuneShare,QA as getAsymmetricAssetWithdrawAmount,EF as getAsymmetricAssetShare,x0 as getAssetType,p as formatBigIntToSafeValue,O$ as findAssetBy,uA as filterSupportedChains,OF as derivationPathToString,N0 as assetFromString,s$ as applyFeeMultiplierToBigInt,t$ as applyFeeMultiplier,dF as addEVMWalletNetwork,dA as addAccountsChangedCallback,h0 as WarningCodeEnum,c as WalletOption,k as SwapKitNumber,J as SwapKitError,W as SKConfig,l as RequestClient,Z0 as RPC_URLS,l0 as ProviderName,y as NetworkDerivationPath,$0 as NODE_URLS,X0 as MemoType,t0 as LedgerErrorCode,n0 as FeeTypeEnum,J0 as FeeOption,z0 as FALLBACK_URLS,c0 as ErrorCode,Y0 as EXPLORER_URLS,RA as DerivationPath,kF as DEFAULT_FEE_MULTIPLIERS,o0 as ContractAddress,w$ as CommonAssetStrings,O as BigIntArithmetics,d as AssetValue,s0 as ApproveMode};
|
|
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},U=$?i(BigInt(P),$):i(P,f);return A?IF(v,$?U:P):L||Y?jF(v,U):new d({decimal:f,identifier:v,tax:m,value:U})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),A=await $(F);for(let{tokens:R}of Object.values(A))for(let{identifier:P,chain:H,...B}of R){let T=T0(H),G=r.includes(T.chain)?P:P.toUpperCase(),L="decimals"in B?B.decimals:T.baseDecimal;g.set(G,{decimal:L,identifier:P})}return!0}static setStaticAssets(F){g.clear();for(let[$,A]of F.entries()){let R=r.includes(A.chain)?A.identifier:A.identifier.toUpperCase(),P="decimals"in A?A.decimals:A.decimal;g.set($,{...A,decimal:P,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(),P=g.get(R),H=P?.decimal||await w0(_0(F));if(!P)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?L0.includes(A):!1,P=F.slice(0,14).includes("~")?"~":"/",[H,B]=R?F.split(".").slice(1).join().split(P):F.split(P);if(!(H&&B))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new d({decimal:8,identifier:`${A||X.THORChain}.${H}${P}${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 N0({chain:$,symbol:A})==="Native"?$:F.asset}function UF(F,$,A){let R=F.split("."),P=R[0]?.toUpperCase(),H=L0.includes(P),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:L,address:Y}=b0({chain:T,symbol:G}),Z=`${T}${B}${G}`;return{address:Y,chain:P,isGasAsset:!1,isSynthetic:$,isTradeAsset:A,symbol:Z,ticker:L}}function VF(F){let $=F.indexOf("."),A=($===-1?F:F.slice(0,$)).toUpperCase(),R=$===-1?F:F.slice($+1),{address:P,ticker:H}=b0({chain:A,symbol:R}),B;try{B=P&&XF.includes(A)&&E0(P)?E0(P):P}catch(G){B=P}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 UF(F,A,R);return VF(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($),P=F*R;return A?Math.floor(P):P}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 Q0(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[A,R,P,,H]=F;return[A,R,P,$.change,H]}if("account"in $){let[A,R,,P,H]=F;return[A,R,$.account,P,H]}return F}function DF([F,$,A,R,P]){let H=typeof P!=="number";if(typeof R!=="number")return`m/${F}'/${$}'/${A}'`;return`m/${F}'/${$}'/${A}'/${R}${H?"":`/${P}`}`}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 Q0(y[F],{index:$})}if(F===f0.Solana){if(R==="account")return[44,501,0,$];return Q0(y[F],{index:$})}let P=F===f0.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,P,$,0,A];case"segwit":return[49,P,0,0,$];case"legacy":return[44,P,0,0,$];default:return Q0(y[F],{index:$})}}function RA(F){let[$,A,R]=F.split("/").map((P)=>Number.parseInt(P,10));switch(A){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var PA=Object.keys(y).reduce((F,$)=>{return F[$]=DF(y[$]),F},{});import{Chain as M,getChainConfig as y0}from"@swapkit/types";import{match as u0}from"ts-pattern";function BA({chain:F,txHash:$}){let{blockExplorerUrl:A}=y0(F);return u0(F).with(M.Maya,M.Kujira,M.Noble,M.Cosmos,M.THORChain,M.Solana,()=>`${A}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(M.Arbitrum,M.Aurora,M.Avalanche,M.BinanceSmartChain,M.Base,M.Berachain,M.Ethereum,M.Gnosis,M.Optimism,M.Polkadot,M.Polygon,()=>`${A}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(M.Litecoin,M.Bitcoin,M.BitcoinCash,M.Dogecoin,M.Zcash,M.Radix,()=>`${A}/transaction/${$.toLowerCase()}`).with(M.Near,()=>`${A}/txns/${$}`).with(M.Ripple,()=>`${A}/transactions/${$}`).with(M.Tron,()=>`${A}/#/transaction/${$}`).otherwise(()=>"")}function TA({chain:F,address:$}){let{blockExplorerUrl:A}=y0(F);return u0(F).with(M.Solana,M.Radix,()=>`${A}/account/${$}`).with(M.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),P=I($),H=I(A),B=R.mul(H),T=P.mul(P).mul(2),G=P.mul(R).mul(2),L=R.mul(R),Y=P.mul(P).mul(P);return B.mul(T.sub(G).add(L)).div(Y)}function bF({liquidityUnits:F,poolUnits:$,assetDepth:A}){let R=I(F),P=I($),H=I(A),B=R.mul(H),T=P.mul(P).mul(2),G=P.mul(R).mul(2),L=R.mul(R),Y=B.mul(T.sub(G).add(L)),Z=P.mul(P).mul(P);return Y.div(Z)}function QA({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:P}){return Object.fromEntries(Object.entries(gF({assetDepth:R,liquidityUnits:F,poolUnits:$,runeDepth:A})).map(([H,B])=>[H,B.mul(P)]))}function zA({runeDepth:F,poolUnits:$,assetDepth:A,liquidityUnits:R,runeAmount:P,assetAmount:H}){let B=new k({decimal:8,value:F}),T=new k({decimal:8,value:A}),G=new k({decimal:8,value:$}),L=new k({decimal:8,value:P}),Y=new k({decimal:8,value:H}),Z=L.mul(T),S=Y.mul(B),q=L.mul(Y),f=B.mul(T),v=G.mul(Z.add(S.add(q.mul(2)))),m=Z.add(S.add(f.mul(2))),U=v.div(m),K=I(R).add(U);if(U.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 P=I(A),H=I(R),B=I($),T=I(F),G=B.mul(P).sub(H.mul(T)),L=H.mul(T).add(P.mul(H));return Math.abs(G.div(L).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 UA(F){return e("POOL+",F)}function VA({chain:F,symbol:$,address:A,...R}){let P=yF({chain:F,symbol:$}),H=A?`:${A}:`:":";return e(`${"+"}:${P}${H}`,R)}function kA({chain:F,symbol:$,ticker:A,basisPoints:R,targetAsset:P}){let H=F==="ETH"&&A!=="ETH"?`${A}-${$.slice(-3)}`:$,B=P?`:${P}`:"";return`${"-"}:${F}.${H}:${R}${B}`}function KA({basisPoints:F,...$}){return e(`${"POOL-"}:${F}`,$)}function wA({name:F,chain:$,address:A,owner:R}){let P=`${"~"}:${F}:${$}:${A}`,H=R?`:${R}`:"";return`${P}${H}`}function OA({name:F,chain:$,asset:A,payout:R,owner:P}){return`${"~"}:${F}:${$}:${R}:${P}:${A}`}function DA(F,{address:$}){return`${F}:${$}`}function SA(F,{unstakeBps:$,...A}){let R=$?`:${$}`:"",P=`${F}${R}`;return e(`${P}`,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,P=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(P)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(P){if(!A)throw new J("helpers_failed_to_switch_network",{error:P,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 P=F.filter((H)=>!$.includes(H));return u({condition:P.length>0,id:`wallet_chain_not_supported_${A}`,warning:`${A} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`}),R}function dF(F,$,A){return async(...R)=>{let{chainIdHex:P}=p0(A);if((await $.getNetwork()).chainId.toString()===P)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 L=dF(G,A,$);return{...B,[T]:L}},{});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:P}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(R&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(A)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function oA(){let F=[];function $(R){if(F.map((P)=>P.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,P=/OKApp/i.test(F);return R&&P}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,Q0 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,Q$ as getTHORNameCost,ZA as getSymmetricWithdraw,gF as getSymmetricPoolShare,x0 as getRPCUrl,h$ as getMinAmountByChain,kA as getMemoForWithdraw,qA as getMemoForUnbond,SA as getMemoForTcyStake,DA as getMemoForTcyClaim,KA as getMemoForRunePoolWithdraw,UA as getMemoForRunePoolDeposit,wA as getMemoForNameRegister,OA as getMemoForNamePreferredAssetRegister,WA as getMemoForLeaveAndBond,VA 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,QA as getAsymmetricRuneWithdrawAmount,EF as getAsymmetricRuneShare,MA as getAsymmetricAssetWithdrawAmount,bF as getAsymmetricAssetShare,N0 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,PA as DerivationPath,KF as DEFAULT_FEE_MULTIPLIERS,c0 as ContractAddress,O$ as CommonAssetStrings,D as BigIntArithmetics,d as AssetValue,t0 as ApproveMode};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=B0472B75EEA3F67164756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|