@swapkit/helpers 4.0.0-beta.38 → 4.0.0-beta.40
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{a as MT,c as LT}from"./chunk-hm14bfyg.js";export*from"@swapkit/tokens";import{getAddress as IT}from"ethers";import{match as KT}from"ts-pattern";import{match as BT}from"ts-pattern";var gT={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 M extends Error{static ErrorCode=gT;constructor(T,_){let F=typeof T==="string",P=F?T:T.errorKey,A=F?void 0:T.info,$=`${P}${A?`: ${JSON.stringify(A)}`:""}`;super($);if(Object.setPrototypeOf(this,M.prototype),this.name="SwapKitError",this.cause=_,_)console.error(`SwapKitError [${P}]:`,_);else if(A)console.error(`SwapKitError [${P}]:`,A)}}var U;((z)=>{z.Arbitrum="ARB";z.Aurora="AURORA";z.Avalanche="AVAX";z.Base="BASE";z.Berachain="BERA";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.Gnosis="GNO";z.Kujira="KUJI";z.Litecoin="LTC";z.Maya="MAYA";z.Near="NEAR";z.Optimism="OP";z.Polkadot="DOT";z.Chainflip="FLIP";z.Polygon="POL";z.Radix="XRD";z.Ripple="XRP";z.THORChain="THOR";z.Solana="SOL";z.Tron="TRX";z.Zcash="ZEC"})(U||={});var _T;((F)=>{F.THORChain="THOR_STAGENET";F.Maya="MAYA_STAGENET"})(_T||={});var d;((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"})(d||={});var U_={["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"},vT=Object.keys(U),h=Object.values(U),j={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},V_={["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},k_=["DOT","FLIP"],E=["ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL"],GT=["BTC","BCH","DASH","DOGE","LTC","ZEC"],O_=["GAIA","THOR","MAYA","KUJI"],I_={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},K_=["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"},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"},bT={["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",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"]:[]},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"},xT=c,yT=(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 M("helpers_chain_not_supported",{chain:T})})};function uT(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}${uT(T)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(yT(T)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},CT=async(T)=>{let _=c[T];if(await NT(T,_))return _;for(let F of bT[T])if(await NT(T,F))return F;return _},D_=async(T=[...Object.values(U),...Object.values(_T)])=>{let _={};await Promise.all(T.map(async(F)=>{let P=await CT(F);_[F]=P})),xT={...xT,..._}},XT=h.reduce((T,_)=>{let F=vT.find((P)=>U[P]===_);if(F)T[_]=F;return T},{}),QT=h.reduce((T,_)=>{return T[_]=d[XT[_]],T},{}),zT=h.reduce((T,_)=>{let F=`${XT[_]}Hex`;return T[_]=d[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:$,body:H,headers:x,dynamicHeader:N}={..._,...P},G=!!$||F.endsWith(".json"),J=G?JSON.stringify($):H;try{let X=mT(F,A),O=pT(G,{...x,...N?.()}),q=await fetch(X,{...P,method:T,body:J,headers:O});if(!q.ok){let w=await q.text();throw new M("helpers_invalid_response",{status:q.status,statusText:q.statusText,message:w})}let W=await q.json();return P.onSuccess?.(W)||P.responseHandler?.(W)||W}catch(X){if(P.onError)return P.onError(X);throw X}}}function pT(T,_){return{..._,...T?{"Content-Type":"application/json"}:{}}}function mT(T,_){let F=new URL(T);if(_)F.search=new URLSearchParams(_).toString();return F.toString()}import{createStore as rT}from"zustand/vanilla";var oT;((Y)=>{Y.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";Y.TC_SUPPORTED_TO_ETH="TC-ERC20";Y.TC_SUPPORTED_TO_AVAX="TC-ARC20";Y.TC_SUPPORTED_TO_BSC="TC-BEP20";Y.ETH_TO_TC_SUPPORTED="ERC20-TC";Y.ETH_TO_ETH="ERC20-ERC20";Y.ETH_TO_AVAX="ERC20-ARC20";Y.ETH_TO_BSC="ERC20-BEP20";Y.AVAX_TO_TC_SUPPORTED="ARC20-TC";Y.AVAX_TO_ETH="ARC20-ERC20";Y.AVAX_TO_AVAX="ARC20-ARC20";Y.AVAX_TO_BSC="ARC20-BEP20";Y.BSC_TO_TC_SUPPORTED="BEP20-TC";Y.BSC_TO_ETH="BEP20-ERC20";Y.BSC_TO_AVAX="BEP20-ARC20";Y.BSC_TO_BSC="BEP20-BEP20"})(oT||={});var v_=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],b_=["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,,$]=T;return[F,P,A,_.change,$]}if("account"in _){let[F,P,,A,$]=T;return[F,P,_.account,A,$]}return T}function ZT([T,_,F,P,A]){let $=typeof A!=="number";if(typeof P!=="number")return`m/${T}'/${_}'/${F}'`;return`m/${T}'/${_}'/${F}'/${P}${$?"":`/${A}`}`}function p_({chain:T,index:_,addressIndex:F=0,type:P}){if(E.includes(T)){if(P&&["legacy","account"].includes(P))return[44,60,0,_];if(P==="ledgerLive")return[44,60,_,0,F];return PT(y[T],{index:_})}if(T==="SOL"){if(P==="account")return[44,501,0,_];return PT(y[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(y[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 dT;((J)=>{J.ARB="0x0000000000000000000000000000000000000000";J.AURORA="0x0000000000000000000000000000000000000000";J.AVAX="0x0000000000000000000000000000000000000000";J.BASE="0x0000000000000000000000000000000000000000";J.BERA="0x0000000000000000000000000000000000000000";J.ETH="0x0000000000000000000000000000000000000000";J.BSC="0x0000000000000000000000000000000000000000";J.GNO="0x0000000000000000000000000000000000000000";J.MATIC="0x0000000000000000000000000000000000001010";J.OP="0x4200000000000000000000000000000000000042"})(dT||={});var y={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(y).reduce((T,_)=>{return T[_]=ZT(y[_]),T},{});var hT;((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"})(hT||={});var cT;((F)=>{F.highSlippage="highSlippage";F.highPriceImpact="highPriceImpact"})(cT||={});var lT;((L)=>{L.CAVIAR_V1="CAVIAR_V1";L.CAMELOT_V3="CAMELOT_V3";L.CHAINFLIP="CHAINFLIP";L.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";L.JUPITER="JUPITER";L.MAYACHAIN="MAYACHAIN";L.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";L.OCISWAP_V1="OCISWAP_V1";L.ONEINCH="ONEINCH";L.OPENOCEAN_V2="OPENOCEAN_V2";L.PANCAKESWAP="PANCAKESWAP";L.PANGOLIN_V1="PANGOLIN_V1";L.SUSHISWAP_V2="SUSHISWAP_V2";L.THORCHAIN="THORCHAIN";L.THORCHAIN_STREAMING="THORCHAIN_STREAMING";L.TRADERJOE_V2="TRADERJOE_V2";L.UNISWAP_V2="UNISWAP_V2";L.UNISWAP_V3="UNISWAP_V3";L.KADO="KADO";L.NEAR="NEAR"})(lT||={});var nT;((x)=>{x.LIQUIDITY="liquidity";x.NETWORK="network";x.INBOUND="inbound";x.OUTBOUND="outbound";x.AFFILIATE="affiliate";x.TAX="tax";x.PRIORITY="priority"})(nT||={});var YT;((P)=>{P.Average="average";P.Fast="fast";P.Fastest="fastest"})(YT||={});var sT;((F)=>{F.Approve="approve";F.CheckOnly="checkOnly"})(sT||={});var JT;((X)=>{X.NAME_REGISTER="~";X.BOND="BOND";X.DEPOSIT="+";X.LEAVE="LEAVE";X.UNBOND="UNBOND";X.WITHDRAW="-";X.RUNEPOOL_DEPOSIT="POOL+";X.RUNEPOOL_WITHDRAW="POOL-";X.CLAIM_TCY="tcy";X.STAKE_TCY="tcy+";X.UNSTAKE_TCY="tcy-"})(JT||={});var n;((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.TRONLINK="TRONLINK";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.VULTISIG="VULTISIG";Q.WALLETCONNECT="WALLETCONNECT";Q.XAMAN="XAMAN"})(n||={});var tT;((P)=>{P[P.NoError=36864]="NoError";P[P.LockedDevice=21781]="LockedDevice";P[P.TC_NotFound=65535]="TC_NotFound"})(tT||={});var iT={apis:{},chains:Object.values(U),wallets:Object.values(n),explorerUrls:FT,nodeUrls:o,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},k=rT((T)=>({...iT,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||[])}))})),I={getState:k.getState,get:(T)=>k.getState()[T],set:(T)=>k.getState().setConfig(T),setApiKey:(T,_)=>k.getState().setApiKey(T,_),setEnv:(T,_)=>k.getState().setEnv(T,_),setExplorerUrl:(T,_)=>k.getState().setExplorerUrl(T,_),setNodeUrl:(T,_)=>k.getState().setNodeUrl(T,_),setRpcUrl:(T,_)=>k.getState().setRpcUrl(T,_),setIntegrationConfig:(T,_)=>k.getState().setIntegrationConfig(T,_),setFeeMultipliers:(T)=>k.getState().setFeeMultipliers(T)};var GF=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],jT=["ARB","AURORA","BASE","ETH","OP","POL"];async function aT({chain:T,to:_}){try{let{result:P}=await b.post(I.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||j[T]).toString())}catch(P){return console.error(`Failed to fetch contract decimals for ${_} on ${T}:`,P),j[T]}}async function eT(T){if(T==="XRD")return j.XRD;try{let _=T.split("-")[1]?.toLowerCase(),{manager:F}=await b.post(`${I.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}:`,_),j["XRD"]}}async function T_({chain:T,symbol:_}){if(E.includes(_))return j[_];let F=_.split("-"),P=F.length===1?void 0:F[F.length-1]?.toLowerCase();return await(P?.startsWith("0x")?aT({chain:T,to:P}):j[T])}function WT({chain:T,symbol:_}){return s(T).with(...E,(F)=>T_({chain:F,symbol:_})).with("XRD",()=>eT(_)).otherwise(()=>j[T])}function XF({chain:T}){return S.from({chain:T})}function qT({chain:T,symbol:_}){return s(T).with(...jT,()=>_==="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 _=j[T];return s(T.toUpperCase()).with(...jT,(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:j.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:j.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:j.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("."),$=A?.split("-"),H=$?.length?$.length===1?$[0]:$.slice(0,-1).join("-"):void 0;return{chain:_,symbol:A,ticker:H,synth:P}};async function QF(T){let{loadTokenLists:_}=await import("./tokens.js"),F=await _();for(let P of Object.values(F))for(let{identifier:A,chain:$,...H}of P.tokens){if("identifier"in T&&A===T.identifier)return A;if("address"in H&&"chain"in T&&$===T.chain&&H.address&&H.address.toLowerCase()===T.contract.toLowerCase())return A}return}function LF(T){if(T<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return 10+T}function jF(T){if(T<0)throw new M({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 M(_,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 UT=new Set;function r(T,_){if(T){if(UT.has(_))return;UT.add(_)}}async function UF(T="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(T))return T;try{let _=I.get("rpcUrls")[T!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await b.get(`${_}/status`)).result.node_info.network}catch(_){return T}}var VT=["TERRA",...I.get("chains")];function kT(T=""){let _=T.toUpperCase(),[F]=_.split(".");if(VT.includes(F))return!0;let[P]=_.split("/");if(VT.includes(P))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${T}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:T}})}function IF(T){if(T.length>30)return!1;let _=/^[a-zA-Z0-9+_-]+$/g;return!!T.match(_)}var m=8,g=(T)=>10n**BigInt(T),p=(T)=>Math.log10(Number.parseFloat(T.toString()));function u({value:T,bigIntDecimal:_=m,decimal:F=m}){if(F===0)return T.toString();let P=T<0n,A=T.toString().substring(P?1:0),$=F-(A.length-1);if($>0)A="0".repeat($)+A;let H=A.length-F,x=A.slice(-F);if(Number.parseInt(x[_]||"0")>=5)x=`${x.substring(0,_-1)}${(Number.parseInt(x[_-1]||"0")+1).toString()}`;else x=x.substring(0,_);return`${P?"-":""}${A.slice(0,H)}.${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:u({value:T,bigIntDecimal:_,decimal:_})})}static shiftDecimals({value:T,from:_,to:F}){return f.fromBigInt(T.getBaseValue("bigint")*g(F)/g(_),F)}constructor(T){let _=$T(T),F=typeof T==="object";this.decimal=F?T.decimal:void 0,this.decimalMultiplier=F&&"decimalMultiplier"in T?T.decimalMultiplier:g(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||p(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/g(_||this.decimal||j.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=$T(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 H=Number.parseInt(A),x=`${H}`.slice(0,T);return`0.${x.padStart(A.length-`${H}`.length+x.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 $=Number.parseInt(A),H=`${$}`.slice(0,T);return`0.${H.padStart(A.length-`${$}`.length+H.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 $=10**(P*3);return`${(_/$).toFixed(T)}${A}`}toCurrency(T="$",{currencyPosition:_="start",decimal:F=2,decimalSeparator:P=".",thousandSeparator:A=","}={}){let $=this.getValue("number"),[H="",x=""]=$.toFixed(6).split("."),N=H.replace(/\B(?=(\d{3})+(?!\d))/g,A),G=H||x?H==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",P):`${N}${Number.parseInt(x)?`${P}${x.slice(0,F)}`:""}`:"0.00";return`${_==="start"?T:""}${G}${_==="end"?T:""}`}formatBigIntToSafeValue(T,_){let F=_||this.decimal||m,P=Math.max(F,p(this.decimalMultiplier)),A=T<0n,$=T.toString().substring(A?1:0),H=P-($.length-1),x=H>0?"0".repeat(H)+$:$,N=x.length-P,G=x.slice(-P);if(Number.parseInt(G[F]||"0")>=5)G=`${G.substring(0,F-1)}${(Number.parseInt(G[F-1]||"0")+1).toString()}`;else G=G.substring(0,F);return`${A?"-":""}${x.slice(0,N)}.${G}`.replace(/\.?0*$/,"")}#_(T,..._){let F=this.#F(this,..._),P=Math.max(F,p(this.decimalMultiplier)),A=g(P),$=_.reduce((x,N)=>{let G=this.getBigIntValue(N,P);switch(T){case"add":return x+G;case"sub":return x-G;case"mul":return x*G/A;case"div":{if(G===0n)throw new RangeError("Division by zero");return x*A/G}default:return x}},this.bigIntValue*A/this.decimalMultiplier),H=u({bigIntDecimal:P,decimal:P,value:$});return new this.constructor({decimalMultiplier:g(P),decimal:this.decimal,value:H,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||p(F.decimalMultiplier):OT(i(F))}).filter(Boolean);return Math.max(..._,m)}#P(T,_){let F=_?g(_):this.decimalMultiplier,P=p(F),[A="",$=""]=T.split(".");return BigInt(`${A}${$.padEnd(P,"0")}`)}}var F_=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function i(T){let F=`${typeof T==="number"?F_.format(T):$T(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 $T(T){return typeof T==="object"?"getValue"in T?T.getValue("string"):T.value:T}var a=["SOL","TRX"],v=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:$}){super(typeof T==="object"?T:{decimal:_,value:T});let H=HT($||`${P}.${A}`);this.type=AT(H),this.tax=F,this.chain=H.chain,this.ticker=H.ticker,this.symbol=H.symbol,this.address=H.address,this.isSynthetic=H.isSynthetic,this.isTradeAsset=H.isTradeAsset,this.isGasAsset=H.isGasAsset,this.chainId=QT[H.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()}getIconUrl(){return v.get(this.toString())?.logoURI}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 M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:T}});let $=F==="THOR"&&A?`${F}.${P}/${A}`:T;return S.from({asset:$,value:_})}static from({value:T=0,fromBaseDecimal:_,asyncTokenLookup:F,...P}){let A=T instanceof f?T.getValue("string"):T,$=$_(P),{identifier:H,decimal:x}=t($),{chain:N,isSynthetic:G,isTradeAsset:J}=HT(H),X=v.get(a.includes(N)?H:H.toUpperCase()),O=X?.decimal||x;r(!(F||O),`Couldn't find static decimal for one or more tokens on ${N} (Using default ${j[N]} decimal as fallback).
|
|
1
|
+
import{a as MT,c as LT}from"./chunk-hm14bfyg.js";export*from"@swapkit/tokens";import{getAddress as IT}from"ethers";import{match as KT}from"ts-pattern";import{match as BT}from"ts-pattern";var gT={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_locked:20007,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 M extends Error{static ErrorCode=gT;constructor(T,_){let F=typeof T==="string",P=F?T:T.errorKey,A=F?void 0:T.info,$=`${P}${A?`: ${JSON.stringify(A)}`:""}`;super($);if(Object.setPrototypeOf(this,M.prototype),this.name="SwapKitError",this.cause=_,_)console.error(`SwapKitError [${P}]:`,_);else if(A)console.error(`SwapKitError [${P}]:`,A)}}var U;((z)=>{z.Arbitrum="ARB";z.Aurora="AURORA";z.Avalanche="AVAX";z.Base="BASE";z.Berachain="BERA";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.Gnosis="GNO";z.Kujira="KUJI";z.Litecoin="LTC";z.Maya="MAYA";z.Near="NEAR";z.Optimism="OP";z.Polkadot="DOT";z.Chainflip="FLIP";z.Polygon="POL";z.Radix="XRD";z.Ripple="XRP";z.THORChain="THOR";z.Solana="SOL";z.Tron="TRX";z.Zcash="ZEC"})(U||={});var _T;((F)=>{F.THORChain="THOR_STAGENET";F.Maya="MAYA_STAGENET"})(_T||={});var d;((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"})(d||={});var U_={["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"},vT=Object.keys(U),h=Object.values(U),j={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},V_={["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},k_=["DOT","FLIP"],E=["ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL"],GT=["BTC","BCH","DASH","DOGE","LTC","ZEC"],O_=["GAIA","THOR","MAYA","KUJI"],I_={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},K_=["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"},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"},bT={["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",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"]:[]},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"},xT=c,yT=(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 M("helpers_chain_not_supported",{chain:T})})};function uT(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}${uT(T)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(yT(T)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},CT=async(T)=>{let _=c[T];if(await NT(T,_))return _;for(let F of bT[T])if(await NT(T,F))return F;return _},D_=async(T=[...Object.values(U),...Object.values(_T)])=>{let _={};await Promise.all(T.map(async(F)=>{let P=await CT(F);_[F]=P})),xT={...xT,..._}},XT=h.reduce((T,_)=>{let F=vT.find((P)=>U[P]===_);if(F)T[_]=F;return T},{}),QT=h.reduce((T,_)=>{return T[_]=d[XT[_]],T},{}),zT=h.reduce((T,_)=>{let F=`${XT[_]}Hex`;return T[_]=d[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:$,body:H,headers:x,dynamicHeader:N}={..._,...P},G=!!$||F.endsWith(".json"),J=G?JSON.stringify($):H;try{let X=mT(F,A),O=pT(G,{...x,...N?.()}),q=await fetch(X,{...P,method:T,body:J,headers:O});if(!q.ok){let w=await q.text();throw new M("helpers_invalid_response",{status:q.status,statusText:q.statusText,message:w})}let W=await q.json();return P.onSuccess?.(W)||P.responseHandler?.(W)||W}catch(X){if(P.onError)return P.onError(X);throw X}}}function pT(T,_){return{..._,...T?{"Content-Type":"application/json"}:{}}}function mT(T,_){let F=new URL(T);if(_)F.search=new URLSearchParams(_).toString();return F.toString()}import{createStore as rT}from"zustand/vanilla";var oT;((Y)=>{Y.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";Y.TC_SUPPORTED_TO_ETH="TC-ERC20";Y.TC_SUPPORTED_TO_AVAX="TC-ARC20";Y.TC_SUPPORTED_TO_BSC="TC-BEP20";Y.ETH_TO_TC_SUPPORTED="ERC20-TC";Y.ETH_TO_ETH="ERC20-ERC20";Y.ETH_TO_AVAX="ERC20-ARC20";Y.ETH_TO_BSC="ERC20-BEP20";Y.AVAX_TO_TC_SUPPORTED="ARC20-TC";Y.AVAX_TO_ETH="ARC20-ERC20";Y.AVAX_TO_AVAX="ARC20-ARC20";Y.AVAX_TO_BSC="ARC20-BEP20";Y.BSC_TO_TC_SUPPORTED="BEP20-TC";Y.BSC_TO_ETH="BEP20-ERC20";Y.BSC_TO_AVAX="BEP20-ARC20";Y.BSC_TO_BSC="BEP20-BEP20"})(oT||={});var v_=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],b_=["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,,$]=T;return[F,P,A,_.change,$]}if("account"in _){let[F,P,,A,$]=T;return[F,P,_.account,A,$]}return T}function ZT([T,_,F,P,A]){let $=typeof A!=="number";if(typeof P!=="number")return`m/${T}'/${_}'/${F}'`;return`m/${T}'/${_}'/${F}'/${P}${$?"":`/${A}`}`}function p_({chain:T,index:_,addressIndex:F=0,type:P}){if(E.includes(T)){if(P&&["legacy","account"].includes(P))return[44,60,0,_];if(P==="ledgerLive")return[44,60,_,0,F];return PT(y[T],{index:_})}if(T==="SOL"){if(P==="account")return[44,501,0,_];return PT(y[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(y[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 dT;((J)=>{J.ARB="0x0000000000000000000000000000000000000000";J.AURORA="0x0000000000000000000000000000000000000000";J.AVAX="0x0000000000000000000000000000000000000000";J.BASE="0x0000000000000000000000000000000000000000";J.BERA="0x0000000000000000000000000000000000000000";J.ETH="0x0000000000000000000000000000000000000000";J.BSC="0x0000000000000000000000000000000000000000";J.GNO="0x0000000000000000000000000000000000000000";J.MATIC="0x0000000000000000000000000000000000001010";J.OP="0x4200000000000000000000000000000000000042"})(dT||={});var y={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(y).reduce((T,_)=>{return T[_]=ZT(y[_]),T},{});var hT;((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"})(hT||={});var cT;((F)=>{F.highSlippage="highSlippage";F.highPriceImpact="highPriceImpact"})(cT||={});var lT;((L)=>{L.CAVIAR_V1="CAVIAR_V1";L.CAMELOT_V3="CAMELOT_V3";L.CHAINFLIP="CHAINFLIP";L.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";L.JUPITER="JUPITER";L.MAYACHAIN="MAYACHAIN";L.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";L.OCISWAP_V1="OCISWAP_V1";L.ONEINCH="ONEINCH";L.OPENOCEAN_V2="OPENOCEAN_V2";L.PANCAKESWAP="PANCAKESWAP";L.PANGOLIN_V1="PANGOLIN_V1";L.SUSHISWAP_V2="SUSHISWAP_V2";L.THORCHAIN="THORCHAIN";L.THORCHAIN_STREAMING="THORCHAIN_STREAMING";L.TRADERJOE_V2="TRADERJOE_V2";L.UNISWAP_V2="UNISWAP_V2";L.UNISWAP_V3="UNISWAP_V3";L.KADO="KADO";L.NEAR="NEAR"})(lT||={});var nT;((x)=>{x.LIQUIDITY="liquidity";x.NETWORK="network";x.INBOUND="inbound";x.OUTBOUND="outbound";x.AFFILIATE="affiliate";x.TAX="tax";x.PRIORITY="priority"})(nT||={});var YT;((P)=>{P.Average="average";P.Fast="fast";P.Fastest="fastest"})(YT||={});var sT;((F)=>{F.Approve="approve";F.CheckOnly="checkOnly"})(sT||={});var JT;((X)=>{X.NAME_REGISTER="~";X.BOND="BOND";X.DEPOSIT="+";X.LEAVE="LEAVE";X.UNBOND="UNBOND";X.WITHDRAW="-";X.RUNEPOOL_DEPOSIT="POOL+";X.RUNEPOOL_WITHDRAW="POOL-";X.CLAIM_TCY="tcy";X.STAKE_TCY="tcy+";X.UNSTAKE_TCY="tcy-"})(JT||={});var n;((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.TRONLINK="TRONLINK";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.VULTISIG="VULTISIG";Q.WALLETCONNECT="WALLETCONNECT";Q.XAMAN="XAMAN"})(n||={});var tT;((P)=>{P[P.NoError=36864]="NoError";P[P.LockedDevice=21781]="LockedDevice";P[P.TC_NotFound=65535]="TC_NotFound"})(tT||={});var iT={apis:{},chains:Object.values(U),wallets:Object.values(n),explorerUrls:FT,nodeUrls:o,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},k=rT((T)=>({...iT,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||[])}))})),I={getState:k.getState,get:(T)=>k.getState()[T],set:(T)=>k.getState().setConfig(T),setApiKey:(T,_)=>k.getState().setApiKey(T,_),setEnv:(T,_)=>k.getState().setEnv(T,_),setExplorerUrl:(T,_)=>k.getState().setExplorerUrl(T,_),setNodeUrl:(T,_)=>k.getState().setNodeUrl(T,_),setRpcUrl:(T,_)=>k.getState().setRpcUrl(T,_),setIntegrationConfig:(T,_)=>k.getState().setIntegrationConfig(T,_),setFeeMultipliers:(T)=>k.getState().setFeeMultipliers(T)};var GF=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],jT=["ARB","AURORA","BASE","ETH","OP","POL"];async function aT({chain:T,to:_}){try{let{result:P}=await b.post(I.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||j[T]).toString())}catch(P){return console.error(`Failed to fetch contract decimals for ${_} on ${T}:`,P),j[T]}}async function eT(T){if(T==="XRD")return j.XRD;try{let _=T.split("-")[1]?.toLowerCase(),{manager:F}=await b.post(`${I.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}:`,_),j["XRD"]}}async function T_({chain:T,symbol:_}){if(E.includes(_))return j[_];let F=_.split("-"),P=F.length===1?void 0:F[F.length-1]?.toLowerCase();return await(P?.startsWith("0x")?aT({chain:T,to:P}):j[T])}function WT({chain:T,symbol:_}){return s(T).with(...E,(F)=>T_({chain:F,symbol:_})).with("XRD",()=>eT(_)).otherwise(()=>j[T])}function XF({chain:T}){return S.from({chain:T})}function qT({chain:T,symbol:_}){return s(T).with(...jT,()=>_==="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 _=j[T];return s(T.toUpperCase()).with(...jT,(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:j.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:j.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:j.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("."),$=A?.split("-"),H=$?.length?$.length===1?$[0]:$.slice(0,-1).join("-"):void 0;return{chain:_,symbol:A,ticker:H,synth:P}};async function QF(T){let{loadTokenLists:_}=await import("./tokens.js"),F=await _();for(let P of Object.values(F))for(let{identifier:A,chain:$,...H}of P.tokens){if("identifier"in T&&A===T.identifier)return A;if("address"in H&&"chain"in T&&$===T.chain&&H.address&&H.address.toLowerCase()===T.contract.toLowerCase())return A}return}function LF(T){if(T<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return 10+T}function jF(T){if(T<0)throw new M({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 M(_,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 UT=new Set;function r(T,_){if(T){if(UT.has(_))return;UT.add(_)}}async function UF(T="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(T))return T;try{let _=I.get("rpcUrls")[T!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await b.get(`${_}/status`)).result.node_info.network}catch(_){return T}}var VT=["TERRA",...I.get("chains")];function kT(T=""){let _=T.toUpperCase(),[F]=_.split(".");if(VT.includes(F))return!0;let[P]=_.split("/");if(VT.includes(P))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${T}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:T}})}function IF(T){if(T.length>30)return!1;let _=/^[a-zA-Z0-9+_-]+$/g;return!!T.match(_)}var m=8,g=(T)=>10n**BigInt(T),p=(T)=>Math.log10(Number.parseFloat(T.toString()));function u({value:T,bigIntDecimal:_=m,decimal:F=m}){if(F===0)return T.toString();let P=T<0n,A=T.toString().substring(P?1:0),$=F-(A.length-1);if($>0)A="0".repeat($)+A;let H=A.length-F,x=A.slice(-F);if(Number.parseInt(x[_]||"0")>=5)x=`${x.substring(0,_-1)}${(Number.parseInt(x[_-1]||"0")+1).toString()}`;else x=x.substring(0,_);return`${P?"-":""}${A.slice(0,H)}.${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:u({value:T,bigIntDecimal:_,decimal:_})})}static shiftDecimals({value:T,from:_,to:F}){return f.fromBigInt(T.getBaseValue("bigint")*g(F)/g(_),F)}constructor(T){let _=$T(T),F=typeof T==="object";this.decimal=F?T.decimal:void 0,this.decimalMultiplier=F&&"decimalMultiplier"in T?T.decimalMultiplier:g(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||p(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/g(_||this.decimal||j.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=$T(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 H=Number.parseInt(A),x=`${H}`.slice(0,T);return`0.${x.padStart(A.length-`${H}`.length+x.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 $=Number.parseInt(A),H=`${$}`.slice(0,T);return`0.${H.padStart(A.length-`${$}`.length+H.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 $=10**(P*3);return`${(_/$).toFixed(T)}${A}`}toCurrency(T="$",{currencyPosition:_="start",decimal:F=2,decimalSeparator:P=".",thousandSeparator:A=","}={}){let $=this.getValue("number"),[H="",x=""]=$.toFixed(6).split("."),N=H.replace(/\B(?=(\d{3})+(?!\d))/g,A),G=H||x?H==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",P):`${N}${Number.parseInt(x)?`${P}${x.slice(0,F)}`:""}`:"0.00";return`${_==="start"?T:""}${G}${_==="end"?T:""}`}formatBigIntToSafeValue(T,_){let F=_||this.decimal||m,P=Math.max(F,p(this.decimalMultiplier)),A=T<0n,$=T.toString().substring(A?1:0),H=P-($.length-1),x=H>0?"0".repeat(H)+$:$,N=x.length-P,G=x.slice(-P);if(Number.parseInt(G[F]||"0")>=5)G=`${G.substring(0,F-1)}${(Number.parseInt(G[F-1]||"0")+1).toString()}`;else G=G.substring(0,F);return`${A?"-":""}${x.slice(0,N)}.${G}`.replace(/\.?0*$/,"")}#_(T,..._){let F=this.#F(this,..._),P=Math.max(F,p(this.decimalMultiplier)),A=g(P),$=_.reduce((x,N)=>{let G=this.getBigIntValue(N,P);switch(T){case"add":return x+G;case"sub":return x-G;case"mul":return x*G/A;case"div":{if(G===0n)throw new RangeError("Division by zero");return x*A/G}default:return x}},this.bigIntValue*A/this.decimalMultiplier),H=u({bigIntDecimal:P,decimal:P,value:$});return new this.constructor({decimalMultiplier:g(P),decimal:this.decimal,value:H,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||p(F.decimalMultiplier):OT(i(F))}).filter(Boolean);return Math.max(..._,m)}#P(T,_){let F=_?g(_):this.decimalMultiplier,P=p(F),[A="",$=""]=T.split(".");return BigInt(`${A}${$.padEnd(P,"0")}`)}}var F_=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function i(T){let F=`${typeof T==="number"?F_.format(T):$T(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 $T(T){return typeof T==="object"?"getValue"in T?T.getValue("string"):T.value:T}var a=["SOL","TRX"],v=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:$}){super(typeof T==="object"?T:{decimal:_,value:T});let H=HT($||`${P}.${A}`);this.type=AT(H),this.tax=F,this.chain=H.chain,this.ticker=H.ticker,this.symbol=H.symbol,this.address=H.address,this.isSynthetic=H.isSynthetic,this.isTradeAsset=H.isTradeAsset,this.isGasAsset=H.isGasAsset,this.chainId=QT[H.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()}getIconUrl(){return v.get(this.toString())?.logoURI}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 M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:T}});let $=F==="THOR"&&A?`${F}.${P}/${A}`:T;return S.from({asset:$,value:_})}static from({value:T=0,fromBaseDecimal:_,asyncTokenLookup:F,...P}){let A=T instanceof f?T.getValue("string"):T,$=$_(P),{identifier:H,decimal:x}=t($),{chain:N,isSynthetic:G,isTradeAsset:J}=HT(H),X=v.get(a.includes(N)?H:H.toUpperCase()),O=X?.decimal||x;r(!(F||O),`Couldn't find static decimal for one or more tokens on ${N} (Using default ${j[N]} 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
4
|
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:q,identifier:W,tax:w}=X||{decimal:O||j[N],identifier:H},Y=G||J,D=_?e(BigInt(A),_):e(A,q);return F?P_(W,_?D:A):Y?A_(W,D):new S({tax:w,decimal:q,identifier:W,value:D})}static async loadStaticAssets(T){let{loadTokenLists:_}=await import("@swapkit/tokens"),F=await _(T);for(let{tokens:P}of Object.values(F))for(let{identifier:A,chain:$,...H}of P){let x=a.includes($)?A:A.toUpperCase(),N="decimals"in H?H.decimals:j[$];v.set(x,{identifier:A,decimal:N})}return!0}static setStaticAssets(T){v.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;v.set(_,{...F,decimal:A,identifier:P})}return!0}}function CF(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){kT(T);let P=T.includes("SOL.")?T:T.toUpperCase(),A=v.get(P),$=A?.decimal||await WT(HT(T));if(!A)v.set(P,{identifier:T,decimal:$});return new S({decimal:$,value:e(_,$),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]=P?T.split(".").slice(1).join().split(A):T.split(A);if(!($&&H))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});return new S({decimal:8,value:e(_,8),identifier:`${F||"THOR"}.${$}${A}${H}`})}function e(T,_){return typeof T==="bigint"?u({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(U).includes(_.toUpperCase()))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function $_(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 HT(T){let _=T.slice(0,14),F=T.split("."),P=F[0]?.toUpperCase(),A=["THOR","MAYA"].includes(P),$=_.includes("/"),H=_.includes("~"),x=$||H,N=H?"~":"/",[G,J=""]=A?F.slice(1).join().split(N):T.split(N);if(x&&!(G&&J))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});let[X,...O]=(T.includes(".")&&!x?T:`${P}.${J}`).split("."),q=x?J:O.join("."),{address:W,ticker:w}=H_({symbol:q,chain:X}),Y;try{Y=W&&E.includes(X)&&IT(W)?IT(W):W}catch(C){Y=W}let D=(x?`${G}${N}`:"")+(Y?`${w}-${Y??""}`:q);return{address:Y,chain:X,isSynthOrTrade:x,isSynthetic:$,isTradeAsset:H,ticker:w,symbol:D,isGasAsset:qT({chain:X,symbol:q})}}function H_({symbol:T,chain:_}){let F=T.split("-"),P=F.length===1?void 0:F[F.length-1],A=a.includes(_)?P:P?.toLowerCase(),$=F.length===1?F[0]:F.slice(0,-1).join("-");return{address:A,ticker:$}}class K extends f{eq(T){return this.eqValue(T)}static fromBigInt(T,_){return new K({decimal:_,value:u({value:T,bigIntDecimal:_,decimal:_})})}}var x_={average:1,fast:1.5,fastest:2};function wT(T="average"){let _=I.get("feeMultipliers");if(_&&_[T]!==void 0)return _[T];return x_[T]}function N_(T="average"){let _=wT(T),F=10n;return{numerator:BigInt(Math.round(_*10)),denominator:F}}function cF(T,_="average"){let{numerator:F,denominator:P}=N_(_);return T*F/P}function lF(T,_="average",F=!1){let P=wT(_),A=T*P;return F?Math.floor(A):A}import{Chain as Z,ChainToExplorerUrl as DT}from"@swapkit/helpers";import{match as ST}from"ts-pattern";function rF({chain:T,txHash:_}){let F=DT[T];return ST(T).with(Z.Maya,Z.Kujira,Z.Cosmos,Z.THORChain,Z.Solana,()=>`${F}/tx/${_.startsWith("0x")?_.slice(2):_}`).with(Z.Arbitrum,Z.Aurora,Z.Avalanche,Z.BinanceSmartChain,Z.Base,Z.Berachain,Z.Ethereum,Z.Gnosis,Z.Optimism,Z.Polkadot,Z.Polygon,()=>`${F}/tx/${_.startsWith("0x")?_:`0x${_}`}`).with(Z.Litecoin,Z.Bitcoin,Z.BitcoinCash,Z.Dogecoin,Z.Zcash,Z.Radix,()=>`${F}/transaction/${_.toLowerCase()}`).with(Z.Near,()=>`${F}/txns/${_}`).with(Z.Ripple,()=>`${F}/transactions/${_}`).with(Z.Tron,()=>`${F}/#/transaction/${_}`).otherwise(()=>"")}function iF({chain:T,address:_}){let F=DT[T];return ST(T).with(Z.Solana,Z.Radix,()=>`${F}/account/${_}`).with(Z.Tron,()=>`${F}/#/address/${_}`).otherwise(()=>`${F}/address/${_}`)}function B_({liquidityUnits:T,poolUnits:_,runeDepth:F}){let P=V(T),A=V(_),$=V(F),H=P.mul($),x=A.mul(A).mul(2),N=A.mul(P).mul(2),G=P.mul(P),J=A.mul(A).mul(A);return H.mul(x.sub(N).add(G)).div(J)}function G_({liquidityUnits:T,poolUnits:_,assetDepth:F}){let P=V(T),A=V(_),$=V(F),H=P.mul($),x=A.mul(A).mul(2),N=A.mul(P).mul(2),G=P.mul(P),J=H.mul(x.sub(N).add(G)),X=A.mul(A).mul(A);return J.div(X)}function _P({percent:T,runeDepth:_,liquidityUnits:F,poolUnits:P}){return B_({runeDepth:_,liquidityUnits:F,poolUnits:P}).mul(T)}function FP({percent:T,assetDepth:_,liquidityUnits:F,poolUnits:P}){return G_({assetDepth:_,liquidityUnits:F,poolUnits:P}).mul(T)}function V(T){return K.fromBigInt(BigInt(T),j.THOR)}function X_({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P}){return{assetAmount:V(P).mul(T).div(_),runeAmount:V(F).mul(T).div(_)}}function PP({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P,percent:A}){return Object.fromEntries(Object.entries(X_({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P})).map(([$,H])=>[$,H.mul(A)]))}function AP({runeDepth:T,poolUnits:_,assetDepth:F,liquidityUnits:P,runeAmount:A,assetAmount:$}){let H=new K({value:T,decimal:8}),x=new K({value:F,decimal:8}),N=new K({value:_,decimal:8}),G=new K({value:A,decimal:8}),J=new K({value:$,decimal:8}),X=G.mul(x),O=J.mul(H),q=G.mul(J),W=H.mul(x),w=N.mul(X.add(O.add(q.mul(2)))),Y=X.add(O.add(W.mul(2))),D=w.div(Y),C=V(P).add(D);if(D.getBaseValue("number")===0)return C.div(N).getBaseValue("number");let ET=N.add(C);return C.div(ET).getBaseValue("number")}function RP({runeAmount:T,assetAmount:_,runeDepth:F,assetDepth:P}){if(T==="0"||_==="0"||F==="0"||P==="0")return 0;let A=V(F),$=V(P),H=V(_),x=V(T),N=H.mul(A).sub($.mul(x)),G=$.mul(x).add(A.mul($));return Math.abs(N.div(G).getBaseValue("number"))}import{match as Q_}from"ts-pattern";function BP({type:T,address:_}){return`${T}:${_}`}function GP({address:T,unbondAmount:_}){return`${"UNBOND"}:${T}:${_}`}function XP(T){return TT("POOL+",T)}function QP({chain:T,symbol:_,address:F,...P}){let A=z_({chain:T,symbol:_}),$=F?`:${F}:`:":";return TT(`${"+"}:${A}${$}`,P)}function zP({chain:T,symbol:_,ticker:F,basisPoints:P,targetAsset:A}){let $=T==="ETH"&&F!=="ETH"?`${F}-${_.slice(-3)}`:_,H=A?`:${A}`:"";return`${"-"}:${T}.${$}:${P}${H}`}function ZP({basisPoints:T,..._}){return TT(`${"POOL-"}:${T}`,_)}function YP({name:T,chain:_,address:F,owner:P}){let A=`${"~"}:${T}:${_}:${F}`,$=P?`:${P}`:"";return`${A}${$}`}function JP({name:T,chain:_,asset:F,payout:P,owner:A}){return`${"~"}:${T}:${_}:${P}:${A}:${F}`}function MP(T,{address:_}){return`${T}:${_}`}function LP(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 VP(){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,$=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=window?.bitkeep?.ethereum,x=window?.$onekey?.ethereum,N=[];if(T)N.push("METAMASK");if(_)N.push("CTRL");if(F)N.push("VULTISIG");if(P)N.push("BRAVE");if(A)N.push("TRUSTWALLET_WEB");if($)N.push("COINBASE_WEB");if(L_())N.push("OKX_MOBILE");if(H)N.push("BITGET");if(x)N.push("ONEKEY");return N}async function Y_(T,_,F){try{await fT({provider:T,method:"wallet_switchEthereumChain",params:[{chainId:zT[_]}]})}catch(P){if(!F)throw new M("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await M_(T,F)}}function OP({chains:T,supportedChains:_,walletType:F}){let P=T.filter(($)=>!$||_.includes($));if(P.length===0)throw new M("wallet_chain_not_supported",{wallet:F,chain:T.join(", ")});let A=T.filter(($)=>!_.includes($));return r(A.length>0,`${F} wallet does not support the following chains: ${A.join(", ")}. These chains will be ignored.`),P}function J_(T,_,F){return async(...P)=>{try{await Y_(_,F)}catch(A){throw new M({errorKey:"helpers_failed_to_switch_network",info:{error:A}})}return T(...P)}}function IP({toolbox:T,chain:_,provider:F=window.ethereum,methodNames:P=[]}){let $=[...P,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((H,x)=>{if(!T[x])return H;let N=T[x];if(typeof N!=="function")return H;let G=J_(N,F,_);return{...H,[x]:G}},{});return{...T,...$}}function M_(T,_){return fT({provider:T,method:"wallet_addEthereumChain",params:[_]})}function KP(T){window.ethereum?.on("accountsChanged",()=>T()),window.xfi?.ethereum.on("accountsChanged",()=>T())}function wP(){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 DP(){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 fT({provider:T,params:_,method:F}){if(!T?.send)throw new M("helpers_not_found_provider");let P=_?Array.isArray(_)?_:[_]:[];return T.send(F,P)}export{WF as wrapWithThrow,J_ as wrapMethodWithNetworkSwitch,r as warnOnce,IF as validateTNS,kT as validateIdentifier,PT as updateDerivationPath,Y_ as switchEVMWalletNetwork,fT as providerRequest,IP as prepareNetworkSwitch,L_ as okxMobileEnabled,Z_ as listWeb3EVMWallets,VP as isWeb3Detected,qT as isGasAsset,kP as isDetected,D_ as initializeRPCUrlsWithFallback,m_ as getWalletFormatFor,LF as getTHORNameCost,PP as getSymmetricWithdraw,X_ as getSymmetricPoolShare,CF as getMinAmountByChain,zP as getMemoForWithdraw,GP as getMemoForUnbond,LP as getMemoForTcyStake,MP as getMemoForTcyClaim,ZP as getMemoForRunePoolWithdraw,XP as getMemoForRunePoolDeposit,YP as getMemoForNameRegister,JP as getMemoForNamePreferredAssetRegister,BP as getMemoForLeaveAndBond,QP as getMemoForDeposit,jF as getMAYANameCost,RP as getLiquiditySlippage,XF as getGasAsset,N_ as getFeeMultiplierAsBigInt,wT as getFeeMultiplier,rF as getExplorerTxUrl,iF as getExplorerAddressUrl,AP as getEstimatedPoolShare,wP as getETHDefaultWallet,DP as getEIP6963Wallets,UF as getDynamicChainId,p_ as getDerivationPathFor,WT as getDecimal,t as getCommonAssetInfo,qF as getChainIdentifier,_P as getAsymmetricRuneWithdrawAmount,B_ as getAsymmetricRuneShare,FP as getAsymmetricAssetWithdrawAmount,G_ as getAsymmetricAssetShare,AT as getAssetType,u as formatBigIntToSafeValue,QF as findAssetBy,OP as filterSupportedChains,ZT as derivationPathToString,RT as assetFromString,cF as applyFeeMultiplierToBigInt,lF as applyFeeMultiplier,M_ as addEVMWalletNetwork,KP as addAccountsChangedCallback,cT as WarningCodeEnum,n as WalletOption,GT as UTXOChains,K_ as TCSupportedChains,K as SwapKitNumber,M as SwapKitError,k_ as SubstrateChains,_T as StagenetChain,y_ as SWAP_OUT,b_ as SWAP_IN,I as SKConfig,b as RequestClient,c as RPC_URLS,oT as QuoteMode,lT as ProviderName,y as NetworkDerivationPath,o as NODE_URLS,JT as MemoType,w_ as MAYASupportedChains,tT as LedgerErrorCode,nT as FeeTypeEnum,YT as FeeOption,bT as FALLBACK_URLS,hT as ErrorCode,FT as EXPLORER_URLS,E as EVMChains,h_ as DerivationPath,x_ as DEFAULT_FEE_MULTIPLIERS,O_ as CosmosChains,I_ as CosmosChainPrefixes,dT as ContractAddress,GF as CommonAssetStrings,zT as ChainToHexChainId,S_ as ChainToExplorerUrl,QT as ChainToChainId,U_ as ChainIdToChain,d as ChainId,U as Chain,V_ as BlockTimes,f as BigIntArithmetics,j as BaseDecimal,S as AssetValue,sT as ApproveMode,v_ as AGG_SWAP};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=E1D34078B9DD406364756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|