@swapkit/helpers 3.0.0-beta.7 → 3.0.0-beta.8

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.js CHANGED
@@ -1,6 +1,6 @@
1
- import{o as G,q as X}from"./chunk-3wnfcm30.js";var t;((O)=>{O.Arbitrum="ARB";O.Avalanche="AVAX";O.Base="BASE";O.BinanceSmartChain="BSC";O.Bitcoin="BTC";O.BitcoinCash="BCH";O.Cosmos="GAIA";O.Dash="DASH";O.Dogecoin="DOGE";O.Ethereum="ETH";O.Fiat="FIAT";O.Kujira="KUJI";O.Litecoin="LTC";O.Maya="MAYA";O.Near="NEAR";O.Optimism="OP";O.Polkadot="DOT";O.Chainflip="FLIP";O.Polygon="MATIC";O.Radix="XRD";O.Ripple="XRP";O.THORChain="THOR";O.Solana="SOL"})(t||={});var on;((o)=>{o.THORChain="THOR_STAGENET";o.Maya="MAYA_STAGENET"})(on||={});var v;((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"})(v||={});var Hh={["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"},Un=Object.keys(t),m=Object.values(t),L={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,XRD:18,XRP:6},_h={["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},Bh=["DOT","FLIP"],q=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Hn=["BTC","BCH","DASH","DOGE","LTC"],Nh=["GAIA","THOR","MAYA","KUJI"],Oh={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},$h=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],ph=["ARB","DASH","ETH","KUJI","MAYA","THOR"],a={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.ankr.com/near",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.thorswap.net",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},y={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},Qn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.quickapi.com","https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://rpc.ankr.com/eth"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",y.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},Tn={["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"},Fn=a,Sn=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{id:1,jsonrpc:"2.0",method:"system_health",params:[]};case"SOL":return{id:1,jsonrpc:"2.0",method:"getHealth"};case"XRD":return"";default:throw new Error(`Unsupported chain: ${n}`)}};function Jn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var xn=async(n,h)=>{try{let o=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${o}${Jn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Sn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},cn=async(n)=>{let h=a[n];if(await xn(n,h))return h;for(let o of Qn[n])if(await xn(n,o))return o;return h},Lh=async(n=[...Object.values(t),...Object.values(on)])=>{let h={};await Promise.all(n.map(async(o)=>{let T=await cn(o);h[o]=T})),Fn={...Fn,...h}},_n=m.reduce((n,h)=>{let o=Un.find((T)=>t[T]===h);if(o)n[h]=o;return n},{}),Bn=m.reduce((n,h)=>{return n[h]=v[_n[h]],n},{}),Nn=m.reduce((n,h)=>{let o=`${_n[h]}Hex`;return n[h]=v[o],n},{}),Mh=m.reduce((n,h)=>{return n[h]=Tn[h],n},{});import{match as i}from"ts-pattern";import{createStore as qn}from"zustand/vanilla";var zn;(($)=>{$.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"})(zn||={});var Ih=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Gh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Xh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function Cn(n,h){if("index"in h)return[...n.slice(0,n.length-1),h.index];if("change"in h){let[o,T,C,,A]=n;return[o,T,C,h.change,A]}if("account"in h){let[o,T,,C,A]=n;return[o,T,h.account,C,A]}return n}function On([n,h,o,T,C]){return`m/${n}'/${h}'/${o}'/${T}${typeof C!=="number"?"":`/${C}`}`}function Uh({chain:n,index:h,addressIndex:o=0,type:T}){if(q.includes(n)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,o];return Cn(W[n],{index:h})}if(n==="SOL"){if(T==="account")return[44,501,0,h];return Cn(W[n],{index:h})}let C=n==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,C,h,0,o];case"segwit":return[49,C,0,0,h];case"legacy":return[44,C,0,0,h];default:return Cn(W[n],{index:h})}}function Qh(n){let[h,o,T]=n.split("/").map((C)=>Number.parseInt(C,10));switch(o){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var gn;((P)=>{P.ARB="0x0000000000000000000000000000000000000000";P.AVAX="0x0000000000000000000000000000000000000000";P.BASE="0x0000000000000000000000000000000000000000";P.ETH="0x0000000000000000000000000000000000000000";P.BSC="0x0000000000000000000000000000000000000000";P.MATIC="0x0000000000000000000000000000000000001010";P.OP="0x4200000000000000000000000000000000000042"})(gn||={});var W={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],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]},ch=Object.keys(W).reduce((n,h)=>{return n[h]=On(W[h]),n},{});var Zn;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noSaversFound="noSaversFound";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLoanPositionFound="noLoanPositionFound";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(Zn||={});var Yn;((o)=>{o.highSlippage="highSlippage";o.highPriceImpact="highPriceImpact"})(Yn||={});var Vn;((p)=>{p.CAVIAR_V1="CAVIAR_V1";p.CAMELOT_V3="CAMELOT_V3";p.CHAINFLIP="CHAINFLIP";p.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";p.JUPITER="JUPITER";p.MAYACHAIN="MAYACHAIN";p.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";p.OCISWAP_V1="OCISWAP_V1";p.ONEINCH="ONEINCH";p.OPENOCEAN_V2="OPENOCEAN_V2";p.PANCAKESWAP="PANCAKESWAP";p.PANGOLIN_V1="PANGOLIN_V1";p.SUSHISWAP_V2="SUSHISWAP_V2";p.THORCHAIN="THORCHAIN";p.THORCHAIN_STREAMING="THORCHAIN_STREAMING";p.TRADERJOE_V2="TRADERJOE_V2";p.UNISWAP_V2="UNISWAP_V2";p.UNISWAP_V3="UNISWAP_V3";p.KADO="KADO"})(Vn||={});var Wn;((P)=>{P.LIQUIDITY="liquidity";P.NETWORK="network";P.INBOUND="inbound";P.OUTBOUND="outbound";P.AFFILIATE="affiliate";P.TAX="tax";P.PRIORITY="priority"})(Wn||={});var fn;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(fn||={});var un;((o)=>{o.Approve="approve";o.CheckOnly="checkOnly"})(un||={});var $n;((B)=>{B.NAME_REGISTER="~";B.BOND="BOND";B.DEPOSIT="+";B.LEAVE="LEAVE";B.UNBOND="UNBOND";B.WITHDRAW="-";B.OPEN_LOAN="$+";B.CLOSE_LOAN="$-";B.RUNEPOOL_DEPOSIT="POOL+";B.RUNEPOOL_WITHDRAW="POOL-"})($n||={});var d;((N)=>{N.BITGET="BITGET";N.BRAVE="BRAVE";N.COINBASE_MOBILE="COINBASE_MOBILE";N.COINBASE_WEB="COINBASE_WEB";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"})(d||={});var wn;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(wn||={});var Dn={apis:{},chains:Object.values(t),wallets:Object.values(d),explorerUrls:Tn,nodeUrls:y,rpcUrls:a,apiKeys:{blockchair:"",kado:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}}},S=qn((n)=>({...Dn,setApiKey:(h,o)=>n((T)=>({apiKeys:{...T.apiKeys,[h]:o}})),setEnv:(h,o)=>n((T)=>({envs:{...T.envs,[h]:o}})),setExplorerUrl:(h,o)=>n((T)=>({explorerUrls:{...T.explorerUrls,[h]:o}})),setNodeUrl:(h,o)=>n((T)=>({nodeUrls:{...T.nodeUrls,[h]:o}})),setRpcUrl:(h,o)=>n((T)=>({rpcUrls:{...T.rpcUrls,[h]:o}})),setIntegrationConfig:(h,o)=>n((T)=>({integrations:{...T.integrations,[h]:o}})),setConfig:(h)=>n((o)=>({apiKeys:{...o.apiKeys,...h.apiKeys},envs:{...o.envs,...h.envs},explorerUrls:{...o.explorerUrls,...h.explorerUrls},integrations:{...o.integrations,...h.integrations},nodeUrls:{...o.nodeUrls,...h.nodeUrls},rpcUrls:{...o.rpcUrls,...h.rpcUrls},chains:o.chains.concat(h.chains||[]),wallets:o.wallets.concat(h.wallets||[])}))})),J={getState:S.getState,get:(n)=>S.getState()[n],set:(n)=>S.getState().setConfig(n),setApiKey:(n,h)=>S.getState().setApiKey(n,h),setEnv:(n,h)=>S.getState().setEnv(n,h),setExplorerUrl:(n,h)=>S.getState().setExplorerUrl(n,h),setNodeUrl:(n,h)=>S.getState().setNodeUrl(n,h),setRpcUrl:(n,h)=>S.getState().setRpcUrl(n,h),setIntegrationConfig:(n,h)=>S.getState().setIntegrationConfig(n,h)};var f={get:s("GET"),post:s("POST"),extend:(n)=>({get:s("GET",n),post:s("POST",n),extend:(h)=>f.extend({...n,...h})})};function s(n,h={}){return async(o,T={})=>{let{searchParams:C,json:A,body:F,headers:P}={...h,...T},{swapKit:_}=J.get("apiKeys"),x=A||o.endsWith(".json"),B=x?JSON.stringify(A):F,I=new URL(o);if(C)I.search=new URLSearchParams(C).toString();let Q={...P,...x?{"Content-Type":"application/json"}:{},..._?{"x-api-key":_}:{}};try{let k=await fetch(I.toString(),{...T,method:n,body:B,headers:Q});if(!k.ok){let z=await k.text();throw new Error(`${k.statusText}(${k.status}): ${z}`)}let j=await k.json();return T.onSuccess?.(j)||T.responseHandler?.(j)||j}catch(k){return T.onError?.(k)||console.error(k)}}}var eh=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],pn=["ARB","BASE","ETH","OP","MATIC"];async function bn({chain:n,to:h}){try{let{result:T}=await f.post(J.get("rpcUrls")[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(T||L[n]).toString())}catch(T){return console.error(T),L[n]}}async function Kn(n){if(n==="XRD")return L.XRD;try{let h=n.split("-")[1]?.toLowerCase(),{manager:o}=await f.post(`${J.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return o.divisibility.value.divisibility}catch(h){return console.error(h),L["XRD"]}}async function En({chain:n,symbol:h}){if(q.includes(h))return L[h];let o=h.split("-"),T=o.length===1?void 0:o[o.length-1]?.toLowerCase();return await(T?.startsWith("0x")?bn({chain:n,to:T}):L[n])}function Ln({chain:n,symbol:h}){return i(n).with(...q,(o)=>En({chain:o,symbol:h})).with("XRD",()=>Kn(h)).otherwise(()=>L[n])}function no({chain:n}){return g.from({chain:n})}function Mn({chain:n,symbol:h}){return i(n).with(...pn,()=>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}`===l(n).identifier).otherwise(()=>h===n)}var l=(n)=>{let h=L[n];return i(n.toUpperCase()).with(...pn,()=>({identifier:`${n.toUpperCase()}.ETH`,decimal:h})).with("THOR",()=>({identifier:`${n.toUpperCase()}.RUNE`,decimal:h})).with("GAIA",()=>({identifier:`${n.toUpperCase()}.ATOM`,decimal:h})).with("MAYA",()=>({identifier:`${n.toUpperCase()}.CACAO`,decimal:10})).with("BSC",()=>({identifier:`${n.toUpperCase()}.BNB`,decimal:h})).with("AVAX",()=>({identifier:`${n.toUpperCase()}.AVAX`,decimal:h})).with(...Hn,"SOL","FLIP","KUJI","XRP","DOT",()=>({identifier:`${n.toUpperCase()}.${n.toUpperCase()}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",()=>({identifier:n.toUpperCase(),decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:L.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:L.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:L.ETH})).with("MAYA.MAYA",()=>({identifier:n.toUpperCase(),decimal:4})).otherwise(()=>({identifier:n,decimal:h}))};function Rn({chain:n,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return i(n).with("XRD",()=>h==="XRD"||`${n}.${h}`===l(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 r=(n)=>{let[h,...o]=n.split("."),T=n.includes("/"),C=o.join("."),A=C?.split("-"),F=A?.length?A.length===1?A[0]:A.slice(0,-1).join("-"):void 0;return{chain:h,symbol:C,ticker:F,synth:T}};async function ho(n){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let o of Object.values(h))for(let{identifier:T,chain:C,...A}of o.tokens){if("identifier"in n&&T===n.identifier)return T;if("address"in A&&"chain"in n&&C===n.chain&&A.address.toLowerCase()===n.contract.toLowerCase())return T}return}var yn={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_ctrl_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_wallet_connection_failed:10112,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_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_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,wallet_bitkeep_not_found:21001,wallet_exodus_sign_transaction_error:21100,wallet_keystore_invalid_password:29900,wallet_keystore_unsupported_version:29901,wallet_onekey_not_found:21200,wallet_onekey_sign_transaction_error:21201,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,api_v2_invalid_method_key_hash:50003,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_cosmos_validate_address_prefix_not_found:90104,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,toolbox_solana_no_signer:90401,toolbox_solana_fee_estimation_failed:90402,toolbox_ripple_rpc_not_configured:90501,toolbox_ripple_signer_not_found:90502,toolbox_ripple_asset_not_supported:90503,toolbox_ripple_broadcast_error:90504,toolbox_ripple_get_balance_error:90505,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class M extends Error{static ErrorCode=yn;constructor(n,h){let o=typeof n==="string",T=o?n:n.errorKey,C=`${T}${o?"":`: ${JSON.stringify(n.info)}`}`;if(h)console.error(h);console.error(T,{code:M.ErrorCode[T],message:C});super(T);Object.setPrototypeOf(this,M.prototype)}}function Fo(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function xo(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function Ho(n,h){try{return n()}catch(o){if(h)throw new M(h,o);return console.error(o)}}function _o(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var kn=new Set;function e(n,h){if(n){if(kn.has(h))return;kn.add(h),console.warn(h)}}async function Bo(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let h=J.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await f.get(`${h}/status`)).result.node_info.network}catch(h){return n}}import{match as vn}from"ts-pattern";var mn=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function In(n){let h=n||mn,o={};for(let T of h){let C=await an(T);o[T]=C}return o}async function an(n){let{list:h}=await vn(n).with("camelot",()=>import("./chunk-mmwvr2y8.js")).with("caviar",()=>import("./chunk-dbsrwnw2.js")).with("chainflip",()=>import("./chunk-kr69v1tm.js")).with("jupiter",()=>import("./chunk-6vvdbb6s.js")).with("mayachain",()=>import("./chunk-q8xy3739.js")).with("oneinch",()=>import("./chunk-z8emzpyc.js")).with("openocean",()=>import("./chunk-fr86y3rx.js")).with("pancakeswap",()=>import("./chunk-tq87xn7m.js")).with("pangolin",()=>import("./chunk-wmxwvv8c.js")).with("sushiswap",()=>import("./chunk-wrjh857m.js")).with("thorchain",()=>import("./chunk-kdcsgh3q.js")).with("traderjoe",()=>import("./chunk-ekd1k975.js")).with("uniswap",()=>import("./chunk-ahpfxkx0.js")).with("uniswapv3",()=>import("./chunk-xyczdrny.js")).exhaustive();return h}var Gn=["TERRA",...J.get("chains")];function Xn(n=""){let h=n.toUpperCase(),[o]=h.split(".");if(Gn.includes(o))return!0;let[T]=h.split("/");if(Gn.includes(T))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function Mo(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var b=8,Y=(n)=>10n**BigInt(n),D=(n)=>Math.log10(Number.parseFloat(n.toString()));function u({value:n,bigIntDecimal:h=b,decimal:o=b}){if(o===0)return n.toString();let T=n<0n,C=n.toString().substring(T?1:0),A=o-(C.length-1);if(A>0)C="0".repeat(A)+C;let F=C.length-o,P=C.slice(-o);if(Number.parseInt(P[h]||"0")>=5)P=`${P.substring(0,h-1)}${(Number.parseInt(P[h-1]||"0")+1).toString()}`;else P=P.substring(0,h);return`${T?"-":""}${C.slice(0,F)}.${P}`.replace(/\.?0*$/,"")}class Z{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new Z({decimal:h,value:u({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:o}){return Z.fromBigInt(n.getBaseValue("bigint")*Y(o)/Y(h),o)}constructor(n){let h=An(n),o=typeof n==="object";this.decimal=o?n.decimal:void 0,this.decimalMultiplier=o&&"decimalMultiplier"in n?n.decimalMultiplier:Y(Math.max(jn(nn(h)),this.decimal||0)),this.#C(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 o=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||D(this.decimalMultiplier));switch(n){case"number":return Number(o);case"string":return o;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return o}}getBaseValue(n,h){let o=this.decimalMultiplier/Y(h||this.decimal||L.THOR),T=this.bigIntValue/o;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 o=An(n),T=nn(o);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(n=6){let[h,o]=this.getValue("string").split("."),T=h||"",C=o||"";if((Number.parseInt(T)?T.length+C.length:C.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}.${C.slice(0,n-T.length)}`.padEnd(n-T.length,"0");let F=Number.parseInt(C),P=`${F}`.slice(0,n);return`0.${P.padStart(C.length-`${F}`.length+P.length,"0")}`}toFixed(n=6){let[h,o]=this.getValue("string").split("."),T=h||"",C=o||"";if(Number.parseInt(T))return`${T}.${C.slice(0,n)}`.padEnd(n,"0");let A=Number.parseInt(C),F=`${A}`.slice(0,n);return`0.${F.padStart(C.length-`${A}`.length+F.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),o=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),C=o[T];if(!C)return this.getValue("string");let A=10**(T*3);return`${(h/A).toFixed(n)}${C}`}toCurrency(n="$",{currencyPosition:h="start",decimal:o=2,decimalSeparator:T=".",thousandSeparator:C=","}={}){let A=this.getValue("number"),[F="",P=""]=A.toFixed(6).split("."),_=F.replace(/\B(?=(\d{3})+(?!\d))/g,C),x=F||P?F==="0"?`${Number.parseFloat(`0.${P}`)}`.replace(".",T):`${_}${Number.parseInt(P)?`${T}${P.slice(0,o)}`:""}`:"0.00";return`${h==="start"?n:""}${x}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let o=h||this.decimal||b,T=Math.max(o,D(this.decimalMultiplier)),C=n<0n,A=n.toString().substring(C?1:0),F=T-(A.length-1),P=F>0?"0".repeat(F)+A:A,_=P.length-T,x=P.slice(-T);if(Number.parseInt(x[o]||"0")>=5)x=`${x.substring(0,o-1)}${(Number.parseInt(x[o-1]||"0")+1).toString()}`;else x=x.substring(0,o);return`${C?"-":""}${P.slice(0,_)}.${x}`.replace(/\.?0*$/,"")}#h(n,...h){let o=this.#o(this,...h),T=Math.max(o,D(this.decimalMultiplier)),C=Y(T),A=h.reduce((P,_)=>{let x=this.getBigIntValue(_,T);switch(n){case"add":return P+x;case"sub":return P-x;case"mul":return P*x/C;case"div":{if(x===0n)throw new RangeError("Division by zero");return P*C/x}default:return P}},this.bigIntValue*C/this.decimalMultiplier),F=u({bigIntDecimal:T,decimal:T,value:A});return new this.constructor({decimalMultiplier:Y(T),decimal:this.decimal,value:F,identifier:this.toString()})}#n(n,...h){let o=this.#o(this,...h),T=this.getBigIntValue(h[0]||"0",o),C=this.getBigIntValue(this,o);switch(n){case"gt":return C>T;case"gte":return C>=T;case"lt":return C<T;case"lte":return C<=T;case"eqValue":return C===T;default:return!1}}#C(n){let h=nn(n)||"0";this.bigIntValue=this.#T(h)}#o(...n){let h=n.map((o)=>{return typeof o==="object"?o.decimal||D(o.decimalMultiplier):jn(nn(o))}).filter(Boolean);return Math.max(...h,b)}#T(n,h){let o=h?Y(h):this.decimalMultiplier,T=D(o),[C="",A=""]=n.split(".");return BigInt(`${C}${A.padEnd(T,"0")}`)}}var dn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function nn(n){let o=`${typeof n==="number"?dn.format(n):An(n)}`.replaceAll(",",".").split(".");return o.length>1?`${o.slice(0,-1).join("")}.${o.at(-1)}`:o[0]||"0"}function jn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,b)}function An(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var w=new Map;class g extends Z{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:o,chain:T,symbol:C,identifier:A}){super(typeof n==="object"?n:{decimal:h,value:n});let F=Pn(A||`${T}.${C}`);this.type=Rn(F),this.tax=o,this.chain=F.chain,this.ticker=F.ticker,this.symbol=F.symbol,this.address=F.address,this.isSynthetic=F.isSynthetic,this.isTradeAsset=F.isTradeAsset,this.isGasAsset=F.isGasAsset,this.chainId=Bn[F.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[o,T,C]=n.split(".");if(!(o&&T))throw new M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let A=o==="THOR"&&C?`${o}.${T}/${C}`:n;return g.from({asset:A,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:o,...T}){let C=n instanceof Z?n.getValue("string"):n,A=en(T),{identifier:F,decimal:P}=l(A),{chain:_,isSynthetic:x,isTradeAsset:B}=Pn(F),I=w.get(_==="SOL"?F:F.toUpperCase()),Q=I?.decimal||P;e(!(o||Q),`Couldn't find static decimal for one or more tokens on ${_} (Using default ${L[_]} decimal as fallback).
1
+ import{o as X,q as j}from"./chunk-3wnfcm30.js";var U;(($)=>{$.Arbitrum="ARB";$.Avalanche="AVAX";$.Base="BASE";$.BinanceSmartChain="BSC";$.Bitcoin="BTC";$.BitcoinCash="BCH";$.Cosmos="GAIA";$.Dash="DASH";$.Dogecoin="DOGE";$.Ethereum="ETH";$.Fiat="FIAT";$.Kujira="KUJI";$.Litecoin="LTC";$.Maya="MAYA";$.Near="NEAR";$.Optimism="OP";$.Polkadot="DOT";$.Chainflip="FLIP";$.Polygon="MATIC";$.Radix="XRD";$.Ripple="XRP";$.THORChain="THOR";$.Solana="SOL"})(U||={});var on;((o)=>{o.THORChain="THOR_STAGENET";o.Maya="MAYA_STAGENET"})(on||={});var v;((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"})(v||={});var _h={["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"},Sn=Object.keys(U),m=Object.values(U),L={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,XRD:18,XRP:6},Bh={["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},Nh=["DOT","FLIP"],W=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Hn=["BTC","BCH","DASH","DOGE","LTC"],Oh=["GAIA","THOR","MAYA","KUJI"],$h={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},ph=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Lh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],a={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.ankr.com/near",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.thorswap.net",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},E={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},Jn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.quickapi.com","https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://rpc.ankr.com/eth"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",E.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},Tn={["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"},Fn=a,tn=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{id:1,jsonrpc:"2.0",method:"system_health",params:[]};case"SOL":return{id:1,jsonrpc:"2.0",method:"getHealth"};case"XRD":return"";default:throw new Error(`Unsupported chain: ${n}`)}};function zn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var xn=async(n,h)=>{try{let o=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${o}${zn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(tn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},cn=async(n)=>{let h=a[n];if(await xn(n,h))return h;for(let o of Jn[n])if(await xn(n,o))return o;return h},Mh=async(n=[...Object.values(U),...Object.values(on)])=>{let h={};await Promise.all(n.map(async(o)=>{let T=await cn(o);h[o]=T})),Fn={...Fn,...h}},_n=m.reduce((n,h)=>{let o=Sn.find((T)=>U[T]===h);if(o)n[h]=o;return n},{}),Bn=m.reduce((n,h)=>{return n[h]=v[_n[h]],n},{}),Nn=m.reduce((n,h)=>{let o=`${_n[h]}Hex`;return n[h]=v[o],n},{}),kh=m.reduce((n,h)=>{return n[h]=Tn[h],n},{});import{match as s}from"ts-pattern";import{createStore as Dn}from"zustand/vanilla";var Zn;((B)=>{B.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";B.TC_SUPPORTED_TO_ETH="TC-ERC20";B.TC_SUPPORTED_TO_AVAX="TC-ARC20";B.TC_SUPPORTED_TO_BSC="TC-BEP20";B.ETH_TO_TC_SUPPORTED="ERC20-TC";B.ETH_TO_ETH="ERC20-ERC20";B.ETH_TO_AVAX="ERC20-ARC20";B.ETH_TO_BSC="ERC20-BEP20";B.AVAX_TO_TC_SUPPORTED="ARC20-TC";B.AVAX_TO_ETH="ARC20-ERC20";B.AVAX_TO_AVAX="ARC20-ARC20";B.AVAX_TO_BSC="ARC20-BEP20";B.BSC_TO_TC_SUPPORTED="BEP20-TC";B.BSC_TO_ETH="BEP20-ERC20";B.BSC_TO_AVAX="BEP20-ARC20";B.BSC_TO_BSC="BEP20-BEP20"})(Zn||={});var Gh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Xh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],jh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function Cn(n,h){if("index"in h)return[...n.slice(0,n.length-1),h.index];if("change"in h){let[o,T,C,,A]=n;return[o,T,C,h.change,A]}if("account"in h){let[o,T,,C,A]=n;return[o,T,h.account,C,A]}return n}function On([n,h,o,T,C]){return`m/${n}'/${h}'/${o}'/${T}${typeof C!=="number"?"":`/${C}`}`}function Sh({chain:n,index:h,addressIndex:o=0,type:T}){if(W.includes(n)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,o];return Cn(f[n],{index:h})}if(n==="SOL"){if(T==="account")return[44,501,0,h];return Cn(f[n],{index:h})}let C=n==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,C,h,0,o];case"segwit":return[49,C,0,0,h];case"legacy":return[44,C,0,0,h];default:return Cn(f[n],{index:h})}}function Jh(n){let[h,o,T]=n.split("/").map((C)=>Number.parseInt(C,10));switch(o){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var gn;((P)=>{P.ARB="0x0000000000000000000000000000000000000000";P.AVAX="0x0000000000000000000000000000000000000000";P.BASE="0x0000000000000000000000000000000000000000";P.ETH="0x0000000000000000000000000000000000000000";P.BSC="0x0000000000000000000000000000000000000000";P.MATIC="0x0000000000000000000000000000000000001010";P.OP="0x4200000000000000000000000000000000000042"})(gn||={});var f={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],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]},ch=Object.keys(f).reduce((n,h)=>{return n[h]=On(f[h]),n},{});var Yn;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noSaversFound="noSaversFound";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLoanPositionFound="noLoanPositionFound";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(Yn||={});var Wn;((o)=>{o.highSlippage="highSlippage";o.highPriceImpact="highPriceImpact"})(Wn||={});var Vn;((p)=>{p.CAVIAR_V1="CAVIAR_V1";p.CAMELOT_V3="CAMELOT_V3";p.CHAINFLIP="CHAINFLIP";p.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";p.JUPITER="JUPITER";p.MAYACHAIN="MAYACHAIN";p.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";p.OCISWAP_V1="OCISWAP_V1";p.ONEINCH="ONEINCH";p.OPENOCEAN_V2="OPENOCEAN_V2";p.PANCAKESWAP="PANCAKESWAP";p.PANGOLIN_V1="PANGOLIN_V1";p.SUSHISWAP_V2="SUSHISWAP_V2";p.THORCHAIN="THORCHAIN";p.THORCHAIN_STREAMING="THORCHAIN_STREAMING";p.TRADERJOE_V2="TRADERJOE_V2";p.UNISWAP_V2="UNISWAP_V2";p.UNISWAP_V3="UNISWAP_V3";p.KADO="KADO"})(Vn||={});var fn;((P)=>{P.LIQUIDITY="liquidity";P.NETWORK="network";P.INBOUND="inbound";P.OUTBOUND="outbound";P.AFFILIATE="affiliate";P.TAX="tax";P.PRIORITY="priority"})(fn||={});var un;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(un||={});var wn;((o)=>{o.Approve="approve";o.CheckOnly="checkOnly"})(wn||={});var $n;((N)=>{N.NAME_REGISTER="~";N.BOND="BOND";N.DEPOSIT="+";N.LEAVE="LEAVE";N.UNBOND="UNBOND";N.WITHDRAW="-";N.OPEN_LOAN="$+";N.CLOSE_LOAN="$-";N.RUNEPOOL_DEPOSIT="POOL+";N.RUNEPOOL_WITHDRAW="POOL-"})($n||={});var i;((O)=>{O.BITGET="BITGET";O.BRAVE="BRAVE";O.COINBASE_MOBILE="COINBASE_MOBILE";O.COINBASE_WEB="COINBASE_WEB";O.CTRL="CTRL";O.EIP6963="EIP6963";O.EXODUS="EXODUS";O.KEEPKEY="KEEPKEY";O.KEEPKEY_BEX="KEEPKEY_BEX";O.KEPLR="KEPLR";O.KEYSTORE="KEYSTORE";O.LEAP="LEAP";O.LEDGER="LEDGER";O.LEDGER_LIVE="LEDGER_LIVE";O.METAMASK="METAMASK";O.OKX="OKX";O.OKX_MOBILE="OKX_MOBILE";O.ONEKEY="ONEKEY";O.PHANTOM="PHANTOM";O.POLKADOT_JS="POLKADOT_JS";O.RADIX_WALLET="RADIX_WALLET";O.TREZOR="TREZOR";O.TALISMAN="TALISMAN";O.TRUSTWALLET_WEB="TRUSTWALLET_WEB";O.WALLETCONNECT="WALLETCONNECT"})(i||={});var qn;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(qn||={});var bn={apis:{},chains:Object.values(U),wallets:Object.values(i),explorerUrls:Tn,nodeUrls:E,rpcUrls:a,apiKeys:{blockchair:"",kado:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}}},J=Dn((n)=>({...bn,setApiKey:(h,o)=>n((T)=>({apiKeys:{...T.apiKeys,[h]:o}})),setEnv:(h,o)=>n((T)=>({envs:{...T.envs,[h]:o}})),setExplorerUrl:(h,o)=>n((T)=>({explorerUrls:{...T.explorerUrls,[h]:o}})),setNodeUrl:(h,o)=>n((T)=>({nodeUrls:{...T.nodeUrls,[h]:o}})),setRpcUrl:(h,o)=>n((T)=>({rpcUrls:{...T.rpcUrls,[h]:o}})),setIntegrationConfig:(h,o)=>n((T)=>({integrations:{...T.integrations,[h]:o}})),setConfig:(h)=>n((o)=>({apiKeys:{...o.apiKeys,...h.apiKeys},envs:{...o.envs,...h.envs},explorerUrls:{...o.explorerUrls,...h.explorerUrls},integrations:{...o.integrations,...h.integrations},nodeUrls:{...o.nodeUrls,...h.nodeUrls},rpcUrls:{...o.rpcUrls,...h.rpcUrls},chains:o.chains.concat(h.chains||[]),wallets:o.wallets.concat(h.wallets||[])}))})),t={getState:J.getState,get:(n)=>J.getState()[n],set:(n)=>J.getState().setConfig(n),setApiKey:(n,h)=>J.getState().setApiKey(n,h),setEnv:(n,h)=>J.getState().setEnv(n,h),setExplorerUrl:(n,h)=>J.getState().setExplorerUrl(n,h),setNodeUrl:(n,h)=>J.getState().setNodeUrl(n,h),setRpcUrl:(n,h)=>J.getState().setRpcUrl(n,h),setIntegrationConfig:(n,h)=>J.getState().setIntegrationConfig(n,h)};var u={get:d("GET"),post:d("POST"),extend:(n)=>({get:d("GET",n),post:d("POST",n),extend:(h)=>u.extend({...n,...h})})};function d(n,h={}){return async(o,T={})=>{let{searchParams:C,json:A,body:F,headers:P}={...h,...T},{swapKit:_}=t.get("apiKeys"),x=A||o.endsWith(".json"),N=x?JSON.stringify(A):F,I=new URL(o);if(C)I.search=new URLSearchParams(C).toString();let S={...P,...x?{"Content-Type":"application/json"}:{},..._?{"x-api-key":_}:{}};try{let k=await fetch(I.toString(),{...T,method:n,body:N,headers:S});if(!k.ok){let c=await k.text();throw new Error(`${k.statusText}(${k.status}): ${c}`)}let G=await k.json();return T.onSuccess?.(G)||T.responseHandler?.(G)||G}catch(k){return T.onError?.(k)||console.error(k)}}}var no=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],pn=["ARB","BASE","ETH","OP","MATIC"];async function Kn({chain:n,to:h}){try{let{result:T}=await u.post(t.get("rpcUrls")[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(T||L[n]).toString())}catch(T){return console.error(T),L[n]}}async function yn(n){if(n==="XRD")return L.XRD;try{let h=n.split("-")[1]?.toLowerCase(),{manager:o}=await u.post(`${t.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return o.divisibility.value.divisibility}catch(h){return console.error(h),L["XRD"]}}async function En({chain:n,symbol:h}){if(W.includes(h))return L[h];let o=h.split("-"),T=o.length===1?void 0:o[o.length-1]?.toLowerCase();return await(T?.startsWith("0x")?Kn({chain:n,to:T}):L[n])}function Ln({chain:n,symbol:h}){return s(n).with(...W,(o)=>En({chain:o,symbol:h})).with("XRD",()=>yn(h)).otherwise(()=>L[n])}function ho({chain:n}){return g.from({chain:n})}function Mn({chain:n,symbol:h}){return s(n).with(...pn,()=>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}`===l(n).identifier).otherwise(()=>h===n)}var l=(n)=>{let h=L[n];return s(n.toUpperCase()).with(...pn,()=>({identifier:`${n.toUpperCase()}.ETH`,decimal:h})).with("THOR",()=>({identifier:`${n.toUpperCase()}.RUNE`,decimal:h})).with("GAIA",()=>({identifier:`${n.toUpperCase()}.ATOM`,decimal:h})).with("MAYA",()=>({identifier:`${n.toUpperCase()}.CACAO`,decimal:10})).with("BSC",()=>({identifier:`${n.toUpperCase()}.BNB`,decimal:h})).with("AVAX",()=>({identifier:`${n.toUpperCase()}.AVAX`,decimal:h})).with(...Hn,"SOL","FLIP","KUJI","XRP","DOT",()=>({identifier:`${n.toUpperCase()}.${n.toUpperCase()}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",()=>({identifier:n.toUpperCase(),decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:L.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:L.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:L.ETH})).with("MAYA.MAYA",()=>({identifier:n.toUpperCase(),decimal:4})).otherwise(()=>({identifier:n,decimal:h}))};function Rn({chain:n,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return s(n).with("XRD",()=>h==="XRD"||`${n}.${h}`===l(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 r=(n)=>{let[h,...o]=n.split("."),T=n.includes("/"),C=o.join("."),A=C?.split("-"),F=A?.length?A.length===1?A[0]:A.slice(0,-1).join("-"):void 0;return{chain:h,symbol:C,ticker:F,synth:T}};async function oo(n){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let o of Object.values(h))for(let{identifier:T,chain:C,...A}of o.tokens){if("identifier"in n&&T===n.identifier)return T;if("address"in A&&"chain"in n&&C===n.chain&&A.address.toLowerCase()===n.contract.toLowerCase())return T}return}var vn={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_ctrl_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_wallet_connection_failed:10112,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_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_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,wallet_bitkeep_not_found:21001,wallet_exodus_sign_transaction_error:21100,wallet_keystore_invalid_password:29900,wallet_keystore_unsupported_version:29901,wallet_onekey_not_found:21200,wallet_onekey_sign_transaction_error:21201,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,api_v2_invalid_method_key_hash:50003,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_cosmos_validate_address_prefix_not_found:90104,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,toolbox_solana_no_signer:90401,toolbox_solana_fee_estimation_failed:90402,toolbox_ripple_rpc_not_configured:90501,toolbox_ripple_signer_not_found:90502,toolbox_ripple_asset_not_supported:90503,toolbox_ripple_broadcast_error:90504,toolbox_ripple_get_balance_error:90505,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class M extends Error{static ErrorCode=vn;constructor(n,h){let o=typeof n==="string",T=o?n:n.errorKey,C=`${T}${o?"":`: ${JSON.stringify(n.info)}`}`;if(h)console.error(h);console.error(T,{code:M.ErrorCode[T],message:C});super(T);Object.setPrototypeOf(this,M.prototype)}}function xo(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function Ho(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function _o(n,h){try{return n()}catch(o){if(h)throw new M(h,o);return console.error(o)}}function Bo(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var kn=new Set;function e(n,h){if(n){if(kn.has(h))return;kn.add(h),console.warn(h)}}async function No(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let h=t.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await u.get(`${h}/status`)).result.node_info.network}catch(h){return n}}import{match as mn}from"ts-pattern";var an=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function In(n){let h=n||an,o={};for(let T of h){let C=await dn(T);o[T]=C}return o}async function dn(n){let{list:h}=await mn(n).with("camelot",()=>import("./chunk-mmwvr2y8.js")).with("caviar",()=>import("./chunk-dbsrwnw2.js")).with("chainflip",()=>import("./chunk-kr69v1tm.js")).with("jupiter",()=>import("./chunk-6vvdbb6s.js")).with("mayachain",()=>import("./chunk-q8xy3739.js")).with("oneinch",()=>import("./chunk-z8emzpyc.js")).with("openocean",()=>import("./chunk-fr86y3rx.js")).with("pancakeswap",()=>import("./chunk-tq87xn7m.js")).with("pangolin",()=>import("./chunk-wmxwvv8c.js")).with("sushiswap",()=>import("./chunk-wrjh857m.js")).with("thorchain",()=>import("./chunk-kdcsgh3q.js")).with("traderjoe",()=>import("./chunk-ekd1k975.js")).with("uniswap",()=>import("./chunk-ahpfxkx0.js")).with("uniswapv3",()=>import("./chunk-xyczdrny.js")).exhaustive();return h}var Gn=["TERRA",...t.get("chains")];function Xn(n=""){let h=n.toUpperCase(),[o]=h.split(".");if(Gn.includes(o))return!0;let[T]=h.split("/");if(Gn.includes(T))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function ko(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}import{getAddress as Un}from"ethers";var K=8,V=(n)=>10n**BigInt(n),b=(n)=>Math.log10(Number.parseFloat(n.toString()));function w({value:n,bigIntDecimal:h=K,decimal:o=K}){if(o===0)return n.toString();let T=n<0n,C=n.toString().substring(T?1:0),A=o-(C.length-1);if(A>0)C="0".repeat(A)+C;let F=C.length-o,P=C.slice(-o);if(Number.parseInt(P[h]||"0")>=5)P=`${P.substring(0,h-1)}${(Number.parseInt(P[h-1]||"0")+1).toString()}`;else P=P.substring(0,h);return`${T?"-":""}${C.slice(0,F)}.${P}`.replace(/\.?0*$/,"")}class Y{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new Y({decimal:h,value:w({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:o}){return Y.fromBigInt(n.getBaseValue("bigint")*V(o)/V(h),o)}constructor(n){let h=An(n),o=typeof n==="object";this.decimal=o?n.decimal:void 0,this.decimalMultiplier=o&&"decimalMultiplier"in n?n.decimalMultiplier:V(Math.max(jn(nn(h)),this.decimal||0)),this.#C(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 o=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||b(this.decimalMultiplier));switch(n){case"number":return Number(o);case"string":return o;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return o}}getBaseValue(n,h){let o=this.decimalMultiplier/V(h||this.decimal||L.THOR),T=this.bigIntValue/o;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 o=An(n),T=nn(o);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(n=6){let[h,o]=this.getValue("string").split("."),T=h||"",C=o||"";if((Number.parseInt(T)?T.length+C.length:C.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}.${C.slice(0,n-T.length)}`.padEnd(n-T.length,"0");let F=Number.parseInt(C),P=`${F}`.slice(0,n);return`0.${P.padStart(C.length-`${F}`.length+P.length,"0")}`}toFixed(n=6){let[h,o]=this.getValue("string").split("."),T=h||"",C=o||"";if(Number.parseInt(T))return`${T}.${C.slice(0,n)}`.padEnd(n,"0");let A=Number.parseInt(C),F=`${A}`.slice(0,n);return`0.${F.padStart(C.length-`${A}`.length+F.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),o=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),C=o[T];if(!C)return this.getValue("string");let A=10**(T*3);return`${(h/A).toFixed(n)}${C}`}toCurrency(n="$",{currencyPosition:h="start",decimal:o=2,decimalSeparator:T=".",thousandSeparator:C=","}={}){let A=this.getValue("number"),[F="",P=""]=A.toFixed(6).split("."),_=F.replace(/\B(?=(\d{3})+(?!\d))/g,C),x=F||P?F==="0"?`${Number.parseFloat(`0.${P}`)}`.replace(".",T):`${_}${Number.parseInt(P)?`${T}${P.slice(0,o)}`:""}`:"0.00";return`${h==="start"?n:""}${x}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let o=h||this.decimal||K,T=Math.max(o,b(this.decimalMultiplier)),C=n<0n,A=n.toString().substring(C?1:0),F=T-(A.length-1),P=F>0?"0".repeat(F)+A:A,_=P.length-T,x=P.slice(-T);if(Number.parseInt(x[o]||"0")>=5)x=`${x.substring(0,o-1)}${(Number.parseInt(x[o-1]||"0")+1).toString()}`;else x=x.substring(0,o);return`${C?"-":""}${P.slice(0,_)}.${x}`.replace(/\.?0*$/,"")}#h(n,...h){let o=this.#o(this,...h),T=Math.max(o,b(this.decimalMultiplier)),C=V(T),A=h.reduce((P,_)=>{let x=this.getBigIntValue(_,T);switch(n){case"add":return P+x;case"sub":return P-x;case"mul":return P*x/C;case"div":{if(x===0n)throw new RangeError("Division by zero");return P*C/x}default:return P}},this.bigIntValue*C/this.decimalMultiplier),F=w({bigIntDecimal:T,decimal:T,value:A});return new this.constructor({decimalMultiplier:V(T),decimal:this.decimal,value:F,identifier:this.toString()})}#n(n,...h){let o=this.#o(this,...h),T=this.getBigIntValue(h[0]||"0",o),C=this.getBigIntValue(this,o);switch(n){case"gt":return C>T;case"gte":return C>=T;case"lt":return C<T;case"lte":return C<=T;case"eqValue":return C===T;default:return!1}}#C(n){let h=nn(n)||"0";this.bigIntValue=this.#T(h)}#o(...n){let h=n.map((o)=>{return typeof o==="object"?o.decimal||b(o.decimalMultiplier):jn(nn(o))}).filter(Boolean);return Math.max(...h,K)}#T(n,h){let o=h?V(h):this.decimalMultiplier,T=b(o),[C="",A=""]=n.split(".");return BigInt(`${C}${A.padEnd(T,"0")}`)}}var sn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function nn(n){let o=`${typeof n==="number"?sn.format(n):An(n)}`.replaceAll(",",".").split(".");return o.length>1?`${o.slice(0,-1).join("")}.${o.at(-1)}`:o[0]||"0"}function jn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,K)}function An(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var q=new Map;class g extends Y{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:o,chain:T,symbol:C,identifier:A}){super(typeof n==="object"?n:{decimal:h,value:n});let F=Pn(A||`${T}.${C}`);this.type=Rn(F),this.tax=o,this.chain=F.chain,this.ticker=F.ticker,this.symbol=F.symbol,this.address=F.address,this.isSynthetic=F.isSynthetic,this.isTradeAsset=F.isTradeAsset,this.isGasAsset=F.isGasAsset,this.chainId=Bn[F.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[o,T,C]=n.split(".");if(!(o&&T))throw new M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let A=o==="THOR"&&C?`${o}.${T}/${C}`:n;return g.from({asset:A,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:o,...T}){let C=n instanceof Y?n.getValue("string"):n,A=nh(T),{identifier:F,decimal:P}=l(A),{chain:_,isSynthetic:x,isTradeAsset:N}=Pn(F),I=q.get(_==="SOL"?F:F.toUpperCase()),S=I?.decimal||P;e(!(o||S),`Couldn't find static decimal for one or more tokens on ${_} (Using default ${L[_]} decimal as fallback).
2
2
  This can result in incorrect calculations and mess with amount sent on transactions.
