@swapkit/helpers 4.12.9 → 4.13.1
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/api/index.js +1 -1
- package/dist/chunk-0mec23vm.js +4 -0
- package/dist/chunk-3tnapk6k.js +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/modules/assetValue.d.ts +1 -1
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/types/wallet.d.ts +2 -3
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/dist/types/utils/wallets.d.ts +0 -16
- package/dist/types/utils/wallets.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-5x8k4c6c.js +0 -4
- package/dist/chunk-71e6bysh.js +0 -5
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as WB,A as of,Aa as oB,B as df,Ba as dB,C as sf,Ca as sB,D as lf,Da as lB,E as nf,Ea as nB,F as pf,Fa as pB,G as tf,Ga as iB,H as af,Ha as tB,I as ef,Ia as aB,J as $B,Ja as eB,K as fB,Ka as $R,L as BB,La as fR,M as RB,Ma as BR,N as Q,Na as RR,O as gB,Oa as gR,P as xB,Pa as xR,Q as MB,Qa as MR,R as YB,Ra as YR,S as GB,T as zB,U as JB,V as LB,W as QB,X as XB,Y as ZB,Z as _B,_ as PB,a as Z,aa as jB,b as qf,ba as CB,c as Tf,ca as HB,d as Sf,da as VB,e as Af,ea as FB,f as m,fa as EB,g as Kf,ga as IB,h as t,ha as NB,i as $$,ia as qB,j as Uf,ja as TB,k as S,ka as SB,l as Df,la as AB,m as P,ma as KB,n as W,na as UB,o as Of,oa as DB,p as kf,pa as OB,q as yf,qa as kB,r as bf,ra as yB,s as mf,sa as bB,t as A,ta as mB,u as vf,ua as vB,v as wf,va as wB,w as cf,wa as cB,x as rf,xa as rB,y as hf,ya as hB,z as uf,za as uB}from"./chunk-71e6bysh.js";export*from"@swapkit/tokens";export*from"@swapkit/types";var v={average:1,fast:1.5,fastest:2};function I($="average"){let f=P.get("feeMultipliers");if(f&&f[$]!==void 0)return f[$];return v[$]}function w($="average"){let f=I($),B=10n,R=BigInt(Math.round(f*10));return{denominator:B,numerator:R}}function G$($,f="average"){let{numerator:B,denominator:R}=w(f);return $*B/R}function z$($,f="average",B=!1){let R=I(f),g=$*R;return B?Math.floor(g):g}import{Chain as N,EVMChains as c}from"@swapkit/types";function V($,f){if("index"in f)return[...$.slice(0,$.length-1),f.index];if("change"in f){let[B,R,g,,x]=$;return[B,R,g,f.change,x]}if("account"in f){let[B,R,,g,x]=$;return[B,R,f.account,g,x]}return $}function r([$,f,B,R,g],{allHardened:x}={}){let Y=x?"'":"",G=typeof g!=="number";if(typeof R!=="number")return`m/${$}'/${f}'/${B}'`;return`m/${$}'/${f}'/${B}'/${R}${Y}${G?"":`/${g}${Y}`}`}function X$({chain:$,index:f,addressIndex:B=0,type:R}){if(c.includes($)){if(R&&["legacy","account"].includes(R))return[44,60,0,f];if(R==="ledgerLive")return[44,60,f,0,B];return V(Z[$],{index:f})}if($===N.Solana){if(R==="account")return[44,501,0,f];return V(Z[$],{index:f})}let g=$===N.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,g,f,0,B];case"segwit":return[49,g,0,0,f];case"legacy":return[44,g,0,0,f];default:return V(Z[$],{index:f})}}function Z$($){let[f,B,R]=$.split("/").map((g)=>Number.parseInt(g,10));switch(B){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var _$=Object.keys(Z).reduce(($,f)=>{return $[f]=r(Z[f]),$},{});import{Chain as J,CosmosChains as h,EVMChains as u,getChainConfig as q,SubstrateChains as o,UTXOChains as d}from"@swapkit/types";import{match as T}from"ts-pattern";function C$({chain:$,txHash:f}){let{explorerUrl:B}=q($);return T($).with(...h,J.Solana,()=>`${B}/tx/${f.startsWith("0x")?f.slice(2):f}`).with(...u,...o,()=>`${B}/tx/${f.startsWith("0x")?f:`0x${f}`}`).with(...d,J.Radix,J.Tron,()=>`${B}/transaction/${f.toLowerCase()}`).with(J.Near,()=>`${B}/txns/${f}`).with(J.Ripple,()=>`${B}/transactions/${f}`).with(J.Sui,()=>`${B}/txblock/${f}`).with(J.Cardano,J.HyperCore,J.Ton,()=>`${B}/tx/${f}`).otherwise(()=>"")}function H$({chain:$,address:f}){let{explorerUrl:B}=q($);return T($).with(J.Solana,J.Sui,J.Radix,()=>`${B}/account/${f}`).otherwise(()=>`${B}/address/${f}`)}import{Chain as s,getChainConfig as l}from"@swapkit/types";function n({liquidityUnits:$,poolUnits:f,runeDepth:B}){let R=z($),g=z(f),x=z(B),Y=R.mul(x),G=g.mul(g).mul(2),M=g.mul(R).mul(2),L=R.mul(R),X=g.mul(g).mul(g);return Y.mul(G.sub(M).add(L)).div(X)}function p({liquidityUnits:$,poolUnits:f,assetDepth:B}){let R=z($),g=z(f),x=z(B),Y=R.mul(x),G=g.mul(g).mul(2),M=g.mul(R).mul(2),L=R.mul(R),X=Y.mul(G.sub(M).add(L)),_=g.mul(g).mul(g);return X.div(_)}function I$({percent:$,runeDepth:f,liquidityUnits:B,poolUnits:R}){return n({liquidityUnits:B,poolUnits:R,runeDepth:f}).mul($)}function N$({percent:$,assetDepth:f,liquidityUnits:B,poolUnits:R}){return p({assetDepth:f,liquidityUnits:B,poolUnits:R}).mul($)}function z($){return Q.fromBigInt(BigInt($),l(s.THORChain).baseDecimal)}function i({liquidityUnits:$,poolUnits:f,runeDepth:B,assetDepth:R}){return{assetAmount:z(R).mul($).div(f),runeAmount:z(B).mul($).div(f)}}function q$({liquidityUnits:$,poolUnits:f,runeDepth:B,assetDepth:R,percent:g}){return Object.fromEntries(Object.entries(i({assetDepth:R,liquidityUnits:$,poolUnits:f,runeDepth:B})).map(([x,Y])=>[x,Y.mul(g)]))}function T$({runeDepth:$,poolUnits:f,assetDepth:B,liquidityUnits:R,runeAmount:g,assetAmount:x}){let Y=new Q({decimal:8,value:$}),G=new Q({decimal:8,value:B}),M=new Q({decimal:8,value:f}),L=new Q({decimal:8,value:g}),X=new Q({decimal:8,value:x}),_=L.mul(G),F=X.mul(Y),D=L.mul(X),O=Y.mul(G),k=M.mul(_.add(F.add(D.mul(2)))),y=_.add(F.add(O.mul(2))),E=k.div(y),H=z(R).add(E);if(E.getBaseValue("number")===0)return H.div(M).getBaseValue("number");let b=M.add(H);return H.div(b).getBaseValue("number")}function S$({runeAmount:$,assetAmount:f,runeDepth:B,assetDepth:R}){if($==="0"||f==="0"||B==="0"||R==="0")return 0;let g=z(B),x=z(R),Y=z(f),G=z($),M=Y.mul(g).sub(x.mul(G)),L=x.mul(G).add(g.mul(x));return Math.abs(M.div(L).getBaseValue("number"))}import{Chain as j}from"@swapkit/types";import{match as a}from"ts-pattern";function O$({type:$,address:f}){return`${$}:${f}`}function k$({address:$,unbondAmount:f}){return`${"UNBOND"}:${$}:${f}`}function y$($){return C("POOL+",$)}function b$({chain:$,symbol:f,address:B,...R}){let g=e({chain:$,symbol:f}),x=B?`:${B}:`:":";return C(`${"+"}:${g}${x}`,R)}function m$({chain:$,symbol:f,ticker:B,basisPoints:R,targetAsset:g}){let x=$==="ETH"&&B!=="ETH"?`${B}-${f.slice(-3)}`:f,Y=g?`:${g}`:"";return`${"-"}:${$}.${x}:${R}${Y}`}function v$({basisPoints:$,...f}){return C(`${"POOL-"}:${$}`,f)}function w$({name:$,chain:f,address:B,owner:R}){let g=`${"~"}:${$}:${f}:${B}`,x=R?`:${R}`:"";return`${g}${x}`}function c$({name:$,chain:f,asset:B,payout:R,owner:g}){return`${"~"}:${$}:${f}:${R}:${g}:${B}`}function r$($,{address:f}){return`${$}:${f}`}function h$($,{unstakeBps:f,...B}){let R=f?`:${f}`:"",g=`${$}${R}`;return C(`${g}`,B)}function C($,{affiliateAddress:f,affiliateBasisPoints:B}={}){let R=`${$}${f?`:${f}:${B||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function e({chain:$,symbol:f}){return a($).with(j.Bitcoin,j.Dogecoin,j.Litecoin,()=>$.slice(0,1).toLowerCase()).with(j.BitcoinCash,()=>"c").otherwise(()=>`${$}.${f}`)}import{getChainConfig as K}from"@swapkit/types";function p$(){return typeof window.ethereum<"u"}function i$($){return f$().includes($)}function f$(){let $=window?.ethereum&&!window.ethereum?.isBraveWallet,f=window?.ctrl||window?.ethereum?.__XDEFI,B=window?.vultisig,R=window?.ethereum?.isBraveWallet,g=window?.ethereum?.isTrust||window?.trustwallet,x=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,Y=window?.bitkeep?.ethereum,G=window?.$onekey?.ethereum,M=[];if($)M.push("METAMASK");if(f)M.push("CTRL");if(B)M.push("VULTISIG");if(R)M.push("BRAVE");if(g)M.push("TRUSTWALLET_WEB");if(x)M.push("COINBASE_WEB");if(x$())M.push("OKX_MOBILE");if(Y)M.push("BITGET");if(G)M.push("ONEKEY");return M}async function B$($,f,B){let R=K(f);try{await U({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:$})}catch(g){if(!B)throw new W("helpers_failed_to_switch_network",{error:g,reason:"networkParams not provided"});await g$($,B)}}function t$({chains:$,supportedChains:f,walletType:B}){let R=$.filter((x)=>!x||f.includes(x));if(R.length===0)throw new W("wallet_chain_not_supported",{chain:$.join(", "),wallet:B});let g=$.filter((x)=>!f.includes(x));return A({condition:g.length>0,id:`wallet_chain_not_supported_${B}`,warning:`${B} wallet does not support the following chains: ${g.join(", ")}. These chains will be ignored.`}),R}function R$($,f,B){return async(...R)=>{let{chainIdHex:g}=K(B);if((await f.getNetwork()).chainId.toString()===g)return $(...R);try{await B$(f,B)}catch(x){throw new W({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return $(...R)}}function a$({toolbox:$,chain:f,provider:B=window.ethereum,methodNames:R=[]}){let x=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((Y,G)=>{if(!$[G])return Y;let M=$[G];if(typeof M!=="function")return Y;let L=R$(M,B,f);return{...Y,[G]:L}},{});return{...$,...x}}function g$($,f){return U({method:"wallet_addEthereumChain",params:[f],provider:$})}function e$($){window.ethereum?.on("accountsChanged",()=>$()),window.ctrl?.ethereum.on("accountsChanged",()=>$())}function $f(){let{isTrust:$,isBraveWallet:f,__XDEFI:B,overrideIsMetaMask:R,selectedProvider:g}=window?.ethereum||{};if($)return"TRUSTWALLET_WEB";if(f)return"BRAVE";if(R&&g?.isCoinbaseWallet)return"COINBASE_WEB";if(B)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function ff(){let $=[];function f(R){if($.map((g)=>g.info.uuid).includes(R.detail.info.uuid))return;$.push(R.detail)}window.addEventListener("eip6963:announceProvider",f),window.dispatchEvent(new Event("eip6963:requestProvider"));function B(){window.removeEventListener("eip6963:announceProvider",f)}return{providers:$,removeEIP6963EventListener:B}}function x$(){let $=navigator.userAgent,f=/iphone|ipad|ipod|ios/i.test($),B=/android|XiaoMi|MiuiBrowser/i.test($),R=f||B,g=/OKApp/i.test($);return R&&g}function U({provider:$,params:f,method:B}){if(!$?.send)throw new W("helpers_not_found_provider");let R=f?Array.isArray(f)?f:[f]:[];return $.send(B,R)}function Bf($,f){if(!P.get("v3SwapFlow")?.enabled)return!1;return S[f]?.includes($)??!1}export{bf as wrapWithThrow,R$ as wrapMethodWithNetworkSwitch,A as warnOnce,ef as validateTNS,af as validateIdentifier,V as updateDerivationPath,B$ as switchEVMWalletNetwork,Df as swapKitConfigStore,Bf as supportsV3SwapFlow,gB as signWidgetRequest,U as providerRequest,a$ as prepareNetworkSwitch,nf as parseSymbolForAddress,x$ as okxMobileEnabled,f$ as listWeb3EVMWallets,p$ as isWeb3Detected,of as isGasAsset,i$ as isDetected,rf as initializeRPCUrlsWithFallback,Z$ as getWalletFormatFor,pf as getTokenLogoURI,kf as getTHORNameCost,q$ as getSymmetricWithdraw,i as getSymmetricPoolShare,wf as getRPCUrlSync,cf as getRPCUrl,RB as getMinAmountByChain,m$ as getMemoForWithdraw,k$ as getMemoForUnbond,h$ as getMemoForTcyStake,r$ as getMemoForTcyClaim,v$ as getMemoForRunePoolWithdraw,y$ as getMemoForRunePoolDeposit,w$ as getMemoForNameRegister,c$ as getMemoForNamePreferredAssetRegister,O$ as getMemoForLeaveAndBond,b$ as getMemoForDeposit,yf as getMAYANameCost,S$ as getLiquiditySlippage,w as getFeeMultiplierAsBigInt,I as getFeeMultiplier,C$ as getExplorerTxUrl,H$ as getExplorerAddressUrl,T$ as getEstimatedPoolShare,$f as getETHDefaultWallet,ff as getEIP6963Wallets,X$ as getDerivationPathFor,df as getCommonAssetInfo,mf as getChainIdentifier,I$ as getAsymmetricRuneWithdrawAmount,n as getAsymmetricRuneShare,N$ as getAsymmetricAssetWithdrawAmount,p as getAsymmetricAssetShare,sf as getAssetType,$B as formatBigIntToSafeValue,tf as findAssetBy,t$ as filterSupportedChains,uf as fetchTokenInfo,r as derivationPathToString,lf as assetFromString,G$ as applyFeeMultiplierToBigInt,z$ as applyFeeMultiplier,g$ as addEVMWalletNetwork,e$ as addAccountsChangedCallback,vf as _rpcCache,Tf as WarningCodeEnum,$$ as WalletOption,S as V3SwapFlowSupport,YB as TxnType,zB as TxnStatus,OB as TronTransactionSchema,SB as TransactionSchema,AB as TransactionDTOSchema,JB as TrackingStatus,QB as TrackingRequestSchema,XB as TrackingRequestQuerySchema,TB as TrackerResponseSchema,LB as TokenSchema,WB as TokenDetailsMetadataSchema,vB as TONTransactionSchema,BR as SwapToResponseSchema,$R as SwapToRequestSchema,fR as SwapToAssetSchema,MR as SwapRouteV2ResponseSchema,Q as SwapKitNumber,W as SwapKitError,YR as SwapKitApi,mB as StarknetTransactionSchema,P as SKConfig,dB as RouteQuoteWarningSchema,MB as RouteQuoteTxType,gR as RouteQuoteProviderErrorSchema,oB as RouteQuoteMetadataV2Schema,uB as RouteQuoteMetadataSchema,rB as RouteQuoteMetadataAssetSchema,cB as RouteLegWithoutAddressesSchema,wB as RouteLegSchema,Of as RequestClient,eB as QuoteV3ResponseSchema,xR as QuoteV2ResponseSchema,RR as QuoteRouteV2Response,lB as QuoteResponseSchema,sB as QuoteResponseRouteItem,CB as QuoteRequestSchema,Sf as ProviderName,GB as ProviderAction,xB as PriorityLabel,jB as PriceResponseSchema,HB as PriceRequestSchema,Z as NetworkDerivationPath,qB as NearSwapResponseSchema,NB as NearDepositChannelResultSchema,IB as NearDepositChannelParamsSchema,t as MemoType,Uf as LedgerErrorCode,nB as GasSchema,pB as GasResponseSchema,KB as FeesSchema,Af as FeeTypeEnum,m as FeeOption,UB as EstimatedTimeSchema,qf as ErrorCode,DB as EVMTransactionSchema,yB as EVMTransactionDetailsSchema,kB as EVMTransactionDetailsParamsSchema,_$ as DerivationPath,EB as DepositChannelResponseSchema,VB as DepositChannelParamsSchema,v as DEFAULT_FEE_MULTIPLIERS,bB as CosmosTransactionSchema,hf as CommonAssetStrings,PB as CoinGeckoMetadataSchema,hB as ChainflipMetadataSchema,FB as BrokerDepositChannelParamsSchema,fB as BigIntArithmetics,_B as AssetValueSchema,BB as AssetValue,tB as ApproveResponseSchema,iB as ApproveRequestParams,Kf as ApproveMode,aB as ApprovalTransactionSchema,ZB as ApiV2ErrorSchema};
|
|
1
|
+
import{$ as Zg,A as hf,Aa as hg,B as of,Ba as og,C as uf,Ca as ug,D as sf,Da as sg,E as df,Ea as dg,F as lf,Fa as lg,G as nf,Ga as ng,H as pf,Ha as pg,I as tf,Ia as ig,J as af,Ja as tg,K as ef,Ka as ag,L as $g,La as eg,M as P,Ma as $R,N as fg,Na as fR,O as gg,Oa as gR,P as Rg,Pa as RR,Q as Bg,Qa as BR,R as xg,S as Mg,T as Yg,U as Gg,V as zg,W as Jg,X as Lg,Y as Pg,Z as Qg,_ as Xg,a as X,aa as _g,b as Ef,ba as Vg,c as If,ca as Cg,d as Tf,da as Wg,e as Sf,ea as jg,f as b,fa as Fg,g as qf,ga as Hg,h as i,ha as Eg,i as e,ia as Ig,j as Nf,ja as Tg,k as Kf,ka as Sg,l as E,la as qg,m as _,ma as Ng,n as Af,na as Kg,o as Of,oa as Ag,p as Uf,pa as Og,q as Df,qa as Ug,r as yf,ra as Dg,s as N,sa as yg,t as kf,ta as kg,u as bf,ua as bg,v as mf,va as mg,w as vf,wa as vg,x as wf,xa as wg,y as cf,ya as cg,z as rf,za as rg}from"./chunk-3tnapk6k.js";export*from"@swapkit/tokens";export*from"@swapkit/types";var m={average:1,fast:1.5,fastest:2};function I($="average"){let f=E.get("feeMultipliers");if(f&&f[$]!==void 0)return f[$];return m[$]}function v($="average"){let f=I($),g=10n,R=BigInt(Math.round(f*10));return{denominator:g,numerator:R}}function Y$($,f="average"){let{numerator:g,denominator:R}=v(f);return $*g/R}function G$($,f="average",g=!1){let R=I(f),B=$*R;return g?Math.floor(B):B}import{Chain as T,EVMChains as w}from"@swapkit/types";function j($,f){if("index"in f)return[...$.slice(0,$.length-1),f.index];if("change"in f){let[g,R,B,,x]=$;return[g,R,B,f.change,x]}if("account"in f){let[g,R,,B,x]=$;return[g,R,f.account,B,x]}return $}function c([$,f,g,R,B],{allHardened:x}={}){let Y=x?"'":"",G=typeof B!=="number";if(typeof R!=="number")return`m/${$}'/${f}'/${g}'`;return`m/${$}'/${f}'/${g}'/${R}${Y}${G?"":`/${B}${Y}`}`}function P$({chain:$,index:f,addressIndex:g=0,type:R}){if(w.includes($)){if(R&&["legacy","account"].includes(R))return[44,60,0,f];if(R==="ledgerLive")return[44,60,f,0,g];return j(X[$],{index:f})}if($===T.Solana){if(R==="account")return[44,501,0,f];return j(X[$],{index:f})}let B=$===T.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,B,f,0,g];case"segwit":return[49,B,0,0,f];case"legacy":return[44,B,0,0,f];default:return j(X[$],{index:f})}}function Q$($){let[f,g,R]=$.split("/").map((B)=>Number.parseInt(B,10));switch(g){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var X$=Object.keys(X).reduce(($,f)=>{return $[f]=c(X[f]),$},{});import{Chain as J,CosmosChains as r,EVMChains as h,getChainConfig as S,SubstrateChains as o,UTXOChains as u}from"@swapkit/types";import{match as q}from"ts-pattern";function C$({chain:$,txHash:f}){let{explorerUrl:g}=S($);return q($).with(...r,J.Solana,()=>`${g}/tx/${f.startsWith("0x")?f.slice(2):f}`).with(...h,...o,()=>`${g}/tx/${f.startsWith("0x")?f:`0x${f}`}`).with(...u,J.Radix,J.Tron,()=>`${g}/transaction/${f.toLowerCase()}`).with(J.Near,()=>`${g}/txns/${f}`).with(J.Ripple,()=>`${g}/transactions/${f}`).with(J.Sui,()=>`${g}/txblock/${f}`).with(J.Cardano,J.HyperCore,J.Ton,()=>`${g}/tx/${f}`).otherwise(()=>"")}function W$({chain:$,address:f}){let{explorerUrl:g}=S($);return q($).with(J.Solana,J.Sui,J.Radix,()=>`${g}/account/${f}`).otherwise(()=>`${g}/address/${f}`)}import{Chain as s,getChainConfig as d}from"@swapkit/types";function l({liquidityUnits:$,poolUnits:f,runeDepth:g}){let R=z($),B=z(f),x=z(g),Y=R.mul(x),G=B.mul(B).mul(2),M=B.mul(R).mul(2),L=R.mul(R),Q=B.mul(B).mul(B);return Y.mul(G.sub(M).add(L)).div(Q)}function n({liquidityUnits:$,poolUnits:f,assetDepth:g}){let R=z($),B=z(f),x=z(g),Y=R.mul(x),G=B.mul(B).mul(2),M=B.mul(R).mul(2),L=R.mul(R),Q=Y.mul(G.sub(M).add(L)),Z=B.mul(B).mul(B);return Q.div(Z)}function E$({percent:$,runeDepth:f,liquidityUnits:g,poolUnits:R}){return l({liquidityUnits:g,poolUnits:R,runeDepth:f}).mul($)}function I$({percent:$,assetDepth:f,liquidityUnits:g,poolUnits:R}){return n({assetDepth:f,liquidityUnits:g,poolUnits:R}).mul($)}function z($){return P.fromBigInt(BigInt($),d(s.THORChain).baseDecimal)}function p({liquidityUnits:$,poolUnits:f,runeDepth:g,assetDepth:R}){return{assetAmount:z(R).mul($).div(f),runeAmount:z(g).mul($).div(f)}}function T$({liquidityUnits:$,poolUnits:f,runeDepth:g,assetDepth:R,percent:B}){return Object.fromEntries(Object.entries(p({assetDepth:R,liquidityUnits:$,poolUnits:f,runeDepth:g})).map(([x,Y])=>[x,Y.mul(B)]))}function S$({runeDepth:$,poolUnits:f,assetDepth:g,liquidityUnits:R,runeAmount:B,assetAmount:x}){let Y=new P({decimal:8,value:$}),G=new P({decimal:8,value:g}),M=new P({decimal:8,value:f}),L=new P({decimal:8,value:B}),Q=new P({decimal:8,value:x}),Z=L.mul(G),F=Q.mul(Y),O=L.mul(Q),U=Y.mul(G),D=M.mul(Z.add(F.add(O.mul(2)))),y=Z.add(F.add(U.mul(2))),H=D.div(y),W=z(R).add(H);if(H.getBaseValue("number")===0)return W.div(M).getBaseValue("number");let k=M.add(W);return W.div(k).getBaseValue("number")}function q$({runeAmount:$,assetAmount:f,runeDepth:g,assetDepth:R}){if($==="0"||f==="0"||g==="0"||R==="0")return 0;let B=z(g),x=z(R),Y=z(f),G=z($),M=Y.mul(B).sub(x.mul(G)),L=x.mul(G).add(B.mul(x));return Math.abs(M.div(L).getBaseValue("number"))}import{Chain as V}from"@swapkit/types";import{match as t}from"ts-pattern";function U$({type:$,address:f}){return`${$}:${f}`}function D$({address:$,unbondAmount:f}){return`${"UNBOND"}:${$}:${f}`}function y$($){return C("POOL+",$)}function k$({chain:$,symbol:f,address:g,...R}){let B=a({chain:$,symbol:f}),x=g?`:${g}:`:":";return C(`${"+"}:${B}${x}`,R)}function b$({chain:$,symbol:f,ticker:g,basisPoints:R,targetAsset:B}){let x=$==="ETH"&&g!=="ETH"?`${g}-${f.slice(-3)}`:f,Y=B?`:${B}`:"";return`${"-"}:${$}.${x}:${R}${Y}`}function m$({basisPoints:$,...f}){return C(`${"POOL-"}:${$}`,f)}function v$({name:$,chain:f,address:g,owner:R}){let B=`${"~"}:${$}:${f}:${g}`,x=R?`:${R}`:"";return`${B}${x}`}function w$({name:$,chain:f,asset:g,payout:R,owner:B}){return`${"~"}:${$}:${f}:${R}:${B}:${g}`}function c$($,{address:f}){return`${$}:${f}`}function r$($,{unstakeBps:f,...g}){let R=f?`:${f}`:"",B=`${$}${R}`;return C(`${B}`,g)}function C($,{affiliateAddress:f,affiliateBasisPoints:g}={}){let R=`${$}${f?`:${f}:${g||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function a({chain:$,symbol:f}){return t($).with(V.Bitcoin,V.Dogecoin,V.Litecoin,()=>$.slice(0,1).toLowerCase()).with(V.BitcoinCash,()=>"c").otherwise(()=>`${$}.${f}`)}import{getChainConfig as K}from"@swapkit/types";function l$(){return typeof window.ethereum<"u"}function n$($){return $$().includes($)}function $$(){let $=window?.ethereum&&!window.ethereum?.isBraveWallet,f=window?.ctrl||window?.ethereum?.__XDEFI,g=window?.vultisig,R=window?.ethereum?.isBraveWallet,B=window?.ethereum?.isTrust||window?.trustwallet,x=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,Y=window?.bitkeep?.ethereum,G=window?.$onekey?.ethereum,M=[];if($)M.push("METAMASK");if(f)M.push("CTRL");if(g)M.push("VULTISIG");if(R)M.push("BRAVE");if(B)M.push("TRUSTWALLET_WEB");if(x)M.push("COINBASE_WEB");if(B$())M.push("OKX_MOBILE");if(Y)M.push("BITGET");if(G)M.push("ONEKEY");return M}async function f$($,f,g){let R=K(f);try{await A({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:$})}catch(B){if(!g)throw new _("helpers_failed_to_switch_network",{error:B,reason:"networkParams not provided"});await R$($,g)}}function p$({chains:$,supportedChains:f,walletType:g}){let R=$.filter((x)=>!x||f.includes(x));if(R.length===0)throw new _("wallet_chain_not_supported",{chain:$.join(", "),wallet:g});let B=$.filter((x)=>!f.includes(x));return N({condition:B.length>0,id:`wallet_chain_not_supported_${g}`,warning:`${g} wallet does not support the following chains: ${B.join(", ")}. These chains will be ignored.`}),R}function g$($,f,g){return async(...R)=>{let{chainIdHex:B}=K(g);if((await f.getNetwork()).chainId.toString()===B)return $(...R);try{await f$(f,g)}catch(x){throw new _({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return $(...R)}}function i$({toolbox:$,chain:f,provider:g=window.ethereum,methodNames:R=[]}){let x=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((Y,G)=>{if(!$[G])return Y;let M=$[G];if(typeof M!=="function")return Y;let L=g$(M,g,f);return{...Y,[G]:L}},{});return{...$,...x}}function R$($,f){return A({method:"wallet_addEthereumChain",params:[f],provider:$})}function t$($){window.ethereum?.on("accountsChanged",()=>$()),window.ctrl?.ethereum.on("accountsChanged",()=>$())}function a$(){let{isTrust:$,isBraveWallet:f,__XDEFI:g,overrideIsMetaMask:R,selectedProvider:B}=window?.ethereum||{};if($)return"TRUSTWALLET_WEB";if(f)return"BRAVE";if(R&&B?.isCoinbaseWallet)return"COINBASE_WEB";if(g)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function e$(){let $=[];function f(R){if($.map((B)=>B.info.uuid).includes(R.detail.info.uuid))return;$.push(R.detail)}window.addEventListener("eip6963:announceProvider",f),window.dispatchEvent(new Event("eip6963:requestProvider"));function g(){window.removeEventListener("eip6963:announceProvider",f)}return{providers:$,removeEIP6963EventListener:g}}function B$(){let $=navigator.userAgent,f=/iphone|ipad|ipod|ios/i.test($),g=/android|XiaoMi|MiuiBrowser/i.test($),R=f||g,B=/OKApp/i.test($);return R&&B}function A({provider:$,params:f,method:g}){if(!$?.send)throw new _("helpers_not_found_provider");let R=f?Array.isArray(f)?f:[f]:[];return $.send(g,R)}export{Df as wrapWithThrow,g$ as wrapMethodWithNetworkSwitch,N as warnOnce,pf as validateTNS,nf as validateIdentifier,j as updateDerivationPath,f$ as switchEVMWalletNetwork,Kf as swapKitConfigStore,fg as signWidgetRequest,A as providerRequest,i$ as prepareNetworkSwitch,sf as parseSymbolForAddress,B$ as okxMobileEnabled,$$ as listWeb3EVMWallets,l$ as isWeb3Detected,rf as isGasAsset,n$ as isDetected,vf as initializeRPCUrlsWithFallback,Q$ as getWalletFormatFor,df as getTokenLogoURI,Of as getTHORNameCost,T$ as getSymmetricWithdraw,p as getSymmetricPoolShare,bf as getRPCUrlSync,mf as getRPCUrl,$g as getMinAmountByChain,b$ as getMemoForWithdraw,D$ as getMemoForUnbond,r$ as getMemoForTcyStake,c$ as getMemoForTcyClaim,m$ as getMemoForRunePoolWithdraw,y$ as getMemoForRunePoolDeposit,v$ as getMemoForNameRegister,w$ as getMemoForNamePreferredAssetRegister,U$ as getMemoForLeaveAndBond,k$ as getMemoForDeposit,Uf as getMAYANameCost,q$ as getLiquiditySlippage,v as getFeeMultiplierAsBigInt,I as getFeeMultiplier,C$ as getExplorerTxUrl,W$ as getExplorerAddressUrl,S$ as getEstimatedPoolShare,a$ as getETHDefaultWallet,e$ as getEIP6963Wallets,P$ as getDerivationPathFor,hf as getCommonAssetInfo,yf as getChainIdentifier,E$ as getAsymmetricRuneWithdrawAmount,l as getAsymmetricRuneShare,I$ as getAsymmetricAssetWithdrawAmount,n as getAsymmetricAssetShare,of as getAssetType,tf as formatBigIntToSafeValue,lf as findAssetBy,p$ as filterSupportedChains,cf as fetchTokenInfo,c as derivationPathToString,uf as assetFromString,Y$ as applyFeeMultiplierToBigInt,G$ as applyFeeMultiplier,R$ as addEVMWalletNetwork,t$ as addAccountsChangedCallback,kf as _rpcCache,If as WarningCodeEnum,e as WalletOption,Bg as TxnType,Mg as TxnStatus,Ag as TronTransactionSchema,Tg as TransactionSchema,Sg as TransactionDTOSchema,Yg as TrackingStatus,zg as TrackingRequestSchema,Jg as TrackingRequestQuerySchema,Ig as TrackerResponseSchema,Gg as TokenSchema,Xg as TokenDetailsMetadataSchema,kg as TONTransactionSchema,eg as SwapToResponseSchema,tg as SwapToRequestSchema,ag as SwapToAssetSchema,RR as SwapRouteV2ResponseSchema,P as SwapKitNumber,_ as SwapKitError,BR as SwapKitApi,yg as StarknetTransactionSchema,E as SKConfig,hg as RouteQuoteWarningSchema,Rg as RouteQuoteTxType,fR as RouteQuoteProviderErrorSchema,rg as RouteQuoteMetadataV2Schema,cg as RouteQuoteMetadataSchema,vg as RouteQuoteMetadataAssetSchema,mg as RouteLegWithoutAddressesSchema,bg as RouteLegSchema,Af as RequestClient,ig as QuoteV3ResponseSchema,gR as QuoteV2ResponseSchema,$R as QuoteRouteV2Response,ug as QuoteResponseSchema,og as QuoteResponseRouteItem,_g as QuoteRequestSchema,Tf as ProviderName,xg as ProviderAction,gg as PriorityLabel,Zg as PriceResponseSchema,Vg as PriceRequestSchema,X as NetworkDerivationPath,Eg as NearSwapResponseSchema,Hg as NearDepositChannelResultSchema,Fg as NearDepositChannelParamsSchema,i as MemoType,Nf as LedgerErrorCode,sg as GasSchema,dg as GasResponseSchema,qg as FeesSchema,Sf as FeeTypeEnum,b as FeeOption,Ng as EstimatedTimeSchema,Ef as ErrorCode,Kg as EVMTransactionSchema,Ug as EVMTransactionDetailsSchema,Og as EVMTransactionDetailsParamsSchema,X$ as DerivationPath,jg as DepositChannelResponseSchema,Cg as DepositChannelParamsSchema,m as DEFAULT_FEE_MULTIPLIERS,Dg as CosmosTransactionSchema,wf as CommonAssetStrings,Qg as CoinGeckoMetadataSchema,wg as ChainflipMetadataSchema,Wg as BrokerDepositChannelParamsSchema,af as BigIntArithmetics,Pg as AssetValueSchema,ef as AssetValue,ng as ApproveResponseSchema,lg as ApproveRequestParams,qf as ApproveMode,pg as ApprovalTransactionSchema,Lg as ApiV2ErrorSchema};
|