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.3.2 to 1.4.0

6

dist/index.js

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

var e=((F)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(F,{get:(x,n)=>(typeof require!=="undefined"?require:x)[n]}):F)(function(F){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+F+'" is not supported')});export*from"@swapkit/contracts";var d;((A)=>{A.Arbitrum="https://arb1.arbitrum.io/rpc";A.Avalanche="https://node-router.thorswap.net/avalanche-c";A.BinanceSmartChain="https://bsc-dataseed.binance.org";A.Bitcoin="https://node-router.thorswap.net/bitcoin";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://node-router.thorswap.net/dash";A.Dogecoin="https://node-router.thorswap.net/dogecoin";A.Ethereum="https://node-router.thorswap.net/ethereum";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://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80"})(d||={});var t;((I)=>{I.Arbitrum="https://arbiscan.io";I.Avalanche="https://snowtrace.io";I.BinanceSmartChain="https://bscscan.com";I.Bitcoin="https://blockchair.com/bitcoin";I.BitcoinCash="https://www.blockchair.com/bitcoin-cash";I.Chainflip="https://explorer.polkascan.io/polkadot";I.Cosmos="https://www.mintscan.io/cosmos";I.Dash="https://blockchair.com/dash";I.Dogecoin="https://blockchair.com/dogecoin";I.Ethereum="https://etherscan.io";I.Kujira="https://finder.kujira.network/kaiyo-1";I.Litecoin="https://blockchair.com/litecoin";I.Maya="https://www.mayascan.org";I.Optimism="https://optimistic.etherscan.io";I.Polkadot="https://polkadot.subscan.io";I.Polygon="https://polygonscan.com";I.Radix="https://dashboard.radixdlt.com";I.THORChain="https://runescan.io";I.Solana="https://solscan.io"})(t||={});var Y;((I)=>{I.Arbitrum="ARB";I.Avalanche="AVAX";I.BinanceSmartChain="BSC";I.Bitcoin="BTC";I.BitcoinCash="BCH";I.Cosmos="GAIA";I.Dash="DASH";I.Dogecoin="DOGE";I.Ethereum="ETH";I.Kujira="KUJI";I.Litecoin="LTC";I.Maya="MAYA";I.Optimism="OP";I.Polkadot="DOT";I.Chainflip="FLIP";I.Polygon="MATIC";I.Radix="XRD";I.THORChain="THOR";I.Solana="SOL"})(Y||={});var u;((L)=>{L.Arbitrum="42161";L.ArbitrumHex="0xa4b1";L.Avalanche="43114";L.AvalancheHex="0xa86a";L.BinanceSmartChain="56";L.BinanceSmartChainHex="0x38";L.Bitcoin="bitcoin";L.BitcoinCash="bitcoincash";L.Chainflip="chainflip";L.Cosmos="cosmoshub-4";L.Dash="dash";L.Dogecoin="dogecoin";L.Kujira="kaiyo-1";L.Ethereum="1";L.EthereumHex="0x1";L.Litecoin="litecoin";L.Maya="mayachain-mainnet-v1";L.MayaStagenet="mayachain-stagenet-v1";L.Optimism="10";L.OptimismHex="0xa";L.Polkadot="polkadot";L.Polygon="137";L.PolygonHex="0x89";L.Radix="radix-mainnet";L.THORChain="thorchain-mainnet-v1";L.THORChainStagenet="thorchain-stagenet-v2";L.Solana="solana"})(u||={});var Ix={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["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-mainnet-v1"]:"THOR",["solana"]:"SOL"},AF=Object.keys(Y),C=Object.values(Y),z;((T)=>{T[T.ARB=18]="ARB";T[T.AVAX=18]="AVAX";T[T.BCH=8]="BCH";T[T.BSC=18]="BSC";T[T.BTC=8]="BTC";T[T.DASH=8]="DASH";T[T.DOGE=8]="DOGE";T[T.DOT=10]="DOT";T[T.ETH=18]="ETH";T[T.FLIP=18]="FLIP";T[T.GAIA=6]="GAIA";T[T.KUJI=6]="KUJI";T[T.LTC=8]="LTC";T[T.MATIC=18]="MATIC";T[T.MAYA=8]="MAYA";T[T.OP=18]="OP";T[T.SOL=9]="SOL";T[T.THOR=8]="THOR";T[T.XRD=18]="XRD";T[T.ZEC=8]="ZEC"})(z||={});var Tx=["DOT","FLIP"],y=["ETH","AVAX","BSC","ARB","OP","MATIC"],_x=["BTC","BCH","DASH","DOGE","LTC"],Gx=["GAIA","THOR","MAYA","KUJI"],Ox=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Lx=["ARB","DASH","ETH","KUJI","MAYA","THOR"],v=C.reduce((F,x)=>{const n=AF.find((H)=>Y[H]===x);if(n)F[x]=n;return F},{}),FF=C.reduce((F,x)=>{return F[x]=u[v[x]],F},{}),m=C.reduce((F,x)=>{return F[x]=d[v[x]],F},{}),Px=C.reduce((F,x)=>{const n=`${v[x]}Hex`;return F[x]=u[n],F},{}),$x=C.reduce((F,x)=>{return F[x]=t[v[x]],F},{});var XF;((j)=>{j.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";j.TC_SUPPORTED_TO_ETH="TC-ERC20";j.TC_SUPPORTED_TO_AVAX="TC-ARC20";j.TC_SUPPORTED_TO_BSC="TC-BEP20";j.ETH_TO_TC_SUPPORTED="ERC20-TC";j.ETH_TO_ETH="ERC20-ERC20";j.ETH_TO_AVAX="ERC20-ARC20";j.ETH_TO_BSC="ERC20-BEP20";j.AVAX_TO_TC_SUPPORTED="ARC20-TC";j.AVAX_TO_ETH="ARC20-ERC20";j.AVAX_TO_AVAX="ARC20-ARC20";j.AVAX_TO_BSC="ARC20-BEP20";j.BSC_TO_TC_SUPPORTED="BEP20-TC";j.BSC_TO_ETH="BEP20-ERC20";j.BSC_TO_AVAX="BEP20-ARC20";j.BSC_TO_BSC="BEP20-BEP20"})(XF||={});var Xx=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],jx=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Jx=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var jF;((k)=>{k.ARB="0x0000000000000000000000000000000000000000";k.AVAX="0x0000000000000000000000000000000000000000";k.ETH="0x0000000000000000000000000000000000000000";k.BSC="0x0000000000000000000000000000000000000000";k.MATIC="0x0000000000000000000000000000000000001010";k.OP="0x4200000000000000000000000000000000000042"})(jF||={});var JF;((I)=>{I.ARB="m/44'/60'/0'/0";I.AVAX="m/44'/60'/0'/0";I.BCH="m/44'/145'/0'/0";I.BSC="m/44'/60'/0'/0";I.BTC="m/84'/0'/0'/0";I.DASH="m/44'/5'/0'/0";I.DOGE="m/44'/3'/0'/0";I.DOT="////";I.ETH="m/44'/60'/0'/0";I.FLIP="////";I.GAIA="m/44'/118'/0'/0";I.KUJI="m/44'/118'/0'/0";I.LTC="m/84'/2'/0'/0";I.MATIC="m/44'/60'/0'/0";I.MAYA="m/44'/931'/0'/0";I.OP="m/44'/60'/0'/0";I.SOL="m/44'/501'/0'/0";I.THOR="m/44'/931'/0'/0";I.XRD="////"})(JF||={});var s={ARB:[44,60,0,0,0],AVAX:[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 xF;((T)=>{T.BRAVE="BRAVE";T.COINBASE_MOBILE="COINBASE_MOBILE";T.COINBASE_WEB="COINBASE_WEB";T.EIP6963="EIP6963";T.EXODUS="EXODUS";T.KEEPKEY="KEEPKEY";T.KEPLR="KEPLR";T.KEYSTORE="KEYSTORE";T.LEDGER="LEDGER";T.METAMASK="METAMASK";T.OKX="OKX";T.OKX_MOBILE="OKX_MOBILE";T.PHANTOM="PHANTOM";T.POLKADOT_JS="POLKADOT_JS";T.RADIX_WALLET="RADIX_WALLET";T.TREZOR="TREZOR";T.TALISMAN="TALISMAN";T.TRUSTWALLET_WEB="TRUSTWALLET_WEB";T.WALLETCONNECT="WALLETCONNECT";T.XDEFI="XDEFI"})(xF||={});var zF;((H)=>{H[H.NoError=36864]="NoError";H[H.LockedDevice=21781]="LockedDevice";H[H.TC_NotFound=65535]="TC_NotFound"})(zF||={});var ZF;((H)=>{H.Average="average";H.Fast="fast";H.Fastest="fastest"})(ZF||={});var YF;((n)=>{n.Approve="approve";n.CheckOnly="checkOnly"})(YF||={});var nF;((O)=>{O.NAME_REGISTER="~";O.BOND="BOND";O.DEPOSIT="+";O.LEAVE="LEAVE";O.UNBOND="UNBOND";O.WITHDRAW="-";O.OPEN_LOAN="$+";O.CLOSE_LOAN="$-";O.RUNEPOOL_DEPOSIT="POOL+";O.RUNEPOOL_WITHDRAW="POOL-"})(nF||={});var wF;((h)=>{h.unknownError="unknownError";h.test_error="test_error";h.providerDetailsError="providerDetailsError";h.blockHeaderNotFound="blockHeaderNotFound";h.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";h.blockHashNotFoundAtHash="blockHashNotFoundAtHash";h.txHashMissing="txHashMissing";h.assetValueMissingInfo="assetValueMissingInfo";h.invalidAsset="invalidAsset";h.blockIsRequired="blockIsRequired";h.currentBlockHeaderNotFound="currentBlockHeaderNotFound";h.failedToRetrieveBalance="failedToRetrieveBalance";h.failedToRetrieveBlock="failedToRetrieveBlock";h.failedToRetrieveFees="failedToRetrieveFees";h.notImplementedBCH="notImplementedBCH";h.notImplementedDoge="notImplementedDoge";h.noPoolsFound="noPoolsFound";h.noVaultsFound="noVaultsFound";h.noTxFound="noTxFound";h.noInputCoinFound="noInputCoinFound";h.noBlockDataFound="noBlockDataFound";h.multipleCosmosMessages="multipleCosmosMessages";h.heightOrHashNotProvided="heightOrHashNotProvided";h.unknownDenom="unknownDenom";h.invalidBlockHeight="invalidBlockHeight";h.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";h.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";h.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";h.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";h.txMemoUndefined="txMemoUndefined";h.txMemoIncorrect="txMemoIncorrect";h.txTypeNotFound="txTypeNotFound";h.txNoMessage="txNoMessage";h.txNotFound="txNotFound";h.txReceiptNotFound="txReceiptNotFound";h.txParsingError="txParsingError";h.blockNotFound="blockNotFound";h.balanceNotFound="balanceNotFound";h.configError="configError";h.noQuoteResponse="noQuoteResponse";h.noPoolAssetsFound="noPoolAssetsFound";h.noThorchainPools="noThorchainPools";h.noMayachainPools="noMayachainPools";h.invalidAffiliateFee="invalidAffiliateFee";h.invalidBuyAssetAddress="invalidBuyAssetAddress";h.invalidSellAssetAddress="invalidSellAssetAddress";h.invalidSourceAddress="invalidSourceAddress";h.invalidDestinationAddress="invalidDestinationAddress";h.sourceAddressIsSmartContract="sourceAddressIsSmartContract";h.destinationAddressIsSmartContract="destinationAddressIsSmartContract";h.invalidChainId="invalidChainId";h.unsupportedChainId="unsupportedChainId";h.unsupportedEVMChainId="unsupportedEVMChainId";h.noWhitelistTokens="noWhitelistTokens";h.failedFetchGasPrice="failedFetchGasPrice";h.failedToCreateDepositChannel="failedToCreateDepositChannel";h.noProviderDetailsFound="noProviderDetailsFound";h.noTokenListsFound="noTokenListsFound";h.tokenNotFound="tokenNotFound";h.tokenPriceNotFound="tokenPriceNotFound";h.swapAmountTooSmall="swapAmountTooSmall";h.legsArrayIsEmpty="legsArrayIsEmpty";h.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";h.noBlockHeaderFound="noBlockHeaderFound";h.failedToSimulateSwap="failedToSimulateSwap";h.addressScreeningFailed="addressScreeningFailed";h.noLiquidtyProvidersFound="noLiquidtyProvidersFound";h.noSaversFound="noSaversFound";h.noInboundAddressesFound="noInboundAddressesFound";h.noInboundAddressFoundForChain="noInboundAddressFoundForChain";h.noLastBlocksFound="noLastBlocksFound";h.noVersionFound="noVersionFound";h.noConstantsFound="noConstantsFound";h.noMimirsFound="noMimirsFound";h.noRoutesFound="noRoutesFound";h.quoteNotFound="quoteNotFound";h.ledgerSignFailed="ledgerSignFailed";h.ledgerFetchSwapFailed="ledgerFetchSwapFailed";h.failedToFetchTx="failedToFetchTx";h.failedBuildTransactionDetails="failedBuildTransactionDetails";h.noLegsForRoute="noLegsForRoute";h.noRouterAddressFound="noRouterAddressFound";h.noAggregatorAddressFound="noAggregatorAddressFound";h.noContractInstanceFound="noContractInstanceFound";h.noContractAddressFound="noContractAddressFound";h.invalidAffiliate="invalidAffiliate";h.providerNotfound="No provider found";h.noRecordFound="No Record found";h.slippageTooLow="Slippage too low";h.tradingHalted="tradingHalted";h.noWrappedGasAsset="noWrappedGasAsset";h.aggregatorAddressNotFound="aggregatorAddressNotFound";h.routerAddressNotFound="routerAddressNotFound";h.dummyAddressNotFound="dummyAddressNotFound";h.trackerError="trackerError";h.noOhlcvDataFound="noOhlcvDataFound";h.noTradingPairs="noTradingPairs";h.noLoanPositionFound="noLoanPositionFound";h.noLendingAvailability="noLendingAvailability";h.lendingRepayTooSmall="lendingRepayTooSmall";h.missingState="missingState";h.ledgerSwapNotFound="ledgerSwapNotFound";h.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";h.errorEstimatingGas="errorEstimatingGas";h.apiKeyInvalid="apiKeyInvalid";h.apiKeyFailedToUpdate="apiKeyFailedToUpdate";h.apiKeyExpired="apiKeyExpired";h.unauthorized="unauthorized";h.failedToCreateMemo="failedToCreateMemo";h.radixIncorrectInstructions="radixIncorrectInstructions";h.invalidAddressForChain="invalidAddressForChain"})(wF||={});var QF;((n)=>{n.highSlippage="highSlippage";n.highPriceImpact="highPriceImpact"})(QF||={});var qF;(($)=>{$.CHAINFLIP="CHAINFLIP";$.TRADERJOE_V1="TRADERJOE_V1";$.PANGOLIN_V1="PANGOLIN_V1";$.UNISWAP_V2="UNISWAP_V2";$.THORCHAIN="THORCHAIN";$.THORCHAIN_STREAMING="THORCHAIN_STREAMING";$.MAYACHAIN="MAYACHAIN";$.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";$.ONEINCH="ONEINCH";$.SUSHISWAP_V2="SUSHISWAP_V2";$.WOOFI_V2="WOOFI_V2";$.PANCAKESWAP="PANCAKESWAP"})(qF||={});var BF;((k)=>{k.LIQUIDITY="liquidity";k.NETWORK="network";k.INBOUND="inbound";k.OUTBOUND="outbound";k.AFFILIATE="affiliate";k.TAX="tax"})(BF||={});import{red as IF,yellow as CF}from"picocolors";var WF={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,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,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,api_v2_invalid_response:50001,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,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=WF;constructor(F,x){const n=typeof F==="string",H=n?F:F.errorKey;if(x)console.error(x,{stack:x?.stack,message:x?.message});super(H,{cause:{code:J.ErrorCode[H],message:`${H}${n?"":`: ${JSON.stringify(F.info)}`}`}});Object.setPrototypeOf(this,J.prototype)}}function yx(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function vx(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function ox(F,x){try{return F()}catch(n){if(x)throw new J(x,n);return console.error(n)}}function Ex(F){switch(F){case"THOR":return`${F}.RUNE`;case"GAIA":return`${F}.ATOM`;case"BSC":return`${F}`;default:return`${F}.${F}`}}function NF(F,x){if(!KF&&F){if(HF.has(x))return;HF.add(x),console.warn(x)}}var KF=["production","test"].includes("development"),HF=new Set;function RF(F=""){const x=F.toUpperCase(),[n]=x.split(".");if(hF.includes(n))return!0;const[H]=x.split("/");if(hF.includes(H))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:F}})}function dx(F){if(F.length>30)return!1;const x=/^[a-zA-Z0-9+_-]+$/g;return!!F.match(x)}var hF=[...Object.values(Y),"TERRA"];function K({value:F,bigIntDecimal:x=S,decimal:n=S}){if(n===0)return F.toString();const H=F<0n;let N=F.toString().substring(H?1:0);const R=n-(N.length-1);if(R>0)N="0".repeat(R)+N;const k=N.length-n;let _=N.slice(-n);if(Number.parseInt(_[x]||"0")>=5)_=`${_.substring(0,x-1)}${(Number.parseInt(_[x-1]||"0")+1).toString()}`;else _=_.substring(0,x);return`${H?"-":""}${N.slice(0,k)}.${_}`.replace(/\.?0*$/,"")}function o(F){const n=`${typeof F==="number"?MF.format(F):i(F)}`.replaceAll(",",".").split(".");return n.length>1?`${n.slice(0,-1).join("")}.${n.at(-1)}`:n[0]||"0"}function kF(F){const x=F.split(".")[1]?.length||0;return Math.max(x,S)}function i(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var S=8,B=(F)=>10n**BigInt(F),V=(F)=>Math.log10(Number.parseFloat(F.toString()));class q{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,x){return new q({decimal:x,value:K({value:F,bigIntDecimal:x,decimal:x})})}static shiftDecimals({value:F,from:x,to:n}){return q.fromBigInt(F.getBaseValue("bigint")*B(n)/B(x),n)}constructor(F){const x=i(F),n=typeof F==="object";this.decimal=n?F.decimal:void 0,this.decimalMultiplier=n&&"decimalMultiplier"in F?F.decimalMultiplier:B(Math.max(kF(o(x)),this.decimal||0)),this.#N(x)}set(F){return new this.constructor({decimal:this.decimal,value:F,identifier:this.toString()})}add(...F){return this.#x("add",...F)}sub(...F){return this.#x("sub",...F)}mul(...F){return this.#x("mul",...F)}div(...F){return this.#x("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F){const x=this.formatBigIntToSafeValue(this.bigIntValue,this.decimal||V(this.decimalMultiplier));switch(F){case"number":return Number(x);case"string":return x;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(F){const x=this.decimalMultiplier/B(this.decimal||8),n=this.bigIntValue/x;switch(F){case"number":return Number(n);case"string":return n.toString();case"bigint":return n}}getBigIntValue(F,x){if(!x&&typeof F==="object")return F.bigIntValue;const n=i(F),H=o(n);if(H==="0"||H==="undefined")return 0n;return this.#H(H,x)}toSignificant(F=6){const[x,n]=this.getValue("string").split("."),H=x||"",N=n||"";if((Number.parseInt(H)?H.length+N.length:N.length)<=F)return this.getValue("string");if(H.length>=F)return H.slice(0,F).padEnd(H.length,"0");if(Number.parseInt(H))return`${H}.${N.slice(0,F-H.length)}`.padEnd(F-H.length,"0");const k=Number.parseInt(N),_=`${k}`.slice(0,F);return`0.${_.padStart(N.length-`${k}`.length+_.length,"0")}`}toFixed(F=6){const[x,n]=this.getValue("string").split("."),H=x||"",N=n||"";if(Number.parseInt(H))return`${H}.${N.slice(0,F)}`.padEnd(F,"0");const R=Number.parseInt(N),k=`${R}`.slice(0,F);return`0.${k.padStart(N.length-`${R}`.length+k.length,"0")}`}toAbbreviation(F=2){const x=this.getValue("number"),n=["","K","M","B","T","Q","Qi","S"],H=Math.floor(Math.log10(Math.abs(x))/3),N=n[H];if(!N)return this.getValue("string");const R=10**(H*3);return`${(x/R).toFixed(F)}${N}`}toCurrency(F="$",{currencyPosition:x="start",decimal:n=2,decimalSeparator:H=".",thousandSeparator:N=","}={}){const R=this.getValue("number"),[k="",_=""]=R.toFixed(6).split("."),P=k.replace(/\B(?=(\d{3})+(?!\d))/g,N),G=k||_?k==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",H):`${P}${Number.parseInt(_)?`${H}${_.slice(0,n)}`:""}`:"0.00";return`${x==="start"?F:""}${G}${x==="end"?F:""}`}formatBigIntToSafeValue(F,x){const n=x||this.decimal||S,H=Math.max(n,V(this.decimalMultiplier)),N=F<0n,R=F.toString().substring(N?1:0),k=H-(R.length-1),_=k>0?"0".repeat(k)+R:R,P=_.length-H;let G=_.slice(-H);if(Number.parseInt(G[n]||"0")>=5)G=`${G.substring(0,n-1)}${(Number.parseInt(G[n-1]||"0")+1).toString()}`;else G=G.substring(0,n);return`${N?"-":""}${_.slice(0,P)}.${G}`.replace(/\.?0*$/,"")}#x(F,...x){const n=this.#n(this,...x),H=Math.max(n,V(this.decimalMultiplier)),N=B(H),R=x.reduce((_,P)=>{const G=this.getBigIntValue(P,H);switch(F){case"add":return _+G;case"sub":return _-G;case"mul":return _*G/N;case"div":{if(G===0n)throw new RangeError("Division by zero");return _*N/G}default:return _}},this.bigIntValue*N/this.decimalMultiplier),k=K({bigIntDecimal:H,decimal:H,value:R});return new this.constructor({decimalMultiplier:B(H),decimal:this.decimal,value:k,identifier:this.toString()})}#F(F,...x){const n=this.#n(this,...x),H=this.getBigIntValue(x[0]||"0",n),N=this.getBigIntValue(this,n);switch(F){case"gt":return N>H;case"gte":return N>=H;case"lt":return N<H;case"lte":return N<=H;case"eqValue":return N===H}}#N(F){const x=o(F)||"0";this.bigIntValue=this.#H(x)}#n(...F){const x=F.map((n)=>{return typeof n==="object"?n.decimal||V(n.decimalMultiplier):kF(o(n))}).filter(Boolean);return Math.max(...x,S)}#H(F,x){const n=x?B(x):this.decimalMultiplier,H=V(n),[N="",R=""]=F.split(".");return BigInt(`${N}${R.padEnd(H,"0")}`)}}var MF=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function nn(F){const x=X.from({chain:F});switch(F){case"BTC":case"LTC":case"BCH":case"DASH":return x.set(0.00010001);case"DOGE":return x.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return x.set(0.00000001);case"THOR":case"MAYA":return x.set(0);case"GAIA":case"KUJI":return x.set(0.000001);default:return x.set(0.00000001)}}async function VF(F,x=0){RF(F);const n=E.get(F.toUpperCase()),H=n?.decimal||await _F(l(F));if(!n)E.set(F.toUpperCase(),{identifier:F,decimal:H});return new X({decimal:H,value:b(x,H),identifier:F})}function SF(F,x=0){const n=F.split(".")?.[0]?.toUpperCase(),H=n?["MAYA","THOR"].includes(n):!1,[N,R]=H?F.split(".").slice(1).join().split("/"):F.split("/");if(!(N&&R&&H))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new X({decimal:8,value:b(x,8),identifier:`${n}.${N}/${R}`})}function b(F,x){return typeof F==="bigint"?K({value:F,bigIntDecimal:x,decimal:x}):F}function l(F){const x=F.slice(0,14).includes("/"),n=F.split(".")?.[0]?.toUpperCase()==="THOR",H=F.split(".")?.[0]?.toUpperCase()==="MAYA",[N,R=""]=n||H?F.split(".").slice(1).join().split("/"):F.split("/");if(x&&!(N&&R))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});const k=F.includes(".")&&!x?F:`${H?"MAYA":"THOR"}.${R}`,[_,...P]=k.split("."),G=x?R:P.join("."),O=G.split("-"),Z=O.length===1?O[0]:O.slice(0,-1).join("-"),$=O.length===1?void 0:O[O.length-1];return{address:$?.toLowerCase(),chain:_,isGasAsset:a({chain:_,symbol:G}),isSynthetic:x,ticker:Z,symbol:(x?`${N}/`:"")+($?`${Z}-${$?.toLowerCase()??""}`:G)}}var E=new Map;class X extends q{address;chain;isGasAsset=!1;isSynthetic=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:x,tax:n,chain:H,symbol:N,identifier:R}){super(typeof F==="object"?F:{decimal:x,value:F});const k=l(R||`${H}.${N}`);this.type=OF(k),this.tax=n,this.chain=k.chain,this.ticker=k.ticker,this.symbol=k.symbol,this.address=k.address,this.isSynthetic=k.isSynthetic,this.isGasAsset=k.isGasAsset,this.chainId=FF[k.chain]}toString(){return this.isSynthetic?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.toString()}eqAsset({chain:F,symbol:x}){return this.chain===F&&this.symbol===x}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,x=0){const[n,H,N]=F.split(".");if(!(n&&H))throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});const R=n==="THOR"&&N?`${n}.${H}/${N}`:F;return X.from({asset:R,value:x})}static from({value:F=0,fromBaseDecimal:x,asyncTokenLookup:n,...H}){const N=F instanceof q?F.getValue("string"):F,R="chain"in H,k=R?H.chain:H.asset,_=R||TF.includes(k),{identifier:P,decimal:G}=_?GF(k):{identifier:k,decimal:void 0},{chain:O,isSynthetic:Z}=l(P),$=E.get(P.toUpperCase()),f=$?.decimal||G;NF(!(n||f),CF(`Couldn't find static decimal for ${IF(P)} (Using default ${IF(z[O])} decimal as fallback).
var e=((x)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(x,{get:(F,n)=>(typeof require!=="undefined"?require:F)[n]}):x)(function(x){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});export*from"@swapkit/contracts";var d;((O)=>{O.Arbitrum="https://arb1.arbitrum.io/rpc";O.Avalanche="https://node-router.thorswap.net/avalanche-c";O.BinanceSmartChain="https://bsc-dataseed.binance.org";O.Bitcoin="https://node-router.thorswap.net/bitcoin";O.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";O.Chainflip="wss://mainnet-archive.chainflip.io";O.Cosmos="https://node-router.thorswap.net/cosmos/rpc";O.Dash="https://node-router.thorswap.net/dash";O.Dogecoin="https://node-router.thorswap.net/dogecoin";O.Ethereum="https://node-router.thorswap.net/ethereum";O.Kujira="https://rpc-kujira.synergynodes.com/";O.Litecoin="https://node-router.thorswap.net/litecoin";O.Maya="https://tendermint.mayachain.info";O.MayaStagenet="https://stagenet.tendermint.mayachain.info";O.Optimism="https://mainnet.optimism.io";O.Polkadot="wss://rpc.polkadot.io";O.Polygon="https://polygon-rpc.com";O.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";O.THORChain="https://rpc.thorswap.net";O.THORChainStagenet="https://stagenet-rpc.ninerealms.com";O.Solana="https://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80"})(d||={});var t;((k)=>{k.Arbitrum="https://arbiscan.io";k.Avalanche="https://snowtrace.io";k.BinanceSmartChain="https://bscscan.com";k.Bitcoin="https://blockchair.com/bitcoin";k.BitcoinCash="https://www.blockchair.com/bitcoin-cash";k.Chainflip="https://explorer.polkascan.io/polkadot";k.Cosmos="https://www.mintscan.io/cosmos";k.Dash="https://blockchair.com/dash";k.Dogecoin="https://blockchair.com/dogecoin";k.Ethereum="https://etherscan.io";k.Kujira="https://finder.kujira.network/kaiyo-1";k.Litecoin="https://blockchair.com/litecoin";k.Maya="https://www.mayascan.org";k.Optimism="https://optimistic.etherscan.io";k.Polkadot="https://polkadot.subscan.io";k.Polygon="https://polygonscan.com";k.Radix="https://dashboard.radixdlt.com";k.THORChain="https://runescan.io";k.Solana="https://solscan.io"})(t||={});var Y;((k)=>{k.Arbitrum="ARB";k.Avalanche="AVAX";k.BinanceSmartChain="BSC";k.Bitcoin="BTC";k.BitcoinCash="BCH";k.Cosmos="GAIA";k.Dash="DASH";k.Dogecoin="DOGE";k.Ethereum="ETH";k.Kujira="KUJI";k.Litecoin="LTC";k.Maya="MAYA";k.Optimism="OP";k.Polkadot="DOT";k.Chainflip="FLIP";k.Polygon="MATIC";k.Radix="XRD";k.THORChain="THOR";k.Solana="SOL"})(Y||={});var u;((P)=>{P.Arbitrum="42161";P.ArbitrumHex="0xa4b1";P.Avalanche="43114";P.AvalancheHex="0xa86a";P.BinanceSmartChain="56";P.BinanceSmartChainHex="0x38";P.Bitcoin="bitcoin";P.BitcoinCash="bitcoincash";P.Chainflip="chainflip";P.Cosmos="cosmoshub-4";P.Dash="dash";P.Dogecoin="dogecoin";P.Kujira="kaiyo-1";P.Ethereum="1";P.EthereumHex="0x1";P.Litecoin="litecoin";P.Maya="mayachain-mainnet-v1";P.MayaStagenet="mayachain-stagenet-v1";P.Optimism="10";P.OptimismHex="0xa";P.Polkadot="polkadot";P.Polygon="137";P.PolygonHex="0x89";P.Radix="radix-mainnet";P.THORChain="thorchain-mainnet-v1";P.THORChainStagenet="thorchain-stagenet-v2";P.Solana="solana"})(u||={});var kF={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["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-mainnet-v1"]:"THOR",["solana"]:"SOL"},$x=Object.keys(Y),C=Object.values(Y),z;((T)=>{T[T.ARB=18]="ARB";T[T.AVAX=18]="AVAX";T[T.BCH=8]="BCH";T[T.BSC=18]="BSC";T[T.BTC=8]="BTC";T[T.DASH=8]="DASH";T[T.DOGE=8]="DOGE";T[T.DOT=10]="DOT";T[T.ETH=18]="ETH";T[T.FLIP=18]="FLIP";T[T.GAIA=6]="GAIA";T[T.KUJI=6]="KUJI";T[T.LTC=8]="LTC";T[T.MATIC=18]="MATIC";T[T.MAYA=8]="MAYA";T[T.OP=18]="OP";T[T.SOL=9]="SOL";T[T.THOR=8]="THOR";T[T.XRD=18]="XRD";T[T.ZEC=8]="ZEC"})(z||={});var TF=["DOT","FLIP"],y=["ETH","AVAX","BSC","ARB","OP","MATIC"],_F=["BTC","BCH","DASH","DOGE","LTC"],GF=["GAIA","THOR","MAYA","KUJI"],LF=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],PF=["ARB","DASH","ETH","KUJI","MAYA","THOR"],v=C.reduce((x,F)=>{const n=$x.find((H)=>Y[H]===F);if(n)x[F]=n;return x},{}),xx=C.reduce((x,F)=>{return x[F]=u[v[F]],x},{}),m=C.reduce((x,F)=>{return x[F]=d[v[F]],x},{}),AF=C.reduce((x,F)=>{const n=`${v[F]}Hex`;return x[F]=u[n],x},{}),OF=C.reduce((x,F)=>{return x[F]=t[v[F]],x},{});var Xx;((X)=>{X.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";X.TC_SUPPORTED_TO_ETH="TC-ERC20";X.TC_SUPPORTED_TO_AVAX="TC-ARC20";X.TC_SUPPORTED_TO_BSC="TC-BEP20";X.ETH_TO_TC_SUPPORTED="ERC20-TC";X.ETH_TO_ETH="ERC20-ERC20";X.ETH_TO_AVAX="ERC20-ARC20";X.ETH_TO_BSC="ERC20-BEP20";X.AVAX_TO_TC_SUPPORTED="ARC20-TC";X.AVAX_TO_ETH="ARC20-ERC20";X.AVAX_TO_AVAX="ARC20-ARC20";X.AVAX_TO_BSC="ARC20-BEP20";X.BSC_TO_TC_SUPPORTED="BEP20-TC";X.BSC_TO_ETH="BEP20-ERC20";X.BSC_TO_AVAX="BEP20-ARC20";X.BSC_TO_BSC="BEP20-BEP20"})(Xx||={});var XF=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],jF=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],JF=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var jx;((I)=>{I.ARB="0x0000000000000000000000000000000000000000";I.AVAX="0x0000000000000000000000000000000000000000";I.ETH="0x0000000000000000000000000000000000000000";I.BSC="0x0000000000000000000000000000000000000000";I.MATIC="0x0000000000000000000000000000000000001010";I.OP="0x4200000000000000000000000000000000000042"})(jx||={});var Jx;((k)=>{k.ARB="m/44'/60'/0'/0";k.AVAX="m/44'/60'/0'/0";k.BCH="m/44'/145'/0'/0";k.BSC="m/44'/60'/0'/0";k.BTC="m/84'/0'/0'/0";k.DASH="m/44'/5'/0'/0";k.DOGE="m/44'/3'/0'/0";k.DOT="////";k.ETH="m/44'/60'/0'/0";k.FLIP="////";k.GAIA="m/44'/118'/0'/0";k.KUJI="m/44'/118'/0'/0";k.LTC="m/84'/2'/0'/0";k.MATIC="m/44'/60'/0'/0";k.MAYA="m/44'/931'/0'/0";k.OP="m/44'/60'/0'/0";k.SOL="m/44'/501'/0'/0";k.THOR="m/44'/931'/0'/0";k.XRD="////"})(Jx||={});var s={ARB:[44,60,0,0,0],AVAX:[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 Fx;((T)=>{T.BRAVE="BRAVE";T.COINBASE_MOBILE="COINBASE_MOBILE";T.COINBASE_WEB="COINBASE_WEB";T.EIP6963="EIP6963";T.EXODUS="EXODUS";T.KEEPKEY="KEEPKEY";T.KEPLR="KEPLR";T.KEYSTORE="KEYSTORE";T.LEDGER="LEDGER";T.METAMASK="METAMASK";T.OKX="OKX";T.OKX_MOBILE="OKX_MOBILE";T.PHANTOM="PHANTOM";T.POLKADOT_JS="POLKADOT_JS";T.RADIX_WALLET="RADIX_WALLET";T.TREZOR="TREZOR";T.TALISMAN="TALISMAN";T.TRUSTWALLET_WEB="TRUSTWALLET_WEB";T.WALLETCONNECT="WALLETCONNECT";T.XDEFI="XDEFI"})(Fx||={});var zx;((H)=>{H[H.NoError=36864]="NoError";H[H.LockedDevice=21781]="LockedDevice";H[H.TC_NotFound=65535]="TC_NotFound"})(zx||={});var Zx;((H)=>{H.Average="average";H.Fast="fast";H.Fastest="fastest"})(Zx||={});var Yx;((n)=>{n.Approve="approve";n.CheckOnly="checkOnly"})(Yx||={});var nx;((L)=>{L.NAME_REGISTER="~";L.BOND="BOND";L.DEPOSIT="+";L.LEAVE="LEAVE";L.UNBOND="UNBOND";L.WITHDRAW="-";L.OPEN_LOAN="$+";L.CLOSE_LOAN="$-";L.RUNEPOOL_DEPOSIT="POOL+";L.RUNEPOOL_WITHDRAW="POOL-"})(nx||={});var wx;((h)=>{h.unknownError="unknownError";h.test_error="test_error";h.providerDetailsError="providerDetailsError";h.blockHeaderNotFound="blockHeaderNotFound";h.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";h.blockHashNotFoundAtHash="blockHashNotFoundAtHash";h.txHashMissing="txHashMissing";h.assetValueMissingInfo="assetValueMissingInfo";h.invalidAsset="invalidAsset";h.blockIsRequired="blockIsRequired";h.currentBlockHeaderNotFound="currentBlockHeaderNotFound";h.failedToRetrieveBalance="failedToRetrieveBalance";h.failedToRetrieveBlock="failedToRetrieveBlock";h.failedToRetrieveFees="failedToRetrieveFees";h.notImplementedBCH="notImplementedBCH";h.notImplementedDoge="notImplementedDoge";h.noPoolsFound="noPoolsFound";h.noVaultsFound="noVaultsFound";h.noTxFound="noTxFound";h.noInputCoinFound="noInputCoinFound";h.noBlockDataFound="noBlockDataFound";h.multipleCosmosMessages="multipleCosmosMessages";h.heightOrHashNotProvided="heightOrHashNotProvided";h.unknownDenom="unknownDenom";h.invalidBlockHeight="invalidBlockHeight";h.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";h.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";h.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";h.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";h.txMemoUndefined="txMemoUndefined";h.txMemoIncorrect="txMemoIncorrect";h.txTypeNotFound="txTypeNotFound";h.txNoMessage="txNoMessage";h.txNotFound="txNotFound";h.txReceiptNotFound="txReceiptNotFound";h.txParsingError="txParsingError";h.blockNotFound="blockNotFound";h.balanceNotFound="balanceNotFound";h.configError="configError";h.noQuoteResponse="noQuoteResponse";h.noPoolAssetsFound="noPoolAssetsFound";h.noThorchainPools="noThorchainPools";h.noMayachainPools="noMayachainPools";h.invalidAffiliateFee="invalidAffiliateFee";h.invalidBuyAssetAddress="invalidBuyAssetAddress";h.invalidSellAssetAddress="invalidSellAssetAddress";h.invalidSourceAddress="invalidSourceAddress";h.invalidDestinationAddress="invalidDestinationAddress";h.sourceAddressIsSmartContract="sourceAddressIsSmartContract";h.destinationAddressIsSmartContract="destinationAddressIsSmartContract";h.invalidChainId="invalidChainId";h.unsupportedChainId="unsupportedChainId";h.unsupportedEVMChainId="unsupportedEVMChainId";h.noWhitelistTokens="noWhitelistTokens";h.failedFetchGasPrice="failedFetchGasPrice";h.failedToCreateDepositChannel="failedToCreateDepositChannel";h.noProviderDetailsFound="noProviderDetailsFound";h.noTokenListsFound="noTokenListsFound";h.tokenNotFound="tokenNotFound";h.tokenPriceNotFound="tokenPriceNotFound";h.swapAmountTooSmall="swapAmountTooSmall";h.legsArrayIsEmpty="legsArrayIsEmpty";h.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";h.noBlockHeaderFound="noBlockHeaderFound";h.failedToSimulateSwap="failedToSimulateSwap";h.addressScreeningFailed="addressScreeningFailed";h.noLiquidtyProvidersFound="noLiquidtyProvidersFound";h.noSaversFound="noSaversFound";h.noInboundAddressesFound="noInboundAddressesFound";h.noInboundAddressFoundForChain="noInboundAddressFoundForChain";h.noLastBlocksFound="noLastBlocksFound";h.noVersionFound="noVersionFound";h.noConstantsFound="noConstantsFound";h.noMimirsFound="noMimirsFound";h.noRoutesFound="noRoutesFound";h.quoteNotFound="quoteNotFound";h.ledgerSignFailed="ledgerSignFailed";h.ledgerFetchSwapFailed="ledgerFetchSwapFailed";h.failedToFetchTx="failedToFetchTx";h.failedBuildTransactionDetails="failedBuildTransactionDetails";h.noLegsForRoute="noLegsForRoute";h.noRouterAddressFound="noRouterAddressFound";h.noAggregatorAddressFound="noAggregatorAddressFound";h.noContractInstanceFound="noContractInstanceFound";h.noContractAddressFound="noContractAddressFound";h.invalidAffiliate="invalidAffiliate";h.providerNotfound="No provider found";h.noRecordFound="No Record found";h.slippageTooLow="Slippage too low";h.tradingHalted="tradingHalted";h.noWrappedGasAsset="noWrappedGasAsset";h.aggregatorAddressNotFound="aggregatorAddressNotFound";h.routerAddressNotFound="routerAddressNotFound";h.dummyAddressNotFound="dummyAddressNotFound";h.trackerError="trackerError";h.noOhlcvDataFound="noOhlcvDataFound";h.noTradingPairs="noTradingPairs";h.noLoanPositionFound="noLoanPositionFound";h.noLendingAvailability="noLendingAvailability";h.lendingRepayTooSmall="lendingRepayTooSmall";h.missingState="missingState";h.ledgerSwapNotFound="ledgerSwapNotFound";h.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";h.errorEstimatingGas="errorEstimatingGas";h.apiKeyInvalid="apiKeyInvalid";h.apiKeyFailedToUpdate="apiKeyFailedToUpdate";h.apiKeyExpired="apiKeyExpired";h.unauthorized="unauthorized";h.failedToCreateMemo="failedToCreateMemo";h.radixIncorrectInstructions="radixIncorrectInstructions";h.invalidAddressForChain="invalidAddressForChain"})(wx||={});var Qx;((n)=>{n.highSlippage="highSlippage";n.highPriceImpact="highPriceImpact"})(Qx||={});var qx;((J)=>{J.CHAINFLIP="CHAINFLIP";J.MAYACHAIN="MAYACHAIN";J.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";J.ONEINCH="ONEINCH";J.PANCAKESWAP="PANCAKESWAP";J.PANGOLIN_V1="PANGOLIN_V1";J.SUSHISWAP_V2="SUSHISWAP_V2";J.THORCHAIN="THORCHAIN";J.THORCHAIN_STREAMING="THORCHAIN_STREAMING";J.TRADERJOE_V2="TRADERJOE_V2";J.UNISWAP_V2="UNISWAP_V2";J.UNISWAP_V3="UNISWAP_V3";J.CAVIAR_V1="CAVIAR_V1"})(qx||={});var Bx;((I)=>{I.LIQUIDITY="liquidity";I.NETWORK="network";I.INBOUND="inbound";I.OUTBOUND="outbound";I.AFFILIATE="affiliate";I.TAX="tax"})(Bx||={});import{red as kx,yellow as Mx}from"picocolors";var Wx={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,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,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,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,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=Wx;constructor(x,F){const n=typeof x==="string",H=n?x:x.errorKey;if(F)console.error(F,{stack:F?.stack,message:F?.message});super(H,{cause:{code:j.ErrorCode[H],message:`${H}${n?"":`: ${JSON.stringify(x.info)}`}`}});Object.setPrototypeOf(this,j.prototype)}}function yF(x){if(x<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:x}});return 10+x}function vF(x){if(x<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:x}});return Math.round((10+x*1.0512)*10000000000)/10000000000}function oF(x,F){try{return x()}catch(n){if(F)throw new j(F,n);return console.error(n)}}function EF(x){switch(x){case"THOR":return`${x}.RUNE`;case"GAIA":return`${x}.ATOM`;case"BSC":return`${x}`;default:return`${x}.${x}`}}function Nx(x,F){if(!Kx&&x){if(Hx.has(F))return;Hx.add(F),console.warn(F)}}var Kx=["production","test"].includes("development"),Hx=new Set;function Rx(x=""){const F=x.toUpperCase(),[n]=F.split(".");if(hx.includes(n))return!0;const[H]=F.split("/");if(hx.includes(H))return!0;throw new j({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${x}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:x}})}function dF(x){if(x.length>30)return!1;const F=/^[a-zA-Z0-9+_-]+$/g;return!!x.match(F)}var hx=[...Object.values(Y),"TERRA"];function V({value:x,bigIntDecimal:F=U,decimal:n=U}){if(n===0)return x.toString();const H=x<0n;let N=x.toString().substring(H?1:0);const R=n-(N.length-1);if(R>0)N="0".repeat(R)+N;const I=N.length-n;let _=N.slice(-n);if(Number.parseInt(_[F]||"0")>=5)_=`${_.substring(0,F-1)}${(Number.parseInt(_[F-1]||"0")+1).toString()}`;else _=_.substring(0,F);return`${H?"-":""}${N.slice(0,I)}.${_}`.replace(/\.?0*$/,"")}function o(x){const n=`${typeof x==="number"?Vx.format(x):i(x)}`.replaceAll(",",".").split(".");return n.length>1?`${n.slice(0,-1).join("")}.${n.at(-1)}`:n[0]||"0"}function Ix(x){const F=x.split(".")[1]?.length||0;return Math.max(F,U)}function i(x){return typeof x==="object"?"getValue"in x?x.getValue("string"):x.value:x}var U=8,W=(x)=>10n**BigInt(x),S=(x)=>Math.log10(Number.parseFloat(x.toString()));class B{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(x,F){return new B({decimal:F,value:V({value:x,bigIntDecimal:F,decimal:F})})}static shiftDecimals({value:x,from:F,to:n}){return B.fromBigInt(x.getBaseValue("bigint")*W(n)/W(F),n)}constructor(x){const F=i(x),n=typeof x==="object";this.decimal=n?x.decimal:void 0,this.decimalMultiplier=n&&"decimalMultiplier"in x?x.decimalMultiplier:W(Math.max(Ix(o(F)),this.decimal||0)),this.#N(F)}set(x){return new this.constructor({decimal:this.decimal,value:x,identifier:this.toString()})}add(...x){return this.#F("add",...x)}sub(...x){return this.#F("sub",...x)}mul(...x){return this.#F("mul",...x)}div(...x){return this.#F("div",...x)}gt(x){return this.#x("gt",x)}gte(x){return this.#x("gte",x)}lt(x){return this.#x("lt",x)}lte(x){return this.#x("lte",x)}eqValue(x){return this.#x("eqValue",x)}getValue(x){const F=this.formatBigIntToSafeValue(this.bigIntValue,this.decimal||S(this.decimalMultiplier));switch(x){case"number":return Number(F);case"string":return F;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(x){const F=this.decimalMultiplier/W(this.decimal||8),n=this.bigIntValue/F;switch(x){case"number":return Number(n);case"string":return n.toString();case"bigint":return n}}getBigIntValue(x,F){if(!F&&typeof x==="object")return x.bigIntValue;const n=i(x),H=o(n);if(H==="0"||H==="undefined")return 0n;return this.#H(H,F)}toSignificant(x=6){const[F,n]=this.getValue("string").split("."),H=F||"",N=n||"";if((Number.parseInt(H)?H.length+N.length:N.length)<=x)return this.getValue("string");if(H.length>=x)return H.slice(0,x).padEnd(H.length,"0");if(Number.parseInt(H))return`${H}.${N.slice(0,x-H.length)}`.padEnd(x-H.length,"0");const I=Number.parseInt(N),_=`${I}`.slice(0,x);return`0.${_.padStart(N.length-`${I}`.length+_.length,"0")}`}toFixed(x=6){const[F,n]=this.getValue("string").split("."),H=F||"",N=n||"";if(Number.parseInt(H))return`${H}.${N.slice(0,x)}`.padEnd(x,"0");const R=Number.parseInt(N),I=`${R}`.slice(0,x);return`0.${I.padStart(N.length-`${R}`.length+I.length,"0")}`}toAbbreviation(x=2){const F=this.getValue("number"),n=["","K","M","B","T","Q","Qi","S"],H=Math.floor(Math.log10(Math.abs(F))/3),N=n[H];if(!N)return this.getValue("string");const R=10**(H*3);return`${(F/R).toFixed(x)}${N}`}toCurrency(x="$",{currencyPosition:F="start",decimal:n=2,decimalSeparator:H=".",thousandSeparator:N=","}={}){const R=this.getValue("number"),[I="",_=""]=R.toFixed(6).split("."),A=I.replace(/\B(?=(\d{3})+(?!\d))/g,N),G=I||_?I==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",H):`${A}${Number.parseInt(_)?`${H}${_.slice(0,n)}`:""}`:"0.00";return`${F==="start"?x:""}${G}${F==="end"?x:""}`}formatBigIntToSafeValue(x,F){const n=F||this.decimal||U,H=Math.max(n,S(this.decimalMultiplier)),N=x<0n,R=x.toString().substring(N?1:0),I=H-(R.length-1),_=I>0?"0".repeat(I)+R:R,A=_.length-H;let G=_.slice(-H);if(Number.parseInt(G[n]||"0")>=5)G=`${G.substring(0,n-1)}${(Number.parseInt(G[n-1]||"0")+1).toString()}`;else G=G.substring(0,n);return`${N?"-":""}${_.slice(0,A)}.${G}`.replace(/\.?0*$/,"")}#F(x,...F){const n=this.#n(this,...F),H=Math.max(n,S(this.decimalMultiplier)),N=W(H),R=F.reduce((_,A)=>{const G=this.getBigIntValue(A,H);switch(x){case"add":return _+G;case"sub":return _-G;case"mul":return _*G/N;case"div":{if(G===0n)throw new RangeError("Division by zero");return _*N/G}default:return _}},this.bigIntValue*N/this.decimalMultiplier),I=V({bigIntDecimal:H,decimal:H,value:R});return new this.constructor({decimalMultiplier:W(H),decimal:this.decimal,value:I,identifier:this.toString()})}#x(x,...F){const n=this.#n(this,...F),H=this.getBigIntValue(F[0]||"0",n),N=this.getBigIntValue(this,n);switch(x){case"gt":return N>H;case"gte":return N>=H;case"lt":return N<H;case"lte":return N<=H;case"eqValue":return N===H}}#N(x){const F=o(x)||"0";this.bigIntValue=this.#H(F)}#n(...x){const F=x.map((n)=>{return typeof n==="object"?n.decimal||S(n.decimalMultiplier):Ix(o(n))}).filter(Boolean);return Math.max(...F,U)}#H(x,F){const n=F?W(F):this.decimalMultiplier,H=S(n),[N="",R=""]=x.split(".");return BigInt(`${N}${R.padEnd(H,"0")}`)}}var Vx=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function nn(x){const F=$.from({chain:x});switch(x){case"BTC":case"LTC":case"BCH":case"DASH":return F.set(0.00010001);case"DOGE":return F.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return F.set(0.00000001);case"THOR":case"MAYA":return F.set(0);case"GAIA":case"KUJI":return F.set(0.000001);default:return F.set(0.00000001)}}async function Cx(x,F=0){Rx(x);const n=E.get(x.toUpperCase()),H=n?.decimal||await _x(l(x));if(!n)E.set(x.toUpperCase(),{identifier:x,decimal:H});return new $({decimal:H,value:b(F,H),identifier:x})}function Sx(x,F=0){const n=x.split(".")?.[0]?.toUpperCase(),H=n?["MAYA","THOR"].includes(n):!1,[N,R]=H?x.split(".").slice(1).join().split("/"):x.split("/");if(!(N&&R&&H))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:x}});return new $({decimal:8,value:b(F,8),identifier:`${n}.${N}/${R}`})}function b(x,F){return typeof x==="bigint"?V({value:x,bigIntDecimal:F,decimal:F}):x}function l(x){const F=x.slice(0,14).includes("/"),n=x.split(".")?.[0]?.toUpperCase()==="THOR",H=x.split(".")?.[0]?.toUpperCase()==="MAYA",[N,R=""]=n||H?x.split(".").slice(1).join().split("/"):x.split("/");if(F&&!(N&&R))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:x}});const I=x.includes(".")&&!F?x:`${H?"MAYA":"THOR"}.${R}`,[_,...A]=I.split("."),G=F?R:A.join("."),L=G.split("-"),Z=L.length===1?L[0]:L.slice(0,-1).join("-"),Q=L.length===1?void 0:L[L.length-1];return{address:Q?.toLowerCase(),chain:_,isGasAsset:a({chain:_,symbol:G}),isSynthetic:F,ticker:Z,symbol:(F?`${N}/`:"")+(Q?`${Z}-${Q?.toLowerCase()??""}`:G)}}var E=new Map;class $ extends B{address;chain;isGasAsset=!1;isSynthetic=!1;symbol;tax;ticker;type;chainId;constructor({value:x,decimal:F,tax:n,chain:H,symbol:N,identifier:R}){super(typeof x==="object"?x:{decimal:F,value:x});const I=l(R||`${H}.${N}`);this.type=Lx(I),this.tax=n,this.chain=I.chain,this.ticker=I.ticker,this.symbol=I.symbol,this.address=I.address,this.isSynthetic=I.isSynthetic,this.isGasAsset=I.isGasAsset,this.chainId=xx[I.chain]}toString(){return this.isSynthetic?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.toString()}eqAsset({chain:x,symbol:F}){return this.chain===x&&this.symbol===F}eq(x){return this.eqAsset(x)&&this.eqValue(x)}static fromUrl(x,F=0){const[n,H,N]=x.split(".");if(!(n&&H))throw new j({errorKey:"helpers_invalid_asset_url",info:{urlAsset:x}});const R=n==="THOR"&&N?`${n}.${H}/${N}`:x;return $.from({asset:R,value:F})}static from({value:x=0,fromBaseDecimal:F,asyncTokenLookup:n,...H}){const N=x instanceof B?x.getValue("string"):x,R="chain"in H,I=R?H.chain:H.asset,_=R||Tx.includes(I),{identifier:A,decimal:G}=_?Gx(I):{identifier:I,decimal:void 0},{chain:L,isSynthetic:Z}=l(A),Q=E.get(A.toUpperCase()),J=Q?.decimal||G;Nx(!(n||J),Mx(`Couldn't find static decimal for ${kx(A)} (Using default ${kx(z[L])} 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.`));const{decimal:p,identifier:M,tax:j}=$||{decimal:f||z[O],identifier:P},W=x?b(BigInt(N),x):b(N,p);return n?VF(M,x?W:N):Z?SF(M,W):new X({tax:j,decimal:p,identifier:M,value:W})}static loadStaticAssets(){return new Promise((F,x)=>{try{import("@swapkit/tokens").then((n)=>{for(let H of Object.values(n))for(let{identifier:N,chain:R,...k}of H.tokens)E.set(N.toUpperCase(),{identifier:N,decimal:"decimals"in k?k.decimals:z[R]});F({ok:!0})})}catch(n){console.error(n),x({ok:!1,error:n,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(F,x=0){return X.from({asset:F,value:x,asyncTokenLookup:!0})}static fromIdentifier(F,x=0){return X.from({asset:F,value:x,asyncTokenLookup:!0})}static fromStringSync(F,x=0){return X.from({asset:F,value:x})}static fromStringWithBase(F,x=0n,n=8){return X.from({asyncTokenLookup:!0,asset:F,value:x,fromBaseDecimal:n})}static fromStringWithBaseSync(F,x=0n,n=8){return X.from({asset:F,value:x,fromBaseDecimal:n})}static fromIdentifierSync(F,x=0){return X.from({asset:F,value:x})}static fromChainOrSignature(F,x=0){if(Object.values(Y).includes(F))return X.from({chain:F,value:x});return X.from({asset:F,value:x})}}function Nn({apiKey:F,...x}){r={...x,apiKey:F}}async function D(F,x){const{apiKey:n,...H}=r,{searchParams:N,json:R,body:k}=x,_={...UF,...H.headers,...x.headers,...R?{"Content-Type":"application/json"}:{}},P=R?JSON.stringify(R):k,G=new URL(F);if(N)G.search=new URLSearchParams(N).toString();if(n)_["x-api-key"]=n;try{const Z=await(await fetch(G.toString(),{...H,...x,body:P,headers:_})).json();if(x.responseHandler)return x.responseHandler(Z);return Z}catch(O){if(x.onError)return x.onError(O);console.error(O)}}var r={},UF=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},c={get:async(F,x)=>D(F,{...x,method:"GET"}),post:async(F,x)=>D(F,{...x,method:"POST"}),extend:(F)=>{const x={...r,...F};return{get:async(n,H)=>D(n,{...x,...H,method:"GET"}),post:async(n,H)=>D(n,{...x,...H,method:"POST"}),extend:(n)=>c.extend({...x,...n})}}};async function On(F){const x=await import("@swapkit/tokens");for(let n of Object.values(x))for(let{identifier:H,chain:N,...R}of n.tokens){if("identifier"in F&&H===F.identifier)return H;if("address"in R&&"chain"in F&&N===F.chain&&R.address.toLowerCase()===F.contract.toLowerCase())return H}return}var fF="0x313ce567",TF=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],LF=async({chain:F,to:x})=>{try{const{result:n}=await c.post(m[F],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:x.toLowerCase(),data:fF},"latest"]})});return Number.parseInt(BigInt(n||z[F]).toString())}catch(n){return console.error(n),z[F]}},pF=async({symbol:F})=>{try{const x=F.split("-")[1]?.toLowerCase(),{manager:n}=await c.post(`${m["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:x})});return n.divisibility.value.divisibility}catch(x){return console.error(x),z["XRD"]}},gF=(F)=>{if(F==="ETH")return 18;const x=F.split("-"),n=x.length===1?void 0:x[x.length-1]?.toLowerCase();return n?.startsWith("0x")?LF({chain:"ETH",to:n}):18},uF=(F)=>{const x=F.split("-"),n=x.length===1?void 0:x[x.length-1];return n?.startsWith("0x")?LF({chain:"AVAX",to:n.toLowerCase()}):18},yF=(F)=>{if(F==="BSC")return 18;return 18},vF=(F)=>{if(F==="XRD")return 18;return pF({symbol:F})},_F=({chain:F,symbol:x})=>{switch(F){case"ETH":return gF(x);case"AVAX":return uF(x);case"BSC":return yF(x);case"XRD":return vF(x);default:return z[F]}},Tn=({chain:F})=>{switch(F){case"ARB":case"OP":return X.from({asset:`${F}.ETH`});case"MAYA":return X.from({asset:`${F}.CACAO`});case"GAIA":return X.from({asset:`${F}.ATOM`});case"BSC":return X.from({asset:`${F}.BNB`});case"THOR":return X.from({asset:`${F}.RUNE`});default:return X.from({asset:`${F}.${F}`})}},a=({chain:F,symbol:x})=>{switch(F){case"ARB":case"OP":return x==="ETH";case"MAYA":return x==="CACAO";case"GAIA":return x==="ATOM";case"BSC":return x==="BNB";case"THOR":return x==="RUNE";default:return x===F}},GF=(F)=>{switch(F){case"ARB":case"OP":return{identifier:`${F}.ETH`,decimal:z[F]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${F}.ATOM`,decimal:z[F]};case"THOR":return{identifier:`${F}.RUNE`,decimal:z[F]};case"BSC":return{identifier:`${F}.BNB`,decimal:z[F]};case"MAYA":return{identifier:`${F}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:z[F]};case`${"MAYA"}.MAYA`:return{identifier:F,decimal:4};case`${"KUJI"}.USK`:return{identifier:F,decimal:6};default:return{identifier:`${F}.${F}`,decimal:z[F]}}},OF=({chain:F,symbol:x})=>{if(x.includes("/"))return"Synth";switch(F){case"GAIA":return x==="ATOM"?"Native":"GAIA";case"KUJI":return x==="KUJI"?"Native":"KUJI";case"BSC":return x==="BNB"?"Native":"BEP20";case"ETH":return x==="ETH"?"Native":"ERC20";case"AVAX":return x==="AVAX"?"Native":"AVAX";case"MATIC":return x==="MATIC"?"Native":"POLYGON";case"ARB":return["ETH","ARB"].includes(x)?"Native":"ARBITRUM";case"OP":return["ETH","OP"].includes(x)?"Native":"OPTIMISM";case"XRD":return x==="XRD"?"Native":"RADIX";default:return"Native"}},_n=(F)=>{const[x,...n]=F.split("."),H=F.includes("/"),N=n.join("."),R=N?.split("-"),k=R?.length?R.length===1?R[0]:R.slice(0,-1).join("-"):void 0;return{chain:x,symbol:N,ticker:k,synth:H}},oF=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),EF=(F)=>{const[x,n]=F.split(".");if(!y.includes(x))return!0;const H=n.split("-"),N=H.length===1?void 0:H[H.length-1];return a({chain:x,symbol:n})||!!N},Gn=(F)=>F.filter(({chain:x,value:n,symbol:H})=>{const N=`${x}.${H}`;return!oF.test(N)&&EF(N)&&n!=="0"});function $n([F,x,n,H,N]){return`m/${F}'/${x}'/${n}'/${H}${typeof N!=="number"?"":`/${N}`}`}function An({chain:F,index:x,addressIndex:n=0,type:H}){if(y.includes(F)){if(H==="legacy")return[44,60,0,x];if(H==="ledgerLive")return[44,60,x,0,n];return PF(s[F],x)}const N=F==="LTC"?2:0;switch(H){case"nativeSegwitMiddleAccount":return[84,N,x,0,n];case"segwit":return[49,N,0,0,x];case"legacy":return[44,N,0,0,x];default:return PF(s[F],x)}}function Xn(F){const[x,n,H]=F.split("/").map((N)=>Number.parseInt(N,10));switch(n){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var PF=(F,x)=>{return[...F.slice(0,F.length-1),x]};function bF({liquidityUnits:F,poolUnits:x,runeDepth:n}){const H=w(F),N=w(x),R=w(n),k=H.mul(R),_=N.mul(N).mul(2),P=N.mul(H).mul(2),G=H.mul(H),O=N.mul(N).mul(N);return k.mul(_.sub(P).add(G)).div(O)}function DF({liquidityUnits:F,poolUnits:x,assetDepth:n}){const H=w(F),N=w(x),R=w(n),k=H.mul(R),_=N.mul(N).mul(2),P=N.mul(H).mul(2),G=H.mul(H),O=k.mul(_.sub(P).add(G)),Z=N.mul(N).mul(N);return O.div(Z)}function Zn({percent:F,runeDepth:x,liquidityUnits:n,poolUnits:H}){return bF({runeDepth:x,liquidityUnits:n,poolUnits:H}).mul(F)}function Yn({percent:F,assetDepth:x,liquidityUnits:n,poolUnits:H}){return DF({assetDepth:x,liquidityUnits:n,poolUnits:H}).mul(F)}function w(F){return Q.fromBigInt(BigInt(F),8)}function cF({liquidityUnits:F,poolUnits:x,runeDepth:n,assetDepth:H}){return{assetAmount:w(H).mul(F).div(x),runeAmount:w(n).mul(F).div(x)}}function wn({liquidityUnits:F,poolUnits:x,runeDepth:n,assetDepth:H,percent:N}){return Object.fromEntries(Object.entries(cF({liquidityUnits:F,poolUnits:x,runeDepth:n,assetDepth:H})).map(([R,k])=>[R,k.mul(N)]))}function Qn({runeDepth:F,poolUnits:x,assetDepth:n,liquidityUnits:H,runeAmount:N,assetAmount:R}){const k=new Q({value:F,decimal:8}),_=new Q({value:n,decimal:8}),P=new Q({value:x,decimal:8}),G=new Q({value:N,decimal:8}),O=new Q({value:R,decimal:8}),Z=G.mul(_),$=O.mul(k),f=G.mul(O),p=k.mul(_),M=P.mul(Z.add($.add(f.mul(2)))),j=Z.add($.add(p.mul(2))),W=M.div(j),g=w(H).add(W);if(W.getBaseValue("number")===0)return g.div(P).getBaseValue("number");const I=P.add(g);return g.div(I).getBaseValue("number")}function qn({runeAmount:F,assetAmount:x,runeDepth:n,assetDepth:H}){if(F==="0"||x==="0"||n==="0"||H==="0")return 0;const N=w(n),R=w(H),k=w(x),_=w(F),P=k.mul(N).sub(R.mul(_)),G=R.mul(_).add(N.mul(R));return Math.abs(P.div(G).getBaseValue("number"))}function dF({type:F,address:x}){return`${F}:${x}`}function tF({address:F,unbondAmount:x}){return`${"UNBOND"}:${F}:${x}`}function Cn(F){return U("POOL+",F)}function mF({chain:F,symbol:x,...n}){return U(`${"+"}:${F}/${x}`,n)}function sF({chain:F,symbol:x,address:n,...H}){const N=eF({chain:F,symbol:x}),R=n?`:${n}:`:":";return U(`${"+"}:${N}${R}`,H)}function iF({chain:F,symbol:x,basisPoints:n}){return`${"-"}:${F}/${x}:${n}`}function lF({chain:F,symbol:x,ticker:n,basisPoints:H,targetAsset:N}){const R=F==="ETH"&&n!=="ETH"?`${n}-${x.slice(-3)}`:x,k=N?`:${N}`:"";return`${"-"}:${F}.${R}:${H}${k}`}function Vn({basisPoints:F,...x}){return U(`${"POOL-"}:${F}`,x)}function aF({name:F,chain:x,address:n,owner:H}){const N=`${"~"}:${F}:${x}:${n}`,R=H?`:${H}`:"";return`${N}${R}`}function Sn({name:F,chain:x,asset:n,payout:H,owner:N}){return`${"~"}:${F}:${x}:${H}:${N}:${n}`}function rF(F,{asset:x,address:n,minAmount:H,...N}){const R=`${F}:${x}:${n}`,k=H?`:${H}`:"";return U(`${R}${k}`,N)}function U(F,{affiliateAddress:x,affiliateBasisPoints:n}={}){const H=`${F}${x?`:${x}:${n||0}`:""}`;return H.endsWith(":")?H.slice(0,-1):H}function eF({chain:F,symbol:x}){switch(F){case"BTC":case"DOGE":case"LTC":return F.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${F}.${x}`}}var Un=(F,x)=>{switch(F){case"LEAVE":case"BOND":return dF({type:F,address:x?.address});case"UNBOND":return tF({address:x?.address,unbondAmount:x?.unbondAmount});case"~":return aF(x);case"$+":case"$-":return rF(F,x);case"+":{const{chain:n,symbol:H,address:N,singleSide:R}=x;if(R)return mF({chain:n,symbol:H});return sF({chain:n,symbol:H,address:N})}case"-":{const{chain:n,ticker:H,symbol:N,basisPoints:R,targetAssetString:k,singleSide:_}=x;if(_)return iF({chain:n,symbol:N,basisPoints:R});return lF({chain:n,ticker:H,symbol:N,basisPoints:R,targetAsset:k})}default:throw new J({errorKey:"helpers_invalid_memo_type",info:{memoType:F}})}};function bn({chain:F,covalentApiKey:x,ethplorerApiKey:n}){const H=F!=="ETH"&&!x?"covalentApiKey":n?void 0:"ethplorerApiKey";if(H)throw new J({errorKey:"wallet_missing_api_key",info:{missingKey:H}});return{covalentApiKey:x,ethplorerApiKey:n}}function Dn(){const F=[];function x(H){if(F.map((N)=>N.info.uuid).includes(H.detail.info.uuid))return;F.push(H.detail)}window.addEventListener("eip6963:announceProvider",x),window.dispatchEvent(new Event("eip6963:requestProvider"));function n(){window.removeEventListener("eip6963:announceProvider",x)}return{providers:F,removeEIP6963EventListener:n}}var Fx=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],xx=(F,x,n)=>async(...H)=>{try{await nx(x,n)}catch(N){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:N}})}return F(...H)},$F=({provider:F,params:x,method:n})=>{if(!F?.send)throw new J("helpers_not_found_provider");const H=x?Array.isArray(x)?x:[x]:[];return F.send(n,H)},un=({toolbox:F,chainId:x,provider:n=window.ethereum})=>{const H=Fx.reduce((N,R)=>{if(!F[R])return N;const k=F[R];if(typeof k!=="function")return N;return{...N,[R]:xx(k,n,x)}},{});return{...F,...H}},yn=(F,x)=>$F({provider:F,method:"wallet_addEthereumChain",params:[x]}),nx=(F,x="0x1")=>$F({provider:F,method:"wallet_switchEthereumChain",params:[{chainId:x}]}),vn=(F)=>{window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())},on=()=>{const{isTrust:F,isBraveWallet:x,__XDEFI:n,overrideIsMetaMask:H,selectedProvider:N}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if(x)return"BRAVE";if(H&&N?.isCoinbaseWallet)return"COINBASE_WEB";if(n)"XDEFI";return"METAMASK"},En=(F)=>{return Hx().includes(F)},Hx=()=>{const F=window?.ethereum&&!window.ethereum?.isBraveWallet,x=window?.xfi||window?.ethereum?.__XDEFI,n=window?.ethereum?.isBraveWallet,H=window?.ethereum?.isTrust||window?.trustwallet,N=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,R=[];if(F)R.push("METAMASK");if(x)R.push("XDEFI");if(n)R.push("BRAVE");if(H)R.push("TRUSTWALLET_WEB");if(N)R.push("COINBASE_WEB");if(Nx())R.push("OKX_MOBILE");return R},Nx=()=>{const F=navigator.userAgent,x=/iphone|ipad|ipod|ios/i.test(F),n=/android|XiaoMi|MiuiBrowser/i.test(F),H=x||n,N=/OKApp/i.test(F);return H&&N},cn=()=>typeof window.ethereum!=="undefined";class Q extends q{eq(F){return this.eqValue(F)}static fromBigInt(F,x){return new Q({decimal:x,value:K({value:F,bigIntDecimal:x,decimal:x})})}}export{ox as wrapWithThrow,xx as wrapMethodWithNetworkSwitch,NF as warnOnce,dx as validateTNS,RF as validateIdentifier,nx as switchEVMWalletNetwork,Nn as setRequestClientConfig,un as prepareNetworkSwitch,Nx as okxMobileEnabled,Hx as listWeb3EVMWallets,cn as isWeb3Detected,a as isGasAsset,En as isDetected,Xn as getWalletFormatFor,yx as getTHORNameCost,wn as getSymmetricWithdraw,cF as getSymmetricPoolShare,nn as getMinAmountByChain,lF as getMemoForWithdraw,tF as getMemoForUnbond,iF as getMemoForSaverWithdraw,mF as getMemoForSaverDeposit,Vn as getMemoForRunePoolWithdraw,Cn as getMemoForRunePoolDeposit,aF as getMemoForNameRegister,Sn as getMemoForNamePreferredAssetRegister,rF as getMemoForLoan,dF as getMemoForLeaveAndBond,sF as getMemoForDeposit,Un as getMemoFor,vx as getMAYANameCost,qn as getLiquiditySlippage,Tn as getGasAsset,Qn as getEstimatedPoolShare,on as getETHDefaultWallet,Dn as getEIP6963Wallets,An as getDerivationPathFor,_F as getDecimal,GF as getCommonAssetInfo,Ex as getChainIdentifier,Zn as getAsymmetricRuneWithdrawAmount,bF as getAsymmetricRuneShare,Yn as getAsymmetricAssetWithdrawAmount,DF as getAsymmetricAssetShare,OF as getAssetType,K as formatBigIntToSafeValue,On as findAssetBy,Gn as filterAssets,bn as ensureEVMApiKeys,$n as derivationPathToString,UF as defaultRequestHeaders,_n as assetFromString,yn as addEVMWalletNetwork,vn as addAccountsChangedCallback,QF as WarningCodeEnum,xF as WalletOption,_x as UTXOChains,Ox as TCSupportedChains,Q as SwapKitNumber,J as SwapKitError,Tx as SubstrateChains,Jx as SWAP_OUT,jx as SWAP_IN,c as RequestClient,d as RPCUrl,XF as QuoteMode,qF as ProviderName,s as NetworkDerivationPath,nF as MemoType,Lx as MAYASupportedChains,zF as LedgerErrorCode,BF as FeeTypeEnum,ZF as FeeOption,t as ExplorerUrl,wF as ErrorCode,y as EVMChains,JF as DerivationPath,Gx as CosmosChains,jF as ContractAddress,TF as CommonAssetStrings,m as ChainToRPC,Px as ChainToHexChainId,$x as ChainToExplorerUrl,FF as ChainToChainId,Ix as ChainIdToChain,u as ChainId,Y as Chain,q as BigIntArithmetics,z as BaseDecimal,X as AssetValue,YF as ApproveMode,Xx as AGG_SWAP};
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`));const{decimal:p,identifier:M,tax:X}=Q||{decimal:J||z[L],identifier:A},K=F?b(BigInt(N),F):b(N,p);return n?Cx(M,F?K:N):Z?Sx(M,K):new $({tax:X,decimal:p,identifier:M,value:K})}static loadStaticAssets(){return new Promise((x,F)=>{try{import("@swapkit/tokens").then((n)=>{for(let H of Object.values(n))for(let{identifier:N,chain:R,...I}of H.tokens)E.set(N.toUpperCase(),{identifier:N,decimal:"decimals"in I?I.decimals:z[R]});x({ok:!0})})}catch(n){console.error(n),F({ok:!1,error:n,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(x,F=0){return $.from({asset:x,value:F,asyncTokenLookup:!0})}static fromIdentifier(x,F=0){return $.from({asset:x,value:F,asyncTokenLookup:!0})}static fromStringSync(x,F=0){return $.from({asset:x,value:F})}static fromStringWithBase(x,F=0n,n=8){return $.from({asyncTokenLookup:!0,asset:x,value:F,fromBaseDecimal:n})}static fromStringWithBaseSync(x,F=0n,n=8){return $.from({asset:x,value:F,fromBaseDecimal:n})}static fromIdentifierSync(x,F=0){return $.from({asset:x,value:F})}static fromChainOrSignature(x,F=0){if(Object.values(Y).includes(x))return $.from({chain:x,value:F});return $.from({asset:x,value:F})}}function Nn({apiKey:x,...F}){r={...F,apiKey:x}}async function D(x,F){const{apiKey:n,...H}=r,{searchParams:N,json:R,body:I}=F,_={...Ux,...H.headers,...F.headers,...R?{"Content-Type":"application/json"}:{}},A=R?JSON.stringify(R):I,G=new URL(x);if(N)G.search=new URLSearchParams(N).toString();if(n)_["x-api-key"]=n;try{const Z=await(await fetch(G.toString(),{...H,...F,body:A,headers:_})).json();if(F.responseHandler)return F.responseHandler(Z);return Z}catch(L){if(F.onError)return F.onError(L);console.error(L)}}var r={},Ux=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},c={get:async(x,F)=>D(x,{...F,method:"GET"}),post:async(x,F)=>D(x,{...F,method:"POST"}),extend:(x)=>{const F={...r,...x};return{get:async(n,H)=>D(n,{...F,...H,method:"GET"}),post:async(n,H)=>D(n,{...F,...H,method:"POST"}),extend:(n)=>c.extend({...F,...n})}}};async function Ln(x){const F=await import("@swapkit/tokens");for(let n of Object.values(F))for(let{identifier:H,chain:N,...R}of n.tokens){if("identifier"in x&&H===x.identifier)return H;if("address"in R&&"chain"in x&&N===x.chain&&R.address.toLowerCase()===x.contract.toLowerCase())return H}return}var fx="0x313ce567",Tx=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],Px=async({chain:x,to:F})=>{try{const{result:n}=await c.post(m[x],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:F.toLowerCase(),data:fx},"latest"]})});return Number.parseInt(BigInt(n||z[x]).toString())}catch(n){return console.error(n),z[x]}},px=async({symbol:x})=>{try{const F=x.split("-")[1]?.toLowerCase(),{manager:n}=await c.post(`${m["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:F})});return n.divisibility.value.divisibility}catch(F){return console.error(F),z["XRD"]}},gx=(x)=>{if(x==="ETH")return 18;const F=x.split("-"),n=F.length===1?void 0:F[F.length-1]?.toLowerCase();return n?.startsWith("0x")?Px({chain:"ETH",to:n}):18},ux=(x)=>{const F=x.split("-"),n=F.length===1?void 0:F[F.length-1];return n?.startsWith("0x")?Px({chain:"AVAX",to:n.toLowerCase()}):18},yx=(x)=>{if(x==="BSC")return 18;return 18},vx=(x)=>{if(x==="XRD")return 18;return px({symbol:x})},_x=({chain:x,symbol:F})=>{switch(x){case"ETH":return gx(F);case"AVAX":return ux(F);case"BSC":return yx(F);case"XRD":return vx(F);default:return z[x]}},Tn=({chain:x})=>{switch(x){case"ARB":case"OP":return $.from({asset:`${x}.ETH`});case"MAYA":return $.from({asset:`${x}.CACAO`});case"GAIA":return $.from({asset:`${x}.ATOM`});case"BSC":return $.from({asset:`${x}.BNB`});case"THOR":return $.from({asset:`${x}.RUNE`});default:return $.from({asset:`${x}.${x}`})}},a=({chain:x,symbol:F})=>{switch(x){case"ARB":case"OP":return F==="ETH";case"MAYA":return F==="CACAO";case"GAIA":return F==="ATOM";case"BSC":return F==="BNB";case"THOR":return F==="RUNE";default:return F===x}},Gx=(x)=>{switch(x){case"ARB":case"OP":return{identifier:`${x}.ETH`,decimal:z[x]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${x}.ATOM`,decimal:z[x]};case"THOR":return{identifier:`${x}.RUNE`,decimal:z[x]};case"BSC":return{identifier:`${x}.BNB`,decimal:z[x]};case"MAYA":return{identifier:`${x}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:z[x]};case`${"MAYA"}.MAYA`:return{identifier:x,decimal:4};case`${"KUJI"}.USK`:return{identifier:x,decimal:6};default:return{identifier:`${x}.${x}`,decimal:z[x]}}},Lx=({chain:x,symbol:F})=>{if(F.includes("/"))return"Synth";switch(x){case"GAIA":return F==="ATOM"?"Native":"GAIA";case"KUJI":return F==="KUJI"?"Native":"KUJI";case"BSC":return F==="BNB"?"Native":"BEP20";case"ETH":return F==="ETH"?"Native":"ERC20";case"AVAX":return F==="AVAX"?"Native":"AVAX";case"MATIC":return F==="MATIC"?"Native":"POLYGON";case"ARB":return["ETH","ARB"].includes(F)?"Native":"ARBITRUM";case"OP":return["ETH","OP"].includes(F)?"Native":"OPTIMISM";case"XRD":return F==="XRD"?"Native":"RADIX";default:return"Native"}},_n=(x)=>{const[F,...n]=x.split("."),H=x.includes("/"),N=n.join("."),R=N?.split("-"),I=R?.length?R.length===1?R[0]:R.slice(0,-1).join("-"):void 0;return{chain:F,symbol:N,ticker:I,synth:H}},ox=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),Ex=(x)=>{const[F,n]=x.split(".");if(!y.includes(F))return!0;const H=n.split("-"),N=H.length===1?void 0:H[H.length-1];return a({chain:F,symbol:n})||!!N},Gn=(x)=>x.filter(({chain:F,value:n,symbol:H})=>{const N=`${F}.${H}`;return!ox.test(N)&&Ex(N)&&n!=="0"});function On([x,F,n,H,N]){return`m/${x}'/${F}'/${n}'/${H}${typeof N!=="number"?"":`/${N}`}`}function $n({chain:x,index:F,addressIndex:n=0,type:H}){if(y.includes(x)){if(H==="legacy")return[44,60,0,F];if(H==="ledgerLive")return[44,60,F,0,n];return Ax(s[x],F)}const N=x==="LTC"?2:0;switch(H){case"nativeSegwitMiddleAccount":return[84,N,F,0,n];case"segwit":return[49,N,0,0,F];case"legacy":return[44,N,0,0,F];default:return Ax(s[x],F)}}function Xn(x){const[F,n,H]=x.split("/").map((N)=>Number.parseInt(N,10));switch(n){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Ax=(x,F)=>{return[...x.slice(0,x.length-1),F]};function bx({liquidityUnits:x,poolUnits:F,runeDepth:n}){const H=w(x),N=w(F),R=w(n),I=H.mul(R),_=N.mul(N).mul(2),A=N.mul(H).mul(2),G=H.mul(H),L=N.mul(N).mul(N);return I.mul(_.sub(A).add(G)).div(L)}function Dx({liquidityUnits:x,poolUnits:F,assetDepth:n}){const H=w(x),N=w(F),R=w(n),I=H.mul(R),_=N.mul(N).mul(2),A=N.mul(H).mul(2),G=H.mul(H),L=I.mul(_.sub(A).add(G)),Z=N.mul(N).mul(N);return L.div(Z)}function Zn({percent:x,runeDepth:F,liquidityUnits:n,poolUnits:H}){return bx({runeDepth:F,liquidityUnits:n,poolUnits:H}).mul(x)}function Yn({percent:x,assetDepth:F,liquidityUnits:n,poolUnits:H}){return Dx({assetDepth:F,liquidityUnits:n,poolUnits:H}).mul(x)}function w(x){return q.fromBigInt(BigInt(x),8)}function cx({liquidityUnits:x,poolUnits:F,runeDepth:n,assetDepth:H}){return{assetAmount:w(H).mul(x).div(F),runeAmount:w(n).mul(x).div(F)}}function wn({liquidityUnits:x,poolUnits:F,runeDepth:n,assetDepth:H,percent:N}){return Object.fromEntries(Object.entries(cx({liquidityUnits:x,poolUnits:F,runeDepth:n,assetDepth:H})).map(([R,I])=>[R,I.mul(N)]))}function Qn({runeDepth:x,poolUnits:F,assetDepth:n,liquidityUnits:H,runeAmount:N,assetAmount:R}){const I=new q({value:x,decimal:8}),_=new q({value:n,decimal:8}),A=new q({value:F,decimal:8}),G=new q({value:N,decimal:8}),L=new q({value:R,decimal:8}),Z=G.mul(_),Q=L.mul(I),J=G.mul(L),p=I.mul(_),M=A.mul(Z.add(Q.add(J.mul(2)))),X=Z.add(Q.add(p.mul(2))),K=M.div(X),g=w(H).add(K);if(K.getBaseValue("number")===0)return g.div(A).getBaseValue("number");const k=A.add(g);return g.div(k).getBaseValue("number")}function qn({runeAmount:x,assetAmount:F,runeDepth:n,assetDepth:H}){if(x==="0"||F==="0"||n==="0"||H==="0")return 0;const N=w(n),R=w(H),I=w(F),_=w(x),A=I.mul(N).sub(R.mul(_)),G=R.mul(_).add(N.mul(R));return Math.abs(A.div(G).getBaseValue("number"))}function dx({type:x,address:F}){return`${x}:${F}`}function tx({address:x,unbondAmount:F}){return`${"UNBOND"}:${x}:${F}`}function Mn(x){return f("POOL+",x)}function mx({chain:x,symbol:F,...n}){return f(`${"+"}:${x}/${F}`,n)}function sx({chain:x,symbol:F,address:n,...H}){const N=ex({chain:x,symbol:F}),R=n?`:${n}:`:":";return f(`${"+"}:${N}${R}`,H)}function ix({chain:x,symbol:F,basisPoints:n}){return`${"-"}:${x}/${F}:${n}`}function lx({chain:x,symbol:F,ticker:n,basisPoints:H,targetAsset:N}){const R=x==="ETH"&&n!=="ETH"?`${n}-${F.slice(-3)}`:F,I=N?`:${N}`:"";return`${"-"}:${x}.${R}:${H}${I}`}function Cn({basisPoints:x,...F}){return f(`${"POOL-"}:${x}`,F)}function ax({name:x,chain:F,address:n,owner:H}){const N=`${"~"}:${x}:${F}:${n}`,R=H?`:${H}`:"";return`${N}${R}`}function Sn({name:x,chain:F,asset:n,payout:H,owner:N}){return`${"~"}:${x}:${F}:${H}:${N}:${n}`}function rx(x,{asset:F,address:n,minAmount:H,...N}){const R=`${x}:${F}:${n}`,I=H?`:${H}`:"";return f(`${R}${I}`,N)}function f(x,{affiliateAddress:F,affiliateBasisPoints:n}={}){const H=`${x}${F?`:${F}:${n||0}`:""}`;return H.endsWith(":")?H.slice(0,-1):H}function ex({chain:x,symbol:F}){switch(x){case"BTC":case"DOGE":case"LTC":return x.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${x}.${F}`}}var Un=(x,F)=>{switch(x){case"LEAVE":case"BOND":return dx({type:x,address:F?.address});case"UNBOND":return tx({address:F?.address,unbondAmount:F?.unbondAmount});case"~":return ax(F);case"$+":case"$-":return rx(x,F);case"+":{const{chain:n,symbol:H,address:N,singleSide:R}=F;if(R)return mx({chain:n,symbol:H});return sx({chain:n,symbol:H,address:N})}case"-":{const{chain:n,ticker:H,symbol:N,basisPoints:R,targetAssetString:I,singleSide:_}=F;if(_)return ix({chain:n,symbol:N,basisPoints:R});return lx({chain:n,ticker:H,symbol:N,basisPoints:R,targetAsset:I})}default:throw new j({errorKey:"helpers_invalid_memo_type",info:{memoType:x}})}};function bn({chain:x,covalentApiKey:F,ethplorerApiKey:n}){const H=x!=="ETH"&&!F?"covalentApiKey":n?void 0:"ethplorerApiKey";if(H)throw new j({errorKey:"wallet_missing_api_key",info:{missingKey:H}});return{covalentApiKey:F,ethplorerApiKey:n}}function Dn(){const x=[];function F(H){if(x.map((N)=>N.info.uuid).includes(H.detail.info.uuid))return;x.push(H.detail)}window.addEventListener("eip6963:announceProvider",F),window.dispatchEvent(new Event("eip6963:requestProvider"));function n(){window.removeEventListener("eip6963:announceProvider",F)}return{providers:x,removeEIP6963EventListener:n}}var xF=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],FF=(x,F,n)=>async(...H)=>{try{await nF(F,n)}catch(N){throw new j({errorKey:"helpers_failed_to_switch_network",info:{error:N}})}return x(...H)},Ox=({provider:x,params:F,method:n})=>{if(!x?.send)throw new j("helpers_not_found_provider");const H=F?Array.isArray(F)?F:[F]:[];return x.send(n,H)},un=({toolbox:x,chainId:F,provider:n=window.ethereum})=>{const H=xF.reduce((N,R)=>{if(!x[R])return N;const I=x[R];if(typeof I!=="function")return N;return{...N,[R]:FF(I,n,F)}},{});return{...x,...H}},yn=(x,F)=>Ox({provider:x,method:"wallet_addEthereumChain",params:[F]}),nF=(x,F="0x1")=>Ox({provider:x,method:"wallet_switchEthereumChain",params:[{chainId:F}]}),vn=(x)=>{window.ethereum?.on("accountsChanged",()=>x()),window.xfi?.ethereum.on("accountsChanged",()=>x())},on=()=>{const{isTrust:x,isBraveWallet:F,__XDEFI:n,overrideIsMetaMask:H,selectedProvider:N}=window?.ethereum||{};if(x)return"TRUSTWALLET_WEB";if(F)return"BRAVE";if(H&&N?.isCoinbaseWallet)return"COINBASE_WEB";if(n)"XDEFI";return"METAMASK"},En=(x)=>{return HF().includes(x)},HF=()=>{const x=window?.ethereum&&!window.ethereum?.isBraveWallet,F=window?.xfi||window?.ethereum?.__XDEFI,n=window?.ethereum?.isBraveWallet,H=window?.ethereum?.isTrust||window?.trustwallet,N=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,R=[];if(x)R.push("METAMASK");if(F)R.push("XDEFI");if(n)R.push("BRAVE");if(H)R.push("TRUSTWALLET_WEB");if(N)R.push("COINBASE_WEB");if(NF())R.push("OKX_MOBILE");return R},NF=()=>{const x=navigator.userAgent,F=/iphone|ipad|ipod|ios/i.test(x),n=/android|XiaoMi|MiuiBrowser/i.test(x),H=F||n,N=/OKApp/i.test(x);return H&&N},cn=()=>typeof window.ethereum!=="undefined";class q extends B{eq(x){return this.eqValue(x)}static fromBigInt(x,F){return new q({decimal:F,value:V({value:x,bigIntDecimal:F,decimal:F})})}}export{oF as wrapWithThrow,FF as wrapMethodWithNetworkSwitch,Nx as warnOnce,dF as validateTNS,Rx as validateIdentifier,nF as switchEVMWalletNetwork,Nn as setRequestClientConfig,un as prepareNetworkSwitch,NF as okxMobileEnabled,HF as listWeb3EVMWallets,cn as isWeb3Detected,a as isGasAsset,En as isDetected,Xn as getWalletFormatFor,yF as getTHORNameCost,wn as getSymmetricWithdraw,cx as getSymmetricPoolShare,nn as getMinAmountByChain,lx as getMemoForWithdraw,tx as getMemoForUnbond,ix as getMemoForSaverWithdraw,mx as getMemoForSaverDeposit,Cn as getMemoForRunePoolWithdraw,Mn as getMemoForRunePoolDeposit,ax as getMemoForNameRegister,Sn as getMemoForNamePreferredAssetRegister,rx as getMemoForLoan,dx as getMemoForLeaveAndBond,sx as getMemoForDeposit,Un as getMemoFor,vF as getMAYANameCost,qn as getLiquiditySlippage,Tn as getGasAsset,Qn as getEstimatedPoolShare,on as getETHDefaultWallet,Dn as getEIP6963Wallets,$n as getDerivationPathFor,_x as getDecimal,Gx as getCommonAssetInfo,EF as getChainIdentifier,Zn as getAsymmetricRuneWithdrawAmount,bx as getAsymmetricRuneShare,Yn as getAsymmetricAssetWithdrawAmount,Dx as getAsymmetricAssetShare,Lx as getAssetType,V as formatBigIntToSafeValue,Ln as findAssetBy,Gn as filterAssets,bn as ensureEVMApiKeys,On as derivationPathToString,Ux as defaultRequestHeaders,_n as assetFromString,yn as addEVMWalletNetwork,vn as addAccountsChangedCallback,Qx as WarningCodeEnum,Fx as WalletOption,_F as UTXOChains,LF as TCSupportedChains,q as SwapKitNumber,j as SwapKitError,TF as SubstrateChains,JF as SWAP_OUT,jF as SWAP_IN,c as RequestClient,d as RPCUrl,Xx as QuoteMode,qx as ProviderName,s as NetworkDerivationPath,nx as MemoType,PF as MAYASupportedChains,zx as LedgerErrorCode,Bx as FeeTypeEnum,Zx as FeeOption,t as ExplorerUrl,wx as ErrorCode,y as EVMChains,Jx as DerivationPath,GF as CosmosChains,jx as ContractAddress,Tx as CommonAssetStrings,m as ChainToRPC,AF as ChainToHexChainId,OF as ChainToExplorerUrl,xx as ChainToChainId,kF as ChainIdToChain,u as ChainId,Y as Chain,B as BigIntArithmetics,z as BaseDecimal,$ as AssetValue,Yx as ApproveMode,XF as AGG_SWAP};
//# debugId=AA26125518CF00D264756E2164756E21
//# debugId=37FFF642195568CA64756E2164756E21

@@ -10,8 +10,8 @@ {

"devDependencies": {
"@swapkit/toolbox-cosmos": "1.0.18",
"@swapkit/toolbox-evm": "1.1.11",
"@swapkit/toolbox-solana": "1.0.16",
"@swapkit/toolbox-radix": "1.0.16",
"@swapkit/toolbox-substrate": "1.1.11",
"@swapkit/toolbox-utxo": "1.0.16"
"@swapkit/toolbox-cosmos": "1.0.19",
"@swapkit/toolbox-evm": "1.2.0",
"@swapkit/toolbox-solana": "1.0.17",
"@swapkit/toolbox-radix": "1.0.17",
"@swapkit/toolbox-substrate": "1.1.12",
"@swapkit/toolbox-utxo": "1.1.0"
},

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

"types": "./src/index.ts",
"version": "1.3.2"
"version": "1.4.0"
}

@@ -114,2 +114,3 @@ const errorCodes = {

api_v2_invalid_response: 50001,
api_v2_server_error: 50002,
/**

@@ -116,0 +117,0 @@ * Toolboxes

@@ -122,13 +122,14 @@ export enum ErrorCode {

CHAINFLIP = "CHAINFLIP",
TRADERJOE_V1 = "TRADERJOE_V1",
PANGOLIN_V1 = "PANGOLIN_V1",
UNISWAP_V2 = "UNISWAP_V2",
THORCHAIN = "THORCHAIN",
THORCHAIN_STREAMING = "THORCHAIN_STREAMING",
MAYACHAIN = "MAYACHAIN",
MAYACHAIN_STREAMING = "MAYACHAIN_STREAMING",
ONEINCH = "ONEINCH",
PANCAKESWAP = "PANCAKESWAP",
PANGOLIN_V1 = "PANGOLIN_V1",
SUSHISWAP_V2 = "SUSHISWAP_V2",
WOOFI_V2 = "WOOFI_V2",
PANCAKESWAP = "PANCAKESWAP",
THORCHAIN = "THORCHAIN",
THORCHAIN_STREAMING = "THORCHAIN_STREAMING",
TRADERJOE_V2 = "TRADERJOE_V2",
UNISWAP_V2 = "UNISWAP_V2",
UNISWAP_V3 = "UNISWAP_V3",
CAVIAR_V1 = "CAVIAR_V1",
}

@@ -135,0 +136,0 @@

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