@swapkit/helpers 4.0.0-beta.27 → 4.0.0-beta.29
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 +3 -3
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
- package/src/modules/swapKitError.ts +3 -0
- package/src/types/chains.ts +4 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{o as X,q as G}from"./chunk-ganzk321.js";import{getAddress as gn}from"ethers";import{match as zn}from"ts-pattern";import{match as _n}from"ts-pattern";var Jn={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_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 k extends Error{static ErrorCode=Jn;constructor(n,h){let C=typeof n==="string",T=C?n:n.errorKey,R=C?void 0:n.info,P=`${T}${R?`: ${JSON.stringify(R)}`:""}`;super(P);if(Object.setPrototypeOf(this,k.prototype),this.name="SwapKitError",this.cause=h,h)console.error(`SwapKitError [${T}]:`,h);else if(R)console.error(`SwapKitError [${T}]:`,R)}}var I;((M)=>{M.Arbitrum="ARB";M.Avalanche="AVAX";M.Base="BASE";M.BinanceSmartChain="BSC";M.Bitcoin="BTC";M.BitcoinCash="BCH";M.Cosmos="GAIA";M.Dash="DASH";M.Dogecoin="DOGE";M.Ethereum="ETH";M.Fiat="FIAT";M.Kujira="KUJI";M.Litecoin="LTC";M.Maya="MAYA";M.Near="NEAR";M.Optimism="OP";M.Polkadot="DOT";M.Chainflip="FLIP";M.Polygon="MATIC";M.Radix="XRD";M.Ripple="XRP";M.THORChain="THOR";M.Solana="SOL";M.Tron="TRX";M.Zcash="ZEC"})(I||={});var hn;((C)=>{C.THORChain="THOR_STAGENET";C.Maya="MAYA_STAGENET"})(hn||={});var u;((H)=>{H.Arbitrum="42161";H.ArbitrumHex="0xa4b1";H.Avalanche="43114";H.AvalancheHex="0xa86a";H.Base="8453";H.BaseHex="0x2105";H.BinanceSmartChain="56";H.BinanceSmartChainHex="0x38";H.Bitcoin="bitcoin";H.BitcoinCash="bitcoincash";H.Chainflip="chainflip";H.Cosmos="cosmoshub-4";H.Dash="dash";H.Dogecoin="dogecoin";H.Kujira="kaiyo-1";H.Ethereum="1";H.EthereumHex="0x1";H.Fiat="fiat";H.Litecoin="litecoin";H.Maya="mayachain-mainnet-v1";H.MayaStagenet="mayachain-stagenet-v1";H.Near="near";H.Optimism="10";H.OptimismHex="0xa";H.Polkadot="polkadot";H.Polygon="137";H.PolygonHex="0x89";H.Radix="radix-mainnet";H.Ripple="ripple";H.THORChain="thorchain-1";H.THORChainStagenet="thorchain-stagenet-v2";H.Solana="solana";H.Tron="728126428";H.TronHex="0x2b6653dc";H.Zcash="zcash"})(u||={});var Zh={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["728126428"]:"TRX",["0x2b6653dc"]:"TRX",["zcash"]:"ZEC"},wn=Object.keys(I),v=Object.values(I),L={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,TRX:6,XRD:18,XRP:6,ZEC:8},gh={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRX"]:3,["ZEC"]:150},zh=["DOT","FLIP"],W=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Fn=["BTC","BCH","DASH","DOGE","LTC","ZEC"],Qh=["GAIA","THOR","MAYA","KUJI"],Uh={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},Yh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Jh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],m={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.mainnet.near.org",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.thorswap.net",["TRX"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://api.blockchair.com/zcash",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},E={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},Vn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",E.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRX"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:["https://api.blockchair.com/zcash"]},Cn={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io",["TRX"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},xn=m,Wn=(n)=>{return _n(n).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC","ZEC",()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with("GAIA","KUJI","MAYA","THOR","MAYA_STAGENET","THOR_STAGENET",()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with("DOT","FLIP",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("TRX","XRD","FIAT",()=>"").with("NEAR",()=>({jsonrpc:"2.0",id:"dontcare",method:"status",params:[]})).with("XRP",()=>({method:"ping",params:[{}],id:1,jsonrpc:"2.0"})).otherwise(()=>{throw new k("helpers_chain_not_supported",{chain:n})})};function cn(n){return _n(n).with("XRD",()=>"/status/network-configuration").with("TRX",()=>"/wallet/getnowblock").otherwise(()=>"")}var Hn=async(n,h)=>{try{let C=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${C}${cn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Wn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},qn=async(n)=>{let h=m[n];if(await Hn(n,h))return h;for(let C of Vn[n])if(await Hn(n,C))return C;return h},wh=async(n=[...Object.values(I),...Object.values(hn)])=>{let h={};await Promise.all(n.map(async(C)=>{let T=await qn(C);h[C]=T})),xn={...xn,...h}},Bn=v.reduce((n,h)=>{let C=wn.find((T)=>I[T]===h);if(C)n[h]=C;return n},{}),Nn=v.reduce((n,h)=>{return n[h]=u[Bn[h]],n},{}),$n=v.reduce((n,h)=>{let C=`${Bn[h]}Hex`;return n[h]=u[C],n},{}),Vh=v.reduce((n,h)=>{return n[h]=Cn[h],n},{});import{match as d}from"ts-pattern";var q={get:a("GET"),post:a("POST"),extend:(n)=>({get:a("GET",n),post:a("POST",n),extend:(h)=>q.extend({...n,...h})})};function a(n,h={}){return async(C,T={})=>{let{searchParams:R,json:P,body:x,headers:o,dynamicHeader:B}={...h,...T},_=!!P||C.endsWith(".json"),S=_?JSON.stringify(P):x;try{let F=tn(C,R),z=bn(_,{...o,...B?.()}),j=await fetch(F,{...T,method:n,body:S,headers:z});if(!j.ok){let Y=await j.text();throw new k("helpers_invalid_response",{status:j.status,statusText:j.statusText,message:Y})}let O=await j.json();return T.onSuccess?.(O)||T.responseHandler?.(O)||O}catch(F){if(T.onError)return T.onError(F);throw F}}}function bn(n,h){return{...h,...n?{"Content-Type":"application/json"}:{}}}function tn(n,h){let C=new URL(n);if(h)C.search=new URLSearchParams(h).toString();return C.toString()}import{createStore as an}from"zustand/vanilla";var Kn;(($)=>{$.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";$.TC_SUPPORTED_TO_ETH="TC-ERC20";$.TC_SUPPORTED_TO_AVAX="TC-ARC20";$.TC_SUPPORTED_TO_BSC="TC-BEP20";$.ETH_TO_TC_SUPPORTED="ERC20-TC";$.ETH_TO_ETH="ERC20-ERC20";$.ETH_TO_AVAX="ERC20-ARC20";$.ETH_TO_BSC="ERC20-BEP20";$.AVAX_TO_TC_SUPPORTED="ARC20-TC";$.AVAX_TO_ETH="ARC20-ERC20";$.AVAX_TO_AVAX="ARC20-ARC20";$.AVAX_TO_BSC="ARC20-BEP20";$.BSC_TO_TC_SUPPORTED="BEP20-TC";$.BSC_TO_ETH="BEP20-ERC20";$.BSC_TO_AVAX="BEP20-ARC20";$.BSC_TO_BSC="BEP20-BEP20"})(Kn||={});var bh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],th=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Kh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function Tn(n,h){if("index"in h)return[...n.slice(0,n.length-1),h.index];if("change"in h){let[C,T,R,,P]=n;return[C,T,R,h.change,P]}if("account"in h){let[C,T,,R,P]=n;return[C,T,h.account,R,P]}return n}function Mn([n,h,C,T,R]){let P=typeof R!=="number";if(typeof T!=="number")return`m/${n}'/${h}'/${C}'`;return`m/${n}'/${h}'/${C}'/${T}${P?"":`/${R}`}`}function fh({chain:n,index:h,addressIndex:C=0,type:T}){if(W.includes(n)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,C];return Tn(b[n],{index:h})}if(n==="SOL"){if(T==="account")return[44,501,0,h];return Tn(b[n],{index:h})}let R=n==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,R,h,0,C];case"segwit":return[49,R,0,0,h];case"legacy":return[44,R,0,0,h];default:return Tn(b[n],{index:h})}}function Eh(n){let[h,C,T]=n.split("/").map((R)=>Number.parseInt(R,10));switch(C){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Dn;((o)=>{o.ARB="0x0000000000000000000000000000000000000000";o.AVAX="0x0000000000000000000000000000000000000000";o.BASE="0x0000000000000000000000000000000000000000";o.ETH="0x0000000000000000000000000000000000000000";o.BSC="0x0000000000000000000000000000000000000000";o.MATIC="0x0000000000000000000000000000000000001010";o.OP="0x4200000000000000000000000000000000000042"})(Dn||={});var b={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRX:[44,195,0,0,0],ZEC:[44,133,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0]},mh=Object.keys(b).reduce((n,h)=>{return n[h]=Mn(b[h]),n},{});var yn;((A)=>{A.unknownError="unknownError";A.test_error="test_error";A.providerDetailsError="providerDetailsError";A.blockHeaderNotFound="blockHeaderNotFound";A.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";A.blockHashNotFoundAtHash="blockHashNotFoundAtHash";A.txHashMissing="txHashMissing";A.assetValueMissingInfo="assetValueMissingInfo";A.invalidAsset="invalidAsset";A.blockIsRequired="blockIsRequired";A.currentBlockHeaderNotFound="currentBlockHeaderNotFound";A.failedToRetrieveBalance="failedToRetrieveBalance";A.failedToRetrieveBlock="failedToRetrieveBlock";A.failedToRetrieveFees="failedToRetrieveFees";A.notImplementedBCH="notImplementedBCH";A.notImplementedDoge="notImplementedDoge";A.noPoolsFound="noPoolsFound";A.noVaultsFound="noVaultsFound";A.noTxFound="noTxFound";A.noInputCoinFound="noInputCoinFound";A.noBlockDataFound="noBlockDataFound";A.multipleCosmosMessages="multipleCosmosMessages";A.heightOrHashNotProvided="heightOrHashNotProvided";A.unknownDenom="unknownDenom";A.invalidBlockHeight="invalidBlockHeight";A.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";A.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";A.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";A.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";A.txMemoUndefined="txMemoUndefined";A.txMemoIncorrect="txMemoIncorrect";A.txTypeNotFound="txTypeNotFound";A.txNoMessage="txNoMessage";A.txNotFound="txNotFound";A.txReceiptNotFound="txReceiptNotFound";A.txParsingError="txParsingError";A.txLogsParsingError="txLogsParsingError";A.blockNotFound="blockNotFound";A.balanceNotFound="balanceNotFound";A.configError="configError";A.synthSwapDisallowed="synthSwapDisallowed";A.providerQuoteTimeout="providerQuoteTimeout";A.noQuoteResponse="noQuoteResponse";A.noPoolAssetsFound="noPoolAssetsFound";A.noThorchainPools="noThorchainPools";A.noMayachainPools="noMayachainPools";A.noThorchainNetworkInfo="noThorchainNetworkInfo";A.invalidAffiliateFee="invalidAffiliateFee";A.invalidBuyAssetAddress="invalidBuyAssetAddress";A.invalidSellAssetAddress="invalidSellAssetAddress";A.invalidSourceAddress="invalidSourceAddress";A.invalidDestinationAddress="invalidDestinationAddress";A.sourceAddressIsSmartContract="sourceAddressIsSmartContract";A.destinationAddressIsSmartContract="destinationAddressIsSmartContract";A.invalidChainId="invalidChainId";A.unsupportedChainId="unsupportedChainId";A.unsupportedEVMChainId="unsupportedEVMChainId";A.unsupportedMethod="unsupportedMethod";A.unsupportedProvider="unsupportedProvider";A.invalidParamsForMethod="invalidParamsForMethod";A.unsupportedAdapter="unsupportedAdapter";A.noWhitelistTokens="noWhitelistTokens";A.failedFetchGasPrice="failedFetchGasPrice";A.failedToCreateDepositChannel="failedToCreateDepositChannel";A.noProviderDetailsFound="noProviderDetailsFound";A.noTokenListsFound="noTokenListsFound";A.tokenNotFound="tokenNotFound";A.tokenPriceNotFound="tokenPriceNotFound";A.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";A.swapAmountTooSmall="swapAmountTooSmall";A.legsArrayIsEmpty="legsArrayIsEmpty";A.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";A.noBlockHeaderFound="noBlockHeaderFound";A.failedToSimulateSwap="failedToSimulateSwap";A.addressScreeningFailed="addressScreeningFailed";A.noLiquidtyProvidersFound="noLiquidtyProvidersFound";A.insufficientLiquidity="insufficientLiquidity";A.noInboundDataFound="noInbounDataFound";A.noInboundAddressesFound="noInboundAddressesFound";A.noInboundAddressFoundForChain="noInboundAddressFoundForChain";A.noLastBlocksFound="noLastBlocksFound";A.noVersionFound="noVersionFound";A.noConstantsFound="noConstantsFound";A.noMimirsFound="noMimirsFound";A.noRoutesFound="noRoutesFound";A.quoteNotFound="quoteNotFound";A.ledgerSignFailed="ledgerSignFailed";A.ledgerWrongPayload="ledgerWrongPayload";A.ledgerFetchSwapFailed="ledgerFetchSwapFailed";A.failedToFetchTx="failedToFetchTx";A.failedBuildTransactionDetails="failedBuildTransactionDetails";A.noLegsForRoute="noLegsForRoute";A.noRouterAddressFound="noRouterAddressFound";A.noAggregatorAddressFound="noAggregatorAddressFound";A.noContractInstanceFound="noContractInstanceFound";A.noContractAddressFound="noContractAddressFound";A.invalidAffiliate="invalidAffiliate";A.thornameAffiliate="thornameAffiliate";A.providerNotfound="No provider found";A.noRecordFound="No Record found";A.slippageTooLow="Slippage too low";A.tradingHalted="tradingHalted";A.noWrappedGasAsset="noWrappedGasAsset";A.aggregatorAddressNotFound="aggregatorAddressNotFound";A.routerAddressNotFound="routerAddressNotFound";A.dummyAddressNotFound="dummyAddressNotFound";A.trackerError="trackerError";A.thorchainPoolUnavailable="thorchainPoolUnavailable";A.noOhlcvDataFound="noOhlcvDataFound";A.noTradingPairs="noTradingPairs";A.noLendingAvailability="noLendingAvailability";A.lendingRepayTooSmall="lendingRepayTooSmall";A.missingState="missingState";A.ledgerSwapNotFound="ledgerSwapNotFound";A.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";A.errorEstimatingGas="errorEstimatingGas";A.apiKeyInvalid="apiKeyInvalid";A.apiKeyFailedToUpdate="apiKeyFailedToUpdate";A.apiKeyExpired="apiKeyExpired";A.unauthorized="unauthorized";A.failedToCreateMemo="failedToCreateMemo";A.radixIncorrectInstructions="radixIncorrectInstructions";A.radixTxMissedParam="radixTxMissedParam";A.radixTxMissedAccount="radixTxMissedAccount";A.radixManifestParseError="radixManifestParseError";A.radixManifestBuildError="radixManifestBuildError";A.invalidAddressForChain="invalidAddressForChain";A.riskyAddress="riskyAddress";A.noRoutesToProcess="noRoutesToProcess";A.sellAssetAmountTooSmall="sellAssetAmountTooSmall";A.missingPrivateKey="missingPrivateKey";A.noMemoPriceProtection="noMemoPriceProtection"})(yn||={});var fn;((C)=>{C.highSlippage="highSlippage";C.highPriceImpact="highPriceImpact"})(fn||={});var En;((p)=>{p.CAVIAR_V1="CAVIAR_V1";p.CAMELOT_V3="CAMELOT_V3";p.CHAINFLIP="CHAINFLIP";p.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";p.JUPITER="JUPITER";p.MAYACHAIN="MAYACHAIN";p.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";p.OCISWAP_V1="OCISWAP_V1";p.ONEINCH="ONEINCH";p.OPENOCEAN_V2="OPENOCEAN_V2";p.PANCAKESWAP="PANCAKESWAP";p.PANGOLIN_V1="PANGOLIN_V1";p.SUSHISWAP_V2="SUSHISWAP_V2";p.THORCHAIN="THORCHAIN";p.THORCHAIN_STREAMING="THORCHAIN_STREAMING";p.TRADERJOE_V2="TRADERJOE_V2";p.UNISWAP_V2="UNISWAP_V2";p.UNISWAP_V3="UNISWAP_V3";p.KADO="KADO";p.NEAR="NEAR"})(En||={});var un;((o)=>{o.LIQUIDITY="liquidity";o.NETWORK="network";o.INBOUND="inbound";o.OUTBOUND="outbound";o.AFFILIATE="affiliate";o.TAX="tax";o.PRIORITY="priority"})(un||={});var kn;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(kn||={});var vn;((C)=>{C.Approve="approve";C.CheckOnly="checkOnly"})(vn||={});var pn;((F)=>{F.NAME_REGISTER="~";F.BOND="BOND";F.DEPOSIT="+";F.LEAVE="LEAVE";F.UNBOND="UNBOND";F.WITHDRAW="-";F.RUNEPOOL_DEPOSIT="POOL+";F.RUNEPOOL_WITHDRAW="POOL-";F.CLAIM_TCY="tcy";F.STAKE_TCY="tcy+";F.UNSTAKE_TCY="tcy-"})(pn||={});var i;((N)=>{N.BITGET="BITGET";N.BRAVE="BRAVE";N.COINBASE_MOBILE="COINBASE_MOBILE";N.COINBASE_WEB="COINBASE_WEB";N.COSMOSTATION="COSMOSTATION";N.CTRL="CTRL";N.EIP6963="EIP6963";N.EXODUS="EXODUS";N.KEEPKEY="KEEPKEY";N.KEEPKEY_BEX="KEEPKEY_BEX";N.KEPLR="KEPLR";N.KEYSTORE="KEYSTORE";N.LEAP="LEAP";N.LEDGER="LEDGER";N.LEDGER_LIVE="LEDGER_LIVE";N.METAMASK="METAMASK";N.OKX="OKX";N.OKX_MOBILE="OKX_MOBILE";N.ONEKEY="ONEKEY";N.PHANTOM="PHANTOM";N.POLKADOT_JS="POLKADOT_JS";N.RADIX_WALLET="RADIX_WALLET";N.TREZOR="TREZOR";N.TALISMAN="TALISMAN";N.TRUSTWALLET_WEB="TRUSTWALLET_WEB";N.WALLETCONNECT="WALLETCONNECT";N.XAMAN="XAMAN"})(i||={});var mn;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(mn||={});var dn={apis:{},chains:Object.values(I),wallets:Object.values(i),explorerUrls:Cn,nodeUrls:E,rpcUrls:m,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},g=an((n)=>({...dn,setApiKey:(h,C)=>n((T)=>({apiKeys:{...T.apiKeys,[h]:C}})),setEnv:(h,C)=>n((T)=>({envs:{...T.envs,[h]:C}})),setExplorerUrl:(h,C)=>n((T)=>({explorerUrls:{...T.explorerUrls,[h]:C}})),setNodeUrl:(h,C)=>n((T)=>({nodeUrls:{...T.nodeUrls,[h]:C}})),setRpcUrl:(h,C)=>n((T)=>({rpcUrls:{...T.rpcUrls,[h]:C}})),setIntegrationConfig:(h,C)=>n((T)=>({integrations:{...T.integrations,[h]:C}})),setFeeMultipliers:(h)=>n(()=>({feeMultipliers:h})),setConfig:(h)=>n((C)=>({apiKeys:{...C.apiKeys,...h.apiKeys},envs:{...C.envs,...h.envs},explorerUrls:{...C.explorerUrls,...h.explorerUrls},integrations:{...C.integrations,...h.integrations},nodeUrls:{...C.nodeUrls,...h.nodeUrls},rpcUrls:{...C.rpcUrls,...h.rpcUrls},feeMultipliers:h.feeMultipliers||C.feeMultipliers,chains:C.chains.concat(h.chains||[]),wallets:C.wallets.concat(h.wallets||[])}))})),Q={getState:g.getState,get:(n)=>g.getState()[n],set:(n)=>g.getState().setConfig(n),setApiKey:(n,h)=>g.getState().setApiKey(n,h),setEnv:(n,h)=>g.getState().setEnv(n,h),setExplorerUrl:(n,h)=>g.getState().setExplorerUrl(n,h),setNodeUrl:(n,h)=>g.getState().setNodeUrl(n,h),setRpcUrl:(n,h)=>g.getState().setRpcUrl(n,h),setIntegrationConfig:(n,h)=>g.getState().setIntegrationConfig(n,h),setFeeMultipliers:(n)=>g.getState().setFeeMultipliers(n)};var $C=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],Ln=["ARB","BASE","ETH","OP","MATIC"];async function sn({chain:n,to:h}){try{let{result:T}=await q.post(Q.get("rpcUrls")[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(T||L[n]).toString())}catch(T){return console.error(`Failed to fetch contract decimals for ${h} on ${n}:`,T),L[n]}}async function ln(n){if(n==="XRD")return L.XRD;try{let h=n.split("-")[1]?.toLowerCase(),{manager:C}=await q.post(`${Q.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return C.divisibility.value.divisibility}catch(h){return console.error(`Failed to fetch Radix asset decimal for ${n}:`,h),L["XRD"]}}async function rn({chain:n,symbol:h}){if(W.includes(h))return L[h];let C=h.split("-"),T=C.length===1?void 0:C[C.length-1]?.toLowerCase();return await(T?.startsWith("0x")?sn({chain:n,to:T}):L[n])}function On({chain:n,symbol:h}){return d(n).with(...W,(C)=>rn({chain:C,symbol:h})).with("XRD",()=>ln(h)).otherwise(()=>L[n])}function MC({chain:n}){return w.from({chain:n})}function Xn({chain:n,symbol:h}){return d(n).with(...Ln,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${n}.${h}`===s(n).identifier).otherwise(()=>h===n)}var s=(n)=>{let h=L[n];return d(n.toUpperCase()).with(...Ln,(T)=>({identifier:`${T}.ETH`,decimal:h})).with("THOR",(T)=>({identifier:`${T}.RUNE`,decimal:h})).with("GAIA",(T)=>({identifier:`${T}.ATOM`,decimal:h})).with("MAYA",(T)=>({identifier:`${T}.CACAO`,decimal:10})).with("BSC",(T)=>({identifier:`${T}.BNB`,decimal:h})).with("AVAX",(T)=>({identifier:`${T}.AVAX`,decimal:h})).with(...Fn,"SOL","FLIP","KUJI","XRP","DOT","TRX","NEAR",(T)=>({identifier:`${T}.${T}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",(T)=>({identifier:T,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:L.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:L.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:L.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:n,decimal:h}))};function Rn({chain:n,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return d(n).with("XRD",()=>h==="XRD"||`${n}.${h}`===s(n).identifier).with("ARB","OP","BASE",()=>h==="ETH").with("GAIA",()=>h==="ATOM").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("THOR",()=>h==="RUNE").otherwise(()=>h===n)?"Native":n}var An=(n)=>{let[h,...C]=n.split("."),T=n.includes("/"),R=C.join("."),P=R?.split("-"),x=P?.length?P.length===1?P[0]:P.slice(0,-1).join("-"):void 0;return{chain:h,symbol:R,ticker:x,synth:T}};async function kC(n){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let C of Object.values(h))for(let{identifier:T,chain:R,...P}of C.tokens){if("identifier"in n&&T===n.identifier)return T;if("address"in P&&"chain"in n&&R===n.chain&&P.address.toLowerCase()===n.contract.toLowerCase())return T}return}function SC(n){if(n<0)throw new k({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function jC(n){if(n<0)throw new k({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function IC(n,h){try{return n()}catch(C){if(h)throw new k(h,C);return}}function ZC(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Gn=new Set;function l(n,h){if(n){if(Gn.has(h))return;Gn.add(h)}}async function gC(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let h=Q.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await q.get(`${h}/status`)).result.node_info.network}catch(h){return n}}import{match as en}from"ts-pattern";var nh=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function Sn(n){let h=n||nh,C={};for(let T of h){let R=await hh(T);C[T]=R}return C}async function hh(n){let{list:h}=await en(n).with("camelot",()=>import("./chunk-9f2b3enk.js")).with("caviar",()=>import("./chunk-0q5vvg5c.js")).with("chainflip",()=>import("./chunk-adrafsdk.js")).with("jupiter",()=>import("./chunk-fm9ycn0h.js")).with("mayachain",()=>import("./chunk-b1hang9z.js")).with("oneinch",()=>import("./chunk-4yqymkbp.js")).with("openocean",()=>import("./chunk-rhqk87p2.js")).with("pancakeswap",()=>import("./chunk-v9zj2gsj.js")).with("pangolin",()=>import("./chunk-6m0d5pv4.js")).with("sushiswap",()=>import("./chunk-18bxh1n7.js")).with("thorchain",()=>import("./chunk-92sk0g47.js")).with("traderjoe",()=>import("./chunk-8x46g3wq.js")).with("uniswap",()=>import("./chunk-vwh9jfxn.js")).with("uniswapv3",()=>import("./chunk-mmyv2vsv.js")).exhaustive();return h}var jn=["TERRA",...Q.get("chains")];function In(n=""){let h=n.toUpperCase(),[C]=h.split(".");if(jn.includes(C))return!0;let[T]=h.split("/");if(jn.includes(T))return!0;throw new k({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function wC(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var f=8,c=(n)=>10n**BigInt(n),y=(n)=>Math.log10(Number.parseFloat(n.toString()));function t({value:n,bigIntDecimal:h=f,decimal:C=f}){if(C===0)return n.toString();let T=n<0n,R=n.toString().substring(T?1:0),P=C-(R.length-1);if(P>0)R="0".repeat(P)+R;let x=R.length-C,o=R.slice(-C);if(Number.parseInt(o[h]||"0")>=5)o=`${o.substring(0,h-1)}${(Number.parseInt(o[h-1]||"0")+1).toString()}`;else o=o.substring(0,h);return`${T?"-":""}${R.slice(0,x)}.${o}`.replace(/\.?0*$/,"")}function Ch(n,h){if(h===0n)throw new Error("Cannot divide by zero");let C=h/2n;if(n>=0n&&h>=0n||n<0n&&h<0n)return(n+C)/h;return(n-C)/h}class V{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new V({decimal:h,value:t({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:C}){return V.fromBigInt(n.getBaseValue("bigint")*c(C)/c(h),C)}constructor(n){let h=Pn(n),C=typeof n==="object";this.decimal=C?n.decimal:void 0,this.decimalMultiplier=C&&"decimalMultiplier"in n?n.decimalMultiplier:c(Math.max(Zn(r(h)),this.decimal||0)),this.#R(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let C=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||y(this.decimalMultiplier));switch(n){case"number":return Number(C);case"string":return C;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return C}}getBaseValue(n,h){let C=this.decimalMultiplier/c(h||this.decimal||L.THOR),T=Ch(this.bigIntValue,C);switch(n){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let C=Pn(n),T=r(C);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(n=6){let[h,C]=this.getValue("string").split("."),T=h||"",R=C||"";if((Number.parseInt(T)?T.length+R.length:R.length)<=n)return this.getValue("string");if(T.length>=n)return T.slice(0,n).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${R.slice(0,n-T.length)}`.padEnd(n-T.length,"0");let x=Number.parseInt(R),o=`${x}`.slice(0,n);return`0.${o.padStart(R.length-`${x}`.length+o.length,"0")}`}toFixed(n=6){let[h,C]=this.getValue("string").split("."),T=h||"",R=C||"";if(Number.parseInt(T))return`${T}.${R.slice(0,n)}`.padEnd(n,"0");let P=Number.parseInt(R),x=`${P}`.slice(0,n);return`0.${x.padStart(R.length-`${P}`.length+x.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),C=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),R=C[T];if(!R)return this.getValue("string");let P=10**(T*3);return`${(h/P).toFixed(n)}${R}`}toCurrency(n="$",{currencyPosition:h="start",decimal:C=2,decimalSeparator:T=".",thousandSeparator:R=","}={}){let P=this.getValue("number"),[x="",o=""]=P.toFixed(6).split("."),B=x.replace(/\B(?=(\d{3})+(?!\d))/g,R),_=x||o?x==="0"?`${Number.parseFloat(`0.${o}`)}`.replace(".",T):`${B}${Number.parseInt(o)?`${T}${o.slice(0,C)}`:""}`:"0.00";return`${h==="start"?n:""}${_}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let C=h||this.decimal||f,T=Math.max(C,y(this.decimalMultiplier)),R=n<0n,P=n.toString().substring(R?1:0),x=T-(P.length-1),o=x>0?"0".repeat(x)+P:P,B=o.length-T,_=o.slice(-T);if(Number.parseInt(_[C]||"0")>=5)_=`${_.substring(0,C-1)}${(Number.parseInt(_[C-1]||"0")+1).toString()}`;else _=_.substring(0,C);return`${R?"-":""}${o.slice(0,B)}.${_}`.replace(/\.?0*$/,"")}#h(n,...h){let C=this.#C(this,...h),T=Math.max(C,y(this.decimalMultiplier)),R=c(T),P=h.reduce((o,B)=>{let _=this.getBigIntValue(B,T);switch(n){case"add":return o+_;case"sub":return o-_;case"mul":return o*_/R;case"div":{if(_===0n)throw new RangeError("Division by zero");return o*R/_}default:return o}},this.bigIntValue*R/this.decimalMultiplier),x=t({bigIntDecimal:T,decimal:T,value:P});return new this.constructor({decimalMultiplier:c(T),decimal:this.decimal,value:x,identifier:this.toString()})}#n(n,...h){let C=this.#C(this,...h),T=this.getBigIntValue(h[0]||"0",C),R=this.getBigIntValue(this,C);switch(n){case"gt":return R>T;case"gte":return R>=T;case"lt":return R<T;case"lte":return R<=T;case"eqValue":return R===T;default:return!1}}#R(n){let h=r(n)||"0";this.bigIntValue=this.#T(h)}#C(...n){let h=n.map((C)=>{return typeof C==="object"?C.decimal||y(C.decimalMultiplier):Zn(r(C))}).filter(Boolean);return Math.max(...h,f)}#T(n,h){let C=h?c(h):this.decimalMultiplier,T=y(C),[R="",P=""]=n.split(".");return BigInt(`${R}${P.padEnd(T,"0")}`)}}var Th=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function r(n){let C=`${typeof n==="number"?Th.format(n):Pn(n)}`.replaceAll(",",".").split(".");return C.length>1?`${C.slice(0,-1).join("")}.${C.at(-1)}`:C[0]||"0"}function Zn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,f)}function Pn(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var Rh=["SOL","TRX"],K=new Map;class w extends V{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:C,chain:T,symbol:R,identifier:P}){super(typeof n==="object"?n:{decimal:h,value:n});let x=on(P||`${T}.${R}`);this.type=Rn(x),this.tax=C,this.chain=x.chain,this.ticker=x.ticker,this.symbol=x.symbol,this.address=x.address,this.isSynthetic=x.isSynthetic,this.isTradeAsset=x.isTradeAsset,this.isGasAsset=x.isGasAsset,this.chainId=Nn[x.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[C,T,R]=n.split(".");if(!(C&&T))throw new k({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let P=C==="THOR"&&R?`${C}.${T}/${R}`:n;return w.from({asset:P,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:C,...T}){let R=n instanceof V?n.getValue("string"):n,P=xh(T),{identifier:x,decimal:o}=s(P),{chain:B,isSynthetic:_,isTradeAsset:S}=on(x),F=K.get(B==="SOL"?x:x.toUpperCase()),z=F?.decimal||o;l(!(C||z),`Couldn't find static decimal for one or more tokens on ${B} (Using default ${L[B]} decimal as fallback).
|
|
1
|
+
import{o as j,q as V}from"./chunk-ganzk321.js";import{getAddress as kT}from"ethers";import{match as IT}from"ts-pattern";import{match as BT}from"ts-pattern";var DT={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class J extends Error{static ErrorCode=DT;constructor(T,_){let F=typeof T==="string",P=F?T:T.errorKey,A=F?void 0:T.info,H=`${P}${A?`: ${JSON.stringify(A)}`:""}`;super(H);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=_,_)console.error(`SwapKitError [${P}]:`,_);else if(A)console.error(`SwapKitError [${P}]:`,A)}}var U;((Z)=>{Z.Arbitrum="ARB";Z.Avalanche="AVAX";Z.Base="BASE";Z.BinanceSmartChain="BSC";Z.Bitcoin="BTC";Z.BitcoinCash="BCH";Z.Cosmos="GAIA";Z.Dash="DASH";Z.Dogecoin="DOGE";Z.Ethereum="ETH";Z.Fiat="FIAT";Z.Kujira="KUJI";Z.Litecoin="LTC";Z.Maya="MAYA";Z.Near="NEAR";Z.Optimism="OP";Z.Polkadot="DOT";Z.Chainflip="FLIP";Z.Polygon="MATIC";Z.Radix="XRD";Z.Ripple="XRP";Z.THORChain="THOR";Z.Solana="SOL";Z.Tron="TRX";Z.Zcash="ZEC"})(U||={});var _T;((F)=>{F.THORChain="THOR_STAGENET";F.Maya="MAYA_STAGENET"})(_T||={});var h;(($)=>{$.Arbitrum="42161";$.ArbitrumHex="0xa4b1";$.Avalanche="43114";$.AvalancheHex="0xa86a";$.Base="8453";$.BaseHex="0x2105";$.BinanceSmartChain="56";$.BinanceSmartChainHex="0x38";$.Bitcoin="bitcoin";$.BitcoinCash="bitcoincash";$.Chainflip="chainflip";$.Cosmos="cosmoshub-4";$.Dash="dash";$.Dogecoin="dogecoin";$.Kujira="kaiyo-1";$.Ethereum="1";$.EthereumHex="0x1";$.Fiat="fiat";$.Litecoin="litecoin";$.Maya="mayachain-mainnet-v1";$.MayaStagenet="mayachain-stagenet-v1";$.Near="near";$.Optimism="10";$.OptimismHex="0xa";$.Polkadot="polkadot";$.Polygon="137";$.PolygonHex="0x89";$.Radix="radix-mainnet";$.Ripple="ripple";$.THORChain="thorchain-1";$.THORChainStagenet="thorchain-stagenet-v2";$.Solana="solana";$.Tron="728126428";$.TronHex="0x2b6653dc";$.Zcash="zcash"})(h||={});var U_={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["728126428"]:"TRX",["0x2b6653dc"]:"TRX",["zcash"]:"ZEC"},fT=Object.keys(U),c=Object.values(U),Y={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,TRX:6,XRD:18,XRP:6,ZEC:8},O_={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRX"]:3,["ZEC"]:150},k_=["DOT","FLIP"],g=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],GT=["BTC","BCH","DASH","DOGE","LTC","ZEC"],I_=["GAIA","THOR","MAYA","KUJI"],K_={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},S_=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],w_=["ARB","DASH","ETH","KUJI","MAYA","THOR"],l={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.mainnet.near.org",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.thorswap.net",["TRX"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://mainnet.lightwalletd.com:9067",["MAYA_STAGENET"]:"",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},o={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},ET={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",o.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRX"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:[]},FT={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io",["TRX"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},xT=l,gT=(T)=>{return BT(T).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC","ZEC",()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with("GAIA","KUJI","MAYA","THOR","MAYA_STAGENET","THOR_STAGENET",()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with("DOT","FLIP",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("TRX","XRD","FIAT",()=>"").with("NEAR",()=>({jsonrpc:"2.0",id:"dontcare",method:"status",params:[]})).with("XRP",()=>({method:"ping",params:[{}],id:1,jsonrpc:"2.0"})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:T})})};function bT(T){return BT(T).with("XRD",()=>"/status/network-configuration").with("TRX",()=>"/wallet/getnowblock").otherwise(()=>"")}var $T=async(T,_)=>{try{let F=_.startsWith("wss")?_.replace("wss","https"):_;return(await fetch(`${F}${bT(T)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(gT(T)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},yT=async(T)=>{let _=l[T];if(await $T(T,_))return _;for(let F of ET[T])if(await $T(T,F))return F;return _},D_=async(T=[...Object.values(U),...Object.values(_T)])=>{let _={};await Promise.all(T.map(async(F)=>{let P=await yT(F);_[F]=P})),xT={...xT,..._}},XT=c.reduce((T,_)=>{let F=fT.find((P)=>U[P]===_);if(F)T[_]=F;return T},{}),QT=c.reduce((T,_)=>{return T[_]=h[XT[_]],T},{}),zT=c.reduce((T,_)=>{let F=`${XT[_]}Hex`;return T[_]=h[F],T},{}),f_=c.reduce((T,_)=>{return T[_]=FT[_],T},{});import{match as t}from"ts-pattern";var y={get:n("GET"),post:n("POST"),extend:(T)=>({get:n("GET",T),post:n("POST",T),extend:(_)=>y.extend({...T,..._})})};function n(T,_={}){return async(F,P={})=>{let{searchParams:A,json:H,body:x,headers:N,dynamicHeader:X}={..._,...P},B=!!H||F.endsWith(".json"),W=B?JSON.stringify(H):x;try{let G=uT(F,A),I=vT(B,{...N,...X?.()}),q=await fetch(G,{...P,method:T,body:W,headers:I});if(!q.ok){let w=await q.text();throw new J("helpers_invalid_response",{status:q.status,statusText:q.statusText,message:w})}let L=await q.json();return P.onSuccess?.(L)||P.responseHandler?.(L)||L}catch(G){if(P.onError)return P.onError(G);throw G}}}function vT(T,_){return{..._,...T?{"Content-Type":"application/json"}:{}}}function uT(T,_){let F=new URL(T);if(_)F.search=new URLSearchParams(_).toString();return F.toString()}import{createStore as nT}from"zustand/vanilla";var CT;((z)=>{z.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";z.TC_SUPPORTED_TO_ETH="TC-ERC20";z.TC_SUPPORTED_TO_AVAX="TC-ARC20";z.TC_SUPPORTED_TO_BSC="TC-BEP20";z.ETH_TO_TC_SUPPORTED="ERC20-TC";z.ETH_TO_ETH="ERC20-ERC20";z.ETH_TO_AVAX="ERC20-ARC20";z.ETH_TO_BSC="ERC20-BEP20";z.AVAX_TO_TC_SUPPORTED="ARC20-TC";z.AVAX_TO_ETH="ARC20-ERC20";z.AVAX_TO_AVAX="ARC20-ARC20";z.AVAX_TO_BSC="ARC20-BEP20";z.BSC_TO_TC_SUPPORTED="BEP20-TC";z.BSC_TO_ETH="BEP20-ERC20";z.BSC_TO_AVAX="BEP20-ARC20";z.BSC_TO_BSC="BEP20-BEP20"})(CT||={});var y_=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],v_=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],u_=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function PT(T,_){if("index"in _)return[...T.slice(0,T.length-1),_.index];if("change"in _){let[F,P,A,,H]=T;return[F,P,A,_.change,H]}if("account"in _){let[F,P,,A,H]=T;return[F,P,_.account,A,H]}return T}function ZT([T,_,F,P,A]){let H=typeof A!=="number";if(typeof P!=="number")return`m/${T}'/${_}'/${F}'`;return`m/${T}'/${_}'/${F}'/${P}${H?"":`/${A}`}`}function m_({chain:T,index:_,addressIndex:F=0,type:P}){if(g.includes(T)){if(P&&["legacy","account"].includes(P))return[44,60,0,_];if(P==="ledgerLive")return[44,60,_,0,F];return PT(v[T],{index:_})}if(T==="SOL"){if(P==="account")return[44,501,0,_];return PT(v[T],{index:_})}let A=T==="LTC"?2:0;switch(P){case"nativeSegwitMiddleAccount":return[84,A,_,0,F];case"segwit":return[49,A,0,0,_];case"legacy":return[44,A,0,0,_];default:return PT(v[T],{index:_})}}function d_(T){let[_,F,P]=T.split("/").map((A)=>Number.parseInt(A,10));switch(F){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var pT;((N)=>{N.ARB="0x0000000000000000000000000000000000000000";N.AVAX="0x0000000000000000000000000000000000000000";N.BASE="0x0000000000000000000000000000000000000000";N.ETH="0x0000000000000000000000000000000000000000";N.BSC="0x0000000000000000000000000000000000000000";N.MATIC="0x0000000000000000000000000000000000001010";N.OP="0x4200000000000000000000000000000000000042"})(pT||={});var v={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRX:[44,195,0,0,0],ZEC:[44,133,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0]},c_=Object.keys(v).reduce((T,_)=>{return T[_]=ZT(v[_]),T},{});var mT;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(mT||={});var dT;((F)=>{F.highSlippage="highSlippage";F.highPriceImpact="highPriceImpact"})(dT||={});var oT;((M)=>{M.CAVIAR_V1="CAVIAR_V1";M.CAMELOT_V3="CAMELOT_V3";M.CHAINFLIP="CHAINFLIP";M.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";M.JUPITER="JUPITER";M.MAYACHAIN="MAYACHAIN";M.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";M.OCISWAP_V1="OCISWAP_V1";M.ONEINCH="ONEINCH";M.OPENOCEAN_V2="OPENOCEAN_V2";M.PANCAKESWAP="PANCAKESWAP";M.PANGOLIN_V1="PANGOLIN_V1";M.SUSHISWAP_V2="SUSHISWAP_V2";M.THORCHAIN="THORCHAIN";M.THORCHAIN_STREAMING="THORCHAIN_STREAMING";M.TRADERJOE_V2="TRADERJOE_V2";M.UNISWAP_V2="UNISWAP_V2";M.UNISWAP_V3="UNISWAP_V3";M.KADO="KADO";M.NEAR="NEAR"})(oT||={});var hT;((N)=>{N.LIQUIDITY="liquidity";N.NETWORK="network";N.INBOUND="inbound";N.OUTBOUND="outbound";N.AFFILIATE="affiliate";N.TAX="tax";N.PRIORITY="priority"})(hT||={});var JT;((P)=>{P.Average="average";P.Fast="fast";P.Fastest="fastest"})(JT||={});var cT;((F)=>{F.Approve="approve";F.CheckOnly="checkOnly"})(cT||={});var MT;((G)=>{G.NAME_REGISTER="~";G.BOND="BOND";G.DEPOSIT="+";G.LEAVE="LEAVE";G.UNBOND="UNBOND";G.WITHDRAW="-";G.RUNEPOOL_DEPOSIT="POOL+";G.RUNEPOOL_WITHDRAW="POOL-";G.CLAIM_TCY="tcy";G.STAKE_TCY="tcy+";G.UNSTAKE_TCY="tcy-"})(MT||={});var s;((Q)=>{Q.BITGET="BITGET";Q.BRAVE="BRAVE";Q.COINBASE_MOBILE="COINBASE_MOBILE";Q.COINBASE_WEB="COINBASE_WEB";Q.COSMOSTATION="COSMOSTATION";Q.CTRL="CTRL";Q.EIP6963="EIP6963";Q.EXODUS="EXODUS";Q.KEEPKEY="KEEPKEY";Q.KEEPKEY_BEX="KEEPKEY_BEX";Q.KEPLR="KEPLR";Q.KEYSTORE="KEYSTORE";Q.LEAP="LEAP";Q.LEDGER="LEDGER";Q.LEDGER_LIVE="LEDGER_LIVE";Q.METAMASK="METAMASK";Q.OKX="OKX";Q.OKX_MOBILE="OKX_MOBILE";Q.ONEKEY="ONEKEY";Q.PHANTOM="PHANTOM";Q.POLKADOT_JS="POLKADOT_JS";Q.RADIX_WALLET="RADIX_WALLET";Q.TREZOR="TREZOR";Q.TALISMAN="TALISMAN";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.WALLETCONNECT="WALLETCONNECT";Q.XAMAN="XAMAN"})(s||={});var lT;((P)=>{P[P.NoError=36864]="NoError";P[P.LockedDevice=21781]="LockedDevice";P[P.TC_NotFound=65535]="TC_NotFound"})(lT||={});var sT={apis:{},chains:Object.values(U),wallets:Object.values(s),explorerUrls:FT,nodeUrls:o,rpcUrls:l,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},feeMultipliers:void 0},k=nT((T)=>({...sT,setApiKey:(_,F)=>T((P)=>({apiKeys:{...P.apiKeys,[_]:F}})),setEnv:(_,F)=>T((P)=>({envs:{...P.envs,[_]:F}})),setExplorerUrl:(_,F)=>T((P)=>({explorerUrls:{...P.explorerUrls,[_]:F}})),setNodeUrl:(_,F)=>T((P)=>({nodeUrls:{...P.nodeUrls,[_]:F}})),setRpcUrl:(_,F)=>T((P)=>({rpcUrls:{...P.rpcUrls,[_]:F}})),setIntegrationConfig:(_,F)=>T((P)=>({integrations:{...P.integrations,[_]:F}})),setFeeMultipliers:(_)=>T(()=>({feeMultipliers:_})),setConfig:(_)=>T((F)=>({apiKeys:{...F.apiKeys,..._.apiKeys},envs:{...F.envs,..._.envs},explorerUrls:{...F.explorerUrls,..._.explorerUrls},integrations:{...F.integrations,..._.integrations},nodeUrls:{...F.nodeUrls,..._.nodeUrls},rpcUrls:{...F.rpcUrls,..._.rpcUrls},feeMultipliers:_.feeMultipliers||F.feeMultipliers,chains:F.chains.concat(_.chains||[]),wallets:F.wallets.concat(_.wallets||[])}))})),K={getState:k.getState,get:(T)=>k.getState()[T],set:(T)=>k.getState().setConfig(T),setApiKey:(T,_)=>k.getState().setApiKey(T,_),setEnv:(T,_)=>k.getState().setEnv(T,_),setExplorerUrl:(T,_)=>k.getState().setExplorerUrl(T,_),setNodeUrl:(T,_)=>k.getState().setNodeUrl(T,_),setRpcUrl:(T,_)=>k.getState().setRpcUrl(T,_),setIntegrationConfig:(T,_)=>k.getState().setIntegrationConfig(T,_),setFeeMultipliers:(T)=>k.getState().setFeeMultipliers(T)};var QF=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],YT=["ARB","BASE","ETH","OP","MATIC"];async function tT({chain:T,to:_}){try{let{result:P}=await y.post(K.get("rpcUrls")[T],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:_.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(P||Y[T]).toString())}catch(P){return console.error(`Failed to fetch contract decimals for ${_} on ${T}:`,P),Y[T]}}async function rT(T){if(T==="XRD")return Y.XRD;try{let _=T.split("-")[1]?.toLowerCase(),{manager:F}=await y.post(`${K.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:_})});return F.divisibility.value.divisibility}catch(_){return console.error(`Failed to fetch Radix asset decimal for ${T}:`,_),Y["XRD"]}}async function iT({chain:T,symbol:_}){if(g.includes(_))return Y[_];let F=_.split("-"),P=F.length===1?void 0:F[F.length-1]?.toLowerCase();return await(P?.startsWith("0x")?tT({chain:T,to:P}):Y[T])}function LT({chain:T,symbol:_}){return t(T).with(...g,(F)=>iT({chain:F,symbol:_})).with("XRD",()=>rT(_)).otherwise(()=>Y[T])}function zF({chain:T}){return f.from({chain:T})}function jT({chain:T,symbol:_}){return t(T).with(...YT,()=>_==="ETH").with("AVAX",()=>_==="AVAX").with("BSC",()=>_==="BNB").with("MAYA",()=>_==="CACAO").with("GAIA",()=>_==="ATOM").with("THOR",()=>_==="RUNE").with("XRD",()=>`${T}.${_}`===r(T).identifier).otherwise(()=>_===T)}var r=(T)=>{let _=Y[T];return t(T.toUpperCase()).with(...YT,(P)=>({identifier:`${P}.ETH`,decimal:_})).with("THOR",(P)=>({identifier:`${P}.RUNE`,decimal:_})).with("GAIA",(P)=>({identifier:`${P}.ATOM`,decimal:_})).with("MAYA",(P)=>({identifier:`${P}.CACAO`,decimal:10})).with("BSC",(P)=>({identifier:`${P}.BNB`,decimal:_})).with("AVAX",(P)=>({identifier:`${P}.AVAX`,decimal:_})).with(...GT,"SOL","FLIP","KUJI","XRP","DOT","TRX","NEAR",(P)=>({identifier:`${P}.${P}`,decimal:_})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:_})).with("KUJI.USK",(P)=>({identifier:P,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:Y.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:Y.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:Y.ETH})).with("MAYA.CACAO",(P)=>({identifier:P,decimal:10})).with("MAYA.MAYA",(P)=>({identifier:P,decimal:4})).otherwise(()=>({identifier:T,decimal:_}))};function AT({chain:T,symbol:_}){if(_.includes("/"))return"Synth";if(_.includes("~"))return"Trade";return t(T).with("XRD",()=>_==="XRD"||`${T}.${_}`===r(T).identifier).with("ARB","OP","BASE",()=>_==="ETH").with("GAIA",()=>_==="ATOM").with("BSC",()=>_==="BNB").with("MAYA",()=>_==="CACAO").with("THOR",()=>_==="RUNE").otherwise(()=>_===T)?"Native":T}var RT=(T)=>{let[_,...F]=T.split("."),P=T.includes("/"),A=F.join("."),H=A?.split("-"),x=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:_,symbol:A,ticker:x,synth:P}};async function ZF(T){let{tokenLists:_}=await import("@swapkit/helpers/tokens");for(let F of Object.values(_))for(let{identifier:P,chain:A,...H}of F.tokens){if("identifier"in T&&P===T.identifier)return P;if("address"in H&&"chain"in T&&A===T.chain&&H.address.toLowerCase()===T.contract.toLowerCase())return P}return}function VF(T){if(T<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return 10+T}function WF(T){if(T<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:T}});return Math.round((10+T*1.0512)*10000000000)/10000000000}function qF(T,_){try{return T()}catch(F){if(_)throw new J(_,F);return}}function UF(T){switch(T){case"THOR":return`${T}.RUNE`;case"GAIA":return`${T}.ATOM`;case"BSC":return`${T}`;default:return`${T}.${T}`}}var VT=new Set;function i(T,_){if(T){if(VT.has(_))return;VT.add(_)}}async function OF(T="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(T))return T;try{let _=K.get("rpcUrls")[T!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await y.get(`${_}/status`)).result.node_info.network}catch(_){return T}}import{match as aT}from"ts-pattern";var eT=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function WT(T){let _=T||eT,F={};for(let P of _){let A=await T_(P);F[P]=A}return F}async function T_(T){let{list:_}=await aT(T).with("camelot",()=>import("./chunk-9f2b3enk.js")).with("caviar",()=>import("./chunk-0q5vvg5c.js")).with("chainflip",()=>import("./chunk-adrafsdk.js")).with("jupiter",()=>import("./chunk-fm9ycn0h.js")).with("mayachain",()=>import("./chunk-b1hang9z.js")).with("oneinch",()=>import("./chunk-4yqymkbp.js")).with("openocean",()=>import("./chunk-rhqk87p2.js")).with("pancakeswap",()=>import("./chunk-v9zj2gsj.js")).with("pangolin",()=>import("./chunk-6m0d5pv4.js")).with("sushiswap",()=>import("./chunk-18bxh1n7.js")).with("thorchain",()=>import("./chunk-92sk0g47.js")).with("traderjoe",()=>import("./chunk-8x46g3wq.js")).with("uniswap",()=>import("./chunk-vwh9jfxn.js")).with("uniswapv3",()=>import("./chunk-mmyv2vsv.js")).exhaustive();return _}var qT=["TERRA",...K.get("chains")];function UT(T=""){let _=T.toUpperCase(),[F]=_.split(".");if(qT.includes(F))return!0;let[P]=_.split("/");if(qT.includes(P))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${T}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:T}})}function DF(T){if(T.length>30)return!1;let _=/^[a-zA-Z0-9+_-]+$/g;return!!T.match(_)}var d=8,b=(T)=>10n**BigInt(T),m=(T)=>Math.log10(Number.parseFloat(T.toString()));function u({value:T,bigIntDecimal:_=d,decimal:F=d}){if(F===0)return T.toString();let P=T<0n,A=T.toString().substring(P?1:0),H=F-(A.length-1);if(H>0)A="0".repeat(H)+A;let x=A.length-F,N=A.slice(-F);if(Number.parseInt(N[_]||"0")>=5)N=`${N.substring(0,_-1)}${(Number.parseInt(N[_-1]||"0")+1).toString()}`;else N=N.substring(0,_);return`${P?"-":""}${A.slice(0,x)}.${N}`.replace(/\.?0*$/,"")}function __(T,_){if(_===0n)throw new Error("Cannot divide by zero");let F=_/2n;if(T>=0n&&_>=0n||T<0n&&_<0n)return(T+F)/_;return(T-F)/_}class E{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(T,_){return new E({decimal:_,value:u({value:T,bigIntDecimal:_,decimal:_})})}static shiftDecimals({value:T,from:_,to:F}){return E.fromBigInt(T.getBaseValue("bigint")*b(F)/b(_),F)}constructor(T){let _=HT(T),F=typeof T==="object";this.decimal=F?T.decimal:void 0,this.decimalMultiplier=F&&"decimalMultiplier"in T?T.decimalMultiplier:b(Math.max(OT(a(_)),this.decimal||0)),this.#A(_)}set(T){return new this.constructor({decimal:this.decimal,value:T,identifier:this.toString({includeSynthProtocol:!0})})}add(...T){return this.#_("add",...T)}sub(...T){return this.#_("sub",...T)}mul(...T){return this.#_("mul",...T)}div(...T){return this.#_("div",...T)}gt(T){return this.#T("gt",T)}gte(T){return this.#T("gte",T)}lt(T){return this.#T("lt",T)}lte(T){return this.#T("lte",T)}eqValue(T){return this.#T("eqValue",T)}getValue(T,_){let F=this.formatBigIntToSafeValue(this.bigIntValue,_||this.decimal||m(this.decimalMultiplier));switch(T){case"number":return Number(F);case"string":return F;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return F}}getBaseValue(T,_){let F=this.decimalMultiplier/b(_||this.decimal||Y.THOR),P=__(this.bigIntValue,F);switch(T){case"number":return Number(P);case"string":return P.toString();case"bigint":return P;default:return P}}getBigIntValue(T,_){if(!_&&typeof T==="object")return T.bigIntValue;let F=HT(T),P=a(F);if(P==="0"||P==="undefined")return 0n;return this.#P(P,_)}toSignificant(T=6){let[_,F]=this.getValue("string").split("."),P=_||"",A=F||"";if((Number.parseInt(P)?P.length+A.length:A.length)<=T)return this.getValue("string");if(P.length>=T)return P.slice(0,T).padEnd(P.length,"0");if(Number.parseInt(P))return`${P}.${A.slice(0,T-P.length)}`.padEnd(T-P.length,"0");let x=Number.parseInt(A),N=`${x}`.slice(0,T);return`0.${N.padStart(A.length-`${x}`.length+N.length,"0")}`}toFixed(T=6){let[_,F]=this.getValue("string").split("."),P=_||"",A=F||"";if(Number.parseInt(P))return`${P}.${A.slice(0,T)}`.padEnd(T,"0");let H=Number.parseInt(A),x=`${H}`.slice(0,T);return`0.${x.padStart(A.length-`${H}`.length+x.length,"0")}`}toAbbreviation(T=2){let _=this.getValue("number"),F=["","K","M","B","T","Q","Qi","S"],P=Math.floor(Math.log10(Math.abs(_))/3),A=F[P];if(!A)return this.getValue("string");let H=10**(P*3);return`${(_/H).toFixed(T)}${A}`}toCurrency(T="$",{currencyPosition:_="start",decimal:F=2,decimalSeparator:P=".",thousandSeparator:A=","}={}){let H=this.getValue("number"),[x="",N=""]=H.toFixed(6).split("."),X=x.replace(/\B(?=(\d{3})+(?!\d))/g,A),B=x||N?x==="0"?`${Number.parseFloat(`0.${N}`)}`.replace(".",P):`${X}${Number.parseInt(N)?`${P}${N.slice(0,F)}`:""}`:"0.00";return`${_==="start"?T:""}${B}${_==="end"?T:""}`}formatBigIntToSafeValue(T,_){let F=_||this.decimal||d,P=Math.max(F,m(this.decimalMultiplier)),A=T<0n,H=T.toString().substring(A?1:0),x=P-(H.length-1),N=x>0?"0".repeat(x)+H:H,X=N.length-P,B=N.slice(-P);if(Number.parseInt(B[F]||"0")>=5)B=`${B.substring(0,F-1)}${(Number.parseInt(B[F-1]||"0")+1).toString()}`;else B=B.substring(0,F);return`${A?"-":""}${N.slice(0,X)}.${B}`.replace(/\.?0*$/,"")}#_(T,..._){let F=this.#F(this,..._),P=Math.max(F,m(this.decimalMultiplier)),A=b(P),H=_.reduce((N,X)=>{let B=this.getBigIntValue(X,P);switch(T){case"add":return N+B;case"sub":return N-B;case"mul":return N*B/A;case"div":{if(B===0n)throw new RangeError("Division by zero");return N*A/B}default:return N}},this.bigIntValue*A/this.decimalMultiplier),x=u({bigIntDecimal:P,decimal:P,value:H});return new this.constructor({decimalMultiplier:b(P),decimal:this.decimal,value:x,identifier:this.toString()})}#T(T,..._){let F=this.#F(this,..._),P=this.getBigIntValue(_[0]||"0",F),A=this.getBigIntValue(this,F);switch(T){case"gt":return A>P;case"gte":return A>=P;case"lt":return A<P;case"lte":return A<=P;case"eqValue":return A===P;default:return!1}}#A(T){let _=a(T)||"0";this.bigIntValue=this.#P(_)}#F(...T){let _=T.map((F)=>{return typeof F==="object"?F.decimal||m(F.decimalMultiplier):OT(a(F))}).filter(Boolean);return Math.max(..._,d)}#P(T,_){let F=_?b(_):this.decimalMultiplier,P=m(F),[A="",H=""]=T.split(".");return BigInt(`${A}${H.padEnd(P,"0")}`)}}var F_=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function a(T){let F=`${typeof T==="number"?F_.format(T):HT(T)}`.replaceAll(",",".").split(".");return F.length>1?`${F.slice(0,-1).join("")}.${F.at(-1)}`:F[0]||"0"}function OT(T){let _=T.split(".")[1]?.length||0;return Math.max(_,d)}function HT(T){return typeof T==="object"?"getValue"in T?T.getValue("string"):T.value:T}var P_=["SOL","TRX"],C=new Map;class f extends E{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:T,decimal:_,tax:F,chain:P,symbol:A,identifier:H}){super(typeof T==="object"?T:{decimal:_,value:T});let x=NT(H||`${P}.${A}`);this.type=AT(x),this.tax=F,this.chain=x.chain,this.ticker=x.ticker,this.symbol=x.symbol,this.address=x.address,this.isSynthetic=x.isSynthetic,this.isTradeAsset=x.isTradeAsset,this.isGasAsset=x.isGasAsset,this.chainId=QT[x.chain]}toString({includeSynthProtocol:T}={}){return(this.isSynthetic||this.isTradeAsset)&&!T?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:T,symbol:_}){return this.chain===T&&this.symbol===_}eq(T){return this.eqAsset(T)&&this.eqValue(T)}static fromUrl(T,_=0){let[F,P,A]=T.split(".");if(!(F&&P))throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:T}});let H=F==="THOR"&&A?`${F}.${P}/${A}`:T;return f.from({asset:H,value:_})}static from({value:T=0,fromBaseDecimal:_,asyncTokenLookup:F,...P}){let A=T instanceof E?T.getValue("string"):T,H=N_(P),{identifier:x,decimal:N}=r(H),{chain:X,isSynthetic:B,isTradeAsset:W}=NT(x),G=C.get(X==="SOL"?x:x.toUpperCase()),I=G?.decimal||N;i(!(F||I),`Couldn't find static decimal for one or more tokens on ${X} (Using default ${Y[X]} decimal as fallback).
|
|
2
2
|
This can result in incorrect calculations and mess with amount sent on transactions.
|
|
3
3
|
You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
|
|
4
|
-
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:j,identifier:O,tax:Y}=F||{decimal:z||L[B],identifier:x},$=_||S,J=h?e(BigInt(R),h):e(R,j);return C?Ah(O,h?J:R):$?Ph(O,J):new w({tax:Y,decimal:j,identifier:O,value:J})}static async loadStaticAssets(n){let h=await Sn(n);for(let{tokens:C}of Object.values(h))for(let{identifier:T,chain:R,...P}of C){let x=R==="SOL"?T:T.toUpperCase(),o="decimals"in P?P.decimals:L[R];K.set(x,{identifier:T,decimal:o})}return!0}static setStaticAssets(n){K.clear();for(let[h,C]of n.entries()){let T=C.chain==="SOL"?C.identifier:C.identifier.toUpperCase(),R="decimals"in C?C.decimals:C.decimal;K.set(h,{...C,decimal:R,identifier:T})}return!0}}function vC(n){let h=w.from({chain:n});return zn(n).with("BTC","LTC","BCH","DASH",()=>h.set(0.00010001)).with("DOGE",()=>h.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>h.set(0.00000001)).with("THOR","MAYA",()=>h.set(0)).with("GAIA","KUJI",()=>h.set(0.000001)).otherwise(()=>h.set(0.00000001))}async function Ah(n,h=0){In(n);let T=n.includes("SOL.")?n:n.toUpperCase(),R=K.get(T),P=R?.decimal||await On(on(n));if(!R)K.set(T,{identifier:n,decimal:P});return new w({decimal:P,value:e(h,P),identifier:n})}function Ph(n,h=0){let C=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,T=C?["MAYA","THOR"].includes(C):!1,R=n.slice(0,14).includes("~")?"~":"/",[P,x]=T?n.split(".").slice(1).join().split(R):n.split(R);if(!(P&&x))throw new k({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new w({decimal:8,value:e(h,8),identifier:`${C||"THOR"}.${P}${R}${x}`})}function e(n,h){return typeof n==="bigint"?t({value:n,bigIntDecimal:h,decimal:h}):n}function oh(n){let h=zn(n).when((C)=>("chain"in C)&&C.chain!==void 0,({chain:C})=>C).otherwise((C)=>{let T=An(C.asset);return T.synth?"THOR":T.chain});if(!Object.values(I).includes(h.toUpperCase()))throw new k({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function xh(n){if(oh(n),"chain"in n)return n.chain;let{chain:h,symbol:C}=An(n.asset);return Rn({chain:h,symbol:C})==="Native"?h:n.asset}function on(n){let h=n.slice(0,14),C=n.split("."),T=C[0]?.toUpperCase(),R=["THOR","MAYA"].includes(T),P=h.includes("/"),x=h.includes("~"),o=P||x,B=x?"~":"/",[_,S=""]=R?C.slice(1).join().split(B):n.split(B);if(o&&!(_&&S))throw new k({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let[F,...z]=(n.includes(".")&&!o?n:`${T}.${S}`).split("."),j=o?S:z.join("."),{address:O,ticker:Y}=Hh({symbol:j,chain:F}),$;try{$=O&&W.includes(F)&&gn(O)?gn(O):O}catch(D){$=O}let J=(o?`${_}${B}`:"")+($?`${Y}-${$??""}`:j);return{address:$,chain:F,isSynthOrTrade:o,isSynthetic:P,isTradeAsset:x,ticker:Y,symbol:J,isGasAsset:Xn({chain:F,symbol:j})}}function Hh({symbol:n,chain:h}){let C=n.split("-"),T=C.length===1?void 0:C[C.length-1],R=Rh.includes(h)?T:T?.toLowerCase(),P=C.length===1?C[0]:C.slice(0,-1).join("-");return{address:R,ticker:P}}class U extends V{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new U({decimal:h,value:t({value:n,bigIntDecimal:h,decimal:h})})}}var _h={average:1,fast:1.5,fastest:2};function Qn(n="average"){let h=Q.get("feeMultipliers");if(h&&h[n]!==void 0)return h[n];return _h[n]}function Fh(n="average"){let h=Qn(n),C=10n;return{numerator:BigInt(Math.round(h*10)),denominator:C}}function lC(n,h="average"){let{numerator:C,denominator:T}=Fh(h);return n*C/T}function rC(n,h="average",C=!1){let T=Qn(h),R=n*T;return C?Math.floor(R):R}function Bh({liquidityUnits:n,poolUnits:h,runeDepth:C}){let T=Z(n),R=Z(h),P=Z(C),x=T.mul(P),o=R.mul(R).mul(2),B=R.mul(T).mul(2),_=T.mul(T),S=R.mul(R).mul(R);return x.mul(o.sub(B).add(_)).div(S)}function Nh({liquidityUnits:n,poolUnits:h,assetDepth:C}){let T=Z(n),R=Z(h),P=Z(C),x=T.mul(P),o=R.mul(R).mul(2),B=R.mul(T).mul(2),_=T.mul(T),S=x.mul(o.sub(B).add(_)),F=R.mul(R).mul(R);return S.div(F)}function CT({percent:n,runeDepth:h,liquidityUnits:C,poolUnits:T}){return Bh({runeDepth:h,liquidityUnits:C,poolUnits:T}).mul(n)}function TT({percent:n,assetDepth:h,liquidityUnits:C,poolUnits:T}){return Nh({assetDepth:h,liquidityUnits:C,poolUnits:T}).mul(n)}function Z(n){return U.fromBigInt(BigInt(n),L.THOR)}function $h({liquidityUnits:n,poolUnits:h,runeDepth:C,assetDepth:T}){return{assetAmount:Z(T).mul(n).div(h),runeAmount:Z(C).mul(n).div(h)}}function RT({liquidityUnits:n,poolUnits:h,runeDepth:C,assetDepth:T,percent:R}){return Object.fromEntries(Object.entries($h({liquidityUnits:n,poolUnits:h,runeDepth:C,assetDepth:T})).map(([P,x])=>[P,x.mul(R)]))}function AT({runeDepth:n,poolUnits:h,assetDepth:C,liquidityUnits:T,runeAmount:R,assetAmount:P}){let x=new U({value:n,decimal:8}),o=new U({value:C,decimal:8}),B=new U({value:h,decimal:8}),_=new U({value:R,decimal:8}),S=new U({value:P,decimal:8}),F=_.mul(o),z=S.mul(x),j=_.mul(S),O=x.mul(o),Y=B.mul(F.add(z.add(j.mul(2)))),$=F.add(z.add(O.mul(2))),J=Y.div($),D=Z(T).add(J);if(J.getBaseValue("number")===0)return D.div(B).getBaseValue("number");let Yn=B.add(D);return D.div(Yn).getBaseValue("number")}function PT({runeAmount:n,assetAmount:h,runeDepth:C,assetDepth:T}){if(n==="0"||h==="0"||C==="0"||T==="0")return 0;let R=Z(C),P=Z(T),x=Z(h),o=Z(n),B=x.mul(R).sub(P.mul(o)),_=P.mul(o).add(R.mul(P));return Math.abs(B.div(_).getBaseValue("number"))}import{match as Mh}from"ts-pattern";function FT({type:n,address:h}){return`${n}:${h}`}function BT({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function NT(n){return nn("POOL+",n)}function $T({chain:n,symbol:h,address:C,...T}){let R=kh({chain:n,symbol:h}),P=C?`:${C}:`:":";return nn(`${"+"}:${R}${P}`,T)}function MT({chain:n,symbol:h,ticker:C,basisPoints:T,targetAsset:R}){let P=n==="ETH"&&C!=="ETH"?`${C}-${h.slice(-3)}`:h,x=R?`:${R}`:"";return`${"-"}:${n}.${P}:${T}${x}`}function kT({basisPoints:n,...h}){return nn(`${"POOL-"}:${n}`,h)}function pT({name:n,chain:h,address:C,owner:T}){let R=`${"~"}:${n}:${h}:${C}`,P=T?`:${T}`:"";return`${R}${P}`}function LT({name:n,chain:h,asset:C,payout:T,owner:R}){return`${"~"}:${n}:${h}:${T}:${R}:${C}`}function OT(n,{address:h}){return`${n}:${h}`}function XT(n,{unstakeBps:h,...C}){let T=h?`:${h}`:"",R=`${n}${T}`;return nn(`${R}`,C)}function nn(n,{affiliateAddress:h,affiliateBasisPoints:C}={}){let T=`${n}${h?`:${h}:${C||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function kh({chain:n,symbol:h}){return Mh(n).with("BTC","DOGE","LTC",()=>n.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${n}.${h}`)}function ST({name:n,properties:h,methods:C}){function T(R){return{...C(R),...h}}return{[n]:T}}function zT(){return typeof window.ethereum!=="undefined"}function QT(n){return ph().includes(n)}function ph(){let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,C=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,R=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,P=window?.bitkeep?.ethereum,x=window?.$onekey?.ethereum,o=[];if(n)o.push("METAMASK");if(h)o.push("CTRL");if(C)o.push("BRAVE");if(T)o.push("TRUSTWALLET_WEB");if(R)o.push("COINBASE_WEB");if(Gh())o.push("OKX_MOBILE");if(P)o.push("BITGET");if(x)o.push("ONEKEY");return o}async function Lh(n,h,C){try{await Un({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:$n[h]}]})}catch(T){if(!C)throw new k("helpers_failed_to_switch_network",{error:T,reason:"networkParams not provided"});await Xh(n,C)}}function UT({chains:n,supportedChains:h,walletType:C}){let T=n.filter((P)=>h.includes(P));if(T.length===0)throw new k("wallet_chain_not_supported",{wallet:C,chain:n.join(", ")});let R=n.filter((P)=>!h.includes(P));return l(R.length>0,`${C} wallet does not support the following chains: ${R.join(", ")}. These chains will be ignored.`),T}function Oh(n,h,C){return async(...T)=>{try{await Lh(h,C)}catch(R){throw new k({errorKey:"helpers_failed_to_switch_network",info:{error:R}})}return n(...T)}}function YT({toolbox:n,chain:h,provider:C=window.ethereum,methodNames:T=[]}){let P=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,o)=>{if(!n[o])return x;let B=n[o];if(typeof B!=="function")return x;let _=Oh(B,C,h);return{...x,[o]:_}},{});return{...n,...P}}function Xh(n,h){return Un({provider:n,method:"wallet_addEthereumChain",params:[h]})}function JT(n){window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())}function wT(){let{isTrust:n,isBraveWallet:h,__XDEFI:C,overrideIsMetaMask:T,selectedProvider:R}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&R?.isCoinbaseWallet)return"COINBASE_WEB";if(C)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function VT(){let n=[];function h(T){if(n.map((R)=>R.info.uuid).includes(T.detail.info.uuid))return;n.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function C(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:C}}function Gh(){let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),C=/android|XiaoMi|MiuiBrowser/i.test(n),T=h||C,R=/OKApp/i.test(n);return T&&R}function WT({connect:n,name:h,supportedChains:C,walletType:T}){function R(P){return n({...P,walletType:T,supportedChains:C})}return{[h]:{supportedChains:C,connectWallet:R}}}function Un({provider:n,params:h,method:C}){if(!n?.send)throw new k("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return n.send(C,T)}export{IC as wrapWithThrow,Oh as wrapMethodWithNetworkSwitch,l as warnOnce,wC as validateTNS,In as validateIdentifier,Tn as updateDerivationPath,Lh as switchEVMWalletNetwork,Un as providerRequest,YT as prepareNetworkSwitch,Gh as okxMobileEnabled,Sn as loadTokenLists,ph as listWeb3EVMWallets,zT as isWeb3Detected,Xn as isGasAsset,QT as isDetected,wh as initializeRPCUrlsWithFallback,Eh as getWalletFormatFor,SC as getTHORNameCost,RT as getSymmetricWithdraw,$h as getSymmetricPoolShare,vC as getMinAmountByChain,MT as getMemoForWithdraw,BT as getMemoForUnbond,XT as getMemoForTcyStake,OT as getMemoForTcyClaim,kT as getMemoForRunePoolWithdraw,NT as getMemoForRunePoolDeposit,pT as getMemoForNameRegister,LT as getMemoForNamePreferredAssetRegister,FT as getMemoForLeaveAndBond,$T as getMemoForDeposit,jC as getMAYANameCost,PT as getLiquiditySlippage,MC as getGasAsset,Fh as getFeeMultiplierAsBigInt,Qn as getFeeMultiplier,AT as getEstimatedPoolShare,wT as getETHDefaultWallet,VT as getEIP6963Wallets,gC as getDynamicChainId,fh as getDerivationPathFor,On as getDecimal,s as getCommonAssetInfo,ZC as getChainIdentifier,CT as getAsymmetricRuneWithdrawAmount,Bh as getAsymmetricRuneShare,TT as getAsymmetricAssetWithdrawAmount,Nh as getAsymmetricAssetShare,Rn as getAssetType,t as formatBigIntToSafeValue,kC as findAssetBy,UT as filterSupportedChains,Mn as derivationPathToString,WT as createWallet,ST as createPlugin,An as assetFromString,lC as applyFeeMultiplierToBigInt,rC as applyFeeMultiplier,Xh as addEVMWalletNetwork,JT as addAccountsChangedCallback,fn as WarningCodeEnum,i as WalletOption,Fn as UTXOChains,Yh as TCSupportedChains,U as SwapKitNumber,k as SwapKitError,zh as SubstrateChains,hn as StagenetChain,Kh as SWAP_OUT,th as SWAP_IN,Q as SKConfig,q as RequestClient,m as RPC_URLS,Kn as QuoteMode,En as ProviderName,b as NetworkDerivationPath,E as NODE_URLS,pn as MemoType,Jh as MAYASupportedChains,mn as LedgerErrorCode,un as FeeTypeEnum,kn as FeeOption,Vn as FALLBACK_URLS,yn as ErrorCode,Cn as EXPLORER_URLS,W as EVMChains,mh as DerivationPath,_h as DEFAULT_FEE_MULTIPLIERS,Qh as CosmosChains,Uh as CosmosChainPrefixes,Dn as ContractAddress,$C as CommonAssetStrings,$n as ChainToHexChainId,Vh as ChainToExplorerUrl,Nn as ChainToChainId,Zh as ChainIdToChain,u as ChainId,I as Chain,gh as BlockTimes,V as BigIntArithmetics,L as BaseDecimal,w as AssetValue,vn as ApproveMode,bh as AGG_SWAP};
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:q,identifier:L,tax:w}=G||{decimal:I||Y[X],identifier:x},z=B||W,D=_?e(BigInt(A),_):e(A,q);return F?A_(L,_?D:A):z?R_(L,D):new f({tax:w,decimal:q,identifier:L,value:D})}static async loadStaticAssets(T){let _=await WT(T);for(let{tokens:F}of Object.values(_))for(let{identifier:P,chain:A,...H}of F){let x=A==="SOL"?P:P.toUpperCase(),N="decimals"in H?H.decimals:Y[A];C.set(x,{identifier:P,decimal:N})}return!0}static setStaticAssets(T){C.clear();for(let[_,F]of T.entries()){let P=F.chain==="SOL"?F.identifier:F.identifier.toUpperCase(),A="decimals"in F?F.decimals:F.decimal;C.set(_,{...F,decimal:A,identifier:P})}return!0}}function hF(T){let _=f.from({chain:T});return IT(T).with("BTC","LTC","BCH","DASH",()=>_.set(0.00010001)).with("DOGE",()=>_.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>_.set(0.00000001)).with("THOR","MAYA",()=>_.set(0)).with("GAIA","KUJI",()=>_.set(0.000001)).otherwise(()=>_.set(0.00000001))}async function A_(T,_=0){UT(T);let P=T.includes("SOL.")?T:T.toUpperCase(),A=C.get(P),H=A?.decimal||await LT(NT(T));if(!A)C.set(P,{identifier:T,decimal:H});return new f({decimal:H,value:e(_,H),identifier:T})}function R_(T,_=0){let F=T.includes(".")?T.split(".")?.[0]?.toUpperCase():void 0,P=F?["MAYA","THOR"].includes(F):!1,A=T.slice(0,14).includes("~")?"~":"/",[H,x]=P?T.split(".").slice(1).join().split(A):T.split(A);if(!(H&&x))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});return new f({decimal:8,value:e(_,8),identifier:`${F||"THOR"}.${H}${A}${x}`})}function e(T,_){return typeof T==="bigint"?u({value:T,bigIntDecimal:_,decimal:_}):T}function H_(T){let _=IT(T).when((F)=>("chain"in F)&&F.chain!==void 0,({chain:F})=>F).otherwise((F)=>{let P=RT(F.asset);return P.synth?"THOR":P.chain});if(!Object.values(U).includes(_.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function N_(T){if(H_(T),"chain"in T)return T.chain;let{chain:_,symbol:F}=RT(T.asset);return AT({chain:_,symbol:F})==="Native"?_:T.asset}function NT(T){let _=T.slice(0,14),F=T.split("."),P=F[0]?.toUpperCase(),A=["THOR","MAYA"].includes(P),H=_.includes("/"),x=_.includes("~"),N=H||x,X=x?"~":"/",[B,W=""]=A?F.slice(1).join().split(X):T.split(X);if(N&&!(B&&W))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T}});let[G,...I]=(T.includes(".")&&!N?T:`${P}.${W}`).split("."),q=N?W:I.join("."),{address:L,ticker:w}=x_({symbol:q,chain:G}),z;try{z=L&&g.includes(G)&&kT(L)?kT(L):L}catch(p){z=L}let D=(N?`${B}${X}`:"")+(z?`${w}-${z??""}`:q);return{address:z,chain:G,isSynthOrTrade:N,isSynthetic:H,isTradeAsset:x,ticker:w,symbol:D,isGasAsset:jT({chain:G,symbol:q})}}function x_({symbol:T,chain:_}){let F=T.split("-"),P=F.length===1?void 0:F[F.length-1],A=P_.includes(_)?P:P?.toLowerCase(),H=F.length===1?F[0]:F.slice(0,-1).join("-");return{address:A,ticker:H}}class S extends E{eq(T){return this.eqValue(T)}static fromBigInt(T,_){return new S({decimal:_,value:u({value:T,bigIntDecimal:_,decimal:_})})}}var $_={average:1,fast:1.5,fastest:2};function KT(T="average"){let _=K.get("feeMultipliers");if(_&&_[T]!==void 0)return _[T];return $_[T]}function B_(T="average"){let _=KT(T),F=10n;return{numerator:BigInt(Math.round(_*10)),denominator:F}}function rF(T,_="average"){let{numerator:F,denominator:P}=B_(_);return T*F/P}function iF(T,_="average",F=!1){let P=KT(_),A=T*P;return F?Math.floor(A):A}function G_({liquidityUnits:T,poolUnits:_,runeDepth:F}){let P=O(T),A=O(_),H=O(F),x=P.mul(H),N=A.mul(A).mul(2),X=A.mul(P).mul(2),B=P.mul(P),W=A.mul(A).mul(A);return x.mul(N.sub(X).add(B)).div(W)}function X_({liquidityUnits:T,poolUnits:_,assetDepth:F}){let P=O(T),A=O(_),H=O(F),x=P.mul(H),N=A.mul(A).mul(2),X=A.mul(P).mul(2),B=P.mul(P),W=x.mul(N.sub(X).add(B)),G=A.mul(A).mul(A);return W.div(G)}function _P({percent:T,runeDepth:_,liquidityUnits:F,poolUnits:P}){return G_({runeDepth:_,liquidityUnits:F,poolUnits:P}).mul(T)}function FP({percent:T,assetDepth:_,liquidityUnits:F,poolUnits:P}){return X_({assetDepth:_,liquidityUnits:F,poolUnits:P}).mul(T)}function O(T){return S.fromBigInt(BigInt(T),Y.THOR)}function Q_({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P}){return{assetAmount:O(P).mul(T).div(_),runeAmount:O(F).mul(T).div(_)}}function PP({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P,percent:A}){return Object.fromEntries(Object.entries(Q_({liquidityUnits:T,poolUnits:_,runeDepth:F,assetDepth:P})).map(([H,x])=>[H,x.mul(A)]))}function AP({runeDepth:T,poolUnits:_,assetDepth:F,liquidityUnits:P,runeAmount:A,assetAmount:H}){let x=new S({value:T,decimal:8}),N=new S({value:F,decimal:8}),X=new S({value:_,decimal:8}),B=new S({value:A,decimal:8}),W=new S({value:H,decimal:8}),G=B.mul(N),I=W.mul(x),q=B.mul(W),L=x.mul(N),w=X.mul(G.add(I.add(q.mul(2)))),z=G.add(I.add(L.mul(2))),D=w.div(z),p=O(P).add(D);if(D.getBaseValue("number")===0)return p.div(X).getBaseValue("number");let wT=X.add(p);return p.div(wT).getBaseValue("number")}function RP({runeAmount:T,assetAmount:_,runeDepth:F,assetDepth:P}){if(T==="0"||_==="0"||F==="0"||P==="0")return 0;let A=O(F),H=O(P),x=O(_),N=O(T),X=x.mul(A).sub(H.mul(N)),B=H.mul(N).add(A.mul(H));return Math.abs(X.div(B).getBaseValue("number"))}import{match as z_}from"ts-pattern";function BP({type:T,address:_}){return`${T}:${_}`}function GP({address:T,unbondAmount:_}){return`${"UNBOND"}:${T}:${_}`}function XP(T){return TT("POOL+",T)}function QP({chain:T,symbol:_,address:F,...P}){let A=Z_({chain:T,symbol:_}),H=F?`:${F}:`:":";return TT(`${"+"}:${A}${H}`,P)}function zP({chain:T,symbol:_,ticker:F,basisPoints:P,targetAsset:A}){let H=T==="ETH"&&F!=="ETH"?`${F}-${_.slice(-3)}`:_,x=A?`:${A}`:"";return`${"-"}:${T}.${H}:${P}${x}`}function ZP({basisPoints:T,..._}){return TT(`${"POOL-"}:${T}`,_)}function JP({name:T,chain:_,address:F,owner:P}){let A=`${"~"}:${T}:${_}:${F}`,H=P?`:${P}`:"";return`${A}${H}`}function MP({name:T,chain:_,asset:F,payout:P,owner:A}){return`${"~"}:${T}:${_}:${P}:${A}:${F}`}function YP(T,{address:_}){return`${T}:${_}`}function LP(T,{unstakeBps:_,...F}){let P=_?`:${_}`:"",A=`${T}${P}`;return TT(`${A}`,F)}function TT(T,{affiliateAddress:_,affiliateBasisPoints:F}={}){let P=`${T}${_?`:${_}:${F||0}`:""}`;return P.endsWith(":")?P.slice(0,-1):P}function Z_({chain:T,symbol:_}){return z_(T).with("BTC","DOGE","LTC",()=>T.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${T}.${_}`)}function VP({name:T,properties:_,methods:F}){function P(A){return{...F(A),..._}}return{[T]:P}}function kP(){return typeof window.ethereum!=="undefined"}function IP(T){return J_().includes(T)}function J_(){let T=window?.ethereum&&!window.ethereum?.isBraveWallet,_=window?.xfi||window?.ethereum?.__XDEFI,F=window?.ethereum?.isBraveWallet,P=window?.ethereum?.isTrust||window?.trustwallet,A=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=window?.bitkeep?.ethereum,x=window?.$onekey?.ethereum,N=[];if(T)N.push("METAMASK");if(_)N.push("CTRL");if(F)N.push("BRAVE");if(P)N.push("TRUSTWALLET_WEB");if(A)N.push("COINBASE_WEB");if(j_())N.push("OKX_MOBILE");if(H)N.push("BITGET");if(x)N.push("ONEKEY");return N}async function M_(T,_,F){try{await ST({provider:T,method:"wallet_switchEthereumChain",params:[{chainId:zT[_]}]})}catch(P){if(!F)throw new J("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await L_(T,F)}}function KP({chains:T,supportedChains:_,walletType:F}){let P=T.filter((H)=>_.includes(H));if(P.length===0)throw new J("wallet_chain_not_supported",{wallet:F,chain:T.join(", ")});let A=T.filter((H)=>!_.includes(H));return i(A.length>0,`${F} wallet does not support the following chains: ${A.join(", ")}. These chains will be ignored.`),P}function Y_(T,_,F){return async(...P)=>{try{await M_(_,F)}catch(A){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:A}})}return T(...P)}}function SP({toolbox:T,chain:_,provider:F=window.ethereum,methodNames:P=[]}){let H=[...P,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,N)=>{if(!T[N])return x;let X=T[N];if(typeof X!=="function")return x;let B=Y_(X,F,_);return{...x,[N]:B}},{});return{...T,...H}}function L_(T,_){return ST({provider:T,method:"wallet_addEthereumChain",params:[_]})}function wP(T){window.ethereum?.on("accountsChanged",()=>T()),window.xfi?.ethereum.on("accountsChanged",()=>T())}function DP(){let{isTrust:T,isBraveWallet:_,__XDEFI:F,overrideIsMetaMask:P,selectedProvider:A}=window?.ethereum||{};if(T)return"TRUSTWALLET_WEB";if(_)return"BRAVE";if(P&&A?.isCoinbaseWallet)return"COINBASE_WEB";if(F)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function fP(){let T=[];function _(P){if(T.map((A)=>A.info.uuid).includes(P.detail.info.uuid))return;T.push(P.detail)}window.addEventListener("eip6963:announceProvider",_),window.dispatchEvent(new Event("eip6963:requestProvider"));function F(){window.removeEventListener("eip6963:announceProvider",_)}return{providers:T,removeEIP6963EventListener:F}}function j_(){let T=navigator.userAgent,_=/iphone|ipad|ipod|ios/i.test(T),F=/android|XiaoMi|MiuiBrowser/i.test(T),P=_||F,A=/OKApp/i.test(T);return P&&A}function EP({connect:T,name:_,supportedChains:F,walletType:P}){function A(H){return T({...H,walletType:P,supportedChains:F})}return{[_]:{supportedChains:F,connectWallet:A}}}function ST({provider:T,params:_,method:F}){if(!T?.send)throw new J("helpers_not_found_provider");let P=_?Array.isArray(_)?_:[_]:[];return T.send(F,P)}export{qF as wrapWithThrow,Y_ as wrapMethodWithNetworkSwitch,i as warnOnce,DF as validateTNS,UT as validateIdentifier,PT as updateDerivationPath,M_ as switchEVMWalletNetwork,ST as providerRequest,SP as prepareNetworkSwitch,j_ as okxMobileEnabled,WT as loadTokenLists,J_ as listWeb3EVMWallets,kP as isWeb3Detected,jT as isGasAsset,IP as isDetected,D_ as initializeRPCUrlsWithFallback,d_ as getWalletFormatFor,VF as getTHORNameCost,PP as getSymmetricWithdraw,Q_ as getSymmetricPoolShare,hF as getMinAmountByChain,zP as getMemoForWithdraw,GP as getMemoForUnbond,LP as getMemoForTcyStake,YP as getMemoForTcyClaim,ZP as getMemoForRunePoolWithdraw,XP as getMemoForRunePoolDeposit,JP as getMemoForNameRegister,MP as getMemoForNamePreferredAssetRegister,BP as getMemoForLeaveAndBond,QP as getMemoForDeposit,WF as getMAYANameCost,RP as getLiquiditySlippage,zF as getGasAsset,B_ as getFeeMultiplierAsBigInt,KT as getFeeMultiplier,AP as getEstimatedPoolShare,DP as getETHDefaultWallet,fP as getEIP6963Wallets,OF as getDynamicChainId,m_ as getDerivationPathFor,LT as getDecimal,r as getCommonAssetInfo,UF as getChainIdentifier,_P as getAsymmetricRuneWithdrawAmount,G_ as getAsymmetricRuneShare,FP as getAsymmetricAssetWithdrawAmount,X_ as getAsymmetricAssetShare,AT as getAssetType,u as formatBigIntToSafeValue,ZF as findAssetBy,KP as filterSupportedChains,ZT as derivationPathToString,EP as createWallet,VP as createPlugin,RT as assetFromString,rF as applyFeeMultiplierToBigInt,iF as applyFeeMultiplier,L_ as addEVMWalletNetwork,wP as addAccountsChangedCallback,dT as WarningCodeEnum,s as WalletOption,GT as UTXOChains,S_ as TCSupportedChains,S as SwapKitNumber,J as SwapKitError,k_ as SubstrateChains,_T as StagenetChain,u_ as SWAP_OUT,v_ as SWAP_IN,K as SKConfig,y as RequestClient,l as RPC_URLS,CT as QuoteMode,oT as ProviderName,v as NetworkDerivationPath,o as NODE_URLS,MT as MemoType,w_ as MAYASupportedChains,lT as LedgerErrorCode,hT as FeeTypeEnum,JT as FeeOption,ET as FALLBACK_URLS,mT as ErrorCode,FT as EXPLORER_URLS,g as EVMChains,c_ as DerivationPath,$_ as DEFAULT_FEE_MULTIPLIERS,I_ as CosmosChains,K_ as CosmosChainPrefixes,pT as ContractAddress,QF as CommonAssetStrings,zT as ChainToHexChainId,f_ as ChainToExplorerUrl,QT as ChainToChainId,U_ as ChainIdToChain,h as ChainId,U as Chain,O_ as BlockTimes,E as BigIntArithmetics,Y as BaseDecimal,f as AssetValue,cT as ApproveMode,y_ as AGG_SWAP};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=E761A026120DA33864756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|