3
3
  You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
4
- or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:k,identifier:j,tax:z}=I||{decimal:Q||L[_],identifier:F},$=x||B,V=h?hn(BigInt(C),h):hn(C,k);return o?sn(j,h?V:C):$?ln(j,V):new g({tax:z,decimal:k,identifier:j,value:V})}static async loadStaticAssets(n){let h=await In(n);for(let{tokens:o}of Object.values(h))for(let{identifier:T,chain:C,...A}of o){let F=C==="SOL"?T:T.toUpperCase(),P="decimals"in A?A.decimals:L[C];w.set(F,{identifier:T,decimal:P})}return!0}static setStaticAssets(n){w.clear();for(let[h,o]of n.entries()){let T=o.chain==="SOL"?o.identifier:o.identifier.toUpperCase(),C="decimals"in o?o.decimals:o.decimal;w.set(h,{...o,decimal:C,identifier:T})}return!0}}function co(n){let h=g.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function sn(n,h=0){Xn(n);let T=n.includes("SOL.")?n:n.toUpperCase(),C=w.get(T),A=C?.decimal||await Ln(Pn(n));if(!C)w.set(T,{identifier:n,decimal:A});return new g({decimal:A,value:hn(h,A),identifier:n})}function ln(n,h=0){let o=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,T=o?["MAYA","THOR"].includes(o):!1,C=n.slice(0,14).includes("~")?"~":"/",[A,F]=T?n.split(".").slice(1).join().split(C):n.split(C);if(!(A&&F))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new g({decimal:8,value:hn(h,8),identifier:`${o||"THOR"}.${A}${C}${F}`})}function hn(n,h){return typeof n==="bigint"?u({value:n,bigIntDecimal:h,decimal:h}):n}function rn(n){let h="chain"in n?n.chain:r(n.asset).synth?"THOR":r(n.asset).chain;if(!Object.values(t).includes(h.toUpperCase()))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function en(n){if(rn(n),"chain"in n)return n.chain;let{chain:h,symbol:o}=r(n.asset);return Rn({chain:h,symbol:o})==="Native"?h:n.asset}function Pn(n){let h=n.slice(0,14),o=n.split("."),T=o[0]?.toUpperCase(),C=["THOR","MAYA"].includes(T),A=h.includes("/"),F=h.includes("~"),P=A||F,_=F?"~":"/",[x,B=""]=C?o.slice(1).join().split(_):n.split(_);if(P&&!(x&&B))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let[I,...Q]=(n.includes(".")&&!P?n:`${T}.${B}`).split("."),k=P?B:Q.join("."),{address:j,ticker:z}=nh({symbol:k,chain:I}),$=(P?`${x}${_}`:"")+(j?`${z}-${j??""}`:k);return{address:j,chain:I,isSynthOrTrade:P,isSynthetic:A,isTradeAsset:F,ticker:z,symbol:$,isGasAsset:Mn({chain:I,symbol:k})}}function nh({symbol:n,chain:h}){let o=n.split("-"),T=o.length===1?void 0:o[o.length-1],C=h==="SOL"?T:T?.toLowerCase(),A=o.length===1?o[0]:o.slice(0,-1).join("-");return{address:C,ticker:A}}class c extends Z{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new c({decimal:h,value:u({value:n,bigIntDecimal:h,decimal:h})})}}function hh({liquidityUnits:n,poolUnits:h,runeDepth:o}){let T=U(n),C=U(h),A=U(o),F=T.mul(A),P=C.mul(C).mul(2),_=C.mul(T).mul(2),x=T.mul(T),B=C.mul(C).mul(C);return F.mul(P.sub(_).add(x)).div(B)}function oh({liquidityUnits:n,poolUnits:h,assetDepth:o}){let T=U(n),C=U(h),A=U(o),F=T.mul(A),P=C.mul(C).mul(2),_=C.mul(T).mul(2),x=T.mul(T),B=F.mul(P.sub(_).add(x)),I=C.mul(C).mul(C);return B.div(I)}function Wo({percent:n,runeDepth:h,liquidityUnits:o,poolUnits:T}){return hh({runeDepth:h,liquidityUnits:o,poolUnits:T}).mul(n)}function fo({percent:n,assetDepth:h,liquidityUnits:o,poolUnits:T}){return oh({assetDepth:h,liquidityUnits:o,poolUnits:T}).mul(n)}function U(n){return c.fromBigInt(BigInt(n),L.THOR)}function Th({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T}){return{assetAmount:U(T).mul(n).div(h),runeAmount:U(o).mul(n).div(h)}}function uo({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T,percent:C}){return Object.fromEntries(Object.entries(Th({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T})).map(([A,F])=>[A,F.mul(C)]))}function wo({runeDepth:n,poolUnits:h,assetDepth:o,liquidityUnits:T,runeAmount:C,assetAmount:A}){let F=new c({value:n,decimal:8}),P=new c({value:o,decimal:8}),_=new c({value:h,decimal:8}),x=new c({value:C,decimal:8}),B=new c({value:A,decimal:8}),I=x.mul(P),Q=B.mul(F),k=x.mul(B),j=F.mul(P),z=_.mul(I.add(Q.add(k.mul(2)))),$=I.add(Q.add(j.mul(2))),V=z.div($),E=U(T).add(V);if(V.getBaseValue("number")===0)return E.div(_).getBaseValue("number");let p=_.add(E);return E.div(p).getBaseValue("number")}function qo({runeAmount:n,assetAmount:h,runeDepth:o,assetDepth:T}){if(n==="0"||h==="0"||o==="0"||T==="0")return 0;let C=U(o),A=U(T),F=U(h),P=U(n),_=F.mul(C).sub(A.mul(P)),x=A.mul(P).add(C.mul(A));return Math.abs(_.div(x).getBaseValue("number"))}function Eo({type:n,address:h}){return`${n}:${h}`}function yo({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function vo(n){return K("POOL+",n)}function mo({chain:n,symbol:h,...o}){return K(`${"+"}:${n}/${h}`,o)}function ao({chain:n,symbol:h,address:o,...T}){let C=Ch({chain:n,symbol:h}),A=o?`:${o}:`:":";return K(`${"+"}:${C}${A}`,T)}function so({chain:n,symbol:h,basisPoints:o}){return`${"-"}:${n}/${h}:${o}`}function io({chain:n,symbol:h,ticker:o,basisPoints:T,targetAsset:C}){let A=n==="ETH"&&o!=="ETH"?`${o}-${h.slice(-3)}`:h,F=C?`:${C}`:"";return`${"-"}:${n}.${A}:${T}${F}`}function lo({basisPoints:n,...h}){return K(`${"POOL-"}:${n}`,h)}function ro({name:n,chain:h,address:o,owner:T}){let C=`${"~"}:${n}:${h}:${o}`,A=T?`:${T}`:"";return`${C}${A}`}function eo({name:n,chain:h,asset:o,payout:T,owner:C}){return`${"~"}:${n}:${h}:${T}:${C}:${o}`}function nT(n,{asset:h,address:o,minAmount:T,...C}){let A=`${n}:${h}:${o}`,F=T?`:${T}`:"";return K(`${A}${F}`,C)}function K(n,{affiliateAddress:h,affiliateBasisPoints:o}={}){let T=`${n}${h?`:${h}:${o||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function Ch({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}function oT({name:n,properties:h,methods:o}){function T(C){return{...o(C),...h}}return{[n]:T}}function PT(){return typeof window.ethereum!=="undefined"}function FT(n){return Rh().includes(n)}function Rh(){let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,o=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,C=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,F=window?.$onekey?.ethereum,P=[];if(n)P.push("METAMASK");if(h)P.push("CTRL");if(o)P.push("BRAVE");if(T)P.push("TRUSTWALLET_WEB");if(C)P.push("COINBASE_WEB");if(xh())P.push("OKX_MOBILE");if(A)P.push("BITGET");if(F)P.push("ONEKEY");return P}async function Ah(n,h,o){try{await tn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:Nn[h]}]})}catch(T){if(!o)throw new Error("Failed to switch network, networkParams not provided");await Fh(n,o)}}function xT({chains:n,supportedChains:h,walletType:o}){let T=n.filter((A)=>h.includes(A));if(T.length===0)throw new M("wallet_chain_not_supported",{wallet:o,chain:n.join(", ")});let C=n.filter((A)=>!h.includes(A));return e(C.length>0,`${o} wallet does not support the following chains: ${C.join(", ")}. These chains will be ignored.`),T}function Ph(n,h,o){}function HT({toolbox:n,chain:h,provider:o=window.ethereum,methodNames:T=[]}){let A=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((F,P)=>{if(!n[P])return F;let _=n[P];if(typeof _!=="function")return F;let x=Ph(_,o,h);return{...F,[P]:x}},{});return{...n,...A}}function Fh(n,h){return tn({provider:n,method:"wallet_addEthereumChain",params:[h]})}function _T(n){window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())}function BT(){let{isTrust:n,isBraveWallet:h,__XDEFI:o,overrideIsMetaMask:T,selectedProvider:C}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&C?.isCoinbaseWallet)return"COINBASE_WEB";if(o)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function NT(){let n=[];function h(T){if(n.map((C)=>C.info.uuid).includes(T.detail.info.uuid))return;n.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function o(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:o}}function xh(){let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),o=/android|XiaoMi|MiuiBrowser/i.test(n),T=h||o,C=/OKApp/i.test(n);return T&&C}function OT({connect:n,name:h,supportedChains:o,walletType:T}){function C(A){return n({...A,walletType:T,supportedChains:o})}return{[h]:{supportedChains:o,connectWallet:C}}}function tn({provider:n,params:h,method:o}){if(!n?.send)throw new M("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return n.send(o,T)}export{Ho as wrapWithThrow,Ph as wrapMethodWithNetworkSwitch,e as warnOnce,Mo as validateTNS,Xn as validateIdentifier,Cn as updateDerivationPath,Ah as switchEVMWalletNetwork,HT as prepareNetworkSwitch,xh as okxMobileEnabled,In as loadTokenLists,Rh as listWeb3EVMWallets,PT as isWeb3Detected,Mn as isGasAsset,FT as isDetected,Lh as initializeRPCUrlsWithFallback,Qh as getWalletFormatFor,Fo as getTHORNameCost,uo as getSymmetricWithdraw,Th as getSymmetricPoolShare,co as getMinAmountByChain,io as getMemoForWithdraw,yo as getMemoForUnbond,so as getMemoForSaverWithdraw,mo as getMemoForSaverDeposit,lo as getMemoForRunePoolWithdraw,vo as getMemoForRunePoolDeposit,ro as getMemoForNameRegister,eo as getMemoForNamePreferredAssetRegister,nT as getMemoForLoan,Eo as getMemoForLeaveAndBond,ao as getMemoForDeposit,xo as getMAYANameCost,qo as getLiquiditySlippage,no as getGasAsset,wo as getEstimatedPoolShare,BT as getETHDefaultWallet,NT as getEIP6963Wallets,Bo as getDynamicChainId,Uh as getDerivationPathFor,Ln as getDecimal,l as getCommonAssetInfo,_o as getChainIdentifier,Wo as getAsymmetricRuneWithdrawAmount,hh as getAsymmetricRuneShare,fo as getAsymmetricAssetWithdrawAmount,oh as getAsymmetricAssetShare,Rn as getAssetType,u as formatBigIntToSafeValue,ho as findAssetBy,xT as filterSupportedChains,On as derivationPathToString,OT as createWallet,oT as createPlugin,r as assetFromString,Fh as addEVMWalletNetwork,_T as addAccountsChangedCallback,Yn as WarningCodeEnum,d as WalletOption,Hn as UTXOChains,$h as TCSupportedChains,c as SwapKitNumber,M as SwapKitError,Bh as SubstrateChains,on as StagenetChain,Xh as SWAP_OUT,Gh as SWAP_IN,J as SKConfig,f as RequestClient,a as RPC_URLS,zn as QuoteMode,Vn as ProviderName,W as NetworkDerivationPath,y as NODE_URLS,$n as MemoType,ph as MAYASupportedChains,wn as LedgerErrorCode,Wn as FeeTypeEnum,fn as FeeOption,Qn as FALLBACK_URLS,Zn as ErrorCode,Tn as EXPLORER_URLS,q as EVMChains,ch as DerivationPath,Nh as CosmosChains,Oh as CosmosChainPrefixes,gn as ContractAddress,eh as CommonAssetStrings,Nn as ChainToHexChainId,Mh as ChainToExplorerUrl,Bn as ChainToChainId,Hh as ChainIdToChain,v as ChainId,t as Chain,_h as BlockTimes,Z as BigIntArithmetics,L as BaseDecimal,g as AssetValue,un as ApproveMode,Ih as AGG_SWAP};
4
+ or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:k,identifier:G,tax:c}=I||{decimal:S||L[_],identifier:F},B=x||N,Z=h?hn(BigInt(C),h):hn(C,k);return o?ln(G,h?Z:C):B?rn(G,Z):new g({tax:c,decimal:k,identifier:G,value:Z})}static async loadStaticAssets(n){let h=await In(n);for(let{tokens:o}of Object.values(h))for(let{identifier:T,chain:C,...A}of o){let F=C==="SOL"?T:T.toUpperCase(),P="decimals"in A?A.decimals:L[C];q.set(F,{identifier:T,decimal:P})}return!0}static setStaticAssets(n){q.clear();for(let[h,o]of n.entries()){let T=o.chain==="SOL"?o.identifier:o.identifier.toUpperCase(),C="decimals"in o?o.decimals:o.decimal;q.set(h,{...o,decimal:C,identifier:T})}return!0}}function Zo(n){let h=g.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function ln(n,h=0){Xn(n);let T=n.includes("SOL.")?n:n.toUpperCase(),C=q.get(T),A=C?.decimal||await Ln(Pn(n));if(!C)q.set(T,{identifier:n,decimal:A});return new g({decimal:A,value:hn(h,A),identifier:n})}function rn(n,h=0){let o=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,T=o?["MAYA","THOR"].includes(o):!1,C=n.slice(0,14).includes("~")?"~":"/",[A,F]=T?n.split(".").slice(1).join().split(C):n.split(C);if(!(A&&F))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new g({decimal:8,value:hn(h,8),identifier:`${o||"THOR"}.${A}${C}${F}`})}function hn(n,h){return typeof n==="bigint"?w({value:n,bigIntDecimal:h,decimal:h}):n}function en(n){let h="chain"in n?n.chain:r(n.asset).synth?"THOR":r(n.asset).chain;if(!Object.values(U).includes(h.toUpperCase()))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function nh(n){if(en(n),"chain"in n)return n.chain;let{chain:h,symbol:o}=r(n.asset);return Rn({chain:h,symbol:o})==="Native"?h:n.asset}function Pn(n){let h=n.slice(0,14),o=n.split("."),T=o[0]?.toUpperCase(),C=["THOR","MAYA"].includes(T),A=h.includes("/"),F=h.includes("~"),P=A||F,_=F?"~":"/",[x,N=""]=C?o.slice(1).join().split(_):n.split(_);if(P&&!(x&&N))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let[I,...S]=(n.includes(".")&&!P?n:`${T}.${N}`).split("."),k=P?N:S.join("."),{address:G,ticker:c}=hh({symbol:k,chain:I}),B;try{B=G&&W.includes(I)&&Un(G)?Un(G):G}catch(D){B=G}let Z=(P?`${x}${_}`:"")+(B?`${c}-${B??""}`:k);return{address:B,chain:I,isSynthOrTrade:P,isSynthetic:A,isTradeAsset:F,ticker:c,symbol:Z,isGasAsset:Mn({chain:I,symbol:k})}}function hh({symbol:n,chain:h}){let o=n.split("-"),T=o.length===1?void 0:o[o.length-1],C=h==="SOL"?T:T?.toLowerCase(),A=o.length===1?o[0]:o.slice(0,-1).join("-");return{address:C,ticker:A}}class z extends Y{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new z({decimal:h,value:w({value:n,bigIntDecimal:h,decimal:h})})}}function oh({liquidityUnits:n,poolUnits:h,runeDepth:o}){let T=Q(n),C=Q(h),A=Q(o),F=T.mul(A),P=C.mul(C).mul(2),_=C.mul(T).mul(2),x=T.mul(T),N=C.mul(C).mul(C);return F.mul(P.sub(_).add(x)).div(N)}function Th({liquidityUnits:n,poolUnits:h,assetDepth:o}){let T=Q(n),C=Q(h),A=Q(o),F=T.mul(A),P=C.mul(C).mul(2),_=C.mul(T).mul(2),x=T.mul(T),N=F.mul(P.sub(_).add(x)),I=C.mul(C).mul(C);return N.div(I)}function uo({percent:n,runeDepth:h,liquidityUnits:o,poolUnits:T}){return oh({runeDepth:h,liquidityUnits:o,poolUnits:T}).mul(n)}function wo({percent:n,assetDepth:h,liquidityUnits:o,poolUnits:T}){return Th({assetDepth:h,liquidityUnits:o,poolUnits:T}).mul(n)}function Q(n){return z.fromBigInt(BigInt(n),L.THOR)}function Ch({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T}){return{assetAmount:Q(T).mul(n).div(h),runeAmount:Q(o).mul(n).div(h)}}function qo({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T,percent:C}){return Object.fromEntries(Object.entries(Ch({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T})).map(([A,F])=>[A,F.mul(C)]))}function Do({runeDepth:n,poolUnits:h,assetDepth:o,liquidityUnits:T,runeAmount:C,assetAmount:A}){let F=new z({value:n,decimal:8}),P=new z({value:o,decimal:8}),_=new z({value:h,decimal:8}),x=new z({value:C,decimal:8}),N=new z({value:A,decimal:8}),I=x.mul(P),S=N.mul(F),k=x.mul(N),G=F.mul(P),c=_.mul(I.add(S.add(k.mul(2)))),B=I.add(S.add(G.mul(2))),Z=c.div(B),D=Q(T).add(Z);if(Z.getBaseValue("number")===0)return D.div(_).getBaseValue("number");let p=_.add(D);return D.div(p).getBaseValue("number")}function bo({runeAmount:n,assetAmount:h,runeDepth:o,assetDepth:T}){if(n==="0"||h==="0"||o==="0"||T==="0")return 0;let C=Q(o),A=Q(T),F=Q(h),P=Q(n),_=F.mul(C).sub(A.mul(P)),x=A.mul(P).add(C.mul(A));return Math.abs(_.div(x).getBaseValue("number"))}function vo({type:n,address:h}){return`${n}:${h}`}function mo({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function ao(n){return y("POOL+",n)}function io({chain:n,symbol:h,...o}){return y(`${"+"}:${n}/${h}`,o)}function so({chain:n,symbol:h,address:o,...T}){let C=Rh({chain:n,symbol:h}),A=o?`:${o}:`:":";return y(`${"+"}:${C}${A}`,T)}function lo({chain:n,symbol:h,basisPoints:o}){return`${"-"}:${n}/${h}:${o}`}function ro({chain:n,symbol:h,ticker:o,basisPoints:T,targetAsset:C}){let A=n==="ETH"&&o!=="ETH"?`${o}-${h.slice(-3)}`:h,F=C?`:${C}`:"";return`${"-"}:${n}.${A}:${T}${F}`}function eo({basisPoints:n,...h}){return y(`${"POOL-"}:${n}`,h)}function nT({name:n,chain:h,address:o,owner:T}){let C=`${"~"}:${n}:${h}:${o}`,A=T?`:${T}`:"";return`${C}${A}`}function hT({name:n,chain:h,asset:o,payout:T,owner:C}){return`${"~"}:${n}:${h}:${T}:${C}:${o}`}function oT(n,{asset:h,address:o,minAmount:T,...C}){let A=`${n}:${h}:${o}`,F=T?`:${T}`:"";return y(`${A}${F}`,C)}function y(n,{affiliateAddress:h,affiliateBasisPoints:o}={}){let T=`${n}${h?`:${h}:${o||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function Rh({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}function CT({name:n,properties:h,methods:o}){function T(C){return{...o(C),...h}}return{[n]:T}}function xT(){return typeof window.ethereum!=="undefined"}function HT(n){return Ah().includes(n)}function Ah(){let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,o=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,C=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,F=window?.$onekey?.ethereum,P=[];if(n)P.push("METAMASK");if(h)P.push("CTRL");if(o)P.push("BRAVE");if(T)P.push("TRUSTWALLET_WEB");if(C)P.push("COINBASE_WEB");if(Hh())P.push("OKX_MOBILE");if(A)P.push("BITGET");if(F)P.push("ONEKEY");return P}async function Ph(n,h,o){try{await Qn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:Nn[h]}]})}catch(T){if(!o)throw new Error("Failed to switch network, networkParams not provided");await xh(n,o)}}function _T({chains:n,supportedChains:h,walletType:o}){let T=n.filter((A)=>h.includes(A));if(T.length===0)throw new M("wallet_chain_not_supported",{wallet:o,chain:n.join(", ")});let C=n.filter((A)=>!h.includes(A));return e(C.length>0,`${o} wallet does not support the following chains: ${C.join(", ")}. These chains will be ignored.`),T}function Fh(n,h,o){}function BT({toolbox:n,chain:h,provider:o=window.ethereum,methodNames:T=[]}){let A=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((F,P)=>{if(!n[P])return F;let _=n[P];if(typeof _!=="function")return F;let x=Fh(_,o,h);return{...F,[P]:x}},{});return{...n,...A}}function xh(n,h){return Qn({provider:n,method:"wallet_addEthereumChain",params:[h]})}function NT(n){window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())}function OT(){let{isTrust:n,isBraveWallet:h,__XDEFI:o,overrideIsMetaMask:T,selectedProvider:C}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&C?.isCoinbaseWallet)return"COINBASE_WEB";if(o)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function $T(){let n=[];function h(T){if(n.map((C)=>C.info.uuid).includes(T.detail.info.uuid))return;n.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function o(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:o}}function Hh(){let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),o=/android|XiaoMi|MiuiBrowser/i.test(n),T=h||o,C=/OKApp/i.test(n);return T&&C}function pT({connect:n,name:h,supportedChains:o,walletType:T}){function C(A){return n({...A,walletType:T,supportedChains:o})}return{[h]:{supportedChains:o,connectWallet:C}}}function Qn({provider:n,params:h,method:o}){if(!n?.send)throw new M("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return n.send(o,T)}export{_o as wrapWithThrow,Fh as wrapMethodWithNetworkSwitch,e as warnOnce,ko as validateTNS,Xn as validateIdentifier,Cn as updateDerivationPath,Ph as switchEVMWalletNetwork,BT as prepareNetworkSwitch,Hh as okxMobileEnabled,In as loadTokenLists,Ah as listWeb3EVMWallets,xT as isWeb3Detected,Mn as isGasAsset,HT as isDetected,Mh as initializeRPCUrlsWithFallback,Jh as getWalletFormatFor,xo as getTHORNameCost,qo as getSymmetricWithdraw,Ch as getSymmetricPoolShare,Zo as getMinAmountByChain,ro as getMemoForWithdraw,mo as getMemoForUnbond,lo as getMemoForSaverWithdraw,io as getMemoForSaverDeposit,eo as getMemoForRunePoolWithdraw,ao as getMemoForRunePoolDeposit,nT as getMemoForNameRegister,hT as getMemoForNamePreferredAssetRegister,oT as getMemoForLoan,vo as getMemoForLeaveAndBond,so as getMemoForDeposit,Ho as getMAYANameCost,bo as getLiquiditySlippage,ho as getGasAsset,Do as getEstimatedPoolShare,OT as getETHDefaultWallet,$T as getEIP6963Wallets,No as getDynamicChainId,Sh as getDerivationPathFor,Ln as getDecimal,l as getCommonAssetInfo,Bo as getChainIdentifier,uo as getAsymmetricRuneWithdrawAmount,oh as getAsymmetricRuneShare,wo as getAsymmetricAssetWithdrawAmount,Th as getAsymmetricAssetShare,Rn as getAssetType,w as formatBigIntToSafeValue,oo as findAssetBy,_T as filterSupportedChains,On as derivationPathToString,pT as createWallet,CT as createPlugin,r as assetFromString,xh as addEVMWalletNetwork,NT as addAccountsChangedCallback,Wn as WarningCodeEnum,i as WalletOption,Hn as UTXOChains,ph as TCSupportedChains,z as SwapKitNumber,M as SwapKitError,Nh as SubstrateChains,on as StagenetChain,jh as SWAP_OUT,Xh as SWAP_IN,t as SKConfig,u as RequestClient,a as RPC_URLS,Zn as QuoteMode,Vn as ProviderName,f as NetworkDerivationPath,E as NODE_URLS,$n as MemoType,Lh as MAYASupportedChains,qn as LedgerErrorCode,fn as FeeTypeEnum,un as FeeOption,Jn as FALLBACK_URLS,Yn as ErrorCode,Tn as EXPLORER_URLS,W as EVMChains,ch as DerivationPath,Oh as CosmosChains,$h as CosmosChainPrefixes,gn as ContractAddress,no as CommonAssetStrings,Nn as ChainToHexChainId,kh as ChainToExplorerUrl,Bn as ChainToChainId,_h as ChainIdToChain,v as ChainId,U as Chain,Bh as BlockTimes,Y as BigIntArithmetics,L as BaseDecimal,g as AssetValue,wn as ApproveMode,Gh as AGG_SWAP};
5
5
 
6
- //# debugId=4D907AD7F50FA4F264756E2164756E21
6
+ //# debugId=15609CF3538B41F964756E2164756E21