@swapkit/helpers 4.13.7 → 4.13.9
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-ha7zbwbt.js +5 -0
- package/dist/chunk-v93qssyv.js +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/api/index.d.ts +2 -3
- package/dist/types/api/midgard/endpoints.d.ts +0 -1
- package/dist/types/api/midgard/types.d.ts +0 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts +2 -3
- package/dist/types/api/swapkitApi/types.d.ts +1 -2
- package/dist/types/api/thornode/endpoints.d.ts +0 -1
- package/dist/types/api/thornode/types.d.ts +0 -1
- package/dist/types/contracts.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/modules/assetValue.d.ts +0 -1
- package/dist/types/modules/bigIntArithmetics.d.ts +0 -1
- package/dist/types/modules/feeMultiplier.d.ts +0 -1
- package/dist/types/modules/requestClient.d.ts +0 -1
- package/dist/types/modules/swapKitConfig.d.ts +3 -1
- package/dist/types/modules/swapKitError.d.ts +6 -3
- package/dist/types/modules/swapKitNumber.d.ts +0 -1
- package/dist/types/modules/widgetAuth.d.ts +0 -1
- package/dist/types/tokens.d.ts +0 -1
- package/dist/types/types/commonTypes.d.ts +0 -1
- package/dist/types/types/derivationPath.d.ts +0 -1
- package/dist/types/types/errors/apiV1.d.ts +0 -1
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/types/quotes.d.ts +2 -2
- package/dist/types/types/sdk.d.ts +0 -1
- package/dist/types/types/wallet.d.ts +18 -9
- package/dist/types/utils/asset.d.ts +0 -1
- package/dist/types/utils/chains.d.ts +0 -1
- package/dist/types/utils/derivationPath.d.ts +0 -1
- package/dist/types/utils/explorerUrls.d.ts +0 -1
- package/dist/types/utils/liquidity.d.ts +0 -1
- package/dist/types/utils/memo.d.ts +0 -1
- package/dist/types/utils/others.d.ts +0 -1
- package/dist/types/utils/validators.d.ts +0 -1
- package/dist/types/utils/wallets.d.ts +7 -9
- package/package.json +10 -12
- package/dist/chunk-48as5x5v.js +0 -5
- package/dist/chunk-5xeeprhe.js +0 -4
- package/dist/types/api/index.d.ts.map +0 -1
- package/dist/types/api/midgard/endpoints.d.ts.map +0 -1
- package/dist/types/api/midgard/types.d.ts.map +0 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts.map +0 -1
- package/dist/types/api/swapkitApi/types.d.ts.map +0 -1
- package/dist/types/api/thornode/endpoints.d.ts.map +0 -1
- package/dist/types/api/thornode/types.d.ts.map +0 -1
- package/dist/types/contracts.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/modules/assetValue.d.ts.map +0 -1
- package/dist/types/modules/bigIntArithmetics.d.ts.map +0 -1
- package/dist/types/modules/feeMultiplier.d.ts.map +0 -1
- package/dist/types/modules/requestClient.d.ts.map +0 -1
- package/dist/types/modules/swapKitConfig.d.ts.map +0 -1
- package/dist/types/modules/swapKitError.d.ts.map +0 -1
- package/dist/types/modules/swapKitNumber.d.ts.map +0 -1
- package/dist/types/modules/widgetAuth.d.ts.map +0 -1
- package/dist/types/tokens.d.ts.map +0 -1
- package/dist/types/types/commonTypes.d.ts.map +0 -1
- package/dist/types/types/derivationPath.d.ts.map +0 -1
- package/dist/types/types/errors/apiV1.d.ts.map +0 -1
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/types/quotes.d.ts.map +0 -1
- package/dist/types/types/sdk.d.ts.map +0 -1
- package/dist/types/types/wallet.d.ts.map +0 -1
- package/dist/types/utils/asset.d.ts.map +0 -1
- package/dist/types/utils/chains.d.ts.map +0 -1
- package/dist/types/utils/derivationPath.d.ts.map +0 -1
- package/dist/types/utils/explorerUrls.d.ts.map +0 -1
- package/dist/types/utils/liquidity.d.ts.map +0 -1
- package/dist/types/utils/memo.d.ts.map +0 -1
- package/dist/types/utils/others.d.ts.map +0 -1
- package/dist/types/utils/validators.d.ts.map +0 -1
- package/dist/types/utils/wallets.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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-48as5x5v.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};
|
|
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-ha7zbwbt.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,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};
|
|
@@ -327,7 +327,7 @@ export declare const SwapKitApi: {
|
|
|
327
327
|
provider?: string | undefined;
|
|
328
328
|
timestamp?: number | undefined;
|
|
329
329
|
}[]>;
|
|
330
|
-
getGasRate(): Promise<(import("zod
|
|
330
|
+
getGasRate(): Promise<(import("zod").ZodSafeParseSuccess<{
|
|
331
331
|
chainId: import("@swapkit/types").ChainId;
|
|
332
332
|
createdAt: Date;
|
|
333
333
|
id: number;
|
|
@@ -339,7 +339,7 @@ export declare const SwapKitApi: {
|
|
|
339
339
|
id: number;
|
|
340
340
|
unit: string;
|
|
341
341
|
value: string;
|
|
342
|
-
}[]> & any[]) | import("zod
|
|
342
|
+
}[]> & any[]) | import("zod").ZodSafeParseSuccess<{
|
|
343
343
|
chainId: import("@swapkit/types").ChainId;
|
|
344
344
|
createdAt: Date;
|
|
345
345
|
id: number;
|
|
@@ -418,4 +418,3 @@ export declare const SwapKitApi: {
|
|
|
418
418
|
}) => Promise<T>;
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -301,7 +301,7 @@ export declare function getPrice(body: PriceRequest): Promise<{
|
|
|
301
301
|
provider?: string | undefined;
|
|
302
302
|
timestamp?: number | undefined;
|
|
303
303
|
}[]>;
|
|
304
|
-
export declare function getGasRate(): Promise<(import("zod
|
|
304
|
+
export declare function getGasRate(): Promise<(import("zod").ZodSafeParseSuccess<{
|
|
305
305
|
chainId: import("@swapkit/types").ChainId;
|
|
306
306
|
createdAt: Date;
|
|
307
307
|
id: number;
|
|
@@ -313,7 +313,7 @@ export declare function getGasRate(): Promise<(import("zod/v4").ZodSafeParseSucc
|
|
|
313
313
|
id: number;
|
|
314
314
|
unit: string;
|
|
315
315
|
value: string;
|
|
316
|
-
}[]> & any[]) | import("zod
|
|
316
|
+
}[]> & any[]) | import("zod").ZodSafeParseSuccess<{
|
|
317
317
|
chainId: import("@swapkit/types").ChainId;
|
|
318
318
|
createdAt: Date;
|
|
319
319
|
id: number;
|
|
@@ -341,4 +341,3 @@ export declare function getNearDepositChannel(body: NearDepositChannelParams): P
|
|
|
341
341
|
deadline?: string | undefined;
|
|
342
342
|
}>;
|
|
343
343
|
export declare function getSwapTo(params: SwapToRequest): Promise<SwapToResponse>;
|
|
344
|
-
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chain, ChainId } from "@swapkit/types";
|
|
2
|
-
import { coerce, type ZodType, z } from "zod
|
|
2
|
+
import { coerce, type ZodType, z } from "zod";
|
|
3
3
|
import { ErrorCode, FeeTypeEnum, ProviderName, WarningCodeEnum } from "../../types/quotes";
|
|
4
4
|
export declare enum PriorityLabel {
|
|
5
5
|
CHEAPEST = "CHEAPEST",
|
|
@@ -2472,4 +2472,3 @@ export declare const SwapRouteV2ResponseSchema: z.ZodObject<{
|
|
|
2472
2472
|
}, z.core.$strip>;
|
|
2473
2473
|
export type SwapRouteV2Response = z.infer<typeof SwapRouteV2ResponseSchema>;
|
|
2474
2474
|
export {};
|
|
2475
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -42,4 +42,3 @@ export declare function applyFeeMultiplierToBigInt(value: bigint, feeOption?: Fe
|
|
|
42
42
|
*/
|
|
43
43
|
export declare function applyFeeMultiplier(value: number, feeOption?: FeeOption, floor?: boolean): number;
|
|
44
44
|
export { DEFAULT_FEE_MULTIPLIERS };
|
|
45
|
-
//# sourceMappingURL=feeMultiplier.d.ts.map
|
|
@@ -30,6 +30,9 @@ export type SKConfigIntegrations = {
|
|
|
30
30
|
nearWalletSelector?: {
|
|
31
31
|
contractId?: string;
|
|
32
32
|
};
|
|
33
|
+
passkey?: {
|
|
34
|
+
rpName?: string;
|
|
35
|
+
};
|
|
33
36
|
trezor?: {
|
|
34
37
|
email: string;
|
|
35
38
|
appUrl: string;
|
|
@@ -199,4 +202,3 @@ export declare const SKConfig: {
|
|
|
199
202
|
setWidgetKey: (key: string) => void;
|
|
200
203
|
};
|
|
201
204
|
export {};
|
|
202
|
-
//# sourceMappingURL=swapKitConfig.d.ts.map
|
|
@@ -214,8 +214,10 @@ declare const errorCodes: {
|
|
|
214
214
|
readonly wallet_cosmostation_no_evm_address: 21507;
|
|
215
215
|
readonly wallet_cosmostation_signer_not_found: 21508;
|
|
216
216
|
/**
|
|
217
|
-
* Wallets -
|
|
217
|
+
* Wallets - SwapKit Passkey Wallet
|
|
218
218
|
*/
|
|
219
|
+
readonly wallet_passkey_not_supported: 21601;
|
|
220
|
+
readonly wallet_passkey_connection_failed: 21602;
|
|
219
221
|
/**
|
|
220
222
|
* Wallets - Coinbase
|
|
221
223
|
*/
|
|
@@ -725,8 +727,10 @@ export declare class SwapKitError extends Error {
|
|
|
725
727
|
readonly wallet_cosmostation_no_evm_address: 21507;
|
|
726
728
|
readonly wallet_cosmostation_signer_not_found: 21508;
|
|
727
729
|
/**
|
|
728
|
-
* Wallets -
|
|
730
|
+
* Wallets - SwapKit Passkey Wallet
|
|
729
731
|
*/
|
|
732
|
+
readonly wallet_passkey_not_supported: 21601;
|
|
733
|
+
readonly wallet_passkey_connection_failed: 21602;
|
|
730
734
|
/**
|
|
731
735
|
* Wallets - Coinbase
|
|
732
736
|
*/
|
|
@@ -1027,4 +1031,3 @@ export declare class SwapKitError extends Error {
|
|
|
1027
1031
|
}, sourceErrorOrInfo?: any);
|
|
1028
1032
|
}
|
|
1029
1033
|
export {};
|
|
1030
|
-
//# sourceMappingURL=swapKitError.d.ts.map
|
package/dist/types/tokens.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type Chain, getChainConfig } from "@swapkit/types";
|
|
2
2
|
export type DerivationPathArray = ReturnType<typeof getChainConfig>["networkDerivationPath"];
|
|
3
3
|
export declare const NetworkDerivationPath: Record<Chain, [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 637, 0, 0, 0] | [44, 60, 0, 0, 0] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 148, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [44, 9004, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0]>;
|
|
4
|
-
//# sourceMappingURL=derivationPath.d.ts.map
|
|
@@ -154,7 +154,8 @@ export declare enum ProviderName {
|
|
|
154
154
|
GARDEN = "GARDEN",
|
|
155
155
|
OKX = "OKX",
|
|
156
156
|
HARBOR = "HARBOR",
|
|
157
|
-
FLASHNET = "FLASHNET"
|
|
157
|
+
FLASHNET = "FLASHNET",
|
|
158
|
+
MAYAN = "MAYAN"
|
|
158
159
|
}
|
|
159
160
|
export declare enum FeeTypeEnum {
|
|
160
161
|
LIQUIDITY = "liquidity",
|
|
@@ -166,4 +167,3 @@ export declare enum FeeTypeEnum {
|
|
|
166
167
|
PRIORITY = "priority",
|
|
167
168
|
SERVICE = "service"
|
|
168
169
|
}
|
|
169
|
-
//# sourceMappingURL=quotes.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Chain, getChainConfig } from "@swapkit/types";
|
|
2
|
-
import type { BrowserProvider, Eip1193Provider, TypedDataField } from "ethers";
|
|
3
2
|
import type { AssetValue } from "../modules/assetValue";
|
|
4
3
|
import type { FeeOption } from "./sdk";
|
|
5
4
|
declare global {
|
|
@@ -7,7 +6,19 @@ declare global {
|
|
|
7
6
|
"eip6963:announceProvider": CustomEvent;
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
export
|
|
9
|
+
export interface Eip1193Provider {
|
|
10
|
+
request<T = unknown>(args: {
|
|
11
|
+
method: string;
|
|
12
|
+
params?: unknown[] | Record<string, unknown>;
|
|
13
|
+
}): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface EvmRpcProvider {
|
|
16
|
+
send<T = unknown>(method: string, params: unknown[]): Promise<T>;
|
|
17
|
+
getNetwork(): Promise<{
|
|
18
|
+
chainId: bigint | number;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export type EthereumWindowProvider = Eip1193Provider & {
|
|
11
22
|
__XDEFI?: boolean;
|
|
12
23
|
isBraveWallet?: boolean;
|
|
13
24
|
isCoinbaseWallet?: boolean;
|
|
@@ -18,10 +29,6 @@ export type EthereumWindowProvider = BrowserProvider & {
|
|
|
18
29
|
isTalisman?: boolean;
|
|
19
30
|
on: (event: string, callback?: () => void) => void;
|
|
20
31
|
overrideIsMetaMask?: boolean;
|
|
21
|
-
request: <T = unknown>(args: {
|
|
22
|
-
method: string;
|
|
23
|
-
params?: unknown[];
|
|
24
|
-
}) => Promise<T>;
|
|
25
32
|
selectedProvider?: EthereumWindowProvider;
|
|
26
33
|
};
|
|
27
34
|
export type NetworkParams = {
|
|
@@ -58,6 +65,7 @@ export declare enum WalletOption {
|
|
|
58
65
|
OKX_MOBILE = "OKX_MOBILE",
|
|
59
66
|
ONEKEY = "ONEKEY",
|
|
60
67
|
PASSKEYS = "PASSKEYS",
|
|
68
|
+
PASSKEY_WALLET = "PASSKEY_WALLET",
|
|
61
69
|
PETRA = "PETRA",
|
|
62
70
|
PHANTOM = "PHANTOM",
|
|
63
71
|
POLKADOT_JS = "POLKADOT_JS",
|
|
@@ -90,7 +98,10 @@ export type ChainWallet<T extends Chain> = {
|
|
|
90
98
|
signMessage?: (message: string) => Promise<string>;
|
|
91
99
|
signTypedData?: (params: {
|
|
92
100
|
domain: Record<string, unknown>;
|
|
93
|
-
types: Record<string,
|
|
101
|
+
types: Record<string, {
|
|
102
|
+
name: string;
|
|
103
|
+
type: string;
|
|
104
|
+
}[]>;
|
|
94
105
|
value: Record<string, unknown>;
|
|
95
106
|
primaryType?: string;
|
|
96
107
|
}) => Promise<string>;
|
|
@@ -118,7 +129,6 @@ export type EIP6963Provider = {
|
|
|
118
129
|
export type EIP6963AnnounceProviderEvent = Event & {
|
|
119
130
|
detail: EIP6963Provider;
|
|
120
131
|
};
|
|
121
|
-
export type { Eip1193Provider };
|
|
122
132
|
export type ChainSigner<T, S> = {
|
|
123
133
|
signTransaction: (params: T) => Promise<S> | S;
|
|
124
134
|
getAddress: () => Promise<string> | string;
|
|
@@ -135,4 +145,3 @@ export type GenericCreateTransactionParams = Omit<GenericTransferParams, "feeOpt
|
|
|
135
145
|
sender: string;
|
|
136
146
|
feeRate: number;
|
|
137
147
|
};
|
|
138
|
-
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -12,4 +12,3 @@ export declare function getRPCUrl(chain: Chain | StagenetChain): Promise<string>
|
|
|
12
12
|
* This function is obsolete and will be removed in a future release.
|
|
13
13
|
*/
|
|
14
14
|
export declare function initializeRPCUrlsWithFallback(_chains: never): void;
|
|
15
|
-
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -20,4 +20,3 @@ export declare function getDerivationPathFor({ chain, index, addressIndex, type
|
|
|
20
20
|
export declare function getWalletFormatFor(path: string): "legacy" | "p2sh" | "bech32";
|
|
21
21
|
export declare const DerivationPath: Record<Chain, string>;
|
|
22
22
|
export {};
|
|
23
|
-
//# sourceMappingURL=derivationPath.d.ts.map
|
|
@@ -56,4 +56,3 @@ export declare function getEstimatedPoolShare({ runeDepth, poolUnits, assetDepth
|
|
|
56
56
|
}>): number;
|
|
57
57
|
export declare function getLiquiditySlippage({ runeAmount, assetAmount, runeDepth, assetDepth }: PoolParams): number;
|
|
58
58
|
export {};
|
|
59
|
-
//# sourceMappingURL=liquidity.d.ts.map
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { type Chain } from "@swapkit/types";
|
|
2
|
-
import type
|
|
3
|
-
import { type EIP6963Provider, type NetworkParams, WalletOption } from "../types";
|
|
2
|
+
import { type EIP6963Provider, type EvmRpcProvider, type NetworkParams, WalletOption } from "../types";
|
|
4
3
|
export declare function isWeb3Detected(): boolean;
|
|
5
4
|
export declare function isDetected(walletOption: WalletOption): boolean;
|
|
6
5
|
export declare function listWeb3EVMWallets(): WalletOption[];
|
|
7
|
-
export declare function switchEVMWalletNetwork(provider:
|
|
6
|
+
export declare function switchEVMWalletNetwork(provider: EvmRpcProvider, chain: Chain, networkParams?: NetworkParams): Promise<void>;
|
|
8
7
|
export declare function filterSupportedChains<T extends string[]>({ chains, supportedChains, walletType, }: {
|
|
9
8
|
chains: Chain[];
|
|
10
9
|
supportedChains: T;
|
|
11
10
|
walletType?: WalletOption;
|
|
12
11
|
}): T;
|
|
13
|
-
export declare function wrapMethodWithNetworkSwitch<T extends (...args: any[]) => any>(func: T, provider:
|
|
12
|
+
export declare function wrapMethodWithNetworkSwitch<T extends (...args: any[]) => any>(func: T, provider: EvmRpcProvider, chain: Chain): T;
|
|
14
13
|
export declare function prepareNetworkSwitch<T extends Record<string, unknown>, M extends keyof T>({ toolbox, chain, provider, methodNames, }: {
|
|
15
14
|
toolbox: T;
|
|
16
15
|
chain: Chain;
|
|
17
|
-
provider
|
|
16
|
+
provider: EvmRpcProvider;
|
|
18
17
|
methodNames?: M[];
|
|
19
18
|
}): T & {};
|
|
20
|
-
export declare function addEVMWalletNetwork(provider:
|
|
19
|
+
export declare function addEVMWalletNetwork(provider: EvmRpcProvider, networkParams: NetworkParams): Promise<unknown>;
|
|
21
20
|
export declare function addAccountsChangedCallback(callback: () => void): void;
|
|
22
21
|
export declare function getETHDefaultWallet(): WalletOption.BRAVE | WalletOption.COINBASE_WEB | WalletOption.CTRL | WalletOption.METAMASK | WalletOption.ONEKEY | WalletOption.TRUSTWALLET_WEB;
|
|
23
22
|
export declare function getEIP6963Wallets(): {
|
|
@@ -26,8 +25,7 @@ export declare function getEIP6963Wallets(): {
|
|
|
26
25
|
};
|
|
27
26
|
export declare function okxMobileEnabled(): boolean;
|
|
28
27
|
export declare function providerRequest({ provider, params, method, }: {
|
|
29
|
-
provider?:
|
|
28
|
+
provider?: EvmRpcProvider;
|
|
30
29
|
params?: any;
|
|
31
30
|
method: "wallet_addEthereumChain" | "wallet_switchEthereumChain" | "eth_requestAccounts" | "eth_sendTransaction" | "eth_signTransaction";
|
|
32
|
-
}): Promise<
|
|
33
|
-
//# sourceMappingURL=wallets.d.ts.map
|
|
31
|
+
}): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "swapkit-dev",
|
|
3
|
-
"dependencies": {
|
|
4
|
-
"@near-js/providers": "~2.5.0",
|
|
5
|
-
"@swapkit/contracts": "4.1.3",
|
|
6
|
-
"@swapkit/tokens": "4.2.7",
|
|
7
|
-
"@swapkit/types": "0.7.4",
|
|
8
|
-
"ethers": "^6.14.0",
|
|
9
|
-
"ts-pattern": "^5.9.0",
|
|
10
|
-
"zod": "3.25.74",
|
|
11
|
-
"zustand": "5.0.8"
|
|
12
|
-
},
|
|
3
|
+
"dependencies": { "@swapkit/contracts": "4.1.4", "@swapkit/tokens": "4.2.8", "@swapkit/types": "0.7.4" },
|
|
13
4
|
"description": "SwapKit - Helpers",
|
|
14
|
-
"devDependencies": { "@near-js/providers": "2.5.
|
|
5
|
+
"devDependencies": { "@near-js/providers": "2.5.1", "@swapkit/toolboxes": "4.15.13", "ethers": "6.16.0" },
|
|
15
6
|
"exports": {
|
|
16
7
|
".": { "default": "./dist/index.js", "require": "./dist/index.cjs", "types": "./dist/types/index.d.ts" },
|
|
17
8
|
"./api": {
|
|
@@ -30,6 +21,13 @@
|
|
|
30
21
|
"homepage": "https://github.com/swapkit/SwapKit",
|
|
31
22
|
"license": "SEE LICENSE IN LICENSE",
|
|
32
23
|
"name": "@swapkit/helpers",
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@near-js/providers": "2.5.1",
|
|
26
|
+
"ethers": "6.16.0",
|
|
27
|
+
"ts-pattern": "5.9.0",
|
|
28
|
+
"zod": "4.4.3",
|
|
29
|
+
"zustand": "5.0.13"
|
|
30
|
+
},
|
|
33
31
|
"publishConfig": { "access": "public" },
|
|
34
32
|
"repository": { "directory": "packages/helpers", "type": "git", "url": "git+https://github.com/swapkit/SwapKit.git" },
|
|
35
33
|
"scripts": {
|
|
@@ -41,5 +39,5 @@
|
|
|
41
39
|
"type-check:go": "tsgo"
|
|
42
40
|
},
|
|
43
41
|
"type": "module",
|
|
44
|
-
"version": "4.13.
|
|
42
|
+
"version": "4.13.9"
|
|
45
43
|
}
|