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