@swapkit/helpers 3.0.0-beta.14 → 3.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +10 -9
- package/dist/index.js +3 -3
- package/dist/index.js.map +10 -9
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/modules/feeMultiplier.ts +87 -0
- package/src/modules/swapKitConfig.ts +9 -0
- package/src/modules/swapKitError.ts +31 -1
- package/src/types/chains.ts +17 -8
- package/src/types/wallet.ts +2 -0
- package/src/utils/asset.ts +1 -0
- package/src/utils/derivationPath.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as IT,b as bT,c as oT,d as gT}from"./chunk-8fdws4se.js";import{s as z,u as F}from"./chunk-s82pm7xc.js";import{getAddress as JC}from"ethers";import{match as aC}from"ts-pattern";import{match as kC}from"ts-pattern";var UC={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,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_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_not_supported:50801,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class j extends Error{static ErrorCode=UC;constructor(C,h){let R=typeof C==="string",T=R?C:C.errorKey,P=R?void 0:C.info,_=`${T}${P?`: ${JSON.stringify(P)}`:""}`;super(_);if(Object.setPrototypeOf(this,j.prototype),this.name="SwapKitError",this.cause=h,h)console.error(`SwapKitError [${T}]:`,h);else if(P)console.error(`SwapKitError [${T}]:`,P)}}var J;((O)=>{O.Arbitrum="ARB";O.Avalanche="AVAX";O.Base="BASE";O.BinanceSmartChain="BSC";O.Bitcoin="BTC";O.BitcoinCash="BCH";O.Cosmos="GAIA";O.Dash="DASH";O.Dogecoin="DOGE";O.Ethereum="ETH";O.Fiat="FIAT";O.Kujira="KUJI";O.Litecoin="LTC";O.Maya="MAYA";O.Near="NEAR";O.Optimism="OP";O.Polkadot="DOT";O.Chainflip="FLIP";O.Polygon="MATIC";O.Radix="XRD";O.Ripple="XRP";O.THORChain="THOR";O.Solana="SOL";O.Tron="TRX"})(J||={});var e;((R)=>{R.THORChain="THOR_STAGENET";R.Maya="MAYA_STAGENET"})(e||={});var v;((E)=>{E.Arbitrum="42161";E.ArbitrumHex="0xa4b1";E.Avalanche="43114";E.AvalancheHex="0xa86a";E.Base="8453";E.BaseHex="0x2105";E.BinanceSmartChain="56";E.BinanceSmartChainHex="0x38";E.Bitcoin="bitcoin";E.BitcoinCash="bitcoincash";E.Chainflip="chainflip";E.Cosmos="cosmoshub-4";E.Dash="dash";E.Dogecoin="dogecoin";E.Kujira="kaiyo-1";E.Ethereum="1";E.EthereumHex="0x1";E.Fiat="fiat";E.Litecoin="litecoin";E.Maya="mayachain-mainnet-v1";E.MayaStagenet="mayachain-stagenet-v1";E.Near="near";E.Optimism="10";E.OptimismHex="0xa";E.Polkadot="polkadot";E.Polygon="137";E.PolygonHex="0x89";E.Radix="radix-mainnet";E.Ripple="ripple";E.THORChain="thorchain-1";E.THORChainStagenet="thorchain-stagenet-v2";E.Solana="solana";E.Tron="tron"})(v||={});var jh={["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",["tron"]:"TRX"},qC=Object.keys(J),c=Object.values(J),G={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},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},Lh=["DOT","FLIP"],p=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],HC=["BTC","BCH","DASH","DOGE","LTC"],Nh=["GAIA","THOR","MAYA","KUJI"],zh={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},Fh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Zh=["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.ankr.com/near",["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://api.trongrid.io",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},f={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},WC={["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.quickapi.com","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://rpc.ankr.com/eth"],["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"],["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://rpc.ankr.com/polygon"],["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",f.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"],["TRX"]:["https://api.tronstack.io","https://api.tron.network"]},CC={["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"},xC=m,wC=(C)=>{return kC(C).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC","TRX",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC",()=>({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",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("XRD",()=>"").otherwise(()=>{throw new j("helpers_chain_not_supported",{chain:C})})};function SC(C){return C==="XRD"?"/status/network-configuration":""}var BC=async(C,h)=>{try{let R=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${R}${SC(C)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(wC(C)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},pC=async(C)=>{let h=m[C];if(await BC(C,h))return h;for(let R of WC[C])if(await BC(C,R))return R;return h},Qh=async(C=[...Object.values(J),...Object.values(e)])=>{let h={};await Promise.all(C.map(async(R)=>{let T=await pC(R);h[R]=T})),xC={...xC,...h}},$C=c.reduce((C,h)=>{let R=qC.find((T)=>J[T]===h);if(R)C[h]=R;return C},{}),EC=c.reduce((C,h)=>{return C[h]=v[$C[h]],C},{}),XC=c.reduce((C,h)=>{let R=`${$C[h]}Hex`;return C[h]=v[R],C},{}),Jh=c.reduce((C,h)=>{return C[h]=CC[h],C},{});import{match as r}from"ts-pattern";import{createStore as oC}from"zustand/vanilla";var VC;((X)=>{X.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";X.TC_SUPPORTED_TO_ETH="TC-ERC20";X.TC_SUPPORTED_TO_AVAX="TC-ARC20";X.TC_SUPPORTED_TO_BSC="TC-BEP20";X.ETH_TO_TC_SUPPORTED="ERC20-TC";X.ETH_TO_ETH="ERC20-ERC20";X.ETH_TO_AVAX="ERC20-ARC20";X.ETH_TO_BSC="ERC20-BEP20";X.AVAX_TO_TC_SUPPORTED="ARC20-TC";X.AVAX_TO_ETH="ARC20-ERC20";X.AVAX_TO_AVAX="ARC20-ARC20";X.AVAX_TO_BSC="ARC20-BEP20";X.BSC_TO_TC_SUPPORTED="BEP20-TC";X.BSC_TO_ETH="BEP20-ERC20";X.BSC_TO_AVAX="BEP20-ARC20";X.BSC_TO_BSC="BEP20-BEP20"})(VC||={});var Yh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Uh=["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 hC(C,h){if("index"in h)return[...C.slice(0,C.length-1),h.index];if("change"in h){let[R,T,P,,_]=C;return[R,T,P,h.change,_]}if("account"in h){let[R,T,,P,_]=C;return[R,T,h.account,P,_]}return C}function AC([C,h,R,T,P]){return`m/${C}'/${h}'/${R}'/${T}${typeof P!=="number"?"":`/${P}`}`}function wh({chain:C,index:h,addressIndex:R=0,type:T}){if(p.includes(C)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,R];return hC(D[C],{index:h})}if(C==="SOL"){if(T==="account")return[44,501,0,h];return hC(D[C],{index:h})}let P=C==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,P,h,0,R];case"segwit":return[49,P,0,0,h];case"legacy":return[44,P,0,0,h];default:return hC(D[C],{index:h})}}function Sh(C){let[h,R,T]=C.split("/").map((P)=>Number.parseInt(P,10));switch(R){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var KC;((x)=>{x.ARB="0x0000000000000000000000000000000000000000";x.AVAX="0x0000000000000000000000000000000000000000";x.BASE="0x0000000000000000000000000000000000000000";x.ETH="0x0000000000000000000000000000000000000000";x.BSC="0x0000000000000000000000000000000000000000";x.MATIC="0x0000000000000000000000000000000000001010";x.OP="0x4200000000000000000000000000000000000042"})(KC||={});var D={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],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]},Kh=Object.keys(D).reduce((C,h)=>{return C[h]=AC(D[h]),C},{});var DC;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(DC||={});var IC;((R)=>{R.Approve="approve";R.CheckOnly="checkOnly"})(IC||={});var OC;((H)=>{H.NAME_REGISTER="~";H.BOND="BOND";H.DEPOSIT="+";H.LEAVE="LEAVE";H.UNBOND="UNBOND";H.WITHDRAW="-";H.RUNEPOOL_DEPOSIT="POOL+";H.RUNEPOOL_WITHDRAW="POOL-"})(OC||={});var u;((A)=>{A.BITGET="BITGET";A.BRAVE="BRAVE";A.COINBASE_MOBILE="COINBASE_MOBILE";A.COINBASE_WEB="COINBASE_WEB";A.COSMOSTATION="COSMOSTATION";A.CTRL="CTRL";A.EIP6963="EIP6963";A.EXODUS="EXODUS";A.KEEPKEY="KEEPKEY";A.KEEPKEY_BEX="KEEPKEY_BEX";A.KEPLR="KEPLR";A.KEYSTORE="KEYSTORE";A.LEAP="LEAP";A.LEDGER="LEDGER";A.LEDGER_LIVE="LEDGER_LIVE";A.METAMASK="METAMASK";A.OKX="OKX";A.OKX_MOBILE="OKX_MOBILE";A.ONEKEY="ONEKEY";A.PHANTOM="PHANTOM";A.POLKADOT_JS="POLKADOT_JS";A.RADIX_WALLET="RADIX_WALLET";A.TREZOR="TREZOR";A.TALISMAN="TALISMAN";A.TRUSTWALLET_WEB="TRUSTWALLET_WEB";A.WALLETCONNECT="WALLETCONNECT"})(u||={});var bC;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(bC||={});var gC={apis:{},chains:Object.values(J),wallets:Object.values(u),explorerUrls:CC,nodeUrls:f,rpcUrls:m,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:""},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"}}}},U=oC((C)=>({...gC,setApiKey:(h,R)=>C((T)=>({apiKeys:{...T.apiKeys,[h]:R}})),setEnv:(h,R)=>C((T)=>({envs:{...T.envs,[h]:R}})),setExplorerUrl:(h,R)=>C((T)=>({explorerUrls:{...T.explorerUrls,[h]:R}})),setNodeUrl:(h,R)=>C((T)=>({nodeUrls:{...T.nodeUrls,[h]:R}})),setRpcUrl:(h,R)=>C((T)=>({rpcUrls:{...T.rpcUrls,[h]:R}})),setIntegrationConfig:(h,R)=>C((T)=>({integrations:{...T.integrations,[h]:R}})),setConfig:(h)=>C((R)=>({apiKeys:{...R.apiKeys,...h.apiKeys},envs:{...R.envs,...h.envs},explorerUrls:{...R.explorerUrls,...h.explorerUrls},integrations:{...R.integrations,...h.integrations},nodeUrls:{...R.nodeUrls,...h.nodeUrls},rpcUrls:{...R.rpcUrls,...h.rpcUrls},chains:R.chains.concat(h.chains||[]),wallets:R.wallets.concat(h.wallets||[])}))})),k={getState:U.getState,get:(C)=>U.getState()[C],set:(C)=>U.getState().setConfig(C),setApiKey:(C,h)=>U.getState().setApiKey(C,h),setEnv:(C,h)=>U.getState().setEnv(C,h),setExplorerUrl:(C,h)=>U.getState().setExplorerUrl(C,h),setNodeUrl:(C,h)=>U.getState().setNodeUrl(C,h),setRpcUrl:(C,h)=>U.getState().setRpcUrl(C,h),setIntegrationConfig:(C,h)=>U.getState().setIntegrationConfig(C,h)};var I={get:t("GET"),post:t("POST"),extend:(C)=>({get:t("GET",C),post:t("POST",C),extend:(h)=>I.extend({...C,...h})})};function t(C,h={}){return async(R,T={})=>{let{searchParams:P,json:_,body:B,headers:x}={...h,...T},H=!!_||R.endsWith(".json"),$=H?JSON.stringify(_):B;try{let L=nC(R,P),N=yC(H,x),Z=await fetch(L,{...T,method:C,body:$,headers:N});if(!Z.ok){let Q=await Z.text();throw new j("helpers_invalid_response",{status:Z.status,statusText:Z.statusText,message:Q})}let Y=await Z.json();return T.onSuccess?.(Y)||T.responseHandler?.(Y)||Y}catch(L){if(T.onError)return T.onError(L);throw L}}}function yC(C,h){let{swapKit:R}=k.get("apiKeys");return{...h,...C?{"Content-Type":"application/json"}:{},...R?{"x-api-key":R}:{}}}function nC(C,h){let R=new URL(C);if(h)R.search=new URLSearchParams(h).toString();return R.toString()}var TR=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],jC=["ARB","BASE","ETH","OP","MATIC"];async function fC({chain:C,to:h}){try{let{result:T}=await I.post(k.get("rpcUrls")[C],{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||G[C]).toString())}catch(T){return console.error(`Failed to fetch contract decimals for ${h} on ${C}:`,T),G[C]}}async function vC(C){if(C==="XRD")return G.XRD;try{let h=C.split("-")[1]?.toLowerCase(),{manager:R}=await I.post(`${k.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return R.divisibility.value.divisibility}catch(h){return console.error(`Failed to fetch Radix asset decimal for ${C}:`,h),G["XRD"]}}async function cC({chain:C,symbol:h}){if(p.includes(h))return G[h];let R=h.split("-"),T=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(T?.startsWith("0x")?fC({chain:C,to:T}):G[C])}function GC({chain:C,symbol:h}){return r(C).with(...p,(R)=>cC({chain:R,symbol:h})).with("XRD",()=>vC(h)).otherwise(()=>G[C])}function PR({chain:C}){return w.from({chain:C})}function LC({chain:C,symbol:h}){return r(C).with(...jC,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${C}.${h}`===d(C).identifier).otherwise(()=>h===C)}var d=(C)=>{let h=G[C];return r(C.toUpperCase()).with(...jC,(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(...HC,"SOL","FLIP","KUJI","XRP","DOT","TRX",(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:G.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:G.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:G.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:C,decimal:h}))};function RC({chain:C,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return r(C).with("XRD",()=>h==="XRD"||`${C}.${h}`===d(C).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===C)?"Native":C}var a=(C)=>{let[h,...R]=C.split("."),T=C.includes("/"),P=R.join("."),_=P?.split("-"),B=_?.length?_.length===1?_[0]:_.slice(0,-1).join("-"):void 0;return{chain:h,symbol:P,ticker:B,synth:T}};async function _R(C){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let R of Object.values(h))for(let{identifier:T,chain:P,..._}of R.tokens){if("identifier"in C&&T===C.identifier)return T;if("address"in _&&"chain"in C&&P===C.chain&&_.address.toLowerCase()===C.contract.toLowerCase())return T}return}function XR(C){if(C<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return 10+C}function AR(C){if(C<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return Math.round((10+C*1.0512)*10000000000)/10000000000}function OR(C,h){try{return C()}catch(R){if(h)throw new j(h,R);return}}function jR(C){switch(C){case"THOR":return`${C}.RUNE`;case"GAIA":return`${C}.ATOM`;case"BSC":return`${C}`;default:return`${C}.${C}`}}var NC=new Set;function i(C,h){if(C){if(NC.has(h))return;NC.add(h)}}async function GR(C="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(C))return C;try{let h=k.get("rpcUrls")[C!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await I.get(`${h}/status`)).result.node_info.network}catch(h){return C}}import{match as mC}from"ts-pattern";var uC=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function zC(C){let h=C||uC,R={};for(let T of h){let P=await tC(T);R[T]=P}return R}async function tC(C){let{list:h}=await mC(C).with("camelot",()=>import("./chunk-bh986mnf.js")).with("caviar",()=>import("./chunk-b8hashv0.js")).with("chainflip",()=>import("./chunk-rr043vwc.js")).with("jupiter",()=>import("./chunk-7shcm26h.js")).with("mayachain",()=>import("./chunk-wssz50sc.js")).with("oneinch",()=>import("./chunk-vadspc46.js")).with("openocean",()=>import("./chunk-jhmhh7ax.js")).with("pancakeswap",()=>import("./chunk-tn4e7zrk.js")).with("pangolin",()=>import("./chunk-ghdhtvtt.js")).with("sushiswap",()=>import("./chunk-rarep8vg.js")).with("thorchain",()=>import("./chunk-bf0ph1bk.js")).with("traderjoe",()=>import("./chunk-nm1av1e6.js")).with("uniswap",()=>import("./chunk-dzypg9sp.js")).with("uniswapv3",()=>import("./chunk-vgg88vt8.js")).exhaustive();return h}var FC=["TERRA",...k.get("chains")];function ZC(C=""){let h=C.toUpperCase(),[R]=h.split(".");if(FC.includes(R))return!0;let[T]=h.split("/");if(FC.includes(T))return!0;throw new j({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${C}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:C}})}function QR(C){if(C.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!C.match(h)}var n=8,V=(C)=>10n**BigInt(C),y=(C)=>Math.log10(Number.parseFloat(C.toString()));function b({value:C,bigIntDecimal:h=n,decimal:R=n}){if(R===0)return C.toString();let T=C<0n,P=C.toString().substring(T?1:0),_=R-(P.length-1);if(_>0)P="0".repeat(_)+P;let B=P.length-R,x=P.slice(-R);if(Number.parseInt(x[h]||"0")>=5)x=`${x.substring(0,h-1)}${(Number.parseInt(x[h-1]||"0")+1).toString()}`;else x=x.substring(0,h);return`${T?"-":""}${P.slice(0,B)}.${x}`.replace(/\.?0*$/,"")}function rC(C,h){if(h===0n)throw new Error("Cannot divide by zero");let R=h/2n;if(C>=0n&&h>=0n||C<0n&&h<0n)return(C+R)/h;return(C-R)/h}class S{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(C,h){return new S({decimal:h,value:b({value:C,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:C,from:h,to:R}){return S.fromBigInt(C.getBaseValue("bigint")*V(R)/V(h),R)}constructor(C){let h=TC(C),R=typeof C==="object";this.decimal=R?C.decimal:void 0,this.decimalMultiplier=R&&"decimalMultiplier"in C?C.decimalMultiplier:V(Math.max(QC(s(h)),this.decimal||0)),this.#P(h)}set(C){return new this.constructor({decimal:this.decimal,value:C,identifier:this.toString({includeSynthProtocol:!0})})}add(...C){return this.#h("add",...C)}sub(...C){return this.#h("sub",...C)}mul(...C){return this.#h("mul",...C)}div(...C){return this.#h("div",...C)}gt(C){return this.#C("gt",C)}gte(C){return this.#C("gte",C)}lt(C){return this.#C("lt",C)}lte(C){return this.#C("lte",C)}eqValue(C){return this.#C("eqValue",C)}getValue(C,h){let R=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||y(this.decimalMultiplier));switch(C){case"number":return Number(R);case"string":return R;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return R}}getBaseValue(C,h){let R=this.decimalMultiplier/V(h||this.decimal||G.THOR),T=rC(this.bigIntValue,R);switch(C){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(C,h){if(!h&&typeof C==="object")return C.bigIntValue;let R=TC(C),T=s(R);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if((Number.parseInt(T)?T.length+P.length:P.length)<=C)return this.getValue("string");if(T.length>=C)return T.slice(0,C).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${P.slice(0,C-T.length)}`.padEnd(C-T.length,"0");let B=Number.parseInt(P),x=`${B}`.slice(0,C);return`0.${x.padStart(P.length-`${B}`.length+x.length,"0")}`}toFixed(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if(Number.parseInt(T))return`${T}.${P.slice(0,C)}`.padEnd(C,"0");let _=Number.parseInt(P),B=`${_}`.slice(0,C);return`0.${B.padStart(P.length-`${_}`.length+B.length,"0")}`}toAbbreviation(C=2){let h=this.getValue("number"),R=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),P=R[T];if(!P)return this.getValue("string");let _=10**(T*3);return`${(h/_).toFixed(C)}${P}`}toCurrency(C="$",{currencyPosition:h="start",decimal:R=2,decimalSeparator:T=".",thousandSeparator:P=","}={}){let _=this.getValue("number"),[B="",x=""]=_.toFixed(6).split("."),H=B.replace(/\B(?=(\d{3})+(?!\d))/g,P),$=B||x?B==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",T):`${H}${Number.parseInt(x)?`${T}${x.slice(0,R)}`:""}`:"0.00";return`${h==="start"?C:""}${$}${h==="end"?C:""}`}formatBigIntToSafeValue(C,h){let R=h||this.decimal||n,T=Math.max(R,y(this.decimalMultiplier)),P=C<0n,_=C.toString().substring(P?1:0),B=T-(_.length-1),x=B>0?"0".repeat(B)+_:_,H=x.length-T,$=x.slice(-T);if(Number.parseInt($[R]||"0")>=5)$=`${$.substring(0,R-1)}${(Number.parseInt($[R-1]||"0")+1).toString()}`;else $=$.substring(0,R);return`${P?"-":""}${x.slice(0,H)}.${$}`.replace(/\.?0*$/,"")}#h(C,...h){let R=this.#R(this,...h),T=Math.max(R,y(this.decimalMultiplier)),P=V(T),_=h.reduce((x,H)=>{let $=this.getBigIntValue(H,T);switch(C){case"add":return x+$;case"sub":return x-$;case"mul":return x*$/P;case"div":{if($===0n)throw new RangeError("Division by zero");return x*P/$}default:return x}},this.bigIntValue*P/this.decimalMultiplier),B=b({bigIntDecimal:T,decimal:T,value:_});return new this.constructor({decimalMultiplier:V(T),decimal:this.decimal,value:B,identifier:this.toString()})}#C(C,...h){let R=this.#R(this,...h),T=this.getBigIntValue(h[0]||"0",R),P=this.getBigIntValue(this,R);switch(C){case"gt":return P>T;case"gte":return P>=T;case"lt":return P<T;case"lte":return P<=T;case"eqValue":return P===T;default:return!1}}#P(C){let h=s(C)||"0";this.bigIntValue=this.#T(h)}#R(...C){let h=C.map((R)=>{return typeof R==="object"?R.decimal||y(R.decimalMultiplier):QC(s(R))}).filter(Boolean);return Math.max(...h,n)}#T(C,h){let R=h?V(h):this.decimalMultiplier,T=y(R),[P="",_=""]=C.split(".");return BigInt(`${P}${_.padEnd(T,"0")}`)}}var dC=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function s(C){let R=`${typeof C==="number"?dC.format(C):TC(C)}`.replaceAll(",",".").split(".");return R.length>1?`${R.slice(0,-1).join("")}.${R.at(-1)}`:R[0]||"0"}function QC(C){let h=C.split(".")[1]?.length||0;return Math.max(h,n)}function TC(C){return typeof C==="object"?"getValue"in C?C.getValue("string"):C.value:C}var o=new Map;class w extends S{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:C,decimal:h,tax:R,chain:T,symbol:P,identifier:_}){super(typeof C==="object"?C:{decimal:h,value:C});let B=PC(_||`${T}.${P}`);this.type=RC(B),this.tax=R,this.chain=B.chain,this.ticker=B.ticker,this.symbol=B.symbol,this.address=B.address,this.isSynthetic=B.isSynthetic,this.isTradeAsset=B.isTradeAsset,this.isGasAsset=B.isGasAsset,this.chainId=EC[B.chain]}toString({includeSynthProtocol:C}={}){return(this.isSynthetic||this.isTradeAsset)&&!C?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:C,symbol:h}){return this.chain===C&&this.symbol===h}eq(C){return this.eqAsset(C)&&this.eqValue(C)}static fromUrl(C,h=0){let[R,T,P]=C.split(".");if(!(R&&T))throw new j({errorKey:"helpers_invalid_asset_url",info:{urlAsset:C}});let _=R==="THOR"&&P?`${R}.${T}/${P}`:C;return w.from({asset:_,value:h})}static from({value:C=0,fromBaseDecimal:h,asyncTokenLookup:R,...T}){let P=C instanceof S?C.getValue("string"):C,_=eC(T),{identifier:B,decimal:x}=d(_),{chain:H,isSynthetic:$,isTradeAsset:L}=PC(B),N=o.get(H==="SOL"?B:B.toUpperCase()),Z=N?.decimal||x;i(!(R||Z),`Couldn't find static decimal for one or more tokens on ${H} (Using default ${G[H]} decimal as fallback).
|
|
1
|
+
import{a as mT,b as uT,c as dT,d as rT}from"./chunk-8fdws4se.js";import{s as Z,u as Q}from"./chunk-s82pm7xc.js";import{getAddress as FC}from"ethers";import{match as iC}from"ts-pattern";import{match as WC}from"ts-pattern";var qC={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,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_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_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 G extends Error{static ErrorCode=qC;constructor(C,h){let R=typeof C==="string",T=R?C:C.errorKey,P=R?void 0:C.info,_=`${T}${P?`: ${JSON.stringify(P)}`:""}`;super(_);if(Object.setPrototypeOf(this,G.prototype),this.name="SwapKitError",this.cause=h,h)console.error(`SwapKitError [${T}]:`,h);else if(P)console.error(`SwapKitError [${T}]:`,P)}}var Y;((A)=>{A.Arbitrum="ARB";A.Avalanche="AVAX";A.Base="BASE";A.BinanceSmartChain="BSC";A.Bitcoin="BTC";A.BitcoinCash="BCH";A.Cosmos="GAIA";A.Dash="DASH";A.Dogecoin="DOGE";A.Ethereum="ETH";A.Fiat="FIAT";A.Kujira="KUJI";A.Litecoin="LTC";A.Maya="MAYA";A.Near="NEAR";A.Optimism="OP";A.Polkadot="DOT";A.Chainflip="FLIP";A.Polygon="MATIC";A.Radix="XRD";A.Ripple="XRP";A.THORChain="THOR";A.Solana="SOL";A.Tron="TRX"})(Y||={});var e;((R)=>{R.THORChain="THOR_STAGENET";R.Maya="MAYA_STAGENET"})(e||={});var v;(($)=>{$.Arbitrum="42161";$.ArbitrumHex="0xa4b1";$.Avalanche="43114";$.AvalancheHex="0xa86a";$.Base="8453";$.BaseHex="0x2105";$.BinanceSmartChain="56";$.BinanceSmartChainHex="0x38";$.Bitcoin="bitcoin";$.BitcoinCash="bitcoincash";$.Chainflip="chainflip";$.Cosmos="cosmoshub-4";$.Dash="dash";$.Dogecoin="dogecoin";$.Kujira="kaiyo-1";$.Ethereum="1";$.EthereumHex="0x1";$.Fiat="fiat";$.Litecoin="litecoin";$.Maya="mayachain-mainnet-v1";$.MayaStagenet="mayachain-stagenet-v1";$.Near="near";$.Optimism="10";$.OptimismHex="0xa";$.Polkadot="polkadot";$.Polygon="137";$.PolygonHex="0x89";$.Radix="radix-mainnet";$.Ripple="ripple";$.THORChain="thorchain-1";$.THORChainStagenet="thorchain-stagenet-v2";$.Solana="solana";$.Tron="728126428";$.TronHex="0x2b6653dc"})(v||={});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"},wC=Object.keys(Y),c=Object.values(Y),N={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},Zh={["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},Qh=["DOT","FLIP"],V=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],BC=["BTC","BCH","DASH","DOGE","LTC"],Jh=["GAIA","THOR","MAYA","KUJI"],Oh={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},Yh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Fh=["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",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},n={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},SC={["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",n.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"]},CC={["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"},xC=m,VC=(C)=>{return WC(C).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC","TRX",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC",()=>({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",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("XRD",()=>"").otherwise(()=>{throw new G("helpers_chain_not_supported",{chain:C})})};function KC(C){return C==="XRD"?"/status/network-configuration":""}var HC=async(C,h)=>{try{let R=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${R}${KC(C)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(VC(C)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},bC=async(C)=>{let h=m[C];if(await HC(C,h))return h;for(let R of SC[C])if(await HC(C,R))return R;return h},Mh=async(C=[...Object.values(Y),...Object.values(e)])=>{let h={};await Promise.all(C.map(async(R)=>{let T=await bC(R);h[R]=T})),xC={...xC,...h}},$C=c.reduce((C,h)=>{let R=wC.find((T)=>Y[T]===h);if(R)C[h]=R;return C},{}),EC=c.reduce((C,h)=>{return C[h]=v[$C[h]],C},{}),XC=c.reduce((C,h)=>{let R=`${$C[h]}Hex`;return C[h]=v[R],C},{}),Uh=c.reduce((C,h)=>{return C[h]=CC[h],C},{});import{match as r}from"ts-pattern";import{createStore as gC}from"zustand/vanilla";var DC;((X)=>{X.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";X.TC_SUPPORTED_TO_ETH="TC-ERC20";X.TC_SUPPORTED_TO_AVAX="TC-ARC20";X.TC_SUPPORTED_TO_BSC="TC-BEP20";X.ETH_TO_TC_SUPPORTED="ERC20-TC";X.ETH_TO_ETH="ERC20-ERC20";X.ETH_TO_AVAX="ERC20-ARC20";X.ETH_TO_BSC="ERC20-BEP20";X.AVAX_TO_TC_SUPPORTED="ARC20-TC";X.AVAX_TO_ETH="ARC20-ERC20";X.AVAX_TO_AVAX="ARC20-ARC20";X.AVAX_TO_BSC="ARC20-BEP20";X.BSC_TO_TC_SUPPORTED="BEP20-TC";X.BSC_TO_ETH="BEP20-ERC20";X.BSC_TO_AVAX="BEP20-ARC20";X.BSC_TO_BSC="BEP20-BEP20"})(DC||={});var qh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Wh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],wh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function hC(C,h){if("index"in h)return[...C.slice(0,C.length-1),h.index];if("change"in h){let[R,T,P,,_]=C;return[R,T,P,h.change,_]}if("account"in h){let[R,T,,P,_]=C;return[R,T,h.account,P,_]}return C}function jC([C,h,R,T,P]){let _=typeof P!=="number";if(typeof T!=="number")return`m/${C}'/${h}'/${R}'`;return`m/${C}'/${h}'/${R}'/${T}${_?"":`/${P}`}`}function Kh({chain:C,index:h,addressIndex:R=0,type:T}){if(V.includes(C)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,R];return hC(D[C],{index:h})}if(C==="SOL"){if(T==="account")return[44,501,0,h];return hC(D[C],{index:h})}let P=C==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,P,h,0,R];case"segwit":return[49,P,0,0,h];case"legacy":return[44,P,0,0,h];default:return hC(D[C],{index:h})}}function bh(C){let[h,R,T]=C.split("/").map((P)=>Number.parseInt(P,10));switch(R){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var IC;((x)=>{x.ARB="0x0000000000000000000000000000000000000000";x.AVAX="0x0000000000000000000000000000000000000000";x.BASE="0x0000000000000000000000000000000000000000";x.ETH="0x0000000000000000000000000000000000000000";x.BSC="0x0000000000000000000000000000000000000000";x.MATIC="0x0000000000000000000000000000000000001010";x.OP="0x4200000000000000000000000000000000000042"})(IC||={});var D={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],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]},ph=Object.keys(D).reduce((C,h)=>{return C[h]=jC(D[h]),C},{});var AC;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(AC||={});var pC;((R)=>{R.Approve="approve";R.CheckOnly="checkOnly"})(pC||={});var GC;((B)=>{B.NAME_REGISTER="~";B.BOND="BOND";B.DEPOSIT="+";B.LEAVE="LEAVE";B.UNBOND="UNBOND";B.WITHDRAW="-";B.RUNEPOOL_DEPOSIT="POOL+";B.RUNEPOOL_WITHDRAW="POOL-"})(GC||={});var u;((j)=>{j.BITGET="BITGET";j.BRAVE="BRAVE";j.COINBASE_MOBILE="COINBASE_MOBILE";j.COINBASE_WEB="COINBASE_WEB";j.COSMOSTATION="COSMOSTATION";j.CTRL="CTRL";j.EIP6963="EIP6963";j.EXODUS="EXODUS";j.KEEPKEY="KEEPKEY";j.KEEPKEY_BEX="KEEPKEY_BEX";j.KEPLR="KEPLR";j.KEYSTORE="KEYSTORE";j.LEAP="LEAP";j.LEDGER="LEDGER";j.LEDGER_LIVE="LEDGER_LIVE";j.METAMASK="METAMASK";j.OKX="OKX";j.OKX_MOBILE="OKX_MOBILE";j.ONEKEY="ONEKEY";j.PHANTOM="PHANTOM";j.POLKADOT_JS="POLKADOT_JS";j.RADIX_WALLET="RADIX_WALLET";j.TREZOR="TREZOR";j.TALISMAN="TALISMAN";j.TRUSTWALLET_WEB="TRUSTWALLET_WEB";j.WALLETCONNECT="WALLETCONNECT"})(u||={});var yC;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(yC||={});var fC={apis:{},chains:Object.values(Y),wallets:Object.values(u),explorerUrls:CC,nodeUrls:n,rpcUrls:m,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},feeMultipliers:void 0},k=gC((C)=>({...fC,setApiKey:(h,R)=>C((T)=>({apiKeys:{...T.apiKeys,[h]:R}})),setEnv:(h,R)=>C((T)=>({envs:{...T.envs,[h]:R}})),setExplorerUrl:(h,R)=>C((T)=>({explorerUrls:{...T.explorerUrls,[h]:R}})),setNodeUrl:(h,R)=>C((T)=>({nodeUrls:{...T.nodeUrls,[h]:R}})),setRpcUrl:(h,R)=>C((T)=>({rpcUrls:{...T.rpcUrls,[h]:R}})),setIntegrationConfig:(h,R)=>C((T)=>({integrations:{...T.integrations,[h]:R}})),setFeeMultipliers:(h)=>C(()=>({feeMultipliers:h})),setConfig:(h)=>C((R)=>({apiKeys:{...R.apiKeys,...h.apiKeys},envs:{...R.envs,...h.envs},explorerUrls:{...R.explorerUrls,...h.explorerUrls},integrations:{...R.integrations,...h.integrations},nodeUrls:{...R.nodeUrls,...h.nodeUrls},rpcUrls:{...R.rpcUrls,...h.rpcUrls},feeMultipliers:h.feeMultipliers||R.feeMultipliers,chains:R.chains.concat(h.chains||[]),wallets:R.wallets.concat(h.wallets||[])}))})),U={getState:k.getState,get:(C)=>k.getState()[C],set:(C)=>k.getState().setConfig(C),setApiKey:(C,h)=>k.getState().setApiKey(C,h),setEnv:(C,h)=>k.getState().setEnv(C,h),setExplorerUrl:(C,h)=>k.getState().setExplorerUrl(C,h),setNodeUrl:(C,h)=>k.getState().setNodeUrl(C,h),setRpcUrl:(C,h)=>k.getState().setRpcUrl(C,h),setIntegrationConfig:(C,h)=>k.getState().setIntegrationConfig(C,h),setFeeMultipliers:(C)=>k.getState().setFeeMultipliers(C)};var I={get:d("GET"),post:d("POST"),extend:(C)=>({get:d("GET",C),post:d("POST",C),extend:(h)=>I.extend({...C,...h})})};function d(C,h={}){return async(R,T={})=>{let{searchParams:P,json:_,body:H,headers:x}={...h,...T},B=!!_||R.endsWith(".json"),E=B?JSON.stringify(_):H;try{let L=nC(R,P),z=oC(B,x),J=await fetch(L,{...T,method:C,body:E,headers:z});if(!J.ok){let O=await J.text();throw new G("helpers_invalid_response",{status:J.status,statusText:J.statusText,message:O})}let M=await J.json();return T.onSuccess?.(M)||T.responseHandler?.(M)||M}catch(L){if(T.onError)return T.onError(L);throw L}}}function oC(C,h){let{swapKit:R}=U.get("apiKeys");return{...h,...C?{"Content-Type":"application/json"}:{},...R?{"x-api-key":R}:{}}}function nC(C,h){let R=new URL(C);if(h)R.search=new URLSearchParams(h).toString();return R.toString()}var xR=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],NC=["ARB","BASE","ETH","OP","MATIC"];async function vC({chain:C,to:h}){try{let{result:T}=await I.post(U.get("rpcUrls")[C],{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||N[C]).toString())}catch(T){return console.error(`Failed to fetch contract decimals for ${h} on ${C}:`,T),N[C]}}async function cC(C){if(C==="XRD")return N.XRD;try{let h=C.split("-")[1]?.toLowerCase(),{manager:R}=await I.post(`${U.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return R.divisibility.value.divisibility}catch(h){return console.error(`Failed to fetch Radix asset decimal for ${C}:`,h),N["XRD"]}}async function mC({chain:C,symbol:h}){if(V.includes(h))return N[h];let R=h.split("-"),T=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(T?.startsWith("0x")?vC({chain:C,to:T}):N[C])}function LC({chain:C,symbol:h}){return r(C).with(...V,(R)=>mC({chain:R,symbol:h})).with("XRD",()=>cC(h)).otherwise(()=>N[C])}function HR({chain:C}){return w.from({chain:C})}function zC({chain:C,symbol:h}){return r(C).with(...NC,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${C}.${h}`===t(C).identifier).otherwise(()=>h===C)}var t=(C)=>{let h=N[C];return r(C.toUpperCase()).with(...NC,(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(...BC,"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:N.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:N.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:N.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:C,decimal:h}))};function RC({chain:C,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return r(C).with("XRD",()=>h==="XRD"||`${C}.${h}`===t(C).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===C)?"Native":C}var a=(C)=>{let[h,...R]=C.split("."),T=C.includes("/"),P=R.join("."),_=P?.split("-"),H=_?.length?_.length===1?_[0]:_.slice(0,-1).join("-"):void 0;return{chain:h,symbol:P,ticker:H,synth:T}};async function BR(C){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let R of Object.values(h))for(let{identifier:T,chain:P,..._}of R.tokens){if("identifier"in C&&T===C.identifier)return T;if("address"in _&&"chain"in C&&P===C.chain&&_.address.toLowerCase()===C.contract.toLowerCase())return T}return}function GR(C){if(C<0)throw new G({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return 10+C}function NR(C){if(C<0)throw new G({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return Math.round((10+C*1.0512)*10000000000)/10000000000}function LR(C,h){try{return C()}catch(R){if(h)throw new G(h,R);return}}function zR(C){switch(C){case"THOR":return`${C}.RUNE`;case"GAIA":return`${C}.ATOM`;case"BSC":return`${C}`;default:return`${C}.${C}`}}var ZC=new Set;function i(C,h){if(C){if(ZC.has(h))return;ZC.add(h)}}async function ZR(C="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(C))return C;try{let h=U.get("rpcUrls")[C!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await I.get(`${h}/status`)).result.node_info.network}catch(h){return C}}import{match as uC}from"ts-pattern";var dC=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function QC(C){let h=C||dC,R={};for(let T of h){let P=await rC(T);R[T]=P}return R}async function rC(C){let{list:h}=await uC(C).with("camelot",()=>import("./chunk-bh986mnf.js")).with("caviar",()=>import("./chunk-b8hashv0.js")).with("chainflip",()=>import("./chunk-rr043vwc.js")).with("jupiter",()=>import("./chunk-7shcm26h.js")).with("mayachain",()=>import("./chunk-wssz50sc.js")).with("oneinch",()=>import("./chunk-vadspc46.js")).with("openocean",()=>import("./chunk-jhmhh7ax.js")).with("pancakeswap",()=>import("./chunk-tn4e7zrk.js")).with("pangolin",()=>import("./chunk-ghdhtvtt.js")).with("sushiswap",()=>import("./chunk-rarep8vg.js")).with("thorchain",()=>import("./chunk-bf0ph1bk.js")).with("traderjoe",()=>import("./chunk-nm1av1e6.js")).with("uniswap",()=>import("./chunk-dzypg9sp.js")).with("uniswapv3",()=>import("./chunk-vgg88vt8.js")).exhaustive();return h}var JC=["TERRA",...U.get("chains")];function OC(C=""){let h=C.toUpperCase(),[R]=h.split(".");if(JC.includes(R))return!0;let[T]=h.split("/");if(JC.includes(T))return!0;throw new G({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${C}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:C}})}function MR(C){if(C.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!C.match(h)}var o=8,K=(C)=>10n**BigInt(C),f=(C)=>Math.log10(Number.parseFloat(C.toString()));function p({value:C,bigIntDecimal:h=o,decimal:R=o}){if(R===0)return C.toString();let T=C<0n,P=C.toString().substring(T?1:0),_=R-(P.length-1);if(_>0)P="0".repeat(_)+P;let H=P.length-R,x=P.slice(-R);if(Number.parseInt(x[h]||"0")>=5)x=`${x.substring(0,h-1)}${(Number.parseInt(x[h-1]||"0")+1).toString()}`;else x=x.substring(0,h);return`${T?"-":""}${P.slice(0,H)}.${x}`.replace(/\.?0*$/,"")}function tC(C,h){if(h===0n)throw new Error("Cannot divide by zero");let R=h/2n;if(C>=0n&&h>=0n||C<0n&&h<0n)return(C+R)/h;return(C-R)/h}class S{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(C,h){return new S({decimal:h,value:p({value:C,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:C,from:h,to:R}){return S.fromBigInt(C.getBaseValue("bigint")*K(R)/K(h),R)}constructor(C){let h=TC(C),R=typeof C==="object";this.decimal=R?C.decimal:void 0,this.decimalMultiplier=R&&"decimalMultiplier"in C?C.decimalMultiplier:K(Math.max(YC(s(h)),this.decimal||0)),this.#P(h)}set(C){return new this.constructor({decimal:this.decimal,value:C,identifier:this.toString({includeSynthProtocol:!0})})}add(...C){return this.#h("add",...C)}sub(...C){return this.#h("sub",...C)}mul(...C){return this.#h("mul",...C)}div(...C){return this.#h("div",...C)}gt(C){return this.#C("gt",C)}gte(C){return this.#C("gte",C)}lt(C){return this.#C("lt",C)}lte(C){return this.#C("lte",C)}eqValue(C){return this.#C("eqValue",C)}getValue(C,h){let R=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||f(this.decimalMultiplier));switch(C){case"number":return Number(R);case"string":return R;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return R}}getBaseValue(C,h){let R=this.decimalMultiplier/K(h||this.decimal||N.THOR),T=tC(this.bigIntValue,R);switch(C){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(C,h){if(!h&&typeof C==="object")return C.bigIntValue;let R=TC(C),T=s(R);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if((Number.parseInt(T)?T.length+P.length:P.length)<=C)return this.getValue("string");if(T.length>=C)return T.slice(0,C).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${P.slice(0,C-T.length)}`.padEnd(C-T.length,"0");let H=Number.parseInt(P),x=`${H}`.slice(0,C);return`0.${x.padStart(P.length-`${H}`.length+x.length,"0")}`}toFixed(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if(Number.parseInt(T))return`${T}.${P.slice(0,C)}`.padEnd(C,"0");let _=Number.parseInt(P),H=`${_}`.slice(0,C);return`0.${H.padStart(P.length-`${_}`.length+H.length,"0")}`}toAbbreviation(C=2){let h=this.getValue("number"),R=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),P=R[T];if(!P)return this.getValue("string");let _=10**(T*3);return`${(h/_).toFixed(C)}${P}`}toCurrency(C="$",{currencyPosition:h="start",decimal:R=2,decimalSeparator:T=".",thousandSeparator:P=","}={}){let _=this.getValue("number"),[H="",x=""]=_.toFixed(6).split("."),B=H.replace(/\B(?=(\d{3})+(?!\d))/g,P),E=H||x?H==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",T):`${B}${Number.parseInt(x)?`${T}${x.slice(0,R)}`:""}`:"0.00";return`${h==="start"?C:""}${E}${h==="end"?C:""}`}formatBigIntToSafeValue(C,h){let R=h||this.decimal||o,T=Math.max(R,f(this.decimalMultiplier)),P=C<0n,_=C.toString().substring(P?1:0),H=T-(_.length-1),x=H>0?"0".repeat(H)+_:_,B=x.length-T,E=x.slice(-T);if(Number.parseInt(E[R]||"0")>=5)E=`${E.substring(0,R-1)}${(Number.parseInt(E[R-1]||"0")+1).toString()}`;else E=E.substring(0,R);return`${P?"-":""}${x.slice(0,B)}.${E}`.replace(/\.?0*$/,"")}#h(C,...h){let R=this.#R(this,...h),T=Math.max(R,f(this.decimalMultiplier)),P=K(T),_=h.reduce((x,B)=>{let E=this.getBigIntValue(B,T);switch(C){case"add":return x+E;case"sub":return x-E;case"mul":return x*E/P;case"div":{if(E===0n)throw new RangeError("Division by zero");return x*P/E}default:return x}},this.bigIntValue*P/this.decimalMultiplier),H=p({bigIntDecimal:T,decimal:T,value:_});return new this.constructor({decimalMultiplier:K(T),decimal:this.decimal,value:H,identifier:this.toString()})}#C(C,...h){let R=this.#R(this,...h),T=this.getBigIntValue(h[0]||"0",R),P=this.getBigIntValue(this,R);switch(C){case"gt":return P>T;case"gte":return P>=T;case"lt":return P<T;case"lte":return P<=T;case"eqValue":return P===T;default:return!1}}#P(C){let h=s(C)||"0";this.bigIntValue=this.#T(h)}#R(...C){let h=C.map((R)=>{return typeof R==="object"?R.decimal||f(R.decimalMultiplier):YC(s(R))}).filter(Boolean);return Math.max(...h,o)}#T(C,h){let R=h?K(h):this.decimalMultiplier,T=f(R),[P="",_=""]=C.split(".");return BigInt(`${P}${_.padEnd(T,"0")}`)}}var aC=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function s(C){let R=`${typeof C==="number"?aC.format(C):TC(C)}`.replaceAll(",",".").split(".");return R.length>1?`${R.slice(0,-1).join("")}.${R.at(-1)}`:R[0]||"0"}function YC(C){let h=C.split(".")[1]?.length||0;return Math.max(h,o)}function TC(C){return typeof C==="object"?"getValue"in C?C.getValue("string"):C.value:C}var y=new Map;class w extends S{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:C,decimal:h,tax:R,chain:T,symbol:P,identifier:_}){super(typeof C==="object"?C:{decimal:h,value:C});let H=PC(_||`${T}.${P}`);this.type=RC(H),this.tax=R,this.chain=H.chain,this.ticker=H.ticker,this.symbol=H.symbol,this.address=H.address,this.isSynthetic=H.isSynthetic,this.isTradeAsset=H.isTradeAsset,this.isGasAsset=H.isGasAsset,this.chainId=EC[H.chain]}toString({includeSynthProtocol:C}={}){return(this.isSynthetic||this.isTradeAsset)&&!C?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:C,symbol:h}){return this.chain===C&&this.symbol===h}eq(C){return this.eqAsset(C)&&this.eqValue(C)}static fromUrl(C,h=0){let[R,T,P]=C.split(".");if(!(R&&T))throw new G({errorKey:"helpers_invalid_asset_url",info:{urlAsset:C}});let _=R==="THOR"&&P?`${R}.${T}/${P}`:C;return w.from({asset:_,value:h})}static from({value:C=0,fromBaseDecimal:h,asyncTokenLookup:R,...T}){let P=C instanceof S?C.getValue("string"):C,_=Ch(T),{identifier:H,decimal:x}=t(_),{chain:B,isSynthetic:E,isTradeAsset:L}=PC(H),z=y.get(B==="SOL"?H:H.toUpperCase()),J=z?.decimal||x;i(!(R||J),`Couldn't find static decimal for one or more tokens on ${B} (Using default ${N[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
|
-
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:Y,identifier:Q,tax:K}=N||{decimal:Z||G[H],identifier:B},X=$||L,W=h?l(BigInt(P),h):l(P,Y);return R?iC(Q,h?W:P):X?sC(Q,W):new w({tax:K,decimal:Y,identifier:Q,value:W})}static async loadStaticAssets(C){let h=await zC(C);for(let{tokens:R}of Object.values(h))for(let{identifier:T,chain:P,..._}of R){let B=P==="SOL"?T:T.toUpperCase(),x="decimals"in _?_.decimals:G[P];o.set(B,{identifier:T,decimal:x})}return!0}static setStaticAssets(C){o.clear();for(let[h,R]of C.entries()){let T=R.chain==="SOL"?R.identifier:R.identifier.toUpperCase(),P="decimals"in R?R.decimals:R.decimal;o.set(h,{...R,decimal:P,identifier:T})}return!0}}function DR(C){let h=w.from({chain:C});return aC(C).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 iC(C,h=0){ZC(C);let T=C.includes("SOL.")?C:C.toUpperCase(),P=o.get(T),_=P?.decimal||await GC(PC(C));if(!P)o.set(T,{identifier:C,decimal:_});return new w({decimal:_,value:l(h,_),identifier:C})}function sC(C,h=0){let R=C.includes(".")?C.split(".")?.[0]?.toUpperCase():void 0,T=R?["MAYA","THOR"].includes(R):!1,P=C.slice(0,14).includes("~")?"~":"/",[_,B]=T?C.split(".").slice(1).join().split(P):C.split(P);if(!(_&&B))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});return new w({decimal:8,value:l(h,8),identifier:`${R||"THOR"}.${_}${P}${B}`})}function l(C,h){return typeof C==="bigint"?b({value:C,bigIntDecimal:h,decimal:h}):C}function lC(C){let h="chain"in C?C.chain:a(C.asset).synth?"THOR":a(C.asset).chain;if(!Object.values(J).includes(h.toUpperCase()))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function eC(C){if(lC(C),"chain"in C)return C.chain;let{chain:h,symbol:R}=a(C.asset);return RC({chain:h,symbol:R})==="Native"?h:C.asset}function PC(C){let h=C.slice(0,14),R=C.split("."),T=R[0]?.toUpperCase(),P=["THOR","MAYA"].includes(T),_=h.includes("/"),B=h.includes("~"),x=_||B,H=B?"~":"/",[$,L=""]=P?R.slice(1).join().split(H):C.split(H);if(x&&!($&&L))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});let[N,...Z]=(C.includes(".")&&!x?C:`${T}.${L}`).split("."),Y=x?L:Z.join("."),{address:Q,ticker:K}=Ch({symbol:Y,chain:N}),X;try{X=Q&&p.includes(N)&&JC(Q)?JC(Q):Q}catch(g){X=Q}let W=(x?`${$}${H}`:"")+(X?`${K}-${X??""}`:Y);return{address:X,chain:N,isSynthOrTrade:x,isSynthetic:_,isTradeAsset:B,ticker:K,symbol:W,isGasAsset:LC({chain:N,symbol:Y})}}function Ch({symbol:C,chain:h}){let R=C.split("-"),T=R.length===1?void 0:R[R.length-1],P=h==="SOL"?T:T?.toLowerCase(),_=R.length===1?R[0]:R.slice(0,-1).join("-");return{address:P,ticker:_}}class q extends S{eq(C){return this.eqValue(C)}static fromBigInt(C,h){return new q({decimal:h,value:b({value:C,bigIntDecimal:h,decimal:h})})}}function hh({liquidityUnits:C,poolUnits:h,runeDepth:R}){let T=M(C),P=M(h),_=M(R),B=T.mul(_),x=P.mul(P).mul(2),H=P.mul(T).mul(2),$=T.mul(T),L=P.mul(P).mul(P);return B.mul(x.sub(H).add($)).div(L)}function Rh({liquidityUnits:C,poolUnits:h,assetDepth:R}){let T=M(C),P=M(h),_=M(R),B=T.mul(_),x=P.mul(P).mul(2),H=P.mul(T).mul(2),$=T.mul(T),L=B.mul(x.sub(H).add($)),N=P.mul(P).mul(P);return L.div(N)}function nR({percent:C,runeDepth:h,liquidityUnits:R,poolUnits:T}){return hh({runeDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function fR({percent:C,assetDepth:h,liquidityUnits:R,poolUnits:T}){return Rh({assetDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function M(C){return q.fromBigInt(BigInt(C),G.THOR)}function Th({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T}){return{assetAmount:M(T).mul(C).div(h),runeAmount:M(R).mul(C).div(h)}}function vR({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T,percent:P}){return Object.fromEntries(Object.entries(Th({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T})).map(([_,B])=>[_,B.mul(P)]))}function cR({runeDepth:C,poolUnits:h,assetDepth:R,liquidityUnits:T,runeAmount:P,assetAmount:_}){let B=new q({value:C,decimal:8}),x=new q({value:R,decimal:8}),H=new q({value:h,decimal:8}),$=new q({value:P,decimal:8}),L=new q({value:_,decimal:8}),N=$.mul(x),Z=L.mul(B),Y=$.mul(L),Q=B.mul(x),K=H.mul(N.add(Z.add(Y.mul(2)))),X=N.add(Z.add(Q.mul(2))),W=K.div(X),g=M(T).add(W);if(W.getBaseValue("number")===0)return g.div(H).getBaseValue("number");let YC=H.add(g);return g.div(YC).getBaseValue("number")}function mR({runeAmount:C,assetAmount:h,runeDepth:R,assetDepth:T}){if(C==="0"||h==="0"||R==="0"||T==="0")return 0;let P=M(R),_=M(T),B=M(h),x=M(C),H=B.mul(P).sub(_.mul(x)),$=_.mul(x).add(P.mul(_));return Math.abs(H.div($).getBaseValue("number"))}import{match as Ph}from"ts-pattern";function aR({type:C,address:h}){return`${C}:${h}`}function iR({address:C,unbondAmount:h}){return`${"UNBOND"}:${C}:${h}`}function sR(C){return _C("POOL+",C)}function lR({chain:C,symbol:h,address:R,...T}){let P=_h({chain:C,symbol:h}),_=R?`:${R}:`:":";return _C(`${"+"}:${P}${_}`,T)}function eR({chain:C,symbol:h,ticker:R,basisPoints:T,targetAsset:P}){let _=C==="ETH"&&R!=="ETH"?`${R}-${h.slice(-3)}`:h,B=P?`:${P}`:"";return`${"-"}:${C}.${_}:${T}${B}`}function CT({basisPoints:C,...h}){return _C(`${"POOL-"}:${C}`,h)}function hT({name:C,chain:h,address:R,owner:T}){let P=`${"~"}:${C}:${h}:${R}`,_=T?`:${T}`:"";return`${P}${_}`}function RT({name:C,chain:h,asset:R,payout:T,owner:P}){return`${"~"}:${C}:${h}:${T}:${P}:${R}`}function _C(C,{affiliateAddress:h,affiliateBasisPoints:R}={}){let T=`${C}${h?`:${h}:${R||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function _h({chain:C,symbol:h}){return Ph(C).with("BTC","DOGE","LTC",()=>C.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${C}.${h}`)}function PT({name:C,properties:h,methods:R}){function T(P){return{...R(P),...h}}return{[C]:T}}function $T(){return typeof window.ethereum!=="undefined"}function ET(C){return xh().includes(C)}function xh(){let C=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,R=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,P=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,_=window?.bitkeep?.ethereum,B=window?.$onekey?.ethereum,x=[];if(C)x.push("METAMASK");if(h)x.push("CTRL");if(R)x.push("BRAVE");if(T)x.push("TRUSTWALLET_WEB");if(P)x.push("COINBASE_WEB");if(Eh())x.push("OKX_MOBILE");if(_)x.push("BITGET");if(B)x.push("ONEKEY");return x}async function Bh(C,h,R){try{await MC({provider:C,method:"wallet_switchEthereumChain",params:[{chainId:XC[h]}]})}catch(T){if(!R)throw new j("helpers_failed_to_switch_network",{error:T,reason:"networkParams not provided"});await $h(C,R)}}function XT({chains:C,supportedChains:h,walletType:R}){let T=C.filter((_)=>h.includes(_));if(T.length===0)throw new j("wallet_chain_not_supported",{wallet:R,chain:C.join(", ")});let P=C.filter((_)=>!h.includes(_));return i(P.length>0,`${R} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`),T}function Hh(C,h,R){return async(...T)=>{try{await Bh(h,R)}catch(P){throw new j({errorKey:"helpers_failed_to_switch_network",info:{error:P}})}return C(...T)}}function AT({toolbox:C,chain:h,provider:R=window.ethereum,methodNames:T=[]}){let _=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((B,x)=>{if(!C[x])return B;let H=C[x];if(typeof H!=="function")return B;let $=Hh(H,R,h);return{...B,[x]:$}},{});return{...C,..._}}function $h(C,h){return MC({provider:C,method:"wallet_addEthereumChain",params:[h]})}function OT(C){window.ethereum?.on("accountsChanged",()=>C()),window.xfi?.ethereum.on("accountsChanged",()=>C())}function jT(){let{isTrust:C,isBraveWallet:h,__XDEFI:R,overrideIsMetaMask:T,selectedProvider:P}=window?.ethereum||{};if(C)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(R)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function GT(){let C=[];function h(T){if(C.map((P)=>P.info.uuid).includes(T.detail.info.uuid))return;C.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function R(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:C,removeEIP6963EventListener:R}}function Eh(){let C=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(C),R=/android|XiaoMi|MiuiBrowser/i.test(C),T=h||R,P=/OKApp/i.test(C);return T&&P}function LT({connect:C,name:h,supportedChains:R,walletType:T}){function P(_){return C({..._,walletType:T,supportedChains:R})}return{[h]:{supportedChains:R,connectWallet:P}}}function MC({provider:C,params:h,method:R}){if(!C?.send)throw new j("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return C.send(R,T)}export{OR as wrapWithThrow,Hh as wrapMethodWithNetworkSwitch,i as warnOnce,QR as validateTNS,ZC as validateIdentifier,hC as updateDerivationPath,Bh as switchEVMWalletNetwork,MC as providerRequest,AT as prepareNetworkSwitch,Eh as okxMobileEnabled,zC as loadTokenLists,xh as listWeb3EVMWallets,$T as isWeb3Detected,LC as isGasAsset,ET as isDetected,Qh as initializeRPCUrlsWithFallback,Sh as getWalletFormatFor,XR as getTHORNameCost,vR as getSymmetricWithdraw,Th as getSymmetricPoolShare,DR as getMinAmountByChain,eR as getMemoForWithdraw,iR as getMemoForUnbond,CT as getMemoForRunePoolWithdraw,sR as getMemoForRunePoolDeposit,hT as getMemoForNameRegister,RT as getMemoForNamePreferredAssetRegister,aR as getMemoForLeaveAndBond,lR as getMemoForDeposit,AR as getMAYANameCost,mR as getLiquiditySlippage,PR as getGasAsset,cR as getEstimatedPoolShare,jT as getETHDefaultWallet,GT as getEIP6963Wallets,GR as getDynamicChainId,wh as getDerivationPathFor,GC as getDecimal,d as getCommonAssetInfo,jR as getChainIdentifier,nR as getAsymmetricRuneWithdrawAmount,hh as getAsymmetricRuneShare,fR as getAsymmetricAssetWithdrawAmount,Rh as getAsymmetricAssetShare,RC as getAssetType,b as formatBigIntToSafeValue,_R as findAssetBy,XT as filterSupportedChains,AC as derivationPathToString,LT as createWallet,PT as createPlugin,a as assetFromString,$h as addEVMWalletNetwork,OT as addAccountsChangedCallback,bT as WarningCodeEnum,u as WalletOption,HC as UTXOChains,Fh as TCSupportedChains,q as SwapKitNumber,j as SwapKitError,Lh as SubstrateChains,e as StagenetChain,kh as SWAP_OUT,Uh as SWAP_IN,k as SKConfig,I as RequestClient,m as RPC_URLS,VC as QuoteMode,oT as ProviderName,D as NetworkDerivationPath,f as NODE_URLS,OC as MemoType,Zh as MAYASupportedChains,bC as LedgerErrorCode,gT as FeeTypeEnum,DC as FeeOption,WC as FALLBACK_URLS,IT as ErrorCode,CC as EXPLORER_URLS,p as EVMChains,Kh as DerivationPath,Nh as CosmosChains,zh as CosmosChainPrefixes,KC as ContractAddress,TR as CommonAssetStrings,XC as ChainToHexChainId,Jh as ChainToExplorerUrl,EC as ChainToChainId,jh as ChainIdToChain,v as ChainId,J as Chain,Gh as BlockTimes,S as BigIntArithmetics,G as BaseDecimal,w as AssetValue,IC as ApproveMode,Yh as AGG_SWAP};
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:M,identifier:O,tax:b}=z||{decimal:J||N[B],identifier:H},X=E||L,W=h?l(BigInt(P),h):l(P,M);return R?sC(O,h?W:P):X?lC(O,W):new w({tax:b,decimal:M,identifier:O,value:W})}static async loadStaticAssets(C){let h=await QC(C);for(let{tokens:R}of Object.values(h))for(let{identifier:T,chain:P,..._}of R){let H=P==="SOL"?T:T.toUpperCase(),x="decimals"in _?_.decimals:N[P];y.set(H,{identifier:T,decimal:x})}return!0}static setStaticAssets(C){y.clear();for(let[h,R]of C.entries()){let T=R.chain==="SOL"?R.identifier:R.identifier.toUpperCase(),P="decimals"in R?R.decimals:R.decimal;y.set(h,{...R,decimal:P,identifier:T})}return!0}}function yR(C){let h=w.from({chain:C});return iC(C).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 sC(C,h=0){OC(C);let T=C.includes("SOL.")?C:C.toUpperCase(),P=y.get(T),_=P?.decimal||await LC(PC(C));if(!P)y.set(T,{identifier:C,decimal:_});return new w({decimal:_,value:l(h,_),identifier:C})}function lC(C,h=0){let R=C.includes(".")?C.split(".")?.[0]?.toUpperCase():void 0,T=R?["MAYA","THOR"].includes(R):!1,P=C.slice(0,14).includes("~")?"~":"/",[_,H]=T?C.split(".").slice(1).join().split(P):C.split(P);if(!(_&&H))throw new G({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});return new w({decimal:8,value:l(h,8),identifier:`${R||"THOR"}.${_}${P}${H}`})}function l(C,h){return typeof C==="bigint"?p({value:C,bigIntDecimal:h,decimal:h}):C}function eC(C){let h="chain"in C?C.chain:a(C.asset).synth?"THOR":a(C.asset).chain;if(!Object.values(Y).includes(h.toUpperCase()))throw new G({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function Ch(C){if(eC(C),"chain"in C)return C.chain;let{chain:h,symbol:R}=a(C.asset);return RC({chain:h,symbol:R})==="Native"?h:C.asset}function PC(C){let h=C.slice(0,14),R=C.split("."),T=R[0]?.toUpperCase(),P=["THOR","MAYA"].includes(T),_=h.includes("/"),H=h.includes("~"),x=_||H,B=H?"~":"/",[E,L=""]=P?R.slice(1).join().split(B):C.split(B);if(x&&!(E&&L))throw new G({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});let[z,...J]=(C.includes(".")&&!x?C:`${T}.${L}`).split("."),M=x?L:J.join("."),{address:O,ticker:b}=hh({symbol:M,chain:z}),X;try{X=O&&V.includes(z)&&FC(O)?FC(O):O}catch(g){X=O}let W=(x?`${E}${B}`:"")+(X?`${b}-${X??""}`:M);return{address:X,chain:z,isSynthOrTrade:x,isSynthetic:_,isTradeAsset:H,ticker:b,symbol:W,isGasAsset:zC({chain:z,symbol:M})}}function hh({symbol:C,chain:h}){let R=C.split("-"),T=R.length===1?void 0:R[R.length-1],P=h==="SOL"?T:T?.toLowerCase(),_=R.length===1?R[0]:R.slice(0,-1).join("-");return{address:P,ticker:_}}class q extends S{eq(C){return this.eqValue(C)}static fromBigInt(C,h){return new q({decimal:h,value:p({value:C,bigIntDecimal:h,decimal:h})})}}var Rh={average:1,fast:1.5,fastest:2};function MC(C="average"){let h=U.get("feeMultipliers");if(h&&h[C]!==void 0)return h[C];return Rh[C]}function Th(C="average"){let h=MC(C),R=10n;return{numerator:BigInt(Math.round(h*10)),denominator:R}}function cR(C,h="average"){let{numerator:R,denominator:T}=Th(h);return C*R/T}function mR(C,h="average",R=!1){let T=MC(h),P=C*T;return R?Math.floor(P):P}function Ph({liquidityUnits:C,poolUnits:h,runeDepth:R}){let T=F(C),P=F(h),_=F(R),H=T.mul(_),x=P.mul(P).mul(2),B=P.mul(T).mul(2),E=T.mul(T),L=P.mul(P).mul(P);return H.mul(x.sub(B).add(E)).div(L)}function _h({liquidityUnits:C,poolUnits:h,assetDepth:R}){let T=F(C),P=F(h),_=F(R),H=T.mul(_),x=P.mul(P).mul(2),B=P.mul(T).mul(2),E=T.mul(T),L=H.mul(x.sub(B).add(E)),z=P.mul(P).mul(P);return L.div(z)}function tR({percent:C,runeDepth:h,liquidityUnits:R,poolUnits:T}){return Ph({runeDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function aR({percent:C,assetDepth:h,liquidityUnits:R,poolUnits:T}){return _h({assetDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function F(C){return q.fromBigInt(BigInt(C),N.THOR)}function xh({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T}){return{assetAmount:F(T).mul(C).div(h),runeAmount:F(R).mul(C).div(h)}}function iR({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T,percent:P}){return Object.fromEntries(Object.entries(xh({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T})).map(([_,H])=>[_,H.mul(P)]))}function sR({runeDepth:C,poolUnits:h,assetDepth:R,liquidityUnits:T,runeAmount:P,assetAmount:_}){let H=new q({value:C,decimal:8}),x=new q({value:R,decimal:8}),B=new q({value:h,decimal:8}),E=new q({value:P,decimal:8}),L=new q({value:_,decimal:8}),z=E.mul(x),J=L.mul(H),M=E.mul(L),O=H.mul(x),b=B.mul(z.add(J.add(M.mul(2)))),X=z.add(J.add(O.mul(2))),W=b.div(X),g=F(T).add(W);if(W.getBaseValue("number")===0)return g.div(B).getBaseValue("number");let kC=B.add(g);return g.div(kC).getBaseValue("number")}function lR({runeAmount:C,assetAmount:h,runeDepth:R,assetDepth:T}){if(C==="0"||h==="0"||R==="0"||T==="0")return 0;let P=F(R),_=F(T),H=F(h),x=F(C),B=H.mul(P).sub(_.mul(x)),E=_.mul(x).add(P.mul(_));return Math.abs(B.div(E).getBaseValue("number"))}import{match as Hh}from"ts-pattern";function TT({type:C,address:h}){return`${C}:${h}`}function PT({address:C,unbondAmount:h}){return`${"UNBOND"}:${C}:${h}`}function _T(C){return _C("POOL+",C)}function xT({chain:C,symbol:h,address:R,...T}){let P=Bh({chain:C,symbol:h}),_=R?`:${R}:`:":";return _C(`${"+"}:${P}${_}`,T)}function HT({chain:C,symbol:h,ticker:R,basisPoints:T,targetAsset:P}){let _=C==="ETH"&&R!=="ETH"?`${R}-${h.slice(-3)}`:h,H=P?`:${P}`:"";return`${"-"}:${C}.${_}:${T}${H}`}function BT({basisPoints:C,...h}){return _C(`${"POOL-"}:${C}`,h)}function $T({name:C,chain:h,address:R,owner:T}){let P=`${"~"}:${C}:${h}:${R}`,_=T?`:${T}`:"";return`${P}${_}`}function ET({name:C,chain:h,asset:R,payout:T,owner:P}){return`${"~"}:${C}:${h}:${T}:${P}:${R}`}function _C(C,{affiliateAddress:h,affiliateBasisPoints:R}={}){let T=`${C}${h?`:${h}:${R||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function Bh({chain:C,symbol:h}){return Hh(C).with("BTC","DOGE","LTC",()=>C.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${C}.${h}`)}function jT({name:C,properties:h,methods:R}){function T(P){return{...R(P),...h}}return{[C]:T}}function zT(){return typeof window.ethereum!=="undefined"}function ZT(C){return $h().includes(C)}function $h(){let C=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,R=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,P=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,_=window?.bitkeep?.ethereum,H=window?.$onekey?.ethereum,x=[];if(C)x.push("METAMASK");if(h)x.push("CTRL");if(R)x.push("BRAVE");if(T)x.push("TRUSTWALLET_WEB");if(P)x.push("COINBASE_WEB");if(Ah())x.push("OKX_MOBILE");if(_)x.push("BITGET");if(H)x.push("ONEKEY");return x}async function Eh(C,h,R){try{await UC({provider:C,method:"wallet_switchEthereumChain",params:[{chainId:XC[h]}]})}catch(T){if(!R)throw new G("helpers_failed_to_switch_network",{error:T,reason:"networkParams not provided"});await jh(C,R)}}function QT({chains:C,supportedChains:h,walletType:R}){let T=C.filter((_)=>h.includes(_));if(T.length===0)throw new G("wallet_chain_not_supported",{wallet:R,chain:C.join(", ")});let P=C.filter((_)=>!h.includes(_));return i(P.length>0,`${R} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`),T}function Xh(C,h,R){return async(...T)=>{try{await Eh(h,R)}catch(P){throw new G({errorKey:"helpers_failed_to_switch_network",info:{error:P}})}return C(...T)}}function JT({toolbox:C,chain:h,provider:R=window.ethereum,methodNames:T=[]}){let _=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((H,x)=>{if(!C[x])return H;let B=C[x];if(typeof B!=="function")return H;let E=Xh(B,R,h);return{...H,[x]:E}},{});return{...C,..._}}function jh(C,h){return UC({provider:C,method:"wallet_addEthereumChain",params:[h]})}function OT(C){window.ethereum?.on("accountsChanged",()=>C()),window.xfi?.ethereum.on("accountsChanged",()=>C())}function YT(){let{isTrust:C,isBraveWallet:h,__XDEFI:R,overrideIsMetaMask:T,selectedProvider:P}=window?.ethereum||{};if(C)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(R)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function FT(){let C=[];function h(T){if(C.map((P)=>P.info.uuid).includes(T.detail.info.uuid))return;C.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function R(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:C,removeEIP6963EventListener:R}}function Ah(){let C=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(C),R=/android|XiaoMi|MiuiBrowser/i.test(C),T=h||R,P=/OKApp/i.test(C);return T&&P}function MT({connect:C,name:h,supportedChains:R,walletType:T}){function P(_){return C({..._,walletType:T,supportedChains:R})}return{[h]:{supportedChains:R,connectWallet:P}}}function UC({provider:C,params:h,method:R}){if(!C?.send)throw new G("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return C.send(R,T)}export{LR as wrapWithThrow,Xh as wrapMethodWithNetworkSwitch,i as warnOnce,MR as validateTNS,OC as validateIdentifier,hC as updateDerivationPath,Eh as switchEVMWalletNetwork,UC as providerRequest,JT as prepareNetworkSwitch,Ah as okxMobileEnabled,QC as loadTokenLists,$h as listWeb3EVMWallets,zT as isWeb3Detected,zC as isGasAsset,ZT as isDetected,Mh as initializeRPCUrlsWithFallback,bh as getWalletFormatFor,GR as getTHORNameCost,iR as getSymmetricWithdraw,xh as getSymmetricPoolShare,yR as getMinAmountByChain,HT as getMemoForWithdraw,PT as getMemoForUnbond,BT as getMemoForRunePoolWithdraw,_T as getMemoForRunePoolDeposit,$T as getMemoForNameRegister,ET as getMemoForNamePreferredAssetRegister,TT as getMemoForLeaveAndBond,xT as getMemoForDeposit,NR as getMAYANameCost,lR as getLiquiditySlippage,HR as getGasAsset,Th as getFeeMultiplierAsBigInt,MC as getFeeMultiplier,sR as getEstimatedPoolShare,YT as getETHDefaultWallet,FT as getEIP6963Wallets,ZR as getDynamicChainId,Kh as getDerivationPathFor,LC as getDecimal,t as getCommonAssetInfo,zR as getChainIdentifier,tR as getAsymmetricRuneWithdrawAmount,Ph as getAsymmetricRuneShare,aR as getAsymmetricAssetWithdrawAmount,_h as getAsymmetricAssetShare,RC as getAssetType,p as formatBigIntToSafeValue,BR as findAssetBy,QT as filterSupportedChains,jC as derivationPathToString,MT as createWallet,jT as createPlugin,a as assetFromString,cR as applyFeeMultiplierToBigInt,mR as applyFeeMultiplier,jh as addEVMWalletNetwork,OT as addAccountsChangedCallback,uT as WarningCodeEnum,u as WalletOption,BC as UTXOChains,Yh as TCSupportedChains,q as SwapKitNumber,G as SwapKitError,Qh as SubstrateChains,e as StagenetChain,wh as SWAP_OUT,Wh as SWAP_IN,U as SKConfig,I as RequestClient,m as RPC_URLS,DC as QuoteMode,dT as ProviderName,D as NetworkDerivationPath,n as NODE_URLS,GC as MemoType,Fh as MAYASupportedChains,yC as LedgerErrorCode,rT as FeeTypeEnum,AC as FeeOption,SC as FALLBACK_URLS,mT as ErrorCode,CC as EXPLORER_URLS,V as EVMChains,ph as DerivationPath,Rh as DEFAULT_FEE_MULTIPLIERS,Jh as CosmosChains,Oh as CosmosChainPrefixes,IC as ContractAddress,xR as CommonAssetStrings,XC as ChainToHexChainId,Uh as ChainToExplorerUrl,EC as ChainToChainId,zh as ChainIdToChain,v as ChainId,Y as Chain,Zh as BlockTimes,S as BigIntArithmetics,N as BaseDecimal,w as AssetValue,pC as ApproveMode,qh as AGG_SWAP};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=2C802E00E4F10BB664756E2164756E21
|