Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swapkit/helpers

Package Overview
Dependencies
Maintainers
0
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swapkit/helpers - npm Package Compare versions

Comparing version 1.14.2 to 1.15.0

6

dist/index.js

@@ -1,6 +0,6 @@

var Ln=Object.create;var{getPrototypeOf:tn,defineProperty:hn,getOwnPropertyNames:jn}=Object;var sn=Object.prototype.hasOwnProperty;var Hn=(n,h,H)=>{H=n!=null?Ln(tn(n)):{};let x=h||!n||!n.__esModule?hn(H,"default",{value:n,enumerable:!0}):H;for(let R of jn(n))if(!sn.call(x,R))hn(x,R,{get:()=>n[R],enumerable:!0});return x};var xn=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,H)=>(typeof require!=="undefined"?require:h)[H]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var M;((G)=>{G.Arbitrum="https://arb1.arbitrum.io/rpc";G.Avalanche="https://avalanche-c-chain-rpc.publicnode.com";G.Base="https://base.llamarpc.com";G.BinanceSmartChain="https://bsc-dataseed.binance.org";G.Bitcoin="https://bitcoin-rpc.publicnode.com";G.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";G.Chainflip="wss://mainnet-archive.chainflip.io";G.Cosmos="https://node-router.thorswap.net/cosmos/rpc";G.Dash="https://dash-rpc.publicnode.com";G.Dogecoin="https://node-router.thorswap.net/dogecoin";G.Ethereum="https://ethereum-rpc.publicnode.com";G.Kujira="https://rpc-kujira.synergynodes.com/";G.Litecoin="https://node-router.thorswap.net/litecoin";G.Maya="https://tendermint.mayachain.info";G.MayaStagenet="https://stagenet.tendermint.mayachain.info";G.Optimism="https://mainnet.optimism.io";G.Polkadot="wss://rpc.polkadot.io";G.Polygon="https://polygon-rpc.com";G.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";G.THORChain="https://rpc.thorswap.net";G.THORChainStagenet="https://stagenet-rpc.ninerealms.com";G.Solana="https://solana-rpc.publicnode.com"})(M||={});var m;((C)=>{C.Arbitrum="https://arbiscan.io";C.Avalanche="https://snowtrace.io";C.Base="https://basescan.org";C.BinanceSmartChain="https://bscscan.com";C.Bitcoin="https://blockchair.com/bitcoin";C.BitcoinCash="https://www.blockchair.com/bitcoin-cash";C.Chainflip="https://explorer.polkascan.io/polkadot";C.Cosmos="https://www.mintscan.io/cosmos";C.Dash="https://blockchair.com/dash";C.Dogecoin="https://blockchair.com/dogecoin";C.Ethereum="https://etherscan.io";C.Kujira="https://finder.kujira.network/kaiyo-1";C.Litecoin="https://blockchair.com/litecoin";C.Maya="https://www.mayascan.org";C.Optimism="https://optimistic.etherscan.io";C.Polkadot="https://polkadot.subscan.io";C.Polygon="https://polygonscan.com";C.Radix="https://dashboard.radixdlt.com";C.THORChain="https://runescan.io";C.Solana="https://solscan.io"})(m||={});var X;((C)=>{C.Arbitrum="ARB";C.Avalanche="AVAX";C.Base="BASE";C.BinanceSmartChain="BSC";C.Bitcoin="BTC";C.BitcoinCash="BCH";C.Cosmos="GAIA";C.Dash="DASH";C.Dogecoin="DOGE";C.Ethereum="ETH";C.Kujira="KUJI";C.Litecoin="LTC";C.Maya="MAYA";C.Optimism="OP";C.Polkadot="DOT";C.Chainflip="FLIP";C.Polygon="MATIC";C.Radix="XRD";C.THORChain="THOR";C.Solana="SOL"})(X||={});var w;((A)=>{A.Arbitrum="42161";A.ArbitrumHex="0xa4b1";A.Avalanche="43114";A.AvalancheHex="0xa86a";A.Base="8453";A.BaseHex="0x2105";A.BinanceSmartChain="56";A.BinanceSmartChainHex="0x38";A.Bitcoin="bitcoin";A.BitcoinCash="bitcoincash";A.Chainflip="chainflip";A.Cosmos="cosmoshub-4";A.Dash="dash";A.Dogecoin="dogecoin";A.Kujira="kaiyo-1";A.Ethereum="1";A.EthereumHex="0x1";A.Litecoin="litecoin";A.Maya="mayachain-mainnet-v1";A.MayaStagenet="mayachain-stagenet-v1";A.Optimism="10";A.OptimismHex="0xa";A.Polkadot="polkadot";A.Polygon="137";A.PolygonHex="0x89";A.Radix="radix-mainnet";A.THORChain="thorchain-1";A.THORChainStagenet="thorchain-stagenet-v2";A.Solana="solana"})(w||={});var Oh={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},Xn=Object.keys(X),y=Object.values(X),k={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,OP:18,SOL:9,THOR:8,XRD:18},$h=["DOT","FLIP"],K=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],_h=["BTC","BCH","DASH","DOGE","LTC"],Gh=["GAIA","THOR","MAYA","KUJI"],Lh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],th=["ARB","DASH","ETH","KUJI","MAYA","THOR"],f=y.reduce((n,h)=>{let H=Xn.find((x)=>X[x]===h);if(H)n[h]=H;return n},{}),Rn=y.reduce((n,h)=>{return n[h]=w[f[h]],n},{}),d=y.reduce((n,h)=>{return n[h]=M[f[h]],n},{}),jh=y.reduce((n,h)=>{let H=`${f[h]}Hex`;return n[h]=w[H],n},{}),sh=y.reduce((n,h)=>{return n[h]=m[f[h]],n},{});var Jn;((_)=>{_.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";_.TC_SUPPORTED_TO_ETH="TC-ERC20";_.TC_SUPPORTED_TO_AVAX="TC-ARC20";_.TC_SUPPORTED_TO_BSC="TC-BEP20";_.ETH_TO_TC_SUPPORTED="ERC20-TC";_.ETH_TO_ETH="ERC20-ERC20";_.ETH_TO_AVAX="ERC20-ARC20";_.ETH_TO_BSC="ERC20-BEP20";_.AVAX_TO_TC_SUPPORTED="ARC20-TC";_.AVAX_TO_ETH="ARC20-ERC20";_.AVAX_TO_AVAX="ARC20-ARC20";_.AVAX_TO_BSC="ARC20-BEP20";_.BSC_TO_TC_SUPPORTED="BEP20-TC";_.BSC_TO_ETH="BEP20-ERC20";_.BSC_TO_AVAX="BEP20-ARC20";_.BSC_TO_BSC="BEP20-BEP20"})(Jn||={});var Jh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Ih=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Sh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var In;((c)=>{c.ARB="0x0000000000000000000000000000000000000000";c.AVAX="0x0000000000000000000000000000000000000000";c.BASE="0x0000000000000000000000000000000000000000";c.ETH="0x0000000000000000000000000000000000000000";c.BSC="0x0000000000000000000000000000000000000000";c.MATIC="0x0000000000000000000000000000000000001010";c.OP="0x4200000000000000000000000000000000000042"})(In||={});var Sn;((C)=>{C.ARB="m/44'/60'/0'/0";C.AVAX="m/44'/60'/0'/0";C.BASE="m/44'/60'/0'/0";C.BCH="m/44'/145'/0'/0";C.BSC="m/44'/60'/0'/0";C.BTC="m/84'/0'/0'/0";C.DASH="m/44'/5'/0'/0";C.DOGE="m/44'/3'/0'/0";C.DOT="////";C.ETH="m/44'/60'/0'/0";C.FLIP="////";C.GAIA="m/44'/118'/0'/0";C.KUJI="m/44'/118'/0'/0";C.LTC="m/84'/2'/0'/0";C.MATIC="m/44'/60'/0'/0";C.MAYA="m/44'/931'/0'/0";C.OP="m/44'/60'/0'/0";C.SOL="m/44'/501'/0'/0";C.THOR="m/44'/931'/0'/0";C.XRD="////"})(Sn||={});var b={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,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],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],XRD:[0,0,0,0,0],DOT:[0,0,0,0,0],FLIP:[0,0,0,0,0]};var Fn;(($)=>{$.BRAVE="BRAVE";$.COINBASE_MOBILE="COINBASE_MOBILE";$.COINBASE_WEB="COINBASE_WEB";$.EIP6963="EIP6963";$.EXODUS="EXODUS";$.KEEPKEY="KEEPKEY";$.KEEPKEY_BEX="KEEPKEY_BEX";$.KEPLR="KEPLR";$.KEYSTORE="KEYSTORE";$.LEAP="LEAP";$.LEDGER="LEDGER";$.LEDGER_LIVE="LEDGER_LIVE";$.METAMASK="METAMASK";$.OKX="OKX";$.OKX_MOBILE="OKX_MOBILE";$.PHANTOM="PHANTOM";$.POLKADOT_JS="POLKADOT_JS";$.RADIX_WALLET="RADIX_WALLET";$.TREZOR="TREZOR";$.TALISMAN="TALISMAN";$.TRUSTWALLET_WEB="TRUSTWALLET_WEB";$.WALLETCONNECT="WALLETCONNECT";$.XDEFI="XDEFI"})(Fn||={});var gn;((x)=>{x[x.NoError=36864]="NoError";x[x.LockedDevice=21781]="LockedDevice";x[x.TC_NotFound=65535]="TC_NotFound"})(gn||={});var zn;((x)=>{x.Average="average";x.Fast="fast";x.Fastest="fastest"})(zn||={});var Zn;((H)=>{H.Approve="approve";H.CheckOnly="checkOnly"})(Zn||={});var Bn;((T)=>{T.NAME_REGISTER="~";T.BOND="BOND";T.DEPOSIT="+";T.LEAVE="LEAVE";T.UNBOND="UNBOND";T.WITHDRAW="-";T.OPEN_LOAN="$+";T.CLOSE_LOAN="$-";T.RUNEPOOL_DEPOSIT="POOL+";T.RUNEPOOL_WITHDRAW="POOL-"})(Bn||={});var Yn;((F)=>{F.unknownError="unknownError";F.test_error="test_error";F.providerDetailsError="providerDetailsError";F.blockHeaderNotFound="blockHeaderNotFound";F.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";F.blockHashNotFoundAtHash="blockHashNotFoundAtHash";F.txHashMissing="txHashMissing";F.assetValueMissingInfo="assetValueMissingInfo";F.invalidAsset="invalidAsset";F.blockIsRequired="blockIsRequired";F.currentBlockHeaderNotFound="currentBlockHeaderNotFound";F.failedToRetrieveBalance="failedToRetrieveBalance";F.failedToRetrieveBlock="failedToRetrieveBlock";F.failedToRetrieveFees="failedToRetrieveFees";F.notImplementedBCH="notImplementedBCH";F.notImplementedDoge="notImplementedDoge";F.noPoolsFound="noPoolsFound";F.noVaultsFound="noVaultsFound";F.noTxFound="noTxFound";F.noInputCoinFound="noInputCoinFound";F.noBlockDataFound="noBlockDataFound";F.multipleCosmosMessages="multipleCosmosMessages";F.heightOrHashNotProvided="heightOrHashNotProvided";F.unknownDenom="unknownDenom";F.invalidBlockHeight="invalidBlockHeight";F.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";F.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";F.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";F.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";F.txMemoUndefined="txMemoUndefined";F.txMemoIncorrect="txMemoIncorrect";F.txTypeNotFound="txTypeNotFound";F.txNoMessage="txNoMessage";F.txNotFound="txNotFound";F.txReceiptNotFound="txReceiptNotFound";F.txParsingError="txParsingError";F.blockNotFound="blockNotFound";F.balanceNotFound="balanceNotFound";F.configError="configError";F.noQuoteResponse="noQuoteResponse";F.noPoolAssetsFound="noPoolAssetsFound";F.noThorchainPools="noThorchainPools";F.noMayachainPools="noMayachainPools";F.invalidAffiliateFee="invalidAffiliateFee";F.invalidBuyAssetAddress="invalidBuyAssetAddress";F.invalidSellAssetAddress="invalidSellAssetAddress";F.invalidSourceAddress="invalidSourceAddress";F.invalidDestinationAddress="invalidDestinationAddress";F.sourceAddressIsSmartContract="sourceAddressIsSmartContract";F.destinationAddressIsSmartContract="destinationAddressIsSmartContract";F.invalidChainId="invalidChainId";F.unsupportedChainId="unsupportedChainId";F.unsupportedEVMChainId="unsupportedEVMChainId";F.noWhitelistTokens="noWhitelistTokens";F.failedFetchGasPrice="failedFetchGasPrice";F.failedToCreateDepositChannel="failedToCreateDepositChannel";F.noProviderDetailsFound="noProviderDetailsFound";F.noTokenListsFound="noTokenListsFound";F.tokenNotFound="tokenNotFound";F.tokenPriceNotFound="tokenPriceNotFound";F.swapAmountTooSmall="swapAmountTooSmall";F.legsArrayIsEmpty="legsArrayIsEmpty";F.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";F.noBlockHeaderFound="noBlockHeaderFound";F.failedToSimulateSwap="failedToSimulateSwap";F.addressScreeningFailed="addressScreeningFailed";F.noLiquidtyProvidersFound="noLiquidtyProvidersFound";F.noSaversFound="noSaversFound";F.noInboundAddressesFound="noInboundAddressesFound";F.noInboundAddressFoundForChain="noInboundAddressFoundForChain";F.noLastBlocksFound="noLastBlocksFound";F.noVersionFound="noVersionFound";F.noConstantsFound="noConstantsFound";F.noMimirsFound="noMimirsFound";F.noRoutesFound="noRoutesFound";F.quoteNotFound="quoteNotFound";F.ledgerSignFailed="ledgerSignFailed";F.ledgerFetchSwapFailed="ledgerFetchSwapFailed";F.failedToFetchTx="failedToFetchTx";F.failedBuildTransactionDetails="failedBuildTransactionDetails";F.noLegsForRoute="noLegsForRoute";F.noRouterAddressFound="noRouterAddressFound";F.noAggregatorAddressFound="noAggregatorAddressFound";F.noContractInstanceFound="noContractInstanceFound";F.noContractAddressFound="noContractAddressFound";F.invalidAffiliate="invalidAffiliate";F.providerNotfound="No provider found";F.noRecordFound="No Record found";F.slippageTooLow="Slippage too low";F.tradingHalted="tradingHalted";F.noWrappedGasAsset="noWrappedGasAsset";F.aggregatorAddressNotFound="aggregatorAddressNotFound";F.routerAddressNotFound="routerAddressNotFound";F.dummyAddressNotFound="dummyAddressNotFound";F.trackerError="trackerError";F.noOhlcvDataFound="noOhlcvDataFound";F.noTradingPairs="noTradingPairs";F.noLoanPositionFound="noLoanPositionFound";F.noLendingAvailability="noLendingAvailability";F.lendingRepayTooSmall="lendingRepayTooSmall";F.missingState="missingState";F.ledgerSwapNotFound="ledgerSwapNotFound";F.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";F.errorEstimatingGas="errorEstimatingGas";F.apiKeyInvalid="apiKeyInvalid";F.apiKeyFailedToUpdate="apiKeyFailedToUpdate";F.apiKeyExpired="apiKeyExpired";F.unauthorized="unauthorized";F.failedToCreateMemo="failedToCreateMemo";F.radixIncorrectInstructions="radixIncorrectInstructions";F.invalidAddressForChain="invalidAddressForChain"})(Yn||={});var Pn;((H)=>{H.highSlippage="highSlippage";H.highPriceImpact="highPriceImpact"})(Pn||={});var qn;((L)=>{L.CHAINFLIP="CHAINFLIP";L.MAYACHAIN="MAYACHAIN";L.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";L.ONEINCH="ONEINCH";L.PANCAKESWAP="PANCAKESWAP";L.PANGOLIN_V1="PANGOLIN_V1";L.SUSHISWAP_V2="SUSHISWAP_V2";L.THORCHAIN="THORCHAIN";L.THORCHAIN_STREAMING="THORCHAIN_STREAMING";L.TRADERJOE_V2="TRADERJOE_V2";L.UNISWAP_V2="UNISWAP_V2";L.UNISWAP_V3="UNISWAP_V3";L.CAVIAR_V1="CAVIAR_V1"})(qn||={});var Qn;((N)=>{N.LIQUIDITY="liquidity";N.NETWORK="network";N.INBOUND="inbound";N.OUTBOUND="outbound";N.AFFILIATE="affiliate";N.TAX="tax"})(Qn||={});var a={},wn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"};function fh({apiKey:n,...h}){a={...h,apiKey:n}}async function U(n,h){let{apiKey:H,...x}=a,{searchParams:R,json:B,body:N}=h,c={...wn,...x.headers,...h.headers,...B?{"Content-Type":"application/json"}:{}},O=B?JSON.stringify(B):N,o=new URL(n);if(R)o.search=new URLSearchParams(R).toString();if(H)c["x-api-key"]=H;try{let s=await(await fetch(o.toString(),{...x,...h,body:O,headers:c})).json();if(h.responseHandler)return h.responseHandler(s);return s}catch(T){if(h.onError)return h.onError(T);console.error(T)}}var q={get:async(n,h)=>U(n,{...h,method:"GET"}),post:async(n,h)=>U(n,{...h,method:"POST"}),extend:(n)=>{let h={...a,...n};return{get:async(H,x)=>U(H,{...h,...x,method:"GET"}),post:async(H,x)=>U(H,{...h,...x,method:"POST"}),extend:(H)=>q.extend({...h,...H})}}};var yn={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_xdefi_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_phantom_not_found:20201,wallet_xdefi_not_found:20301,wallet_xdefi_send_transaction_no_address:20302,wallet_xdefi_contract_address_not_provided:20303,wallet_xdefi_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class j extends Error{static ErrorCode=yn;constructor(n,h){let H=typeof n==="string",x=H?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(x,{cause:{code:j.ErrorCode[x],message:`${x}${H?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,j.prototype)}}function mh(n){if(n<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function dh(n){if(n<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function ah(n,h){try{return n()}catch(H){if(h)throw new j(h,H);return console.error(H)}}function ih(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Wn=["production","test"].includes("development"),Nn=new Set;function Cn(n,h){if(!Wn&&n){if(Nn.has(h))return;Nn.add(h),console.warn(h)}}async function lh(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{return(await q.get(`${n!=="thorchain-1"?"https://stagenet-rpc.ninerealms.com":"https://rpc.thorswap.net"}/status`)).result.node_info.network}catch(h){return n}}var cn=[...Object.values(X),"TERRA"];function on(n=""){let h=n.toUpperCase(),[H]=h.split(".");if(cn.includes(H))return!0;let[x]=h.split("/");if(cn.includes(x))return!0;throw new j({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function hH(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var p=8,P=(n)=>10n**BigInt(n),W=(n)=>Math.log10(Number.parseFloat(n.toString()));function Q({value:n,bigIntDecimal:h=p,decimal:H=p}){if(H===0)return n.toString();let x=n<0n,R=n.toString().substring(x?1:0),B=H-(R.length-1);if(B>0)R="0".repeat(B)+R;let N=R.length-H,c=R.slice(-H);if(Number.parseInt(c[h]||"0")>=5)c=`${c.substring(0,h-1)}${(Number.parseInt(c[h-1]||"0")+1).toString()}`;else c=c.substring(0,h);return`${x?"-":""}${R.slice(0,N)}.${c}`.replace(/\.?0*$/,"")}class z{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new z({decimal:h,value:Q({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:H}){return z.fromBigInt(n.getBaseValue("bigint")*P(H)/P(h),H)}constructor(n){let h=i(n),H=typeof n==="object";this.decimal=H?n.decimal:void 0,this.decimalMultiplier=H&&"decimalMultiplier"in n?n.decimalMultiplier:P(Math.max(An(D(h)),this.decimal||0)),this.#R(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let H=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||W(this.decimalMultiplier));switch(n){case"number":return Number(H);case"string":return H;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n,h){let H=this.decimalMultiplier/P(h||this.decimal||k.THOR),x=this.bigIntValue/H;switch(n){case"number":return Number(x);case"string":return x.toString();case"bigint":return x}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let H=i(n),x=D(H);if(x==="0"||x==="undefined")return 0n;return this.#x(x,h)}toSignificant(n=6){let[h,H]=this.getValue("string").split("."),x=h||"",R=H||"";if((Number.parseInt(x)?x.length+R.length:R.length)<=n)return this.getValue("string");if(x.length>=n)return x.slice(0,n).padEnd(x.length,"0");if(Number.parseInt(x))return`${x}.${R.slice(0,n-x.length)}`.padEnd(n-x.length,"0");let N=Number.parseInt(R),c=`${N}`.slice(0,n);return`0.${c.padStart(R.length-`${N}`.length+c.length,"0")}`}toFixed(n=6){let[h,H]=this.getValue("string").split("."),x=h||"",R=H||"";if(Number.parseInt(x))return`${x}.${R.slice(0,n)}`.padEnd(n,"0");let B=Number.parseInt(R),N=`${B}`.slice(0,n);return`0.${N.padStart(R.length-`${B}`.length+N.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),H=["","K","M","B","T","Q","Qi","S"],x=Math.floor(Math.log10(Math.abs(h))/3),R=H[x];if(!R)return this.getValue("string");let B=10**(x*3);return`${(h/B).toFixed(n)}${R}`}toCurrency(n="$",{currencyPosition:h="start",decimal:H=2,decimalSeparator:x=".",thousandSeparator:R=","}={}){let B=this.getValue("number"),[N="",c=""]=B.toFixed(6).split("."),O=N.replace(/\B(?=(\d{3})+(?!\d))/g,R),o=N||c?N==="0"?`${Number.parseFloat(`0.${c}`)}`.replace(".",x):`${O}${Number.parseInt(c)?`${x}${c.slice(0,H)}`:""}`:"0.00";return`${h==="start"?n:""}${o}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let H=h||this.decimal||p,x=Math.max(H,W(this.decimalMultiplier)),R=n<0n,B=n.toString().substring(R?1:0),N=x-(B.length-1),c=N>0?"0".repeat(N)+B:B,O=c.length-x,o=c.slice(-x);if(Number.parseInt(o[H]||"0")>=5)o=`${o.substring(0,H-1)}${(Number.parseInt(o[H-1]||"0")+1).toString()}`;else o=o.substring(0,H);return`${R?"-":""}${c.slice(0,O)}.${o}`.replace(/\.?0*$/,"")}#h(n,...h){let H=this.#H(this,...h),x=Math.max(H,W(this.decimalMultiplier)),R=P(x),B=h.reduce((c,O)=>{let o=this.getBigIntValue(O,x);switch(n){case"add":return c+o;case"sub":return c-o;case"mul":return c*o/R;case"div":{if(o===0n)throw new RangeError("Division by zero");return c*R/o}default:return c}},this.bigIntValue*R/this.decimalMultiplier),N=Q({bigIntDecimal:x,decimal:x,value:B});return new this.constructor({decimalMultiplier:P(x),decimal:this.decimal,value:N,identifier:this.toString()})}#n(n,...h){let H=this.#H(this,...h),x=this.getBigIntValue(h[0]||"0",H),R=this.getBigIntValue(this,H);switch(n){case"gt":return R>x;case"gte":return R>=x;case"lt":return R<x;case"lte":return R<=x;case"eqValue":return R===x}}#R(n){let h=D(n)||"0";this.bigIntValue=this.#x(h)}#H(...n){let h=n.map((H)=>{return typeof H==="object"?H.decimal||W(H.decimalMultiplier):An(D(H))}).filter(Boolean);return Math.max(...h,p)}#x(n,h){let H=h?P(h):this.decimalMultiplier,x=W(H),[R="",B=""]=n.split(".");return BigInt(`${R}${B.padEnd(x,"0")}`)}}var pn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function D(n){let H=`${typeof n==="number"?pn.format(n):i(n)}`.replaceAll(",",".").split(".");return H.length>1?`${H.slice(0,-1).join("")}.${H.at(-1)}`:H[0]||"0"}function An(n){let h=n.split(".")[1]?.length||0;return Math.max(h,p)}function i(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var E=new Map;class t extends z{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:H,chain:x,symbol:R,identifier:B}){super(typeof n==="object"?n:{decimal:h,value:n});let N=l(B||`${x}.${R}`);this.type=$n(N),this.tax=H,this.chain=N.chain,this.ticker=N.ticker,this.symbol=N.symbol,this.address=N.address,this.isSynthetic=N.isSynthetic,this.isTradeAsset=N.isTradeAsset,this.isGasAsset=N.isGasAsset,this.chainId=Rn[N.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[H,x,R]=n.split(".");if(!(H&&x))throw new j({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let B=H==="THOR"&&R?`${H}.${x}/${R}`:n;return t.from({asset:B,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:H,...x}){let R=n instanceof z?n.getValue("string"):n,B="chain"in x,N=B?x.chain:x.asset,c=B||Tn.includes(N),{identifier:O,decimal:o}=c?On(N):{identifier:N,decimal:void 0},{chain:T,isSynthetic:s,isTradeAsset:I}=l(O),L=E.get(T==="SOL"?O:O.toUpperCase()),Z=L?.decimal||o;Cn(!(H||Z),`Couldn't find static decimal for ${O} (Using default ${k[T]} decimal as fallback).
var _n=Object.create;var{getPrototypeOf:Sn,defineProperty:hn,getOwnPropertyNames:jn}=Object;var Gn=Object.prototype.hasOwnProperty;var tn=(n,h,t)=>{t=n!=null?_n(Sn(n)):{};let o=h||!n||!n.__esModule?hn(t,"default",{value:n,enumerable:!0}):t;for(let c of jn(n))if(!Gn.call(o,c))hn(o,c,{get:()=>n[c],enumerable:!0});return o};var on=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,t)=>(typeof require!=="undefined"?require:h)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var S;((x)=>{x.Arbitrum="ARB";x.Avalanche="AVAX";x.Base="BASE";x.BinanceSmartChain="BSC";x.Bitcoin="BTC";x.BitcoinCash="BCH";x.Cosmos="GAIA";x.Dash="DASH";x.Dogecoin="DOGE";x.Ethereum="ETH";x.Kujira="KUJI";x.Litecoin="LTC";x.Maya="MAYA";x.Optimism="OP";x.Polkadot="DOT";x.Chainflip="FLIP";x.Polygon="MATIC";x.Radix="XRD";x.THORChain="THOR";x.Solana="SOL"})(S||={});var m;((t)=>{t.THORChain="THOR_STAGENET";t.Maya="MAYA_STAGENET"})(m||={});var z;((B)=>{B.Arbitrum="42161";B.ArbitrumHex="0xa4b1";B.Avalanche="43114";B.AvalancheHex="0xa86a";B.Base="8453";B.BaseHex="0x2105";B.BinanceSmartChain="56";B.BinanceSmartChainHex="0x38";B.Bitcoin="bitcoin";B.BitcoinCash="bitcoincash";B.Chainflip="chainflip";B.Cosmos="cosmoshub-4";B.Dash="dash";B.Dogecoin="dogecoin";B.Kujira="kaiyo-1";B.Ethereum="1";B.EthereumHex="0x1";B.Litecoin="litecoin";B.Maya="mayachain-mainnet-v1";B.MayaStagenet="mayachain-stagenet-v1";B.Optimism="10";B.OptimismHex="0xa";B.Polkadot="polkadot";B.Polygon="137";B.PolygonHex="0x89";B.Radix="radix-mainnet";B.THORChain="thorchain-1";B.THORChainStagenet="thorchain-stagenet-v2";B.Solana="solana"})(z||={});var Sh={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},Ln=Object.keys(S),b=Object.values(S),N={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,OP:18,SOL:9,THOR:8,XRD:18},jh=["DOT","FLIP"],Q=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Gh=["BTC","BCH","DASH","DOGE","LTC"],Lh=["GAIA","THOR","MAYA","KUJI"],uh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],wh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],Cn={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://avalanche-c-chain-rpc.publicnode.com",["BASE"]:"https://base.llamarpc.com",["BSC"]:"https://bsc-dataseed.binance.org",["BTC"]:"https://bitcoin-rpc.publicnode.com",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["KUJI"]:"https://rpc-kujira.synergynodes.com/",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["THOR"]:"https://rpc.thorswap.net",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["SOL"]:"https://solana-rpc.publicnode.com"},un={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.quickapi.com","https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://rpc.ankr.com/eth"],["KUJI"]:["https://kujira-rpc.polkachu.com","https://kujira-rpc.ibs.team"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["THOR"]:["https://thornode.ninerealms.com","https://thornode.thorswap.net"],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},wn={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},D=Cn,f=(n)=>{return D[n]},Xn=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{jsonrpc:"2.0",method:"eth_blockNumber",params:[],id:1};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{jsonrpc:"1.0",id:"test",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{jsonrpc:"2.0",id:1,method:"system_health",params:[]};case"XRD":return"";case"SOL":return{jsonrpc:"2.0",id:1,method:"getHealth"};default:throw new Error(`Unsupported chain: ${n}`)}};function Jn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var cn=async(n,h)=>{try{let t=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${t}${Jn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Xn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},yn=async(n)=>{let h=Cn[n];if(await cn(n,h))return h;for(let t of un[n])if(await cn(n,t))return t;return h},Xh=async(n=[...Object.values(S),...Object.values(m)])=>{let h={};await Promise.all(n.map(async(t)=>{let o=await yn(t);h[t]=o})),D={...D,...h}},sn=b.reduce((n,h)=>{let t=Ln.find((o)=>S[o]===h);if(t)n[h]=t;return n},{}),Hn=b.reduce((n,h)=>{return n[h]=z[sn[h]],n},{}),E=b.reduce((n,h)=>{return n[h]=f(h),n},{}),Jh=b.reduce((n,h)=>{let t=`${sn[h]}Hex`;return n[h]=z[t],n},{}),yh=b.reduce((n,h)=>{return n[h]=wn[h],n},{});var In;((T)=>{T.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";T.TC_SUPPORTED_TO_ETH="TC-ERC20";T.TC_SUPPORTED_TO_AVAX="TC-ARC20";T.TC_SUPPORTED_TO_BSC="TC-BEP20";T.ETH_TO_TC_SUPPORTED="ERC20-TC";T.ETH_TO_ETH="ERC20-ERC20";T.ETH_TO_AVAX="ERC20-ARC20";T.ETH_TO_BSC="ERC20-BEP20";T.AVAX_TO_TC_SUPPORTED="ARC20-TC";T.AVAX_TO_ETH="ARC20-ERC20";T.AVAX_TO_AVAX="ARC20-ARC20";T.AVAX_TO_BSC="ARC20-BEP20";T.BSC_TO_TC_SUPPORTED="BEP20-TC";T.BSC_TO_ETH="BEP20-ERC20";T.BSC_TO_AVAX="BEP20-ARC20";T.BSC_TO_BSC="BEP20-BEP20"})(In||={});var Ph=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],zh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],bh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var Pn;((R)=>{R.ARB="0x0000000000000000000000000000000000000000";R.AVAX="0x0000000000000000000000000000000000000000";R.BASE="0x0000000000000000000000000000000000000000";R.ETH="0x0000000000000000000000000000000000000000";R.BSC="0x0000000000000000000000000000000000000000";R.MATIC="0x0000000000000000000000000000000000001010";R.OP="0x4200000000000000000000000000000000000042"})(Pn||={});var zn;((x)=>{x.ARB="m/44'/60'/0'/0";x.AVAX="m/44'/60'/0'/0";x.BASE="m/44'/60'/0'/0";x.BCH="m/44'/145'/0'/0";x.BSC="m/44'/60'/0'/0";x.BTC="m/84'/0'/0'/0";x.DASH="m/44'/5'/0'/0";x.DOGE="m/44'/3'/0'/0";x.DOT="////";x.ETH="m/44'/60'/0'/0";x.FLIP="////";x.GAIA="m/44'/118'/0'/0";x.KUJI="m/44'/118'/0'/0";x.LTC="m/84'/2'/0'/0";x.MATIC="m/44'/60'/0'/0";x.MAYA="m/44'/931'/0'/0";x.OP="m/44'/60'/0'/0";x.SOL="m/44'/501'/0'/0";x.THOR="m/44'/931'/0'/0";x.XRD="////"})(zn||={});var W={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,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],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],XRD:[0,0,0,0,0],DOT:[0,0,0,0,0],FLIP:[0,0,0,0,0]};var bn;((a)=>{a.Arbitrum="https://arb1.arbitrum.io/rpc";a.Avalanche="https://avalanche-c-chain-rpc.publicnode.com";a.Base="https://base.llamarpc.com";a.BinanceSmartChain="https://bsc-dataseed.binance.org";a.Bitcoin="https://bitcoin-rpc.publicnode.com";a.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";a.Chainflip="wss://mainnet-archive.chainflip.io";a.Cosmos="https://node-router.thorswap.net/cosmos/rpc";a.Dash="https://dash-rpc.publicnode.com";a.Dogecoin="https://node-router.thorswap.net/dogecoin";a.Ethereum="https://ethereum-rpc.publicnode.com";a.Kujira="https://rpc-kujira.synergynodes.com/";a.Litecoin="https://node-router.thorswap.net/litecoin";a.Maya="https://tendermint.mayachain.info";a.MayaStagenet="https://stagenet.tendermint.mayachain.info";a.Optimism="https://mainnet.optimism.io";a.Polkadot="wss://rpc.polkadot.io";a.Polygon="https://polygon-rpc.com";a.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";a.THORChain="https://rpc.thorswap.net";a.THORChainStagenet="https://stagenet-rpc.ninerealms.com";a.Solana="https://solana-rpc.publicnode.com"})(bn||={});var Zn;((x)=>{x.Arbitrum="https://arbiscan.io";x.Avalanche="https://snowtrace.io";x.Base="https://basescan.org";x.BinanceSmartChain="https://bscscan.com";x.Bitcoin="https://blockchair.com/bitcoin";x.BitcoinCash="https://www.blockchair.com/bitcoin-cash";x.Chainflip="https://explorer.polkascan.io/polkadot";x.Cosmos="https://www.mintscan.io/cosmos";x.Dash="https://blockchair.com/dash";x.Dogecoin="https://blockchair.com/dogecoin";x.Ethereum="https://etherscan.io";x.Kujira="https://finder.kujira.network/kaiyo-1";x.Litecoin="https://blockchair.com/litecoin";x.Maya="https://www.mayascan.org";x.Optimism="https://optimistic.etherscan.io";x.Polkadot="https://polkadot.subscan.io";x.Polygon="https://polygonscan.com";x.Radix="https://dashboard.radixdlt.com";x.THORChain="https://runescan.io";x.Solana="https://solscan.io"})(Zn||={});var xn;((A)=>{A.BRAVE="BRAVE";A.COINBASE_MOBILE="COINBASE_MOBILE";A.COINBASE_WEB="COINBASE_WEB";A.EIP6963="EIP6963";A.EXODUS="EXODUS";A.KEEPKEY="KEEPKEY";A.KEEPKEY_BEX="KEEPKEY_BEX";A.KEPLR="KEPLR";A.KEYSTORE="KEYSTORE";A.LEAP="LEAP";A.LEDGER="LEDGER";A.LEDGER_LIVE="LEDGER_LIVE";A.METAMASK="METAMASK";A.OKX="OKX";A.OKX_MOBILE="OKX_MOBILE";A.PHANTOM="PHANTOM";A.POLKADOT_JS="POLKADOT_JS";A.RADIX_WALLET="RADIX_WALLET";A.TREZOR="TREZOR";A.TALISMAN="TALISMAN";A.TRUSTWALLET_WEB="TRUSTWALLET_WEB";A.WALLETCONNECT="WALLETCONNECT";A.XDEFI="XDEFI"})(xn||={});var Yn;((o)=>{o[o.NoError=36864]="NoError";o[o.LockedDevice=21781]="LockedDevice";o[o.TC_NotFound=65535]="TC_NotFound"})(Yn||={});var qn;((o)=>{o.Average="average";o.Fast="fast";o.Fastest="fastest"})(qn||={});var Qn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(Qn||={});var Rn;((p)=>{p.NAME_REGISTER="~";p.BOND="BOND";p.DEPOSIT="+";p.LEAVE="LEAVE";p.UNBOND="UNBOND";p.WITHDRAW="-";p.OPEN_LOAN="$+";p.CLOSE_LOAN="$-";p.RUNEPOOL_DEPOSIT="POOL+";p.RUNEPOOL_WITHDRAW="POOL-"})(Rn||={});var fn;((C)=>{C.unknownError="unknownError";C.test_error="test_error";C.providerDetailsError="providerDetailsError";C.blockHeaderNotFound="blockHeaderNotFound";C.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";C.blockHashNotFoundAtHash="blockHashNotFoundAtHash";C.txHashMissing="txHashMissing";C.assetValueMissingInfo="assetValueMissingInfo";C.invalidAsset="invalidAsset";C.blockIsRequired="blockIsRequired";C.currentBlockHeaderNotFound="currentBlockHeaderNotFound";C.failedToRetrieveBalance="failedToRetrieveBalance";C.failedToRetrieveBlock="failedToRetrieveBlock";C.failedToRetrieveFees="failedToRetrieveFees";C.notImplementedBCH="notImplementedBCH";C.notImplementedDoge="notImplementedDoge";C.noPoolsFound="noPoolsFound";C.noVaultsFound="noVaultsFound";C.noTxFound="noTxFound";C.noInputCoinFound="noInputCoinFound";C.noBlockDataFound="noBlockDataFound";C.multipleCosmosMessages="multipleCosmosMessages";C.heightOrHashNotProvided="heightOrHashNotProvided";C.unknownDenom="unknownDenom";C.invalidBlockHeight="invalidBlockHeight";C.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";C.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";C.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";C.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";C.txMemoUndefined="txMemoUndefined";C.txMemoIncorrect="txMemoIncorrect";C.txTypeNotFound="txTypeNotFound";C.txNoMessage="txNoMessage";C.txNotFound="txNotFound";C.txReceiptNotFound="txReceiptNotFound";C.txParsingError="txParsingError";C.blockNotFound="blockNotFound";C.balanceNotFound="balanceNotFound";C.configError="configError";C.noQuoteResponse="noQuoteResponse";C.noPoolAssetsFound="noPoolAssetsFound";C.noThorchainPools="noThorchainPools";C.noMayachainPools="noMayachainPools";C.invalidAffiliateFee="invalidAffiliateFee";C.invalidBuyAssetAddress="invalidBuyAssetAddress";C.invalidSellAssetAddress="invalidSellAssetAddress";C.invalidSourceAddress="invalidSourceAddress";C.invalidDestinationAddress="invalidDestinationAddress";C.sourceAddressIsSmartContract="sourceAddressIsSmartContract";C.destinationAddressIsSmartContract="destinationAddressIsSmartContract";C.invalidChainId="invalidChainId";C.unsupportedChainId="unsupportedChainId";C.unsupportedEVMChainId="unsupportedEVMChainId";C.noWhitelistTokens="noWhitelistTokens";C.failedFetchGasPrice="failedFetchGasPrice";C.failedToCreateDepositChannel="failedToCreateDepositChannel";C.noProviderDetailsFound="noProviderDetailsFound";C.noTokenListsFound="noTokenListsFound";C.tokenNotFound="tokenNotFound";C.tokenPriceNotFound="tokenPriceNotFound";C.swapAmountTooSmall="swapAmountTooSmall";C.legsArrayIsEmpty="legsArrayIsEmpty";C.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";C.noBlockHeaderFound="noBlockHeaderFound";C.failedToSimulateSwap="failedToSimulateSwap";C.addressScreeningFailed="addressScreeningFailed";C.noLiquidtyProvidersFound="noLiquidtyProvidersFound";C.noSaversFound="noSaversFound";C.noInboundAddressesFound="noInboundAddressesFound";C.noInboundAddressFoundForChain="noInboundAddressFoundForChain";C.noLastBlocksFound="noLastBlocksFound";C.noVersionFound="noVersionFound";C.noConstantsFound="noConstantsFound";C.noMimirsFound="noMimirsFound";C.noRoutesFound="noRoutesFound";C.quoteNotFound="quoteNotFound";C.ledgerSignFailed="ledgerSignFailed";C.ledgerFetchSwapFailed="ledgerFetchSwapFailed";C.failedToFetchTx="failedToFetchTx";C.failedBuildTransactionDetails="failedBuildTransactionDetails";C.noLegsForRoute="noLegsForRoute";C.noRouterAddressFound="noRouterAddressFound";C.noAggregatorAddressFound="noAggregatorAddressFound";C.noContractInstanceFound="noContractInstanceFound";C.noContractAddressFound="noContractAddressFound";C.invalidAffiliate="invalidAffiliate";C.providerNotfound="No provider found";C.noRecordFound="No Record found";C.slippageTooLow="Slippage too low";C.tradingHalted="tradingHalted";C.noWrappedGasAsset="noWrappedGasAsset";C.aggregatorAddressNotFound="aggregatorAddressNotFound";C.routerAddressNotFound="routerAddressNotFound";C.dummyAddressNotFound="dummyAddressNotFound";C.trackerError="trackerError";C.noOhlcvDataFound="noOhlcvDataFound";C.noTradingPairs="noTradingPairs";C.noLoanPositionFound="noLoanPositionFound";C.noLendingAvailability="noLendingAvailability";C.lendingRepayTooSmall="lendingRepayTooSmall";C.missingState="missingState";C.ledgerSwapNotFound="ledgerSwapNotFound";C.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";C.errorEstimatingGas="errorEstimatingGas";C.apiKeyInvalid="apiKeyInvalid";C.apiKeyFailedToUpdate="apiKeyFailedToUpdate";C.apiKeyExpired="apiKeyExpired";C.unauthorized="unauthorized";C.failedToCreateMemo="failedToCreateMemo";C.radixIncorrectInstructions="radixIncorrectInstructions";C.invalidAddressForChain="invalidAddressForChain"})(fn||={});var Wn;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(Wn||={});var Mn;((O)=>{O.CHAINFLIP="CHAINFLIP";O.MAYACHAIN="MAYACHAIN";O.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";O.ONEINCH="ONEINCH";O.PANCAKESWAP="PANCAKESWAP";O.PANGOLIN_V1="PANGOLIN_V1";O.SUSHISWAP_V2="SUSHISWAP_V2";O.THORCHAIN="THORCHAIN";O.THORCHAIN_STREAMING="THORCHAIN_STREAMING";O.TRADERJOE_V2="TRADERJOE_V2";O.UNISWAP_V2="UNISWAP_V2";O.UNISWAP_V3="UNISWAP_V3";O.CAVIAR_V1="CAVIAR_V1"})(Mn||={});var Kn;((H)=>{H.LIQUIDITY="liquidity";H.NETWORK="network";H.INBOUND="inbound";H.OUTBOUND="outbound";H.AFFILIATE="affiliate";H.TAX="tax"})(Kn||={});var v={},Vn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"};function lh({apiKey:n,...h}){v={...h,apiKey:n}}async function M(n,h){let{apiKey:t,...o}=v,{searchParams:c,json:s,body:H}=h,R={...Vn,...o.headers,...h.headers,...s?{"Content-Type":"application/json"}:{}},k=s?JSON.stringify(s):H,F=new URL(n);if(c)F.search=new URLSearchParams(c).toString();if(t)R["x-api-key"]=t;try{let _=await(await fetch(F.toString(),{...o,...h,body:k,headers:R})).json();if(h.responseHandler)return h.responseHandler(_);return _}catch(p){if(h.onError)return h.onError(p);console.error(p)}}var I={get:async(n,h)=>M(n,{...h,method:"GET"}),post:async(n,h)=>M(n,{...h,method:"POST"}),extend:(n)=>{let h={...v,...n};return{get:async(t,o)=>M(t,{...h,...o,method:"GET"}),post:async(t,o)=>M(t,{...h,...o,method:"POST"}),extend:(t)=>I.extend({...h,...t})}}};var Un={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_xdefi_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_phantom_not_found:20201,wallet_xdefi_not_found:20301,wallet_xdefi_send_transaction_no_address:20302,wallet_xdefi_contract_address_not_provided:20303,wallet_xdefi_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class $ extends Error{static ErrorCode=Un;constructor(n,h){let t=typeof n==="string",o=t?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(o,{cause:{code:$.ErrorCode[o],message:`${o}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,$.prototype)}}function ot(n){if(n<0)throw new $({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function ct(n){if(n<0)throw new $({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function Ct(n,h){try{return n()}catch(t){if(h)throw new $(h,t);return console.error(t)}}function st(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Dn=["production","test"].includes("development"),Fn=new Set;function Bn(n,h){if(!Dn&&n){if(Fn.has(h))return;Fn.add(h),console.warn(h)}}async function Ht(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{return(await I.get(`${n!=="thorchain-1"?f("THOR_STAGENET"):f("THOR")}/status`)).result.node_info.network}catch(h){return n}}var pn=[...Object.values(S),"TERRA"];function Nn(n=""){let h=n.toUpperCase(),[t]=h.split(".");if(pn.includes(t))return!0;let[o]=h.split("/");if(pn.includes(o))return!0;throw new $({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function Bt(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var Y=8,y=(n)=>10n**BigInt(n),Z=(n)=>Math.log10(Number.parseFloat(n.toString()));function P({value:n,bigIntDecimal:h=Y,decimal:t=Y}){if(t===0)return n.toString();let o=n<0n,c=n.toString().substring(o?1:0),s=t-(c.length-1);if(s>0)c="0".repeat(s)+c;let H=c.length-t,R=c.slice(-t);if(Number.parseInt(R[h]||"0")>=5)R=`${R.substring(0,h-1)}${(Number.parseInt(R[h-1]||"0")+1).toString()}`;else R=R.substring(0,h);return`${o?"-":""}${c.slice(0,H)}.${R}`.replace(/\.?0*$/,"")}class w{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new w({decimal:h,value:P({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return w.fromBigInt(n.getBaseValue("bigint")*y(t)/y(h),t)}constructor(n){let h=d(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:y(Math.max(kn(K(h)),this.decimal||0)),this.#c(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let t=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||Z(this.decimalMultiplier));switch(n){case"number":return Number(t);case"string":return t;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n,h){let t=this.decimalMultiplier/y(h||this.decimal||N.THOR),o=this.bigIntValue/t;switch(n){case"number":return Number(o);case"string":return o.toString();case"bigint":return o}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let t=d(n),o=K(t);if(o==="0"||o==="undefined")return 0n;return this.#o(o,h)}toSignificant(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if((Number.parseInt(o)?o.length+c.length:c.length)<=n)return this.getValue("string");if(o.length>=n)return o.slice(0,n).padEnd(o.length,"0");if(Number.parseInt(o))return`${o}.${c.slice(0,n-o.length)}`.padEnd(n-o.length,"0");let H=Number.parseInt(c),R=`${H}`.slice(0,n);return`0.${R.padStart(c.length-`${H}`.length+R.length,"0")}`}toFixed(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if(Number.parseInt(o))return`${o}.${c.slice(0,n)}`.padEnd(n,"0");let s=Number.parseInt(c),H=`${s}`.slice(0,n);return`0.${H.padStart(c.length-`${s}`.length+H.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],o=Math.floor(Math.log10(Math.abs(h))/3),c=t[o];if(!c)return this.getValue("string");let s=10**(o*3);return`${(h/s).toFixed(n)}${c}`}toCurrency(n="$",{currencyPosition:h="start",decimal:t=2,decimalSeparator:o=".",thousandSeparator:c=","}={}){let s=this.getValue("number"),[H="",R=""]=s.toFixed(6).split("."),k=H.replace(/\B(?=(\d{3})+(?!\d))/g,c),F=H||R?H==="0"?`${Number.parseFloat(`0.${R}`)}`.replace(".",o):`${k}${Number.parseInt(R)?`${o}${R.slice(0,t)}`:""}`:"0.00";return`${h==="start"?n:""}${F}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let t=h||this.decimal||Y,o=Math.max(t,Z(this.decimalMultiplier)),c=n<0n,s=n.toString().substring(c?1:0),H=o-(s.length-1),R=H>0?"0".repeat(H)+s:s,k=R.length-o,F=R.slice(-o);if(Number.parseInt(F[t]||"0")>=5)F=`${F.substring(0,t-1)}${(Number.parseInt(F[t-1]||"0")+1).toString()}`;else F=F.substring(0,t);return`${c?"-":""}${R.slice(0,k)}.${F}`.replace(/\.?0*$/,"")}#h(n,...h){let t=this.#t(this,...h),o=Math.max(t,Z(this.decimalMultiplier)),c=y(o),s=h.reduce((R,k)=>{let F=this.getBigIntValue(k,o);switch(n){case"add":return R+F;case"sub":return R-F;case"mul":return R*F/c;case"div":{if(F===0n)throw new RangeError("Division by zero");return R*c/F}default:return R}},this.bigIntValue*c/this.decimalMultiplier),H=P({bigIntDecimal:o,decimal:o,value:s});return new this.constructor({decimalMultiplier:y(o),decimal:this.decimal,value:H,identifier:this.toString()})}#n(n,...h){let t=this.#t(this,...h),o=this.getBigIntValue(h[0]||"0",t),c=this.getBigIntValue(this,t);switch(n){case"gt":return c>o;case"gte":return c>=o;case"lt":return c<o;case"lte":return c<=o;case"eqValue":return c===o}}#c(n){let h=K(n)||"0";this.bigIntValue=this.#o(h)}#t(...n){let h=n.map((t)=>{return typeof t==="object"?t.decimal||Z(t.decimalMultiplier):kn(K(t))}).filter(Boolean);return Math.max(...h,Y)}#o(n,h){let t=h?y(h):this.decimalMultiplier,o=Z(t),[c="",s=""]=n.split(".");return BigInt(`${c}${s.padEnd(o,"0")}`)}}var mn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function K(n){let t=`${typeof n==="number"?mn.format(n):d(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function kn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,Y)}function d(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var V=new Map;class g extends w{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:t,chain:o,symbol:c,identifier:s}){super(typeof n==="object"?n:{decimal:h,value:n});let H=l(s||`${o}.${c}`);this.type=On(H),this.tax=t,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=Hn[H.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[t,o,c]=n.split(".");if(!(t&&o))throw new $({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let s=t==="THOR"&&c?`${t}.${o}/${c}`:n;return g.from({asset:s,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...o}){let c=n instanceof w?n.getValue("string"):n,s="chain"in o,H=s?o.chain:o.asset,R=s||An.includes(H),{identifier:k,decimal:F}=R?an(H):{identifier:H,decimal:void 0},{chain:p,isSynthetic:_,isTradeAsset:G}=l(k),O=V.get(p==="SOL"?k:k.toUpperCase()),X=O?.decimal||F;Bn(!(t||X),`Couldn't find static decimal for ${k} (Using default ${N[p]} decimal as fallback).
This can result in incorrect calculations and mess with amount sent on transactions.
You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:g,identifier:_,tax:u}=L||{decimal:Z||k[T],identifier:O},Y=h?v(BigInt(R),h):v(R,g);return H?Vn(_,h?Y:R):s||I?un(_,Y):new t({tax:u,decimal:g,identifier:_,value:Y})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((H)=>{for(let x of Object.values(H))for(let{identifier:R,chain:B,...N}of x.tokens)E.set(B!=="SOL"?R.toUpperCase():R,{identifier:R,decimal:"decimals"in N?N.decimals:k[B]});n({ok:!0})})}catch(H){console.error(H),h({ok:!1,error:H,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return t.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return t.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return t.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,H=k.THOR){return t.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:H})}static fromStringWithBaseSync(n,h=0n,H=k.THOR){return t.from({asset:n,value:h,fromBaseDecimal:H})}static fromIdentifierSync(n,h=0){return t.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(X).includes(n))return t.from({chain:n,value:h});return t.from({asset:n,value:h})}}function AH(n){let h=t.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function Vn(n,h=0){on(n);let x=n.includes("SOL.")?n:n.toUpperCase(),R=E.get(x),B=R?.decimal||await kn(l(n));if(!R)E.set(x,{identifier:n,decimal:B});return new t({decimal:B,value:v(h,B),identifier:n})}function un(n,h=0){let H=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,x=H?["MAYA","THOR"].includes(H):!1,R=n.slice(0,14).includes("~")?"~":"/",[B,N]=x?n.split(".").slice(1).join().split(R):n.split(R);if(!(B&&N))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new t({decimal:8,value:v(h,8),identifier:`${H||"THOR"}.${B}${R}${N}`})}function v(n,h){return typeof n==="bigint"?Q({value:n,bigIntDecimal:h,decimal:h}):n}function l(n){let h=n.slice(0,14).includes("/"),H=n.slice(0,14).includes("~"),x=H?"~":"/",R=n.split(".")?.[0]?.toUpperCase()==="THOR",B=n.split(".")?.[0]?.toUpperCase()==="MAYA",[N,c=""]=R||B?n.split(".").slice(1).join().split(x):n.split(x);if((h||H)&&!(N&&c))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let O=n.includes(".")&&!h&&!H?n:`${B?"MAYA":"THOR"}.${c}`,[o,...T]=O.split("."),s=h||H?c:T.join("."),I=s.split("-"),L=I.length===1?I[0]:I.slice(0,-1).join("-"),Z=I.length===1?void 0:I[I.length-1],g=o==="SOL"?Z:Z?.toLowerCase();return{address:g,chain:o,isGasAsset:r({chain:o,symbol:s}),isSynthetic:h,isTradeAsset:H,ticker:L,symbol:(h||H?`${N}${x}`:"")+(g?`${L}-${g??""}`:s)}}var Mn="0x313ce567",Tn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],_n=async({chain:n,to:h})=>{try{let{result:H}=await q.post(d[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:Mn},"latest"]})});return Number.parseInt(BigInt(H||k[n]).toString())}catch(H){return console.error(H),k[n]}},Kn=async({symbol:n})=>{try{let h=n.split("-")[1]?.toLowerCase(),{manager:H}=await q.post(`${d["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return H.divisibility.value.divisibility}catch(h){return console.error(h),k["XRD"]}},fn=(n)=>{if(n==="ETH")return k.ETH;let h=n.split("-"),H=h.length===1?void 0:h[h.length-1]?.toLowerCase();return H?.startsWith("0x")?_n({chain:"ETH",to:H}):k.ETH},bn=(n)=>{let h=n.split("-"),H=h.length===1?void 0:h[h.length-1];return H?.startsWith("0x")?_n({chain:"AVAX",to:H.toLowerCase()}):k.AVAX},Un=(n)=>{if(n==="BSC")return k.BSC;return k.BSC},Dn=(n)=>{if(n==="XRD")return k.XRD;return Kn({symbol:n})},kn=({chain:n,symbol:h})=>{switch(n){case"ETH":return fn(h);case"AVAX":return bn(h);case"BSC":return Un(h);case"XRD":return Dn(h);default:return k[n]}},_H=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return t.from({asset:`${n}.ETH`});case"MAYA":return t.from({asset:`${n}.CACAO`});case"GAIA":return t.from({asset:`${n}.ATOM`});case"BSC":return t.from({asset:`${n}.BNB`});case"THOR":return t.from({asset:`${n}.RUNE`});default:return t.from({asset:`${n}.${n}`})}},r=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},On=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:k[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:k[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:k[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:k[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:k[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:k[n]}}},$n=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},GH=(n)=>{let[h,...H]=n.split("."),x=n.includes("/"),R=H.join("."),B=R?.split("-"),N=B?.length?B.length===1?B[0]:B.slice(0,-1).join("-"):void 0;return{chain:h,symbol:R,ticker:N,synth:x}},En=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),vn=(n)=>{let[h,H]=n.split(".");if(!K.includes(h))return!0;let x=H.split("-"),R=x.length===1?void 0:x[x.length-1];return r({chain:h,symbol:H})||!!R},LH=(n)=>n.filter(({chain:h,value:H,symbol:x})=>{let R=`${h}.${x}`;return!En.test(R)&&vn(R)&&H!=="0"});async function tH(n){let h=await import("@swapkit/tokens");for(let H of Object.values(h))for(let{identifier:x,chain:R,...B}of H.tokens){if("identifier"in n&&x===n.identifier)return x;if("address"in B&&"chain"in n&&R===n.chain&&B.address.toLowerCase()===n.contract.toLowerCase())return x}return}var e=(n,h)=>{return[...n.slice(0,n.length-1),h]};function XH([n,h,H,x,R]){return`m/${n}'/${h}'/${H}'/${x}${typeof R!=="number"?"":`/${R}`}`}function JH({chain:n,index:h,addressIndex:H=0,type:x}){if(K.includes(n)){if(x&&["legacy","account"].includes(x))return[44,60,0,h];if(x==="ledgerLive")return[44,60,h,0,H];return e(b[n],h)}if(n==="SOL"){if(x==="account")return[44,501,0,h];return e(b[n],h)}let R=n==="LTC"?2:0;switch(x){case"nativeSegwitMiddleAccount":return[84,R,h,0,H];case"segwit":return[49,R,0,0,h];case"legacy":return[44,R,0,0,h];default:return e(b[n],h)}}function IH(n){let[h,H,x]=n.split("/").map((R)=>Number.parseInt(R,10));switch(H){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}function mn({liquidityUnits:n,poolUnits:h,runeDepth:H}){let x=J(n),R=J(h),B=J(H),N=x.mul(B),c=R.mul(R).mul(2),O=R.mul(x).mul(2),o=x.mul(x),T=R.mul(R).mul(R);return N.mul(c.sub(O).add(o)).div(T)}function dn({liquidityUnits:n,poolUnits:h,assetDepth:H}){let x=J(n),R=J(h),B=J(H),N=x.mul(B),c=R.mul(R).mul(2),O=R.mul(x).mul(2),o=x.mul(x),T=N.mul(c.sub(O).add(o)),s=R.mul(R).mul(R);return T.div(s)}function ZH({percent:n,runeDepth:h,liquidityUnits:H,poolUnits:x}){return mn({runeDepth:h,liquidityUnits:H,poolUnits:x}).mul(n)}function YH({percent:n,assetDepth:h,liquidityUnits:H,poolUnits:x}){return dn({assetDepth:h,liquidityUnits:H,poolUnits:x}).mul(n)}function J(n){return S.fromBigInt(BigInt(n),k.THOR)}function an({liquidityUnits:n,poolUnits:h,runeDepth:H,assetDepth:x}){return{assetAmount:J(x).mul(n).div(h),runeAmount:J(H).mul(n).div(h)}}function PH({liquidityUnits:n,poolUnits:h,runeDepth:H,assetDepth:x,percent:R}){return Object.fromEntries(Object.entries(an({liquidityUnits:n,poolUnits:h,runeDepth:H,assetDepth:x})).map(([B,N])=>[B,N.mul(R)]))}function qH({runeDepth:n,poolUnits:h,assetDepth:H,liquidityUnits:x,runeAmount:R,assetAmount:B}){let N=new S({value:n,decimal:8}),c=new S({value:H,decimal:8}),O=new S({value:h,decimal:8}),o=new S({value:R,decimal:8}),T=new S({value:B,decimal:8}),s=o.mul(c),I=T.mul(N),L=o.mul(T),Z=N.mul(c),g=O.mul(s.add(I.add(L.mul(2)))),_=s.add(I.add(Z.mul(2))),u=g.div(_),Y=J(x).add(u);if(u.getBaseValue("number")===0)return Y.div(O).getBaseValue("number");let nn=O.add(Y);return Y.div(nn).getBaseValue("number")}function QH({runeAmount:n,assetAmount:h,runeDepth:H,assetDepth:x}){if(n==="0"||h==="0"||H==="0"||x==="0")return 0;let R=J(H),B=J(x),N=J(h),c=J(n),O=N.mul(R).sub(B.mul(c)),o=B.mul(c).add(R.mul(B));return Math.abs(O.div(o).getBaseValue("number"))}function ln({type:n,address:h}){return`${n}:${h}`}function rn({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function VH(n){return V("POOL+",n)}function en({chain:n,symbol:h,...H}){return V(`${"+"}:${n}/${h}`,H)}function nh({chain:n,symbol:h,address:H,...x}){let R=Fh({chain:n,symbol:h}),B=H?`:${H}:`:":";return V(`${"+"}:${R}${B}`,x)}function hh({chain:n,symbol:h,basisPoints:H}){return`${"-"}:${n}/${h}:${H}`}function Hh({chain:n,symbol:h,ticker:H,basisPoints:x,targetAsset:R}){let B=n==="ETH"&&H!=="ETH"?`${H}-${h.slice(-3)}`:h,N=R?`:${R}`:"";return`${"-"}:${n}.${B}:${x}${N}`}function uH({basisPoints:n,...h}){return V(`${"POOL-"}:${n}`,h)}function xh({name:n,chain:h,address:H,owner:x}){let R=`${"~"}:${n}:${h}:${H}`,B=x?`:${x}`:"";return`${R}${B}`}function MH({name:n,chain:h,asset:H,payout:x,owner:R}){return`${"~"}:${n}:${h}:${x}:${R}:${H}`}function Rh(n,{asset:h,address:H,minAmount:x,...R}){let B=`${n}:${h}:${H}`,N=x?`:${x}`:"";return V(`${B}${N}`,R)}function V(n,{affiliateAddress:h,affiliateBasisPoints:H}={}){let x=`${n}${h?`:${h}:${H||0}`:""}`;return x.endsWith(":")?x.slice(0,-1):x}function Fh({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var KH=(n,h)=>{switch(n){case"LEAVE":case"BOND":return ln({type:n,address:h?.address});case"UNBOND":return rn({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return xh(h);case"$+":case"$-":return Rh(n,h);case"+":{let{chain:H,symbol:x,address:R,singleSide:B}=h;if(B)return en({chain:H,symbol:x});return nh({chain:H,symbol:x,address:R})}case"-":{let{chain:H,ticker:x,symbol:R,basisPoints:B,targetAssetString:N,singleSide:c}=h;if(c)return hh({chain:H,symbol:R,basisPoints:B});return Hh({chain:H,ticker:x,symbol:R,basisPoints:B,targetAsset:N})}default:throw new j({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};var Bh=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],Nh=(n,h,H)=>async(...x)=>{try{await Ch(h,H)}catch(R){throw new j({errorKey:"helpers_failed_to_switch_network",info:{error:R}})}return n(...x)},Gn=({provider:n,params:h,method:H})=>{if(!n?.send)throw new j("helpers_not_found_provider");let x=h?Array.isArray(h)?h:[h]:[];return n.send(H,x)},DH=({toolbox:n,chainId:h,provider:H=window.ethereum})=>{let x=Bh.reduce((R,B)=>{if(!n[B])return R;let N=n[B];if(typeof N!=="function")return R;return{...R,[B]:Nh(N,H,h)}},{});return{...n,...x}},EH=(n,h)=>Gn({provider:n,method:"wallet_addEthereumChain",params:[h]}),Ch=(n,h="0x1")=>Gn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]}),vH=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},mH=()=>{let{isTrust:n,isBraveWallet:h,__XDEFI:H,overrideIsMetaMask:x,selectedProvider:R}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(x&&R?.isCoinbaseWallet)return"COINBASE_WEB";if(H)"XDEFI";return"METAMASK"},dH=(n)=>{return ch().includes(n)},ch=()=>{let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,H=window?.ethereum?.isBraveWallet,x=window?.ethereum?.isTrust||window?.trustwallet,R=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,B=[];if(n)B.push("METAMASK");if(h)B.push("XDEFI");if(H)B.push("BRAVE");if(x)B.push("TRUSTWALLET_WEB");if(R)B.push("COINBASE_WEB");if(oh())B.push("OKX_MOBILE");return B};function aH({chain:n,covalentApiKey:h,ethplorerApiKey:H}){let x=n!=="ETH"&&!h?"covalentApiKey":H?void 0:"ethplorerApiKey";if(x)throw new j({errorKey:"wallet_missing_api_key",info:{missingKey:x}});return{covalentApiKey:h,ethplorerApiKey:H}}function iH(){let n=[];function h(x){if(n.map((R)=>R.info.uuid).includes(x.detail.info.uuid))return;n.push(x.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function H(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:H}}var oh=()=>{let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),H=/android|XiaoMi|MiuiBrowser/i.test(n),x=h||H,R=/OKApp/i.test(n);return x&&R},lH=()=>typeof window.ethereum!=="undefined";class S extends z{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new S({decimal:h,value:Q({value:n,bigIntDecimal:h,decimal:h})})}}export{ah as wrapWithThrow,Nh as wrapMethodWithNetworkSwitch,Cn as warnOnce,hH as validateTNS,on as validateIdentifier,e as updatedLastIndex,Ch as switchEVMWalletNetwork,fh as setRequestClientConfig,DH as prepareNetworkSwitch,oh as okxMobileEnabled,ch as listWeb3EVMWallets,lH as isWeb3Detected,r as isGasAsset,dH as isDetected,IH as getWalletFormatFor,mh as getTHORNameCost,PH as getSymmetricWithdraw,an as getSymmetricPoolShare,AH as getMinAmountByChain,Hh as getMemoForWithdraw,rn as getMemoForUnbond,hh as getMemoForSaverWithdraw,en as getMemoForSaverDeposit,uH as getMemoForRunePoolWithdraw,VH as getMemoForRunePoolDeposit,xh as getMemoForNameRegister,MH as getMemoForNamePreferredAssetRegister,Rh as getMemoForLoan,ln as getMemoForLeaveAndBond,nh as getMemoForDeposit,KH as getMemoFor,dh as getMAYANameCost,QH as getLiquiditySlippage,_H as getGasAsset,qH as getEstimatedPoolShare,mH as getETHDefaultWallet,iH as getEIP6963Wallets,lh as getDynamicChainId,JH as getDerivationPathFor,kn as getDecimal,On as getCommonAssetInfo,ih as getChainIdentifier,ZH as getAsymmetricRuneWithdrawAmount,mn as getAsymmetricRuneShare,YH as getAsymmetricAssetWithdrawAmount,dn as getAsymmetricAssetShare,$n as getAssetType,Q as formatBigIntToSafeValue,tH as findAssetBy,LH as filterAssets,aH as ensureEVMApiKeys,XH as derivationPathToString,wn as defaultRequestHeaders,GH as assetFromString,EH as addEVMWalletNetwork,vH as addAccountsChangedCallback,Pn as WarningCodeEnum,Fn as WalletOption,_h as UTXOChains,Lh as TCSupportedChains,S as SwapKitNumber,j as SwapKitError,$h as SubstrateChains,Sh as SWAP_OUT,Ih as SWAP_IN,q as RequestClient,M as RPCUrl,Jn as QuoteMode,qn as ProviderName,b as NetworkDerivationPath,Bn as MemoType,th as MAYASupportedChains,gn as LedgerErrorCode,Qn as FeeTypeEnum,zn as FeeOption,m as ExplorerUrl,Yn as ErrorCode,K as EVMChains,Sn as DerivationPath,Gh as CosmosChains,In as ContractAddress,Tn as CommonAssetStrings,d as ChainToRPC,jh as ChainToHexChainId,sh as ChainToExplorerUrl,Rn as ChainToChainId,Oh as ChainIdToChain,w as ChainId,X as Chain,z as BigIntArithmetics,k as BaseDecimal,t as AssetValue,Zn as ApproveMode,Jh as AGG_SWAP};
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:u,identifier:T,tax:i}=O||{decimal:X||N[p],identifier:k},J=h?U(BigInt(c),h):U(c,u);return t?En(T,h?J:c):_||G?vn(T,J):new g({tax:i,decimal:u,identifier:T,value:J})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((t)=>{for(let o of Object.values(t))for(let{identifier:c,chain:s,...H}of o.tokens)V.set(s!=="SOL"?c.toUpperCase():c,{identifier:c,decimal:"decimals"in H?H.decimals:N[s]});n({ok:!0})})}catch(t){console.error(t),h({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return g.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return g.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return g.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=N.THOR){return g.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=N.THOR){return g.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return g.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(S).includes(n))return g.from({chain:n,value:h});return g.from({asset:n,value:h})}}function _t(n){let h=g.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function En(n,h=0){Nn(n);let o=n.includes("SOL.")?n:n.toUpperCase(),c=V.get(o),s=c?.decimal||await Tn(l(n));if(!c)V.set(o,{identifier:n,decimal:s});return new g({decimal:s,value:U(h,s),identifier:n})}function vn(n,h=0){let t=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,o=t?["MAYA","THOR"].includes(t):!1,c=n.slice(0,14).includes("~")?"~":"/",[s,H]=o?n.split(".").slice(1).join().split(c):n.split(c);if(!(s&&H))throw new $({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new g({decimal:8,value:U(h,8),identifier:`${t||"THOR"}.${s}${c}${H}`})}function U(n,h){return typeof n==="bigint"?P({value:n,bigIntDecimal:h,decimal:h}):n}function l(n){let h=n.slice(0,14).includes("/"),t=n.slice(0,14).includes("~"),o=t?"~":"/",c=n.split(".")?.[0]?.toUpperCase()==="THOR",s=n.split(".")?.[0]?.toUpperCase()==="MAYA",[H,R=""]=c||s?n.split(".").slice(1).join().split(o):n.split(o);if((h||t)&&!(H&&R))throw new $({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let k=n.includes(".")&&!h&&!t?n:`${s?"MAYA":"THOR"}.${R}`,[F,...p]=k.split("."),_=h||t?R:p.join("."),G=_.split("-"),O=G.length===1?G[0]:G.slice(0,-1).join("-"),X=G.length===1?void 0:G[G.length-1],u=F==="SOL"?X:X?.toLowerCase();return{address:u,chain:F,isGasAsset:r({chain:F,symbol:_}),isSynthetic:h,isTradeAsset:t,ticker:O,symbol:(h||t?`${H}${o}`:"")+(u?`${O}-${u??""}`:_)}}var dn="0x313ce567",An=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],gn=async({chain:n,to:h})=>{try{let{result:t}=await I.post(E[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:dn},"latest"]})});return Number.parseInt(BigInt(t||N[n]).toString())}catch(t){return console.error(t),N[n]}},ln=async({symbol:n})=>{try{let h=n.split("-")[1]?.toLowerCase(),{manager:t}=await I.post(`${E["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return t.divisibility.value.divisibility}catch(h){return console.error(h),N["XRD"]}},rn=(n)=>{if(n==="ETH")return N.ETH;let h=n.split("-"),t=h.length===1?void 0:h[h.length-1]?.toLowerCase();return t?.startsWith("0x")?gn({chain:"ETH",to:t}):N.ETH},en=(n)=>{let h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?gn({chain:"AVAX",to:t.toLowerCase()}):N.AVAX},nh=(n)=>{if(n==="BSC")return N.BSC;return N.BSC},hh=(n)=>{if(n==="XRD")return N.XRD;return ln({symbol:n})},Tn=({chain:n,symbol:h})=>{switch(n){case"ETH":return rn(h);case"AVAX":return en(h);case"BSC":return nh(h);case"XRD":return hh(h);default:return N[n]}},ut=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return g.from({asset:`${n}.ETH`});case"MAYA":return g.from({asset:`${n}.CACAO`});case"GAIA":return g.from({asset:`${n}.ATOM`});case"BSC":return g.from({asset:`${n}.BNB`});case"THOR":return g.from({asset:`${n}.RUNE`});default:return g.from({asset:`${n}.${n}`})}},r=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},an=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:N[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:N[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:N[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:N[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:N[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:N[n]}}},On=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},wt=(n)=>{let[h,...t]=n.split("."),o=n.includes("/"),c=t.join("."),s=c?.split("-"),H=s?.length?s.length===1?s[0]:s.slice(0,-1).join("-"):void 0;return{chain:h,symbol:c,ticker:H,synth:o}},th=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),oh=(n)=>{let[h,t]=n.split(".");if(!Q.includes(h))return!0;let o=t.split("-"),c=o.length===1?void 0:o[o.length-1];return r({chain:h,symbol:t})||!!c},Xt=(n)=>n.filter(({chain:h,value:t,symbol:o})=>{let c=`${h}.${o}`;return!th.test(c)&&oh(c)&&t!=="0"});async function Jt(n){let h=await import("@swapkit/tokens");for(let t of Object.values(h))for(let{identifier:o,chain:c,...s}of t.tokens){if("identifier"in n&&o===n.identifier)return o;if("address"in s&&"chain"in n&&c===n.chain&&s.address.toLowerCase()===n.contract.toLowerCase())return o}return}var e=(n,h)=>{return[...n.slice(0,n.length-1),h]};function Pt([n,h,t,o,c]){return`m/${n}'/${h}'/${t}'/${o}${typeof c!=="number"?"":`/${c}`}`}function zt({chain:n,index:h,addressIndex:t=0,type:o}){if(Q.includes(n)){if(o&&["legacy","account"].includes(o))return[44,60,0,h];if(o==="ledgerLive")return[44,60,h,0,t];return e(W[n],h)}if(n==="SOL"){if(o==="account")return[44,501,0,h];return e(W[n],h)}let c=n==="LTC"?2:0;switch(o){case"nativeSegwitMiddleAccount":return[84,c,h,0,t];case"segwit":return[49,c,0,0,h];case"legacy":return[44,c,0,0,h];default:return e(W[n],h)}}function bt(n){let[h,t,o]=n.split("/").map((c)=>Number.parseInt(c,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}function ch({liquidityUnits:n,poolUnits:h,runeDepth:t}){let o=j(n),c=j(h),s=j(t),H=o.mul(s),R=c.mul(c).mul(2),k=c.mul(o).mul(2),F=o.mul(o),p=c.mul(c).mul(c);return H.mul(R.sub(k).add(F)).div(p)}function Ch({liquidityUnits:n,poolUnits:h,assetDepth:t}){let o=j(n),c=j(h),s=j(t),H=o.mul(s),R=c.mul(c).mul(2),k=c.mul(o).mul(2),F=o.mul(o),p=H.mul(R.sub(k).add(F)),_=c.mul(c).mul(c);return p.div(_)}function it({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:o}){return ch({runeDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function Qt({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:o}){return Ch({assetDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function j(n){return L.fromBigInt(BigInt(n),N.THOR)}function sh({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o}){return{assetAmount:j(o).mul(n).div(h),runeAmount:j(t).mul(n).div(h)}}function ft({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o,percent:c}){return Object.fromEntries(Object.entries(sh({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o})).map(([s,H])=>[s,H.mul(c)]))}function Wt({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:o,runeAmount:c,assetAmount:s}){let H=new L({value:n,decimal:8}),R=new L({value:t,decimal:8}),k=new L({value:h,decimal:8}),F=new L({value:c,decimal:8}),p=new L({value:s,decimal:8}),_=F.mul(R),G=p.mul(H),O=F.mul(p),X=H.mul(R),u=k.mul(_.add(G.add(O.mul(2)))),T=_.add(G.add(X.mul(2))),i=u.div(T),J=j(o).add(i);if(i.getBaseValue("number")===0)return J.div(k).getBaseValue("number");let nn=k.add(J);return J.div(nn).getBaseValue("number")}function Mt({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:o}){if(n==="0"||h==="0"||t==="0"||o==="0")return 0;let c=j(t),s=j(o),H=j(h),R=j(n),k=H.mul(c).sub(s.mul(R)),F=s.mul(R).add(c.mul(s));return Math.abs(k.div(F).getBaseValue("number"))}function Hh({type:n,address:h}){return`${n}:${h}`}function xh({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function mt(n){return q("POOL+",n)}function Rh({chain:n,symbol:h,...t}){return q(`${"+"}:${n}/${h}`,t)}function Fh({chain:n,symbol:h,address:t,...o}){let c=Ah({chain:n,symbol:h}),s=t?`:${t}:`:":";return q(`${"+"}:${c}${s}`,o)}function Bh({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function ph({chain:n,symbol:h,ticker:t,basisPoints:o,targetAsset:c}){let s=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,H=c?`:${c}`:"";return`${"-"}:${n}.${s}:${o}${H}`}function Et({basisPoints:n,...h}){return q(`${"POOL-"}:${n}`,h)}function Nh({name:n,chain:h,address:t,owner:o}){let c=`${"~"}:${n}:${h}:${t}`,s=o?`:${o}`:"";return`${c}${s}`}function vt({name:n,chain:h,asset:t,payout:o,owner:c}){return`${"~"}:${n}:${h}:${o}:${c}:${t}`}function kh(n,{asset:h,address:t,minAmount:o,...c}){let s=`${n}:${h}:${t}`,H=o?`:${o}`:"";return q(`${s}${H}`,c)}function q(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){let o=`${n}${h?`:${h}:${t||0}`:""}`;return o.endsWith(":")?o.slice(0,-1):o}function Ah({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var dt=(n,h)=>{switch(n){case"LEAVE":case"BOND":return Hh({type:n,address:h?.address});case"UNBOND":return xh({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return Nh(h);case"$+":case"$-":return kh(n,h);case"+":{let{chain:t,symbol:o,address:c,singleSide:s}=h;if(s)return Rh({chain:t,symbol:o});return Fh({chain:t,symbol:o,address:c})}case"-":{let{chain:t,ticker:o,symbol:c,basisPoints:s,targetAssetString:H,singleSide:R}=h;if(R)return Bh({chain:t,symbol:c,basisPoints:s});return ph({chain:t,ticker:o,symbol:c,basisPoints:s,targetAsset:H})}default:throw new $({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};var Th=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],ah=(n,h,t)=>async(...o)=>{try{await Oh(h,t)}catch(c){throw new $({errorKey:"helpers_failed_to_switch_network",info:{error:c}})}return n(...o)},$n=({provider:n,params:h,method:t})=>{if(!n?.send)throw new $("helpers_not_found_provider");let o=h?Array.isArray(h)?h:[h]:[];return n.send(t,o)},no=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{let o=Th.reduce((c,s)=>{if(!n[s])return c;let H=n[s];if(typeof H!=="function")return c;return{...c,[s]:ah(H,t,h)}},{});return{...n,...o}},ho=(n,h)=>$n({provider:n,method:"wallet_addEthereumChain",params:[h]}),Oh=(n,h="0x1")=>$n({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]}),to=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},oo=()=>{let{isTrust:n,isBraveWallet:h,__XDEFI:t,overrideIsMetaMask:o,selectedProvider:c}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(o&&c?.isCoinbaseWallet)return"COINBASE_WEB";if(t)"XDEFI";return"METAMASK"},co=(n)=>{return gh().includes(n)},gh=()=>{let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,o=window?.ethereum?.isTrust||window?.trustwallet,c=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,s=[];if(n)s.push("METAMASK");if(h)s.push("XDEFI");if(t)s.push("BRAVE");if(o)s.push("TRUSTWALLET_WEB");if(c)s.push("COINBASE_WEB");if($h())s.push("OKX_MOBILE");return s};function Co({chain:n,covalentApiKey:h,ethplorerApiKey:t}){let o=n!=="ETH"&&!h?"covalentApiKey":t?void 0:"ethplorerApiKey";if(o)throw new $({errorKey:"wallet_missing_api_key",info:{missingKey:o}});return{covalentApiKey:h,ethplorerApiKey:t}}function so(){let n=[];function h(o){if(n.map((c)=>c.info.uuid).includes(o.detail.info.uuid))return;n.push(o.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:t}}var $h=()=>{let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),o=h||t,c=/OKApp/i.test(n);return o&&c},Ho=()=>typeof window.ethereum!=="undefined";class L extends w{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new L({decimal:h,value:P({value:n,bigIntDecimal:h,decimal:h})})}}export{Ct as wrapWithThrow,ah as wrapMethodWithNetworkSwitch,Bn as warnOnce,Bt as validateTNS,Nn as validateIdentifier,e as updatedLastIndex,Oh as switchEVMWalletNetwork,lh as setRequestClientConfig,no as prepareNetworkSwitch,$h as okxMobileEnabled,gh as listWeb3EVMWallets,Ho as isWeb3Detected,r as isGasAsset,co as isDetected,Xh as initializeRPCUrlsWithFallback,bt as getWalletFormatFor,ot as getTHORNameCost,ft as getSymmetricWithdraw,sh as getSymmetricPoolShare,f as getRPCUrl,_t as getMinAmountByChain,ph as getMemoForWithdraw,xh as getMemoForUnbond,Bh as getMemoForSaverWithdraw,Rh as getMemoForSaverDeposit,Et as getMemoForRunePoolWithdraw,mt as getMemoForRunePoolDeposit,Nh as getMemoForNameRegister,vt as getMemoForNamePreferredAssetRegister,kh as getMemoForLoan,Hh as getMemoForLeaveAndBond,Fh as getMemoForDeposit,dt as getMemoFor,ct as getMAYANameCost,Mt as getLiquiditySlippage,ut as getGasAsset,Wt as getEstimatedPoolShare,oo as getETHDefaultWallet,so as getEIP6963Wallets,Ht as getDynamicChainId,zt as getDerivationPathFor,Tn as getDecimal,an as getCommonAssetInfo,st as getChainIdentifier,it as getAsymmetricRuneWithdrawAmount,ch as getAsymmetricRuneShare,Qt as getAsymmetricAssetWithdrawAmount,Ch as getAsymmetricAssetShare,On as getAssetType,P as formatBigIntToSafeValue,Jt as findAssetBy,Xt as filterAssets,Co as ensureEVMApiKeys,Pt as derivationPathToString,Vn as defaultRequestHeaders,wt as assetFromString,ho as addEVMWalletNetwork,to as addAccountsChangedCallback,Wn as WarningCodeEnum,xn as WalletOption,Gh as UTXOChains,uh as TCSupportedChains,L as SwapKitNumber,$ as SwapKitError,jh as SubstrateChains,m as StagenetChain,bh as SWAP_OUT,zh as SWAP_IN,I as RequestClient,Cn as RPC_URLS,bn as RPCUrl,In as QuoteMode,Mn as ProviderName,W as NetworkDerivationPath,Rn as MemoType,wh as MAYASupportedChains,Yn as LedgerErrorCode,Kn as FeeTypeEnum,qn as FeeOption,un as FALLBACK_URLS,Zn as ExplorerUrl,fn as ErrorCode,wn as EXPLORER_URLS,Q as EVMChains,zn as DerivationPath,Lh as CosmosChains,Pn as ContractAddress,An as CommonAssetStrings,E as ChainToRPC,Jh as ChainToHexChainId,yh as ChainToExplorerUrl,Hn as ChainToChainId,Sh as ChainIdToChain,z as ChainId,S as Chain,w as BigIntArithmetics,N as BaseDecimal,g as AssetValue,Qn as ApproveMode,Ph as AGG_SWAP};
//# debugId=F3984BD04D7E9A0E64756E2164756E21
//# debugId=683132142AC0B74864756E2164756E21

@@ -9,8 +9,8 @@ {

"devDependencies": {
"@swapkit/toolbox-cosmos": "1.4.3",
"@swapkit/toolbox-evm": "1.6.3",
"@swapkit/toolbox-radix": "1.2.15",
"@swapkit/toolbox-solana": "1.2.3",
"@swapkit/toolbox-substrate": "1.2.23",
"@swapkit/toolbox-utxo": "1.1.28"
"@swapkit/toolbox-cosmos": "1.5.0",
"@swapkit/toolbox-evm": "1.7.0",
"@swapkit/toolbox-radix": "1.2.16",
"@swapkit/toolbox-solana": "1.3.0",
"@swapkit/toolbox-substrate": "1.3.0",
"@swapkit/toolbox-utxo": "1.2.0"
},

@@ -39,3 +39,3 @@ "files": [

"types": "./src/index.ts",
"version": "1.14.2"
"version": "1.15.0"
}
import { RequestClient } from "../modules/requestClient";
import { type ErrorKeys, SwapKitError } from "../modules/swapKitError";
import { Chain, ChainId, RPCUrl } from "../types";
import { Chain, ChainId, StagenetChain, getRPCUrl } from "../types";

@@ -74,3 +74,3 @@ // 10 rune for register, 1 rune per year

const response = await RequestClient.get<{ result: { node_info: { network: string } } }>(
`${chainId !== ChainId.THORChain ? RPCUrl.THORChainStagenet : RPCUrl.THORChain}/status`,
`${chainId !== ChainId.THORChain ? getRPCUrl(StagenetChain.THORChain) : getRPCUrl(Chain.THORChain)}/status`,
);

@@ -77,0 +77,0 @@ return response.result.node_info.network as ChainId;

@@ -1,3 +0,1 @@

import { ExplorerUrl, RPCUrl } from "./network";
export enum Chain {

@@ -26,2 +24,7 @@ Arbitrum = "ARB",

export enum StagenetChain {
THORChain = "THOR_STAGENET",
Maya = "MAYA_STAGENET",
}
export type WalletChain = Exclude<Chain, Chain.Radix>;

@@ -179,2 +182,213 @@

export const RPC_URLS: Record<Chain | StagenetChain, string> = {
[Chain.Arbitrum]: "https://arb1.arbitrum.io/rpc",
[Chain.Avalanche]: "https://avalanche-c-chain-rpc.publicnode.com",
[Chain.Base]: "https://base.llamarpc.com",
[Chain.BinanceSmartChain]: "https://bsc-dataseed.binance.org",
[Chain.Bitcoin]: "https://bitcoin-rpc.publicnode.com",
[Chain.BitcoinCash]: "https://node-router.thorswap.net/bitcoin-cash",
[Chain.Chainflip]: "wss://mainnet-archive.chainflip.io",
[Chain.Cosmos]: "https://node-router.thorswap.net/cosmos/rpc",
[Chain.Dash]: "https://dash-rpc.publicnode.com",
[Chain.Dogecoin]: "https://node-router.thorswap.net/dogecoin",
[Chain.Ethereum]: "https://ethereum-rpc.publicnode.com",
[Chain.Kujira]: "https://rpc-kujira.synergynodes.com/",
[Chain.Litecoin]: "https://node-router.thorswap.net/litecoin",
[Chain.Maya]: "https://tendermint.mayachain.info",
[Chain.Optimism]: "https://mainnet.optimism.io",
[Chain.Polkadot]: "wss://rpc.polkadot.io",
[Chain.Polygon]: "https://polygon-rpc.com",
[Chain.Radix]: "https://radix-mainnet.rpc.grove.city/v1/326002fc/core",
[Chain.THORChain]: "https://rpc.thorswap.net",
[StagenetChain.THORChain]: "https://stagenet-rpc.ninerealms.com",
[StagenetChain.Maya]: "https://stagenet.tendermint.mayachain.info",
[Chain.Solana]: "https://solana-rpc.publicnode.com",
};
export const FALLBACK_URLS: Record<Chain | StagenetChain, string[]> = {
[Chain.Arbitrum]: [
"https://arb-mainnet.g.alchemy.com/v2/demo",
"https://arbitrum.blockpi.network/v1/rpc/public",
],
[Chain.Avalanche]: [
"https://api.avax.network/ext/bc/C/rpc",
"https://avalanche-c-chain-rpc.publicnode.com",
],
[Chain.Base]: ["https://base.blockpi.network/v1/rpc/public", "https://1rpc.io/base"],
[Chain.BinanceSmartChain]: [
"https://bsc-rpc.gateway.pokt.network",
"https://bsc-dataseed2.binance.org",
],
[Chain.Bitcoin]: ["https://bitcoin.publicnode.com"],
[Chain.BitcoinCash]: ["https://bch-dataseed.binance.org", "https://bch.getblock.io/mainnet"],
[Chain.Chainflip]: [
"wss://archive-1.mainnet.chainflip.io",
"wss://archive-2.mainnet.chainflip.io",
],
[Chain.Cosmos]: ["https://cosmos-rpc.quickapi.com", "https://cosmos-rpc.publicnode.com"],
[Chain.Dash]: ["https://dash-rpc.publicnode.com"],
[Chain.Dogecoin]: ["https://doge.getblock.io/mainnet", "https://dogecoin.publicnode.com"],
[Chain.Ethereum]: ["https://eth.llamarpc.com", "https://rpc.ankr.com/eth"],
[Chain.Kujira]: ["https://kujira-rpc.polkachu.com", "https://kujira-rpc.ibs.team"],
[Chain.Litecoin]: ["https://ltc.getblock.io/mainnet", "https://litecoin.publicnode.com"],
[Chain.Maya]: ["https://tendermint.mayachain.info", "https://maya-tendermint.publicnode.com"],
[StagenetChain.Maya]: [],
[Chain.Optimism]: ["https://optimism.llamarpc.com", "https://1rpc.io/op"],
[Chain.Polkadot]: [
"wss://polkadot-rpc.dwellir.com",
"wss://polkadot.api.onfinality.io/public-ws",
],
[Chain.Polygon]: ["https://polygon.llamarpc.com", "https://rpc.ankr.com/polygon"],
[Chain.Radix]: ["https://mainnet.radixdlt.com", "https://radix-mainnet.rpc.grove.city/v1"],
[Chain.THORChain]: ["https://thornode.ninerealms.com", "https://thornode.thorswap.net"],
[StagenetChain.THORChain]: [],
[Chain.Solana]: ["https://api.mainnet-beta.solana.com", "https://rpc.ankr.com/solana"],
};
export const EXPLORER_URLS: Record<Chain, string> = {
[Chain.Arbitrum]: "https://arbiscan.io",
[Chain.Avalanche]: "https://snowtrace.io",
[Chain.Base]: "https://basescan.org",
[Chain.BinanceSmartChain]: "https://bscscan.com",
[Chain.Bitcoin]: "https://blockchair.com/bitcoin",
[Chain.BitcoinCash]: "https://www.blockchair.com/bitcoin-cash",
[Chain.Chainflip]: "https://explorer.polkascan.io/polkadot",
[Chain.Cosmos]: "https://www.mintscan.io/cosmos",
[Chain.Dash]: "https://blockchair.com/dash",
[Chain.Dogecoin]: "https://blockchair.com/dogecoin",
[Chain.Ethereum]: "https://etherscan.io",
[Chain.Kujira]: "https://finder.kujira.network/kaiyo-1",
[Chain.Litecoin]: "https://blockchair.com/litecoin",
[Chain.Maya]: "https://www.mayascan.org",
[Chain.Optimism]: "https://optimistic.etherscan.io",
[Chain.Polkadot]: "https://polkadot.subscan.io",
[Chain.Polygon]: "https://polygonscan.com",
[Chain.Radix]: "https://dashboard.radixdlt.com",
[Chain.THORChain]: "https://runescan.io",
[Chain.Solana]: "https://solscan.io",
};
let RPCUrlsMerged = RPC_URLS;
export const getRPCUrl = (chain: Chain | StagenetChain) => {
return RPCUrlsMerged[chain];
};
const getRpcBody = (chain: Chain | StagenetChain) => {
switch (chain) {
case Chain.Arbitrum:
case Chain.Avalanche:
case Chain.Base:
case Chain.BinanceSmartChain:
case Chain.Ethereum:
case Chain.Optimism:
case Chain.Polygon:
return {
jsonrpc: "2.0",
method: "eth_blockNumber",
params: [],
id: 1,
};
case Chain.Bitcoin:
case Chain.Dogecoin:
case Chain.BitcoinCash:
case Chain.Dash:
case Chain.Litecoin:
return {
jsonrpc: "1.0",
id: "test",
method: "getblockchaininfo",
params: [],
};
case Chain.Cosmos:
case Chain.Kujira:
case Chain.Maya:
case Chain.THORChain:
case StagenetChain.Maya:
case StagenetChain.THORChain:
return {
id: 1,
jsonrpc: "2.0",
method: "status",
params: {},
};
case Chain.Polkadot:
return {
jsonrpc: "2.0",
id: 1,
method: "system_health",
params: [],
};
case Chain.Radix:
return "";
case Chain.Solana:
return {
jsonrpc: "2.0",
id: 1,
method: "getHealth",
};
default:
throw new Error(`Unsupported chain: ${chain}`);
}
};
function getChainStatusEndpoint(chain: Chain | StagenetChain) {
switch (chain) {
case Chain.Radix:
return "/status/network-configuration";
default:
return "";
}
}
const testRPCConnection = async (chain: Chain | StagenetChain, url: string) => {
try {
const endpoint = url.startsWith("wss") ? url.replace("wss", "https") : url;
const response = await fetch(`${endpoint}${getChainStatusEndpoint(chain)}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(getRpcBody(chain)),
signal: AbortSignal.timeout(3000),
});
return response.ok;
} catch {
return false;
}
};
const getRPCUrlWithFallback = async (chain: Chain | StagenetChain) => {
const primaryUrl = RPC_URLS[chain];
if (await testRPCConnection(chain, primaryUrl)) {
return primaryUrl;
}
for (const fallbackUrl of FALLBACK_URLS[chain]) {
if (await testRPCConnection(chain, fallbackUrl)) {
return fallbackUrl;
}
}
return primaryUrl;
};
export const initializeRPCUrlsWithFallback = async (
chains: (Chain | StagenetChain)[] = [...Object.values(Chain), ...Object.values(StagenetChain)],
) => {
const workingUrls: Record<Chain | StagenetChain, string> = {} as Record<
Chain | StagenetChain,
string
>;
await Promise.all(
chains.map(async (chain) => {
const workingUrl = await getRPCUrlWithFallback(chain);
workingUrls[chain] = workingUrl;
}),
);
RPCUrlsMerged = { ...RPCUrlsMerged, ...workingUrls };
};
const ChainToChainName = chains.reduce(

@@ -201,6 +415,6 @@ (acc, chain) => {

(acc, chain) => {
acc[chain] = RPCUrl[ChainToChainName[chain]];
acc[chain] = getRPCUrl(chain);
return acc;
},
{} as { [key in Chain]: RPCUrl },
{} as { [key in Chain]: string },
);

@@ -220,3 +434,3 @@

(acc, chain) => {
acc[chain] = ExplorerUrl[ChainToChainName[chain]];
acc[chain] = EXPLORER_URLS[chain];
return acc;

@@ -223,0 +437,0 @@ },

@@ -9,4 +9,8 @@ import type { RadixNetwork } from "@swapkit/toolbox-radix";

/**
* @required
* @required for swapkit API access
*/
swapkitApiKey?: string;
/**
* @required for AVAX & BSC
*/
thorswapApiKey?: string;

@@ -13,0 +17,0 @@ /**

@@ -0,1 +1,2 @@

/** @deprecated Use getRPCUrl or RPC_URLS instead */
export enum RPCUrl {

@@ -26,2 +27,3 @@ Arbitrum = "https://arb1.arbitrum.io/rpc",

/** @deprecated Use EXPLORER_URLS instead */
export enum ExplorerUrl {

@@ -28,0 +30,0 @@ Arbitrum = "https://arbiscan.io",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc