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.4.2 to 1.5.0

6

dist/index.js

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

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 Vx}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 M({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"?Mx.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:M({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=M({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 Mx=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))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:x}});return new $({decimal:8,value:b(F,8),identifier:`${n||"THOR"}.${N}/${R}`})}function b(x,F){return typeof x==="bigint"?M({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),Vx(`Couldn't find static decimal for ${kx(A)} (Using default ${kx(z[L])} 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;((P)=>{P.Arbitrum="https://arb1.arbitrum.io/rpc";P.Avalanche="https://node-router.thorswap.net/avalanche-c";P.BinanceSmartChain="https://bsc-dataseed.binance.org";P.Bitcoin="https://node-router.thorswap.net/bitcoin";P.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";P.Chainflip="wss://mainnet-archive.chainflip.io";P.Cosmos="https://node-router.thorswap.net/cosmos/rpc";P.Dash="https://node-router.thorswap.net/dash";P.Dogecoin="https://node-router.thorswap.net/dogecoin";P.Ethereum="https://node-router.thorswap.net/ethereum";P.Kujira="https://rpc-kujira.synergynodes.com/";P.Litecoin="https://node-router.thorswap.net/litecoin";P.Maya="https://tendermint.mayachain.info";P.MayaStagenet="https://stagenet.tendermint.mayachain.info";P.Optimism="https://mainnet.optimism.io";P.Polkadot="wss://rpc.polkadot.io";P.Polygon="https://polygon-rpc.com";P.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";P.THORChain="https://rpc.thorswap.net";P.THORChainStagenet="https://stagenet-rpc.ninerealms.com";P.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;((A)=>{A.Arbitrum="42161";A.ArbitrumHex="0xa4b1";A.Avalanche="43114";A.AvalancheHex="0xa86a";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-mainnet-v1";A.THORChainStagenet="thorchain-stagenet-v2";A.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"],AF=["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},{}),OF=C.reduce((x,F)=>{const n=`${v[F]}Hex`;return x[F]=u[n],x},{}),PF=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 Vx}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 M({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"?Mx.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:M({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("."),O=I.replace(/\B(?=(\d{3})+(?!\d))/g,N),G=I||_?I==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",H):`${O}${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,O=_.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,O)}.${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((_,O)=>{const G=this.getBigIntValue(O,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=M({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 Mx=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))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:x}});return new $({decimal:8,value:b(F,8),identifier:`${n||"THOR"}.${N}/${R}`})}function b(x,F){return typeof x==="bigint"?M({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}`,[_,...O]=I.split("."),G=F?R:O.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({includeSynthProtocol:x}={}){return this.isSynthetic&&!x?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:O,decimal:G}=_?Gx(I):{identifier:I,decimal:void 0},{chain:L,isSynthetic:Z}=l(O),Q=E.get(O.toUpperCase()),J=Q?.decimal||G;Nx(!(n||J),Vx(`Couldn't find static decimal for ${kx(O)} (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:V,tax:X}=Q||{decimal:J||z[L],identifier:A},K=F?b(BigInt(N),F):b(N,p);return n?Cx(V,F?K:N):Z?Sx(V,K):new $({tax:X,decimal:p,identifier:V,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(_),V=A.mul(Z.add(Q.add(J.mul(2)))),X=Z.add(Q.add(p.mul(2))),K=V.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 Vn(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:M({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,Vn 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,M 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};
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`));const{decimal:p,identifier:V,tax:X}=Q||{decimal:J||z[L],identifier:O},K=F?b(BigInt(N),F):b(N,p);return n?Cx(V,F?K:N):Z?Sx(V,K):new $({tax:X,decimal:p,identifier:V,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"}:{}},O=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:O,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`],Ax=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")?Ax({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")?Ax({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 Pn([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 Ox(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 Ox(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 Ox=(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),O=N.mul(H).mul(2),G=H.mul(H),L=N.mul(N).mul(N);return I.mul(_.sub(O).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),O=N.mul(H).mul(2),G=H.mul(H),L=I.mul(_.sub(O).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}),O=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(_),V=O.mul(Z.add(Q.add(J.mul(2)))),X=Z.add(Q.add(p.mul(2))),K=V.div(X),g=w(H).add(K);if(K.getBaseValue("number")===0)return g.div(O).getBaseValue("number");const k=O.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),O=I.mul(N).sub(R.mul(_)),G=R.mul(_).add(N.mul(R));return Math.abs(O.div(G).getBaseValue("number"))}function dx({type:x,address:F}){return`${x}:${F}`}function tx({address:x,unbondAmount:F}){return`${"UNBOND"}:${x}:${F}`}function Vn(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)},Px=({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)=>Px({provider:x,method:"wallet_addEthereumChain",params:[F]}),nF=(x,F="0x1")=>Px({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:M({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,Vn 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,M as formatBigIntToSafeValue,Ln as findAssetBy,Gn as filterAssets,bn as ensureEVMApiKeys,Pn 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,AF 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,OF as ChainToHexChainId,PF 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=7D344121A68CA21B64756E2164756E21
//# debugId=60845FF4BDBE5C1164756E2164756E21

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

"devDependencies": {
"@swapkit/toolbox-cosmos": "1.0.21",
"@swapkit/toolbox-evm": "1.2.2",
"@swapkit/toolbox-solana": "1.0.19",
"@swapkit/toolbox-radix": "1.0.19",
"@swapkit/toolbox-substrate": "1.1.14",
"@swapkit/toolbox-utxo": "1.1.2"
"@swapkit/toolbox-cosmos": "1.0.22",
"@swapkit/toolbox-evm": "1.2.3",
"@swapkit/toolbox-solana": "1.0.20",
"@swapkit/toolbox-radix": "1.0.20",
"@swapkit/toolbox-substrate": "1.1.15",
"@swapkit/toolbox-utxo": "1.1.3"
},

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

"types": "./src/index.ts",
"version": "1.4.2"
"version": "1.5.0"
}

@@ -62,2 +62,19 @@ import { describe, expect, test } from "bun:test";

const mayaCacao = AssetValue.from({
asset: "MAYA.CACAO",
value: 10,
});
expect(mayaCacao.toString()).toBe("MAYA.CACAO");
expect(mayaCacao.getBaseValue("string")).toBe("1000000000");
const ethMayaSynth = AssetValue.from({
asset: "MAYA.ETH/ETH",
value: 10,
});
expect(ethMayaSynth.toString()).toBe("ETH/ETH");
expect(ethMayaSynth.toString({ includeSynthProtocol: true })).toBe("MAYA.ETH/ETH");
expect(ethMayaSynth.getBaseValue("string")).toBe("1000000000");
// TODO:

@@ -64,0 +81,0 @@ // const radixXWBTC = new AssetValue({

@@ -77,4 +77,4 @@ import { red, yellow } from "picocolors";

toString() {
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
toString({ includeSynthProtocol }: { includeSynthProtocol?: boolean } = {}) {
return this.isSynthetic && !includeSynthProtocol ? this.symbol : `${this.chain}.${this.symbol}`;
}

@@ -81,0 +81,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