@swapkit/helpers 3.0.0-beta.19 → 3.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- var GR={};ER(GR,{wrapWithThrow:()=>Fh,wrapMethodWithNetworkSwitch:()=>vC,warnOnce:()=>m,validateTNS:()=>Wh,validateIdentifier:()=>XC,updateDerivationPath:()=>i,switchEVMWalletNetwork:()=>nC,providerRequest:()=>OC,prepareNetworkSwitch:()=>PR,okxMobileEnabled:()=>mC,loadTokenLists:()=>EC,listWeb3EVMWallets:()=>oC,isWeb3Detected:()=>hR,isGasAsset:()=>$C,isDetected:()=>RR,initializeRPCUrlsWithFallback:()=>Ph,getWalletFormatFor:()=>jh,getTHORNameCost:()=>Jh,getSymmetricWithdraw:()=>vh,getSymmetricPoolShare:()=>gC,getMinAmountByChain:()=>Kh,getMemoForWithdraw:()=>ah,getMemoForUnbond:()=>rh,getMemoForRunePoolWithdraw:()=>sh,getMemoForRunePoolDeposit:()=>dh,getMemoForNameRegister:()=>ih,getMemoForNamePreferredAssetRegister:()=>lh,getMemoForLeaveAndBond:()=>uh,getMemoForDeposit:()=>th,getMAYANameCost:()=>Yh,getLiquiditySlippage:()=>mh,getGasAsset:()=>Lh,getFeeMultiplierAsBigInt:()=>pC,getFeeMultiplier:()=>zC,getEstimatedPoolShare:()=>ch,getETHDefaultWallet:()=>HR,getEIP6963Wallets:()=>xR,getDynamicChainId:()=>Uh,getDerivationPathFor:()=>Xh,getDecimal:()=>BC,getCommonAssetInfo:()=>c,getChainIdentifier:()=>Mh,getAsymmetricRuneWithdrawAmount:()=>oh,getAsymmetricRuneShare:()=>IC,getAsymmetricAssetWithdrawAmount:()=>nh,getAsymmetricAssetShare:()=>yC,getAssetType:()=>l,formatBigIntToSafeValue:()=>D,findAssetBy:()=>Qh,filterSupportedChains:()=>TR,derivationPathToString:()=>_C,createWallet:()=>BR,createPlugin:()=>CR,assetFromString:()=>e,applyFeeMultiplierToBigInt:()=>gh,applyFeeMultiplier:()=>fh,addEVMWalletNetwork:()=>cC,addAccountsChangedCallback:()=>_R,WarningCodeEnum:()=>jR,WalletOption:()=>n,UTXOChains:()=>RC,TCSupportedChains:()=>eC,SwapKitNumber:()=>k,SwapKitError:()=>A,SubstrateChains:()=>sC,StagenetChain:()=>d,SWAP_OUT:()=>Eh,SWAP_IN:()=>$h,SKConfig:()=>U,RequestClient:()=>S,RPC_URLS:()=>o,QuoteMode:()=>MC,ProviderName:()=>ZR,NetworkDerivationPath:()=>K,NODE_URLS:()=>g,MemoType:()=>xC,MAYASupportedChains:()=>Ch,LedgerErrorCode:()=>qC,FeeTypeEnum:()=>AR,FeeOption:()=>HC,FALLBACK_URLS:()=>YC,ErrorCode:()=>XR,EXPLORER_URLS:()=>a,EVMChains:()=>V,DerivationPath:()=>Zh,DEFAULT_FEE_MULTIPLIERS:()=>DC,CosmosChains:()=>iC,CosmosChainPrefixes:()=>lC,ContractAddress:()=>UC,CommonAssetStrings:()=>Gh,ChainToHexChainId:()=>PC,ChainToExplorerUrl:()=>_h,ChainToChainId:()=>TC,ChainIdToChain:()=>dC,ChainId:()=>f,Chain:()=>L,BlockTimes:()=>aC,BigIntArithmetics:()=>W,BaseDecimal:()=>G,AssetValue:()=>q,ApproveMode:()=>kC,AGG_SWAP:()=>Bh});module.exports=$R(GR);var ZC=require("ethers"),GC=require("ts-pattern");var JC=require("ts-pattern");var rC={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,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_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class A extends Error{static ErrorCode=rC;constructor(C,h){let R=typeof C==="string",T=R?C:C.errorKey,P=R?void 0:C.info,_=`${T}${P?`: ${JSON.stringify(P)}`:""}`;super(_);if(Object.setPrototypeOf(this,A.prototype),this.name="SwapKitError",this.cause=h,h)console.error(`SwapKitError [${T}]:`,h);else if(P)console.error(`SwapKitError [${T}]:`,P)}}var L;((Z)=>{Z.Arbitrum="ARB";Z.Avalanche="AVAX";Z.Base="BASE";Z.BinanceSmartChain="BSC";Z.Bitcoin="BTC";Z.BitcoinCash="BCH";Z.Cosmos="GAIA";Z.Dash="DASH";Z.Dogecoin="DOGE";Z.Ethereum="ETH";Z.Fiat="FIAT";Z.Kujira="KUJI";Z.Litecoin="LTC";Z.Maya="MAYA";Z.Near="NEAR";Z.Optimism="OP";Z.Polkadot="DOT";Z.Chainflip="FLIP";Z.Polygon="MATIC";Z.Radix="XRD";Z.Ripple="XRP";Z.THORChain="THOR";Z.Solana="SOL";Z.Tron="TRX";Z.Zcash="ZEC"})(L||={});var d;((R)=>{R.THORChain="THOR_STAGENET";R.Maya="MAYA_STAGENET"})(d||={});var f;(($)=>{$.Arbitrum="42161";$.ArbitrumHex="0xa4b1";$.Avalanche="43114";$.AvalancheHex="0xa86a";$.Base="8453";$.BaseHex="0x2105";$.BinanceSmartChain="56";$.BinanceSmartChainHex="0x38";$.Bitcoin="bitcoin";$.BitcoinCash="bitcoincash";$.Chainflip="chainflip";$.Cosmos="cosmoshub-4";$.Dash="dash";$.Dogecoin="dogecoin";$.Kujira="kaiyo-1";$.Ethereum="1";$.EthereumHex="0x1";$.Fiat="fiat";$.Litecoin="litecoin";$.Maya="mayachain-mainnet-v1";$.MayaStagenet="mayachain-stagenet-v1";$.Near="near";$.Optimism="10";$.OptimismHex="0xa";$.Polkadot="polkadot";$.Polygon="137";$.PolygonHex="0x89";$.Radix="radix-mainnet";$.Ripple="ripple";$.THORChain="thorchain-1";$.THORChainStagenet="thorchain-stagenet-v2";$.Solana="solana";$.Tron="728126428";$.TronHex="0x2b6653dc";$.Zcash="zcash"})(f||={});var dC={["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",["1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["728126428"]:"TRX",["0x2b6653dc"]:"TRX",["zcash"]:"ZEC"},tC=Object.keys(L),t=Object.values(L),G={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,TRX:6,XRD:18,XRP:6,ZEC:8},aC={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRX"]:3,["ZEC"]:150},sC=["DOT","FLIP"],V=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],RC=["BTC","BCH","DASH","DOGE","LTC","ZEC"],iC=["GAIA","THOR","MAYA","KUJI"],lC={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},eC=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Ch=["ARB","DASH","ETH","KUJI","MAYA","THOR"],o={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.mainnet.near.org",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.thorswap.net",["TRX"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://api.blockchair.com/zcash",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},g={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},YC={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",g.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRX"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:["https://api.blockchair.com/zcash"]},a={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io",["TRX"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},LC=o,hh=(C)=>{return JC.match(C).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC","TRX",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC","ZEC",()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with("GAIA","KUJI","MAYA","THOR","MAYA_STAGENET","THOR_STAGENET",()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with("DOT",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("XRD",()=>"").otherwise(()=>{throw new A("helpers_chain_not_supported",{chain:C})})};function Rh(C){return C==="XRD"?"/status/network-configuration":""}var QC=async(C,h)=>{try{let R=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${R}${Rh(C)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(hh(C)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},Th=async(C)=>{let h=o[C];if(await QC(C,h))return h;for(let R of YC[C])if(await QC(C,R))return R;return h},Ph=async(C=[...Object.values(L),...Object.values(d)])=>{let h={};await Promise.all(C.map(async(R)=>{let T=await Th(R);h[R]=T})),LC={...LC,...h}},FC=t.reduce((C,h)=>{let R=tC.find((T)=>L[T]===h);if(R)C[h]=R;return C},{}),TC=t.reduce((C,h)=>{return C[h]=f[FC[h]],C},{}),PC=t.reduce((C,h)=>{let R=`${FC[h]}Hex`;return C[h]=f[R],C},{}),_h=t.reduce((C,h)=>{return C[h]=a[h],C},{});var v=require("ts-pattern");var S={get:s("GET"),post:s("POST"),extend:(C)=>({get:s("GET",C),post:s("POST",C),extend:(h)=>S.extend({...C,...h})})};function s(C,h={}){return async(R,T={})=>{let{searchParams:P,json:_,body:x,headers:H}={...h,...T},B=!!_||R.endsWith(".json"),E=B?JSON.stringify(_):x;try{let z=xh(R,P),N=Hh(B,{...H,...T.getDynamicHeader?.()}),Q=await fetch(z,{...T,method:C,body:E,headers:N});if(!Q.ok){let J=await Q.text();throw new A("helpers_invalid_response",{status:Q.status,statusText:Q.statusText,message:J})}let F=await Q.json();return T.onSuccess?.(F)||T.responseHandler?.(F)||F}catch(z){if(T.onError)return T.onError(z);throw z}}}function Hh(C,h){return{...h,...C?{"Content-Type":"application/json"}:{}}}function xh(C,h){let R=new URL(C);if(h)R.search=new URLSearchParams(h).toString();return R.toString()}var WC=require("zustand/vanilla");var MC;((X)=>{X.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";X.TC_SUPPORTED_TO_ETH="TC-ERC20";X.TC_SUPPORTED_TO_AVAX="TC-ARC20";X.TC_SUPPORTED_TO_BSC="TC-BEP20";X.ETH_TO_TC_SUPPORTED="ERC20-TC";X.ETH_TO_ETH="ERC20-ERC20";X.ETH_TO_AVAX="ERC20-ARC20";X.ETH_TO_BSC="ERC20-BEP20";X.AVAX_TO_TC_SUPPORTED="ARC20-TC";X.AVAX_TO_ETH="ARC20-ERC20";X.AVAX_TO_AVAX="ARC20-ARC20";X.AVAX_TO_BSC="ARC20-BEP20";X.BSC_TO_TC_SUPPORTED="BEP20-TC";X.BSC_TO_ETH="BEP20-ERC20";X.BSC_TO_AVAX="BEP20-ARC20";X.BSC_TO_BSC="BEP20-BEP20"})(MC||={});var Bh=["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"],Eh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function i(C,h){if("index"in h)return[...C.slice(0,C.length-1),h.index];if("change"in h){let[R,T,P,,_]=C;return[R,T,P,h.change,_]}if("account"in h){let[R,T,,P,_]=C;return[R,T,h.account,P,_]}return C}function _C([C,h,R,T,P]){let _=typeof P!=="number";if(typeof T!=="number")return`m/${C}'/${h}'/${R}'`;return`m/${C}'/${h}'/${R}'/${T}${_?"":`/${P}`}`}function Xh({chain:C,index:h,addressIndex:R=0,type:T}){if(V.includes(C)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,R];return i(K[C],{index:h})}if(C==="SOL"){if(T==="account")return[44,501,0,h];return i(K[C],{index:h})}let P=C==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,P,h,0,R];case"segwit":return[49,P,0,0,h];case"legacy":return[44,P,0,0,h];default:return i(K[C],{index:h})}}function jh(C){let[h,R,T]=C.split("/").map((P)=>Number.parseInt(P,10));switch(R){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var UC;((H)=>{H.ARB="0x0000000000000000000000000000000000000000";H.AVAX="0x0000000000000000000000000000000000000000";H.BASE="0x0000000000000000000000000000000000000000";H.ETH="0x0000000000000000000000000000000000000000";H.BSC="0x0000000000000000000000000000000000000000";H.MATIC="0x0000000000000000000000000000000000001010";H.OP="0x4200000000000000000000000000000000000042"})(UC||={});var K={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],NEAR:[44,397,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRX:[44,195,0,0,0],ZEC:[44,133,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0]},Zh=Object.keys(K).reduce((C,h)=>{return C[h]=_C(K[h]),C},{});var HC;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(HC||={});var kC;((R)=>{R.Approve="approve";R.CheckOnly="checkOnly"})(kC||={});var xC;((B)=>{B.NAME_REGISTER="~";B.BOND="BOND";B.DEPOSIT="+";B.LEAVE="LEAVE";B.UNBOND="UNBOND";B.WITHDRAW="-";B.RUNEPOOL_DEPOSIT="POOL+";B.RUNEPOOL_WITHDRAW="POOL-"})(xC||={});var n;((j)=>{j.BITGET="BITGET";j.BRAVE="BRAVE";j.COINBASE_MOBILE="COINBASE_MOBILE";j.COINBASE_WEB="COINBASE_WEB";j.COSMOSTATION="COSMOSTATION";j.CTRL="CTRL";j.EIP6963="EIP6963";j.EXODUS="EXODUS";j.KEEPKEY="KEEPKEY";j.KEEPKEY_BEX="KEEPKEY_BEX";j.KEPLR="KEPLR";j.KEYSTORE="KEYSTORE";j.LEAP="LEAP";j.LEDGER="LEDGER";j.LEDGER_LIVE="LEDGER_LIVE";j.METAMASK="METAMASK";j.OKX="OKX";j.OKX_MOBILE="OKX_MOBILE";j.ONEKEY="ONEKEY";j.PHANTOM="PHANTOM";j.POLKADOT_JS="POLKADOT_JS";j.RADIX_WALLET="RADIX_WALLET";j.TREZOR="TREZOR";j.TALISMAN="TALISMAN";j.TRUSTWALLET_WEB="TRUSTWALLET_WEB";j.WALLETCONNECT="WALLETCONNECT"})(n||={});var qC;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(qC||={});var Ah={apis:{},chains:Object.values(L),wallets:Object.values(n),explorerUrls:a,nodeUrls:g,rpcUrls:o,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},feeMultipliers:void 0},M=WC.createStore((C)=>({...Ah,setApiKey:(h,R)=>C((T)=>({apiKeys:{...T.apiKeys,[h]:R}})),setEnv:(h,R)=>C((T)=>({envs:{...T.envs,[h]:R}})),setExplorerUrl:(h,R)=>C((T)=>({explorerUrls:{...T.explorerUrls,[h]:R}})),setNodeUrl:(h,R)=>C((T)=>({nodeUrls:{...T.nodeUrls,[h]:R}})),setRpcUrl:(h,R)=>C((T)=>({rpcUrls:{...T.rpcUrls,[h]:R}})),setIntegrationConfig:(h,R)=>C((T)=>({integrations:{...T.integrations,[h]:R}})),setFeeMultipliers:(h)=>C(()=>({feeMultipliers:h})),setConfig:(h)=>C((R)=>({apiKeys:{...R.apiKeys,...h.apiKeys},envs:{...R.envs,...h.envs},explorerUrls:{...R.explorerUrls,...h.explorerUrls},integrations:{...R.integrations,...h.integrations},nodeUrls:{...R.nodeUrls,...h.nodeUrls},rpcUrls:{...R.rpcUrls,...h.rpcUrls},feeMultipliers:h.feeMultipliers||R.feeMultipliers,chains:R.chains.concat(h.chains||[]),wallets:R.wallets.concat(h.wallets||[])}))})),U={getState:M.getState,get:(C)=>M.getState()[C],set:(C)=>M.getState().setConfig(C),setApiKey:(C,h)=>M.getState().setApiKey(C,h),setEnv:(C,h)=>M.getState().setEnv(C,h),setExplorerUrl:(C,h)=>M.getState().setExplorerUrl(C,h),setNodeUrl:(C,h)=>M.getState().setNodeUrl(C,h),setRpcUrl:(C,h)=>M.getState().setRpcUrl(C,h),setIntegrationConfig:(C,h)=>M.getState().setIntegrationConfig(C,h),setFeeMultipliers:(C)=>M.getState().setFeeMultipliers(C)};var Gh=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],wC=["ARB","BASE","ETH","OP","MATIC"];async function zh({chain:C,to:h}){try{let{result:T}=await S.post(U.get("rpcUrls")[C],{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:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(T||G[C]).toString())}catch(T){return console.error(`Failed to fetch contract decimals for ${h} on ${C}:`,T),G[C]}}async function Nh(C){if(C==="XRD")return G.XRD;try{let h=C.split("-")[1]?.toLowerCase(),{manager:R}=await S.post(`${U.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return R.divisibility.value.divisibility}catch(h){return console.error(`Failed to fetch Radix asset decimal for ${C}:`,h),G["XRD"]}}async function Oh({chain:C,symbol:h}){if(V.includes(h))return G[h];let R=h.split("-"),T=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(T?.startsWith("0x")?zh({chain:C,to:T}):G[C])}function BC({chain:C,symbol:h}){return v.match(C).with(...V,(R)=>Oh({chain:R,symbol:h})).with("XRD",()=>Nh(h)).otherwise(()=>G[C])}function Lh({chain:C}){return q.from({chain:C})}function $C({chain:C,symbol:h}){return v.match(C).with(...wC,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${C}.${h}`===c(C).identifier).otherwise(()=>h===C)}var c=(C)=>{let h=G[C];return v.match(C.toUpperCase()).with(...wC,(T)=>({identifier:`${T}.ETH`,decimal:h})).with("THOR",(T)=>({identifier:`${T}.RUNE`,decimal:h})).with("GAIA",(T)=>({identifier:`${T}.ATOM`,decimal:h})).with("MAYA",(T)=>({identifier:`${T}.CACAO`,decimal:10})).with("BSC",(T)=>({identifier:`${T}.BNB`,decimal:h})).with("AVAX",(T)=>({identifier:`${T}.AVAX`,decimal:h})).with(...RC,"SOL","FLIP","KUJI","XRP","DOT","TRX","NEAR",(T)=>({identifier:`${T}.${T}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",(T)=>({identifier:T,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:G.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:G.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:G.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:C,decimal:h}))};function l({chain:C,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return v.match(C).with("XRD",()=>h==="XRD"||`${C}.${h}`===c(C).identifier).with("ARB","OP","BASE",()=>h==="ETH").with("GAIA",()=>h==="ATOM").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("THOR",()=>h==="RUNE").otherwise(()=>h===C)?"Native":C}var e=(C)=>{let[h,...R]=C.split("."),T=C.includes("/"),P=R.join("."),_=P?.split("-"),x=_?.length?_.length===1?_[0]:_.slice(0,-1).join("-"):void 0;return{chain:h,symbol:P,ticker:x,synth:T}};async function Qh(C){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let R of Object.values(h))for(let{identifier:T,chain:P,..._}of R.tokens){if("identifier"in C&&T===C.identifier)return T;if("address"in _&&"chain"in C&&P===C.chain&&_.address.toLowerCase()===C.contract.toLowerCase())return T}return}function Jh(C){if(C<0)throw new A({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return 10+C}function Yh(C){if(C<0)throw new A({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return Math.round((10+C*1.0512)*10000000000)/10000000000}function Fh(C,h){try{return C()}catch(R){if(h)throw new A(h,R);return}}function Mh(C){switch(C){case"THOR":return`${C}.RUNE`;case"GAIA":return`${C}.ATOM`;case"BSC":return`${C}`;default:return`${C}.${C}`}}var VC=new Set;function m(C,h){if(C){if(VC.has(h))return;VC.add(h)}}async function Uh(C="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(C))return C;try{let h=U.get("rpcUrls")[C!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await S.get(`${h}/status`)).result.node_info.network}catch(h){return C}}var SC=require("ts-pattern"),kh=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function EC(C){let h=C||kh,R={};for(let T of h){let P=await qh(T);R[T]=P}return R}async function qh(C){let{list:h}=await SC.match(C).with("camelot",()=>import("./chunk-bz1hfk9z.js")).with("caviar",()=>import("./chunk-8pft100q.js")).with("chainflip",()=>import("./chunk-qr6hqr2f.js")).with("jupiter",()=>import("./chunk-509k5s4y.js")).with("mayachain",()=>import("./chunk-s3f27t8q.js")).with("oneinch",()=>import("./chunk-mjavf655.js")).with("openocean",()=>import("./chunk-a6bjd9ar.js")).with("pancakeswap",()=>import("./chunk-j2emm8jm.js")).with("pangolin",()=>import("./chunk-z80467hm.js")).with("sushiswap",()=>import("./chunk-abwjsvdg.js")).with("thorchain",()=>import("./chunk-zsakm9d3.js")).with("traderjoe",()=>import("./chunk-cs1sv94g.js")).with("uniswap",()=>import("./chunk-rqj9janq.js")).with("uniswapv3",()=>import("./chunk-hqs6577q.js")).exhaustive();return h}var KC=["TERRA",...U.get("chains")];function XC(C=""){let h=C.toUpperCase(),[R]=h.split(".");if(KC.includes(R))return!0;let[T]=h.split("/");if(KC.includes(T))return!0;throw new A({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${C}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:C}})}function Wh(C){if(C.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!C.match(h)}var r=8,b=(C)=>10n**BigInt(C),u=(C)=>Math.log10(Number.parseFloat(C.toString()));function D({value:C,bigIntDecimal:h=r,decimal:R=r}){if(R===0)return C.toString();let T=C<0n,P=C.toString().substring(T?1:0),_=R-(P.length-1);if(_>0)P="0".repeat(_)+P;let x=P.length-R,H=P.slice(-R);if(Number.parseInt(H[h]||"0")>=5)H=`${H.substring(0,h-1)}${(Number.parseInt(H[h-1]||"0")+1).toString()}`;else H=H.substring(0,h);return`${T?"-":""}${P.slice(0,x)}.${H}`.replace(/\.?0*$/,"")}function wh(C,h){if(h===0n)throw new Error("Cannot divide by zero");let R=h/2n;if(C>=0n&&h>=0n||C<0n&&h<0n)return(C+R)/h;return(C-R)/h}class W{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(C,h){return new W({decimal:h,value:D({value:C,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:C,from:h,to:R}){return W.fromBigInt(C.getBaseValue("bigint")*b(R)/b(h),R)}constructor(C){let h=jC(C),R=typeof C==="object";this.decimal=R?C.decimal:void 0,this.decimalMultiplier=R&&"decimalMultiplier"in C?C.decimalMultiplier:b(Math.max(bC(CC(h)),this.decimal||0)),this.#P(h)}set(C){return new this.constructor({decimal:this.decimal,value:C,identifier:this.toString({includeSynthProtocol:!0})})}add(...C){return this.#h("add",...C)}sub(...C){return this.#h("sub",...C)}mul(...C){return this.#h("mul",...C)}div(...C){return this.#h("div",...C)}gt(C){return this.#C("gt",C)}gte(C){return this.#C("gte",C)}lt(C){return this.#C("lt",C)}lte(C){return this.#C("lte",C)}eqValue(C){return this.#C("eqValue",C)}getValue(C,h){let R=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||u(this.decimalMultiplier));switch(C){case"number":return Number(R);case"string":return R;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return R}}getBaseValue(C,h){let R=this.decimalMultiplier/b(h||this.decimal||G.THOR),T=wh(this.bigIntValue,R);switch(C){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(C,h){if(!h&&typeof C==="object")return C.bigIntValue;let R=jC(C),T=CC(R);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if((Number.parseInt(T)?T.length+P.length:P.length)<=C)return this.getValue("string");if(T.length>=C)return T.slice(0,C).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${P.slice(0,C-T.length)}`.padEnd(C-T.length,"0");let x=Number.parseInt(P),H=`${x}`.slice(0,C);return`0.${H.padStart(P.length-`${x}`.length+H.length,"0")}`}toFixed(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if(Number.parseInt(T))return`${T}.${P.slice(0,C)}`.padEnd(C,"0");let _=Number.parseInt(P),x=`${_}`.slice(0,C);return`0.${x.padStart(P.length-`${_}`.length+x.length,"0")}`}toAbbreviation(C=2){let h=this.getValue("number"),R=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),P=R[T];if(!P)return this.getValue("string");let _=10**(T*3);return`${(h/_).toFixed(C)}${P}`}toCurrency(C="$",{currencyPosition:h="start",decimal:R=2,decimalSeparator:T=".",thousandSeparator:P=","}={}){let _=this.getValue("number"),[x="",H=""]=_.toFixed(6).split("."),B=x.replace(/\B(?=(\d{3})+(?!\d))/g,P),E=x||H?x==="0"?`${Number.parseFloat(`0.${H}`)}`.replace(".",T):`${B}${Number.parseInt(H)?`${T}${H.slice(0,R)}`:""}`:"0.00";return`${h==="start"?C:""}${E}${h==="end"?C:""}`}formatBigIntToSafeValue(C,h){let R=h||this.decimal||r,T=Math.max(R,u(this.decimalMultiplier)),P=C<0n,_=C.toString().substring(P?1:0),x=T-(_.length-1),H=x>0?"0".repeat(x)+_:_,B=H.length-T,E=H.slice(-T);if(Number.parseInt(E[R]||"0")>=5)E=`${E.substring(0,R-1)}${(Number.parseInt(E[R-1]||"0")+1).toString()}`;else E=E.substring(0,R);return`${P?"-":""}${H.slice(0,B)}.${E}`.replace(/\.?0*$/,"")}#h(C,...h){let R=this.#R(this,...h),T=Math.max(R,u(this.decimalMultiplier)),P=b(T),_=h.reduce((H,B)=>{let E=this.getBigIntValue(B,T);switch(C){case"add":return H+E;case"sub":return H-E;case"mul":return H*E/P;case"div":{if(E===0n)throw new RangeError("Division by zero");return H*P/E}default:return H}},this.bigIntValue*P/this.decimalMultiplier),x=D({bigIntDecimal:T,decimal:T,value:_});return new this.constructor({decimalMultiplier:b(T),decimal:this.decimal,value:x,identifier:this.toString()})}#C(C,...h){let R=this.#R(this,...h),T=this.getBigIntValue(h[0]||"0",R),P=this.getBigIntValue(this,R);switch(C){case"gt":return P>T;case"gte":return P>=T;case"lt":return P<T;case"lte":return P<=T;case"eqValue":return P===T;default:return!1}}#P(C){let h=CC(C)||"0";this.bigIntValue=this.#T(h)}#R(...C){let h=C.map((R)=>{return typeof R==="object"?R.decimal||u(R.decimalMultiplier):bC(CC(R))}).filter(Boolean);return Math.max(...h,r)}#T(C,h){let R=h?b(h):this.decimalMultiplier,T=u(R),[P="",_=""]=C.split(".");return BigInt(`${P}${_.padEnd(T,"0")}`)}}var Vh=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function CC(C){let R=`${typeof C==="number"?Vh.format(C):jC(C)}`.replaceAll(",",".").split(".");return R.length>1?`${R.slice(0,-1).join("")}.${R.at(-1)}`:R[0]||"0"}function bC(C){let h=C.split(".")[1]?.length||0;return Math.max(h,r)}function jC(C){return typeof C==="object"?"getValue"in C?C.getValue("string"):C.value:C}var Sh=["SOL","TRX"],I=new Map;class q extends W{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:C,decimal:h,tax:R,chain:T,symbol:P,identifier:_}){super(typeof C==="object"?C:{decimal:h,value:C});let x=AC(_||`${T}.${P}`);this.type=l(x),this.tax=R,this.chain=x.chain,this.ticker=x.ticker,this.symbol=x.symbol,this.address=x.address,this.isSynthetic=x.isSynthetic,this.isTradeAsset=x.isTradeAsset,this.isGasAsset=x.isGasAsset,this.chainId=TC[x.chain]}toString({includeSynthProtocol:C}={}){return(this.isSynthetic||this.isTradeAsset)&&!C?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:C,symbol:h}){return this.chain===C&&this.symbol===h}eq(C){return this.eqAsset(C)&&this.eqValue(C)}static fromUrl(C,h=0){let[R,T,P]=C.split(".");if(!(R&&T))throw new A({errorKey:"helpers_invalid_asset_url",info:{urlAsset:C}});let _=R==="THOR"&&P?`${R}.${T}/${P}`:C;return q.from({asset:_,value:h})}static from({value:C=0,fromBaseDecimal:h,asyncTokenLookup:R,...T}){let P=C instanceof W?C.getValue("string"):C,_=Ih(T),{identifier:x,decimal:H}=c(_),{chain:B,isSynthetic:E,isTradeAsset:z}=AC(x),N=I.get(B==="SOL"?x:x.toUpperCase()),Q=N?.decimal||H;m(!(R||Q),`Couldn't find static decimal for one or more tokens on ${B} (Using default ${G[B]} decimal as fallback).
1
+ var GR={};ER(GR,{wrapWithThrow:()=>Fh,wrapMethodWithNetworkSwitch:()=>vC,warnOnce:()=>m,validateTNS:()=>qh,validateIdentifier:()=>jC,updateDerivationPath:()=>s,switchEVMWalletNetwork:()=>fC,providerRequest:()=>LC,prepareNetworkSwitch:()=>PR,okxMobileEnabled:()=>mC,loadTokenLists:()=>XC,listWeb3EVMWallets:()=>nC,isWeb3Detected:()=>hR,isGasAsset:()=>EC,isDetected:()=>RR,initializeRPCUrlsWithFallback:()=>Ph,getWalletFormatFor:()=>jh,getTHORNameCost:()=>Jh,getSymmetricWithdraw:()=>vh,getSymmetricPoolShare:()=>gC,getMinAmountByChain:()=>Kh,getMemoForWithdraw:()=>ah,getMemoForUnbond:()=>rh,getMemoForRunePoolWithdraw:()=>ih,getMemoForRunePoolDeposit:()=>dh,getMemoForNameRegister:()=>sh,getMemoForNamePreferredAssetRegister:()=>lh,getMemoForLeaveAndBond:()=>uh,getMemoForDeposit:()=>th,getMAYANameCost:()=>Yh,getLiquiditySlippage:()=>mh,getGasAsset:()=>Lh,getFeeMultiplierAsBigInt:()=>pC,getFeeMultiplier:()=>NC,getEstimatedPoolShare:()=>ch,getETHDefaultWallet:()=>HR,getEIP6963Wallets:()=>xR,getDynamicChainId:()=>Mh,getDerivationPathFor:()=>Xh,getDecimal:()=>$C,getCommonAssetInfo:()=>c,getChainIdentifier:()=>kh,getAsymmetricRuneWithdrawAmount:()=>nh,getAsymmetricRuneShare:()=>IC,getAsymmetricAssetWithdrawAmount:()=>fh,getAsymmetricAssetShare:()=>yC,getAssetType:()=>l,formatBigIntToSafeValue:()=>D,findAssetBy:()=>Qh,filterSupportedChains:()=>TR,derivationPathToString:()=>HC,createWallet:()=>BR,createPlugin:()=>CR,assetFromString:()=>e,applyFeeMultiplierToBigInt:()=>gh,applyFeeMultiplier:()=>oh,addEVMWalletNetwork:()=>cC,addAccountsChangedCallback:()=>_R,WarningCodeEnum:()=>jR,WalletOption:()=>f,UTXOChains:()=>TC,TCSupportedChains:()=>eC,SwapKitNumber:()=>U,SwapKitError:()=>A,SubstrateChains:()=>iC,StagenetChain:()=>d,SWAP_OUT:()=>Eh,SWAP_IN:()=>$h,SKConfig:()=>M,RequestClient:()=>S,RPC_URLS:()=>n,QuoteMode:()=>kC,ProviderName:()=>ZR,NetworkDerivationPath:()=>K,NODE_URLS:()=>g,MemoType:()=>BC,MAYASupportedChains:()=>Ch,LedgerErrorCode:()=>wC,FeeTypeEnum:()=>AR,FeeOption:()=>xC,FALLBACK_URLS:()=>YC,ErrorCode:()=>XR,EXPLORER_URLS:()=>a,EVMChains:()=>V,DerivationPath:()=>Zh,DEFAULT_FEE_MULTIPLIERS:()=>DC,CosmosChains:()=>sC,CosmosChainPrefixes:()=>lC,ContractAddress:()=>MC,CommonAssetStrings:()=>Gh,ChainToHexChainId:()=>_C,ChainToExplorerUrl:()=>_h,ChainToChainId:()=>PC,ChainIdToChain:()=>dC,ChainId:()=>o,Chain:()=>L,BlockTimes:()=>aC,BigIntArithmetics:()=>q,BaseDecimal:()=>G,AssetValue:()=>w,ApproveMode:()=>UC,AGG_SWAP:()=>Bh});module.exports=$R(GR);var AC=require("ethers"),zC=require("ts-pattern");var RC=require("ts-pattern");var rC={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,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_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class A extends Error{static ErrorCode=rC;constructor(C,h){let R=typeof C==="string",T=R?C:C.errorKey,P=R?void 0:C.info,_=`${T}${P?`: ${JSON.stringify(P)}`:""}`;super(_);if(Object.setPrototypeOf(this,A.prototype),this.name="SwapKitError",this.cause=h,h)console.error(`SwapKitError [${T}]:`,h);else if(P)console.error(`SwapKitError [${T}]:`,P)}}var L;((Z)=>{Z.Arbitrum="ARB";Z.Avalanche="AVAX";Z.Base="BASE";Z.BinanceSmartChain="BSC";Z.Bitcoin="BTC";Z.BitcoinCash="BCH";Z.Cosmos="GAIA";Z.Dash="DASH";Z.Dogecoin="DOGE";Z.Ethereum="ETH";Z.Fiat="FIAT";Z.Kujira="KUJI";Z.Litecoin="LTC";Z.Maya="MAYA";Z.Near="NEAR";Z.Optimism="OP";Z.Polkadot="DOT";Z.Chainflip="FLIP";Z.Polygon="MATIC";Z.Radix="XRD";Z.Ripple="XRP";Z.THORChain="THOR";Z.Solana="SOL";Z.Tron="TRX";Z.Zcash="ZEC"})(L||={});var d;((R)=>{R.THORChain="THOR_STAGENET";R.Maya="MAYA_STAGENET"})(d||={});var o;(($)=>{$.Arbitrum="42161";$.ArbitrumHex="0xa4b1";$.Avalanche="43114";$.AvalancheHex="0xa86a";$.Base="8453";$.BaseHex="0x2105";$.BinanceSmartChain="56";$.BinanceSmartChainHex="0x38";$.Bitcoin="bitcoin";$.BitcoinCash="bitcoincash";$.Chainflip="chainflip";$.Cosmos="cosmoshub-4";$.Dash="dash";$.Dogecoin="dogecoin";$.Kujira="kaiyo-1";$.Ethereum="1";$.EthereumHex="0x1";$.Fiat="fiat";$.Litecoin="litecoin";$.Maya="mayachain-mainnet-v1";$.MayaStagenet="mayachain-stagenet-v1";$.Near="near";$.Optimism="10";$.OptimismHex="0xa";$.Polkadot="polkadot";$.Polygon="137";$.PolygonHex="0x89";$.Radix="radix-mainnet";$.Ripple="ripple";$.THORChain="thorchain-1";$.THORChainStagenet="thorchain-stagenet-v2";$.Solana="solana";$.Tron="728126428";$.TronHex="0x2b6653dc";$.Zcash="zcash"})(o||={});var dC={["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",["1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["728126428"]:"TRX",["0x2b6653dc"]:"TRX",["zcash"]:"ZEC"},tC=Object.keys(L),t=Object.values(L),G={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,TRX:6,XRD:18,XRP:6,ZEC:8},aC={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRX"]:3,["ZEC"]:150},iC=["DOT","FLIP"],V=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],TC=["BTC","BCH","DASH","DOGE","LTC","ZEC"],sC=["GAIA","THOR","MAYA","KUJI"],lC={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},eC=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Ch=["ARB","DASH","ETH","KUJI","MAYA","THOR"],n={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.mainnet.near.org",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.thorswap.net",["TRX"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://api.blockchair.com/zcash",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},g={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},YC={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",g.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRX"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:["https://api.blockchair.com/zcash"]},a={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io",["TRX"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},QC=n,hh=(C)=>{return RC.match(C).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC","ZEC",()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with("GAIA","KUJI","MAYA","THOR","MAYA_STAGENET","THOR_STAGENET",()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with("DOT","FLIP",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("TRX","XRD","FIAT",()=>"").with("NEAR",()=>({jsonrpc:"2.0",id:"dontcare",method:"status",params:[]})).otherwise(()=>{throw new A("helpers_chain_not_supported",{chain:C})})};function Rh(C){return RC.match(C).with("XRD",()=>"/status/network-configuration").with("TRX",()=>"/wallet/getnowblock").otherwise(()=>"")}var JC=async(C,h)=>{try{let R=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${R}${Rh(C)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(hh(C)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},Th=async(C)=>{let h=n[C];if(await JC(C,h))return h;for(let R of YC[C])if(await JC(C,R))return R;return h},Ph=async(C=[...Object.values(L),...Object.values(d)])=>{let h={};await Promise.all(C.map(async(R)=>{let T=await Th(R);h[R]=T})),QC={...QC,...h}},FC=t.reduce((C,h)=>{let R=tC.find((T)=>L[T]===h);if(R)C[h]=R;return C},{}),PC=t.reduce((C,h)=>{return C[h]=o[FC[h]],C},{}),_C=t.reduce((C,h)=>{let R=`${FC[h]}Hex`;return C[h]=o[R],C},{}),_h=t.reduce((C,h)=>{return C[h]=a[h],C},{});var v=require("ts-pattern");var S={get:i("GET"),post:i("POST"),extend:(C)=>({get:i("GET",C),post:i("POST",C),extend:(h)=>S.extend({...C,...h})})};function i(C,h={}){return async(R,T={})=>{let{searchParams:P,json:_,body:x,headers:H}={...h,...T},B=!!_||R.endsWith(".json"),E=B?JSON.stringify(_):x;try{let z=xh(R,P),N=Hh(B,{...H,...T.getDynamicHeader?.()}),Q=await fetch(z,{...T,method:C,body:E,headers:N});if(!Q.ok){let J=await Q.text();throw new A("helpers_invalid_response",{status:Q.status,statusText:Q.statusText,message:J})}let F=await Q.json();return T.onSuccess?.(F)||T.responseHandler?.(F)||F}catch(z){if(T.onError)return T.onError(z);throw z}}}function Hh(C,h){return{...h,...C?{"Content-Type":"application/json"}:{}}}function xh(C,h){let R=new URL(C);if(h)R.search=new URLSearchParams(h).toString();return R.toString()}var qC=require("zustand/vanilla");var kC;((X)=>{X.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";X.TC_SUPPORTED_TO_ETH="TC-ERC20";X.TC_SUPPORTED_TO_AVAX="TC-ARC20";X.TC_SUPPORTED_TO_BSC="TC-BEP20";X.ETH_TO_TC_SUPPORTED="ERC20-TC";X.ETH_TO_ETH="ERC20-ERC20";X.ETH_TO_AVAX="ERC20-ARC20";X.ETH_TO_BSC="ERC20-BEP20";X.AVAX_TO_TC_SUPPORTED="ARC20-TC";X.AVAX_TO_ETH="ARC20-ERC20";X.AVAX_TO_AVAX="ARC20-ARC20";X.AVAX_TO_BSC="ARC20-BEP20";X.BSC_TO_TC_SUPPORTED="BEP20-TC";X.BSC_TO_ETH="BEP20-ERC20";X.BSC_TO_AVAX="BEP20-ARC20";X.BSC_TO_BSC="BEP20-BEP20"})(kC||={});var Bh=["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"],Eh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function s(C,h){if("index"in h)return[...C.slice(0,C.length-1),h.index];if("change"in h){let[R,T,P,,_]=C;return[R,T,P,h.change,_]}if("account"in h){let[R,T,,P,_]=C;return[R,T,h.account,P,_]}return C}function HC([C,h,R,T,P]){let _=typeof P!=="number";if(typeof T!=="number")return`m/${C}'/${h}'/${R}'`;return`m/${C}'/${h}'/${R}'/${T}${_?"":`/${P}`}`}function Xh({chain:C,index:h,addressIndex:R=0,type:T}){if(V.includes(C)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,R];return s(K[C],{index:h})}if(C==="SOL"){if(T==="account")return[44,501,0,h];return s(K[C],{index:h})}let P=C==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,P,h,0,R];case"segwit":return[49,P,0,0,h];case"legacy":return[44,P,0,0,h];default:return s(K[C],{index:h})}}function jh(C){let[h,R,T]=C.split("/").map((P)=>Number.parseInt(P,10));switch(R){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var MC;((H)=>{H.ARB="0x0000000000000000000000000000000000000000";H.AVAX="0x0000000000000000000000000000000000000000";H.BASE="0x0000000000000000000000000000000000000000";H.ETH="0x0000000000000000000000000000000000000000";H.BSC="0x0000000000000000000000000000000000000000";H.MATIC="0x0000000000000000000000000000000000001010";H.OP="0x4200000000000000000000000000000000000042"})(MC||={});var K={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],NEAR:[44,397,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRX:[44,195,0,0,0],ZEC:[44,133,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0]},Zh=Object.keys(K).reduce((C,h)=>{return C[h]=HC(K[h]),C},{});var xC;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(xC||={});var UC;((R)=>{R.Approve="approve";R.CheckOnly="checkOnly"})(UC||={});var BC;((B)=>{B.NAME_REGISTER="~";B.BOND="BOND";B.DEPOSIT="+";B.LEAVE="LEAVE";B.UNBOND="UNBOND";B.WITHDRAW="-";B.RUNEPOOL_DEPOSIT="POOL+";B.RUNEPOOL_WITHDRAW="POOL-"})(BC||={});var f;((j)=>{j.BITGET="BITGET";j.BRAVE="BRAVE";j.COINBASE_MOBILE="COINBASE_MOBILE";j.COINBASE_WEB="COINBASE_WEB";j.COSMOSTATION="COSMOSTATION";j.CTRL="CTRL";j.EIP6963="EIP6963";j.EXODUS="EXODUS";j.KEEPKEY="KEEPKEY";j.KEEPKEY_BEX="KEEPKEY_BEX";j.KEPLR="KEPLR";j.KEYSTORE="KEYSTORE";j.LEAP="LEAP";j.LEDGER="LEDGER";j.LEDGER_LIVE="LEDGER_LIVE";j.METAMASK="METAMASK";j.OKX="OKX";j.OKX_MOBILE="OKX_MOBILE";j.ONEKEY="ONEKEY";j.PHANTOM="PHANTOM";j.POLKADOT_JS="POLKADOT_JS";j.RADIX_WALLET="RADIX_WALLET";j.TREZOR="TREZOR";j.TALISMAN="TALISMAN";j.TRUSTWALLET_WEB="TRUSTWALLET_WEB";j.WALLETCONNECT="WALLETCONNECT"})(f||={});var wC;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(wC||={});var Ah={apis:{},chains:Object.values(L),wallets:Object.values(f),explorerUrls:a,nodeUrls:g,rpcUrls:n,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},feeMultipliers:void 0},k=qC.createStore((C)=>({...Ah,setApiKey:(h,R)=>C((T)=>({apiKeys:{...T.apiKeys,[h]:R}})),setEnv:(h,R)=>C((T)=>({envs:{...T.envs,[h]:R}})),setExplorerUrl:(h,R)=>C((T)=>({explorerUrls:{...T.explorerUrls,[h]:R}})),setNodeUrl:(h,R)=>C((T)=>({nodeUrls:{...T.nodeUrls,[h]:R}})),setRpcUrl:(h,R)=>C((T)=>({rpcUrls:{...T.rpcUrls,[h]:R}})),setIntegrationConfig:(h,R)=>C((T)=>({integrations:{...T.integrations,[h]:R}})),setFeeMultipliers:(h)=>C(()=>({feeMultipliers:h})),setConfig:(h)=>C((R)=>({apiKeys:{...R.apiKeys,...h.apiKeys},envs:{...R.envs,...h.envs},explorerUrls:{...R.explorerUrls,...h.explorerUrls},integrations:{...R.integrations,...h.integrations},nodeUrls:{...R.nodeUrls,...h.nodeUrls},rpcUrls:{...R.rpcUrls,...h.rpcUrls},feeMultipliers:h.feeMultipliers||R.feeMultipliers,chains:R.chains.concat(h.chains||[]),wallets:R.wallets.concat(h.wallets||[])}))})),M={getState:k.getState,get:(C)=>k.getState()[C],set:(C)=>k.getState().setConfig(C),setApiKey:(C,h)=>k.getState().setApiKey(C,h),setEnv:(C,h)=>k.getState().setEnv(C,h),setExplorerUrl:(C,h)=>k.getState().setExplorerUrl(C,h),setNodeUrl:(C,h)=>k.getState().setNodeUrl(C,h),setRpcUrl:(C,h)=>k.getState().setRpcUrl(C,h),setIntegrationConfig:(C,h)=>k.getState().setIntegrationConfig(C,h),setFeeMultipliers:(C)=>k.getState().setFeeMultipliers(C)};var Gh=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],WC=["ARB","BASE","ETH","OP","MATIC"];async function zh({chain:C,to:h}){try{let{result:T}=await S.post(M.get("rpcUrls")[C],{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:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(T||G[C]).toString())}catch(T){return console.error(`Failed to fetch contract decimals for ${h} on ${C}:`,T),G[C]}}async function Nh(C){if(C==="XRD")return G.XRD;try{let h=C.split("-")[1]?.toLowerCase(),{manager:R}=await S.post(`${M.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return R.divisibility.value.divisibility}catch(h){return console.error(`Failed to fetch Radix asset decimal for ${C}:`,h),G["XRD"]}}async function Oh({chain:C,symbol:h}){if(V.includes(h))return G[h];let R=h.split("-"),T=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(T?.startsWith("0x")?zh({chain:C,to:T}):G[C])}function $C({chain:C,symbol:h}){return v.match(C).with(...V,(R)=>Oh({chain:R,symbol:h})).with("XRD",()=>Nh(h)).otherwise(()=>G[C])}function Lh({chain:C}){return w.from({chain:C})}function EC({chain:C,symbol:h}){return v.match(C).with(...WC,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${C}.${h}`===c(C).identifier).otherwise(()=>h===C)}var c=(C)=>{let h=G[C];return v.match(C.toUpperCase()).with(...WC,(T)=>({identifier:`${T}.ETH`,decimal:h})).with("THOR",(T)=>({identifier:`${T}.RUNE`,decimal:h})).with("GAIA",(T)=>({identifier:`${T}.ATOM`,decimal:h})).with("MAYA",(T)=>({identifier:`${T}.CACAO`,decimal:10})).with("BSC",(T)=>({identifier:`${T}.BNB`,decimal:h})).with("AVAX",(T)=>({identifier:`${T}.AVAX`,decimal:h})).with(...TC,"SOL","FLIP","KUJI","XRP","DOT","TRX","NEAR",(T)=>({identifier:`${T}.${T}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",(T)=>({identifier:T,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:G.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:G.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:G.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:C,decimal:h}))};function l({chain:C,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return v.match(C).with("XRD",()=>h==="XRD"||`${C}.${h}`===c(C).identifier).with("ARB","OP","BASE",()=>h==="ETH").with("GAIA",()=>h==="ATOM").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("THOR",()=>h==="RUNE").otherwise(()=>h===C)?"Native":C}var e=(C)=>{let[h,...R]=C.split("."),T=C.includes("/"),P=R.join("."),_=P?.split("-"),x=_?.length?_.length===1?_[0]:_.slice(0,-1).join("-"):void 0;return{chain:h,symbol:P,ticker:x,synth:T}};async function Qh(C){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let R of Object.values(h))for(let{identifier:T,chain:P,..._}of R.tokens){if("identifier"in C&&T===C.identifier)return T;if("address"in _&&"chain"in C&&P===C.chain&&_.address.toLowerCase()===C.contract.toLowerCase())return T}return}function Jh(C){if(C<0)throw new A({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return 10+C}function Yh(C){if(C<0)throw new A({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return Math.round((10+C*1.0512)*10000000000)/10000000000}function Fh(C,h){try{return C()}catch(R){if(h)throw new A(h,R);return}}function kh(C){switch(C){case"THOR":return`${C}.RUNE`;case"GAIA":return`${C}.ATOM`;case"BSC":return`${C}`;default:return`${C}.${C}`}}var VC=new Set;function m(C,h){if(C){if(VC.has(h))return;VC.add(h)}}async function Mh(C="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(C))return C;try{let h=M.get("rpcUrls")[C!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await S.get(`${h}/status`)).result.node_info.network}catch(h){return C}}var SC=require("ts-pattern"),Uh=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function XC(C){let h=C||Uh,R={};for(let T of h){let P=await wh(T);R[T]=P}return R}async function wh(C){let{list:h}=await SC.match(C).with("camelot",()=>import("./chunk-bz1hfk9z.js")).with("caviar",()=>import("./chunk-8pft100q.js")).with("chainflip",()=>import("./chunk-qr6hqr2f.js")).with("jupiter",()=>import("./chunk-509k5s4y.js")).with("mayachain",()=>import("./chunk-s3f27t8q.js")).with("oneinch",()=>import("./chunk-mjavf655.js")).with("openocean",()=>import("./chunk-a6bjd9ar.js")).with("pancakeswap",()=>import("./chunk-j2emm8jm.js")).with("pangolin",()=>import("./chunk-z80467hm.js")).with("sushiswap",()=>import("./chunk-abwjsvdg.js")).with("thorchain",()=>import("./chunk-zsakm9d3.js")).with("traderjoe",()=>import("./chunk-cs1sv94g.js")).with("uniswap",()=>import("./chunk-rqj9janq.js")).with("uniswapv3",()=>import("./chunk-hqs6577q.js")).exhaustive();return h}var KC=["TERRA",...M.get("chains")];function jC(C=""){let h=C.toUpperCase(),[R]=h.split(".");if(KC.includes(R))return!0;let[T]=h.split("/");if(KC.includes(T))return!0;throw new A({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${C}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:C}})}function qh(C){if(C.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!C.match(h)}var r=8,b=(C)=>10n**BigInt(C),u=(C)=>Math.log10(Number.parseFloat(C.toString()));function D({value:C,bigIntDecimal:h=r,decimal:R=r}){if(R===0)return C.toString();let T=C<0n,P=C.toString().substring(T?1:0),_=R-(P.length-1);if(_>0)P="0".repeat(_)+P;let x=P.length-R,H=P.slice(-R);if(Number.parseInt(H[h]||"0")>=5)H=`${H.substring(0,h-1)}${(Number.parseInt(H[h-1]||"0")+1).toString()}`;else H=H.substring(0,h);return`${T?"-":""}${P.slice(0,x)}.${H}`.replace(/\.?0*$/,"")}function Wh(C,h){if(h===0n)throw new Error("Cannot divide by zero");let R=h/2n;if(C>=0n&&h>=0n||C<0n&&h<0n)return(C+R)/h;return(C-R)/h}class q{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(C,h){return new q({decimal:h,value:D({value:C,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:C,from:h,to:R}){return q.fromBigInt(C.getBaseValue("bigint")*b(R)/b(h),R)}constructor(C){let h=ZC(C),R=typeof C==="object";this.decimal=R?C.decimal:void 0,this.decimalMultiplier=R&&"decimalMultiplier"in C?C.decimalMultiplier:b(Math.max(bC(CC(h)),this.decimal||0)),this.#P(h)}set(C){return new this.constructor({decimal:this.decimal,value:C,identifier:this.toString({includeSynthProtocol:!0})})}add(...C){return this.#h("add",...C)}sub(...C){return this.#h("sub",...C)}mul(...C){return this.#h("mul",...C)}div(...C){return this.#h("div",...C)}gt(C){return this.#C("gt",C)}gte(C){return this.#C("gte",C)}lt(C){return this.#C("lt",C)}lte(C){return this.#C("lte",C)}eqValue(C){return this.#C("eqValue",C)}getValue(C,h){let R=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||u(this.decimalMultiplier));switch(C){case"number":return Number(R);case"string":return R;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return R}}getBaseValue(C,h){let R=this.decimalMultiplier/b(h||this.decimal||G.THOR),T=Wh(this.bigIntValue,R);switch(C){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(C,h){if(!h&&typeof C==="object")return C.bigIntValue;let R=ZC(C),T=CC(R);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if((Number.parseInt(T)?T.length+P.length:P.length)<=C)return this.getValue("string");if(T.length>=C)return T.slice(0,C).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${P.slice(0,C-T.length)}`.padEnd(C-T.length,"0");let x=Number.parseInt(P),H=`${x}`.slice(0,C);return`0.${H.padStart(P.length-`${x}`.length+H.length,"0")}`}toFixed(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if(Number.parseInt(T))return`${T}.${P.slice(0,C)}`.padEnd(C,"0");let _=Number.parseInt(P),x=`${_}`.slice(0,C);return`0.${x.padStart(P.length-`${_}`.length+x.length,"0")}`}toAbbreviation(C=2){let h=this.getValue("number"),R=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),P=R[T];if(!P)return this.getValue("string");let _=10**(T*3);return`${(h/_).toFixed(C)}${P}`}toCurrency(C="$",{currencyPosition:h="start",decimal:R=2,decimalSeparator:T=".",thousandSeparator:P=","}={}){let _=this.getValue("number"),[x="",H=""]=_.toFixed(6).split("."),B=x.replace(/\B(?=(\d{3})+(?!\d))/g,P),E=x||H?x==="0"?`${Number.parseFloat(`0.${H}`)}`.replace(".",T):`${B}${Number.parseInt(H)?`${T}${H.slice(0,R)}`:""}`:"0.00";return`${h==="start"?C:""}${E}${h==="end"?C:""}`}formatBigIntToSafeValue(C,h){let R=h||this.decimal||r,T=Math.max(R,u(this.decimalMultiplier)),P=C<0n,_=C.toString().substring(P?1:0),x=T-(_.length-1),H=x>0?"0".repeat(x)+_:_,B=H.length-T,E=H.slice(-T);if(Number.parseInt(E[R]||"0")>=5)E=`${E.substring(0,R-1)}${(Number.parseInt(E[R-1]||"0")+1).toString()}`;else E=E.substring(0,R);return`${P?"-":""}${H.slice(0,B)}.${E}`.replace(/\.?0*$/,"")}#h(C,...h){let R=this.#R(this,...h),T=Math.max(R,u(this.decimalMultiplier)),P=b(T),_=h.reduce((H,B)=>{let E=this.getBigIntValue(B,T);switch(C){case"add":return H+E;case"sub":return H-E;case"mul":return H*E/P;case"div":{if(E===0n)throw new RangeError("Division by zero");return H*P/E}default:return H}},this.bigIntValue*P/this.decimalMultiplier),x=D({bigIntDecimal:T,decimal:T,value:_});return new this.constructor({decimalMultiplier:b(T),decimal:this.decimal,value:x,identifier:this.toString()})}#C(C,...h){let R=this.#R(this,...h),T=this.getBigIntValue(h[0]||"0",R),P=this.getBigIntValue(this,R);switch(C){case"gt":return P>T;case"gte":return P>=T;case"lt":return P<T;case"lte":return P<=T;case"eqValue":return P===T;default:return!1}}#P(C){let h=CC(C)||"0";this.bigIntValue=this.#T(h)}#R(...C){let h=C.map((R)=>{return typeof R==="object"?R.decimal||u(R.decimalMultiplier):bC(CC(R))}).filter(Boolean);return Math.max(...h,r)}#T(C,h){let R=h?b(h):this.decimalMultiplier,T=u(R),[P="",_=""]=C.split(".");return BigInt(`${P}${_.padEnd(T,"0")}`)}}var Vh=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function CC(C){let R=`${typeof C==="number"?Vh.format(C):ZC(C)}`.replaceAll(",",".").split(".");return R.length>1?`${R.slice(0,-1).join("")}.${R.at(-1)}`:R[0]||"0"}function bC(C){let h=C.split(".")[1]?.length||0;return Math.max(h,r)}function ZC(C){return typeof C==="object"?"getValue"in C?C.getValue("string"):C.value:C}var Sh=["SOL","TRX"],I=new Map;class w extends q{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:C,decimal:h,tax:R,chain:T,symbol:P,identifier:_}){super(typeof C==="object"?C:{decimal:h,value:C});let x=GC(_||`${T}.${P}`);this.type=l(x),this.tax=R,this.chain=x.chain,this.ticker=x.ticker,this.symbol=x.symbol,this.address=x.address,this.isSynthetic=x.isSynthetic,this.isTradeAsset=x.isTradeAsset,this.isGasAsset=x.isGasAsset,this.chainId=PC[x.chain]}toString({includeSynthProtocol:C}={}){return(this.isSynthetic||this.isTradeAsset)&&!C?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:C,symbol:h}){return this.chain===C&&this.symbol===h}eq(C){return this.eqAsset(C)&&this.eqValue(C)}static fromUrl(C,h=0){let[R,T,P]=C.split(".");if(!(R&&T))throw new A({errorKey:"helpers_invalid_asset_url",info:{urlAsset:C}});let _=R==="THOR"&&P?`${R}.${T}/${P}`:C;return w.from({asset:_,value:h})}static from({value:C=0,fromBaseDecimal:h,asyncTokenLookup:R,...T}){let P=C instanceof q?C.getValue("string"):C,_=Ih(T),{identifier:x,decimal:H}=c(_),{chain:B,isSynthetic:E,isTradeAsset:z}=GC(x),N=I.get(B==="SOL"?x:x.toUpperCase()),Q=N?.decimal||H;m(!(R||Q),`Couldn't find static decimal for one or more tokens on ${B} (Using default ${G[B]} decimal as fallback).
2
2
  This can result in incorrect calculations and mess with amount sent on transactions.
3
3
  You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
4
- or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:F,identifier:J,tax:p}=N||{decimal:Q||G[B],identifier:x},X=E||z,w=h?hC(BigInt(P),h):hC(P,F);return R?bh(J,h?w:P):X?Dh(J,w):new q({tax:p,decimal:F,identifier:J,value:w})}static async loadStaticAssets(C){let h=await EC(C);for(let{tokens:R}of Object.values(h))for(let{identifier:T,chain:P,..._}of R){let x=P==="SOL"?T:T.toUpperCase(),H="decimals"in _?_.decimals:G[P];I.set(x,{identifier:T,decimal:H})}return!0}static setStaticAssets(C){I.clear();for(let[h,R]of C.entries()){let T=R.chain==="SOL"?R.identifier:R.identifier.toUpperCase(),P="decimals"in R?R.decimals:R.decimal;I.set(h,{...R,decimal:P,identifier:T})}return!0}}function Kh(C){let h=q.from({chain:C});return GC.match(C).with("BTC","LTC","BCH","DASH",()=>h.set(0.00010001)).with("DOGE",()=>h.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>h.set(0.00000001)).with("THOR","MAYA",()=>h.set(0)).with("GAIA","KUJI",()=>h.set(0.000001)).otherwise(()=>h.set(0.00000001))}async function bh(C,h=0){XC(C);let T=C.includes("SOL.")?C:C.toUpperCase(),P=I.get(T),_=P?.decimal||await BC(AC(C));if(!P)I.set(T,{identifier:C,decimal:_});return new q({decimal:_,value:hC(h,_),identifier:C})}function Dh(C,h=0){let R=C.includes(".")?C.split(".")?.[0]?.toUpperCase():void 0,T=R?["MAYA","THOR"].includes(R):!1,P=C.slice(0,14).includes("~")?"~":"/",[_,x]=T?C.split(".").slice(1).join().split(P):C.split(P);if(!(_&&x))throw new A({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});return new q({decimal:8,value:hC(h,8),identifier:`${R||"THOR"}.${_}${P}${x}`})}function hC(C,h){return typeof C==="bigint"?D({value:C,bigIntDecimal:h,decimal:h}):C}function ph(C){let h=GC.match(C).when((R)=>("chain"in R)&&R.chain!==void 0,({chain:R})=>R).otherwise((R)=>{let T=e(R.asset);return T.synth?"THOR":T.chain});if(!Object.values(L).includes(h.toUpperCase()))throw new A({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function Ih(C){if(ph(C),"chain"in C)return C.chain;let{chain:h,symbol:R}=e(C.asset);return l({chain:h,symbol:R})==="Native"?h:C.asset}function AC(C){let h=C.slice(0,14),R=C.split("."),T=R[0]?.toUpperCase(),P=["THOR","MAYA"].includes(T),_=h.includes("/"),x=h.includes("~"),H=_||x,B=x?"~":"/",[E,z=""]=P?R.slice(1).join().split(B):C.split(B);if(H&&!(E&&z))throw new A({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});let[N,...Q]=(C.includes(".")&&!H?C:`${T}.${z}`).split("."),F=H?z:Q.join("."),{address:J,ticker:p}=yh({symbol:F,chain:N}),X;try{X=J&&V.includes(N)&&ZC.getAddress(J)?ZC.getAddress(J):J}catch(y){X=J}let w=(H?`${E}${B}`:"")+(X?`${p}-${X??""}`:F);return{address:X,chain:N,isSynthOrTrade:H,isSynthetic:_,isTradeAsset:x,ticker:p,symbol:w,isGasAsset:$C({chain:N,symbol:F})}}function yh({symbol:C,chain:h}){let R=C.split("-"),T=R.length===1?void 0:R[R.length-1],P=Sh.includes(h)?T:T?.toLowerCase(),_=R.length===1?R[0]:R.slice(0,-1).join("-");return{address:P,ticker:_}}class k extends W{eq(C){return this.eqValue(C)}static fromBigInt(C,h){return new k({decimal:h,value:D({value:C,bigIntDecimal:h,decimal:h})})}}var DC={average:1,fast:1.5,fastest:2};function zC(C="average"){let h=U.get("feeMultipliers");if(h&&h[C]!==void 0)return h[C];return DC[C]}function pC(C="average"){let h=zC(C),R=10n;return{numerator:BigInt(Math.round(h*10)),denominator:R}}function gh(C,h="average"){let{numerator:R,denominator:T}=pC(h);return C*R/T}function fh(C,h="average",R=!1){let T=zC(h),P=C*T;return R?Math.floor(P):P}function IC({liquidityUnits:C,poolUnits:h,runeDepth:R}){let T=Y(C),P=Y(h),_=Y(R),x=T.mul(_),H=P.mul(P).mul(2),B=P.mul(T).mul(2),E=T.mul(T),z=P.mul(P).mul(P);return x.mul(H.sub(B).add(E)).div(z)}function yC({liquidityUnits:C,poolUnits:h,assetDepth:R}){let T=Y(C),P=Y(h),_=Y(R),x=T.mul(_),H=P.mul(P).mul(2),B=P.mul(T).mul(2),E=T.mul(T),z=x.mul(H.sub(B).add(E)),N=P.mul(P).mul(P);return z.div(N)}function oh({percent:C,runeDepth:h,liquidityUnits:R,poolUnits:T}){return IC({runeDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function nh({percent:C,assetDepth:h,liquidityUnits:R,poolUnits:T}){return yC({assetDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function Y(C){return k.fromBigInt(BigInt(C),G.THOR)}function gC({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T}){return{assetAmount:Y(T).mul(C).div(h),runeAmount:Y(R).mul(C).div(h)}}function vh({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T,percent:P}){return Object.fromEntries(Object.entries(gC({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T})).map(([_,x])=>[_,x.mul(P)]))}function ch({runeDepth:C,poolUnits:h,assetDepth:R,liquidityUnits:T,runeAmount:P,assetAmount:_}){let x=new k({value:C,decimal:8}),H=new k({value:R,decimal:8}),B=new k({value:h,decimal:8}),E=new k({value:P,decimal:8}),z=new k({value:_,decimal:8}),N=E.mul(H),Q=z.mul(x),F=E.mul(z),J=x.mul(H),p=B.mul(N.add(Q.add(F.mul(2)))),X=N.add(Q.add(J.mul(2))),w=p.div(X),y=Y(T).add(w);if(w.getBaseValue("number")===0)return y.div(B).getBaseValue("number");let uC=B.add(y);return y.div(uC).getBaseValue("number")}function mh({runeAmount:C,assetAmount:h,runeDepth:R,assetDepth:T}){if(C==="0"||h==="0"||R==="0"||T==="0")return 0;let P=Y(R),_=Y(T),x=Y(h),H=Y(C),B=x.mul(P).sub(_.mul(H)),E=_.mul(H).add(P.mul(_));return Math.abs(B.div(E).getBaseValue("number"))}var fC=require("ts-pattern");function uh({type:C,address:h}){return`${C}:${h}`}function rh({address:C,unbondAmount:h}){return`${"UNBOND"}:${C}:${h}`}function dh(C){return NC("POOL+",C)}function th({chain:C,symbol:h,address:R,...T}){let P=eh({chain:C,symbol:h}),_=R?`:${R}:`:":";return NC(`${"+"}:${P}${_}`,T)}function ah({chain:C,symbol:h,ticker:R,basisPoints:T,targetAsset:P}){let _=C==="ETH"&&R!=="ETH"?`${R}-${h.slice(-3)}`:h,x=P?`:${P}`:"";return`${"-"}:${C}.${_}:${T}${x}`}function sh({basisPoints:C,...h}){return NC(`${"POOL-"}:${C}`,h)}function ih({name:C,chain:h,address:R,owner:T}){let P=`${"~"}:${C}:${h}:${R}`,_=T?`:${T}`:"";return`${P}${_}`}function lh({name:C,chain:h,asset:R,payout:T,owner:P}){return`${"~"}:${C}:${h}:${T}:${P}:${R}`}function NC(C,{affiliateAddress:h,affiliateBasisPoints:R}={}){let T=`${C}${h?`:${h}:${R||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function eh({chain:C,symbol:h}){return fC.match(C).with("BTC","DOGE","LTC",()=>C.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${C}.${h}`)}function CR({name:C,properties:h,methods:R}){function T(P){return{...R(P),...h}}return{[C]:T}}function hR(){return typeof window.ethereum!=="undefined"}function RR(C){return oC().includes(C)}function oC(){let C=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,R=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,P=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,_=window?.bitkeep?.ethereum,x=window?.$onekey?.ethereum,H=[];if(C)H.push("METAMASK");if(h)H.push("CTRL");if(R)H.push("BRAVE");if(T)H.push("TRUSTWALLET_WEB");if(P)H.push("COINBASE_WEB");if(mC())H.push("OKX_MOBILE");if(_)H.push("BITGET");if(x)H.push("ONEKEY");return H}async function nC(C,h,R){try{await OC({provider:C,method:"wallet_switchEthereumChain",params:[{chainId:PC[h]}]})}catch(T){if(!R)throw new A("helpers_failed_to_switch_network",{error:T,reason:"networkParams not provided"});await cC(C,R)}}function TR({chains:C,supportedChains:h,walletType:R}){let T=C.filter((_)=>h.includes(_));if(T.length===0)throw new A("wallet_chain_not_supported",{wallet:R,chain:C.join(", ")});let P=C.filter((_)=>!h.includes(_));return m(P.length>0,`${R} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`),T}function vC(C,h,R){return async(...T)=>{try{await nC(h,R)}catch(P){throw new A({errorKey:"helpers_failed_to_switch_network",info:{error:P}})}return C(...T)}}function PR({toolbox:C,chain:h,provider:R=window.ethereum,methodNames:T=[]}){let _=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,H)=>{if(!C[H])return x;let B=C[H];if(typeof B!=="function")return x;let E=vC(B,R,h);return{...x,[H]:E}},{});return{...C,..._}}function cC(C,h){return OC({provider:C,method:"wallet_addEthereumChain",params:[h]})}function _R(C){window.ethereum?.on("accountsChanged",()=>C()),window.xfi?.ethereum.on("accountsChanged",()=>C())}function HR(){let{isTrust:C,isBraveWallet:h,__XDEFI:R,overrideIsMetaMask:T,selectedProvider:P}=window?.ethereum||{};if(C)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(R)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function xR(){let C=[];function h(T){if(C.map((P)=>P.info.uuid).includes(T.detail.info.uuid))return;C.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function R(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:C,removeEIP6963EventListener:R}}function mC(){let C=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(C),R=/android|XiaoMi|MiuiBrowser/i.test(C),T=h||R,P=/OKApp/i.test(C);return T&&P}function BR({connect:C,name:h,supportedChains:R,walletType:T}){function P(_){return C({..._,walletType:T,supportedChains:R})}return{[h]:{supportedChains:R,connectWallet:P}}}function OC({provider:C,params:h,method:R}){if(!C?.send)throw new A("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return C.send(R,T)}
4
+ or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:F,identifier:J,tax:p}=N||{decimal:Q||G[B],identifier:x},X=E||z,W=h?hC(BigInt(P),h):hC(P,F);return R?bh(J,h?W:P):X?Dh(J,W):new w({tax:p,decimal:F,identifier:J,value:W})}static async loadStaticAssets(C){let h=await XC(C);for(let{tokens:R}of Object.values(h))for(let{identifier:T,chain:P,..._}of R){let x=P==="SOL"?T:T.toUpperCase(),H="decimals"in _?_.decimals:G[P];I.set(x,{identifier:T,decimal:H})}return!0}static setStaticAssets(C){I.clear();for(let[h,R]of C.entries()){let T=R.chain==="SOL"?R.identifier:R.identifier.toUpperCase(),P="decimals"in R?R.decimals:R.decimal;I.set(h,{...R,decimal:P,identifier:T})}return!0}}function Kh(C){let h=w.from({chain:C});return zC.match(C).with("BTC","LTC","BCH","DASH",()=>h.set(0.00010001)).with("DOGE",()=>h.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>h.set(0.00000001)).with("THOR","MAYA",()=>h.set(0)).with("GAIA","KUJI",()=>h.set(0.000001)).otherwise(()=>h.set(0.00000001))}async function bh(C,h=0){jC(C);let T=C.includes("SOL.")?C:C.toUpperCase(),P=I.get(T),_=P?.decimal||await $C(GC(C));if(!P)I.set(T,{identifier:C,decimal:_});return new w({decimal:_,value:hC(h,_),identifier:C})}function Dh(C,h=0){let R=C.includes(".")?C.split(".")?.[0]?.toUpperCase():void 0,T=R?["MAYA","THOR"].includes(R):!1,P=C.slice(0,14).includes("~")?"~":"/",[_,x]=T?C.split(".").slice(1).join().split(P):C.split(P);if(!(_&&x))throw new A({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});return new w({decimal:8,value:hC(h,8),identifier:`${R||"THOR"}.${_}${P}${x}`})}function hC(C,h){return typeof C==="bigint"?D({value:C,bigIntDecimal:h,decimal:h}):C}function ph(C){let h=zC.match(C).when((R)=>("chain"in R)&&R.chain!==void 0,({chain:R})=>R).otherwise((R)=>{let T=e(R.asset);return T.synth?"THOR":T.chain});if(!Object.values(L).includes(h.toUpperCase()))throw new A({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function Ih(C){if(ph(C),"chain"in C)return C.chain;let{chain:h,symbol:R}=e(C.asset);return l({chain:h,symbol:R})==="Native"?h:C.asset}function GC(C){let h=C.slice(0,14),R=C.split("."),T=R[0]?.toUpperCase(),P=["THOR","MAYA"].includes(T),_=h.includes("/"),x=h.includes("~"),H=_||x,B=x?"~":"/",[E,z=""]=P?R.slice(1).join().split(B):C.split(B);if(H&&!(E&&z))throw new A({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});let[N,...Q]=(C.includes(".")&&!H?C:`${T}.${z}`).split("."),F=H?z:Q.join("."),{address:J,ticker:p}=yh({symbol:F,chain:N}),X;try{X=J&&V.includes(N)&&AC.getAddress(J)?AC.getAddress(J):J}catch(y){X=J}let W=(H?`${E}${B}`:"")+(X?`${p}-${X??""}`:F);return{address:X,chain:N,isSynthOrTrade:H,isSynthetic:_,isTradeAsset:x,ticker:p,symbol:W,isGasAsset:EC({chain:N,symbol:F})}}function yh({symbol:C,chain:h}){let R=C.split("-"),T=R.length===1?void 0:R[R.length-1],P=Sh.includes(h)?T:T?.toLowerCase(),_=R.length===1?R[0]:R.slice(0,-1).join("-");return{address:P,ticker:_}}class U extends q{eq(C){return this.eqValue(C)}static fromBigInt(C,h){return new U({decimal:h,value:D({value:C,bigIntDecimal:h,decimal:h})})}}var DC={average:1,fast:1.5,fastest:2};function NC(C="average"){let h=M.get("feeMultipliers");if(h&&h[C]!==void 0)return h[C];return DC[C]}function pC(C="average"){let h=NC(C),R=10n;return{numerator:BigInt(Math.round(h*10)),denominator:R}}function gh(C,h="average"){let{numerator:R,denominator:T}=pC(h);return C*R/T}function oh(C,h="average",R=!1){let T=NC(h),P=C*T;return R?Math.floor(P):P}function IC({liquidityUnits:C,poolUnits:h,runeDepth:R}){let T=Y(C),P=Y(h),_=Y(R),x=T.mul(_),H=P.mul(P).mul(2),B=P.mul(T).mul(2),E=T.mul(T),z=P.mul(P).mul(P);return x.mul(H.sub(B).add(E)).div(z)}function yC({liquidityUnits:C,poolUnits:h,assetDepth:R}){let T=Y(C),P=Y(h),_=Y(R),x=T.mul(_),H=P.mul(P).mul(2),B=P.mul(T).mul(2),E=T.mul(T),z=x.mul(H.sub(B).add(E)),N=P.mul(P).mul(P);return z.div(N)}function nh({percent:C,runeDepth:h,liquidityUnits:R,poolUnits:T}){return IC({runeDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function fh({percent:C,assetDepth:h,liquidityUnits:R,poolUnits:T}){return yC({assetDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function Y(C){return U.fromBigInt(BigInt(C),G.THOR)}function gC({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T}){return{assetAmount:Y(T).mul(C).div(h),runeAmount:Y(R).mul(C).div(h)}}function vh({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T,percent:P}){return Object.fromEntries(Object.entries(gC({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T})).map(([_,x])=>[_,x.mul(P)]))}function ch({runeDepth:C,poolUnits:h,assetDepth:R,liquidityUnits:T,runeAmount:P,assetAmount:_}){let x=new U({value:C,decimal:8}),H=new U({value:R,decimal:8}),B=new U({value:h,decimal:8}),E=new U({value:P,decimal:8}),z=new U({value:_,decimal:8}),N=E.mul(H),Q=z.mul(x),F=E.mul(z),J=x.mul(H),p=B.mul(N.add(Q.add(F.mul(2)))),X=N.add(Q.add(J.mul(2))),W=p.div(X),y=Y(T).add(W);if(W.getBaseValue("number")===0)return y.div(B).getBaseValue("number");let uC=B.add(y);return y.div(uC).getBaseValue("number")}function mh({runeAmount:C,assetAmount:h,runeDepth:R,assetDepth:T}){if(C==="0"||h==="0"||R==="0"||T==="0")return 0;let P=Y(R),_=Y(T),x=Y(h),H=Y(C),B=x.mul(P).sub(_.mul(H)),E=_.mul(H).add(P.mul(_));return Math.abs(B.div(E).getBaseValue("number"))}var oC=require("ts-pattern");function uh({type:C,address:h}){return`${C}:${h}`}function rh({address:C,unbondAmount:h}){return`${"UNBOND"}:${C}:${h}`}function dh(C){return OC("POOL+",C)}function th({chain:C,symbol:h,address:R,...T}){let P=eh({chain:C,symbol:h}),_=R?`:${R}:`:":";return OC(`${"+"}:${P}${_}`,T)}function ah({chain:C,symbol:h,ticker:R,basisPoints:T,targetAsset:P}){let _=C==="ETH"&&R!=="ETH"?`${R}-${h.slice(-3)}`:h,x=P?`:${P}`:"";return`${"-"}:${C}.${_}:${T}${x}`}function ih({basisPoints:C,...h}){return OC(`${"POOL-"}:${C}`,h)}function sh({name:C,chain:h,address:R,owner:T}){let P=`${"~"}:${C}:${h}:${R}`,_=T?`:${T}`:"";return`${P}${_}`}function lh({name:C,chain:h,asset:R,payout:T,owner:P}){return`${"~"}:${C}:${h}:${T}:${P}:${R}`}function OC(C,{affiliateAddress:h,affiliateBasisPoints:R}={}){let T=`${C}${h?`:${h}:${R||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function eh({chain:C,symbol:h}){return oC.match(C).with("BTC","DOGE","LTC",()=>C.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${C}.${h}`)}function CR({name:C,properties:h,methods:R}){function T(P){return{...R(P),...h}}return{[C]:T}}function hR(){return typeof window.ethereum!=="undefined"}function RR(C){return nC().includes(C)}function nC(){let C=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,R=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,P=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,_=window?.bitkeep?.ethereum,x=window?.$onekey?.ethereum,H=[];if(C)H.push("METAMASK");if(h)H.push("CTRL");if(R)H.push("BRAVE");if(T)H.push("TRUSTWALLET_WEB");if(P)H.push("COINBASE_WEB");if(mC())H.push("OKX_MOBILE");if(_)H.push("BITGET");if(x)H.push("ONEKEY");return H}async function fC(C,h,R){try{await LC({provider:C,method:"wallet_switchEthereumChain",params:[{chainId:_C[h]}]})}catch(T){if(!R)throw new A("helpers_failed_to_switch_network",{error:T,reason:"networkParams not provided"});await cC(C,R)}}function TR({chains:C,supportedChains:h,walletType:R}){let T=C.filter((_)=>h.includes(_));if(T.length===0)throw new A("wallet_chain_not_supported",{wallet:R,chain:C.join(", ")});let P=C.filter((_)=>!h.includes(_));return m(P.length>0,`${R} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`),T}function vC(C,h,R){return async(...T)=>{try{await fC(h,R)}catch(P){throw new A({errorKey:"helpers_failed_to_switch_network",info:{error:P}})}return C(...T)}}function PR({toolbox:C,chain:h,provider:R=window.ethereum,methodNames:T=[]}){let _=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,H)=>{if(!C[H])return x;let B=C[H];if(typeof B!=="function")return x;let E=vC(B,R,h);return{...x,[H]:E}},{});return{...C,..._}}function cC(C,h){return LC({provider:C,method:"wallet_addEthereumChain",params:[h]})}function _R(C){window.ethereum?.on("accountsChanged",()=>C()),window.xfi?.ethereum.on("accountsChanged",()=>C())}function HR(){let{isTrust:C,isBraveWallet:h,__XDEFI:R,overrideIsMetaMask:T,selectedProvider:P}=window?.ethereum||{};if(C)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(R)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function xR(){let C=[];function h(T){if(C.map((P)=>P.info.uuid).includes(T.detail.info.uuid))return;C.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function R(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:C,removeEIP6963EventListener:R}}function mC(){let C=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(C),R=/android|XiaoMi|MiuiBrowser/i.test(C),T=h||R,P=/OKApp/i.test(C);return T&&P}function BR({connect:C,name:h,supportedChains:R,walletType:T}){function P(_){return C({..._,walletType:T,supportedChains:R})}return{[h]:{supportedChains:R,connectWallet:P}}}function LC({provider:C,params:h,method:R}){if(!C?.send)throw new A("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return C.send(R,T)}
5
5
 
6
- //# debugId=18CE7DBCCCE2AB1864756E2164756E21
6
+ //# debugId=9FC0F08144CA307D64756E2164756E21