@swapkit/helpers 4.0.0-beta.31 → 4.0.0-beta.33

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.js CHANGED
@@ -1,7 +1,7 @@
1
- import{o as j,q as W}from"./chunk-ganzk321.js";import{getAddress as IT}from"ethers";import{match as KT}from"ts-pattern";import{match as GT}from"ts-pattern";var fT={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,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,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_asset_is_not_tcy:40003,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_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,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 J extends Error{static ErrorCode=fT;constructor(T,F){let _=typeof T==="string",P=_?T:T.errorKey,A=_?void 0:T.info,H=`${P}${A?`: ${JSON.stringify(A)}`:""}`;super(H);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=F,F)console.error(`SwapKitError [${P}]:`,F);else if(A)console.error(`SwapKitError [${P}]:`,A)}}var U;((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"})(U||={});var _T;((_)=>{_.THORChain="THOR_STAGENET";_.Maya="MAYA_STAGENET"})(_T||={});var h;((N)=>{N.Arbitrum="42161";N.ArbitrumHex="0xa4b1";N.Avalanche="43114";N.AvalancheHex="0xa86a";N.Base="8453";N.BaseHex="0x2105";N.BinanceSmartChain="56";N.BinanceSmartChainHex="0x38";N.Bitcoin="bitcoin";N.BitcoinCash="bitcoincash";N.Chainflip="chainflip";N.Cosmos="cosmoshub-4";N.Dash="dash";N.Dogecoin="dogecoin";N.Kujira="kaiyo-1";N.Ethereum="1";N.EthereumHex="0x1";N.Fiat="fiat";N.Litecoin="litecoin";N.Maya="mayachain-mainnet-v1";N.MayaStagenet="mayachain-stagenet-v1";N.Near="near";N.Optimism="10";N.OptimismHex="0xa";N.Polkadot="polkadot";N.Polygon="137";N.PolygonHex="0x89";N.Radix="radix-mainnet";N.Ripple="ripple";N.THORChain="thorchain-1";N.THORChainStagenet="thorchain-stagenet-v2";N.Solana="solana";N.Tron="728126428";N.TronHex="0x2b6653dc";N.Zcash="zcash"})(h||={});var UF={["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"},gT=Object.keys(U),c=Object.values(U),Y={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},OF={["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},kF=["DOT","FLIP"],E=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],XT=["BTC","BCH","DASH","DOGE","LTC","ZEC"],IF=["GAIA","THOR","MAYA","KUJI"],KF={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},wF=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],DF=["ARB","DASH","ETH","KUJI","MAYA","THOR"],l={["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://mainnet.lightwalletd.com:9067",["MAYA_STAGENET"]:"",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},o={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},ET={["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",o.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"]:[]},PT={["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"},NT=l,bT=(T)=>{return GT(T).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:[]})).with("XRP",()=>({method:"ping",params:[{}],id:1,jsonrpc:"2.0"})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:T})})};function yT(T){return GT(T).with("XRD",()=>"/status/network-configuration").with("TRX",()=>"/wallet/getnowblock").otherwise(()=>"")}var BT=async(T,F)=>{try{let _=F.startsWith("wss")?F.replace("wss","https"):F;return(await fetch(`${_}${yT(T)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(bT(T)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},vT=async(T)=>{let F=l[T];if(await BT(T,F))return F;for(let _ of ET[T])if(await BT(T,_))return _;return F},SF=async(T=[...Object.values(U),...Object.values(_T)])=>{let F={};await Promise.all(T.map(async(_)=>{let P=await vT(_);F[_]=P})),NT={...NT,...F}},QT=c.reduce((T,F)=>{let _=gT.find((P)=>U[P]===F);if(_)T[F]=_;return T},{}),zT=c.reduce((T,F)=>{return T[F]=h[QT[F]],T},{}),ZT=c.reduce((T,F)=>{let _=`${QT[F]}Hex`;return T[F]=h[_],T},{}),fF=c.reduce((T,F)=>{return T[F]=PT[F],T},{});import{match as t}from"ts-pattern";var y={get:n("GET"),post:n("POST"),extend:(T)=>({get:n("GET",T),post:n("POST",T),extend:(F)=>y.extend({...T,...F})})};function n(T,F={}){return async(_,P={})=>{let{searchParams:A,json:H,body:$,headers:x,dynamicHeader:X}={...F,...P},B=!!H||_.endsWith(".json"),V=B?JSON.stringify(H):$;try{let G=CT(_,A),I=uT(B,{...x,...X?.()}),q=await fetch(G,{...P,method:T,body:V,headers:I});if(!q.ok){let D=await q.text();throw new J("helpers_invalid_response",{status:q.status,statusText:q.statusText,message:D})}let L=await q.json();return P.onSuccess?.(L)||P.responseHandler?.(L)||L}catch(G){if(P.onError)return P.onError(G);throw G}}}function uT(T,F){return{...F,...T?{"Content-Type":"application/json"}:{}}}function CT(T,F){let _=new URL(T);if(F)_.search=new URLSearchParams(F).toString();return _.toString()}import{createStore as sT}from"zustand/vanilla";var pT;((z)=>{z.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";z.TC_SUPPORTED_TO_ETH="TC-ERC20";z.TC_SUPPORTED_TO_AVAX="TC-ARC20";z.TC_SUPPORTED_TO_BSC="TC-BEP20";z.ETH_TO_TC_SUPPORTED="ERC20-TC";z.ETH_TO_ETH="ERC20-ERC20";z.ETH_TO_AVAX="ERC20-ARC20";z.ETH_TO_BSC="ERC20-BEP20";z.AVAX_TO_TC_SUPPORTED="ARC20-TC";z.AVAX_TO_ETH="ARC20-ERC20";z.AVAX_TO_AVAX="ARC20-ARC20";z.AVAX_TO_BSC="ARC20-BEP20";z.BSC_TO_TC_SUPPORTED="BEP20-TC";z.BSC_TO_ETH="BEP20-ERC20";z.BSC_TO_AVAX="BEP20-ARC20";z.BSC_TO_BSC="BEP20-BEP20"})(pT||={});var yF=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],vF=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],uF=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function AT(T,F){if("index"in F)return[...T.slice(0,T.length-1),F.index];if("change"in F){let[_,P,A,,H]=T;return[_,P,A,F.change,H]}if("account"in F){let[_,P,,A,H]=T;return[_,P,F.account,A,H]}return T}function JT([T,F,_,P,A]){let H=typeof A!=="number";if(typeof P!=="number")return`m/${T}'/${F}'/${_}'`;return`m/${T}'/${F}'/${_}'/${P}${H?"":`/${A}`}`}function mF({chain:T,index:F,addressIndex:_=0,type:P}){if(E.includes(T)){if(P&&["legacy","account"].includes(P))return[44,60,0,F];if(P==="ledgerLive")return[44,60,F,0,_];return AT(v[T],{index:F})}if(T==="SOL"){if(P==="account")return[44,501,0,F];return AT(v[T],{index:F})}let A=T==="LTC"?2:0;switch(P){case"nativeSegwitMiddleAccount":return[84,A,F,0,_];case"segwit":return[49,A,0,0,F];case"legacy":return[44,A,0,0,F];default:return AT(v[T],{index:F})}}function dF(T){let[F,_,P]=T.split("/").map((A)=>Number.parseInt(A,10));switch(_){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var mT;((x)=>{x.ARB="0x0000000000000000000000000000000000000000";x.AVAX="0x0000000000000000000000000000000000000000";x.BASE="0x0000000000000000000000000000000000000000";x.ETH="0x0000000000000000000000000000000000000000";x.BSC="0x0000000000000000000000000000000000000000";x.MATIC="0x0000000000000000000000000000000000001010";x.OP="0x4200000000000000000000000000000000000042"})(mT||={});var v={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],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]},cF=Object.keys(v).reduce((T,F)=>{return T[F]=JT(v[F]),T},{});var dT;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(dT||={});var oT;((_)=>{_.highSlippage="highSlippage";_.highPriceImpact="highPriceImpact"})(oT||={});var hT;((M)=>{M.CAVIAR_V1="CAVIAR_V1";M.CAMELOT_V3="CAMELOT_V3";M.CHAINFLIP="CHAINFLIP";M.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";M.JUPITER="JUPITER";M.MAYACHAIN="MAYACHAIN";M.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";M.OCISWAP_V1="OCISWAP_V1";M.ONEINCH="ONEINCH";M.OPENOCEAN_V2="OPENOCEAN_V2";M.PANCAKESWAP="PANCAKESWAP";M.PANGOLIN_V1="PANGOLIN_V1";M.SUSHISWAP_V2="SUSHISWAP_V2";M.THORCHAIN="THORCHAIN";M.THORCHAIN_STREAMING="THORCHAIN_STREAMING";M.TRADERJOE_V2="TRADERJOE_V2";M.UNISWAP_V2="UNISWAP_V2";M.UNISWAP_V3="UNISWAP_V3";M.KADO="KADO";M.NEAR="NEAR"})(hT||={});var cT;((x)=>{x.LIQUIDITY="liquidity";x.NETWORK="network";x.INBOUND="inbound";x.OUTBOUND="outbound";x.AFFILIATE="affiliate";x.TAX="tax";x.PRIORITY="priority"})(cT||={});var MT;((P)=>{P.Average="average";P.Fast="fast";P.Fastest="fastest"})(MT||={});var lT;((_)=>{_.Approve="approve";_.CheckOnly="checkOnly"})(lT||={});var YT;((G)=>{G.NAME_REGISTER="~";G.BOND="BOND";G.DEPOSIT="+";G.LEAVE="LEAVE";G.UNBOND="UNBOND";G.WITHDRAW="-";G.RUNEPOOL_DEPOSIT="POOL+";G.RUNEPOOL_WITHDRAW="POOL-";G.CLAIM_TCY="tcy";G.STAKE_TCY="tcy+";G.UNSTAKE_TCY="tcy-"})(YT||={});var s;((Q)=>{Q.BITGET="BITGET";Q.BRAVE="BRAVE";Q.COINBASE_MOBILE="COINBASE_MOBILE";Q.COINBASE_WEB="COINBASE_WEB";Q.COSMOSTATION="COSMOSTATION";Q.CTRL="CTRL";Q.EIP6963="EIP6963";Q.EXODUS="EXODUS";Q.KEEPKEY="KEEPKEY";Q.KEEPKEY_BEX="KEEPKEY_BEX";Q.KEPLR="KEPLR";Q.KEYSTORE="KEYSTORE";Q.LEAP="LEAP";Q.LEDGER="LEDGER";Q.LEDGER_LIVE="LEDGER_LIVE";Q.METAMASK="METAMASK";Q.OKX="OKX";Q.OKX_MOBILE="OKX_MOBILE";Q.ONEKEY="ONEKEY";Q.PHANTOM="PHANTOM";Q.POLKADOT_JS="POLKADOT_JS";Q.RADIX_WALLET="RADIX_WALLET";Q.TREZOR="TREZOR";Q.TALISMAN="TALISMAN";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.WALLETCONNECT="WALLETCONNECT";Q.XAMAN="XAMAN"})(s||={});var nT;((P)=>{P[P.NoError=36864]="NoError";P[P.LockedDevice=21781]="LockedDevice";P[P.TC_NotFound=65535]="TC_NotFound"})(nT||={});var tT={apis:{},chains:Object.values(U),wallets:Object.values(s),explorerUrls:PT,nodeUrls:o,rpcUrls:l,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},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=sT((T)=>({...tT,setApiKey:(F,_)=>T((P)=>({apiKeys:{...P.apiKeys,[F]:_}})),setEnv:(F,_)=>T((P)=>({envs:{...P.envs,[F]:_}})),setExplorerUrl:(F,_)=>T((P)=>({explorerUrls:{...P.explorerUrls,[F]:_}})),setNodeUrl:(F,_)=>T((P)=>({nodeUrls:{...P.nodeUrls,[F]:_}})),setRpcUrl:(F,_)=>T((P)=>({rpcUrls:{...P.rpcUrls,[F]:_}})),setIntegrationConfig:(F,_)=>T((P)=>({integrations:{...P.integrations,[F]:_}})),setFeeMultipliers:(F)=>T(()=>({feeMultipliers:F})),setConfig:(F)=>T((_)=>({apiKeys:{..._.apiKeys,...F.apiKeys},envs:{..._.envs,...F.envs},explorerUrls:{..._.explorerUrls,...F.explorerUrls},integrations:{..._.integrations,...F.integrations},nodeUrls:{..._.nodeUrls,...F.nodeUrls},rpcUrls:{..._.rpcUrls,...F.rpcUrls},feeMultipliers:F.feeMultipliers||_.feeMultipliers,chains:_.chains.concat(F.chains||[]),wallets:_.wallets.concat(F.wallets||[])}))})),K={getState:k.getState,get:(T)=>k.getState()[T],set:(T)=>k.getState().setConfig(T),setApiKey:(T,F)=>k.getState().setApiKey(T,F),setEnv:(T,F)=>k.getState().setEnv(T,F),setExplorerUrl:(T,F)=>k.getState().setExplorerUrl(T,F),setNodeUrl:(T,F)=>k.getState().setNodeUrl(T,F),setRpcUrl:(T,F)=>k.getState().setRpcUrl(T,F),setIntegrationConfig:(T,F)=>k.getState().setIntegrationConfig(T,F),setFeeMultipliers:(T)=>k.getState().setFeeMultipliers(T)};var Q_=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],LT=["ARB","BASE","ETH","OP","MATIC"];async function rT({chain:T,to:F}){try{let{result:P}=await y.post(K.get("rpcUrls")[T],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:F.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(P||Y[T]).toString())}catch(P){return console.error(`Failed to fetch contract decimals for ${F} on ${T}:`,P),Y[T]}}async function iT(T){if(T==="XRD")return Y.XRD;try{let F=T.split("-")[1]?.toLowerCase(),{manager:_}=await y.post(`${K.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:F})});return _.divisibility.value.divisibility}catch(F){return console.error(`Failed to fetch Radix asset decimal for ${T}:`,F),Y["XRD"]}}async function aT({chain:T,symbol:F}){if(E.includes(F))return Y[F];let _=F.split("-"),P=_.length===1?void 0:_[_.length-1]?.toLowerCase();return await(P?.startsWith("0x")?rT({chain:T,to:P}):Y[T])}function jT({chain:T,symbol:F}){return t(T).with(...E,(_)=>aT({chain:_,symbol:F})).with("XRD",()=>iT(F)).otherwise(()=>Y[T])}function z_({chain:T}){return f.from({chain:T})}function WT({chain:T,symbol:F}){return t(T).with(...LT,()=>F==="ETH").with("AVAX",()=>F==="AVAX").with("BSC",()=>F==="BNB").with("MAYA",()=>F==="CACAO").with("GAIA",()=>F==="ATOM").with("THOR",()=>F==="RUNE").with("XRD",()=>`${T}.${F}`===r(T).identifier).otherwise(()=>F===T)}var r=(T)=>{let F=Y[T];return t(T.toUpperCase()).with(...LT,(P)=>({identifier:`${P}.ETH`,decimal:F})).with("THOR",(P)=>({identifier:`${P}.RUNE`,decimal:F})).with("GAIA",(P)=>({identifier:`${P}.ATOM`,decimal:F})).with("MAYA",(P)=>({identifier:`${P}.CACAO`,decimal:10})).with("BSC",(P)=>({identifier:`${P}.BNB`,decimal:F})).with("AVAX",(P)=>({identifier:`${P}.AVAX`,decimal:F})).with(...XT,"SOL","FLIP","KUJI","XRP","DOT","TRX","NEAR",(P)=>({identifier:`${P}.${P}`,decimal:F})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:F})).with("KUJI.USK",(P)=>({identifier:P,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:Y.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:Y.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:Y.ETH})).with("MAYA.CACAO",(P)=>({identifier:P,decimal:10})).with("MAYA.MAYA",(P)=>({identifier:P,decimal:4})).otherwise(()=>({identifier:T,decimal:F}))};function RT({chain:T,symbol:F}){if(F.includes("/"))return"Synth";if(F.includes("~"))return"Trade";return t(T).with("XRD",()=>F==="XRD"||`${T}.${F}`===r(T).identifier).with("ARB","OP","BASE",()=>F==="ETH").with("GAIA",()=>F==="ATOM").with("BSC",()=>F==="BNB").with("MAYA",()=>F==="CACAO").with("THOR",()=>F==="RUNE").otherwise(()=>F===T)?"Native":T}var HT=(T)=>{let[F,..._]=T.split("."),P=T.includes("/"),A=_.join("."),H=A?.split("-"),$=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:F,symbol:A,ticker:$,synth:P}};async function Z_(T){let{tokenLists:F}=await import("@swapkit/helpers/tokens");for(let _ of Object.values(F))for(let{identifier:P,chain:A,...H}of _.tokens){if("identifier"in T&&P===T.identifier)return P;if("address"in H&&"chain"in T&&A===T.chain&&H.address.toLowerCase()===T.contract.toLowerCase())return P}return}function W_(T){if(T<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return 10+T}function V_(T){if(T<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return Math.round((10+T*1.0512)*10000000000)/10000000000}function q_(T,F){try{return T()}catch(_){if(F)throw new J(F,_);return}}function U_(T){switch(T){case"THOR":return`${T}.RUNE`;case"GAIA":return`${T}.ATOM`;case"BSC":return`${T}`;default:return`${T}.${T}`}}var VT=new Set;function i(T,F){if(T){if(VT.has(F))return;VT.add(F)}}async function O_(T="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(T))return T;try{let F=K.get("rpcUrls")[T!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await y.get(`${F}/status`)).result.node_info.network}catch(F){return T}}import{match as eT}from"ts-pattern";var TF=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function qT(T){let F=T||TF,_={};for(let P of F){let A=await FF(P);_[P]=A}return _}async function FF(T){let{list:F}=await eT(T).with("camelot",()=>import("./chunk-9f2b3enk.js")).with("caviar",()=>import("./chunk-0q5vvg5c.js")).with("chainflip",()=>import("./chunk-adrafsdk.js")).with("jupiter",()=>import("./chunk-fm9ycn0h.js")).with("mayachain",()=>import("./chunk-b1hang9z.js")).with("oneinch",()=>import("./chunk-4yqymkbp.js")).with("openocean",()=>import("./chunk-rhqk87p2.js")).with("pancakeswap",()=>import("./chunk-v9zj2gsj.js")).with("pangolin",()=>import("./chunk-6m0d5pv4.js")).with("sushiswap",()=>import("./chunk-18bxh1n7.js")).with("thorchain",()=>import("./chunk-92sk0g47.js")).with("traderjoe",()=>import("./chunk-8x46g3wq.js")).with("uniswap",()=>import("./chunk-vwh9jfxn.js")).with("uniswapv3",()=>import("./chunk-mmyv2vsv.js")).exhaustive();return F}var UT=["TERRA",...K.get("chains")];function OT(T=""){let F=T.toUpperCase(),[_]=F.split(".");if(UT.includes(_))return!0;let[P]=F.split("/");if(UT.includes(P))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${T}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:T}})}function S_(T){if(T.length>30)return!1;let F=/^[a-zA-Z0-9+_-]+$/g;return!!T.match(F)}var d=8,b=(T)=>10n**BigInt(T),m=(T)=>Math.log10(Number.parseFloat(T.toString()));function u({value:T,bigIntDecimal:F=d,decimal:_=d}){if(_===0)return T.toString();let P=T<0n,A=T.toString().substring(P?1:0),H=_-(A.length-1);if(H>0)A="0".repeat(H)+A;let $=A.length-_,x=A.slice(-_);if(Number.parseInt(x[F]||"0")>=5)x=`${x.substring(0,F-1)}${(Number.parseInt(x[F-1]||"0")+1).toString()}`;else x=x.substring(0,F);return`${P?"-":""}${A.slice(0,$)}.${x}`.replace(/\.?0*$/,"")}function _F(T,F){if(F===0n)throw new Error("Cannot divide by zero");let _=F/2n;if(T>=0n&&F>=0n||T<0n&&F<0n)return(T+_)/F;return(T-_)/F}class g{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(T,F){return new g({decimal:F,value:u({value:T,bigIntDecimal:F,decimal:F})})}static shiftDecimals({value:T,from:F,to:_}){return g.fromBigInt(T.getBaseValue("bigint")*b(_)/b(F),_)}constructor(T){let F=xT(T),_=typeof T==="object";this.decimal=_?T.decimal:void 0,this.decimalMultiplier=_&&"decimalMultiplier"in T?T.decimalMultiplier:b(Math.max(kT(a(F)),this.decimal||0)),this.#A(F)}set(T){return new this.constructor({decimal:this.decimal,value:T,identifier:this.toString({includeSynthProtocol:!0})})}add(...T){return this.#F("add",...T)}sub(...T){return this.#F("sub",...T)}mul(...T){return this.#F("mul",...T)}div(...T){return this.#F("div",...T)}gt(T){return this.#T("gt",T)}gte(T){return this.#T("gte",T)}lt(T){return this.#T("lt",T)}lte(T){return this.#T("lte",T)}eqValue(T){return this.#T("eqValue",T)}getValue(T,F){let _=this.formatBigIntToSafeValue(this.bigIntValue,F||this.decimal||m(this.decimalMultiplier));switch(T){case"number":return Number(_);case"string":return _;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return _}}getBaseValue(T,F){let _=this.decimalMultiplier/b(F||this.decimal||Y.THOR),P=_F(this.bigIntValue,_);switch(T){case"number":return Number(P);case"string":return P.toString();case"bigint":return P;default:return P}}getBigIntValue(T,F){if(!F&&typeof T==="object")return T.bigIntValue;let _=xT(T),P=a(_);if(P==="0"||P==="undefined")return 0n;return this.#P(P,F)}toSignificant(T=6){let[F,_]=this.getValue("string").split("."),P=F||"",A=_||"";if((Number.parseInt(P)?P.length+A.length:A.length)<=T)return this.getValue("string");if(P.length>=T)return P.slice(0,T).padEnd(P.length,"0");if(Number.parseInt(P))return`${P}.${A.slice(0,T-P.length)}`.padEnd(T-P.length,"0");let $=Number.parseInt(A),x=`${$}`.slice(0,T);return`0.${x.padStart(A.length-`${$}`.length+x.length,"0")}`}toFixed(T=6){let[F,_]=this.getValue("string").split("."),P=F||"",A=_||"";if(Number.parseInt(P))return`${P}.${A.slice(0,T)}`.padEnd(T,"0");let H=Number.parseInt(A),$=`${H}`.slice(0,T);return`0.${$.padStart(A.length-`${H}`.length+$.length,"0")}`}toAbbreviation(T=2){let F=this.getValue("number"),_=["","K","M","B","T","Q","Qi","S"],P=Math.floor(Math.log10(Math.abs(F))/3),A=_[P];if(!A)return this.getValue("string");let H=10**(P*3);return`${(F/H).toFixed(T)}${A}`}toCurrency(T="$",{currencyPosition:F="start",decimal:_=2,decimalSeparator:P=".",thousandSeparator:A=","}={}){let H=this.getValue("number"),[$="",x=""]=H.toFixed(6).split("."),X=$.replace(/\B(?=(\d{3})+(?!\d))/g,A),B=$||x?$==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",P):`${X}${Number.parseInt(x)?`${P}${x.slice(0,_)}`:""}`:"0.00";return`${F==="start"?T:""}${B}${F==="end"?T:""}`}formatBigIntToSafeValue(T,F){let _=F||this.decimal||d,P=Math.max(_,m(this.decimalMultiplier)),A=T<0n,H=T.toString().substring(A?1:0),$=P-(H.length-1),x=$>0?"0".repeat($)+H:H,X=x.length-P,B=x.slice(-P);if(Number.parseInt(B[_]||"0")>=5)B=`${B.substring(0,_-1)}${(Number.parseInt(B[_-1]||"0")+1).toString()}`;else B=B.substring(0,_);return`${A?"-":""}${x.slice(0,X)}.${B}`.replace(/\.?0*$/,"")}#F(T,...F){let _=this.#_(this,...F),P=Math.max(_,m(this.decimalMultiplier)),A=b(P),H=F.reduce((x,X)=>{let B=this.getBigIntValue(X,P);switch(T){case"add":return x+B;case"sub":return x-B;case"mul":return x*B/A;case"div":{if(B===0n)throw new RangeError("Division by zero");return x*A/B}default:return x}},this.bigIntValue*A/this.decimalMultiplier),$=u({bigIntDecimal:P,decimal:P,value:H});return new this.constructor({decimalMultiplier:b(P),decimal:this.decimal,value:$,identifier:this.toString()})}#T(T,...F){let _=this.#_(this,...F),P=this.getBigIntValue(F[0]||"0",_),A=this.getBigIntValue(this,_);switch(T){case"gt":return A>P;case"gte":return A>=P;case"lt":return A<P;case"lte":return A<=P;case"eqValue":return A===P;default:return!1}}#A(T){let F=a(T)||"0";this.bigIntValue=this.#P(F)}#_(...T){let F=T.map((_)=>{return typeof _==="object"?_.decimal||m(_.decimalMultiplier):kT(a(_))}).filter(Boolean);return Math.max(...F,d)}#P(T,F){let _=F?b(F):this.decimalMultiplier,P=m(_),[A="",H=""]=T.split(".");return BigInt(`${A}${H.padEnd(P,"0")}`)}}var PF=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function a(T){let _=`${typeof T==="number"?PF.format(T):xT(T)}`.replaceAll(",",".").split(".");return _.length>1?`${_.slice(0,-1).join("")}.${_.at(-1)}`:_[0]||"0"}function kT(T){let F=T.split(".")[1]?.length||0;return Math.max(F,d)}function xT(T){return typeof T==="object"?"getValue"in T?T.getValue("string"):T.value:T}var e=["SOL","TRX"],C=new Map;class f extends g{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:T,decimal:F,tax:_,chain:P,symbol:A,identifier:H}){super(typeof T==="object"?T:{decimal:F,value:T});let $=$T(H||`${P}.${A}`);this.type=RT($),this.tax=_,this.chain=$.chain,this.ticker=$.ticker,this.symbol=$.symbol,this.address=$.address,this.isSynthetic=$.isSynthetic,this.isTradeAsset=$.isTradeAsset,this.isGasAsset=$.isGasAsset,this.chainId=zT[$.chain]}toString({includeSynthProtocol:T}={}){return(this.isSynthetic||this.isTradeAsset)&&!T?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:T,symbol:F}){return this.chain===T&&this.symbol===F}eq(T){return this.eqAsset(T)&&this.eqValue(T)}static fromUrl(T,F=0){let[_,P,A]=T.split(".");if(!(_&&P))throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:T}});let H=_==="THOR"&&A?`${_}.${P}/${A}`:T;return f.from({asset:H,value:F})}static from({value:T=0,fromBaseDecimal:F,asyncTokenLookup:_,...P}){let A=T instanceof g?T.getValue("string"):T,H=xF(P),{identifier:$,decimal:x}=r(H),{chain:X,isSynthetic:B,isTradeAsset:V}=$T($),G=C.get(e.includes(X)?$:$.toUpperCase()),I=G?.decimal||x;i(!(_||I),`Couldn't find static decimal for one or more tokens on ${X} (Using default ${Y[X]} decimal as fallback).
1
+ import{o as j,q as V}from"./chunk-ganzk321.js";import{getAddress as kT}from"ethers";import{match as KT}from"ts-pattern";import{match as BT}from"ts-pattern";var ST={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,wallet_vultisig_not_found:22101,wallet_vultisig_contract_address_not_provided:22102,wallet_vultisig_asset_not_defined:22103,wallet_vultisig_send_transaction_no_address:22104,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,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_asset_is_not_tcy:40003,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_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,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 J extends Error{static ErrorCode=ST;constructor(T,_){let F=typeof T==="string",P=F?T:T.errorKey,A=F?void 0:T.info,H=`${P}${A?`: ${JSON.stringify(A)}`:""}`;super(H);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=_,_)console.error(`SwapKitError [${P}]:`,_);else if(A)console.error(`SwapKitError [${P}]:`,A)}}var q;((N)=>{N.Arbitrum="ARB";N.Aurora="AURORA";N.Avalanche="AVAX";N.Base="BASE";N.Berachain="BERA";N.BinanceSmartChain="BSC";N.Bitcoin="BTC";N.BitcoinCash="BCH";N.Cosmos="GAIA";N.Dash="DASH";N.Dogecoin="DOGE";N.Ethereum="ETH";N.Fiat="FIAT";N.Gnosis="GNO";N.Kujira="KUJI";N.Litecoin="LTC";N.Maya="MAYA";N.Near="NEAR";N.Optimism="OP";N.Polkadot="DOT";N.Chainflip="FLIP";N.Polygon="POL";N.Radix="XRD";N.Ripple="XRP";N.THORChain="THOR";N.Solana="SOL";N.Tron="TRX";N.Zcash="ZEC"})(q||={});var _T;((F)=>{F.THORChain="THOR_STAGENET";F.Maya="MAYA_STAGENET"})(_T||={});var o;((B)=>{B.Arbitrum="42161";B.ArbitrumHex="0xa4b1";B.Aurora="1313161554";B.AuroraHex="0x4e454152";B.Avalanche="43114";B.AvalancheHex="0xa86a";B.Base="8453";B.BaseHex="0x2105";B.Berachain="80094";B.BerachainHex="0x138de";B.BinanceSmartChain="56";B.BinanceSmartChainHex="0x38";B.Bitcoin="bitcoin";B.BitcoinCash="bitcoincash";B.Chainflip="chainflip";B.Cosmos="cosmoshub-4";B.Dash="dash";B.Dogecoin="dogecoin";B.Ethereum="1";B.EthereumHex="0x1";B.Fiat="fiat";B.Gnosis="100";B.GnosisHex="0x64";B.Kujira="kaiyo-1";B.Litecoin="litecoin";B.Maya="mayachain-mainnet-v1";B.MayaStagenet="mayachain-stagenet-v1";B.Near="near";B.Optimism="10";B.OptimismHex="0xa";B.Polkadot="polkadot";B.Polygon="137";B.PolygonHex="0x89";B.Radix="radix-mainnet";B.Ripple="ripple";B.THORChain="thorchain-1";B.THORChainStagenet="thorchain-stagenet-v2";B.Solana="solana";B.Tron="728126428";B.TronHex="0x2b6653dc";B.Zcash="zcash"})(o||={});var q_={["0xa4b1"]:"ARB",["42161"]:"ARB",["0x4e454152"]:"AURORA",["1313161554"]:"AURORA",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x138de"]:"BERA",["80094"]:"BERA",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["1"]:"ETH",["fiat"]:"FIAT",["0x64"]:"GNO",["100"]:"GNO",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"POL",["137"]:"POL",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["728126428"]:"TRX",["0x2b6653dc"]:"TRX",["zcash"]:"ZEC"},fT=Object.keys(q),h=Object.values(q),Y={ARB:18,AURORA:18,AVAX:18,BASE:18,BCH:8,BERA:18,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,GNO:18,KUJI:6,LTC:8,POL:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,TRX:6,XRD:18,XRP:6,ZEC:8},U_={["ARB"]:0.3,["AURORA"]:1,["AVAX"]:3,["BASE"]:2,["BERA"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["GNO"]:5.2,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["POL"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRX"]:3,["ZEC"]:150},O_=["DOT","FLIP"],g=["ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL"],GT=["BTC","BCH","DASH","DOGE","LTC","ZEC"],k_=["GAIA","THOR","MAYA","KUJI"],K_={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},I_=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],w_=["ARB","DASH","ETH","KUJI","MAYA","THOR"],c={["ARB"]:"https://arb1.arbitrum.io/rpc",["AURORA"]:"https://aurora-rpc.publicnode.com",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BERA"]:"https://berachain-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"]:"",["GNO"]:"https://gnosis-rpc.publicnode.com",["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",["POL"]:"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://mainnet.lightwalletd.com:9067",["MAYA_STAGENET"]:"",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},d={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},gT={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AURORA"]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],["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"],["BERA"]:["https://rpc.berachain.com","https://berachain.drpc.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"]:[],["GNO"]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],["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"],["POL"]:["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",d.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"]:[]},FT={["ARB"]:"https://arbiscan.io",["AURORA"]:"https://explorer.mainnet.aurora.dev",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BERA"]:"https://berascan.com",["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"]:"",["GNO"]:"https://gnosisscan.io",["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",["POL"]:"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"},$T=c,ET=(T)=>{return BT(T).with("ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL",()=>({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:[]})).with("XRP",()=>({method:"ping",params:[{}],id:1,jsonrpc:"2.0"})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:T})})};function bT(T){return BT(T).with("XRD",()=>"/status/network-configuration").with("TRX",()=>"/wallet/getnowblock").otherwise(()=>"")}var NT=async(T,_)=>{try{let F=_.startsWith("wss")?_.replace("wss","https"):_;return(await fetch(`${F}${bT(T)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ET(T)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},vT=async(T)=>{let _=c[T];if(await NT(T,_))return _;for(let F of gT[T])if(await NT(T,F))return F;return _},D_=async(T=[...Object.values(q),...Object.values(_T)])=>{let _={};await Promise.all(T.map(async(F)=>{let P=await vT(F);_[F]=P})),$T={...$T,..._}},XT=h.reduce((T,_)=>{let F=fT.find((P)=>q[P]===_);if(F)T[_]=F;return T},{}),QT=h.reduce((T,_)=>{return T[_]=o[XT[_]],T},{}),zT=h.reduce((T,_)=>{let F=`${XT[_]}Hex`;return T[_]=o[F],T},{}),S_=h.reduce((T,_)=>{return T[_]=FT[_],T},{});import{match as s}from"ts-pattern";var b={get:l("GET"),post:l("POST"),extend:(T)=>({get:l("GET",T),post:l("POST",T),extend:(_)=>b.extend({...T,..._})})};function l(T,_={}){return async(F,P={})=>{let{searchParams:A,json:H,body:x,headers:$,dynamicHeader:G}={..._,...P},X=!!H||F.endsWith(".json"),Z=X?JSON.stringify(H):x;try{let Q=uT(F,A),k=yT(X,{...$,...G?.()}),W=await fetch(Q,{...P,method:T,body:Z,headers:k});if(!W.ok){let w=await W.text();throw new J("helpers_invalid_response",{status:W.status,statusText:W.statusText,message:w})}let L=await W.json();return P.onSuccess?.(L)||P.responseHandler?.(L)||L}catch(Q){if(P.onError)return P.onError(Q);throw Q}}}function yT(T,_){return{..._,...T?{"Content-Type":"application/json"}:{}}}function uT(T,_){let F=new URL(T);if(_)F.search=new URLSearchParams(_).toString();return F.toString()}import{createStore as nT}from"zustand/vanilla";var pT;((z)=>{z.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";z.TC_SUPPORTED_TO_ETH="TC-ERC20";z.TC_SUPPORTED_TO_AVAX="TC-ARC20";z.TC_SUPPORTED_TO_BSC="TC-BEP20";z.ETH_TO_TC_SUPPORTED="ERC20-TC";z.ETH_TO_ETH="ERC20-ERC20";z.ETH_TO_AVAX="ERC20-ARC20";z.ETH_TO_BSC="ERC20-BEP20";z.AVAX_TO_TC_SUPPORTED="ARC20-TC";z.AVAX_TO_ETH="ARC20-ERC20";z.AVAX_TO_AVAX="ARC20-ARC20";z.AVAX_TO_BSC="ARC20-BEP20";z.BSC_TO_TC_SUPPORTED="BEP20-TC";z.BSC_TO_ETH="BEP20-ERC20";z.BSC_TO_AVAX="BEP20-ARC20";z.BSC_TO_BSC="BEP20-BEP20"})(pT||={});var b_=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],v_=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],y_=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function PT(T,_){if("index"in _)return[...T.slice(0,T.length-1),_.index];if("change"in _){let[F,P,A,,H]=T;return[F,P,A,_.change,H]}if("account"in _){let[F,P,,A,H]=T;return[F,P,_.account,A,H]}return T}function ZT([T,_,F,P,A]){let H=typeof A!=="number";if(typeof P!=="number")return`m/${T}'/${_}'/${F}'`;return`m/${T}'/${_}'/${F}'/${P}${H?"":`/${A}`}`}function C_({chain:T,index:_,addressIndex:F=0,type:P}){if(g.includes(T)){if(P&&["legacy","account"].includes(P))return[44,60,0,_];if(P==="ledgerLive")return[44,60,_,0,F];return PT(v[T],{index:_})}if(T==="SOL"){if(P==="account")return[44,501,0,_];return PT(v[T],{index:_})}let A=T==="LTC"?2:0;switch(P){case"nativeSegwitMiddleAccount":return[84,A,_,0,F];case"segwit":return[49,A,0,0,_];case"legacy":return[44,A,0,0,_];default:return PT(v[T],{index:_})}}function m_(T){let[_,F,P]=T.split("/").map((A)=>Number.parseInt(A,10));switch(F){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var CT;((Z)=>{Z.ARB="0x0000000000000000000000000000000000000000";Z.AURORA="0x0000000000000000000000000000000000000000";Z.AVAX="0x0000000000000000000000000000000000000000";Z.BASE="0x0000000000000000000000000000000000000000";Z.BERA="0x0000000000000000000000000000000000000000";Z.ETH="0x0000000000000000000000000000000000000000";Z.BSC="0x0000000000000000000000000000000000000000";Z.GNO="0x0000000000000000000000000000000000000000";Z.MATIC="0x0000000000000000000000000000000000001010";Z.OP="0x4200000000000000000000000000000000000042"})(CT||={});var v={ARB:[44,60,0,0,0],AURORA:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BERA:[44,60,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],GNO:[44,60,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],POL:[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]},h_=Object.keys(v).reduce((T,_)=>{return T[_]=ZT(v[_]),T},{});var mT;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(mT||={});var dT;((F)=>{F.highSlippage="highSlippage";F.highPriceImpact="highPriceImpact"})(dT||={});var oT;((M)=>{M.CAVIAR_V1="CAVIAR_V1";M.CAMELOT_V3="CAMELOT_V3";M.CHAINFLIP="CHAINFLIP";M.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";M.JUPITER="JUPITER";M.MAYACHAIN="MAYACHAIN";M.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";M.OCISWAP_V1="OCISWAP_V1";M.ONEINCH="ONEINCH";M.OPENOCEAN_V2="OPENOCEAN_V2";M.PANCAKESWAP="PANCAKESWAP";M.PANGOLIN_V1="PANGOLIN_V1";M.SUSHISWAP_V2="SUSHISWAP_V2";M.THORCHAIN="THORCHAIN";M.THORCHAIN_STREAMING="THORCHAIN_STREAMING";M.TRADERJOE_V2="TRADERJOE_V2";M.UNISWAP_V2="UNISWAP_V2";M.UNISWAP_V3="UNISWAP_V3";M.KADO="KADO";M.NEAR="NEAR"})(oT||={});var hT;(($)=>{$.LIQUIDITY="liquidity";$.NETWORK="network";$.INBOUND="inbound";$.OUTBOUND="outbound";$.AFFILIATE="affiliate";$.TAX="tax";$.PRIORITY="priority"})(hT||={});var JT;((P)=>{P.Average="average";P.Fast="fast";P.Fastest="fastest"})(JT||={});var cT;((F)=>{F.Approve="approve";F.CheckOnly="checkOnly"})(cT||={});var MT;((Q)=>{Q.NAME_REGISTER="~";Q.BOND="BOND";Q.DEPOSIT="+";Q.LEAVE="LEAVE";Q.UNBOND="UNBOND";Q.WITHDRAW="-";Q.RUNEPOOL_DEPOSIT="POOL+";Q.RUNEPOOL_WITHDRAW="POOL-";Q.CLAIM_TCY="tcy";Q.STAKE_TCY="tcy+";Q.UNSTAKE_TCY="tcy-"})(MT||={});var n;((N)=>{N.BITGET="BITGET";N.BRAVE="BRAVE";N.COINBASE_MOBILE="COINBASE_MOBILE";N.COINBASE_WEB="COINBASE_WEB";N.COSMOSTATION="COSMOSTATION";N.CTRL="CTRL";N.EIP6963="EIP6963";N.EXODUS="EXODUS";N.KEEPKEY="KEEPKEY";N.KEEPKEY_BEX="KEEPKEY_BEX";N.KEPLR="KEPLR";N.KEYSTORE="KEYSTORE";N.LEAP="LEAP";N.LEDGER="LEDGER";N.LEDGER_LIVE="LEDGER_LIVE";N.METAMASK="METAMASK";N.OKX="OKX";N.OKX_MOBILE="OKX_MOBILE";N.ONEKEY="ONEKEY";N.PHANTOM="PHANTOM";N.POLKADOT_JS="POLKADOT_JS";N.RADIX_WALLET="RADIX_WALLET";N.TREZOR="TREZOR";N.TALISMAN="TALISMAN";N.TRUSTWALLET_WEB="TRUSTWALLET_WEB";N.VULTISIG="VULTISIG";N.WALLETCONNECT="WALLETCONNECT";N.XAMAN="XAMAN"})(n||={});var lT;((P)=>{P[P.NoError=36864]="NoError";P[P.LockedDevice=21781]="LockedDevice";P[P.TC_NotFound=65535]="TC_NotFound"})(lT||={});var sT={apis:{},chains:Object.values(q),wallets:Object.values(n),explorerUrls:FT,nodeUrls:d,rpcUrls:c,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},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},O=nT((T)=>({...sT,setApiKey:(_,F)=>T((P)=>({apiKeys:{...P.apiKeys,[_]:F}})),setEnv:(_,F)=>T((P)=>({envs:{...P.envs,[_]:F}})),setExplorerUrl:(_,F)=>T((P)=>({explorerUrls:{...P.explorerUrls,[_]:F}})),setNodeUrl:(_,F)=>T((P)=>({nodeUrls:{...P.nodeUrls,[_]:F}})),setRpcUrl:(_,F)=>T((P)=>({rpcUrls:{...P.rpcUrls,[_]:F}})),setIntegrationConfig:(_,F)=>T((P)=>({integrations:{...P.integrations,[_]:F}})),setFeeMultipliers:(_)=>T(()=>({feeMultipliers:_})),setConfig:(_)=>T((F)=>({apiKeys:{...F.apiKeys,..._.apiKeys},envs:{...F.envs,..._.envs},explorerUrls:{...F.explorerUrls,..._.explorerUrls},integrations:{...F.integrations,..._.integrations},nodeUrls:{...F.nodeUrls,..._.nodeUrls},rpcUrls:{...F.rpcUrls,..._.rpcUrls},feeMultipliers:_.feeMultipliers||F.feeMultipliers,chains:F.chains.concat(_.chains||[]),wallets:F.wallets.concat(_.wallets||[])}))})),K={getState:O.getState,get:(T)=>O.getState()[T],set:(T)=>O.getState().setConfig(T),setApiKey:(T,_)=>O.getState().setApiKey(T,_),setEnv:(T,_)=>O.getState().setEnv(T,_),setExplorerUrl:(T,_)=>O.getState().setExplorerUrl(T,_),setNodeUrl:(T,_)=>O.getState().setNodeUrl(T,_),setRpcUrl:(T,_)=>O.getState().setRpcUrl(T,_),setIntegrationConfig:(T,_)=>O.getState().setIntegrationConfig(T,_),setFeeMultipliers:(T)=>O.getState().setFeeMultipliers(T)};var XF=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],YT=["ARB","AURORA","BASE","ETH","OP","POL"];async function tT({chain:T,to:_}){try{let{result:P}=await b.post(K.get("rpcUrls")[T],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:_.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(P||Y[T]).toString())}catch(P){return console.error(`Failed to fetch contract decimals for ${_} on ${T}:`,P),Y[T]}}async function rT(T){if(T==="XRD")return Y.XRD;try{let _=T.split("-")[1]?.toLowerCase(),{manager:F}=await b.post(`${K.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:_})});return F.divisibility.value.divisibility}catch(_){return console.error(`Failed to fetch Radix asset decimal for ${T}:`,_),Y["XRD"]}}async function iT({chain:T,symbol:_}){if(g.includes(_))return Y[_];let F=_.split("-"),P=F.length===1?void 0:F[F.length-1]?.toLowerCase();return await(P?.startsWith("0x")?tT({chain:T,to:P}):Y[T])}function LT({chain:T,symbol:_}){return s(T).with(...g,(F)=>iT({chain:F,symbol:_})).with("XRD",()=>rT(_)).otherwise(()=>Y[T])}function QF({chain:T}){return S.from({chain:T})}function jT({chain:T,symbol:_}){return s(T).with(...YT,()=>_==="ETH").with("AVAX",()=>_==="AVAX").with("BERA",()=>_==="BERA").with("BSC",()=>_==="BNB").with("GNO",()=>_==="XDAU").with("MAYA",()=>_==="CACAO").with("GAIA",()=>_==="ATOM").with("THOR",()=>_==="RUNE").with("XRD",()=>`${T}.${_}`===t(T).identifier).otherwise(()=>_===T)}var t=(T)=>{let _=Y[T];return s(T.toUpperCase()).with(...YT,(P)=>({identifier:`${P}.ETH`,decimal:_})).with("THOR",(P)=>({identifier:`${P}.RUNE`,decimal:_})).with("GAIA",(P)=>({identifier:`${P}.ATOM`,decimal:_})).with("MAYA",(P)=>({identifier:`${P}.CACAO`,decimal:10})).with("BSC",(P)=>({identifier:`${P}.BNB`,decimal:_})).with("AVAX",(P)=>({identifier:`${P}.AVAX`,decimal:_})).with("GNO",(P)=>({identifier:`${P}.XDAI`,decimal:_})).with("BERA",(P)=>({identifier:`${P}.BERA`,decimal:_})).with(...GT,"SOL","FLIP","KUJI","XRP","DOT","TRX","NEAR",(P)=>({identifier:`${P}.${P}`,decimal:_})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:_})).with("KUJI.USK",(P)=>({identifier:P,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:Y.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:Y.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:Y.ETH})).with("MAYA.CACAO",(P)=>({identifier:P,decimal:10})).with("MAYA.MAYA",(P)=>({identifier:P,decimal:4})).otherwise(()=>({identifier:T,decimal:_}))};function AT({chain:T,symbol:_}){if(_.includes("/"))return"Synth";if(_.includes("~"))return"Trade";return s(T).with("XRD",()=>_==="XRD"||`${T}.${_}`===t(T).identifier).with("ARB","OP","BASE",()=>_==="ETH").with("GAIA",()=>_==="ATOM").with("BSC",()=>_==="BNB").with("MAYA",()=>_==="CACAO").with("THOR",()=>_==="RUNE").otherwise(()=>_===T)?"Native":T}var RT=(T)=>{let[_,...F]=T.split("."),P=T.includes("/"),A=F.join("."),H=A?.split("-"),x=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:_,symbol:A,ticker:x,synth:P}};async function zF(T){let{tokenLists:_}=await import("@swapkit/helpers/tokens");for(let F of Object.values(_))for(let{identifier:P,chain:A,...H}of F.tokens){if("identifier"in T&&P===T.identifier)return P;if("address"in H&&"chain"in T&&A===T.chain&&H.address.toLowerCase()===T.contract.toLowerCase())return P}return}function jF(T){if(T<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return 10+T}function VF(T){if(T<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return Math.round((10+T*1.0512)*10000000000)/10000000000}function WF(T,_){try{return T()}catch(F){if(_)throw new J(_,F);return}}function qF(T){switch(T){case"THOR":return`${T}.RUNE`;case"GAIA":return`${T}.ATOM`;case"BSC":return`${T}`;default:return`${T}.${T}`}}var VT=new Set;function r(T,_){if(T){if(VT.has(_))return;VT.add(_)}}async function UF(T="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(T))return T;try{let _=K.get("rpcUrls")[T!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await b.get(`${_}/status`)).result.node_info.network}catch(_){return T}}import{match as aT}from"ts-pattern";var eT=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function WT(T){let _=T||eT,F={};for(let P of _){let A=await T_(P);F[P]=A}return F}async function T_(T){let{list:_}=await aT(T).with("camelot",()=>import("./chunk-9f2b3enk.js")).with("caviar",()=>import("./chunk-0q5vvg5c.js")).with("chainflip",()=>import("./chunk-adrafsdk.js")).with("jupiter",()=>import("./chunk-fm9ycn0h.js")).with("mayachain",()=>import("./chunk-b1hang9z.js")).with("oneinch",()=>import("./chunk-4yqymkbp.js")).with("openocean",()=>import("./chunk-rhqk87p2.js")).with("pancakeswap",()=>import("./chunk-v9zj2gsj.js")).with("pangolin",()=>import("./chunk-6m0d5pv4.js")).with("sushiswap",()=>import("./chunk-18bxh1n7.js")).with("thorchain",()=>import("./chunk-92sk0g47.js")).with("traderjoe",()=>import("./chunk-8x46g3wq.js")).with("uniswap",()=>import("./chunk-vwh9jfxn.js")).with("uniswapv3",()=>import("./chunk-mmyv2vsv.js")).exhaustive();return _}var qT=["TERRA",...K.get("chains")];function UT(T=""){let _=T.toUpperCase(),[F]=_.split(".");if(qT.includes(F))return!0;let[P]=_.split("/");if(qT.includes(P))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${T}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:T}})}function DF(T){if(T.length>30)return!1;let _=/^[a-zA-Z0-9+_-]+$/g;return!!T.match(_)}var m=8,E=(T)=>10n**BigInt(T),C=(T)=>Math.log10(Number.parseFloat(T.toString()));function y({value:T,bigIntDecimal:_=m,decimal:F=m}){if(F===0)return T.toString();let P=T<0n,A=T.toString().substring(P?1:0),H=F-(A.length-1);if(H>0)A="0".repeat(H)+A;let x=A.length-F,$=A.slice(-F);if(Number.parseInt($[_]||"0")>=5)$=`${$.substring(0,_-1)}${(Number.parseInt($[_-1]||"0")+1).toString()}`;else $=$.substring(0,_);return`${P?"-":""}${A.slice(0,x)}.${$}`.replace(/\.?0*$/,"")}function __(T,_){if(_===0n)throw new Error("Cannot divide by zero");let F=_/2n;if(T>=0n&&_>=0n||T<0n&&_<0n)return(T+F)/_;return(T-F)/_}class f{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(T,_){return new f({decimal:_,value:y({value:T,bigIntDecimal:_,decimal:_})})}static shiftDecimals({value:T,from:_,to:F}){return f.fromBigInt(T.getBaseValue("bigint")*E(F)/E(_),F)}constructor(T){let _=HT(T),F=typeof T==="object";this.decimal=F?T.decimal:void 0,this.decimalMultiplier=F&&"decimalMultiplier"in T?T.decimalMultiplier:E(Math.max(OT(i(_)),this.decimal||0)),this.#A(_)}set(T){return new this.constructor({decimal:this.decimal,value:T,identifier:this.toString({includeSynthProtocol:!0})})}add(...T){return this.#_("add",...T)}sub(...T){return this.#_("sub",...T)}mul(...T){return this.#_("mul",...T)}div(...T){return this.#_("div",...T)}gt(T){return this.#T("gt",T)}gte(T){return this.#T("gte",T)}lt(T){return this.#T("lt",T)}lte(T){return this.#T("lte",T)}eqValue(T){return this.#T("eqValue",T)}getValue(T,_){let F=this.formatBigIntToSafeValue(this.bigIntValue,_||this.decimal||C(this.decimalMultiplier));switch(T){case"number":return Number(F);case"string":return F;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return F}}getBaseValue(T,_){let F=this.decimalMultiplier/E(_||this.decimal||Y.THOR),P=__(this.bigIntValue,F);switch(T){case"number":return Number(P);case"string":return P.toString();case"bigint":return P;default:return P}}getBigIntValue(T,_){if(!_&&typeof T==="object")return T.bigIntValue;let F=HT(T),P=i(F);if(P==="0"||P==="undefined")return 0n;return this.#P(P,_)}toSignificant(T=6){let[_,F]=this.getValue("string").split("."),P=_||"",A=F||"";if((Number.parseInt(P)?P.length+A.length:A.length)<=T)return this.getValue("string");if(P.length>=T)return P.slice(0,T).padEnd(P.length,"0");if(Number.parseInt(P))return`${P}.${A.slice(0,T-P.length)}`.padEnd(T-P.length,"0");let x=Number.parseInt(A),$=`${x}`.slice(0,T);return`0.${$.padStart(A.length-`${x}`.length+$.length,"0")}`}toFixed(T=6){let[_,F]=this.getValue("string").split("."),P=_||"",A=F||"";if(Number.parseInt(P))return`${P}.${A.slice(0,T)}`.padEnd(T,"0");let H=Number.parseInt(A),x=`${H}`.slice(0,T);return`0.${x.padStart(A.length-`${H}`.length+x.length,"0")}`}toAbbreviation(T=2){let _=this.getValue("number"),F=["","K","M","B","T","Q","Qi","S"],P=Math.floor(Math.log10(Math.abs(_))/3),A=F[P];if(!A)return this.getValue("string");let H=10**(P*3);return`${(_/H).toFixed(T)}${A}`}toCurrency(T="$",{currencyPosition:_="start",decimal:F=2,decimalSeparator:P=".",thousandSeparator:A=","}={}){let H=this.getValue("number"),[x="",$=""]=H.toFixed(6).split("."),G=x.replace(/\B(?=(\d{3})+(?!\d))/g,A),X=x||$?x==="0"?`${Number.parseFloat(`0.${$}`)}`.replace(".",P):`${G}${Number.parseInt($)?`${P}${$.slice(0,F)}`:""}`:"0.00";return`${_==="start"?T:""}${X}${_==="end"?T:""}`}formatBigIntToSafeValue(T,_){let F=_||this.decimal||m,P=Math.max(F,C(this.decimalMultiplier)),A=T<0n,H=T.toString().substring(A?1:0),x=P-(H.length-1),$=x>0?"0".repeat(x)+H:H,G=$.length-P,X=$.slice(-P);if(Number.parseInt(X[F]||"0")>=5)X=`${X.substring(0,F-1)}${(Number.parseInt(X[F-1]||"0")+1).toString()}`;else X=X.substring(0,F);return`${A?"-":""}${$.slice(0,G)}.${X}`.replace(/\.?0*$/,"")}#_(T,..._){let F=this.#F(this,..._),P=Math.max(F,C(this.decimalMultiplier)),A=E(P),H=_.reduce(($,G)=>{let X=this.getBigIntValue(G,P);switch(T){case"add":return $+X;case"sub":return $-X;case"mul":return $*X/A;case"div":{if(X===0n)throw new RangeError("Division by zero");return $*A/X}default:return $}},this.bigIntValue*A/this.decimalMultiplier),x=y({bigIntDecimal:P,decimal:P,value:H});return new this.constructor({decimalMultiplier:E(P),decimal:this.decimal,value:x,identifier:this.toString()})}#T(T,..._){let F=this.#F(this,..._),P=this.getBigIntValue(_[0]||"0",F),A=this.getBigIntValue(this,F);switch(T){case"gt":return A>P;case"gte":return A>=P;case"lt":return A<P;case"lte":return A<=P;case"eqValue":return A===P;default:return!1}}#A(T){let _=i(T)||"0";this.bigIntValue=this.#P(_)}#F(...T){let _=T.map((F)=>{return typeof F==="object"?F.decimal||C(F.decimalMultiplier):OT(i(F))}).filter(Boolean);return Math.max(..._,m)}#P(T,_){let F=_?E(_):this.decimalMultiplier,P=C(F),[A="",H=""]=T.split(".");return BigInt(`${A}${H.padEnd(P,"0")}`)}}var F_=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function i(T){let F=`${typeof T==="number"?F_.format(T):HT(T)}`.replaceAll(",",".").split(".");return F.length>1?`${F.slice(0,-1).join("")}.${F.at(-1)}`:F[0]||"0"}function OT(T){let _=T.split(".")[1]?.length||0;return Math.max(_,m)}function HT(T){return typeof T==="object"?"getValue"in T?T.getValue("string"):T.value:T}var a=["SOL","TRX"],u=new Map;class S extends f{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:T,decimal:_,tax:F,chain:P,symbol:A,identifier:H}){super(typeof T==="object"?T:{decimal:_,value:T});let x=xT(H||`${P}.${A}`);this.type=AT(x),this.tax=F,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=QT[x.chain]}toString({includeSynthProtocol:T}={}){return(this.isSynthetic||this.isTradeAsset)&&!T?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:T,symbol:_}){return this.chain===T&&this.symbol===_}eq(T){return this.eqAsset(T)&&this.eqValue(T)}static fromUrl(T,_=0){let[F,P,A]=T.split(".");if(!(F&&P))throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:T}});let H=F==="THOR"&&A?`${F}.${P}/${A}`:T;return S.from({asset:H,value:_})}static from({value:T=0,fromBaseDecimal:_,asyncTokenLookup:F,...P}){let A=T instanceof f?T.getValue("string"):T,H=H_(P),{identifier:x,decimal:$}=t(H),{chain:G,isSynthetic:X,isTradeAsset:Z}=xT(x),Q=u.get(a.includes(G)?x:x.toUpperCase()),k=Q?.decimal||$;r(!(F||k),`Couldn't find static decimal for one or more tokens on ${G} (Using default ${Y[G]} 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:q,identifier:L,tax:D}=G||{decimal:I||Y[X],identifier:$},z=B||V,S=F?TT(BigInt(A),F):TT(A,q);return _?AF(L,F?S:A):z?RF(L,S):new f({tax:D,decimal:q,identifier:L,value:S})}static async loadStaticAssets(T){let F=await qT(T);for(let{tokens:_}of Object.values(F))for(let{identifier:P,chain:A,...H}of _){let $=e.includes(A)?P:P.toUpperCase(),x="decimals"in H?H.decimals:Y[A];C.set($,{identifier:P,decimal:x})}return!0}static setStaticAssets(T){C.clear();for(let[F,_]of T.entries()){let P=e.includes(_.chain)?_.identifier:_.identifier.toUpperCase(),A="decimals"in _?_.decimals:_.decimal;C.set(F,{..._,decimal:A,identifier:P})}return!0}}function h_(T){let F=f.from({chain:T});return KT(T).with("BTC","LTC","BCH","DASH",()=>F.set(0.00010001)).with("DOGE",()=>F.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>F.set(0.00000001)).with("THOR","MAYA",()=>F.set(0)).with("GAIA","KUJI",()=>F.set(0.000001)).otherwise(()=>F.set(0.00000001))}async function AF(T,F=0){OT(T);let P=T.includes("SOL.")?T:T.toUpperCase(),A=C.get(P),H=A?.decimal||await jT($T(T));if(!A)C.set(P,{identifier:T,decimal:H});return new f({decimal:H,value:TT(F,H),identifier:T})}function RF(T,F=0){let _=T.includes(".")?T.split(".")?.[0]?.toUpperCase():void 0,P=_?["MAYA","THOR"].includes(_):!1,A=T.slice(0,14).includes("~")?"~":"/",[H,$]=P?T.split(".").slice(1).join().split(A):T.split(A);if(!(H&&$))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});return new f({decimal:8,value:TT(F,8),identifier:`${_||"THOR"}.${H}${A}${$}`})}function TT(T,F){return typeof T==="bigint"?u({value:T,bigIntDecimal:F,decimal:F}):T}function HF(T){let F=KT(T).when((_)=>("chain"in _)&&_.chain!==void 0,({chain:_})=>_).otherwise((_)=>{let P=HT(_.asset);return P.synth?"THOR":P.chain});if(!Object.values(U).includes(F.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function xF(T){if(HF(T),"chain"in T)return T.chain;let{chain:F,symbol:_}=HT(T.asset);return RT({chain:F,symbol:_})==="Native"?F:T.asset}function $T(T){let F=T.slice(0,14),_=T.split("."),P=_[0]?.toUpperCase(),A=["THOR","MAYA"].includes(P),H=F.includes("/"),$=F.includes("~"),x=H||$,X=$?"~":"/",[B,V=""]=A?_.slice(1).join().split(X):T.split(X);if(x&&!(B&&V))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});let[G,...I]=(T.includes(".")&&!x?T:`${P}.${V}`).split("."),q=x?V:I.join("."),{address:L,ticker:D}=$F({symbol:q,chain:G}),z;try{z=L&&E.includes(G)&&IT(L)?IT(L):L}catch(p){z=L}let S=(x?`${B}${X}`:"")+(z?`${D}-${z??""}`:q);return{address:z,chain:G,isSynthOrTrade:x,isSynthetic:H,isTradeAsset:$,ticker:D,symbol:S,isGasAsset:WT({chain:G,symbol:q})}}function $F({symbol:T,chain:F}){let _=T.split("-"),P=_.length===1?void 0:_[_.length-1],A=e.includes(F)?P:P?.toLowerCase(),H=_.length===1?_[0]:_.slice(0,-1).join("-");return{address:A,ticker:H}}class w extends g{eq(T){return this.eqValue(T)}static fromBigInt(T,F){return new w({decimal:F,value:u({value:T,bigIntDecimal:F,decimal:F})})}}var NF={average:1,fast:1.5,fastest:2};function wT(T="average"){let F=K.get("feeMultipliers");if(F&&F[T]!==void 0)return F[T];return NF[T]}function BF(T="average"){let F=wT(T),_=10n;return{numerator:BigInt(Math.round(F*10)),denominator:_}}function r_(T,F="average"){let{numerator:_,denominator:P}=BF(F);return T*_/P}function i_(T,F="average",_=!1){let P=wT(F),A=T*P;return _?Math.floor(A):A}function GF({liquidityUnits:T,poolUnits:F,runeDepth:_}){let P=O(T),A=O(F),H=O(_),$=P.mul(H),x=A.mul(A).mul(2),X=A.mul(P).mul(2),B=P.mul(P),V=A.mul(A).mul(A);return $.mul(x.sub(X).add(B)).div(V)}function XF({liquidityUnits:T,poolUnits:F,assetDepth:_}){let P=O(T),A=O(F),H=O(_),$=P.mul(H),x=A.mul(A).mul(2),X=A.mul(P).mul(2),B=P.mul(P),V=$.mul(x.sub(X).add(B)),G=A.mul(A).mul(A);return V.div(G)}function FP({percent:T,runeDepth:F,liquidityUnits:_,poolUnits:P}){return GF({runeDepth:F,liquidityUnits:_,poolUnits:P}).mul(T)}function _P({percent:T,assetDepth:F,liquidityUnits:_,poolUnits:P}){return XF({assetDepth:F,liquidityUnits:_,poolUnits:P}).mul(T)}function O(T){return w.fromBigInt(BigInt(T),Y.THOR)}function QF({liquidityUnits:T,poolUnits:F,runeDepth:_,assetDepth:P}){return{assetAmount:O(P).mul(T).div(F),runeAmount:O(_).mul(T).div(F)}}function PP({liquidityUnits:T,poolUnits:F,runeDepth:_,assetDepth:P,percent:A}){return Object.fromEntries(Object.entries(QF({liquidityUnits:T,poolUnits:F,runeDepth:_,assetDepth:P})).map(([H,$])=>[H,$.mul(A)]))}function AP({runeDepth:T,poolUnits:F,assetDepth:_,liquidityUnits:P,runeAmount:A,assetAmount:H}){let $=new w({value:T,decimal:8}),x=new w({value:_,decimal:8}),X=new w({value:F,decimal:8}),B=new w({value:A,decimal:8}),V=new w({value:H,decimal:8}),G=B.mul(x),I=V.mul($),q=B.mul(V),L=$.mul(x),D=X.mul(G.add(I.add(q.mul(2)))),z=G.add(I.add(L.mul(2))),S=D.div(z),p=O(P).add(S);if(S.getBaseValue("number")===0)return p.div(X).getBaseValue("number");let ST=X.add(p);return p.div(ST).getBaseValue("number")}function RP({runeAmount:T,assetAmount:F,runeDepth:_,assetDepth:P}){if(T==="0"||F==="0"||_==="0"||P==="0")return 0;let A=O(_),H=O(P),$=O(F),x=O(T),X=$.mul(A).sub(H.mul(x)),B=H.mul(x).add(A.mul(H));return Math.abs(X.div(B).getBaseValue("number"))}import{match as zF}from"ts-pattern";function BP({type:T,address:F}){return`${T}:${F}`}function GP({address:T,unbondAmount:F}){return`${"UNBOND"}:${T}:${F}`}function XP(T){return FT("POOL+",T)}function QP({chain:T,symbol:F,address:_,...P}){let A=ZF({chain:T,symbol:F}),H=_?`:${_}:`:":";return FT(`${"+"}:${A}${H}`,P)}function zP({chain:T,symbol:F,ticker:_,basisPoints:P,targetAsset:A}){let H=T==="ETH"&&_!=="ETH"?`${_}-${F.slice(-3)}`:F,$=A?`:${A}`:"";return`${"-"}:${T}.${H}:${P}${$}`}function ZP({basisPoints:T,...F}){return FT(`${"POOL-"}:${T}`,F)}function JP({name:T,chain:F,address:_,owner:P}){let A=`${"~"}:${T}:${F}:${_}`,H=P?`:${P}`:"";return`${A}${H}`}function MP({name:T,chain:F,asset:_,payout:P,owner:A}){return`${"~"}:${T}:${F}:${P}:${A}:${_}`}function YP(T,{address:F}){return`${T}:${F}`}function LP(T,{unstakeBps:F,..._}){let P=F?`:${F}`:"",A=`${T}${P}`;return FT(`${A}`,_)}function FT(T,{affiliateAddress:F,affiliateBasisPoints:_}={}){let P=`${T}${F?`:${F}:${_||0}`:""}`;return P.endsWith(":")?P.slice(0,-1):P}function ZF({chain:T,symbol:F}){return zF(T).with("BTC","DOGE","LTC",()=>T.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${T}.${F}`)}function WP({name:T,properties:F,methods:_}){function P(A){return{..._(A),...F}}return{[T]:P}}function kP(){return typeof window.ethereum!=="undefined"}function IP(T){return JF().includes(T)}function JF(){let T=window?.ethereum&&!window.ethereum?.isBraveWallet,F=window?.xfi||window?.ethereum?.__XDEFI,_=window?.ethereum?.isBraveWallet,P=window?.ethereum?.isTrust||window?.trustwallet,A=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=window?.bitkeep?.ethereum,$=window?.$onekey?.ethereum,x=[];if(T)x.push("METAMASK");if(F)x.push("CTRL");if(_)x.push("BRAVE");if(P)x.push("TRUSTWALLET_WEB");if(A)x.push("COINBASE_WEB");if(jF())x.push("OKX_MOBILE");if(H)x.push("BITGET");if($)x.push("ONEKEY");return x}async function MF(T,F,_){try{await DT({provider:T,method:"wallet_switchEthereumChain",params:[{chainId:ZT[F]}]})}catch(P){if(!_)throw new J("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await LF(T,_)}}function KP({chains:T,supportedChains:F,walletType:_}){let P=T.filter((H)=>F.includes(H));if(P.length===0)throw new J("wallet_chain_not_supported",{wallet:_,chain:T.join(", ")});let A=T.filter((H)=>!F.includes(H));return i(A.length>0,`${_} wallet does not support the following chains: ${A.join(", ")}. These chains will be ignored.`),P}function YF(T,F,_){return async(...P)=>{try{await MF(F,_)}catch(A){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:A}})}return T(...P)}}function wP({toolbox:T,chain:F,provider:_=window.ethereum,methodNames:P=[]}){let H=[...P,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce(($,x)=>{if(!T[x])return $;let X=T[x];if(typeof X!=="function")return $;let B=YF(X,_,F);return{...$,[x]:B}},{});return{...T,...H}}function LF(T,F){return DT({provider:T,method:"wallet_addEthereumChain",params:[F]})}function DP(T){window.ethereum?.on("accountsChanged",()=>T()),window.xfi?.ethereum.on("accountsChanged",()=>T())}function SP(){let{isTrust:T,isBraveWallet:F,__XDEFI:_,overrideIsMetaMask:P,selectedProvider:A}=window?.ethereum||{};if(T)return"TRUSTWALLET_WEB";if(F)return"BRAVE";if(P&&A?.isCoinbaseWallet)return"COINBASE_WEB";if(_)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function fP(){let T=[];function F(P){if(T.map((A)=>A.info.uuid).includes(P.detail.info.uuid))return;T.push(P.detail)}window.addEventListener("eip6963:announceProvider",F),window.dispatchEvent(new Event("eip6963:requestProvider"));function _(){window.removeEventListener("eip6963:announceProvider",F)}return{providers:T,removeEIP6963EventListener:_}}function jF(){let T=navigator.userAgent,F=/iphone|ipad|ipod|ios/i.test(T),_=/android|XiaoMi|MiuiBrowser/i.test(T),P=F||_,A=/OKApp/i.test(T);return P&&A}function gP({connect:T,name:F,supportedChains:_,walletType:P}){function A(H){return T({...H,walletType:P,supportedChains:_})}return{[F]:{supportedChains:_,connectWallet:A}}}function DT({provider:T,params:F,method:_}){if(!T?.send)throw new J("helpers_not_found_provider");let P=F?Array.isArray(F)?F:[F]:[];return T.send(_,P)}export{q_ as wrapWithThrow,YF as wrapMethodWithNetworkSwitch,i as warnOnce,S_ as validateTNS,OT as validateIdentifier,AT as updateDerivationPath,MF as switchEVMWalletNetwork,DT as providerRequest,wP as prepareNetworkSwitch,jF as okxMobileEnabled,qT as loadTokenLists,JF as listWeb3EVMWallets,kP as isWeb3Detected,WT as isGasAsset,IP as isDetected,SF as initializeRPCUrlsWithFallback,dF as getWalletFormatFor,W_ as getTHORNameCost,PP as getSymmetricWithdraw,QF as getSymmetricPoolShare,h_ as getMinAmountByChain,zP as getMemoForWithdraw,GP as getMemoForUnbond,LP as getMemoForTcyStake,YP as getMemoForTcyClaim,ZP as getMemoForRunePoolWithdraw,XP as getMemoForRunePoolDeposit,JP as getMemoForNameRegister,MP as getMemoForNamePreferredAssetRegister,BP as getMemoForLeaveAndBond,QP as getMemoForDeposit,V_ as getMAYANameCost,RP as getLiquiditySlippage,z_ as getGasAsset,BF as getFeeMultiplierAsBigInt,wT as getFeeMultiplier,AP as getEstimatedPoolShare,SP as getETHDefaultWallet,fP as getEIP6963Wallets,O_ as getDynamicChainId,mF as getDerivationPathFor,jT as getDecimal,r as getCommonAssetInfo,U_ as getChainIdentifier,FP as getAsymmetricRuneWithdrawAmount,GF as getAsymmetricRuneShare,_P as getAsymmetricAssetWithdrawAmount,XF as getAsymmetricAssetShare,RT as getAssetType,u as formatBigIntToSafeValue,Z_ as findAssetBy,KP as filterSupportedChains,JT as derivationPathToString,gP as createWallet,WP as createPlugin,HT as assetFromString,r_ as applyFeeMultiplierToBigInt,i_ as applyFeeMultiplier,LF as addEVMWalletNetwork,DP as addAccountsChangedCallback,oT as WarningCodeEnum,s as WalletOption,XT as UTXOChains,wF as TCSupportedChains,w as SwapKitNumber,J as SwapKitError,kF as SubstrateChains,_T as StagenetChain,uF as SWAP_OUT,vF as SWAP_IN,K as SKConfig,y as RequestClient,l as RPC_URLS,pT as QuoteMode,hT as ProviderName,v as NetworkDerivationPath,o as NODE_URLS,YT as MemoType,DF as MAYASupportedChains,nT as LedgerErrorCode,cT as FeeTypeEnum,MT as FeeOption,ET as FALLBACK_URLS,dT as ErrorCode,PT as EXPLORER_URLS,E as EVMChains,cF as DerivationPath,NF as DEFAULT_FEE_MULTIPLIERS,IF as CosmosChains,KF as CosmosChainPrefixes,mT as ContractAddress,Q_ as CommonAssetStrings,ZT as ChainToHexChainId,fF as ChainToExplorerUrl,zT as ChainToChainId,UF as ChainIdToChain,h as ChainId,U as Chain,OF as BlockTimes,g as BigIntArithmetics,Y as BaseDecimal,f as AssetValue,lT as ApproveMode,yF as AGG_SWAP};
4
+ or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:W,identifier:L,tax:w}=Q||{decimal:k||Y[G],identifier:x},z=X||Z,D=_?e(BigInt(A),_):e(A,W);return F?P_(L,_?D:A):z?A_(L,D):new S({tax:w,decimal:W,identifier:L,value:D})}static async loadStaticAssets(T){let _=await WT(T);for(let{tokens:F}of Object.values(_))for(let{identifier:P,chain:A,...H}of F){let x=a.includes(A)?P:P.toUpperCase(),$="decimals"in H?H.decimals:Y[A];u.set(x,{identifier:P,decimal:$})}return!0}static setStaticAssets(T){u.clear();for(let[_,F]of T.entries()){let P=a.includes(F.chain)?F.identifier:F.identifier.toUpperCase(),A="decimals"in F?F.decimals:F.decimal;u.set(_,{...F,decimal:A,identifier:P})}return!0}}function oF(T){let _=S.from({chain:T});return KT(T).with("BTC","LTC","BCH","DASH",()=>_.set(0.00010001)).with("DOGE",()=>_.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>_.set(0.00000001)).with("THOR","MAYA",()=>_.set(0)).with("GAIA","KUJI",()=>_.set(0.000001)).otherwise(()=>_.set(0.00000001))}async function P_(T,_=0){UT(T);let P=T.includes("SOL.")?T:T.toUpperCase(),A=u.get(P),H=A?.decimal||await LT(xT(T));if(!A)u.set(P,{identifier:T,decimal:H});return new S({decimal:H,value:e(_,H),identifier:T})}function A_(T,_=0){let F=T.includes(".")?T.split(".")?.[0]?.toUpperCase():void 0,P=F?["MAYA","THOR"].includes(F):!1,A=T.slice(0,14).includes("~")?"~":"/",[H,x]=P?T.split(".").slice(1).join().split(A):T.split(A);if(!(H&&x))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});return new S({decimal:8,value:e(_,8),identifier:`${F||"THOR"}.${H}${A}${x}`})}function e(T,_){return typeof T==="bigint"?y({value:T,bigIntDecimal:_,decimal:_}):T}function R_(T){let _=KT(T).when((F)=>("chain"in F)&&F.chain!==void 0,({chain:F})=>F).otherwise((F)=>{let P=RT(F.asset);return P.synth?"THOR":P.chain});if(!Object.values(q).includes(_.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function H_(T){if(R_(T),"chain"in T)return T.chain;let{chain:_,symbol:F}=RT(T.asset);return AT({chain:_,symbol:F})==="Native"?_:T.asset}function xT(T){let _=T.slice(0,14),F=T.split("."),P=F[0]?.toUpperCase(),A=["THOR","MAYA"].includes(P),H=_.includes("/"),x=_.includes("~"),$=H||x,G=x?"~":"/",[X,Z=""]=A?F.slice(1).join().split(G):T.split(G);if($&&!(X&&Z))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});let[Q,...k]=(T.includes(".")&&!$?T:`${P}.${Z}`).split("."),W=$?Z:k.join("."),{address:L,ticker:w}=x_({symbol:W,chain:Q}),z;try{z=L&&g.includes(Q)&&kT(L)?kT(L):L}catch(p){z=L}let D=($?`${X}${G}`:"")+(z?`${w}-${z??""}`:W);return{address:z,chain:Q,isSynthOrTrade:$,isSynthetic:H,isTradeAsset:x,ticker:w,symbol:D,isGasAsset:jT({chain:Q,symbol:W})}}function x_({symbol:T,chain:_}){let F=T.split("-"),P=F.length===1?void 0:F[F.length-1],A=a.includes(_)?P:P?.toLowerCase(),H=F.length===1?F[0]:F.slice(0,-1).join("-");return{address:A,ticker:H}}class I extends f{eq(T){return this.eqValue(T)}static fromBigInt(T,_){return new I({decimal:_,value:y({value:T,bigIntDecimal:_,decimal:_})})}}var $_={average:1,fast:1.5,fastest:2};function IT(T="average"){let _=K.get("feeMultipliers");if(_&&_[T]!==void 0)return _[T];return $_[T]}function N_(T="average"){let _=IT(T),F=10n;return{numerator:BigInt(Math.round(_*10)),denominator:F}}function tF(T,_="average"){let{numerator:F,denominator:P}=N_(_);return T*F/P}function rF(T,_="average",F=!1){let P=IT(_),A=T*P;return F?Math.floor(A):A}function B_({liquidityUnits:T,poolUnits:_,runeDepth:F}){let P=U(T),A=U(_),H=U(F),x=P.mul(H),$=A.mul(A).mul(2),G=A.mul(P).mul(2),X=P.mul(P),Z=A.mul(A).mul(A);return x.mul($.sub(G).add(X)).div(Z)}function G_({liquidityUnits:T,poolUnits:_,assetDepth:F}){let P=U(T),A=U(_),H=U(F),x=P.mul(H),$=A.mul(A).mul(2),G=A.mul(P).mul(2),X=P.mul(P),Z=x.mul($.sub(G).add(X)),Q=A.mul(A).mul(A);return Z.div(Q)}function TP({percent:T,runeDepth:_,liquidityUnits:F,poolUnits:P}){return B_({runeDepth:_,liquidityUnits:F,poolUnits:P}).mul(T)}function _P({percent:T,assetDepth:_,liquidityUnits:F,poolUnits:P}){return G_({assetDepth:_,liquidityUnits:F,poolUnits:P}).mul(T)}function U(T){return I.fromBigInt(BigInt(T),Y.THOR)}function X_({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P}){return{assetAmount:U(P).mul(T).div(_),runeAmount:U(F).mul(T).div(_)}}function FP({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P,percent:A}){return Object.fromEntries(Object.entries(X_({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P})).map(([H,x])=>[H,x.mul(A)]))}function PP({runeDepth:T,poolUnits:_,assetDepth:F,liquidityUnits:P,runeAmount:A,assetAmount:H}){let x=new I({value:T,decimal:8}),$=new I({value:F,decimal:8}),G=new I({value:_,decimal:8}),X=new I({value:A,decimal:8}),Z=new I({value:H,decimal:8}),Q=X.mul($),k=Z.mul(x),W=X.mul(Z),L=x.mul($),w=G.mul(Q.add(k.add(W.mul(2)))),z=Q.add(k.add(L.mul(2))),D=w.div(z),p=U(P).add(D);if(D.getBaseValue("number")===0)return p.div(G).getBaseValue("number");let DT=G.add(p);return p.div(DT).getBaseValue("number")}function AP({runeAmount:T,assetAmount:_,runeDepth:F,assetDepth:P}){if(T==="0"||_==="0"||F==="0"||P==="0")return 0;let A=U(F),H=U(P),x=U(_),$=U(T),G=x.mul(A).sub(H.mul($)),X=H.mul($).add(A.mul(H));return Math.abs(G.div(X).getBaseValue("number"))}import{match as Q_}from"ts-pattern";function NP({type:T,address:_}){return`${T}:${_}`}function BP({address:T,unbondAmount:_}){return`${"UNBOND"}:${T}:${_}`}function GP(T){return TT("POOL+",T)}function XP({chain:T,symbol:_,address:F,...P}){let A=z_({chain:T,symbol:_}),H=F?`:${F}:`:":";return TT(`${"+"}:${A}${H}`,P)}function QP({chain:T,symbol:_,ticker:F,basisPoints:P,targetAsset:A}){let H=T==="ETH"&&F!=="ETH"?`${F}-${_.slice(-3)}`:_,x=A?`:${A}`:"";return`${"-"}:${T}.${H}:${P}${x}`}function zP({basisPoints:T,..._}){return TT(`${"POOL-"}:${T}`,_)}function ZP({name:T,chain:_,address:F,owner:P}){let A=`${"~"}:${T}:${_}:${F}`,H=P?`:${P}`:"";return`${A}${H}`}function JP({name:T,chain:_,asset:F,payout:P,owner:A}){return`${"~"}:${T}:${_}:${P}:${A}:${F}`}function MP(T,{address:_}){return`${T}:${_}`}function YP(T,{unstakeBps:_,...F}){let P=_?`:${_}`:"",A=`${T}${P}`;return TT(`${A}`,F)}function TT(T,{affiliateAddress:_,affiliateBasisPoints:F}={}){let P=`${T}${_?`:${_}:${F||0}`:""}`;return P.endsWith(":")?P.slice(0,-1):P}function z_({chain:T,symbol:_}){return Q_(T).with("BTC","DOGE","LTC",()=>T.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${T}.${_}`)}function jP({name:T,properties:_,methods:F}){function P(A){return{...F(A),..._}}return{[T]:P}}function OP(){return typeof window.ethereum!=="undefined"}function kP(T){return Z_().includes(T)}function Z_(){let T=window?.ethereum&&!window.ethereum?.isBraveWallet,_=window?.xfi||window?.ethereum?.__XDEFI,F=window?.vultisig,P=window?.ethereum?.isBraveWallet,A=window?.ethereum?.isTrust||window?.trustwallet,H=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,x=window?.bitkeep?.ethereum,$=window?.$onekey?.ethereum,G=[];if(T)G.push("METAMASK");if(_)G.push("CTRL");if(F)G.push("VULTISIG");if(P)G.push("BRAVE");if(A)G.push("TRUSTWALLET_WEB");if(H)G.push("COINBASE_WEB");if(L_())G.push("OKX_MOBILE");if(x)G.push("BITGET");if($)G.push("ONEKEY");return G}async function J_(T,_,F){try{await wT({provider:T,method:"wallet_switchEthereumChain",params:[{chainId:zT[_]}]})}catch(P){if(!F)throw new J("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await Y_(T,F)}}function KP({chains:T,supportedChains:_,walletType:F}){let P=T.filter((H)=>!H||_.includes(H));if(P.length===0)throw new J("wallet_chain_not_supported",{wallet:F,chain:T.join(", ")});let A=T.filter((H)=>!_.includes(H));return r(A.length>0,`${F} wallet does not support the following chains: ${A.join(", ")}. These chains will be ignored.`),P}function M_(T,_,F){return async(...P)=>{try{await J_(_,F)}catch(A){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:A}})}return T(...P)}}function IP({toolbox:T,chain:_,provider:F=window.ethereum,methodNames:P=[]}){let H=[...P,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,$)=>{if(!T[$])return x;let G=T[$];if(typeof G!=="function")return x;let X=M_(G,F,_);return{...x,[$]:X}},{});return{...T,...H}}function Y_(T,_){return wT({provider:T,method:"wallet_addEthereumChain",params:[_]})}function wP(T){window.ethereum?.on("accountsChanged",()=>T()),window.xfi?.ethereum.on("accountsChanged",()=>T())}function DP(){let{isTrust:T,isBraveWallet:_,__XDEFI:F,overrideIsMetaMask:P,selectedProvider:A}=window?.ethereum||{};if(T)return"TRUSTWALLET_WEB";if(_)return"BRAVE";if(P&&A?.isCoinbaseWallet)return"COINBASE_WEB";if(F)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function SP(){let T=[];function _(P){if(T.map((A)=>A.info.uuid).includes(P.detail.info.uuid))return;T.push(P.detail)}window.addEventListener("eip6963:announceProvider",_),window.dispatchEvent(new Event("eip6963:requestProvider"));function F(){window.removeEventListener("eip6963:announceProvider",_)}return{providers:T,removeEIP6963EventListener:F}}function L_(){let T=navigator.userAgent,_=/iphone|ipad|ipod|ios/i.test(T),F=/android|XiaoMi|MiuiBrowser/i.test(T),P=_||F,A=/OKApp/i.test(T);return P&&A}function fP({connect:T,name:_,supportedChains:F,walletType:P}){function A(H){return T({...H,walletType:P,supportedChains:F})}return{[_]:{supportedChains:F,connectWallet:A}}}function wT({provider:T,params:_,method:F}){if(!T?.send)throw new J("helpers_not_found_provider");let P=_?Array.isArray(_)?_:[_]:[];return T.send(F,P)}export{WF as wrapWithThrow,M_ as wrapMethodWithNetworkSwitch,r as warnOnce,DF as validateTNS,UT as validateIdentifier,PT as updateDerivationPath,J_ as switchEVMWalletNetwork,wT as providerRequest,IP as prepareNetworkSwitch,L_ as okxMobileEnabled,WT as loadTokenLists,Z_ as listWeb3EVMWallets,OP as isWeb3Detected,jT as isGasAsset,kP as isDetected,D_ as initializeRPCUrlsWithFallback,m_ as getWalletFormatFor,jF as getTHORNameCost,FP as getSymmetricWithdraw,X_ as getSymmetricPoolShare,oF as getMinAmountByChain,QP as getMemoForWithdraw,BP as getMemoForUnbond,YP as getMemoForTcyStake,MP as getMemoForTcyClaim,zP as getMemoForRunePoolWithdraw,GP as getMemoForRunePoolDeposit,ZP as getMemoForNameRegister,JP as getMemoForNamePreferredAssetRegister,NP as getMemoForLeaveAndBond,XP as getMemoForDeposit,VF as getMAYANameCost,AP as getLiquiditySlippage,QF as getGasAsset,N_ as getFeeMultiplierAsBigInt,IT as getFeeMultiplier,PP as getEstimatedPoolShare,DP as getETHDefaultWallet,SP as getEIP6963Wallets,UF as getDynamicChainId,C_ as getDerivationPathFor,LT as getDecimal,t as getCommonAssetInfo,qF as getChainIdentifier,TP as getAsymmetricRuneWithdrawAmount,B_ as getAsymmetricRuneShare,_P as getAsymmetricAssetWithdrawAmount,G_ as getAsymmetricAssetShare,AT as getAssetType,y as formatBigIntToSafeValue,zF as findAssetBy,KP as filterSupportedChains,ZT as derivationPathToString,fP as createWallet,jP as createPlugin,RT as assetFromString,tF as applyFeeMultiplierToBigInt,rF as applyFeeMultiplier,Y_ as addEVMWalletNetwork,wP as addAccountsChangedCallback,dT as WarningCodeEnum,n as WalletOption,GT as UTXOChains,I_ as TCSupportedChains,I as SwapKitNumber,J as SwapKitError,O_ as SubstrateChains,_T as StagenetChain,y_ as SWAP_OUT,v_ as SWAP_IN,K as SKConfig,b as RequestClient,c as RPC_URLS,pT as QuoteMode,oT as ProviderName,v as NetworkDerivationPath,d as NODE_URLS,MT as MemoType,w_ as MAYASupportedChains,lT as LedgerErrorCode,hT as FeeTypeEnum,JT as FeeOption,gT as FALLBACK_URLS,mT as ErrorCode,FT as EXPLORER_URLS,g as EVMChains,h_ as DerivationPath,$_ as DEFAULT_FEE_MULTIPLIERS,k_ as CosmosChains,K_ as CosmosChainPrefixes,CT as ContractAddress,XF as CommonAssetStrings,zT as ChainToHexChainId,S_ as ChainToExplorerUrl,QT as ChainToChainId,q_ as ChainIdToChain,o as ChainId,q as Chain,U_ as BlockTimes,f as BigIntArithmetics,Y as BaseDecimal,S as AssetValue,cT as ApproveMode,b_ as AGG_SWAP};
5
5
 
6
- //# debugId=BECF59B86DF1CF2A64756E2164756E21
6
+ //# debugId=105F4C6260C3950164756E2164756E21
7
7
  //# sourceMappingURL=index.js.map