Socket
Socket
Sign inDemoInstall

@swapkit/helpers

Package Overview
Dependencies
Maintainers
0
Versions
203
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 0.0.0-nightly-20240903175543 to 0.0.0-nightly-20240905095330

6

dist/index.js

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

var l=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,t)=>(typeof require!=="undefined"?require:h)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var d;((k)=>{k.Arbitrum="https://arb1.arbitrum.io/rpc";k.Avalanche="https://node-router.thorswap.net/avalanche-c";k.Base="https://base.llamarpc.com";k.BinanceSmartChain="https://bsc-dataseed.binance.org";k.Bitcoin="https://node-router.thorswap.net/bitcoin";k.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";k.Chainflip="wss://mainnet-archive.chainflip.io";k.Cosmos="https://node-router.thorswap.net/cosmos/rpc";k.Dash="https://node-router.thorswap.net/dash";k.Dogecoin="https://node-router.thorswap.net/dogecoin";k.Ethereum="https://node-router.thorswap.net/ethereum";k.Kujira="https://rpc-kujira.synergynodes.com/";k.Litecoin="https://node-router.thorswap.net/litecoin";k.Maya="https://tendermint.mayachain.info";k.MayaStagenet="https://stagenet.tendermint.mayachain.info";k.Optimism="https://mainnet.optimism.io";k.Polkadot="wss://rpc.polkadot.io";k.Polygon="https://polygon-rpc.com";k.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";k.THORChain="https://rpc.thorswap.net";k.THORChainStagenet="https://stagenet-rpc.ninerealms.com";k.Solana="https://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80"})(d||={});var U;((R)=>{R.Arbitrum="https://arbiscan.io";R.Avalanche="https://snowtrace.io";R.Base="https://basescan.org";R.BinanceSmartChain="https://bscscan.com";R.Bitcoin="https://blockchair.com/bitcoin";R.BitcoinCash="https://www.blockchair.com/bitcoin-cash";R.Chainflip="https://explorer.polkascan.io/polkadot";R.Cosmos="https://www.mintscan.io/cosmos";R.Dash="https://blockchair.com/dash";R.Dogecoin="https://blockchair.com/dogecoin";R.Ethereum="https://etherscan.io";R.Kujira="https://finder.kujira.network/kaiyo-1";R.Litecoin="https://blockchair.com/litecoin";R.Maya="https://www.mayascan.org";R.Optimism="https://optimistic.etherscan.io";R.Polkadot="https://polkadot.subscan.io";R.Polygon="https://polygonscan.com";R.Radix="https://dashboard.radixdlt.com";R.THORChain="https://runescan.io";R.Solana="https://solscan.io"})(U||={});var g;((R)=>{R.Arbitrum="ARB";R.Avalanche="AVAX";R.Base="BASE";R.BinanceSmartChain="BSC";R.Bitcoin="BTC";R.BitcoinCash="BCH";R.Cosmos="GAIA";R.Dash="DASH";R.Dogecoin="DOGE";R.Ethereum="ETH";R.Kujira="KUJI";R.Litecoin="LTC";R.Maya="MAYA";R.Optimism="OP";R.Polkadot="DOT";R.Chainflip="FLIP";R.Polygon="MATIC";R.Radix="XRD";R.THORChain="THOR";R.Solana="SOL"})(g||={});var Q;((A)=>{A.Arbitrum="42161";A.ArbitrumHex="0xa4b1";A.Avalanche="43114";A.AvalancheHex="0xa86a";A.Base="8453";A.BaseHex="0x2105";A.BinanceSmartChain="56";A.BinanceSmartChainHex="0x38";A.Bitcoin="bitcoin";A.BitcoinCash="bitcoincash";A.Chainflip="chainflip";A.Cosmos="cosmoshub-4";A.Dash="dash";A.Dogecoin="dogecoin";A.Kujira="kaiyo-1";A.Ethereum="1";A.EthereumHex="0x1";A.Litecoin="litecoin";A.Maya="mayachain-mainnet-v1";A.MayaStagenet="mayachain-stagenet-v1";A.Optimism="10";A.OptimismHex="0xa";A.Polkadot="polkadot";A.Polygon="137";A.PolygonHex="0x89";A.Radix="radix-mainnet";A.THORChain="thorchain-mainnet-v1";A.THORChainStagenet="thorchain-stagenet-v2";A.Solana="solana"})(Q||={});var Ch={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-mainnet-v1"]:"THOR",["solana"]:"SOL"},$n=Object.keys(g),z=Object.values(g),B={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,OP:18,SOL:9,THOR:8,XRD:18},Nh=["DOT","FLIP"],W=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Ah=["BTC","BCH","DASH","DOGE","LTC"],Bh=["GAIA","THOR","MAYA","KUJI"],Th=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],kh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],M=z.reduce((n,h)=>{const t=$n.find((o)=>g[o]===h);if(t)n[h]=t;return n},{}),nn=z.reduce((n,h)=>{return n[h]=Q[M[h]],n},{}),i=z.reduce((n,h)=>{return n[h]=d[M[h]],n},{}),Oh=z.reduce((n,h)=>{const t=`${M[h]}Hex`;return n[h]=Q[t],n},{}),$h=z.reduce((n,h)=>{return n[h]=U[M[h]],n},{});var In;((I)=>{I.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";I.TC_SUPPORTED_TO_ETH="TC-ERC20";I.TC_SUPPORTED_TO_AVAX="TC-ARC20";I.TC_SUPPORTED_TO_BSC="TC-BEP20";I.ETH_TO_TC_SUPPORTED="ERC20-TC";I.ETH_TO_ETH="ERC20-ERC20";I.ETH_TO_AVAX="ERC20-ARC20";I.ETH_TO_BSC="ERC20-BEP20";I.AVAX_TO_TC_SUPPORTED="ARC20-TC";I.AVAX_TO_ETH="ARC20-ERC20";I.AVAX_TO_AVAX="ARC20-ARC20";I.AVAX_TO_BSC="ARC20-BEP20";I.BSC_TO_TC_SUPPORTED="BEP20-TC";I.BSC_TO_ETH="BEP20-ERC20";I.BSC_TO_AVAX="BEP20-ARC20";I.BSC_TO_BSC="BEP20-BEP20"})(In||={});var Lh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],_h=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Gh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var Ln;((F)=>{F.ARB="0x0000000000000000000000000000000000000000";F.AVAX="0x0000000000000000000000000000000000000000";F.BASE="0x0000000000000000000000000000000000000000";F.ETH="0x0000000000000000000000000000000000000000";F.BSC="0x0000000000000000000000000000000000000000";F.MATIC="0x0000000000000000000000000000000000001010";F.OP="0x4200000000000000000000000000000000000042"})(Ln||={});var _n;((R)=>{R.ARB="m/44'/60'/0'/0";R.AVAX="m/44'/60'/0'/0";R.BASE="m/44'/60'/0'/0";R.BCH="m/44'/145'/0'/0";R.BSC="m/44'/60'/0'/0";R.BTC="m/84'/0'/0'/0";R.DASH="m/44'/5'/0'/0";R.DOGE="m/44'/3'/0'/0";R.DOT="////";R.ETH="m/44'/60'/0'/0";R.FLIP="////";R.GAIA="m/44'/118'/0'/0";R.KUJI="m/44'/118'/0'/0";R.LTC="m/84'/2'/0'/0";R.MATIC="m/44'/60'/0'/0";R.MAYA="m/44'/931'/0'/0";R.OP="m/44'/60'/0'/0";R.SOL="m/44'/501'/0'/0";R.THOR="m/44'/931'/0'/0";R.XRD="////"})(_n||={});var E={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],XRD:[0,0,0,0,0],DOT:[0,0,0,0,0],FLIP:[0,0,0,0,0]};var hn;((O)=>{O.BRAVE="BRAVE";O.COINBASE_MOBILE="COINBASE_MOBILE";O.COINBASE_WEB="COINBASE_WEB";O.EIP6963="EIP6963";O.EXODUS="EXODUS";O.KEEPKEY="KEEPKEY";O.KEPLR="KEPLR";O.KEYSTORE="KEYSTORE";O.LEDGER="LEDGER";O.LEDGER_LIVE="LEDGER_LIVE";O.METAMASK="METAMASK";O.OKX="OKX";O.OKX_MOBILE="OKX_MOBILE";O.PHANTOM="PHANTOM";O.POLKADOT_JS="POLKADOT_JS";O.RADIX_WALLET="RADIX_WALLET";O.TREZOR="TREZOR";O.TALISMAN="TALISMAN";O.TRUSTWALLET_WEB="TRUSTWALLET_WEB";O.WALLETCONNECT="WALLETCONNECT";O.XDEFI="XDEFI"})(hn||={});var Gn;((o)=>{o[o.NoError=36864]="NoError";o[o.LockedDevice=21781]="LockedDevice";o[o.TC_NotFound=65535]="TC_NotFound"})(Gn||={});var gn;((o)=>{o.Average="average";o.Fast="fast";o.Fastest="fastest"})(gn||={});var Pn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(Pn||={});var tn;((N)=>{N.NAME_REGISTER="~";N.BOND="BOND";N.DEPOSIT="+";N.LEAVE="LEAVE";N.UNBOND="UNBOND";N.WITHDRAW="-";N.OPEN_LOAN="$+";N.CLOSE_LOAN="$-";N.RUNEPOOL_DEPOSIT="POOL+";N.RUNEPOOL_WITHDRAW="POOL-"})(tn||={});var un;((c)=>{c.unknownError="unknownError";c.test_error="test_error";c.providerDetailsError="providerDetailsError";c.blockHeaderNotFound="blockHeaderNotFound";c.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";c.blockHashNotFoundAtHash="blockHashNotFoundAtHash";c.txHashMissing="txHashMissing";c.assetValueMissingInfo="assetValueMissingInfo";c.invalidAsset="invalidAsset";c.blockIsRequired="blockIsRequired";c.currentBlockHeaderNotFound="currentBlockHeaderNotFound";c.failedToRetrieveBalance="failedToRetrieveBalance";c.failedToRetrieveBlock="failedToRetrieveBlock";c.failedToRetrieveFees="failedToRetrieveFees";c.notImplementedBCH="notImplementedBCH";c.notImplementedDoge="notImplementedDoge";c.noPoolsFound="noPoolsFound";c.noVaultsFound="noVaultsFound";c.noTxFound="noTxFound";c.noInputCoinFound="noInputCoinFound";c.noBlockDataFound="noBlockDataFound";c.multipleCosmosMessages="multipleCosmosMessages";c.heightOrHashNotProvided="heightOrHashNotProvided";c.unknownDenom="unknownDenom";c.invalidBlockHeight="invalidBlockHeight";c.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";c.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";c.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";c.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";c.txMemoUndefined="txMemoUndefined";c.txMemoIncorrect="txMemoIncorrect";c.txTypeNotFound="txTypeNotFound";c.txNoMessage="txNoMessage";c.txNotFound="txNotFound";c.txReceiptNotFound="txReceiptNotFound";c.txParsingError="txParsingError";c.blockNotFound="blockNotFound";c.balanceNotFound="balanceNotFound";c.configError="configError";c.noQuoteResponse="noQuoteResponse";c.noPoolAssetsFound="noPoolAssetsFound";c.noThorchainPools="noThorchainPools";c.noMayachainPools="noMayachainPools";c.invalidAffiliateFee="invalidAffiliateFee";c.invalidBuyAssetAddress="invalidBuyAssetAddress";c.invalidSellAssetAddress="invalidSellAssetAddress";c.invalidSourceAddress="invalidSourceAddress";c.invalidDestinationAddress="invalidDestinationAddress";c.sourceAddressIsSmartContract="sourceAddressIsSmartContract";c.destinationAddressIsSmartContract="destinationAddressIsSmartContract";c.invalidChainId="invalidChainId";c.unsupportedChainId="unsupportedChainId";c.unsupportedEVMChainId="unsupportedEVMChainId";c.noWhitelistTokens="noWhitelistTokens";c.failedFetchGasPrice="failedFetchGasPrice";c.failedToCreateDepositChannel="failedToCreateDepositChannel";c.noProviderDetailsFound="noProviderDetailsFound";c.noTokenListsFound="noTokenListsFound";c.tokenNotFound="tokenNotFound";c.tokenPriceNotFound="tokenPriceNotFound";c.swapAmountTooSmall="swapAmountTooSmall";c.legsArrayIsEmpty="legsArrayIsEmpty";c.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";c.noBlockHeaderFound="noBlockHeaderFound";c.failedToSimulateSwap="failedToSimulateSwap";c.addressScreeningFailed="addressScreeningFailed";c.noLiquidtyProvidersFound="noLiquidtyProvidersFound";c.noSaversFound="noSaversFound";c.noInboundAddressesFound="noInboundAddressesFound";c.noInboundAddressFoundForChain="noInboundAddressFoundForChain";c.noLastBlocksFound="noLastBlocksFound";c.noVersionFound="noVersionFound";c.noConstantsFound="noConstantsFound";c.noMimirsFound="noMimirsFound";c.noRoutesFound="noRoutesFound";c.quoteNotFound="quoteNotFound";c.ledgerSignFailed="ledgerSignFailed";c.ledgerFetchSwapFailed="ledgerFetchSwapFailed";c.failedToFetchTx="failedToFetchTx";c.failedBuildTransactionDetails="failedBuildTransactionDetails";c.noLegsForRoute="noLegsForRoute";c.noRouterAddressFound="noRouterAddressFound";c.noAggregatorAddressFound="noAggregatorAddressFound";c.noContractInstanceFound="noContractInstanceFound";c.noContractAddressFound="noContractAddressFound";c.invalidAffiliate="invalidAffiliate";c.providerNotfound="No provider found";c.noRecordFound="No Record found";c.slippageTooLow="Slippage too low";c.tradingHalted="tradingHalted";c.noWrappedGasAsset="noWrappedGasAsset";c.aggregatorAddressNotFound="aggregatorAddressNotFound";c.routerAddressNotFound="routerAddressNotFound";c.dummyAddressNotFound="dummyAddressNotFound";c.trackerError="trackerError";c.noOhlcvDataFound="noOhlcvDataFound";c.noTradingPairs="noTradingPairs";c.noLoanPositionFound="noLoanPositionFound";c.noLendingAvailability="noLendingAvailability";c.lendingRepayTooSmall="lendingRepayTooSmall";c.missingState="missingState";c.ledgerSwapNotFound="ledgerSwapNotFound";c.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";c.errorEstimatingGas="errorEstimatingGas";c.apiKeyInvalid="apiKeyInvalid";c.apiKeyFailedToUpdate="apiKeyFailedToUpdate";c.apiKeyExpired="apiKeyExpired";c.unauthorized="unauthorized";c.failedToCreateMemo="failedToCreateMemo";c.radixIncorrectInstructions="radixIncorrectInstructions";c.invalidAddressForChain="invalidAddressForChain"})(un||={});var Sn;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(Sn||={});var jn;((_)=>{_.CHAINFLIP="CHAINFLIP";_.MAYACHAIN="MAYACHAIN";_.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";_.ONEINCH="ONEINCH";_.PANCAKESWAP="PANCAKESWAP";_.PANGOLIN_V1="PANGOLIN_V1";_.SUSHISWAP_V2="SUSHISWAP_V2";_.THORCHAIN="THORCHAIN";_.THORCHAIN_STREAMING="THORCHAIN_STREAMING";_.TRADERJOE_V2="TRADERJOE_V2";_.UNISWAP_V2="UNISWAP_V2";_.UNISWAP_V3="UNISWAP_V3";_.CAVIAR_V1="CAVIAR_V1"})(jn||={});var Xn;((s)=>{s.LIQUIDITY="liquidity";s.NETWORK="network";s.INBOUND="inbound";s.OUTBOUND="outbound";s.AFFILIATE="affiliate";s.TAX="tax"})(Xn||={});import{red as Rn,yellow as zn}from"picocolors";var pn={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,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,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,toolbox_radix_signer_not_defined:90301,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class L extends Error{static ErrorCode=pn;constructor(n,h){const t=typeof n==="string",o=t?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(o,{cause:{code:L.ErrorCode[o],message:`${o}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,L.prototype)}}function Vh(n){if(n<0)throw new L({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function bh(n){if(n<0)throw new L({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function Kh(n,h){try{return n()}catch(t){if(h)throw new L(h,t);return console.error(t)}}function Dh(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}function xn(n,h){if(!Jn&&n){if(on.has(h))return;on.add(h),console.warn(h)}}var Jn=["production","test"].includes("development"),on=new Set;function Hn(n=""){const h=n.toUpperCase(),[t]=h.split(".");if(cn.includes(t))return!0;const[o]=h.split("/");if(cn.includes(o))return!0;throw new L({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function ih(n){if(n.length>30)return!1;const h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var cn=[...Object.values(g),"TERRA"];function J({value:n,bigIntDecimal:h=Z,decimal:t=Z}){if(t===0)return n.toString();const o=n<0n;let x=n.toString().substring(o?1:0);const H=t-(x.length-1);if(H>0)x="0".repeat(H)+x;const s=x.length-t;let F=x.slice(-t);if(Number.parseInt(F[h]||"0")>=5)F=`${F.substring(0,h-1)}${(Number.parseInt(F[h-1]||"0")+1).toString()}`;else F=F.substring(0,h);return`${o?"-":""}${x.slice(0,s)}.${F}`.replace(/\.?0*$/,"")}function V(n){const t=`${typeof n==="number"?wn.format(n):v(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function sn(n){const h=n.split(".")[1]?.length||0;return Math.max(h,Z)}function v(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var Z=8,X=(n)=>10n**BigInt(n),y=(n)=>Math.log10(Number.parseFloat(n.toString()));class j{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new j({decimal:h,value:J({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return j.fromBigInt(n.getBaseValue("bigint")*X(t)/X(h),t)}constructor(n){const h=v(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:X(Math.max(sn(V(h)),this.decimal||0)),this.#x(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString()})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n){const h=this.formatBigIntToSafeValue(this.bigIntValue,this.decimal||y(this.decimalMultiplier));switch(n){case"number":return Number(h);case"string":return h;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n){const h=this.decimalMultiplier/X(this.decimal||B.THOR),t=this.bigIntValue/h;switch(n){case"number":return Number(t);case"string":return t.toString();case"bigint":return t}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;const t=v(n),o=V(t);if(o==="0"||o==="undefined")return 0n;return this.#o(o,h)}toSignificant(n=6){const[h,t]=this.getValue("string").split("."),o=h||"",x=t||"";if((Number.parseInt(o)?o.length+x.length:x.length)<=n)return this.getValue("string");if(o.length>=n)return o.slice(0,n).padEnd(o.length,"0");if(Number.parseInt(o))return`${o}.${x.slice(0,n-o.length)}`.padEnd(n-o.length,"0");const s=Number.parseInt(x),F=`${s}`.slice(0,n);return`0.${F.padStart(x.length-`${s}`.length+F.length,"0")}`}toFixed(n=6){const[h,t]=this.getValue("string").split("."),o=h||"",x=t||"";if(Number.parseInt(o))return`${o}.${x.slice(0,n)}`.padEnd(n,"0");const H=Number.parseInt(x),s=`${H}`.slice(0,n);return`0.${s.padStart(x.length-`${H}`.length+s.length,"0")}`}toAbbreviation(n=2){const h=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],o=Math.floor(Math.log10(Math.abs(h))/3),x=t[o];if(!x)return this.getValue("string");const H=10**(o*3);return`${(h/H).toFixed(n)}${x}`}toCurrency(n="$",{currencyPosition:h="start",decimal:t=2,decimalSeparator:o=".",thousandSeparator:x=","}={}){const H=this.getValue("number"),[s="",F=""]=H.toFixed(6).split("."),T=s.replace(/\B(?=(\d{3})+(?!\d))/g,x),C=s||F?s==="0"?`${Number.parseFloat(`0.${F}`)}`.replace(".",o):`${T}${Number.parseInt(F)?`${o}${F.slice(0,t)}`:""}`:"0.00";return`${h==="start"?n:""}${C}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){const t=h||this.decimal||Z,o=Math.max(t,y(this.decimalMultiplier)),x=n<0n,H=n.toString().substring(x?1:0),s=o-(H.length-1),F=s>0?"0".repeat(s)+H:H,T=F.length-o;let C=F.slice(-o);if(Number.parseInt(C[t]||"0")>=5)C=`${C.substring(0,t-1)}${(Number.parseInt(C[t-1]||"0")+1).toString()}`;else C=C.substring(0,t);return`${x?"-":""}${F.slice(0,T)}.${C}`.replace(/\.?0*$/,"")}#h(n,...h){const t=this.#t(this,...h),o=Math.max(t,y(this.decimalMultiplier)),x=X(o),H=h.reduce((F,T)=>{const C=this.getBigIntValue(T,o);switch(n){case"add":return F+C;case"sub":return F-C;case"mul":return F*C/x;case"div":{if(C===0n)throw new RangeError("Division by zero");return F*x/C}default:return F}},this.bigIntValue*x/this.decimalMultiplier),s=J({bigIntDecimal:o,decimal:o,value:H});return new this.constructor({decimalMultiplier:X(o),decimal:this.decimal,value:s,identifier:this.toString()})}#n(n,...h){const t=this.#t(this,...h),o=this.getBigIntValue(h[0]||"0",t),x=this.getBigIntValue(this,t);switch(n){case"gt":return x>o;case"gte":return x>=o;case"lt":return x<o;case"lte":return x<=o;case"eqValue":return x===o}}#x(n){const h=V(n)||"0";this.bigIntValue=this.#o(h)}#t(...n){const h=n.map((t)=>{return typeof t==="object"?t.decimal||y(t.decimalMultiplier):sn(V(t))}).filter(Boolean);return Math.max(...h,Z)}#o(n,h){const t=h?X(h):this.decimalMultiplier,o=y(t),[x="",H=""]=n.split(".");return BigInt(`${x}${H.padEnd(o,"0")}`)}}var wn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function xt(n){const h=$.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function yn(n,h=0){Hn(n);const t=b.get(n.toUpperCase()),o=t?.decimal||await Cn(m(n));if(!t)b.set(n.toUpperCase(),{identifier:n,decimal:o});return new $({decimal:o,value:K(h,o),identifier:n})}function Zn(n,h=0){const t=n.split(".")?.[0]?.toUpperCase(),o=t?["MAYA","THOR"].includes(t):!1,[x,H]=o?n.split(".").slice(1).join().split("/"):n.split("/");if(!(x&&H))throw new L({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new $({decimal:8,value:K(h,8),identifier:`${t||"THOR"}.${x}/${H}`})}function K(n,h){return typeof n==="bigint"?J({value:n,bigIntDecimal:h,decimal:h}):n}function m(n){const h=n.slice(0,14).includes("/"),t=n.split(".")?.[0]?.toUpperCase()==="THOR",o=n.split(".")?.[0]?.toUpperCase()==="MAYA",[x,H=""]=t||o?n.split(".").slice(1).join().split("/"):n.split("/");if(h&&!(x&&H))throw new L({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});const s=n.includes(".")&&!h?n:`${o?"MAYA":"THOR"}.${H}`,[F,...T]=s.split("."),C=h?H:T.join("."),N=C.split("-"),G=N.length===1?N[0]:N.slice(0,-1).join("-"),u=N.length===1?void 0:N[N.length-1];return{address:u?.toLowerCase(),chain:F,isGasAsset:r({chain:F,symbol:C}),isSynthetic:h,ticker:G,symbol:(h?`${x}/`:"")+(u?`${G}-${u?.toLowerCase()??""}`:C)}}var b=new Map;class $ extends j{address;chain;isGasAsset=!1;isSynthetic=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:t,chain:o,symbol:x,identifier:H}){super(typeof n==="object"?n:{decimal:h,value:n});const s=m(H||`${o}.${x}`);this.type=An(s),this.tax=t,this.chain=s.chain,this.ticker=s.ticker,this.symbol=s.symbol,this.address=s.address,this.isSynthetic=s.isSynthetic,this.isGasAsset=s.isGasAsset,this.chainId=nn[s.chain]}toString({includeSynthProtocol:n}={}){return this.isSynthetic&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){const[t,o,x]=n.split(".");if(!(t&&o))throw new L({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});const H=t==="THOR"&&x?`${t}.${o}/${x}`:n;return $.from({asset:H,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...o}){const x=n instanceof j?n.getValue("string"):n,H="chain"in o,s=H?o.chain:o.asset,F=H||Fn.includes(s),{identifier:T,decimal:C}=F?Nn(s):{identifier:s,decimal:void 0},{chain:N,isSynthetic:G}=m(T),u=b.get(T.toUpperCase()),_=u?.decimal||C;xn(!(t||_),zn(`Couldn't find static decimal for ${Rn(T)} (Using default ${Rn(B[N])} decimal as fallback).
var l=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,t)=>(typeof require!=="undefined"?require:h)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var M;((k)=>{k.Arbitrum="https://arb1.arbitrum.io/rpc";k.Avalanche="https://node-router.thorswap.net/avalanche-c";k.Base="https://base.llamarpc.com";k.BinanceSmartChain="https://bsc-dataseed.binance.org";k.Bitcoin="https://node-router.thorswap.net/bitcoin";k.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";k.Chainflip="wss://mainnet-archive.chainflip.io";k.Cosmos="https://node-router.thorswap.net/cosmos/rpc";k.Dash="https://node-router.thorswap.net/dash";k.Dogecoin="https://node-router.thorswap.net/dogecoin";k.Ethereum="https://node-router.thorswap.net/ethereum";k.Kujira="https://rpc-kujira.synergynodes.com/";k.Litecoin="https://node-router.thorswap.net/litecoin";k.Maya="https://tendermint.mayachain.info";k.MayaStagenet="https://stagenet.tendermint.mayachain.info";k.Optimism="https://mainnet.optimism.io";k.Polkadot="wss://rpc.polkadot.io";k.Polygon="https://polygon-rpc.com";k.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";k.THORChain="https://rpc.thorswap.net";k.THORChainStagenet="https://stagenet-rpc.ninerealms.com";k.Solana="https://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80"})(M||={});var d;((F)=>{F.Arbitrum="https://arbiscan.io";F.Avalanche="https://snowtrace.io";F.Base="https://basescan.org";F.BinanceSmartChain="https://bscscan.com";F.Bitcoin="https://blockchair.com/bitcoin";F.BitcoinCash="https://www.blockchair.com/bitcoin-cash";F.Chainflip="https://explorer.polkascan.io/polkadot";F.Cosmos="https://www.mintscan.io/cosmos";F.Dash="https://blockchair.com/dash";F.Dogecoin="https://blockchair.com/dogecoin";F.Ethereum="https://etherscan.io";F.Kujira="https://finder.kujira.network/kaiyo-1";F.Litecoin="https://blockchair.com/litecoin";F.Maya="https://www.mayascan.org";F.Optimism="https://optimistic.etherscan.io";F.Polkadot="https://polkadot.subscan.io";F.Polygon="https://polygonscan.com";F.Radix="https://dashboard.radixdlt.com";F.THORChain="https://runescan.io";F.Solana="https://solscan.io"})(d||={});var g;((F)=>{F.Arbitrum="ARB";F.Avalanche="AVAX";F.Base="BASE";F.BinanceSmartChain="BSC";F.Bitcoin="BTC";F.BitcoinCash="BCH";F.Cosmos="GAIA";F.Dash="DASH";F.Dogecoin="DOGE";F.Ethereum="ETH";F.Kujira="KUJI";F.Litecoin="LTC";F.Maya="MAYA";F.Optimism="OP";F.Polkadot="DOT";F.Chainflip="FLIP";F.Polygon="MATIC";F.Radix="XRD";F.THORChain="THOR";F.Solana="SOL"})(g||={});var z;((B)=>{B.Arbitrum="42161";B.ArbitrumHex="0xa4b1";B.Avalanche="43114";B.AvalancheHex="0xa86a";B.Base="8453";B.BaseHex="0x2105";B.BinanceSmartChain="56";B.BinanceSmartChainHex="0x38";B.Bitcoin="bitcoin";B.BitcoinCash="bitcoincash";B.Chainflip="chainflip";B.Cosmos="cosmoshub-4";B.Dash="dash";B.Dogecoin="dogecoin";B.Kujira="kaiyo-1";B.Ethereum="1";B.EthereumHex="0x1";B.Litecoin="litecoin";B.Maya="mayachain-mainnet-v1";B.MayaStagenet="mayachain-stagenet-v1";B.Optimism="10";B.OptimismHex="0xa";B.Polkadot="polkadot";B.Polygon="137";B.PolygonHex="0x89";B.Radix="radix-mainnet";B.THORChain="thorchain-1";B.THORChainStagenet="thorchain-stagenet-v2";B.Solana="solana"})(z||={});var Ah={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},$n=Object.keys(g),Z=Object.values(g),N={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,OP:18,SOL:9,THOR:8,XRD:18},Ch=["DOT","FLIP"],V=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Bh=["BTC","BCH","DASH","DOGE","LTC"],Nh=["GAIA","THOR","MAYA","KUJI"],Th=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],kh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],b=Z.reduce((n,h)=>{const t=$n.find((x)=>g[x]===h);if(t)n[h]=t;return n},{}),nn=Z.reduce((n,h)=>{return n[h]=z[b[h]],n},{}),E=Z.reduce((n,h)=>{return n[h]=M[b[h]],n},{}),Oh=Z.reduce((n,h)=>{const t=`${b[h]}Hex`;return n[h]=z[t],n},{}),$h=Z.reduce((n,h)=>{return n[h]=d[b[h]],n},{});var In;((I)=>{I.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";I.TC_SUPPORTED_TO_ETH="TC-ERC20";I.TC_SUPPORTED_TO_AVAX="TC-ARC20";I.TC_SUPPORTED_TO_BSC="TC-BEP20";I.ETH_TO_TC_SUPPORTED="ERC20-TC";I.ETH_TO_ETH="ERC20-ERC20";I.ETH_TO_AVAX="ERC20-ARC20";I.ETH_TO_BSC="ERC20-BEP20";I.AVAX_TO_TC_SUPPORTED="ARC20-TC";I.AVAX_TO_ETH="ARC20-ERC20";I.AVAX_TO_AVAX="ARC20-ARC20";I.AVAX_TO_BSC="ARC20-BEP20";I.BSC_TO_TC_SUPPORTED="BEP20-TC";I.BSC_TO_ETH="BEP20-ERC20";I.BSC_TO_AVAX="BEP20-ARC20";I.BSC_TO_BSC="BEP20-BEP20"})(In||={});var Lh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],_h=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Gh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var Ln;((R)=>{R.ARB="0x0000000000000000000000000000000000000000";R.AVAX="0x0000000000000000000000000000000000000000";R.BASE="0x0000000000000000000000000000000000000000";R.ETH="0x0000000000000000000000000000000000000000";R.BSC="0x0000000000000000000000000000000000000000";R.MATIC="0x0000000000000000000000000000000000001010";R.OP="0x4200000000000000000000000000000000000042"})(Ln||={});var _n;((F)=>{F.ARB="m/44'/60'/0'/0";F.AVAX="m/44'/60'/0'/0";F.BASE="m/44'/60'/0'/0";F.BCH="m/44'/145'/0'/0";F.BSC="m/44'/60'/0'/0";F.BTC="m/84'/0'/0'/0";F.DASH="m/44'/5'/0'/0";F.DOGE="m/44'/3'/0'/0";F.DOT="////";F.ETH="m/44'/60'/0'/0";F.FLIP="////";F.GAIA="m/44'/118'/0'/0";F.KUJI="m/44'/118'/0'/0";F.LTC="m/84'/2'/0'/0";F.MATIC="m/44'/60'/0'/0";F.MAYA="m/44'/931'/0'/0";F.OP="m/44'/60'/0'/0";F.SOL="m/44'/501'/0'/0";F.THOR="m/44'/931'/0'/0";F.XRD="////"})(_n||={});var v={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],XRD:[0,0,0,0,0],DOT:[0,0,0,0,0],FLIP:[0,0,0,0,0]};var hn;((O)=>{O.BRAVE="BRAVE";O.COINBASE_MOBILE="COINBASE_MOBILE";O.COINBASE_WEB="COINBASE_WEB";O.EIP6963="EIP6963";O.EXODUS="EXODUS";O.KEEPKEY="KEEPKEY";O.KEPLR="KEPLR";O.KEYSTORE="KEYSTORE";O.LEDGER="LEDGER";O.LEDGER_LIVE="LEDGER_LIVE";O.METAMASK="METAMASK";O.OKX="OKX";O.OKX_MOBILE="OKX_MOBILE";O.PHANTOM="PHANTOM";O.POLKADOT_JS="POLKADOT_JS";O.RADIX_WALLET="RADIX_WALLET";O.TREZOR="TREZOR";O.TALISMAN="TALISMAN";O.TRUSTWALLET_WEB="TRUSTWALLET_WEB";O.WALLETCONNECT="WALLETCONNECT";O.XDEFI="XDEFI"})(hn||={});var Gn;((x)=>{x[x.NoError=36864]="NoError";x[x.LockedDevice=21781]="LockedDevice";x[x.TC_NotFound=65535]="TC_NotFound"})(Gn||={});var gn;((x)=>{x.Average="average";x.Fast="fast";x.Fastest="fastest"})(gn||={});var Pn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(Pn||={});var tn;((C)=>{C.NAME_REGISTER="~";C.BOND="BOND";C.DEPOSIT="+";C.LEAVE="LEAVE";C.UNBOND="UNBOND";C.WITHDRAW="-";C.OPEN_LOAN="$+";C.CLOSE_LOAN="$-";C.RUNEPOOL_DEPOSIT="POOL+";C.RUNEPOOL_WITHDRAW="POOL-"})(tn||={});var Sn;((c)=>{c.unknownError="unknownError";c.test_error="test_error";c.providerDetailsError="providerDetailsError";c.blockHeaderNotFound="blockHeaderNotFound";c.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";c.blockHashNotFoundAtHash="blockHashNotFoundAtHash";c.txHashMissing="txHashMissing";c.assetValueMissingInfo="assetValueMissingInfo";c.invalidAsset="invalidAsset";c.blockIsRequired="blockIsRequired";c.currentBlockHeaderNotFound="currentBlockHeaderNotFound";c.failedToRetrieveBalance="failedToRetrieveBalance";c.failedToRetrieveBlock="failedToRetrieveBlock";c.failedToRetrieveFees="failedToRetrieveFees";c.notImplementedBCH="notImplementedBCH";c.notImplementedDoge="notImplementedDoge";c.noPoolsFound="noPoolsFound";c.noVaultsFound="noVaultsFound";c.noTxFound="noTxFound";c.noInputCoinFound="noInputCoinFound";c.noBlockDataFound="noBlockDataFound";c.multipleCosmosMessages="multipleCosmosMessages";c.heightOrHashNotProvided="heightOrHashNotProvided";c.unknownDenom="unknownDenom";c.invalidBlockHeight="invalidBlockHeight";c.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";c.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";c.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";c.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";c.txMemoUndefined="txMemoUndefined";c.txMemoIncorrect="txMemoIncorrect";c.txTypeNotFound="txTypeNotFound";c.txNoMessage="txNoMessage";c.txNotFound="txNotFound";c.txReceiptNotFound="txReceiptNotFound";c.txParsingError="txParsingError";c.blockNotFound="blockNotFound";c.balanceNotFound="balanceNotFound";c.configError="configError";c.noQuoteResponse="noQuoteResponse";c.noPoolAssetsFound="noPoolAssetsFound";c.noThorchainPools="noThorchainPools";c.noMayachainPools="noMayachainPools";c.invalidAffiliateFee="invalidAffiliateFee";c.invalidBuyAssetAddress="invalidBuyAssetAddress";c.invalidSellAssetAddress="invalidSellAssetAddress";c.invalidSourceAddress="invalidSourceAddress";c.invalidDestinationAddress="invalidDestinationAddress";c.sourceAddressIsSmartContract="sourceAddressIsSmartContract";c.destinationAddressIsSmartContract="destinationAddressIsSmartContract";c.invalidChainId="invalidChainId";c.unsupportedChainId="unsupportedChainId";c.unsupportedEVMChainId="unsupportedEVMChainId";c.noWhitelistTokens="noWhitelistTokens";c.failedFetchGasPrice="failedFetchGasPrice";c.failedToCreateDepositChannel="failedToCreateDepositChannel";c.noProviderDetailsFound="noProviderDetailsFound";c.noTokenListsFound="noTokenListsFound";c.tokenNotFound="tokenNotFound";c.tokenPriceNotFound="tokenPriceNotFound";c.swapAmountTooSmall="swapAmountTooSmall";c.legsArrayIsEmpty="legsArrayIsEmpty";c.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";c.noBlockHeaderFound="noBlockHeaderFound";c.failedToSimulateSwap="failedToSimulateSwap";c.addressScreeningFailed="addressScreeningFailed";c.noLiquidtyProvidersFound="noLiquidtyProvidersFound";c.noSaversFound="noSaversFound";c.noInboundAddressesFound="noInboundAddressesFound";c.noInboundAddressFoundForChain="noInboundAddressFoundForChain";c.noLastBlocksFound="noLastBlocksFound";c.noVersionFound="noVersionFound";c.noConstantsFound="noConstantsFound";c.noMimirsFound="noMimirsFound";c.noRoutesFound="noRoutesFound";c.quoteNotFound="quoteNotFound";c.ledgerSignFailed="ledgerSignFailed";c.ledgerFetchSwapFailed="ledgerFetchSwapFailed";c.failedToFetchTx="failedToFetchTx";c.failedBuildTransactionDetails="failedBuildTransactionDetails";c.noLegsForRoute="noLegsForRoute";c.noRouterAddressFound="noRouterAddressFound";c.noAggregatorAddressFound="noAggregatorAddressFound";c.noContractInstanceFound="noContractInstanceFound";c.noContractAddressFound="noContractAddressFound";c.invalidAffiliate="invalidAffiliate";c.providerNotfound="No provider found";c.noRecordFound="No Record found";c.slippageTooLow="Slippage too low";c.tradingHalted="tradingHalted";c.noWrappedGasAsset="noWrappedGasAsset";c.aggregatorAddressNotFound="aggregatorAddressNotFound";c.routerAddressNotFound="routerAddressNotFound";c.dummyAddressNotFound="dummyAddressNotFound";c.trackerError="trackerError";c.noOhlcvDataFound="noOhlcvDataFound";c.noTradingPairs="noTradingPairs";c.noLoanPositionFound="noLoanPositionFound";c.noLendingAvailability="noLendingAvailability";c.lendingRepayTooSmall="lendingRepayTooSmall";c.missingState="missingState";c.ledgerSwapNotFound="ledgerSwapNotFound";c.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";c.errorEstimatingGas="errorEstimatingGas";c.apiKeyInvalid="apiKeyInvalid";c.apiKeyFailedToUpdate="apiKeyFailedToUpdate";c.apiKeyExpired="apiKeyExpired";c.unauthorized="unauthorized";c.failedToCreateMemo="failedToCreateMemo";c.radixIncorrectInstructions="radixIncorrectInstructions";c.invalidAddressForChain="invalidAddressForChain"})(Sn||={});var jn;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(jn||={});var pn;((_)=>{_.CHAINFLIP="CHAINFLIP";_.MAYACHAIN="MAYACHAIN";_.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";_.ONEINCH="ONEINCH";_.PANCAKESWAP="PANCAKESWAP";_.PANGOLIN_V1="PANGOLIN_V1";_.SUSHISWAP_V2="SUSHISWAP_V2";_.THORCHAIN="THORCHAIN";_.THORCHAIN_STREAMING="THORCHAIN_STREAMING";_.TRADERJOE_V2="TRADERJOE_V2";_.UNISWAP_V2="UNISWAP_V2";_.UNISWAP_V3="UNISWAP_V3";_.CAVIAR_V1="CAVIAR_V1"})(pn||={});var un;((s)=>{s.LIQUIDITY="liquidity";s.NETWORK="network";s.INBOUND="inbound";s.OUTBOUND="outbound";s.AFFILIATE="affiliate";s.TAX="tax"})(un||={});import{red as Fn,yellow as zn}from"picocolors";function Qh({apiKey:n,...h}){i={...h,apiKey:n}}async function K(n,h){const{apiKey:t,...x}=i,{searchParams:o,json:H,body:s}=h,R={...Xn,...x.headers,...h.headers,...H?{"Content-Type":"application/json"}:{}},T=H?JSON.stringify(H):s,A=new URL(n);if(o)A.search=new URLSearchParams(o).toString();if(t)R["x-api-key"]=t;try{const G=await(await fetch(A.toString(),{...x,...h,body:T,headers:R})).json();if(h.responseHandler)return h.responseHandler(G);return G}catch(C){if(h.onError)return h.onError(C);console.error(C)}}var i={},Xn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},y={get:async(n,h)=>K(n,{...h,method:"GET"}),post:async(n,h)=>K(n,{...h,method:"POST"}),extend:(n)=>{const h={...i,...n};return{get:async(t,x)=>K(t,{...h,...x,method:"GET"}),post:async(t,x)=>K(t,{...h,...x,method:"POST"}),extend:(t)=>y.extend({...h,...t})}}};var yn={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_xdefi_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,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 L extends Error{static ErrorCode=yn;constructor(n,h){const t=typeof n==="string",x=t?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(x,{cause:{code:L.ErrorCode[x],message:`${x}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,L.prototype)}}function Dh(n){if(n<0)throw new L({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function Uh(n){if(n<0)throw new L({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function ah(n,h){try{return n()}catch(t){if(h)throw new L(h,t);return console.error(t)}}function dh(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}function on(n,h){if(!Jn&&n){if(xn.has(h))return;xn.add(h),console.warn(h)}}async function Eh(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{return(await y.get(`${n!=="thorchain-1"?"https://stagenet-rpc.ninerealms.com":"https://rpc.thorswap.net"}/status`)).result.node_info.network}catch(h){return n}}var Jn=["production","test"].includes("development"),xn=new Set;function Hn(n=""){const h=n.toUpperCase(),[t]=h.split(".");if(cn.includes(t))return!0;const[x]=h.split("/");if(cn.includes(x))return!0;throw new L({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function rh(n){if(n.length>30)return!1;const h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var cn=[...Object.values(g),"TERRA"];function J({value:n,bigIntDecimal:h=Y,decimal:t=Y}){if(t===0)return n.toString();const x=n<0n;let o=n.toString().substring(x?1:0);const H=t-(o.length-1);if(H>0)o="0".repeat(H)+o;const s=o.length-t;let R=o.slice(-t);if(Number.parseInt(R[h]||"0")>=5)R=`${R.substring(0,h-1)}${(Number.parseInt(R[h-1]||"0")+1).toString()}`;else R=R.substring(0,h);return`${x?"-":""}${o.slice(0,s)}.${R}`.replace(/\.?0*$/,"")}function D(n){const t=`${typeof n==="number"?wn.format(n):m(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function sn(n){const h=n.split(".")[1]?.length||0;return Math.max(h,Y)}function m(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var Y=8,u=(n)=>10n**BigInt(n),f=(n)=>Math.log10(Number.parseFloat(n.toString()));class p{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new p({decimal:h,value:J({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return p.fromBigInt(n.getBaseValue("bigint")*u(t)/u(h),t)}constructor(n){const h=m(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:u(Math.max(sn(D(h)),this.decimal||0)),this.#o(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n){const h=this.formatBigIntToSafeValue(this.bigIntValue,this.decimal||f(this.decimalMultiplier));switch(n){case"number":return Number(h);case"string":return h;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n){const h=this.decimalMultiplier/u(this.decimal||N.THOR),t=this.bigIntValue/h;switch(n){case"number":return Number(t);case"string":return t.toString();case"bigint":return t}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;const t=m(n),x=D(t);if(x==="0"||x==="undefined")return 0n;return this.#x(x,h)}toSignificant(n=6){const[h,t]=this.getValue("string").split("."),x=h||"",o=t||"";if((Number.parseInt(x)?x.length+o.length:o.length)<=n)return this.getValue("string");if(x.length>=n)return x.slice(0,n).padEnd(x.length,"0");if(Number.parseInt(x))return`${x}.${o.slice(0,n-x.length)}`.padEnd(n-x.length,"0");const s=Number.parseInt(o),R=`${s}`.slice(0,n);return`0.${R.padStart(o.length-`${s}`.length+R.length,"0")}`}toFixed(n=6){const[h,t]=this.getValue("string").split("."),x=h||"",o=t||"";if(Number.parseInt(x))return`${x}.${o.slice(0,n)}`.padEnd(n,"0");const H=Number.parseInt(o),s=`${H}`.slice(0,n);return`0.${s.padStart(o.length-`${H}`.length+s.length,"0")}`}toAbbreviation(n=2){const h=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],x=Math.floor(Math.log10(Math.abs(h))/3),o=t[x];if(!o)return this.getValue("string");const H=10**(x*3);return`${(h/H).toFixed(n)}${o}`}toCurrency(n="$",{currencyPosition:h="start",decimal:t=2,decimalSeparator:x=".",thousandSeparator:o=","}={}){const H=this.getValue("number"),[s="",R=""]=H.toFixed(6).split("."),T=s.replace(/\B(?=(\d{3})+(?!\d))/g,o),A=s||R?s==="0"?`${Number.parseFloat(`0.${R}`)}`.replace(".",x):`${T}${Number.parseInt(R)?`${x}${R.slice(0,t)}`:""}`:"0.00";return`${h==="start"?n:""}${A}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){const t=h||this.decimal||Y,x=Math.max(t,f(this.decimalMultiplier)),o=n<0n,H=n.toString().substring(o?1:0),s=x-(H.length-1),R=s>0?"0".repeat(s)+H:H,T=R.length-x;let A=R.slice(-x);if(Number.parseInt(A[t]||"0")>=5)A=`${A.substring(0,t-1)}${(Number.parseInt(A[t-1]||"0")+1).toString()}`;else A=A.substring(0,t);return`${o?"-":""}${R.slice(0,T)}.${A}`.replace(/\.?0*$/,"")}#h(n,...h){const t=this.#t(this,...h),x=Math.max(t,f(this.decimalMultiplier)),o=u(x),H=h.reduce((R,T)=>{const A=this.getBigIntValue(T,x);switch(n){case"add":return R+A;case"sub":return R-A;case"mul":return R*A/o;case"div":{if(A===0n)throw new RangeError("Division by zero");return R*o/A}default:return R}},this.bigIntValue*o/this.decimalMultiplier),s=J({bigIntDecimal:x,decimal:x,value:H});return new this.constructor({decimalMultiplier:u(x),decimal:this.decimal,value:s,identifier:this.toString()})}#n(n,...h){const t=this.#t(this,...h),x=this.getBigIntValue(h[0]||"0",t),o=this.getBigIntValue(this,t);switch(n){case"gt":return o>x;case"gte":return o>=x;case"lt":return o<x;case"lte":return o<=x;case"eqValue":return o===x}}#o(n){const h=D(n)||"0";this.bigIntValue=this.#x(h)}#t(...n){const h=n.map((t)=>{return typeof t==="object"?t.decimal||f(t.decimalMultiplier):sn(D(t))}).filter(Boolean);return Math.max(...h,Y)}#x(n,h){const t=h?u(h):this.decimalMultiplier,x=f(t),[o="",H=""]=n.split(".");return BigInt(`${o}${H.padEnd(x,"0")}`)}}var wn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function Ft(n){const h=$.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function Zn(n,h=0){Hn(n);const t=U.get(n.toUpperCase()),x=t?.decimal||await An(r(n));if(!t)U.set(n.toUpperCase(),{identifier:n,decimal:x});return new $({decimal:x,value:a(h,x),identifier:n})}function fn(n,h=0){const t=n.split(".")?.[0]?.toUpperCase(),x=t?["MAYA","THOR"].includes(t):!1,[o,H]=x?n.split(".").slice(1).join().split("/"):n.split("/");if(!(o&&H))throw new L({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new $({decimal:8,value:a(h,8),identifier:`${t||"THOR"}.${o}/${H}`})}function a(n,h){return typeof n==="bigint"?J({value:n,bigIntDecimal:h,decimal:h}):n}function r(n){const h=n.slice(0,14).includes("/"),t=n.split(".")?.[0]?.toUpperCase()==="THOR",x=n.split(".")?.[0]?.toUpperCase()==="MAYA",[o,H=""]=t||x?n.split(".").slice(1).join().split("/"):n.split("/");if(h&&!(o&&H))throw new L({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});const s=n.includes(".")&&!h?n:`${x?"MAYA":"THOR"}.${H}`,[R,...T]=s.split("."),A=h?H:T.join("."),C=A.split("-"),G=C.length===1?C[0]:C.slice(0,-1).join("-"),S=C.length===1?void 0:C[C.length-1];return{address:S?.toLowerCase(),chain:R,isGasAsset:e({chain:R,symbol:A}),isSynthetic:h,ticker:G,symbol:(h?`${o}/`:"")+(S?`${G}-${S?.toLowerCase()??""}`:A)}}var U=new Map;class $ extends p{address;chain;isGasAsset=!1;isSynthetic=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:t,chain:x,symbol:o,identifier:H}){super(typeof n==="object"?n:{decimal:h,value:n});const s=r(H||`${x}.${o}`);this.type=Bn(s),this.tax=t,this.chain=s.chain,this.ticker=s.ticker,this.symbol=s.symbol,this.address=s.address,this.isSynthetic=s.isSynthetic,this.isGasAsset=s.isGasAsset,this.chainId=nn[s.chain]}toString({includeSynthProtocol:n}={}){return this.isSynthetic&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){const[t,x,o]=n.split(".");if(!(t&&x))throw new L({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});const H=t==="THOR"&&o?`${t}.${x}/${o}`:n;return $.from({asset:H,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...x}){const o=n instanceof p?n.getValue("string"):n,H="chain"in x,s=H?x.chain:x.asset,R=H||Rn.includes(s),{identifier:T,decimal:A}=R?Cn(s):{identifier:s,decimal:void 0},{chain:C,isSynthetic:G}=r(T),S=U.get(T.toUpperCase()),_=S?.decimal||A;on(!(t||_),zn(`Couldn't find static decimal for ${Fn(T)} (Using default ${Fn(N[C])} 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:f,identifier:w,tax:I}=u||{decimal:_||B[N],identifier:T},p=h?K(BigInt(x),h):K(x,f);return t?yn(w,h?p:x):G?Zn(w,p):new $({tax:I,decimal:f,identifier:w,value:p})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((t)=>{for(let o of Object.values(t))for(let{identifier:x,chain:H,...s}of o.tokens)b.set(x.toUpperCase(),{identifier:x,decimal:"decimals"in s?s.decimals:B[H]});n({ok:!0})})}catch(t){console.error(t),h({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return $.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return $.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return $.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=B.THOR){return $.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=B.THOR){return $.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return $.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(g).includes(n))return $.from({chain:n,value:h});return $.from({asset:n,value:h})}}function Ht({apiKey:n,...h}){e={...h,apiKey:n}}async function D(n,h){const{apiKey:t,...o}=e,{searchParams:x,json:H,body:s}=h,F={...Yn,...o.headers,...h.headers,...H?{"Content-Type":"application/json"}:{}},T=H?JSON.stringify(H):s,C=new URL(n);if(x)C.search=new URLSearchParams(x).toString();if(t)F["x-api-key"]=t;try{const G=await(await fetch(C.toString(),{...o,...h,body:T,headers:F})).json();if(h.responseHandler)return h.responseHandler(G);return G}catch(N){if(h.onError)return h.onError(N);console.error(N)}}var e={},Yn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},a={get:async(n,h)=>D(n,{...h,method:"GET"}),post:async(n,h)=>D(n,{...h,method:"POST"}),extend:(n)=>{const h={...e,...n};return{get:async(t,o)=>D(t,{...h,...o,method:"GET"}),post:async(t,o)=>D(t,{...h,...o,method:"POST"}),extend:(t)=>a.extend({...h,...t})}}};async function Tt(n){const h=await import("@swapkit/tokens");for(let t of Object.values(h))for(let{identifier:o,chain:x,...H}of t.tokens){if("identifier"in n&&o===n.identifier)return o;if("address"in H&&"chain"in n&&x===n.chain&&H.address.toLowerCase()===n.contract.toLowerCase())return o}return}var fn="0x313ce567",Fn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],Bn=async({chain:n,to:h})=>{try{const{result:t}=await a.post(i[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:fn},"latest"]})});return Number.parseInt(BigInt(t||B[n]).toString())}catch(t){return console.error(t),B[n]}},qn=async({symbol:n})=>{try{const h=n.split("-")[1]?.toLowerCase(),{manager:t}=await a.post(`${i["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return t.divisibility.value.divisibility}catch(h){return console.error(h),B["XRD"]}},Qn=(n)=>{if(n==="ETH")return B.ETH;const h=n.split("-"),t=h.length===1?void 0:h[h.length-1]?.toLowerCase();return t?.startsWith("0x")?Bn({chain:"ETH",to:t}):B.ETH},Wn=(n)=>{const h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?Bn({chain:"AVAX",to:t.toLowerCase()}):B.AVAX},Mn=(n)=>{if(n==="BSC")return B.BSC;return B.BSC},Vn=(n)=>{if(n==="XRD")return B.XRD;return qn({symbol:n})},Cn=({chain:n,symbol:h})=>{switch(n){case"ETH":return Qn(h);case"AVAX":return Wn(h);case"BSC":return Mn(h);case"XRD":return Vn(h);default:return B[n]}},Nt=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return $.from({asset:`${n}.ETH`});case"MAYA":return $.from({asset:`${n}.CACAO`});case"GAIA":return $.from({asset:`${n}.ATOM`});case"BSC":return $.from({asset:`${n}.BNB`});case"THOR":return $.from({asset:`${n}.RUNE`});default:return $.from({asset:`${n}.${n}`})}},r=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},Nn=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:B[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:B[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:B[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:B[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:B[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:B[n]}}},An=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},At=(n)=>{const[h,...t]=n.split("."),o=n.includes("/"),x=t.join("."),H=x?.split("-"),s=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:h,symbol:x,ticker:s,synth:o}},bn=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),Kn=(n)=>{const[h,t]=n.split(".");if(!W.includes(h))return!0;const o=t.split("-"),x=o.length===1?void 0:o[o.length-1];return r({chain:h,symbol:t})||!!x},Bt=(n)=>n.filter(({chain:h,value:t,symbol:o})=>{const x=`${h}.${o}`;return!bn.test(x)&&Kn(x)&&t!=="0"});function $t([n,h,t,o,x]){return`m/${n}'/${h}'/${t}'/${o}${typeof x!=="number"?"":`/${x}`}`}function It({chain:n,index:h,addressIndex:t=0,type:o}){if(W.includes(n)){if(o==="legacy")return[44,60,0,h];if(o==="ledgerLive")return[44,60,h,0,t];return Tn(E[n],h)}const x=n==="LTC"?2:0;switch(o){case"nativeSegwitMiddleAccount":return[84,x,h,0,t];case"segwit":return[49,x,0,0,h];case"legacy":return[44,x,0,0,h];default:return Tn(E[n],h)}}function Lt(n){const[h,t,o]=n.split("/").map((x)=>Number.parseInt(x,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Tn=(n,h)=>{return[...n.slice(0,n.length-1),h]};function Dn({liquidityUnits:n,poolUnits:h,runeDepth:t}){const o=P(n),x=P(h),H=P(t),s=o.mul(H),F=x.mul(x).mul(2),T=x.mul(o).mul(2),C=o.mul(o),N=x.mul(x).mul(x);return s.mul(F.sub(T).add(C)).div(N)}function an({liquidityUnits:n,poolUnits:h,assetDepth:t}){const o=P(n),x=P(h),H=P(t),s=o.mul(H),F=x.mul(x).mul(2),T=x.mul(o).mul(2),C=o.mul(o),N=s.mul(F.sub(T).add(C)),G=x.mul(x).mul(x);return N.div(G)}function Pt({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:o}){return Dn({runeDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function ut({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:o}){return an({assetDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function P(n){return S.fromBigInt(BigInt(n),B.THOR)}function dn({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o}){return{assetAmount:P(o).mul(n).div(h),runeAmount:P(t).mul(n).div(h)}}function St({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o,percent:x}){return Object.fromEntries(Object.entries(dn({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o})).map(([H,s])=>[H,s.mul(x)]))}function jt({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:o,runeAmount:x,assetAmount:H}){const s=new S({value:n,decimal:8}),F=new S({value:t,decimal:8}),T=new S({value:h,decimal:8}),C=new S({value:x,decimal:8}),N=new S({value:H,decimal:8}),G=C.mul(F),u=N.mul(s),_=C.mul(N),f=s.mul(F),w=T.mul(G.add(u.add(_.mul(2)))),I=G.add(u.add(f.mul(2))),p=w.div(I),q=P(o).add(p);if(p.getBaseValue("number")===0)return q.div(T).getBaseValue("number");const On=T.add(q);return q.div(On).getBaseValue("number")}function Xt({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:o}){if(n==="0"||h==="0"||t==="0"||o==="0")return 0;const x=P(t),H=P(o),s=P(h),F=P(n),T=s.mul(x).sub(H.mul(F)),C=H.mul(F).add(x.mul(H));return Math.abs(T.div(C).getBaseValue("number"))}function Un({type:n,address:h}){return`${n}:${h}`}function En({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function yt(n){return Y("POOL+",n)}function vn({chain:n,symbol:h,...t}){return Y(`${"+"}:${n}/${h}`,t)}function mn({chain:n,symbol:h,address:t,...o}){const x=hh({chain:n,symbol:h}),H=t?`:${t}:`:":";return Y(`${"+"}:${x}${H}`,o)}function rn({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function en({chain:n,symbol:h,ticker:t,basisPoints:o,targetAsset:x}){const H=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,s=x?`:${x}`:"";return`${"-"}:${n}.${H}:${o}${s}`}function Zt({basisPoints:n,...h}){return Y(`${"POOL-"}:${n}`,h)}function ln({name:n,chain:h,address:t,owner:o}){const x=`${"~"}:${n}:${h}:${t}`,H=o?`:${o}`:"";return`${x}${H}`}function Yt({name:n,chain:h,asset:t,payout:o,owner:x}){return`${"~"}:${n}:${h}:${o}:${x}:${t}`}function nh(n,{asset:h,address:t,minAmount:o,...x}){const H=`${n}:${h}:${t}`,s=o?`:${o}`:"";return Y(`${H}${s}`,x)}function Y(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){const o=`${n}${h?`:${h}:${t||0}`:""}`;return o.endsWith(":")?o.slice(0,-1):o}function hh({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var ft=(n,h)=>{switch(n){case"LEAVE":case"BOND":return Un({type:n,address:h?.address});case"UNBOND":return En({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return ln(h);case"$+":case"$-":return nh(n,h);case"+":{const{chain:t,symbol:o,address:x,singleSide:H}=h;if(H)return vn({chain:t,symbol:o});return mn({chain:t,symbol:o,address:x})}case"-":{const{chain:t,ticker:o,symbol:x,basisPoints:H,targetAssetString:s,singleSide:F}=h;if(F)return rn({chain:t,symbol:x,basisPoints:H});return en({chain:t,ticker:o,symbol:x,basisPoints:H,targetAsset:s})}default:throw new L({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};function at({chain:n,covalentApiKey:h,ethplorerApiKey:t}){const o=n!=="ETH"&&!h?"covalentApiKey":t?void 0:"ethplorerApiKey";if(o)throw new L({errorKey:"wallet_missing_api_key",info:{missingKey:o}});return{covalentApiKey:h,ethplorerApiKey:t}}function dt(){const n=[];function h(o){if(n.map((x)=>x.info.uuid).includes(o.detail.info.uuid))return;n.push(o.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:t}}var th=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],oh=(n,h,t)=>async(...o)=>{try{await xh(h,t)}catch(x){throw new L({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return n(...o)},kn=({provider:n,params:h,method:t})=>{if(!n?.send)throw new L("helpers_not_found_provider");const o=h?Array.isArray(h)?h:[h]:[];return n.send(t,o)},Mt=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{const o=th.reduce((x,H)=>{if(!n[H])return x;const s=n[H];if(typeof s!=="function")return x;return{...x,[H]:oh(s,t,h)}},{});return{...n,...o}},Vt=(n,h)=>kn({provider:n,method:"wallet_addEthereumChain",params:[h]}),xh=(n,h="0x1")=>kn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]}),bt=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},Kt=()=>{const{isTrust:n,isBraveWallet:h,__XDEFI:t,overrideIsMetaMask:o,selectedProvider:x}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(o&&x?.isCoinbaseWallet)return"COINBASE_WEB";if(t)"XDEFI";return"METAMASK"},Dt=(n)=>{return ch().includes(n)},ch=()=>{const n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,o=window?.ethereum?.isTrust||window?.trustwallet,x=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=[];if(n)H.push("METAMASK");if(h)H.push("XDEFI");if(t)H.push("BRAVE");if(o)H.push("TRUSTWALLET_WEB");if(x)H.push("COINBASE_WEB");if(Hh())H.push("OKX_MOBILE");return H},Hh=()=>{const n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),o=h||t,x=/OKApp/i.test(n);return o&&x},Ut=()=>typeof window.ethereum!=="undefined";class S extends j{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new S({decimal:h,value:J({value:n,bigIntDecimal:h,decimal:h})})}}export{Kh as wrapWithThrow,oh as wrapMethodWithNetworkSwitch,xn as warnOnce,ih as validateTNS,Hn as validateIdentifier,xh as switchEVMWalletNetwork,Ht as setRequestClientConfig,Mt as prepareNetworkSwitch,Hh as okxMobileEnabled,ch as listWeb3EVMWallets,Ut as isWeb3Detected,r as isGasAsset,Dt as isDetected,Lt as getWalletFormatFor,Vh as getTHORNameCost,St as getSymmetricWithdraw,dn as getSymmetricPoolShare,xt as getMinAmountByChain,en as getMemoForWithdraw,En as getMemoForUnbond,rn as getMemoForSaverWithdraw,vn as getMemoForSaverDeposit,Zt as getMemoForRunePoolWithdraw,yt as getMemoForRunePoolDeposit,ln as getMemoForNameRegister,Yt as getMemoForNamePreferredAssetRegister,nh as getMemoForLoan,Un as getMemoForLeaveAndBond,mn as getMemoForDeposit,ft as getMemoFor,bh as getMAYANameCost,Xt as getLiquiditySlippage,Nt as getGasAsset,jt as getEstimatedPoolShare,Kt as getETHDefaultWallet,dt as getEIP6963Wallets,It as getDerivationPathFor,Cn as getDecimal,Nn as getCommonAssetInfo,Dh as getChainIdentifier,Pt as getAsymmetricRuneWithdrawAmount,Dn as getAsymmetricRuneShare,ut as getAsymmetricAssetWithdrawAmount,an as getAsymmetricAssetShare,An as getAssetType,J as formatBigIntToSafeValue,Tt as findAssetBy,Bt as filterAssets,at as ensureEVMApiKeys,$t as derivationPathToString,Yn as defaultRequestHeaders,At as assetFromString,Vt as addEVMWalletNetwork,bt as addAccountsChangedCallback,Sn as WarningCodeEnum,hn as WalletOption,Ah as UTXOChains,Th as TCSupportedChains,S as SwapKitNumber,L as SwapKitError,Nh as SubstrateChains,Gh as SWAP_OUT,_h as SWAP_IN,a as RequestClient,d as RPCUrl,In as QuoteMode,jn as ProviderName,E as NetworkDerivationPath,tn as MemoType,kh as MAYASupportedChains,Gn as LedgerErrorCode,Xn as FeeTypeEnum,gn as FeeOption,U as ExplorerUrl,un as ErrorCode,W as EVMChains,_n as DerivationPath,Bh as CosmosChains,Ln as ContractAddress,Fn as CommonAssetStrings,i as ChainToRPC,Oh as ChainToHexChainId,$h as ChainToExplorerUrl,nn as ChainToChainId,Ch as ChainIdToChain,Q as ChainId,g as Chain,j as BigIntArithmetics,B as BaseDecimal,$ as AssetValue,Pn as ApproveMode,Lh as AGG_SWAP};
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`));const{decimal:Q,identifier:w,tax:I}=S||{decimal:_||N[C],identifier:T},X=h?a(BigInt(o),h):a(o,Q);return t?Zn(w,h?X:o):G?fn(w,X):new $({tax:I,decimal:Q,identifier:w,value:X})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((t)=>{for(let x of Object.values(t))for(let{identifier:o,chain:H,...s}of x.tokens)U.set(o.toUpperCase(),{identifier:o,decimal:"decimals"in s?s.decimals:N[H]});n({ok:!0})})}catch(t){console.error(t),h({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return $.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return $.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return $.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=N.THOR){return $.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=N.THOR){return $.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return $.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(g).includes(n))return $.from({chain:n,value:h});return $.from({asset:n,value:h})}}async function Ot(n){const h=await import("@swapkit/tokens");for(let t of Object.values(h))for(let{identifier:x,chain:o,...H}of t.tokens){if("identifier"in n&&x===n.identifier)return x;if("address"in H&&"chain"in n&&o===n.chain&&H.address.toLowerCase()===n.contract.toLowerCase())return x}return}var Yn="0x313ce567",Rn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],Nn=async({chain:n,to:h})=>{try{const{result:t}=await y.post(E[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:Yn},"latest"]})});return Number.parseInt(BigInt(t||N[n]).toString())}catch(t){return console.error(t),N[n]}},qn=async({symbol:n})=>{try{const h=n.split("-")[1]?.toLowerCase(),{manager:t}=await y.post(`${E["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return t.divisibility.value.divisibility}catch(h){return console.error(h),N["XRD"]}},Qn=(n)=>{if(n==="ETH")return N.ETH;const h=n.split("-"),t=h.length===1?void 0:h[h.length-1]?.toLowerCase();return t?.startsWith("0x")?Nn({chain:"ETH",to:t}):N.ETH},Wn=(n)=>{const h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?Nn({chain:"AVAX",to:t.toLowerCase()}):N.AVAX},Mn=(n)=>{if(n==="BSC")return N.BSC;return N.BSC},Vn=(n)=>{if(n==="XRD")return N.XRD;return qn({symbol:n})},An=({chain:n,symbol:h})=>{switch(n){case"ETH":return Qn(h);case"AVAX":return Wn(h);case"BSC":return Mn(h);case"XRD":return Vn(h);default:return N[n]}},Nt=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return $.from({asset:`${n}.ETH`});case"MAYA":return $.from({asset:`${n}.CACAO`});case"GAIA":return $.from({asset:`${n}.ATOM`});case"BSC":return $.from({asset:`${n}.BNB`});case"THOR":return $.from({asset:`${n}.RUNE`});default:return $.from({asset:`${n}.${n}`})}},e=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},Cn=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:N[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:N[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:N[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:N[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:N[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:N[n]}}},Bn=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},Tt=(n)=>{const[h,...t]=n.split("."),x=n.includes("/"),o=t.join("."),H=o?.split("-"),s=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:h,symbol:o,ticker:s,synth:x}},bn=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),Kn=(n)=>{const[h,t]=n.split(".");if(!V.includes(h))return!0;const x=t.split("-"),o=x.length===1?void 0:x[x.length-1];return e({chain:h,symbol:t})||!!o},kt=(n)=>n.filter(({chain:h,value:t,symbol:x})=>{const o=`${h}.${x}`;return!bn.test(o)&&Kn(o)&&t!=="0"});function Lt([n,h,t,x,o]){return`m/${n}'/${h}'/${t}'/${x}${typeof o!=="number"?"":`/${o}`}`}function _t({chain:n,index:h,addressIndex:t=0,type:x}){if(V.includes(n)){if(x==="legacy")return[44,60,0,h];if(x==="ledgerLive")return[44,60,h,0,t];return Tn(v[n],h)}const o=n==="LTC"?2:0;switch(x){case"nativeSegwitMiddleAccount":return[84,o,h,0,t];case"segwit":return[49,o,0,0,h];case"legacy":return[44,o,0,0,h];default:return Tn(v[n],h)}}function Gt(n){const[h,t,x]=n.split("/").map((o)=>Number.parseInt(o,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Tn=(n,h)=>{return[...n.slice(0,n.length-1),h]};function Dn({liquidityUnits:n,poolUnits:h,runeDepth:t}){const x=P(n),o=P(h),H=P(t),s=x.mul(H),R=o.mul(o).mul(2),T=o.mul(x).mul(2),A=x.mul(x),C=o.mul(o).mul(o);return s.mul(R.sub(T).add(A)).div(C)}function Un({liquidityUnits:n,poolUnits:h,assetDepth:t}){const x=P(n),o=P(h),H=P(t),s=x.mul(H),R=o.mul(o).mul(2),T=o.mul(x).mul(2),A=x.mul(x),C=s.mul(R.sub(T).add(A)),G=o.mul(o).mul(o);return C.div(G)}function jt({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:x}){return Dn({runeDepth:h,liquidityUnits:t,poolUnits:x}).mul(n)}function pt({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:x}){return Un({assetDepth:h,liquidityUnits:t,poolUnits:x}).mul(n)}function P(n){return j.fromBigInt(BigInt(n),N.THOR)}function an({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:x}){return{assetAmount:P(x).mul(n).div(h),runeAmount:P(t).mul(n).div(h)}}function ut({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:x,percent:o}){return Object.fromEntries(Object.entries(an({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:x})).map(([H,s])=>[H,s.mul(o)]))}function Xt({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:x,runeAmount:o,assetAmount:H}){const s=new j({value:n,decimal:8}),R=new j({value:t,decimal:8}),T=new j({value:h,decimal:8}),A=new j({value:o,decimal:8}),C=new j({value:H,decimal:8}),G=A.mul(R),S=C.mul(s),_=A.mul(C),Q=s.mul(R),w=T.mul(G.add(S.add(_.mul(2)))),I=G.add(S.add(Q.mul(2))),X=w.div(I),W=P(x).add(X);if(X.getBaseValue("number")===0)return W.div(T).getBaseValue("number");const On=T.add(W);return W.div(On).getBaseValue("number")}function yt({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:x}){if(n==="0"||h==="0"||t==="0"||x==="0")return 0;const o=P(t),H=P(x),s=P(h),R=P(n),T=s.mul(o).sub(H.mul(R)),A=H.mul(R).add(o.mul(H));return Math.abs(T.div(A).getBaseValue("number"))}function dn({type:n,address:h}){return`${n}:${h}`}function En({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function ft(n){return q("POOL+",n)}function vn({chain:n,symbol:h,...t}){return q(`${"+"}:${n}/${h}`,t)}function mn({chain:n,symbol:h,address:t,...x}){const o=hh({chain:n,symbol:h}),H=t?`:${t}:`:":";return q(`${"+"}:${o}${H}`,x)}function rn({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function en({chain:n,symbol:h,ticker:t,basisPoints:x,targetAsset:o}){const H=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,s=o?`:${o}`:"";return`${"-"}:${n}.${H}:${x}${s}`}function Yt({basisPoints:n,...h}){return q(`${"POOL-"}:${n}`,h)}function ln({name:n,chain:h,address:t,owner:x}){const o=`${"~"}:${n}:${h}:${t}`,H=x?`:${x}`:"";return`${o}${H}`}function qt({name:n,chain:h,asset:t,payout:x,owner:o}){return`${"~"}:${n}:${h}:${x}:${o}:${t}`}function nh(n,{asset:h,address:t,minAmount:x,...o}){const H=`${n}:${h}:${t}`,s=x?`:${x}`:"";return q(`${H}${s}`,o)}function q(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){const x=`${n}${h?`:${h}:${t||0}`:""}`;return x.endsWith(":")?x.slice(0,-1):x}function hh({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var Qt=(n,h)=>{switch(n){case"LEAVE":case"BOND":return dn({type:n,address:h?.address});case"UNBOND":return En({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return ln(h);case"$+":case"$-":return nh(n,h);case"+":{const{chain:t,symbol:x,address:o,singleSide:H}=h;if(H)return vn({chain:t,symbol:x});return mn({chain:t,symbol:x,address:o})}case"-":{const{chain:t,ticker:x,symbol:o,basisPoints:H,targetAssetString:s,singleSide:R}=h;if(R)return rn({chain:t,symbol:o,basisPoints:H});return en({chain:t,ticker:x,symbol:o,basisPoints:H,targetAsset:s})}default:throw new L({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};function dt({chain:n,covalentApiKey:h,ethplorerApiKey:t}){const x=n!=="ETH"&&!h?"covalentApiKey":t?void 0:"ethplorerApiKey";if(x)throw new L({errorKey:"wallet_missing_api_key",info:{missingKey:x}});return{covalentApiKey:h,ethplorerApiKey:t}}function Et(){const n=[];function h(x){if(n.map((o)=>o.info.uuid).includes(x.detail.info.uuid))return;n.push(x.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:t}}var th=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],xh=(n,h,t)=>async(...x)=>{try{await oh(h,t)}catch(o){throw new L({errorKey:"helpers_failed_to_switch_network",info:{error:o}})}return n(...x)},kn=({provider:n,params:h,method:t})=>{if(!n?.send)throw new L("helpers_not_found_provider");const x=h?Array.isArray(h)?h:[h]:[];return n.send(t,x)},bt=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{const x=th.reduce((o,H)=>{if(!n[H])return o;const s=n[H];if(typeof s!=="function")return o;return{...o,[H]:xh(s,t,h)}},{});return{...n,...x}},Kt=(n,h)=>kn({provider:n,method:"wallet_addEthereumChain",params:[h]}),oh=(n,h="0x1")=>kn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]}),Dt=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},Ut=()=>{const{isTrust:n,isBraveWallet:h,__XDEFI:t,overrideIsMetaMask:x,selectedProvider:o}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(x&&o?.isCoinbaseWallet)return"COINBASE_WEB";if(t)"XDEFI";return"METAMASK"},at=(n)=>{return ch().includes(n)},ch=()=>{const n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,x=window?.ethereum?.isTrust||window?.trustwallet,o=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=[];if(n)H.push("METAMASK");if(h)H.push("XDEFI");if(t)H.push("BRAVE");if(x)H.push("TRUSTWALLET_WEB");if(o)H.push("COINBASE_WEB");if(Hh())H.push("OKX_MOBILE");return H},Hh=()=>{const n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),x=h||t,o=/OKApp/i.test(n);return x&&o},vt=()=>typeof window.ethereum!=="undefined";class j extends p{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new j({decimal:h,value:J({value:n,bigIntDecimal:h,decimal:h})})}}export{ah as wrapWithThrow,xh as wrapMethodWithNetworkSwitch,on as warnOnce,rh as validateTNS,Hn as validateIdentifier,oh as switchEVMWalletNetwork,Qh as setRequestClientConfig,bt as prepareNetworkSwitch,Hh as okxMobileEnabled,ch as listWeb3EVMWallets,vt as isWeb3Detected,e as isGasAsset,at as isDetected,Gt as getWalletFormatFor,Dh as getTHORNameCost,ut as getSymmetricWithdraw,an as getSymmetricPoolShare,Ft as getMinAmountByChain,en as getMemoForWithdraw,En as getMemoForUnbond,rn as getMemoForSaverWithdraw,vn as getMemoForSaverDeposit,Yt as getMemoForRunePoolWithdraw,ft as getMemoForRunePoolDeposit,ln as getMemoForNameRegister,qt as getMemoForNamePreferredAssetRegister,nh as getMemoForLoan,dn as getMemoForLeaveAndBond,mn as getMemoForDeposit,Qt as getMemoFor,Uh as getMAYANameCost,yt as getLiquiditySlippage,Nt as getGasAsset,Xt as getEstimatedPoolShare,Ut as getETHDefaultWallet,Et as getEIP6963Wallets,Eh as getDynamicChainId,_t as getDerivationPathFor,An as getDecimal,Cn as getCommonAssetInfo,dh as getChainIdentifier,jt as getAsymmetricRuneWithdrawAmount,Dn as getAsymmetricRuneShare,pt as getAsymmetricAssetWithdrawAmount,Un as getAsymmetricAssetShare,Bn as getAssetType,J as formatBigIntToSafeValue,Ot as findAssetBy,kt as filterAssets,dt as ensureEVMApiKeys,Lt as derivationPathToString,Xn as defaultRequestHeaders,Tt as assetFromString,Kt as addEVMWalletNetwork,Dt as addAccountsChangedCallback,jn as WarningCodeEnum,hn as WalletOption,Bh as UTXOChains,Th as TCSupportedChains,j as SwapKitNumber,L as SwapKitError,Ch as SubstrateChains,Gh as SWAP_OUT,_h as SWAP_IN,y as RequestClient,M as RPCUrl,In as QuoteMode,pn as ProviderName,v as NetworkDerivationPath,tn as MemoType,kh as MAYASupportedChains,Gn as LedgerErrorCode,un as FeeTypeEnum,gn as FeeOption,d as ExplorerUrl,Sn as ErrorCode,V as EVMChains,_n as DerivationPath,Nh as CosmosChains,Ln as ContractAddress,Rn as CommonAssetStrings,E as ChainToRPC,Oh as ChainToHexChainId,$h as ChainToExplorerUrl,nn as ChainToChainId,Ah as ChainIdToChain,z as ChainId,g as Chain,p as BigIntArithmetics,N as BaseDecimal,$ as AssetValue,Pn as ApproveMode,Lh as AGG_SWAP};
//# debugId=4FE9A8FC98F16CEC64756E2164756E21
//# debugId=BB5728AB006E996264756E2164756E21

@@ -5,13 +5,13 @@ {

"dependencies": {
"@swapkit/contracts": "1.0.4",
"@swapkit/tokens": "0.0.0-nightly-20240903175543",
"@swapkit/contracts": "0.0.0-nightly-20240905095330",
"@swapkit/tokens": "0.0.0-nightly-20240905095330",
"picocolors": "1.0.1"
},
"devDependencies": {
"@swapkit/toolbox-cosmos": "0.0.0-nightly-20240903175543",
"@swapkit/toolbox-evm": "0.0.0-nightly-20240903175543",
"@swapkit/toolbox-radix": "0.0.0-nightly-20240903175543",
"@swapkit/toolbox-solana": "0.0.0-nightly-20240903175543",
"@swapkit/toolbox-substrate": "0.0.0-nightly-20240903175543",
"@swapkit/toolbox-utxo": "0.0.0-nightly-20240903175543"
"@swapkit/toolbox-cosmos": "0.0.0-nightly-20240905095330",
"@swapkit/toolbox-evm": "0.0.0-nightly-20240905095330",
"@swapkit/toolbox-radix": "0.0.0-nightly-20240905095330",
"@swapkit/toolbox-solana": "0.0.0-nightly-20240905095330",
"@swapkit/toolbox-substrate": "0.0.0-nightly-20240905095330",
"@swapkit/toolbox-utxo": "0.0.0-nightly-20240905095330"
},

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

"types": "./src/index.ts",
"version": "0.0.0-nightly-20240903175543"
"version": "0.0.0-nightly-20240905095330"
}
import { describe, expect, test } from "bun:test";
import { BaseDecimal, Chain } from "../../types";
import { assetFromString, getAssetType, getDecimal } from "../asset.ts";
import { assetFromString, getAssetType, getDecimal } from "../asset";

@@ -6,0 +6,0 @@ const tickerMap: Record<string, string> = {

@@ -14,3 +14,3 @@ import { describe, expect, test } from "bun:test";

getMemoForWithdraw,
} from "../memo.ts";
} from "../memo";

@@ -17,0 +17,0 @@ describe("getMemoForSaverDeposit", () => {

import { describe, expect, test } from "bun:test";
import { Chain } from "../../types";
import { findAssetBy } from "../asset.ts";
import { getTHORNameCost } from "../others.ts";
import { findAssetBy } from "../asset";
import { getTHORNameCost } from "../others";

@@ -7,0 +7,0 @@ describe("getTHORNameCost", () => {

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

import { AssetValue } from "../modules/assetValue.ts";
import { RequestClient } from "../modules/requestClient.ts";
import { BaseDecimal, Chain, ChainToRPC, type EVMChain, EVMChains } from "../types/chains.ts";
import type { RadixCoreStateResourceDTO } from "../types/radix.ts";
import type { TokenNames } from "../types/tokens.ts";
import { AssetValue } from "../modules/assetValue";
import { RequestClient } from "../modules/requestClient";
import { BaseDecimal, Chain, ChainToRPC, type EVMChain, EVMChains } from "../types/chains";
import type { RadixCoreStateResourceDTO } from "../types/radix";
import type { TokenNames } from "../types/tokens";

@@ -7,0 +7,0 @@ const getDecimalMethodHex = "0x313ce567";

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

import { SwapKitNumber } from "../index.ts";
import { BaseDecimal } from "../types/chains.ts";
import { SwapKitNumber } from "../index";
import { BaseDecimal } from "../types/chains";

@@ -4,0 +4,0 @@ type ShareParams<T extends {}> = T & {

@@ -169,3 +169,3 @@ import { SwapKitError } from "../modules/swapKitError";

*/
export const getMemoFor = <T extends MemoType>(memoType: T, options: NotWorth) => {
export const getMemoFor = <T extends MemoType>(memoType: T, options: any) => {
switch (memoType) {

@@ -172,0 +172,0 @@ case MemoType.LEAVE:

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

import { RequestClient } from "../modules/requestClient";
import { type ErrorKeys, SwapKitError } from "../modules/swapKitError";
import { Chain } from "../types";
import { Chain, ChainId, RPCUrl } from "../types";

@@ -67,1 +68,14 @@ // 10 rune for register, 1 rune per year

}
export async function getDynamicChainId(chainId: ChainId = ChainId.THORChain) {
if (![ChainId.THORChainStagenet, ChainId.THORChain, "thorchain-mainnet-v1"].includes(chainId))
return chainId;
try {
const response = await RequestClient.get<{ result: { node_info: { network: string } } }>(
`${chainId !== ChainId.THORChain ? RPCUrl.THORChainStagenet : RPCUrl.THORChain}/status`,
);
return response.result.node_info.network as ChainId;
} catch (_error) {
return chainId;
}
}

@@ -29,3 +29,3 @@ import type { BrowserProvider } from "ethers";

coinbaseWalletExtension: EthereumWindowProvider;
braveSolana: Todo;
braveSolana: any;
} & Window;

@@ -47,3 +47,3 @@

provider?: BrowserProvider;
params?: Todo;
params?: any;
method:

@@ -74,3 +74,3 @@ | "wallet_addEthereumChain"

export const wrapMethodWithNetworkSwitch = <T extends (...args: Todo[]) => Todo>(
export const wrapMethodWithNetworkSwitch = <T extends (...args: any[]) => any>(
func: T,

@@ -80,3 +80,3 @@ provider: BrowserProvider,

) =>
(async (...args: Todo[]) => {
(async (...args: any[]) => {
try {

@@ -102,3 +102,3 @@ await switchEVMWalletNetwork(provider, chainId);

export const prepareNetworkSwitch = <T extends { [key: string]: (...args: Todo[]) => Todo }>({
export const prepareNetworkSwitch = <T extends { [key: string]: (...args: any[]) => any }>({
toolbox,

@@ -105,0 +105,0 @@ chainId,

export * from "@swapkit/contracts";
export * from "./types/index.ts";
export * from "./types/index";

@@ -7,9 +7,9 @@ /**

*/
export * from "./helpers/asset.ts";
export * from "./helpers/derivationPath.ts";
export * from "./helpers/liquidity.ts";
export * from "./helpers/memo.ts";
export * from "./helpers/others.ts";
export * from "./helpers/validators.ts";
export * from "./helpers/web3wallets.ts";
export * from "./helpers/asset";
export * from "./helpers/derivationPath";
export * from "./helpers/liquidity";
export * from "./helpers/memo";
export * from "./helpers/others";
export * from "./helpers/validators";
export * from "./helpers/web3wallets";

@@ -19,6 +19,6 @@ /**

*/
export * from "./modules/assetValue.ts";
export * from "./modules/bigIntArithmetics.ts";
export * from "./modules/requestClient.ts";
export * from "./modules/swapKitError.ts";
export * from "./modules/swapKitNumber.ts";
export * from "./modules/assetValue";
export * from "./modules/bigIntArithmetics";
export * from "./modules/requestClient";
export * from "./modules/swapKitError";
export * from "./modules/swapKitNumber";
import { describe, expect, test } from "bun:test";
import { BaseDecimal, Chain } from "../../types/chains.ts";
import { AssetValue, getMinAmountByChain } from "../assetValue.ts";
import { BaseDecimal, Chain } from "../../types/chains";
import { AssetValue, getMinAmountByChain } from "../assetValue";

@@ -93,2 +93,53 @@ describe("AssetValue", () => {

describe("set", () => {
test("get a copy of an assetValue with a new value", () => {
const btc = AssetValue.from({
asset: "BTC.BTC",
});
const btc2 = btc.set(10);
expect(btc2).toBeDefined();
expect(btc2).toEqual(
expect.objectContaining({
chain: Chain.Bitcoin,
decimal: 8,
isGasAsset: true,
isSynthetic: false,
symbol: "BTC",
ticker: "BTC",
}),
);
expect(btc.getValue("string")).toBe("0");
expect(btc2.getValue("string")).toBe("10");
});
test("get a copy of a synth assetValue with a new value", () => {
const synthAvax = AssetValue.from({
asset: "THOR.AVAX/AVAX",
value: 1,
});
const synthAvax2 = synthAvax.set(10);
expect(synthAvax2).toBeDefined();
expect(synthAvax2).toEqual(
expect.objectContaining({
chain: Chain.THORChain,
decimal: 8,
isGasAsset: false,
isSynthetic: true,
symbol: "AVAX/AVAX",
ticker: "AVAX",
}),
);
expect(synthAvax.getValue("string")).toBe("1");
expect(synthAvax2.getValue("string")).toBe("10");
expect(synthAvax.toString({ includeSynthProtocol: true })).toBe("THOR.AVAX/AVAX");
expect(synthAvax2.toString({ includeSynthProtocol: true })).toBe("THOR.AVAX/AVAX");
});
});
describe("toUrl", () => {

@@ -95,0 +146,0 @@ test("returns asset compliance with url", () => {

import { describe, expect, test } from "bun:test";
import { formatBigIntToSafeValue } from "../bigIntArithmetics.ts";
import { formatBigIntToSafeValue } from "../bigIntArithmetics";

@@ -5,0 +5,0 @@ describe("BigIntArithmatics", () => {

import { describe, expect, test } from "bun:test";
import { SwapKitNumber } from "../swapKitNumber.ts";
import { SwapKitNumber } from "../swapKitNumber";

@@ -5,0 +5,0 @@ describe("SwapKitNumber", () => {

@@ -9,12 +9,12 @@ import { red, yellow } from "picocolors";

isGasAsset,
} from "../helpers/asset.ts";
import { warnOnce } from "../helpers/others.ts";
import { validateIdentifier } from "../helpers/validators.ts";
import { BaseDecimal, Chain, type ChainId, ChainToChainId } from "../types/chains.ts";
import type { TokenNames, TokenTax } from "../types/tokens.ts";
} from "../helpers/asset";
import { warnOnce } from "../helpers/others";
import { validateIdentifier } from "../helpers/validators";
import { BaseDecimal, Chain, type ChainId, ChainToChainId } from "../types/chains";
import type { TokenNames, TokenTax } from "../types/tokens";
import type { NumberPrimitives } from "./bigIntArithmetics.ts";
import { BigIntArithmetics, formatBigIntToSafeValue } from "./bigIntArithmetics.ts";
import { SwapKitError } from "./swapKitError.ts";
import type { SwapKitValueType } from "./swapKitNumber.ts";
import type { NumberPrimitives } from "./bigIntArithmetics";
import { BigIntArithmetics, formatBigIntToSafeValue } from "./bigIntArithmetics";
import { SwapKitError } from "./swapKitError";
import type { SwapKitValueType } from "./swapKitNumber";

@@ -162,3 +162,3 @@ const staticTokensMap = new Map<

static loadStaticAssets() {
return new Promise<{ ok: true } | { ok: false; message: string; error: Todo }>(
return new Promise<{ ok: true } | { ok: false; message: string; error: any }>(
(resolve, reject) => {

@@ -165,0 +165,0 @@ try {

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

import { BaseDecimal } from "../types/chains.ts";
import type { SwapKitNumber } from "./swapKitNumber.ts";
import { BaseDecimal } from "../types/chains";
import type { SwapKitNumber } from "./swapKitNumber";

@@ -99,3 +99,8 @@ type NumberPrimitivesType = {

// @ts-expect-error False positive
return new this.constructor({ decimal: this.decimal, value, identifier: this.toString() });
return new this.constructor({
decimal: this.decimal,
value,
// @ts-expect-error False positive
identifier: this.toString({ includeSynthProtocol: true }),
});
}

@@ -102,0 +107,0 @@ add(...args: InitialisationValueType[]) {

@@ -5,4 +5,4 @@ type Options = Parameters<typeof fetch>[1] & {

method?: "GET" | "POST";
onError?: (error: NotWorth) => NotWorth;
responseHandler?: (response: NotWorth) => NotWorth;
onError?: (error: any) => any;
responseHandler?: (response: any) => any;
searchParams?: Record<string, string>;

@@ -9,0 +9,0 @@ json?: unknown;

@@ -89,4 +89,2 @@ const errorCodes = {

wallet_polkadot_not_found: 20701,
wallet_radix_not_found: 20801,
wallet_radix_transaction_failed: 20802,
/**

@@ -136,3 +134,2 @@ * Chainflip

toolbox_evm_error_sending_transaction: 90212,
toolbox_radix_signer_not_defined: 90301,
/**

@@ -161,4 +158,4 @@ * Helpers

constructor(
errorOrErrorKey: ErrorKeys | { errorKey: ErrorKeys; info?: Record<string, NotWorth> },
sourceError?: NotWorth,
errorOrErrorKey: ErrorKeys | { errorKey: ErrorKeys; info?: Record<string, any> },
sourceError?: any,
) {

@@ -165,0 +162,0 @@ const isErrorString = typeof errorOrErrorKey === "string";

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

import { BigIntArithmetics, formatBigIntToSafeValue } from "./bigIntArithmetics.ts";
import { BigIntArithmetics, formatBigIntToSafeValue } from "./bigIntArithmetics";

@@ -3,0 +3,0 @@ export type SwapKitValueType = BigIntArithmetics | string | number;

@@ -55,3 +55,3 @@ import { ExplorerUrl, RPCUrl } from "./network";

Radix = "radix-mainnet",
THORChain = "thorchain-mainnet-v1",
THORChain = "thorchain-1",
THORChainStagenet = "thorchain-stagenet-v2",

@@ -58,0 +58,0 @@ Solana = "solana",

@@ -1,4 +0,4 @@

import type { Chain } from "./chains.ts";
import type { ChainApis } from "./sdk.ts";
import type { ChainWallet } from "./wallet.ts";
import type { Chain } from "./chains";
import type { ChainApis } from "./sdk";
import type { ChainWallet } from "./wallet";

@@ -50,13 +50,5 @@ export type ConnectConfig = {

chainflipBrokerUrl?: string;
/**
* @optional for setting the chainflip radix dapp config
*/
radixDappConfig?: {
dAppDefinitionAddress: string;
applicationName: string;
applicationVersion: string;
};
};
export type ConnectWalletParams<M = { [key in string]: NotWorth }> = {
export type ConnectWalletParams<M = { [key in string]: any }> = {
addChain: <T extends Chain>(params: ChainWallet<T> & M) => void;

@@ -63,0 +55,0 @@ apis: ChainApis;

export type RadixCoreStateResourceDTO = {
at_ledger_state?: Todo; // not needed
at_ledger_state?: any; // not needed
manager: {

@@ -13,3 +13,3 @@ resource_type: string;

};
owner_role?: Todo; // not needed
owner_role?: any; // not needed
};

@@ -9,2 +9,3 @@ import type {

ThorchainList,
TraderjoeV1List,
TraderjoeV2List,

@@ -25,2 +26,3 @@ UniswapV2List,

| (typeof ThorchainList)["tokens"][number]["identifier"]
| (typeof TraderjoeV1List)["tokens"][number]["identifier"]
| (typeof TraderjoeV2List)["tokens"][number]["identifier"]

@@ -27,0 +29,0 @@ | (typeof UniswapV2List)["tokens"][number]["identifier"]

import type { CosmosWallets, ThorchainWallets } from "@swapkit/toolbox-cosmos";
import type { EVMWallets } from "@swapkit/toolbox-evm";
import type { RadixWallets } from "@swapkit/toolbox-radix";
import type { SolanaWallets } from "@swapkit/toolbox-solana";
import type { SolanaWallet } from "@swapkit/toolbox-solana";
import type { SubstrateWallets } from "@swapkit/toolbox-substrate";

@@ -66,9 +65,3 @@ import type { UTXOWallets } from "@swapkit/toolbox-utxo";

export type FullWallet = BaseWallet<
EVMWallets &
UTXOWallets &
CosmosWallets &
ThorchainWallets &
SubstrateWallets &
SolanaWallets &
RadixWallets
EVMWallets & UTXOWallets & CosmosWallets & ThorchainWallets & SubstrateWallets & SolanaWallet
>;

@@ -81,3 +74,3 @@

export type SwapKitWallet<ConnectParams extends Todo[]> = (
export type SwapKitWallet<ConnectParams extends any[]> = (
params: ConnectWalletParams,

@@ -84,0 +77,0 @@ ) => (...connectParams: ConnectParams) => boolean | Promise<boolean>;

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