@swapkit/helpers
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -1,6 +0,6 @@ | ||
var e=((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 a;((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"})(a||={});var d;((s)=>{s.Arbitrum="https://arbiscan.io";s.Avalanche="https://snowtrace.io";s.Base="https://basescan.org";s.BinanceSmartChain="https://bscscan.com";s.Bitcoin="https://blockchair.com/bitcoin";s.BitcoinCash="https://www.blockchair.com/bitcoin-cash";s.Chainflip="https://explorer.polkascan.io/polkadot";s.Cosmos="https://www.mintscan.io/cosmos";s.Dash="https://blockchair.com/dash";s.Dogecoin="https://blockchair.com/dogecoin";s.Ethereum="https://etherscan.io";s.Kujira="https://finder.kujira.network/kaiyo-1";s.Litecoin="https://blockchair.com/litecoin";s.Maya="https://www.mayascan.org";s.Optimism="https://optimistic.etherscan.io";s.Polkadot="https://polkadot.subscan.io";s.Polygon="https://polygonscan.com";s.Radix="https://dashboard.radixdlt.com";s.THORChain="https://runescan.io";s.Solana="https://solscan.io"})(d||={});var G;((s)=>{s.Arbitrum="ARB";s.Avalanche="AVAX";s.Base="BASE";s.BinanceSmartChain="BSC";s.Bitcoin="BTC";s.BitcoinCash="BCH";s.Cosmos="GAIA";s.Dash="DASH";s.Dogecoin="DOGE";s.Ethereum="ETH";s.Kujira="KUJI";s.Litecoin="LTC";s.Maya="MAYA";s.Optimism="OP";s.Polkadot="DOT";s.Chainflip="FLIP";s.Polygon="MATIC";s.Radix="XRD";s.THORChain="THOR";s.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 Fh={["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"},On=Object.keys(G),w=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},Ch=["DOT","FLIP"],Q=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Nh=["BTC","BCH","DASH","DOGE","LTC"],Ah=["GAIA","THOR","MAYA","KUJI"],Bh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Th=["ARB","DASH","ETH","KUJI","MAYA","THOR"],W=w.reduce((n,h)=>{const t=On.find((o)=>G[o]===h);if(t)n[h]=t;return n},{}),l=w.reduce((n,h)=>{return n[h]=q[W[h]],n},{}),U=w.reduce((n,h)=>{return n[h]=a[W[h]],n},{}),kh=w.reduce((n,h)=>{const t=`${W[h]}Hex`;return n[h]=q[t],n},{}),Oh=w.reduce((n,h)=>{return n[h]=d[W[h]],n},{});var $n;(($)=>{$.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";$.TC_SUPPORTED_TO_ETH="TC-ERC20";$.TC_SUPPORTED_TO_AVAX="TC-ARC20";$.TC_SUPPORTED_TO_BSC="TC-BEP20";$.ETH_TO_TC_SUPPORTED="ERC20-TC";$.ETH_TO_ETH="ERC20-ERC20";$.ETH_TO_AVAX="ERC20-ARC20";$.ETH_TO_BSC="ERC20-BEP20";$.AVAX_TO_TC_SUPPORTED="ARC20-TC";$.AVAX_TO_ETH="ARC20-ERC20";$.AVAX_TO_AVAX="ARC20-ARC20";$.AVAX_TO_BSC="ARC20-BEP20";$.BSC_TO_TC_SUPPORTED="BEP20-TC";$.BSC_TO_ETH="BEP20-ERC20";$.BSC_TO_AVAX="BEP20-ARC20";$.BSC_TO_BSC="BEP20-BEP20"})($n||={});var Ih=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Lh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],_h=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var In;((F)=>{F.ARB="0x0000000000000000000000000000000000000000";F.AVAX="0x0000000000000000000000000000000000000000";F.BASE="0x0000000000000000000000000000000000000000";F.ETH="0x0000000000000000000000000000000000000000";F.BSC="0x0000000000000000000000000000000000000000";F.MATIC="0x0000000000000000000000000000000000001010";F.OP="0x4200000000000000000000000000000000000042"})(In||={});var Ln;((s)=>{s.ARB="m/44'/60'/0'/0";s.AVAX="m/44'/60'/0'/0";s.BASE="m/44'/60'/0'/0";s.BCH="m/44'/145'/0'/0";s.BSC="m/44'/60'/0'/0";s.BTC="m/84'/0'/0'/0";s.DASH="m/44'/5'/0'/0";s.DOGE="m/44'/3'/0'/0";s.DOT="////";s.ETH="m/44'/60'/0'/0";s.FLIP="////";s.GAIA="m/44'/118'/0'/0";s.KUJI="m/44'/118'/0'/0";s.LTC="m/84'/2'/0'/0";s.MATIC="m/44'/60'/0'/0";s.MAYA="m/44'/931'/0'/0";s.OP="m/44'/60'/0'/0";s.SOL="m/44'/501'/0'/0";s.THOR="m/44'/931'/0'/0";s.XRD="////"})(Ln||={});var i={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 nn;((s)=>{s.BRAVE="BRAVE";s.COINBASE_MOBILE="COINBASE_MOBILE";s.COINBASE_WEB="COINBASE_WEB";s.EIP6963="EIP6963";s.EXODUS="EXODUS";s.KEEPKEY="KEEPKEY";s.KEPLR="KEPLR";s.KEYSTORE="KEYSTORE";s.LEDGER="LEDGER";s.METAMASK="METAMASK";s.OKX="OKX";s.OKX_MOBILE="OKX_MOBILE";s.PHANTOM="PHANTOM";s.POLKADOT_JS="POLKADOT_JS";s.RADIX_WALLET="RADIX_WALLET";s.TREZOR="TREZOR";s.TALISMAN="TALISMAN";s.TRUSTWALLET_WEB="TRUSTWALLET_WEB";s.WALLETCONNECT="WALLETCONNECT";s.XDEFI="XDEFI"})(nn||={});var _n;((o)=>{o[o.NoError=36864]="NoError";o[o.LockedDevice=21781]="LockedDevice";o[o.TC_NotFound=65535]="TC_NotFound"})(_n||={});var Gn;((o)=>{o.Average="average";o.Fast="fast";o.Fastest="fastest"})(Gn||={});var gn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(gn||={});var hn;((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-"})(hn||={});var Pn;((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"})(Pn||={});var un;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(un||={});var Sn;((L)=>{L.CHAINFLIP="CHAINFLIP";L.MAYACHAIN="MAYACHAIN";L.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";L.ONEINCH="ONEINCH";L.PANCAKESWAP="PANCAKESWAP";L.PANGOLIN_V1="PANGOLIN_V1";L.SUSHISWAP_V2="SUSHISWAP_V2";L.THORCHAIN="THORCHAIN";L.THORCHAIN_STREAMING="THORCHAIN_STREAMING";L.TRADERJOE_V2="TRADERJOE_V2";L.UNISWAP_V2="UNISWAP_V2";L.UNISWAP_V3="UNISWAP_V3";L.CAVIAR_V1="CAVIAR_V1"})(Sn||={});var jn;((R)=>{R.LIQUIDITY="liquidity";R.NETWORK="network";R.INBOUND="inbound";R.OUTBOUND="outbound";R.AFFILIATE="affiliate";R.TAX="tax"})(jn||={});import{red as sn,yellow as wn}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,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 I 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:I.ErrorCode[o],message:`${o}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,I.prototype)}}function Mh(n){if(n<0)throw new I({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function Vh(n){if(n<0)throw new I({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function bh(n,h){try{return n()}catch(t){if(h)throw new I(h,t);return console.error(t)}}function Kh(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(!Xn&&n){if(tn.has(h))return;tn.add(h),console.warn(h)}}var Xn=["production","test"].includes("development"),tn=new Set;function cn(n=""){const h=n.toUpperCase(),[t]=h.split(".");if(xn.includes(t))return!0;const[o]=h.split("/");if(xn.includes(o))return!0;throw new I({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function Uh(n){if(n.length>30)return!1;const h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var xn=[...Object.values(G),"TERRA"];function X({value:n,bigIntDecimal:h=y,decimal:t=y}){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 R=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,R)}.${F}`.replace(/\.?0*$/,"")}function M(n){const t=`${typeof n==="number"?Jn.format(n):E(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function Hn(n){const h=n.split(".")[1]?.length||0;return Math.max(h,y)}function E(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var y=8,j=(n)=>10n**BigInt(n),z=(n)=>Math.log10(Number.parseFloat(n.toString()));class S{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new S({decimal:h,value:X({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return S.fromBigInt(n.getBaseValue("bigint")*j(t)/j(h),t)}constructor(n){const h=E(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:j(Math.max(Hn(M(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||z(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/j(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=E(n),o=M(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 R=Number.parseInt(x),F=`${R}`.slice(0,n);return`0.${F.padStart(x.length-`${R}`.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),R=`${H}`.slice(0,n);return`0.${R.padStart(x.length-`${H}`.length+R.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"),[R="",F=""]=H.toFixed(6).split("."),T=R.replace(/\B(?=(\d{3})+(?!\d))/g,x),C=R||F?R==="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||y,o=Math.max(t,z(this.decimalMultiplier)),x=n<0n,H=n.toString().substring(x?1:0),R=o-(H.length-1),F=R>0?"0".repeat(R)+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,z(this.decimalMultiplier)),x=j(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),R=X({bigIntDecimal:o,decimal:o,value:H});return new this.constructor({decimalMultiplier:j(o),decimal:this.decimal,value:R,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=M(n)||"0";this.bigIntValue=this.#o(h)}#t(...n){const h=n.map((t)=>{return typeof t==="object"?t.decimal||z(t.decimalMultiplier):Hn(M(t))}).filter(Boolean);return Math.max(...h,y)}#o(n,h){const t=h?j(h):this.decimalMultiplier,o=z(t),[x="",H=""]=n.split(".");return BigInt(`${x}${H.padEnd(o,"0")}`)}}var Jn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function ot(n){const h=O.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){cn(n);const t=V.get(n.toUpperCase()),o=t?.decimal||await Fn(v(n));if(!t)V.set(n.toUpperCase(),{identifier:n,decimal:o});return new O({decimal:o,value:b(h,o),identifier:n})}function yn(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 I({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new O({decimal:8,value:b(h,8),identifier:`${t||"THOR"}.${x}/${H}`})}function b(n,h){return typeof n==="bigint"?X({value:n,bigIntDecimal:h,decimal:h}):n}function v(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 I({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});const R=n.includes(".")&&!h?n:`${o?"MAYA":"THOR"}.${H}`,[F,...T]=R.split("."),C=h?H:T.join("."),N=C.split("-"),_=N.length===1?N[0]:N.slice(0,-1).join("-"),P=N.length===1?void 0:N[N.length-1];return{address:P?.toLowerCase(),chain:F,isGasAsset:m({chain:F,symbol:C}),isSynthetic:h,ticker:_,symbol:(h?`${x}/`:"")+(P?`${_}-${P?.toLowerCase()??""}`:C)}}var V=new Map;class O extends S{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 R=v(H||`${o}.${x}`);this.type=Nn(R),this.tax=t,this.chain=R.chain,this.ticker=R.ticker,this.symbol=R.symbol,this.address=R.address,this.isSynthetic=R.isSynthetic,this.isGasAsset=R.isGasAsset,this.chainId=l[R.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 I({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});const H=t==="THOR"&&x?`${t}.${o}/${x}`:n;return O.from({asset:H,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...o}){const x=n instanceof S?n.getValue("string"):n,H="chain"in o,R=H?o.chain:o.asset,F=H||Rn.includes(R),{identifier:T,decimal:C}=F?Cn(R):{identifier:R,decimal:void 0},{chain:N,isSynthetic:_}=v(T),P=V.get(T.toUpperCase()),L=P?.decimal||C;on(!(t||L),wn(`Couldn't find static decimal for ${sn(T)} (Using default ${sn(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 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 pn;((s)=>{s.LIQUIDITY="liquidity";s.NETWORK="network";s.INBOUND="inbound";s.OUTBOUND="outbound";s.AFFILIATE="affiliate";s.TAX="tax"})(pn||={});import{red as Rn,yellow as zn}from"picocolors";var Xn={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=Xn;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,p=(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")*p(t)/p(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:p(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/p(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=p(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:p(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?p(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). | ||
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:J,tax:$}=P||{decimal:L||B[N],identifier:T},p=h?b(BigInt(x),h):b(x,f);return t?zn(J,h?p:x):_?yn(J,p):new O({tax:$,decimal:f,identifier:J,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,...R}of o.tokens)V.set(x.toUpperCase(),{identifier:x,decimal:"decimals"in R?R.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 O.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return O.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return O.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=B.THOR){return O.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=B.THOR){return O.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return O.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(G).includes(n))return O.from({chain:n,value:h});return O.from({asset:n,value:h})}}function ct({apiKey:n,...h}){r={...h,apiKey:n}}async function K(n,h){const{apiKey:t,...o}=r,{searchParams:x,json:H,body:R}=h,F={...Zn,...o.headers,...h.headers,...H?{"Content-Type":"application/json"}:{}},T=H?JSON.stringify(H):R,C=new URL(n);if(x)C.search=new URLSearchParams(x).toString();if(t)F["x-api-key"]=t;try{const _=await(await fetch(C.toString(),{...o,...h,body:T,headers:F})).json();if(h.responseHandler)return h.responseHandler(_);return _}catch(N){if(h.onError)return h.onError(N);console.error(N)}}var r={},Zn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},D={get:async(n,h)=>K(n,{...h,method:"GET"}),post:async(n,h)=>K(n,{...h,method:"POST"}),extend:(n)=>{const h={...r,...n};return{get:async(t,o)=>K(t,{...h,...o,method:"GET"}),post:async(t,o)=>K(t,{...h,...o,method:"POST"}),extend:(t)=>D.extend({...h,...t})}}};async function Bt(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",Rn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],An=async({chain:n,to:h})=>{try{const{result:t}=await D.post(U[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]}},Yn=async({symbol:n})=>{try{const h=n.split("-")[1]?.toLowerCase(),{manager:t}=await D.post(`${U["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")?An({chain:"ETH",to:t}):B.ETH},Qn=(n)=>{const h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?An({chain:"AVAX",to:t.toLowerCase()}):B.AVAX},Wn=(n)=>{if(n==="BSC")return B.BSC;return B.BSC},Mn=(n)=>{if(n==="XRD")return B.XRD;return Yn({symbol:n})},Fn=({chain:n,symbol:h})=>{switch(n){case"ETH":return qn(h);case"AVAX":return Qn(h);case"BSC":return Wn(h);case"XRD":return Mn(h);default:return B[n]}},Ct=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return O.from({asset:`${n}.ETH`});case"MAYA":return O.from({asset:`${n}.CACAO`});case"GAIA":return O.from({asset:`${n}.ATOM`});case"BSC":return O.from({asset:`${n}.BNB`});case"THOR":return O.from({asset:`${n}.RUNE`});default:return O.from({asset:`${n}.${n}`})}},m=({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: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]}}},Nn=({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}},Nt=(n)=>{const[h,...t]=n.split("."),o=n.includes("/"),x=t.join("."),H=x?.split("-"),R=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:h,symbol:x,ticker:R,synth:o}},Vn=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),bn=(n)=>{const[h,t]=n.split(".");if(!Q.includes(h))return!0;const o=t.split("-"),x=o.length===1?void 0:o[o.length-1];return m({chain:h,symbol:t})||!!x},At=(n)=>n.filter(({chain:h,value:t,symbol:o})=>{const x=`${h}.${o}`;return!Vn.test(x)&&bn(x)&&t!=="0"});function Ot([n,h,t,o,x]){return`m/${n}'/${h}'/${t}'/${o}${typeof x!=="number"?"":`/${x}`}`}function $t({chain:n,index:h,addressIndex:t=0,type:o}){if(Q.includes(n)){if(o==="legacy")return[44,60,0,h];if(o==="ledgerLive")return[44,60,h,0,t];return Bn(i[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 Bn(i[n],h)}}function It(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 Bn=(n,h)=>{return[...n.slice(0,n.length-1),h]};function Kn({liquidityUnits:n,poolUnits:h,runeDepth:t}){const o=g(n),x=g(h),H=g(t),R=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 R.mul(F.sub(T).add(C)).div(N)}function Dn({liquidityUnits:n,poolUnits:h,assetDepth:t}){const o=g(n),x=g(h),H=g(t),R=o.mul(H),F=x.mul(x).mul(2),T=x.mul(o).mul(2),C=o.mul(o),N=R.mul(F.sub(T).add(C)),_=x.mul(x).mul(x);return N.div(_)}function gt({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:o}){return Kn({runeDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function Pt({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:o}){return Dn({assetDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function g(n){return u.fromBigInt(BigInt(n),B.THOR)}function an({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o}){return{assetAmount:g(o).mul(n).div(h),runeAmount:g(t).mul(n).div(h)}}function ut({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o,percent:x}){return Object.fromEntries(Object.entries(an({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o})).map(([H,R])=>[H,R.mul(x)]))}function St({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:o,runeAmount:x,assetAmount:H}){const R=new u({value:n,decimal:8}),F=new u({value:t,decimal:8}),T=new u({value:h,decimal:8}),C=new u({value:x,decimal:8}),N=new u({value:H,decimal:8}),_=C.mul(F),P=N.mul(R),L=C.mul(N),f=R.mul(F),J=T.mul(_.add(P.add(L.mul(2)))),$=_.add(P.add(f.mul(2))),p=J.div($),Y=g(o).add(p);if(p.getBaseValue("number")===0)return Y.div(T).getBaseValue("number");const kn=T.add(Y);return Y.div(kn).getBaseValue("number")}function jt({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:o}){if(n==="0"||h==="0"||t==="0"||o==="0")return 0;const x=g(t),H=g(o),R=g(h),F=g(n),T=R.mul(x).sub(H.mul(F)),C=H.mul(F).add(x.mul(H));return Math.abs(T.div(C).getBaseValue("number"))}function dn({type:n,address:h}){return`${n}:${h}`}function Un({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function zt(n){return Z("POOL+",n)}function En({chain:n,symbol:h,...t}){return Z(`${"+"}:${n}/${h}`,t)}function vn({chain:n,symbol:h,address:t,...o}){const x=nh({chain:n,symbol:h}),H=t?`:${t}:`:":";return Z(`${"+"}:${x}${H}`,o)}function mn({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function rn({chain:n,symbol:h,ticker:t,basisPoints:o,targetAsset:x}){const H=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,R=x?`:${x}`:"";return`${"-"}:${n}.${H}:${o}${R}`}function yt({basisPoints:n,...h}){return Z(`${"POOL-"}:${n}`,h)}function en({name:n,chain:h,address:t,owner:o}){const x=`${"~"}:${n}:${h}:${t}`,H=o?`:${o}`:"";return`${x}${H}`}function Zt({name:n,chain:h,asset:t,payout:o,owner:x}){return`${"~"}:${n}:${h}:${o}:${x}:${t}`}function ln(n,{asset:h,address:t,minAmount:o,...x}){const H=`${n}:${h}:${t}`,R=o?`:${o}`:"";return Z(`${H}${R}`,x)}function Z(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){const o=`${n}${h?`:${h}:${t||0}`:""}`;return o.endsWith(":")?o.slice(0,-1):o}function nh({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 dn({type:n,address:h?.address});case"UNBOND":return Un({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return en(h);case"$+":case"$-":return ln(n,h);case"+":{const{chain:t,symbol:o,address:x,singleSide:H}=h;if(H)return En({chain:t,symbol:o});return vn({chain:t,symbol:o,address:x})}case"-":{const{chain:t,ticker:o,symbol:x,basisPoints:H,targetAssetString:R,singleSide:F}=h;if(F)return mn({chain:t,symbol:x,basisPoints:H});return rn({chain:t,ticker:o,symbol:x,basisPoints:H,targetAsset:R})}default:throw new I({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};function Dt({chain:n,covalentApiKey:h,ethplorerApiKey:t}){const o=n!=="ETH"&&!h?"covalentApiKey":t?void 0:"ethplorerApiKey";if(o)throw new I({errorKey:"wallet_missing_api_key",info:{missingKey:o}});return{covalentApiKey:h,ethplorerApiKey:t}}function at(){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 hh=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],th=(n,h,t)=>async(...o)=>{try{await oh(h,t)}catch(x){throw new I({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return n(...o)},Tn=({provider:n,params:h,method:t})=>{if(!n?.send)throw new I("helpers_not_found_provider");const o=h?Array.isArray(h)?h:[h]:[];return n.send(t,o)},Wt=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{const o=hh.reduce((x,H)=>{if(!n[H])return x;const R=n[H];if(typeof R!=="function")return x;return{...x,[H]:th(R,t,h)}},{});return{...n,...o}},Mt=(n,h)=>Tn({provider:n,method:"wallet_addEthereumChain",params:[h]}),oh=(n,h="0x1")=>Tn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]}),Vt=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},bt=()=>{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"},Kt=(n)=>{return xh().includes(n)},xh=()=>{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(ch())H.push("OKX_MOBILE");return H},ch=()=>{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},dt=()=>typeof window.ethereum!=="undefined";class u extends S{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new u({decimal:h,value:X({value:n,bigIntDecimal:h,decimal:h})})}}export{bh as wrapWithThrow,th as wrapMethodWithNetworkSwitch,on as warnOnce,Uh as validateTNS,cn as validateIdentifier,oh as switchEVMWalletNetwork,ct as setRequestClientConfig,Wt as prepareNetworkSwitch,ch as okxMobileEnabled,xh as listWeb3EVMWallets,dt as isWeb3Detected,m as isGasAsset,Kt as isDetected,It as getWalletFormatFor,Mh as getTHORNameCost,ut as getSymmetricWithdraw,an as getSymmetricPoolShare,ot as getMinAmountByChain,rn as getMemoForWithdraw,Un as getMemoForUnbond,mn as getMemoForSaverWithdraw,En as getMemoForSaverDeposit,yt as getMemoForRunePoolWithdraw,zt as getMemoForRunePoolDeposit,en as getMemoForNameRegister,Zt as getMemoForNamePreferredAssetRegister,ln as getMemoForLoan,dn as getMemoForLeaveAndBond,vn as getMemoForDeposit,ft as getMemoFor,Vh as getMAYANameCost,jt as getLiquiditySlippage,Ct as getGasAsset,St as getEstimatedPoolShare,bt as getETHDefaultWallet,at as getEIP6963Wallets,$t as getDerivationPathFor,Fn as getDecimal,Cn as getCommonAssetInfo,Kh as getChainIdentifier,gt as getAsymmetricRuneWithdrawAmount,Kn as getAsymmetricRuneShare,Pt as getAsymmetricAssetWithdrawAmount,Dn as getAsymmetricAssetShare,Nn as getAssetType,X as formatBigIntToSafeValue,Bt as findAssetBy,At as filterAssets,Dt as ensureEVMApiKeys,Ot as derivationPathToString,Zn as defaultRequestHeaders,Nt as assetFromString,Mt as addEVMWalletNetwork,Vt as addAccountsChangedCallback,un as WarningCodeEnum,nn as WalletOption,Nh as UTXOChains,Bh as TCSupportedChains,u as SwapKitNumber,I as SwapKitError,Ch as SubstrateChains,_h as SWAP_OUT,Lh as SWAP_IN,D as RequestClient,a as RPCUrl,$n as QuoteMode,Sn as ProviderName,i as NetworkDerivationPath,hn as MemoType,Th as MAYASupportedChains,_n as LedgerErrorCode,jn as FeeTypeEnum,Gn as FeeOption,d as ExplorerUrl,Pn as ErrorCode,Q as EVMChains,Ln as DerivationPath,Ah as CosmosChains,In as ContractAddress,Rn as CommonAssetStrings,U as ChainToRPC,kh as ChainToHexChainId,Oh as ChainToExplorerUrl,l as ChainToChainId,Fh as ChainIdToChain,q as ChainId,G as Chain,S as BigIntArithmetics,B as BaseDecimal,O as AssetValue,gn as ApproveMode,Ih as AGG_SWAP}; | ||
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`));const{decimal:Y,identifier:w,tax:I}=u||{decimal:_||B[N],identifier:T},X=h?K(BigInt(x),h):K(x,Y);return t?yn(w,h?X:x):G?Zn(w,X):new $({tax:I,decimal:Y,identifier:w,value:X})}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={...fn,...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={},fn=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 Yn="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:Yn},"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),Y=s.mul(F),w=T.mul(G.add(u.add(_.mul(2)))),I=G.add(u.add(Y.mul(2))),X=w.div(I),q=P(o).add(X);if(X.getBaseValue("number")===0)return q.div(T).getBaseValue("number");const On=T.add(q);return q.div(On).getBaseValue("number")}function pt({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 f("POOL+",n)}function vn({chain:n,symbol:h,...t}){return f(`${"+"}:${n}/${h}`,t)}function mn({chain:n,symbol:h,address:t,...o}){const x=hh({chain:n,symbol:h}),H=t?`:${t}:`:":";return f(`${"+"}:${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 f(`${"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 ft({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 f(`${H}${s}`,x)}function f(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 Yt=(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,ft as getMemoForNamePreferredAssetRegister,nh as getMemoForLoan,Un as getMemoForLeaveAndBond,mn as getMemoForDeposit,Yt as getMemoFor,bh as getMAYANameCost,pt 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,fn 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,pn 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}; | ||
//# debugId=7BCCE44FE6AAA7A764756E2164756E21 | ||
//# debugId=89BFFB003ED02FFF64756E2164756E21 |
@@ -10,8 +10,8 @@ { | ||
"devDependencies": { | ||
"@swapkit/toolbox-cosmos": "1.1.2", | ||
"@swapkit/toolbox-evm": "1.3.1", | ||
"@swapkit/toolbox-solana": "1.0.23", | ||
"@swapkit/toolbox-radix": "1.0.23", | ||
"@swapkit/toolbox-substrate": "1.2.1", | ||
"@swapkit/toolbox-utxo": "1.1.6" | ||
"@swapkit/toolbox-cosmos": "1.1.3", | ||
"@swapkit/toolbox-evm": "1.3.2", | ||
"@swapkit/toolbox-solana": "1.0.24", | ||
"@swapkit/toolbox-radix": "1.0.24", | ||
"@swapkit/toolbox-substrate": "1.2.2", | ||
"@swapkit/toolbox-utxo": "1.1.7" | ||
}, | ||
@@ -41,3 +41,3 @@ "files": [ | ||
"types": "./src/index.ts", | ||
"version": "1.6.1" | ||
"version": "1.6.2" | ||
} |
@@ -30,2 +30,3 @@ import type { CosmosWallets, ThorchainWallets } from "@swapkit/toolbox-cosmos"; | ||
LEDGER = "LEDGER", | ||
LEDGER_LIVE = "LEDGER_LIVE", | ||
METAMASK = "METAMASK", | ||
@@ -32,0 +33,0 @@ OKX = "OKX", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
315780
4225