@swapkit/helpers 4.0.0-beta.25 → 4.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/package.json +4 -4
- package/src/modules/swapKitError.ts +1 -0
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_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 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).
|
|
2
2
|
This can result in incorrect calculations and mess with amount sent on transactions.
|
|
3
3
|
You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
|
|
4
4
|
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:j,identifier: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};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=662F9B3E35B2B08964756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|