@swapkit/helpers 4.0.0-beta.48 → 4.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/types/utils/asset.d.ts +1 -1
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as MF,c as XF}from"./chunk-hm14bfyg.js";export*from"@swapkit/tokens";import{getAddress as IF}from"ethers";import{match as KF}from"ts-pattern";import{match as GF}from"ts-pattern";var SF={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 J extends Error{static ErrorCode=SF;constructor(F,$){let x=typeof F==="string",N=x?F:F.errorKey,H=x?void 0:F.info,R=`${N}${H?`: ${JSON.stringify(H)}`:""}`;super(R);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${N}]:`,$);else if(H)console.error(`SwapKitError [${N}]:`,H)}}var q;((G)=>{G.Arbitrum="ARB";G.Aurora="AURORA";G.Avalanche="AVAX";G.Base="BASE";G.Berachain="BERA";G.BinanceSmartChain="BSC";G.Bitcoin="BTC";G.BitcoinCash="BCH";G.Cosmos="GAIA";G.Dash="DASH";G.Dogecoin="DOGE";G.Ethereum="ETH";G.Fiat="FIAT";G.Gnosis="GNO";G.Kujira="KUJI";G.Litecoin="LTC";G.Maya="MAYA";G.Near="NEAR";G.Noble="NOBLE";G.Optimism="OP";G.Polkadot="DOT";G.Chainflip="FLIP";G.Polygon="POL";G.Radix="XRD";G.Ripple="XRP";G.THORChain="THOR";G.Solana="SOL";G.Tron="TRON";G.Zcash="ZEC"})(q||={});var FF;((x)=>{x.THORChain="THOR_STAGENET";x.Maya="MAYA_STAGENET"})(FF||={});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.Noble="noble-1";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 j$={["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",["noble-1"]:"NOBLE",["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"]:"TRON",["0x2b6653dc"]:"TRON",["zcash"]:"ZEC"},gF=Object.keys(q),o=Object.values(q),X={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,NOBLE:6,OP:18,SOL:9,THOR:8,TRON:6,XRD:18,XRP:6,ZEC:8},q$={["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,["NOBLE"]:1.3,["OP"]:2,["DOT"]:6,["POL"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRON"]:3,["ZEC"]:150},W$=["DOT","FLIP"],S=["ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL"],TF=["BTC","BCH","DASH","DOGE","LTC","ZEC"],U$=["GAIA","THOR","MAYA","KUJI","NOBLE"],V$={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira",["NOBLE"]:"noble"},h={["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",["NOBLE"]:"https://noble-rpc.polkachu.com",["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",["TRON"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",["MAYA_STAGENET"]:"",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},m={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},vF={["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"],["NOBLE"]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],["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",m.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRON"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:[]},$F={["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",["NOBLE"]:"https://www.mintscan.io/noble",["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",["TRON"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},AF=h,bF=(F)=>{return GF(F).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","NOBLE","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("TRON","XRD","FIAT",()=>"").with("NEAR",()=>({jsonrpc:"2.0",id:"dontcare",method:"status",params:[]})).with("XRP",()=>({method:"ping",params:[{}],id:1,jsonrpc:"2.0"})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:F})})};function EF(F){return GF(F).with("XRD",()=>"/status/network-configuration").with("TRON",()=>"/wallet/getnowblock").otherwise(()=>"")}var _F=async(F,$)=>{try{let x=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${x}${EF(F)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(bF(F)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},yF=async(F)=>{let $=h[F];if(await _F(F,$))return $;for(let x of vF[F])if(await _F(F,x))return x;return $},k$=async(F=[...Object.values(q),...Object.values(FF)])=>{let $={};await Promise.all(F.map(async(x)=>{let N=await yF(x);$[x]=N})),AF={...AF,...$}},BF=o.reduce((F,$)=>{let x=gF.find((N)=>q[N]===$);if(x)F[$]=x;return F},{}),QF=o.reduce((F,$)=>{return F[$]=d[BF[$]],F},{}),zF=o.reduce((F,$)=>{let x=`${BF[$]}Hex`;return F[$]=d[x],F},{}),I$=o.reduce((F,$)=>{return F[$]=$F[$],F},{});import{match as n}from"ts-pattern";var b={get:c("GET"),post:c("POST"),extend:(F)=>({get:c("GET",F),post:c("POST",F),extend:($)=>b.extend({...F,...$})})};function c(F,$={}){return async(x,N={})=>{let{searchParams:H,json:R,body:A,headers:_,dynamicHeader:T}={...$,...N},Q=!!R||x.endsWith(".json"),Y=Q?JSON.stringify(R):A;try{let z=pF(x,H),V=uF(Q,{..._,...T?.()}),j=await fetch(z,{...N,method:F,body:Y,headers:V});if(!j.ok){let w=await j.text();throw new J("helpers_invalid_response",{status:j.status,statusText:j.statusText,message:w})}let L=await j.json();return N.onSuccess?.(L)||N.responseHandler?.(L)||L}catch(z){if(N.onError)return N.onError(z);throw z}}}function uF(F,$){return{...$,...F?{"Content-Type":"application/json"}:{}}}function pF(F,$){let x=new URL(F);if($)x.search=new URLSearchParams($).toString();return x.toString()}import{createStore as nF}from"zustand/vanilla";function xF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[x,N,H,,R]=F;return[x,N,H,$.change,R]}if("account"in $){let[x,N,,H,R]=F;return[x,N,$.account,H,R]}return F}function ZF([F,$,x,N,H]){let R=typeof H!=="number";if(typeof N!=="number")return`m/${F}'/${$}'/${x}'`;return`m/${F}'/${$}'/${x}'/${N}${R?"":`/${H}`}`}function f$({chain:F,index:$,addressIndex:x=0,type:N}){if(S.includes(F)){if(N&&["legacy","account"].includes(N))return[44,60,0,$];if(N==="ledgerLive")return[44,60,$,0,x];return xF(E[F],{index:$})}if(F==="SOL"){if(N==="account")return[44,501,0,$];return xF(E[F],{index:$})}let H=F==="LTC"?2:0;switch(N){case"nativeSegwitMiddleAccount":return[84,H,$,0,x];case"segwit":return[49,H,0,0,$];case"legacy":return[44,H,0,0,$];default:return xF(E[F],{index:$})}}function S$(F){let[$,x,N]=F.split("/").map((H)=>Number.parseInt(H,10));switch(x){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var CF;((Y)=>{Y.ARB="0x0000000000000000000000000000000000000000";Y.AURORA="0x0000000000000000000000000000000000000000";Y.AVAX="0x0000000000000000000000000000000000000000";Y.BASE="0x0000000000000000000000000000000000000000";Y.BERA="0x0000000000000000000000000000000000000000";Y.ETH="0x0000000000000000000000000000000000000000";Y.BSC="0x0000000000000000000000000000000000000000";Y.GNO="0x0000000000000000000000000000000000000000";Y.MATIC="0x0000000000000000000000000000000000001010";Y.OP="0x4200000000000000000000000000000000000042"})(CF||={});var E={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],NOBLE:[44,118,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRON:[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]},b$=Object.keys(E).reduce((F,$)=>{return F[$]=ZF(E[$]),F},{});var mF;((P)=>{P.unknownError="unknownError";P.test_error="test_error";P.providerDetailsError="providerDetailsError";P.blockHeaderNotFound="blockHeaderNotFound";P.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";P.blockHashNotFoundAtHash="blockHashNotFoundAtHash";P.txHashMissing="txHashMissing";P.assetValueMissingInfo="assetValueMissingInfo";P.invalidAsset="invalidAsset";P.blockIsRequired="blockIsRequired";P.currentBlockHeaderNotFound="currentBlockHeaderNotFound";P.failedToRetrieveBalance="failedToRetrieveBalance";P.failedToRetrieveBlock="failedToRetrieveBlock";P.failedToRetrieveFees="failedToRetrieveFees";P.notImplementedBCH="notImplementedBCH";P.notImplementedDoge="notImplementedDoge";P.noPoolsFound="noPoolsFound";P.noVaultsFound="noVaultsFound";P.noTxFound="noTxFound";P.noInputCoinFound="noInputCoinFound";P.noBlockDataFound="noBlockDataFound";P.multipleCosmosMessages="multipleCosmosMessages";P.heightOrHashNotProvided="heightOrHashNotProvided";P.unknownDenom="unknownDenom";P.invalidBlockHeight="invalidBlockHeight";P.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";P.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";P.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";P.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";P.txMemoUndefined="txMemoUndefined";P.txMemoIncorrect="txMemoIncorrect";P.txTypeNotFound="txTypeNotFound";P.txNoMessage="txNoMessage";P.txNotFound="txNotFound";P.txReceiptNotFound="txReceiptNotFound";P.txParsingError="txParsingError";P.txLogsParsingError="txLogsParsingError";P.blockNotFound="blockNotFound";P.balanceNotFound="balanceNotFound";P.configError="configError";P.synthSwapDisallowed="synthSwapDisallowed";P.providerQuoteTimeout="providerQuoteTimeout";P.noQuoteResponse="noQuoteResponse";P.noPoolAssetsFound="noPoolAssetsFound";P.noThorchainPools="noThorchainPools";P.noMayachainPools="noMayachainPools";P.noThorchainNetworkInfo="noThorchainNetworkInfo";P.invalidAffiliateFee="invalidAffiliateFee";P.invalidBuyAssetAddress="invalidBuyAssetAddress";P.invalidSellAssetAddress="invalidSellAssetAddress";P.invalidSourceAddress="invalidSourceAddress";P.invalidDestinationAddress="invalidDestinationAddress";P.sourceAddressIsSmartContract="sourceAddressIsSmartContract";P.destinationAddressIsSmartContract="destinationAddressIsSmartContract";P.invalidChainId="invalidChainId";P.unsupportedChainId="unsupportedChainId";P.unsupportedEVMChainId="unsupportedEVMChainId";P.unsupportedMethod="unsupportedMethod";P.unsupportedProvider="unsupportedProvider";P.invalidParamsForMethod="invalidParamsForMethod";P.unsupportedAdapter="unsupportedAdapter";P.noWhitelistTokens="noWhitelistTokens";P.failedFetchGasPrice="failedFetchGasPrice";P.failedToCreateDepositChannel="failedToCreateDepositChannel";P.noProviderDetailsFound="noProviderDetailsFound";P.noTokenListsFound="noTokenListsFound";P.tokenNotFound="tokenNotFound";P.tokenPriceNotFound="tokenPriceNotFound";P.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";P.swapAmountTooSmall="swapAmountTooSmall";P.legsArrayIsEmpty="legsArrayIsEmpty";P.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";P.noBlockHeaderFound="noBlockHeaderFound";P.failedToSimulateSwap="failedToSimulateSwap";P.addressScreeningFailed="addressScreeningFailed";P.noLiquidtyProvidersFound="noLiquidtyProvidersFound";P.insufficientLiquidity="insufficientLiquidity";P.noInboundDataFound="noInbounDataFound";P.noInboundAddressesFound="noInboundAddressesFound";P.noInboundAddressFoundForChain="noInboundAddressFoundForChain";P.noLastBlocksFound="noLastBlocksFound";P.noVersionFound="noVersionFound";P.noConstantsFound="noConstantsFound";P.noMimirsFound="noMimirsFound";P.noRoutesFound="noRoutesFound";P.quoteNotFound="quoteNotFound";P.ledgerSignFailed="ledgerSignFailed";P.ledgerWrongPayload="ledgerWrongPayload";P.ledgerFetchSwapFailed="ledgerFetchSwapFailed";P.failedToFetchTx="failedToFetchTx";P.failedBuildTransactionDetails="failedBuildTransactionDetails";P.noLegsForRoute="noLegsForRoute";P.noRouterAddressFound="noRouterAddressFound";P.noAggregatorAddressFound="noAggregatorAddressFound";P.noContractInstanceFound="noContractInstanceFound";P.noContractAddressFound="noContractAddressFound";P.invalidAffiliate="invalidAffiliate";P.thornameAffiliate="thornameAffiliate";P.providerNotfound="No provider found";P.noRecordFound="No Record found";P.slippageTooLow="Slippage too low";P.tradingHalted="tradingHalted";P.noWrappedGasAsset="noWrappedGasAsset";P.aggregatorAddressNotFound="aggregatorAddressNotFound";P.routerAddressNotFound="routerAddressNotFound";P.dummyAddressNotFound="dummyAddressNotFound";P.trackerError="trackerError";P.thorchainPoolUnavailable="thorchainPoolUnavailable";P.noOhlcvDataFound="noOhlcvDataFound";P.noTradingPairs="noTradingPairs";P.noLendingAvailability="noLendingAvailability";P.lendingRepayTooSmall="lendingRepayTooSmall";P.missingState="missingState";P.ledgerSwapNotFound="ledgerSwapNotFound";P.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";P.errorEstimatingGas="errorEstimatingGas";P.apiKeyInvalid="apiKeyInvalid";P.apiKeyFailedToUpdate="apiKeyFailedToUpdate";P.apiKeyExpired="apiKeyExpired";P.unauthorized="unauthorized";P.failedToCreateMemo="failedToCreateMemo";P.radixIncorrectInstructions="radixIncorrectInstructions";P.radixTxMissedParam="radixTxMissedParam";P.radixTxMissedAccount="radixTxMissedAccount";P.radixManifestParseError="radixManifestParseError";P.radixManifestBuildError="radixManifestBuildError";P.invalidAddressForChain="invalidAddressForChain";P.riskyAddress="riskyAddress";P.noRoutesToProcess="noRoutesToProcess";P.sellAssetAmountTooSmall="sellAssetAmountTooSmall";P.missingPrivateKey="missingPrivateKey";P.noMemoPriceProtection="noMemoPriceProtection"})(mF||={});var dF;((x)=>{x.highSlippage="highSlippage";x.highPriceImpact="highPriceImpact"})(dF||={});var oF;((M)=>{M.CAVIAR_V1="CAVIAR_V1";M.CAMELOT_V3="CAMELOT_V3";M.CHAINFLIP="CHAINFLIP";M.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";M.JUPITER="JUPITER";M.MAYACHAIN="MAYACHAIN";M.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";M.OCISWAP_V1="OCISWAP_V1";M.ONEINCH="ONEINCH";M.OPENOCEAN_V2="OPENOCEAN_V2";M.PANCAKESWAP="PANCAKESWAP";M.PANGOLIN_V1="PANGOLIN_V1";M.SUSHISWAP_V2="SUSHISWAP_V2";M.THORCHAIN="THORCHAIN";M.THORCHAIN_STREAMING="THORCHAIN_STREAMING";M.TRADERJOE_V2="TRADERJOE_V2";M.UNISWAP_V2="UNISWAP_V2";M.UNISWAP_V3="UNISWAP_V3";M.NEAR="NEAR"})(oF||={});var hF;((_)=>{_.LIQUIDITY="liquidity";_.NETWORK="network";_.INBOUND="inbound";_.OUTBOUND="outbound";_.AFFILIATE="affiliate";_.TAX="tax";_.PRIORITY="priority"})(hF||={});var YF;((N)=>{N.Average="average";N.Fast="fast";N.Fastest="fastest"})(YF||={});var cF;((x)=>{x.Approve="approve";x.CheckOnly="checkOnly"})(cF||={});var JF;((z)=>{z.NAME_REGISTER="~";z.BOND="BOND";z.DEPOSIT="+";z.LEAVE="LEAVE";z.UNBOND="UNBOND";z.WITHDRAW="-";z.RUNEPOOL_DEPOSIT="POOL+";z.RUNEPOOL_WITHDRAW="POOL-";z.CLAIM_TCY="tcy";z.STAKE_TCY="tcy+";z.UNSTAKE_TCY="tcy-"})(JF||={});var l;((G)=>{G.BITGET="BITGET";G.BRAVE="BRAVE";G.COINBASE_MOBILE="COINBASE_MOBILE";G.COINBASE_WEB="COINBASE_WEB";G.COSMOSTATION="COSMOSTATION";G.CTRL="CTRL";G.EIP6963="EIP6963";G.EXODUS="EXODUS";G.KEEPKEY="KEEPKEY";G.KEEPKEY_BEX="KEEPKEY_BEX";G.KEPLR="KEPLR";G.KEYSTORE="KEYSTORE";G.LEAP="LEAP";G.LEDGER="LEDGER";G.LEDGER_LIVE="LEDGER_LIVE";G.METAMASK="METAMASK";G.OKX="OKX";G.OKX_MOBILE="OKX_MOBILE";G.ONEKEY="ONEKEY";G.PHANTOM="PHANTOM";G.POLKADOT_JS="POLKADOT_JS";G.RADIX_WALLET="RADIX_WALLET";G.TREZOR="TREZOR";G.TALISMAN="TALISMAN";G.TRONLINK="TRONLINK";G.TRUSTWALLET_WEB="TRUSTWALLET_WEB";G.VULTISIG="VULTISIG";G.WALLETCONNECT="WALLETCONNECT";G.XAMAN="XAMAN"})(l||={});var lF;((N)=>{N[N.NoError=36864]="NoError";N[N.LockedDevice=21781]="LockedDevice";N[N.TC_NotFound=65535]="TC_NotFound"})(lF||={});var sF={apis:{},chains:Object.values(q),wallets:Object.values(l),explorerUrls:$F,nodeUrls:m,rpcUrls:h,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},U=nF((F)=>({...sF,setApiKey:($,x)=>F((N)=>({apiKeys:{...N.apiKeys,[$]:x}})),setEnv:($,x)=>F((N)=>({envs:{...N.envs,[$]:x}})),setExplorerUrl:($,x)=>F((N)=>({explorerUrls:{...N.explorerUrls,[$]:x}})),setNodeUrl:($,x)=>F((N)=>({nodeUrls:{...N.nodeUrls,[$]:x}})),setRpcUrl:($,x)=>F((N)=>({rpcUrls:{...N.rpcUrls,[$]:x}})),setIntegrationConfig:($,x)=>F((N)=>({integrations:{...N.integrations,[$]:x}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setConfig:($)=>F((x)=>({apiKeys:{...x.apiKeys,...$.apiKeys},envs:{...x.envs,...$.envs},explorerUrls:{...x.explorerUrls,...$.explorerUrls},integrations:{...x.integrations,...$.integrations},nodeUrls:{...x.nodeUrls,...$.nodeUrls},rpcUrls:{...x.rpcUrls,...$.rpcUrls},feeMultipliers:$.feeMultipliers||x.feeMultipliers,chains:x.chains.concat($.chains||[]),wallets:x.wallets.concat($.wallets||[])}))})),I={getState:U.getState,get:(F)=>U.getState()[F],set:(F)=>U.getState().setConfig(F),setApiKey:(F,$)=>U.getState().setApiKey(F,$),setEnv:(F,$)=>U.getState().setEnv(F,$),setExplorerUrl:(F,$)=>U.getState().setExplorerUrl(F,$),setNodeUrl:(F,$)=>U.getState().setNodeUrl(F,$),setRpcUrl:(F,$)=>U.getState().setRpcUrl(F,$),setIntegrationConfig:(F,$)=>U.getState().setIntegrationConfig(F,$),setFeeMultipliers:(F)=>U.getState().setFeeMultipliers(F)};var xx=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],LF=["ARB","AURORA","BASE","ETH","OP"];async function tF({chain:F,to:$}){try{let{result:N}=await b.post(I.get("rpcUrls")[F],{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(N||X[F]).toString())}catch(N){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,N),X[F]}}async function rF(F){if(F==="XRD")return X.XRD;try{let $=F.split("-")[1]?.toLowerCase(),{manager:x}=await b.post(`${I.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:$})});return x.divisibility.value.divisibility}catch($){return console.error(`Failed to fetch Radix asset decimal for ${F}:`,$),X["XRD"]}}async function iF({chain:F,symbol:$}){if(S.includes($))return X[$];let x=$.split("-"),N=x.length===1?void 0:x[x.length-1]?.toLowerCase();return await(N?.startsWith("0x")?tF({chain:F,to:N}):X[F])}function jF({chain:F,symbol:$}){return n(F).with(...S,(x)=>iF({chain:x,symbol:$})).with("XRD",()=>rF($)).otherwise(()=>X[F])}function Nx({chain:F}){return O.from({chain:F})}function qF({chain:F,symbol:$}){return n(F).with(...LF,()=>$==="ETH").with("AVAX",()=>$==="AVAX").with("BERA",()=>$==="BERA").with("BSC",()=>$==="BNB").with("GNO",()=>$==="XDAI").with("MAYA",()=>$==="CACAO").with("GAIA",()=>$==="ATOM").with("THOR",()=>$==="RUNE").with("TRON",()=>$==="TRX").with("XRD",()=>`${F}.${$}`===s(F).identifier).otherwise(()=>$===F)}var s=(F)=>{let $=X[F];return n(F.toUpperCase()).with(...LF,(N)=>({identifier:`${N}.ETH`,decimal:$})).with("THOR",(N)=>({identifier:`${N}.RUNE`,decimal:$})).with("GAIA",(N)=>({identifier:`${N}.ATOM`,decimal:$})).with("MAYA",(N)=>({identifier:`${N}.CACAO`,decimal:10})).with("BSC",(N)=>({identifier:`${N}.BNB`,decimal:$})).with("AVAX",(N)=>({identifier:`${N}.AVAX`,decimal:$})).with("GNO",(N)=>({identifier:`${N}.XDAI`,decimal:$})).with("BERA",(N)=>({identifier:`${N}.BERA`,decimal:$})).with("TRON",(N)=>({identifier:`${N}.TRX`,decimal:$})).with(...TF,"SOL","FLIP","KUJI","XRP","DOT","NEAR",(N)=>({identifier:`${N}.${N}`,decimal:$})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:$})).with("POL","POL.POL",()=>({identifier:"POL.POL",decimal:$})).with("KUJI.USK",(N)=>({identifier:N,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:X.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:X.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:X.ETH})).with("MAYA.CACAO",(N)=>({identifier:N,decimal:10})).with("MAYA.MAYA",(N)=>({identifier:N,decimal:4})).otherwise(()=>({identifier:F,decimal:$}))};function NF({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return n(F).with("XRD",()=>$==="XRD"||`${F}.${$}`===s(F).identifier).with("ARB","OP","BASE","AURORA",()=>$==="ETH").with("GAIA",()=>$==="ATOM").with("BSC",()=>$==="BNB").with("MAYA",()=>$==="CACAO").with("THOR",()=>$==="RUNE").with("TRON",()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var HF=(F)=>{let[$,...x]=F.split("."),N=F.includes("/"),H=x.join("."),R=H?.split("-"),A=R?.length?R.length===1?R[0]:R.slice(0,-1).join("-"):void 0;return{chain:$,symbol:H,ticker:A,synth:N}};async function Hx(F){let{loadTokenLists:$}=await import("./tokens.js"),x=await $();for(let N of Object.values(x))for(let{identifier:H,chain:R,...A}of N.tokens){if("identifier"in F&&H===F.identifier)return H;if("address"in A&&"chain"in F&&R===F.chain&&A.address&&A.address.toLowerCase()===F.contract.toLowerCase())return H}return}function Tx(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function Bx(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function Qx(F,$){try{return F()}catch(x){if($)throw new J($,x);return}}function zx(F){switch(F){case"THOR":return`${F}.RUNE`;case"GAIA":return`${F}.ATOM`;case"BSC":return`${F}`;default:return`${F}.${F}`}}var WF=new Set;function t(F,$){if(F){if(WF.has($))return;WF.add($)}}async function Zx(F="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(F))return F;try{let $=I.get("rpcUrls")[F!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await b.get(`${$}/status`)).result.node_info.network}catch($){return F}}var UF=["TERRA",...I.get("chains")];function VF(F=""){let $=F.toUpperCase(),[x]=$.split(".");if(UF.includes(x))return!0;let[N]=$.split("/");if(UF.includes(N))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:F}})}function Xx(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var C=8,g=(F)=>10n**BigInt(F),p=(F)=>Math.log10(Number.parseFloat(F.toString()));function y({value:F,bigIntDecimal:$=C,decimal:x=C}){if(x===0)return F.toString();let N=F<0n,H=F.toString().substring(N?1:0),R=x-(H.length-1);if(R>0)H="0".repeat(R)+H;let A=H.length-x,_=H.slice(-x);if(Number.parseInt(_[$]||"0")>=5)_=`${_.substring(0,$-1)}${(Number.parseInt(_[$-1]||"0")+1).toString()}`;else _=_.substring(0,$);return`${N?"-":""}${H.slice(0,A)}.${_}`.replace(/\.?0*$/,"")}function aF(F,$){if($===0n)throw new Error("Cannot divide by zero");let x=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+x)/$;return(F-x)/$}class f{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new f({decimal:$,value:y({value:F,bigIntDecimal:$,decimal:$})})}static shiftDecimals({value:F,from:$,to:x}){return f.fromBigInt(F.getBaseValue("bigint")*g(x)/g($),x)}constructor(F){let $=PF(F),x=typeof F==="object";this.decimal=x?F.decimal:void 0,this.decimalMultiplier=x&&"decimalMultiplier"in F?F.decimalMultiplier:g(Math.max(kF(r($)),this.decimal||0)),this.#H($)}set(F){return new this.constructor({decimal:this.decimal,value:F,identifier:this.toString({includeSynthProtocol:!0})})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let x=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||p(this.decimalMultiplier));switch(F){case"number":return Number(x);case"string":return x;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return x}}getBaseValue(F,$){let x=this.decimalMultiplier/g($||this.decimal||X.THOR),N=aF(this.bigIntValue,x);switch(F){case"number":return Number(N);case"string":return N.toString();case"bigint":return N;default:return N}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let x=PF(F),N=r(x);if(N==="0"||N==="undefined")return 0n;return this.#N(N,$)}toSignificant(F=6){let[$,x]=this.getValue("string").split("."),N=$||"",H=x||"";if((Number.parseInt(N)?N.length+H.length:H.length)<=F)return this.getValue("string");if(N.length>=F)return N.slice(0,F).padEnd(N.length,"0");if(Number.parseInt(N))return`${N}.${H.slice(0,F-N.length)}`.padEnd(F-N.length,"0");let A=Number.parseInt(H),_=`${A}`.slice(0,F);return`0.${_.padStart(H.length-`${A}`.length+_.length,"0")}`}toFixed(F=6){let[$,x]=this.getValue("string").split("."),N=$||"",H=x||"";if(Number.parseInt(N))return`${N}.${H.slice(0,F)}`.padEnd(F,"0");let R=Number.parseInt(H),A=`${R}`.slice(0,F);return`0.${A.padStart(H.length-`${R}`.length+A.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),x=["","K","M","B","T","Q","Qi","S"],N=Math.floor(Math.log10(Math.abs($))/3),H=x[N];if(!H)return this.getValue("string");let R=10**(N*3);return`${($/R).toFixed(F)}${H}`}toCurrency(F="$",{currencyPosition:$="start",decimal:x=2,decimalSeparator:N=".",thousandSeparator:H=","}={}){let R=this.getValue("number"),[A="",_=""]=R.toFixed(6).split("."),T=A.replace(/\B(?=(\d{3})+(?!\d))/g,H),Q=A||_?A==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",N):`${T}${Number.parseInt(_)?`${N}${_.slice(0,x)}`:""}`:"0.00";return`${$==="start"?F:""}${Q}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let x=$||this.decimal||C,N=Math.max(x,p(this.decimalMultiplier)),H=F<0n,R=F.toString().substring(H?1:0),A=N-(R.length-1),_=A>0?"0".repeat(A)+R:R,T=_.length-N,Q=_.slice(-N);if(Number.parseInt(Q[x]||"0")>=5)Q=`${Q.substring(0,x-1)}${(Number.parseInt(Q[x-1]||"0")+1).toString()}`;else Q=Q.substring(0,x);return`${H?"-":""}${_.slice(0,T)}.${Q}`.replace(/\.?0*$/,"")}#$(F,...$){let x=this.#x(this,...$),N=Math.max(x,p(this.decimalMultiplier)),H=g(N),R=$.reduce((_,T)=>{let Q=this.getBigIntValue(T,N);switch(F){case"add":return _+Q;case"sub":return _-Q;case"mul":return _*Q/H;case"div":{if(Q===0n)throw new RangeError("Division by zero");return _*H/Q}default:return _}},this.bigIntValue*H/this.decimalMultiplier),A=y({bigIntDecimal:N,decimal:N,value:R});return new this.constructor({decimalMultiplier:g(N),decimal:this.decimal,value:A,identifier:this.toString()})}#F(F,...$){let x=this.#x(this,...$),N=this.getBigIntValue($[0]||"0",x),H=this.getBigIntValue(this,x);switch(F){case"gt":return H>N;case"gte":return H>=N;case"lt":return H<N;case"lte":return H<=N;case"eqValue":return H===N;default:return!1}}#H(F){let $=r(F)||"0";this.bigIntValue=this.#N($)}#x(...F){let $=F.map((x)=>{return typeof x==="object"?x.decimal||p(x.decimalMultiplier):kF(r(x))}).filter(Boolean);return Math.max(...$,C)}#N(F,$){let x=$?g($):this.decimalMultiplier,N=p(x),[H="",R=""]=F.split(".");return BigInt(`${H}${R.padEnd(N,"0")}`)}}var eF=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function r(F){let x=`${typeof F==="number"?eF.format(F):PF(F)}`.replaceAll(",",".").split(".");return x.length>1?`${x.slice(0,-1).join("")}.${x.at(-1)}`:x[0]||"0"}function kF(F){let $=F.split(".")[1]?.length||0;return Math.max($,C)}function PF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var i=["SOL","TRON"],v=new Map;class O extends f{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:x,chain:N,symbol:H,identifier:R}){super(typeof F==="object"?F:{decimal:$,value:F});let A=RF(R||`${N}.${H}`);this.type=NF(A),this.tax=x,this.chain=A.chain,this.ticker=A.ticker,this.symbol=A.symbol,this.address=A.address,this.isSynthetic=A.isSynthetic,this.isTradeAsset=A.isTradeAsset,this.isGasAsset=A.isGasAsset,this.chainId=QF[A.chain]}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?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:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let[x,N,H]=F.split(".");if(!(x&&N))throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let R=x==="THOR"&&H?`${x}.${N}/${H}`:F;return O.from({asset:R,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:x,...N}){let H=F instanceof f?F.getValue("string"):F,R=N$(N),{identifier:A,decimal:_}=s(R),{chain:T,isSynthetic:Q,isTradeAsset:Y}=RF(A),z=v.get(i.includes(T)?A:A.toUpperCase()),V=z?.decimal||_;t(!(x||V),`Couldn't find static decimal for one or more tokens on ${T} (Using default ${X[T]} decimal as fallback).
|
|
1
|
+
import{a as MF,c as XF}from"./chunk-hm14bfyg.js";export*from"@swapkit/tokens";import{getAddress as IF}from"ethers";import{match as KF}from"ts-pattern";import{match as GF}from"ts-pattern";var SF={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 J extends Error{static ErrorCode=SF;constructor(F,$){let x=typeof F==="string",N=x?F:F.errorKey,H=x?void 0:F.info,R=`${N}${H?`: ${JSON.stringify(H)}`:""}`;super(R);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${N}]:`,$);else if(H)console.error(`SwapKitError [${N}]:`,H)}}var q;((G)=>{G.Arbitrum="ARB";G.Aurora="AURORA";G.Avalanche="AVAX";G.Base="BASE";G.Berachain="BERA";G.BinanceSmartChain="BSC";G.Bitcoin="BTC";G.BitcoinCash="BCH";G.Cosmos="GAIA";G.Dash="DASH";G.Dogecoin="DOGE";G.Ethereum="ETH";G.Fiat="FIAT";G.Gnosis="GNO";G.Kujira="KUJI";G.Litecoin="LTC";G.Maya="MAYA";G.Near="NEAR";G.Noble="NOBLE";G.Optimism="OP";G.Polkadot="DOT";G.Chainflip="FLIP";G.Polygon="POL";G.Radix="XRD";G.Ripple="XRP";G.THORChain="THOR";G.Solana="SOL";G.Tron="TRON";G.Zcash="ZEC"})(q||={});var FF;((x)=>{x.THORChain="THOR_STAGENET";x.Maya="MAYA_STAGENET"})(FF||={});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.Noble="noble-1";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 j$={["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",["noble-1"]:"NOBLE",["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"]:"TRON",["0x2b6653dc"]:"TRON",["zcash"]:"ZEC"},gF=Object.keys(q),o=Object.values(q),X={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,NOBLE:6,OP:18,SOL:9,THOR:8,TRON:6,XRD:18,XRP:6,ZEC:8},q$={["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,["NOBLE"]:1.3,["OP"]:2,["DOT"]:6,["POL"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRON"]:3,["ZEC"]:150},W$=["DOT","FLIP"],S=["ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL"],TF=["BTC","BCH","DASH","DOGE","LTC","ZEC"],U$=["GAIA","THOR","MAYA","KUJI","NOBLE"],V$={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira",["NOBLE"]:"noble"},h={["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://cosmos-rpc.publicnode.com:443",["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",["NOBLE"]:"https://noble-rpc.polkachu.com",["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",["TRON"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",["MAYA_STAGENET"]:"",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},m={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},vF={["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"],["NOBLE"]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],["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",m.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRON"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:[]},$F={["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",["NOBLE"]:"https://www.mintscan.io/noble",["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",["TRON"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},AF=h,bF=(F)=>{return GF(F).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","NOBLE","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("TRON","XRD","FIAT",()=>"").with("NEAR",()=>({jsonrpc:"2.0",id:"dontcare",method:"status",params:[]})).with("XRP",()=>({method:"ping",params:[{}],id:1,jsonrpc:"2.0"})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:F})})};function EF(F){return GF(F).with("XRD",()=>"/status/network-configuration").with("TRON",()=>"/wallet/getnowblock").otherwise(()=>"")}var _F=async(F,$)=>{try{let x=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${x}${EF(F)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(bF(F)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},yF=async(F)=>{let $=h[F];if(await _F(F,$))return $;for(let x of vF[F])if(await _F(F,x))return x;return $},k$=async(F=[...Object.values(q),...Object.values(FF)])=>{let $={};await Promise.all(F.map(async(x)=>{let N=await yF(x);$[x]=N})),AF={...AF,...$}},BF=o.reduce((F,$)=>{let x=gF.find((N)=>q[N]===$);if(x)F[$]=x;return F},{}),QF=o.reduce((F,$)=>{return F[$]=d[BF[$]],F},{}),zF=o.reduce((F,$)=>{let x=`${BF[$]}Hex`;return F[$]=d[x],F},{}),I$=o.reduce((F,$)=>{return F[$]=$F[$],F},{});import{match as n}from"ts-pattern";var b={get:c("GET"),post:c("POST"),extend:(F)=>({get:c("GET",F),post:c("POST",F),extend:($)=>b.extend({...F,...$})})};function c(F,$={}){return async(x,N={})=>{let{searchParams:H,json:R,body:A,headers:_,dynamicHeader:T}={...$,...N},Q=!!R||x.endsWith(".json"),Y=Q?JSON.stringify(R):A;try{let z=pF(x,H),V=uF(Q,{..._,...T?.()}),j=await fetch(z,{...N,method:F,body:Y,headers:V});if(!j.ok){let w=await j.text();throw new J("helpers_invalid_response",{status:j.status,statusText:j.statusText,message:w})}let L=await j.json();return N.onSuccess?.(L)||N.responseHandler?.(L)||L}catch(z){if(N.onError)return N.onError(z);throw z}}}function uF(F,$){return{...$,...F?{"Content-Type":"application/json"}:{}}}function pF(F,$){let x=new URL(F);if($)x.search=new URLSearchParams($).toString();return x.toString()}import{createStore as nF}from"zustand/vanilla";function xF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[x,N,H,,R]=F;return[x,N,H,$.change,R]}if("account"in $){let[x,N,,H,R]=F;return[x,N,$.account,H,R]}return F}function ZF([F,$,x,N,H]){let R=typeof H!=="number";if(typeof N!=="number")return`m/${F}'/${$}'/${x}'`;return`m/${F}'/${$}'/${x}'/${N}${R?"":`/${H}`}`}function f$({chain:F,index:$,addressIndex:x=0,type:N}){if(S.includes(F)){if(N&&["legacy","account"].includes(N))return[44,60,0,$];if(N==="ledgerLive")return[44,60,$,0,x];return xF(E[F],{index:$})}if(F==="SOL"){if(N==="account")return[44,501,0,$];return xF(E[F],{index:$})}let H=F==="LTC"?2:0;switch(N){case"nativeSegwitMiddleAccount":return[84,H,$,0,x];case"segwit":return[49,H,0,0,$];case"legacy":return[44,H,0,0,$];default:return xF(E[F],{index:$})}}function S$(F){let[$,x,N]=F.split("/").map((H)=>Number.parseInt(H,10));switch(x){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var CF;((Y)=>{Y.ARB="0x0000000000000000000000000000000000000000";Y.AURORA="0x0000000000000000000000000000000000000000";Y.AVAX="0x0000000000000000000000000000000000000000";Y.BASE="0x0000000000000000000000000000000000000000";Y.BERA="0x0000000000000000000000000000000000000000";Y.ETH="0x0000000000000000000000000000000000000000";Y.BSC="0x0000000000000000000000000000000000000000";Y.GNO="0x0000000000000000000000000000000000000000";Y.MATIC="0x0000000000000000000000000000000000001010";Y.OP="0x4200000000000000000000000000000000000042"})(CF||={});var E={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],NOBLE:[44,118,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRON:[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]},b$=Object.keys(E).reduce((F,$)=>{return F[$]=ZF(E[$]),F},{});var mF;((P)=>{P.unknownError="unknownError";P.test_error="test_error";P.providerDetailsError="providerDetailsError";P.blockHeaderNotFound="blockHeaderNotFound";P.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";P.blockHashNotFoundAtHash="blockHashNotFoundAtHash";P.txHashMissing="txHashMissing";P.assetValueMissingInfo="assetValueMissingInfo";P.invalidAsset="invalidAsset";P.blockIsRequired="blockIsRequired";P.currentBlockHeaderNotFound="currentBlockHeaderNotFound";P.failedToRetrieveBalance="failedToRetrieveBalance";P.failedToRetrieveBlock="failedToRetrieveBlock";P.failedToRetrieveFees="failedToRetrieveFees";P.notImplementedBCH="notImplementedBCH";P.notImplementedDoge="notImplementedDoge";P.noPoolsFound="noPoolsFound";P.noVaultsFound="noVaultsFound";P.noTxFound="noTxFound";P.noInputCoinFound="noInputCoinFound";P.noBlockDataFound="noBlockDataFound";P.multipleCosmosMessages="multipleCosmosMessages";P.heightOrHashNotProvided="heightOrHashNotProvided";P.unknownDenom="unknownDenom";P.invalidBlockHeight="invalidBlockHeight";P.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";P.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";P.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";P.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";P.txMemoUndefined="txMemoUndefined";P.txMemoIncorrect="txMemoIncorrect";P.txTypeNotFound="txTypeNotFound";P.txNoMessage="txNoMessage";P.txNotFound="txNotFound";P.txReceiptNotFound="txReceiptNotFound";P.txParsingError="txParsingError";P.txLogsParsingError="txLogsParsingError";P.blockNotFound="blockNotFound";P.balanceNotFound="balanceNotFound";P.configError="configError";P.synthSwapDisallowed="synthSwapDisallowed";P.providerQuoteTimeout="providerQuoteTimeout";P.noQuoteResponse="noQuoteResponse";P.noPoolAssetsFound="noPoolAssetsFound";P.noThorchainPools="noThorchainPools";P.noMayachainPools="noMayachainPools";P.noThorchainNetworkInfo="noThorchainNetworkInfo";P.invalidAffiliateFee="invalidAffiliateFee";P.invalidBuyAssetAddress="invalidBuyAssetAddress";P.invalidSellAssetAddress="invalidSellAssetAddress";P.invalidSourceAddress="invalidSourceAddress";P.invalidDestinationAddress="invalidDestinationAddress";P.sourceAddressIsSmartContract="sourceAddressIsSmartContract";P.destinationAddressIsSmartContract="destinationAddressIsSmartContract";P.invalidChainId="invalidChainId";P.unsupportedChainId="unsupportedChainId";P.unsupportedEVMChainId="unsupportedEVMChainId";P.unsupportedMethod="unsupportedMethod";P.unsupportedProvider="unsupportedProvider";P.invalidParamsForMethod="invalidParamsForMethod";P.unsupportedAdapter="unsupportedAdapter";P.noWhitelistTokens="noWhitelistTokens";P.failedFetchGasPrice="failedFetchGasPrice";P.failedToCreateDepositChannel="failedToCreateDepositChannel";P.noProviderDetailsFound="noProviderDetailsFound";P.noTokenListsFound="noTokenListsFound";P.tokenNotFound="tokenNotFound";P.tokenPriceNotFound="tokenPriceNotFound";P.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";P.swapAmountTooSmall="swapAmountTooSmall";P.legsArrayIsEmpty="legsArrayIsEmpty";P.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";P.noBlockHeaderFound="noBlockHeaderFound";P.failedToSimulateSwap="failedToSimulateSwap";P.addressScreeningFailed="addressScreeningFailed";P.noLiquidtyProvidersFound="noLiquidtyProvidersFound";P.insufficientLiquidity="insufficientLiquidity";P.noInboundDataFound="noInbounDataFound";P.noInboundAddressesFound="noInboundAddressesFound";P.noInboundAddressFoundForChain="noInboundAddressFoundForChain";P.noLastBlocksFound="noLastBlocksFound";P.noVersionFound="noVersionFound";P.noConstantsFound="noConstantsFound";P.noMimirsFound="noMimirsFound";P.noRoutesFound="noRoutesFound";P.quoteNotFound="quoteNotFound";P.ledgerSignFailed="ledgerSignFailed";P.ledgerWrongPayload="ledgerWrongPayload";P.ledgerFetchSwapFailed="ledgerFetchSwapFailed";P.failedToFetchTx="failedToFetchTx";P.failedBuildTransactionDetails="failedBuildTransactionDetails";P.noLegsForRoute="noLegsForRoute";P.noRouterAddressFound="noRouterAddressFound";P.noAggregatorAddressFound="noAggregatorAddressFound";P.noContractInstanceFound="noContractInstanceFound";P.noContractAddressFound="noContractAddressFound";P.invalidAffiliate="invalidAffiliate";P.thornameAffiliate="thornameAffiliate";P.providerNotfound="No provider found";P.noRecordFound="No Record found";P.slippageTooLow="Slippage too low";P.tradingHalted="tradingHalted";P.noWrappedGasAsset="noWrappedGasAsset";P.aggregatorAddressNotFound="aggregatorAddressNotFound";P.routerAddressNotFound="routerAddressNotFound";P.dummyAddressNotFound="dummyAddressNotFound";P.trackerError="trackerError";P.thorchainPoolUnavailable="thorchainPoolUnavailable";P.noOhlcvDataFound="noOhlcvDataFound";P.noTradingPairs="noTradingPairs";P.noLendingAvailability="noLendingAvailability";P.lendingRepayTooSmall="lendingRepayTooSmall";P.missingState="missingState";P.ledgerSwapNotFound="ledgerSwapNotFound";P.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";P.errorEstimatingGas="errorEstimatingGas";P.apiKeyInvalid="apiKeyInvalid";P.apiKeyFailedToUpdate="apiKeyFailedToUpdate";P.apiKeyExpired="apiKeyExpired";P.unauthorized="unauthorized";P.failedToCreateMemo="failedToCreateMemo";P.radixIncorrectInstructions="radixIncorrectInstructions";P.radixTxMissedParam="radixTxMissedParam";P.radixTxMissedAccount="radixTxMissedAccount";P.radixManifestParseError="radixManifestParseError";P.radixManifestBuildError="radixManifestBuildError";P.invalidAddressForChain="invalidAddressForChain";P.riskyAddress="riskyAddress";P.noRoutesToProcess="noRoutesToProcess";P.sellAssetAmountTooSmall="sellAssetAmountTooSmall";P.missingPrivateKey="missingPrivateKey";P.noMemoPriceProtection="noMemoPriceProtection"})(mF||={});var dF;((x)=>{x.highSlippage="highSlippage";x.highPriceImpact="highPriceImpact"})(dF||={});var oF;((M)=>{M.CAVIAR_V1="CAVIAR_V1";M.CAMELOT_V3="CAMELOT_V3";M.CHAINFLIP="CHAINFLIP";M.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";M.JUPITER="JUPITER";M.MAYACHAIN="MAYACHAIN";M.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";M.OCISWAP_V1="OCISWAP_V1";M.ONEINCH="ONEINCH";M.OPENOCEAN_V2="OPENOCEAN_V2";M.PANCAKESWAP="PANCAKESWAP";M.PANGOLIN_V1="PANGOLIN_V1";M.SUSHISWAP_V2="SUSHISWAP_V2";M.THORCHAIN="THORCHAIN";M.THORCHAIN_STREAMING="THORCHAIN_STREAMING";M.TRADERJOE_V2="TRADERJOE_V2";M.UNISWAP_V2="UNISWAP_V2";M.UNISWAP_V3="UNISWAP_V3";M.NEAR="NEAR"})(oF||={});var hF;((_)=>{_.LIQUIDITY="liquidity";_.NETWORK="network";_.INBOUND="inbound";_.OUTBOUND="outbound";_.AFFILIATE="affiliate";_.TAX="tax";_.PRIORITY="priority"})(hF||={});var YF;((N)=>{N.Average="average";N.Fast="fast";N.Fastest="fastest"})(YF||={});var cF;((x)=>{x.Approve="approve";x.CheckOnly="checkOnly"})(cF||={});var JF;((z)=>{z.NAME_REGISTER="~";z.BOND="BOND";z.DEPOSIT="+";z.LEAVE="LEAVE";z.UNBOND="UNBOND";z.WITHDRAW="-";z.RUNEPOOL_DEPOSIT="POOL+";z.RUNEPOOL_WITHDRAW="POOL-";z.CLAIM_TCY="tcy";z.STAKE_TCY="tcy+";z.UNSTAKE_TCY="tcy-"})(JF||={});var l;((G)=>{G.BITGET="BITGET";G.BRAVE="BRAVE";G.COINBASE_MOBILE="COINBASE_MOBILE";G.COINBASE_WEB="COINBASE_WEB";G.COSMOSTATION="COSMOSTATION";G.CTRL="CTRL";G.EIP6963="EIP6963";G.EXODUS="EXODUS";G.KEEPKEY="KEEPKEY";G.KEEPKEY_BEX="KEEPKEY_BEX";G.KEPLR="KEPLR";G.KEYSTORE="KEYSTORE";G.LEAP="LEAP";G.LEDGER="LEDGER";G.LEDGER_LIVE="LEDGER_LIVE";G.METAMASK="METAMASK";G.OKX="OKX";G.OKX_MOBILE="OKX_MOBILE";G.ONEKEY="ONEKEY";G.PHANTOM="PHANTOM";G.POLKADOT_JS="POLKADOT_JS";G.RADIX_WALLET="RADIX_WALLET";G.TREZOR="TREZOR";G.TALISMAN="TALISMAN";G.TRONLINK="TRONLINK";G.TRUSTWALLET_WEB="TRUSTWALLET_WEB";G.VULTISIG="VULTISIG";G.WALLETCONNECT="WALLETCONNECT";G.XAMAN="XAMAN"})(l||={});var lF;((N)=>{N[N.NoError=36864]="NoError";N[N.LockedDevice=21781]="LockedDevice";N[N.TC_NotFound=65535]="TC_NotFound"})(lF||={});var sF={apis:{},chains:Object.values(q),wallets:Object.values(l),explorerUrls:$F,nodeUrls:m,rpcUrls:h,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},U=nF((F)=>({...sF,setApiKey:($,x)=>F((N)=>({apiKeys:{...N.apiKeys,[$]:x}})),setEnv:($,x)=>F((N)=>({envs:{...N.envs,[$]:x}})),setExplorerUrl:($,x)=>F((N)=>({explorerUrls:{...N.explorerUrls,[$]:x}})),setNodeUrl:($,x)=>F((N)=>({nodeUrls:{...N.nodeUrls,[$]:x}})),setRpcUrl:($,x)=>F((N)=>({rpcUrls:{...N.rpcUrls,[$]:x}})),setIntegrationConfig:($,x)=>F((N)=>({integrations:{...N.integrations,[$]:x}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setConfig:($)=>F((x)=>({apiKeys:{...x.apiKeys,...$.apiKeys},envs:{...x.envs,...$.envs},explorerUrls:{...x.explorerUrls,...$.explorerUrls},integrations:{...x.integrations,...$.integrations},nodeUrls:{...x.nodeUrls,...$.nodeUrls},rpcUrls:{...x.rpcUrls,...$.rpcUrls},feeMultipliers:$.feeMultipliers||x.feeMultipliers,chains:x.chains.concat($.chains||[]),wallets:x.wallets.concat($.wallets||[])}))})),I={getState:U.getState,get:(F)=>U.getState()[F],set:(F)=>U.getState().setConfig(F),setApiKey:(F,$)=>U.getState().setApiKey(F,$),setEnv:(F,$)=>U.getState().setEnv(F,$),setExplorerUrl:(F,$)=>U.getState().setExplorerUrl(F,$),setNodeUrl:(F,$)=>U.getState().setNodeUrl(F,$),setRpcUrl:(F,$)=>U.getState().setRpcUrl(F,$),setIntegrationConfig:(F,$)=>U.getState().setIntegrationConfig(F,$),setFeeMultipliers:(F)=>U.getState().setFeeMultipliers(F)};var xx=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],LF=["ARB","AURORA","BASE","ETH","OP"];async function tF({chain:F,to:$}){try{let{result:N}=await b.post(I.get("rpcUrls")[F],{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(N||X[F]).toString())}catch(N){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,N),X[F]}}async function rF(F){if(F==="XRD")return X.XRD;try{let $=F.split("-")[1]?.toLowerCase(),{manager:x}=await b.post(`${I.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:$})});return x.divisibility.value.divisibility}catch($){return console.error(`Failed to fetch Radix asset decimal for ${F}:`,$),X["XRD"]}}async function iF({chain:F,symbol:$}){if(S.includes($))return X[$];let x=$.split("-"),N=x.length===1?void 0:x[x.length-1]?.toLowerCase();return await(N?.startsWith("0x")?tF({chain:F,to:N}):X[F])}function jF({chain:F,symbol:$}){return n(F).with(...S,(x)=>iF({chain:x,symbol:$})).with("XRD",()=>rF($)).otherwise(()=>X[F])}function Nx({chain:F}){return O.from({chain:F})}function qF({chain:F,symbol:$}){return n(F).with(...LF,()=>$==="ETH").with("AVAX",()=>$==="AVAX").with("BERA",()=>$==="BERA").with("BSC",()=>$==="BNB").with("GNO",()=>$==="XDAI").with("MAYA",()=>$==="CACAO").with("GAIA",()=>$==="ATOM").with("THOR",()=>$==="RUNE").with("TRON",()=>$==="TRX").with("XRD",()=>`${F}.${$}`===s(F).identifier).otherwise(()=>$===F)}var s=(F)=>{let $=X[F];return n(F.toUpperCase()).with(...LF,(N)=>({identifier:`${N}.ETH`,decimal:$})).with("THOR",(N)=>({identifier:`${N}.RUNE`,decimal:$})).with("GAIA",(N)=>({identifier:`${N}.ATOM`,decimal:$})).with("MAYA",(N)=>({identifier:`${N}.CACAO`,decimal:10})).with("BSC",(N)=>({identifier:`${N}.BNB`,decimal:$})).with("AVAX",(N)=>({identifier:`${N}.AVAX`,decimal:$})).with("GNO",(N)=>({identifier:`${N}.XDAI`,decimal:$})).with("BERA",(N)=>({identifier:`${N}.BERA`,decimal:$})).with("TRON",(N)=>({identifier:`${N}.TRX`,decimal:$})).with(...TF,"SOL","FLIP","KUJI","XRP","DOT","NEAR",(N)=>({identifier:`${N}.${N}`,decimal:$})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:$})).with("POL","POL.POL",()=>({identifier:"POL.POL",decimal:$})).with("KUJI.USK",(N)=>({identifier:N,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:X.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:X.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:X.ETH})).with("MAYA.CACAO",(N)=>({identifier:N,decimal:10})).with("MAYA.MAYA",(N)=>({identifier:N,decimal:4})).otherwise(()=>({identifier:F,decimal:$}))};function NF({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return n(F).with("XRD",()=>$==="XRD"||`${F}.${$}`===s(F).identifier).with("ARB","OP","BASE","AURORA",()=>$==="ETH").with("GAIA",()=>$==="ATOM").with("BSC",()=>$==="BNB").with("MAYA",()=>$==="CACAO").with("THOR",()=>$==="RUNE").with("TRON",()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var HF=(F)=>{let[$,...x]=F.split("."),N=F.includes("/"),H=x.join("."),R=H?.split("-"),A=R?.length?R.length===1?R[0]:R.slice(0,-1).join("-"):void 0;return{chain:$,symbol:H,ticker:A,synth:N}};async function Hx(F){let{loadTokenLists:$}=await import("./tokens.js"),x=await $();for(let N of Object.values(x))for(let{identifier:H,chain:R,...A}of N.tokens){if("identifier"in F&&H===F.identifier)return H;if("address"in A&&"chain"in F&&R===F.chain&&A.address&&A.address.toLowerCase()===F.contract.toLowerCase())return H}return}function Tx(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function Bx(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function Qx(F,$){try{return F()}catch(x){if($)throw new J($,x);return}}function zx(F){switch(F){case"THOR":return`${F}.RUNE`;case"GAIA":return`${F}.ATOM`;case"BSC":return`${F}`;default:return`${F}.${F}`}}var WF=new Set;function t(F,$){if(F){if(WF.has($))return;WF.add($)}}async function Zx(F="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(F))return F;try{let $=I.get("rpcUrls")[F!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await b.get(`${$}/status`)).result.node_info.network}catch($){return F}}var UF=["TERRA",...I.get("chains")];function VF(F=""){let $=F.toUpperCase(),[x]=$.split(".");if(UF.includes(x))return!0;let[N]=$.split("/");if(UF.includes(N))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:F}})}function Xx(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var C=8,g=(F)=>10n**BigInt(F),p=(F)=>Math.log10(Number.parseFloat(F.toString()));function y({value:F,bigIntDecimal:$=C,decimal:x=C}){if(x===0)return F.toString();let N=F<0n,H=F.toString().substring(N?1:0),R=x-(H.length-1);if(R>0)H="0".repeat(R)+H;let A=H.length-x,_=H.slice(-x);if(Number.parseInt(_[$]||"0")>=5)_=`${_.substring(0,$-1)}${(Number.parseInt(_[$-1]||"0")+1).toString()}`;else _=_.substring(0,$);return`${N?"-":""}${H.slice(0,A)}.${_}`.replace(/\.?0*$/,"")}function aF(F,$){if($===0n)throw new Error("Cannot divide by zero");let x=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+x)/$;return(F-x)/$}class f{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new f({decimal:$,value:y({value:F,bigIntDecimal:$,decimal:$})})}static shiftDecimals({value:F,from:$,to:x}){return f.fromBigInt(F.getBaseValue("bigint")*g(x)/g($),x)}constructor(F){let $=PF(F),x=typeof F==="object";this.decimal=x?F.decimal:void 0,this.decimalMultiplier=x&&"decimalMultiplier"in F?F.decimalMultiplier:g(Math.max(kF(r($)),this.decimal||0)),this.#H($)}set(F){return new this.constructor({decimal:this.decimal,value:F,identifier:this.toString({includeSynthProtocol:!0})})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let x=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||p(this.decimalMultiplier));switch(F){case"number":return Number(x);case"string":return x;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return x}}getBaseValue(F,$){let x=this.decimalMultiplier/g($||this.decimal||X.THOR),N=aF(this.bigIntValue,x);switch(F){case"number":return Number(N);case"string":return N.toString();case"bigint":return N;default:return N}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let x=PF(F),N=r(x);if(N==="0"||N==="undefined")return 0n;return this.#N(N,$)}toSignificant(F=6){let[$,x]=this.getValue("string").split("."),N=$||"",H=x||"";if((Number.parseInt(N)?N.length+H.length:H.length)<=F)return this.getValue("string");if(N.length>=F)return N.slice(0,F).padEnd(N.length,"0");if(Number.parseInt(N))return`${N}.${H.slice(0,F-N.length)}`.padEnd(F-N.length,"0");let A=Number.parseInt(H),_=`${A}`.slice(0,F);return`0.${_.padStart(H.length-`${A}`.length+_.length,"0")}`}toFixed(F=6){let[$,x]=this.getValue("string").split("."),N=$||"",H=x||"";if(Number.parseInt(N))return`${N}.${H.slice(0,F)}`.padEnd(F,"0");let R=Number.parseInt(H),A=`${R}`.slice(0,F);return`0.${A.padStart(H.length-`${R}`.length+A.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),x=["","K","M","B","T","Q","Qi","S"],N=Math.floor(Math.log10(Math.abs($))/3),H=x[N];if(!H)return this.getValue("string");let R=10**(N*3);return`${($/R).toFixed(F)}${H}`}toCurrency(F="$",{currencyPosition:$="start",decimal:x=2,decimalSeparator:N=".",thousandSeparator:H=","}={}){let R=this.getValue("number"),[A="",_=""]=R.toFixed(6).split("."),T=A.replace(/\B(?=(\d{3})+(?!\d))/g,H),Q=A||_?A==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",N):`${T}${Number.parseInt(_)?`${N}${_.slice(0,x)}`:""}`:"0.00";return`${$==="start"?F:""}${Q}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let x=$||this.decimal||C,N=Math.max(x,p(this.decimalMultiplier)),H=F<0n,R=F.toString().substring(H?1:0),A=N-(R.length-1),_=A>0?"0".repeat(A)+R:R,T=_.length-N,Q=_.slice(-N);if(Number.parseInt(Q[x]||"0")>=5)Q=`${Q.substring(0,x-1)}${(Number.parseInt(Q[x-1]||"0")+1).toString()}`;else Q=Q.substring(0,x);return`${H?"-":""}${_.slice(0,T)}.${Q}`.replace(/\.?0*$/,"")}#$(F,...$){let x=this.#x(this,...$),N=Math.max(x,p(this.decimalMultiplier)),H=g(N),R=$.reduce((_,T)=>{let Q=this.getBigIntValue(T,N);switch(F){case"add":return _+Q;case"sub":return _-Q;case"mul":return _*Q/H;case"div":{if(Q===0n)throw new RangeError("Division by zero");return _*H/Q}default:return _}},this.bigIntValue*H/this.decimalMultiplier),A=y({bigIntDecimal:N,decimal:N,value:R});return new this.constructor({decimalMultiplier:g(N),decimal:this.decimal,value:A,identifier:this.toString()})}#F(F,...$){let x=this.#x(this,...$),N=this.getBigIntValue($[0]||"0",x),H=this.getBigIntValue(this,x);switch(F){case"gt":return H>N;case"gte":return H>=N;case"lt":return H<N;case"lte":return H<=N;case"eqValue":return H===N;default:return!1}}#H(F){let $=r(F)||"0";this.bigIntValue=this.#N($)}#x(...F){let $=F.map((x)=>{return typeof x==="object"?x.decimal||p(x.decimalMultiplier):kF(r(x))}).filter(Boolean);return Math.max(...$,C)}#N(F,$){let x=$?g($):this.decimalMultiplier,N=p(x),[H="",R=""]=F.split(".");return BigInt(`${H}${R.padEnd(N,"0")}`)}}var eF=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function r(F){let x=`${typeof F==="number"?eF.format(F):PF(F)}`.replaceAll(",",".").split(".");return x.length>1?`${x.slice(0,-1).join("")}.${x.at(-1)}`:x[0]||"0"}function kF(F){let $=F.split(".")[1]?.length||0;return Math.max($,C)}function PF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var i=["SOL","TRON"],v=new Map;class O extends f{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:x,chain:N,symbol:H,identifier:R}){super(typeof F==="object"?F:{decimal:$,value:F});let A=RF(R||`${N}.${H}`);this.type=NF(A),this.tax=x,this.chain=A.chain,this.ticker=A.ticker,this.symbol=A.symbol,this.address=A.address,this.isSynthetic=A.isSynthetic,this.isTradeAsset=A.isTradeAsset,this.isGasAsset=A.isGasAsset,this.chainId=QF[A.chain]}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?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:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let[x,N,H]=F.split(".");if(!(x&&N))throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let R=x==="THOR"&&H?`${x}.${N}/${H}`:F;return O.from({asset:R,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:x,...N}){let H=F instanceof f?F.getValue("string"):F,R=N$(N),{identifier:A,decimal:_}=s(R),{chain:T,isSynthetic:Q,isTradeAsset:Y}=RF(A),z=v.get(i.includes(T)?A:A.toUpperCase()),V=z?.decimal||_;t(!(x||V),`Couldn't find static decimal for one or more tokens on ${T} (Using default ${X[T]} 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:j,identifier:L,tax:w}=z||{decimal:V||X[T],identifier:A},k=Q||Y,D=$?a(BigInt(H),$):a(H,j);return x?F$(L,$?D:H):k?$$(L,D):new O({tax:w,decimal:j,identifier:L,value:D})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),x=await $(F);for(let{tokens:N}of Object.values(x))for(let{identifier:H,chain:R,...A}of N){let _=i.includes(R)?H:H.toUpperCase(),T="decimals"in A?A.decimals:X[R];v.set(_,{identifier:H,decimal:T})}return!0}static setStaticAssets(F){v.clear();for(let[$,x]of F.entries()){let N=i.includes(x.chain)?x.identifier:x.identifier.toUpperCase(),H="decimals"in x?x.decimals:x.decimal;v.set($,{...x,decimal:H,identifier:N})}return!0}}function Ox(F){let $=O.from({chain:F});return KF(F).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 F$(F,$=0){VF(F);let N=F.includes("SOL.")?F:F.toUpperCase(),H=v.get(N),R=H?.decimal||await jF(RF(F));if(!H)v.set(N,{identifier:F,decimal:R});return new O({decimal:R,value:a($,R),identifier:F})}function $$(F,$=0){let x=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,N=x?["MAYA","THOR"].includes(x):!1,H=F.slice(0,14).includes("~")?"~":"/",[R,A]=N?F.split(".").slice(1).join().split(H):F.split(H);if(!(R&&A))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new O({decimal:8,value:a($,8),identifier:`${x||"THOR"}.${R}${H}${A}`})}function a(F,$){return typeof F==="bigint"?y({value:F,bigIntDecimal:$,decimal:$}):F}function x$(F){let $=KF(F).when((x)=>("chain"in x)&&x.chain!==void 0,({chain:x})=>x).otherwise((x)=>{let N=HF(x.asset);return N.synth?"THOR":N.chain});if(!Object.values(q).includes($.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function N$(F){if(x$(F),"chain"in F)return F.chain;let{chain:$,symbol:x}=HF(F.asset);return NF({chain:$,symbol:x})==="Native"?$:F.asset}function RF(F){let $=F.slice(0,14),x=F.split("."),N=x[0]?.toUpperCase(),H=["THOR","MAYA"].includes(N),R=$.includes("/"),A=$.includes("~"),_=R||A,T=A?"~":"/",[Q,Y=""]=H?x.slice(1).join().split(T):F.split(T);if(_&&!(Q&&Y))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let[z,...V]=(F.includes(".")&&!_?F:`${N}.${Y}`).split("."),j=_?Y:V.join("."),{address:L,ticker:w}=H$({symbol:j,chain:z}),k;try{k=L&&S.includes(z)&&IF(L)?IF(L):L}catch(u){k=L}let D=(_?`${Q}${T}`:"")+(k?`${w}-${k??""}`:j);return{address:k,chain:z,isSynthOrTrade:_,isSynthetic:R,isTradeAsset:A,ticker:w,symbol:D,isGasAsset:qF({chain:z,symbol:j})}}function H$({symbol:F,chain:$}){let x=F.split("-"),N=x.length===1?void 0:x[x.length-1],H=i.includes($)?N:N?.toLowerCase(),R=x.length===1?x[0]:x.slice(0,-1).join("-");return{address:H,ticker:R}}class K extends f{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new K({decimal:$,value:y({value:F,bigIntDecimal:$,decimal:$})})}}var P$={average:1,fast:1.5,fastest:2};function wF(F="average"){let $=I.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return P$[F]}function R$(F="average"){let $=wF(F),x=10n;return{numerator:BigInt(Math.round($*10)),denominator:x}}function Ex(F,$="average"){let{numerator:x,denominator:N}=R$($);return F*x/N}function yx(F,$="average",x=!1){let N=wF($),H=F*N;return x?Math.floor(H):H}import{Chain as Z,ChainToExplorerUrl as DF}from"@swapkit/helpers";import{match as OF}from"ts-pattern";function mx({chain:F,txHash:$}){let x=DF[F];return OF(F).with(Z.Maya,Z.Kujira,Z.Noble,Z.Cosmos,Z.THORChain,Z.Solana,()=>`${x}/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,()=>`${x}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(Z.Litecoin,Z.Bitcoin,Z.BitcoinCash,Z.Dogecoin,Z.Zcash,Z.Radix,()=>`${x}/transaction/${$.toLowerCase()}`).with(Z.Near,()=>`${x}/txns/${$}`).with(Z.Ripple,()=>`${x}/transactions/${$}`).with(Z.Tron,()=>`${x}/#/transaction/${$}`).otherwise(()=>"")}function dx({chain:F,address:$}){let x=DF[F];return OF(F).with(Z.Solana,Z.Radix,()=>`${x}/account/${$}`).with(Z.Tron,()=>`${x}/#/address/${$}`).otherwise(()=>`${x}/address/${$}`)}function A$({liquidityUnits:F,poolUnits:$,runeDepth:x}){let N=W(F),H=W($),R=W(x),A=N.mul(R),_=H.mul(H).mul(2),T=H.mul(N).mul(2),Q=N.mul(N),Y=H.mul(H).mul(H);return A.mul(_.sub(T).add(Q)).div(Y)}function _$({liquidityUnits:F,poolUnits:$,assetDepth:x}){let N=W(F),H=W($),R=W(x),A=N.mul(R),_=H.mul(H).mul(2),T=H.mul(N).mul(2),Q=N.mul(N),Y=A.mul(_.sub(T).add(Q)),z=H.mul(H).mul(H);return Y.div(z)}function lx({percent:F,runeDepth:$,liquidityUnits:x,poolUnits:N}){return A$({runeDepth:$,liquidityUnits:x,poolUnits:N}).mul(F)}function nx({percent:F,assetDepth:$,liquidityUnits:x,poolUnits:N}){return _$({assetDepth:$,liquidityUnits:x,poolUnits:N}).mul(F)}function W(F){return K.fromBigInt(BigInt(F),X.THOR)}function G$({liquidityUnits:F,poolUnits:$,runeDepth:x,assetDepth:N}){return{assetAmount:W(N).mul(F).div($),runeAmount:W(x).mul(F).div($)}}function sx({liquidityUnits:F,poolUnits:$,runeDepth:x,assetDepth:N,percent:H}){return Object.fromEntries(Object.entries(G$({liquidityUnits:F,poolUnits:$,runeDepth:x,assetDepth:N})).map(([R,A])=>[R,A.mul(H)]))}function tx({runeDepth:F,poolUnits:$,assetDepth:x,liquidityUnits:N,runeAmount:H,assetAmount:R}){let A=new K({value:F,decimal:8}),_=new K({value:x,decimal:8}),T=new K({value:$,decimal:8}),Q=new K({value:H,decimal:8}),Y=new K({value:R,decimal:8}),z=Q.mul(_),V=Y.mul(A),j=Q.mul(Y),L=A.mul(_),w=T.mul(z.add(V.add(j.mul(2)))),k=z.add(V.add(L.mul(2))),D=w.div(k),u=W(N).add(D);if(D.getBaseValue("number")===0)return u.div(T).getBaseValue("number");let M=T.add(u);return u.div(M).getBaseValue("number")}function rx({runeAmount:F,assetAmount:$,runeDepth:x,assetDepth:N}){if(F==="0"||$==="0"||x==="0"||N==="0")return 0;let H=W(x),R=W(N),A=W($),_=W(F),T=A.mul(H).sub(R.mul(_)),Q=R.mul(_).add(H.mul(R));return Math.abs(T.div(Q).getBaseValue("number"))}import{match as T$}from"ts-pattern";function $N({type:F,address:$}){return`${F}:${$}`}function xN({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function NN(F){return e("POOL+",F)}function HN({chain:F,symbol:$,address:x,...N}){let H=B$({chain:F,symbol:$}),R=x?`:${x}:`:":";return e(`${"+"}:${H}${R}`,N)}function PN({chain:F,symbol:$,ticker:x,basisPoints:N,targetAsset:H}){let R=F==="ETH"&&x!=="ETH"?`${x}-${$.slice(-3)}`:$,A=H?`:${H}`:"";return`${"-"}:${F}.${R}:${N}${A}`}function RN({basisPoints:F,...$}){return e(`${"POOL-"}:${F}`,$)}function AN({name:F,chain:$,address:x,owner:N}){let H=`${"~"}:${F}:${$}:${x}`,R=N?`:${N}`:"";return`${H}${R}`}function _N({name:F,chain:$,asset:x,payout:N,owner:H}){return`${"~"}:${F}:${$}:${N}:${H}:${x}`}function GN(F,{address:$}){return`${F}:${$}`}function TN(F,{unstakeBps:$,...x}){let N=$?`:${$}`:"",H=`${F}${N}`;return e(`${H}`,x)}function e(F,{affiliateAddress:$,affiliateBasisPoints:x}={}){let N=`${F}${$?`:${$}:${x||0}`:""}`;return N.endsWith(":")?N.slice(0,-1):N}function B$({chain:F,symbol:$}){return T$(F).with("BTC","DOGE","LTC",()=>F.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${F}.${$}`)}function YN(){return typeof window.ethereum!=="undefined"}function JN(F){return Q$().includes(F)}function Q$(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,x=window?.vultisig,N=window?.ethereum?.isBraveWallet,H=window?.ethereum?.isTrust||window?.trustwallet,R=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,_=window?.$onekey?.ethereum,T=[];if(F)T.push("METAMASK");if($)T.push("CTRL");if(x)T.push("VULTISIG");if(N)T.push("BRAVE");if(H)T.push("TRUSTWALLET_WEB");if(R)T.push("COINBASE_WEB");if(J$())T.push("OKX_MOBILE");if(A)T.push("BITGET");if(_)T.push("ONEKEY");return T}async function z$(F,$,x){try{await fF({provider:F,method:"wallet_switchEthereumChain",params:[{chainId:zF[$]}]})}catch(N){if(!x)throw new J("helpers_failed_to_switch_network",{error:N,reason:"networkParams not provided"});await Y$(F,x)}}function MN({chains:F,supportedChains:$,walletType:x}){let N=F.filter((R)=>!R||$.includes(R));if(N.length===0)throw new J("wallet_chain_not_supported",{wallet:x,chain:F.join(", ")});let H=F.filter((R)=>!$.includes(R));return t(H.length>0,`${x} wallet does not support the following chains: ${H.join(", ")}. These chains will be ignored.`),N}function Z$(F,$,x){return async(...N)=>{try{await z$($,x)}catch(H){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:H}})}return F(...N)}}function XN({toolbox:F,chain:$,provider:x=window.ethereum,methodNames:N=[]}){let R=[...N,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((A,_)=>{if(!F[_])return A;let T=F[_];if(typeof T!=="function")return A;let Q=Z$(T,x,$);return{...A,[_]:Q}},{});return{...F,...R}}function Y$(F,$){return fF({provider:F,method:"wallet_addEthereumChain",params:[$]})}function LN(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function jN(){let{isTrust:F,isBraveWallet:$,__XDEFI:x,overrideIsMetaMask:N,selectedProvider:H}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(N&&H?.isCoinbaseWallet)return"COINBASE_WEB";if(x)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function qN(){let F=[];function $(N){if(F.map((H)=>H.info.uuid).includes(N.detail.info.uuid))return;F.push(N.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function x(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:x}}function J$(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),x=/android|XiaoMi|MiuiBrowser/i.test(F),N=$||x,H=/OKApp/i.test(F);return N&&H}function fF({provider:F,params:$,method:x}){if(!F?.send)throw new J("helpers_not_found_provider");let N=$?Array.isArray($)?$:[$]:[];return F.send(x,N)}export{Qx as wrapWithThrow,Z$ as wrapMethodWithNetworkSwitch,t as warnOnce,Xx as validateTNS,VF as validateIdentifier,xF as updateDerivationPath,z$ as switchEVMWalletNetwork,fF as providerRequest,XN as prepareNetworkSwitch,J$ as okxMobileEnabled,Q$ as listWeb3EVMWallets,YN as isWeb3Detected,qF as isGasAsset,JN as isDetected,k$ as initializeRPCUrlsWithFallback,S$ as getWalletFormatFor,Tx as getTHORNameCost,sx as getSymmetricWithdraw,G$ as getSymmetricPoolShare,Ox as getMinAmountByChain,PN as getMemoForWithdraw,xN as getMemoForUnbond,TN as getMemoForTcyStake,GN as getMemoForTcyClaim,RN as getMemoForRunePoolWithdraw,NN as getMemoForRunePoolDeposit,AN as getMemoForNameRegister,_N as getMemoForNamePreferredAssetRegister,$N as getMemoForLeaveAndBond,HN as getMemoForDeposit,Bx as getMAYANameCost,rx as getLiquiditySlippage,Nx as getGasAsset,R$ as getFeeMultiplierAsBigInt,wF as getFeeMultiplier,mx as getExplorerTxUrl,dx as getExplorerAddressUrl,tx as getEstimatedPoolShare,jN as getETHDefaultWallet,qN as getEIP6963Wallets,Zx as getDynamicChainId,f$ as getDerivationPathFor,jF as getDecimal,s as getCommonAssetInfo,zx as getChainIdentifier,lx as getAsymmetricRuneWithdrawAmount,A$ as getAsymmetricRuneShare,nx as getAsymmetricAssetWithdrawAmount,_$ as getAsymmetricAssetShare,NF as getAssetType,y as formatBigIntToSafeValue,Hx as findAssetBy,MN as filterSupportedChains,ZF as derivationPathToString,HF as assetFromString,Ex as applyFeeMultiplierToBigInt,yx as applyFeeMultiplier,Y$ as addEVMWalletNetwork,LN as addAccountsChangedCallback,dF as WarningCodeEnum,l as WalletOption,TF as UTXOChains,K as SwapKitNumber,J as SwapKitError,W$ as SubstrateChains,FF as StagenetChain,I as SKConfig,b as RequestClient,h as RPC_URLS,oF as ProviderName,E as NetworkDerivationPath,m as NODE_URLS,JF as MemoType,lF as LedgerErrorCode,hF as FeeTypeEnum,YF as FeeOption,vF as FALLBACK_URLS,mF as ErrorCode,$F as EXPLORER_URLS,S as EVMChains,b$ as DerivationPath,P$ as DEFAULT_FEE_MULTIPLIERS,U$ as CosmosChains,V$ as CosmosChainPrefixes,CF as ContractAddress,xx as CommonAssetStrings,zF as ChainToHexChainId,I$ as ChainToExplorerUrl,QF as ChainToChainId,j$ as ChainIdToChain,d as ChainId,q as Chain,q$ as BlockTimes,f as BigIntArithmetics,X as BaseDecimal,O as AssetValue,cF as ApproveMode};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=CB28C8129F30D5FC64756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|