@swapkit/helpers 4.20.5 → 5.0.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/CHANGELOG.md CHANGED
@@ -1,29 +1,23 @@
1
1
  # @swapkit/helpers
2
2
 
3
- ## 4.20.5
3
+ ## 5.0.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - [`ef0c115`](https://github.com/swapkit/sdk/commit/ef0c11521563e781f5dc8846c96931e7e436c22c) Thanks [@towanTG](https://github.com/towanTG)! - Drop `HYPE.*` identifiers carrying an EVM address. Hypercore assets are addressed by Hyperliquid `NAME:tokenId` — `spotSend` puts that value straight into its `token` field — so an entry like `HYPE.USDC-0xb88339CB…` describes an asset that does not exist on Hypercore (no Hyperliquid spot token backs that contract) and cannot be sent. Near Intents tags HyperEVM tokens onto its `hypercore` chain, which is where these came from. Genuine `HYPEREVM.*` tokens and flashnet's real Hypercore assets are unaffected. (via @swapkit/tokens@4.5.3)
7
+ - Update generated token lists. (via @swapkit/tokens@5.0.1)
8
+ - [#363](https://github.com/swapkit/sdk/pull/363) [`7b9f214`](https://github.com/swapkit/sdk/commit/7b9f2145e8644975620db1f2b39775c33cb40d20) Thanks [@towanTG](https://github.com/towanTG)! - Correct the Hyperliquid chain display names: `Chain.Hyperevm`'s config is now (via @swapkit/types@1.0.1)
8
9
 
9
- ## 4.20.4
10
+ ## 5.0.0
10
11
 
11
- ### Patch Changes
12
-
13
- - [#358](https://github.com/swapkit/sdk/pull/358) [`6734cab`](https://github.com/swapkit/sdk/commit/6734cab233f17b6e5372519fe43e029477117827) Thanks [@github-actions](https://github.com/apps/github-actions)! - Correct flashnet's Hypercore assets in the dev list. The api collapses flashnet's two Hyperliquid chains and emitted Hypercore USDC carrying HyperEVM USDC's contract address (`HYPE.USDC-0xb88339CB…`) — an EVM address is not a valid Hypercore asset id, so `spotSend` built from it was rejected. Hypercore entries are now generated in Hyperliquid `NAME:tokenId` form, matching what the hypercore toolbox builds at runtime: `HYPE.USDC-USDC:0x6d1e7cde…` and `HYPE.USDE-USDE:0x2e6d84f2…`, both 8 decimals (`weiDecimals`). `HYPEREVM.*` assets are untouched. (via @swapkit/tokens@4.5.2)
14
-
15
- ## 4.20.3
16
-
17
- ### Patch Changes
18
-
19
- - [`bca217f`](https://github.com/swapkit/sdk/commit/bca217f89314ac520eae2d5eeeee027f125c4262) Thanks [@towanTG](https://github.com/towanTG)! - Refresh generated token lists and restore faithful provider mirroring. The `HYPE.*` filter added in 4.5.0 is removed: `HYPE.USDC-0xb88339CB…` is the identifier the api actually routes on (it is the only HYPE-family buy asset `/swapTo` returns on prod), so dropping it removed the static entry for a routable token. Dev flashnet now carries `HYPE.USDC` alongside its `HYPEREVM.*` assets, exactly as the provider serves them. (via @swapkit/tokens@4.5.1)
20
-
21
- ## 4.20.2
22
-
23
- ### Patch Changes
12
+ ### Major Changes
24
13
 
25
- - [`f90fa82`](https://github.com/swapkit/sdk/commit/f90fa826d1e56dba934ee968ec31a94ae20399fd) Thanks [@towanTG](https://github.com/towanTG)! - Update generated token lists (prod and dev). Remove the hand-maintained hypercore token list and its `hype`/`hypercore` list names — the api serves no HYPE provider, so the documented exception from 4.4.0 is retired and static lists are again 100% provider-generated. (via @swapkit/tokens@4.5.0)
26
- - [`c3ef809`](https://github.com/swapkit/sdk/commit/c3ef80967cab859310aa7e20e6f0aeb817027bb7) Thanks [@towanTG](https://github.com/towanTG)! - Refresh generated token lists — flashnet now carries the HyperEVM assets (HYPEREVM.HYPE, USDC, USDe, USDT0). The generator drops non-native `HYPE.*` identifiers misfiled by providers: HyperEVM assets belong on `HYPEREVM.*`, and the HYPE (Hypercore) chain keeps only native HYPE. (via @swapkit/tokens@4.5.0)
14
+ - [#344](https://github.com/swapkit/sdk/pull/344) [`7f99d74`](https://github.com/swapkit/sdk/commit/7f99d74ec21d58d07b2cccc5b111f8fdae6c7afb) Thanks [@ice-chillios](https://github.com/ice-chillios)! - **ESM-only packages.** CommonJS output (`.cjs`) and `require` export conditions have been removed; every package now ships ESM only (code-splitting stays enabled), with a uniform `{ default, types }` exports shape. `buildPackage` from `@swapkit/tools-builder` no longer emits CJS and the unused `esmOnly` option has been removed.
15
+ - [#295](https://github.com/swapkit/sdk/pull/295) [`fd1d5d7`](https://github.com/swapkit/sdk/commit/fd1d5d7304eda3ff20c53b14d0eb5998fb6b8250) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Remove `ethers` and `@near-js/providers` from `@swapkit/helpers`. EVM address checksum/validation now uses an in-house EIP-55 implementation backed by `@noble/hashes`, ERC-20 symbol decoding reuses the existing dynamic-string ABI decoder, and NEAR token metadata is fetched via JSON-RPC through `RequestClient`. Public behaviour is preserved (ethers-parity semantics, including throw-on-bad-checksum).
16
+ - [#360](https://github.com/swapkit/sdk/pull/360) [`d6061d5`](https://github.com/swapkit/sdk/commit/d6061d58367cdf077acf60421a1e8b448363f486) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Add HyperCore `sendAsset` payin support.
17
+ - [#295](https://github.com/swapkit/sdk/pull/295) [`fd1d5d7`](https://github.com/swapkit/sdk/commit/fd1d5d7304eda3ff20c53b14d0eb5998fb6b8250) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Consolidate scattered helper utility modules (explorer URLs, validators, widget auth, TNS cost helpers) into grouped homes. Pure internal relocation — the public export surface is unchanged.
18
+ - [#353](https://github.com/swapkit/sdk/pull/353) [`2d00760`](https://github.com/swapkit/sdk/commit/2d0076010f56b843295fa814922b46385d3fc52b) Thanks [@towanTG](https://github.com/towanTG)! - Update generated token lists (prod and dev). Remove the hand-maintained hypercore token list and its `hype`/`hypercore` list names — the api serves no HYPE provider, so the documented exception from 4.4.0 is retired and static lists are again 100% provider-generated. (via @swapkit/tokens@5.0.0)
19
+ - Update generated token lists. (via @swapkit/tokens@5.0.0)
20
+ - [#354](https://github.com/swapkit/sdk/pull/354) [`8d21eef`](https://github.com/swapkit/sdk/commit/8d21eefe8a5379347a6a9b92978b0336e1a155a4) Thanks [@towanTG](https://github.com/towanTG)! - Refresh generated token lists (prod and dev) — dev flashnet now carries the HyperEVM assets (`HYPEREVM.HYPE`, `USDC`, `USDe`, `USDT0`) alongside `HYPE.USDC`. Lists mirror provider output verbatim; no identifiers are filtered. (via @swapkit/tokens@5.0.0)
27
21
 
28
22
  ## 4.20.1
29
23
 
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as n,Aa as O,Ba as P,Ca as Q,Da as R,Ea as S,Fa as T,Ga as U,Ha as V,Ia as W,Ja as X,Ka as Y,La as Z,Ma as _,Na as $,O as a,Oa as aa,P as b,Pa as ba,Q as c,Qa as ca,R as d,Ra as da,S as e,Sa as ea,T as f,Ta as fa,U as g,Ua as ga,V as h,Va as ha,W as i,Wa as ia,X as j,Y as k,Z as l,_ as m,aa as o,ba as p,ca as q,da as r,ea as s,fa as t,ga as u,ha as v,ia as w,ja as x,ka as y,la as z,ma as A,na as B,oa as C,pa as D,qa as E,ra as F,sa as G,ta as H,ua as I,va as J,wa as K,xa as L,ya as M,za as N}from"../chunk-8pyeeg27.js";export{D as toHexTransactionValue,C as parseTransactionValue,B as isTransactionValue,c as TxnType,e as TxnStatus,F as TronTransactionSchema,x as TransactionSchema,y as TransactionDTOSchema,f as TrackingStatus,h as TrackingRequestSchema,i as TrackingRequestQuerySchema,w as TrackerResponseSchema,g as TokenSchema,m as TokenDetailsMetadataSchema,L as TONTransactionSchema,K as TONTransactionMessageSchema,da as SwapToResponseSchema,ba as SwapToRequestSchema,ca as SwapToAssetSchema,ha as SwapRouteV2ResponseSchema,ia as SwapKitApi,$ as SwapApprovalTransactionSchema,_ as StellarApprovalTransactionSchema,J as StarknetTransactionSchema,S as RouteQuoteWarningSchema,b as RouteQuoteTxType,fa as RouteQuoteProviderErrorSchema,R as RouteQuoteMetadataV2Schema,Q as RouteQuoteMetadataSchema,O as RouteQuoteMetadataAssetSchema,N as RouteLegWithoutAddressesSchema,M as RouteLegSchema,aa as QuoteV3ResponseSchema,ga as QuoteV2ResponseSchema,ea as QuoteRouteV2Response,U as QuoteResponseSchema,T as QuoteResponseRouteItem,o as QuoteRequestSchema,d as ProviderAction,a as PriorityLabel,n as PriceResponseSchema,p as PriceRequestSchema,v as NearSwapResponseSchema,u as NearDepositChannelResultSchema,t as NearDepositChannelParamsSchema,V as GasSchema,W as GasResponseSchema,z as FeesSchema,A as EstimatedTimeSchema,E as EVMTransactionSchema,H as EVMTransactionDetailsSchema,G as EVMTransactionDetailsParamsSchema,s as DepositChannelResponseSchema,q as DepositChannelParamsSchema,I as CosmosTransactionSchema,l as CoinGeckoMetadataSchema,P as ChainflipMetadataSchema,r as BrokerDepositChannelParamsSchema,k as AssetValueSchema,Y as ApproveResponseSchema,X as ApproveRequestParams,Z as ApprovalTransactionSchema,j as ApiV2ErrorSchema};
1
+ import{$ as m,$a as ma,Aa as N,Ba as O,Ca as P,Da as Q,Ea as R,Fa as S,Ga as T,Ha as U,Ia as V,Ja as W,Ka as X,La as Y,Ma as Z,Na as _,Oa as $,P as a,Pa as aa,Q as b,Qa as ba,R as c,Ra as ca,S as d,Sa as da,T as e,Ta as ea,U as f,Ua as fa,V as g,Va as ga,W as h,Wa as ha,X as i,Xa as ia,Y as j,Ya as ja,Z as k,Za as ka,_ as l,_a as la,aa as n,ab as na,ba as o,ca as p,da as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B,pa as C,qa as D,ra as E,sa as F,ta as G,ua as H,va as I,wa as J,xa as K,ya as L,za as M}from"../chunk-g60m4sgr.js";export{D as toHexTransactionValue,C as parseTransactionValue,B as isTransactionValue,c as TxnType,e as TxnStatus,F as TronTransactionSchema,x as TransactionSchema,y as TransactionDTOSchema,f as TrackingStatus,h as TrackingRequestSchema,i as TrackingRequestQuerySchema,w as TrackerResponseSchema,g as TokenSchema,m as TokenDetailsMetadataSchema,L as TONTransactionSchema,K as TONTransactionMessageSchema,ia as SwapToResponseSchema,ga as SwapToRequestSchema,ha as SwapToAssetSchema,ma as SwapRouteV2ResponseSchema,na as SwapKitApi,ea as SwapApprovalTransactionSchema,da as StellarApprovalTransactionSchema,J as StarknetTransactionSchema,X as RouteQuoteWarningSchema,b as RouteQuoteTxType,ka as RouteQuoteProviderErrorSchema,W as RouteQuoteMetadataV2Schema,V as RouteQuoteMetadataSchema,T as RouteQuoteMetadataAssetSchema,S as RouteLegWithoutAddressesSchema,R as RouteLegSchema,fa as QuoteV3ResponseSchema,la as QuoteV2ResponseSchema,ja as QuoteRouteV2Response,Z as QuoteResponseSchema,Y as QuoteResponseRouteItem,o as QuoteRequestSchema,d as ProviderAction,a as PriorityLabel,n as PriceResponseSchema,p as PriceRequestSchema,v as NearSwapResponseSchema,u as NearDepositChannelResultSchema,t as NearDepositChannelParamsSchema,P as HyperCoreTypedDataTransactionSchema,Q as HyperCoreSendAssetTransactionSchema,O as HyperCoreSendAssetActionSchema,N as HyperCoreEip712TypedDataSchema,M as HYPERCORE_USDC_TOKEN_ID,_ as GasSchema,$ as GasResponseSchema,z as FeesSchema,A as EstimatedTimeSchema,E as EVMTransactionSchema,H as EVMTransactionDetailsSchema,G as EVMTransactionDetailsParamsSchema,s as DepositChannelResponseSchema,q as DepositChannelParamsSchema,I as CosmosTransactionSchema,l as CoinGeckoMetadataSchema,U as ChainflipMetadataSchema,r as BrokerDepositChannelParamsSchema,k as AssetValueSchema,ba as ApproveResponseSchema,aa as ApproveRequestParams,ca as ApprovalTransactionSchema,j as ApiV2ErrorSchema};
@@ -0,0 +1,5 @@
1
+ var AT=Object.defineProperty;var TT=(N)=>N;function HT(N,A){this[N]=TT.bind(null,A)}var lN=(N,A)=>{for(var T in A)AT(N,T,{get:A[T],enumerable:!0,configurable:!0,set:HT.bind(A,T)})};var rN=((N)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(N,{get:(A,T)=>(typeof require<"u"?require:A)[T]}):N)(function(N){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+N+'" is not supported')});import{Chain as wN,getChainConfig as NH}from"@swapkit/types";import{AllChains as pT,Chain as z,EVMChains as oT,getChainConfig as ON}from"@swapkit/types";import{match as kN}from"ts-pattern";import{Chain as B,EVMChains as jT,getChainConfig as p,UTXOChains as VT}from"@swapkit/types";import{match as FN}from"ts-pattern";import{AllChains as sN,Chain as iN,getChainConfig as BT,MAYAConfig as $T,StagenetChain as _N,StagenetMAYAConfig as eN,StagenetTHORConfig as aN,THORConfig as GT}from"@swapkit/types";import{createStore as YT}from"zustand/vanilla";import{AllChains as LT,getChainConfig as PT}from"@swapkit/types";var dL=LT.reduce((N,A)=>{return N[A]=PT(A).networkDerivationPath,N},{});var PN;((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.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.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"})(PN||={});var ZN;((H)=>{H.highSlippage="highSlippage";H.highPriceImpact="highPriceImpact";H.insufficientBalance="insufficientBalance"})(ZN||={});var V;((J)=>{J.CHAINFLIP="CHAINFLIP";J.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";J.JUPITER="JUPITER";J.MAYACHAIN="MAYACHAIN";J.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";J.ONEINCH="ONEINCH";J.PANCAKESWAP="PANCAKESWAP";J.SUSHISWAP_V2="SUSHISWAP_V2";J.THORCHAIN="THORCHAIN";J.THORCHAIN_STREAMING="THORCHAIN_STREAMING";J.TRADERJOE_V2="TRADERJOE_V2";J.UNISWAP_V2="UNISWAP_V2";J.UNISWAP_V3="UNISWAP_V3";J.NEAR="NEAR";J.GARDEN="GARDEN";J.OKX="OKX";J.HARBOR="HARBOR";J.FLASHNET="FLASHNET";J.MAYAN="MAYAN"})(V||={});var WN;((M)=>{M.LIQUIDITY="liquidity";M.NETWORK="network";M.INBOUND="inbound";M.OUTBOUND="outbound";M.AFFILIATE="affiliate";M.TAX="tax";M.PRIORITY="priority";M.SERVICE="service"})(WN||={});var FT;((H)=>{H.Average="average";H.Fast="fast";H.Fastest="fastest"})(FT||={});var IT;((T)=>{T.Approve="approve";T.CheckOnly="checkOnly"})(IT||={});var RT;((S)=>{S.NAME_REGISTER="~";S.BOND="BOND";S.DEPOSIT="+";S.LEAVE="LEAVE";S.UNBOND="UNBOND";S.WITHDRAW="-";S.RUNEPOOL_DEPOSIT="POOL+";S.RUNEPOOL_WITHDRAW="POOL-";S.CLAIM_TCY="tcy";S.STAKE_TCY="tcy+";S.UNSTAKE_TCY="tcy-"})(RT||={});var jN;((E)=>{E.BITGET="BITGET";E.BRAVE="BRAVE";E.COINBASE_MOBILE="COINBASE_MOBILE";E.COINBASE_WEB="COINBASE_WEB";E.COSMOSTATION="COSMOSTATION";E.CTRL="CTRL";E.EIP6963="EIP6963";E.EXODUS="EXODUS";E.KEEPKEY="KEEPKEY";E.KEEPKEY_BEX="KEEPKEY_BEX";E.KEPLR="KEPLR";E.KEYSTORE="KEYSTORE";E.LEAP="LEAP";E.LEDGER="LEDGER";E.METAMASK="METAMASK";E.OKX="OKX";E.OKX_MOBILE="OKX_MOBILE";E.ONEKEY="ONEKEY";E.PASSKEYS="PASSKEYS";E.PASSKEY_WALLET="PASSKEY_WALLET";E.PETRA="PETRA";E.PHANTOM="PHANTOM";E.POLKADOT_JS="POLKADOT_JS";E.RADIX_WALLET="RADIX_WALLET";E.TALISMAN="TALISMAN";E.TREZOR="TREZOR";E.TRONLINK="TRONLINK";E.TRUSTWALLET_WEB="TRUSTWALLET_WEB";E.VULTISIG="VULTISIG";E.WALLETCONNECT="WALLETCONNECT";E.WALLET_SELECTOR="WALLET_SELECTOR";E.XAMAN="XAMAN"})(jN||={});var OT;((H)=>{H[H.NoError=36864]="NoError";H[H.LockedDevice=21781]="LockedDevice";H[H.TC_NotFound=65535]="TC_NotFound"})(OT||={});var MT=sN.reduce((N,A)=>{if(!N.THOR_STAGENET)N[_N.Maya]=eN.rpcUrls,N[_N.THORChain]=aN.rpcUrls;return N[A]=BT(A).rpcUrls,N},{}),_T={[iN.THORChain]:GT.nodeUrl,[iN.Maya]:$T.nodeUrl,[_N.THORChain]:aN.nodeUrl,[_N.Maya]:eN.nodeUrl},NA={apiKeys:{blockchair:"",keepKey:"",passkeys:"",swapKit:"",walletConnectProjectId:"",xaman:""},chains:sN,endpoints:{},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},localMode:{enabled:!1,quoteUrl:"http://localhost:3000",swapUrl:"http://localhost:3001"},requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:MT,thornodeUrls:_T,v3SwapFlow:{enabled:typeof process<"u"&&process.env?.SWAPKIT_V3_SWAP_FLOW==="true"},wallets:Object.values(jN),widgetId:"",widgetKey:""},x=YT((N)=>({...NA,setApiKey:(A,T)=>N((H)=>({apiKeys:{...H.apiKeys,[A]:T}})),setConfig:(A)=>N((T)=>({apiKeys:{...T.apiKeys,...A?.apiKeys},chains:T.chains.concat(A?.chains||[]),endpoints:{...T.endpoints,...A?.endpoints},envs:{...T.envs,...A?.envs},feeMultipliers:A?.feeMultipliers||T.feeMultipliers,integrations:{...T.integrations,...A?.integrations},localMode:{...T.localMode,...A?.localMode},rpcUrls:{...T.rpcUrls,...A?.rpcUrls},thornodeUrls:{...T.thornodeUrls,...A?.thornodeUrls},v3SwapFlow:{...T.v3SwapFlow,...A?.v3SwapFlow},wallets:T.wallets.concat(A?.wallets||[]),widgetId:A?.widgetId||T.widgetId,widgetKey:A?.widgetKey||T.widgetKey})),setEndpoint:(A,T)=>N((H)=>({endpoints:{...H.endpoints,[A]:T}})),setEnv:(A,T)=>N((H)=>({envs:{...H.envs,[A]:T}})),setFeeMultipliers:(A)=>N(()=>({feeMultipliers:A})),setIntegrationConfig:(A,T)=>N((H)=>({integrations:{...H.integrations,[A]:T}})),setRequestOptions:(A)=>N((T)=>({requestOptions:{retry:{...T.requestOptions.retry,...A.retry},timeoutMs:A.timeoutMs||T.requestOptions.timeoutMs}})),setRpcUrl:(A,T)=>N((H)=>({rpcUrls:{...H.rpcUrls,[A]:T}})),setThornodeUrl:(A,T)=>N((H)=>({thornodeUrls:{...H.thornodeUrls,[A]:T}})),setWidgetId:(A)=>N({widgetId:A}),setWidgetKey:(A)=>N({widgetKey:A})})),b={get:(N)=>x.getState()[N],getState:x.getState,reinitialize:()=>x.setState(NA),set:(N)=>x.getState().setConfig(N),setApiKey:(N,A)=>x.getState().setApiKey(N,A),setEndpoint:(N,A)=>x.getState().setEndpoint(N,A),setEnv:(N,A)=>x.getState().setEnv(N,A),setFeeMultipliers:(N)=>x.getState().setFeeMultipliers(N),setIntegrationConfig:(N,A)=>x.getState().setIntegrationConfig(N,A),setRequestOptions:(N)=>x.getState().setRequestOptions(N),setRpcUrl:(N,A)=>x.getState().setRpcUrl(N,A),setThornodeUrl:(N,A)=>x.getState().setThornodeUrl(N,A),setWidgetId:(N)=>x.getState().setWidgetId(N),setWidgetKey:(N)=>x.getState().setWidgetKey(N)};var DT={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_wallet_create_not_supported:10115,core_wallet_sign_typed_data_not_supported:10116,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_ledger_webhid_not_supported:20124,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_trezor_failed_to_get_public_key:20506,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_keepkey_failed_to_get_public_key:20918,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_passkeys_sign_transaction_error:21101,wallet_passkeys_not_found:21102,wallet_passkeys_no_address:21103,wallet_passkeys_request_canceled:21104,wallet_passkeys_signature_canceled:21105,wallet_passkeys_failed_to_switch_network:21106,wallet_passkeys_chain_not_supported:21107,wallet_passkeys_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_passkey_not_supported:21601,wallet_passkey_connection_failed:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22004,wallet_petra_not_found:22201,wallet_vultisig_not_found:22101,wallet_vultisig_contract_address_not_provided:22102,wallet_vultisig_asset_not_defined:22103,wallet_vultisig_send_transaction_no_address:22104,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,wallet_tronlink_request_accounts_failed:24001,wallet_tronlink_locked:24002,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_evm_invalid_eip7702_authorization:50217,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_utxo_tx_not_found:50309,toolbox_utxo_rbf_not_supported:50310,toolbox_utxo_tx_not_replaceable:50311,toolbox_utxo_tx_already_confirmed:50312,toolbox_utxo_rbf_fee_too_low:50313,toolbox_utxo_rbf_insufficient_change:50314,toolbox_solana_no_signer:50401,toolbox_substrate_not_supported:50501,toolbox_substrate_transfer_error:50502,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_ripple_get_trust_lines_error:50706,toolbox_ripple_invalid_trust_line_limit:50707,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_trongrid_api_error:50805,toolbox_tron_approve_failed:50806,toolbox_tron_invalid_token_contract:50807,toolbox_tron_allowance_check_failed:50808,toolbox_tron_invalid_transaction_integrity:50809,toolbox_tron_broadcast_failed:50810,toolbox_hypercore_no_signer:51001,toolbox_hypercore_payload_mismatch:51002,toolbox_hypercore_insufficient_balance:51003,toolbox_hypercore_destination_sanctioned:51004,toolbox_hypercore_transfer_hash_not_found:51005,toolbox_hypercore_pre_transfer_check_failed:51006,toolbox_cardano_sign_transaction_failed:50901,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_near_no_public_key_found:90613,toolbox_near_sign_transaction_failed:90614,toolbox_sui_address_required:90701,toolbox_sui_keypair_required:90702,toolbox_sui_balance_error:90703,toolbox_sui_transaction_creation_error:90704,toolbox_sui_signing_error:90705,toolbox_sui_broadcast_error:90706,toolbox_sui_no_signer:90707,toolbox_sui_no_sender:90708,toolbox_sui_missing_coin_type:90709,toolbox_sui_no_coins_found:90710,toolbox_sui_insufficient_balance:90711,toolbox_starknet_no_signer:90801,toolbox_starknet_invalid_address:90802,toolbox_starknet_fee_estimation_failed:90803,toolbox_starknet_account_not_deployed:90804,toolbox_starknet_transaction_failed:90805,toolbox_ton_no_signer:90901,toolbox_ton_invalid_address:90902,toolbox_ton_missing_jetton_address:90903,toolbox_ton_jetton_transfer_failed:90904,toolbox_ton_transaction_failed:90905,toolbox_aptos_address_required:91001,toolbox_aptos_keypair_required:91002,toolbox_aptos_balance_error:91003,toolbox_aptos_transaction_creation_error:91004,toolbox_aptos_signing_error:91005,toolbox_aptos_broadcast_error:91006,toolbox_aptos_no_signer:91007,toolbox_aptos_no_sender:91008,toolbox_aptos_missing_asset_type:91009,toolbox_aptos_insufficient_balance:91010,toolbox_stellar_no_signer:91101,toolbox_stellar_broadcast_error:91102,toolbox_stellar_invalid_address:91103,toolbox_stellar_account_not_found:91104,toolbox_stellar_transaction_failed:91105,toolbox_stellar_balance_error:91106,toolbox_stellar_trustline_asset_invalid:91112,toolbox_aleo_no_signer:91201,toolbox_aleo_invalid_address:91202,toolbox_aleo_balance_error:91203,toolbox_aleo_fee_estimation_failed:91204,toolbox_aleo_broadcast_error:91205,toolbox_aleo_transaction_failed:91206,toolbox_aleo_wasm_init_failed:91207,toolbox_aleo_unsupported_token:91208,toolbox_aleo_token_transfer_rejected:91209,toolbox_aleo_insufficient_fee_balance:91210,toolbox_aleo_no_unspent_records:91211,toolbox_aleo_conflicting_signers:91212,toolbox_aleo_no_rpc_urls:91213,toolbox_not_supported:59901,toolbox_fee_estimation_failed:59902,toolbox_sweep_amount_too_low:59903,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,plugin_garden_missing_data:42001,plugin_swapkit_swap_invalid_data:43001,plugin_swapkit_invalid_transaction:43002,plugin_swapkit_stellar_destination_wallet_not_found:43003,plugin_swapkit_unsupported_tx_type:43004,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,helpers_chain_no_public_or_set_rpc_url:70012,helpers_chain_rpc_connection_failed:70013,mcp_wallet_not_configured:90001,not_implemented:99999};function VN(N){return JSON.stringify(N,(A,T)=>typeof T==="bigint"?T.toString():T)}class U extends Error{static ErrorCode=DT;errorKey;info;constructor(N,A){let T=typeof N==="string",H=T?N:N.errorKey,L=T?void 0:N.info,I=`${H}${L?`: ${VN(L)}`:""}`;super(I);if(Object.setPrototypeOf(this,U.prototype),this.name="SwapKitError",this.errorKey=H,this.info=L,this.cause=A,A){let O=A instanceof Error?`${A.message}${A.cause?` (${A.cause})`:""}`:VN(A);console.error(`SwapKitError [${H}]: ${O}`)}else if(L)console.error(`SwapKitError [${H}]: ${VN(L)}`)}}var uT=(N)=>new Promise((A)=>setTimeout(A,N)),XT=(N,{baseDelay:A,backoffMultiplier:T,maxDelay:H})=>Math.min(A*T**N,H);function UT(N,A){if(N instanceof Error&&N.name==="AbortError")return!0;if(N instanceof TypeError)return!0;if(A===429)return!0;if(A&&A>=500&&A<600)return!0;return!1}var ET=async(N,A)=>{let T=await fetch(N,A),H;try{H=await T.json()}catch{if(!T.ok)throw new U({errorKey:"helpers_invalid_response",info:{status:T.status,statusText:T.statusText}},{status:T.status,statusText:T.statusText});return{}}if(!T.ok){let I={data:H?.data,error:H?.error,message:H?.message,status:T.status};throw new U({errorKey:H?.error||"helpers_invalid_response",info:I},I)}let L=H?.routes?.length||H?.result||H?.data&&!H?.error;if(H?.error&&!L){let I={data:H.data,error:H.error,message:H.message,status:T.status};throw new U({errorKey:H.error,info:I},I)}if(H?.providerErrors?.length||H?.error&&L)console.warn("[SwapKit] Partial errors in response:",H.providerErrors||H.error);return H};function DN(N,A={}){return async function(H,L={}){let{searchParams:I,json:O,body:G,headers:M,dynamicHeader:Q,retry:X,timeoutMs:S,abortController:j,onError:w,onSuccess:K,responseHandler:Z,...W}={...A,...L},HN=b.get("requestOptions"),h={...HN.retry,...X},J=!!O||H.endsWith(".json"),YN=bT(H,I),dN=Q?await Q():{},LN=ST(J,{...M,...dN}),c=J?JSON.stringify(O):G,QN;for(let MN=0;MN<=h.maxRetries;MN++){let hN=j||new AbortController,cN=setTimeout(()=>hN.abort(),S||HN.timeoutMs);try{let y=await ET(YN,{...W,body:c,headers:LN,method:N,signal:hN.signal});return clearTimeout(cN),K?.(y)||Z?.(y)||y}catch(y){clearTimeout(cN),QN=y;let NT=y?.cause?.status;if(MN>=h.maxRetries||!UT(y,NT))return w?w(y):Promise.reject(y);await uT(XT(MN,h))}}return w?w(QN):Promise.reject(QN)}}function ST(N,A){return{...A,...N&&{"Content-Type":"application/json"}}}function bT(N,A){let T=new URL(N);if(A)T.search=new URLSearchParams(A).toString();return T.toString()}var _={extend:(N)=>({extend:(A)=>_.extend({...N,...A}),get:DN("GET",N),post:DN("POST",N)}),get:DN("GET"),post:DN("POST")};async function AA(N,A,T,H){let L=`${A}:${T}:${H}`,I=new TextEncoder,O=await crypto.subtle.importKey("raw",I.encode(N),{hash:"SHA-256",name:"HMAC"},!1,["sign"]),G=await crypto.subtle.sign("HMAC",O,I.encode(L));return Array.from(new Uint8Array(G)).map((M)=>M.toString(16).padStart(2,"0")).join("")}import{Chain as u,CosmosChains as PA,EVMChains as FA,getChainConfig as IA,StagenetChains as gT,SubstrateChains as wT,UTXOChains as RA}from"@swapkit/types";import{match as uN}from"ts-pattern";function $P(N,A){try{return N()}catch(T){if(A)throw new U(A,T);return}}var TA=new Set;function l({condition:N,id:A,warning:T}){if(N){if(TA.has(A))return;console.warn(T),TA.add(A)}}function zT(N){return uN(N).with(...FA,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...RA,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...PA,...gT,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(u.Polkadot,u.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(u.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(u.Sui,()=>({id:1,jsonrpc:"2.0",method:"sui_getSystemState",params:[]})).with(u.Ton,()=>({id:1,jsonrpc:"2.0",method:"getAddressInformation",params:{address:""}})).with(u.Aleo,u.Aptos,u.Tron,u.Radix,u.Stellar,()=>"").with(u.Hype,()=>({type:"meta"})).with(u.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(u.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).with(u.Starknet,()=>({id:1,jsonrpc:"2.0",method:"starknet_chainId",params:[]})).otherwise(()=>{throw new U("helpers_chain_not_supported",{chain:N})})}function HA(N){return uN(N).with(u.Aptos,()=>"/-/healthy").with(u.Aleo,()=>"/mainnet/block/height/latest").with(u.Hype,()=>"/info").with(u.Radix,()=>"/status/network-configuration").with(u.Stellar,()=>"").with(u.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function LA(N,A){try{let T=A.startsWith("wss")?A.replace("wss","https"):A;if(N===u.Aleo||N===u.Stellar)return(await fetch(`${T}${HA(N)}`,{cache:"no-store",method:"GET",signal:AbortSignal.timeout(3000)})).ok;return(await fetch(`${T}${HA(N)}`,{body:JSON.stringify(zT(N)),cache:"no-store",headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var xN=new Map,JT=120000;function QT(N){let[A=""]=b.get("rpcUrls")[N];if(!A)throw l({condition:!0,id:"helpers_chain_no_public_or_set_rpc_url",warning:`No public or set RPC URL found for chain. Please ensure you configured rpcUrls for ${N}.`}),new U("helpers_chain_no_public_or_set_rpc_url",{chain:N});let T=xN.get(N);if(T&&Date.now()-T.timestamp<JT)return T.url;return xN.set(N,{timestamp:Date.now(),url:A}),A}async function r(N){let A=QT(N),[,...T]=b.get("rpcUrls")[N];if(await LA(N,A))return A;for(let L of T)if(await LA(N,L))return xN.set(N,{timestamp:Date.now(),url:L}),L;throw new U("helpers_chain_rpc_connection_failed",{chain:N,fallbackUrls:T,primaryRpcUrl:A})}function XP(N){l({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}function UP({chain:N,txHash:A}){let{explorerUrl:T}=IA(N);return uN(N).with(...PA,u.Solana,()=>`${T}/tx/${A.startsWith("0x")?A.slice(2):A}`).with(...FA,...wT,()=>`${T}/tx/${A.startsWith("0x")?A:`0x${A}`}`).with(...RA,u.Radix,u.Tron,()=>`${T}/transaction/${A.toLowerCase()}`).with(u.Near,()=>`${T}/txns/${A}`).with(u.Ripple,()=>`${T}/transactions/${A}`).with(u.Stellar,()=>`${T}/explorer/public/tx/${A}`).with(u.Sui,()=>`${T}/txblock/${A}`).with(u.Cardano,u.Hype,u.Spark,u.Ton,()=>`${T}/tx/${A}`).otherwise(()=>"")}function EP({chain:N,address:A}){let{explorerUrl:T}=IA(N);return uN(N).with(u.Solana,u.Sui,u.Radix,()=>`${T}/account/${A}`).with(u.Stellar,()=>`${T}/explorer/public/account/${A}`).otherwise(()=>`${T}/address/${A}`)}function SP(N){switch(N){case u.THORChain:return`${N}.RUNE`;case u.Cosmos:return`${N}.ATOM`;case u.BinanceSmartChain:return`${N}`;default:return`${N}.${N}`}}import{keccak_256 as ZT}from"@noble/hashes/sha3.js";import{bytesToHex as WT}from"@noble/hashes/utils.js";var OA=/^(0x)?[0-9a-fA-F]{40}$/;function XN(N){if(typeof N!=="string"||!OA.test(N))throw Error(`invalid address: ${N}`);let A=N.toLowerCase().replace(/^0x/,""),T=WT(ZT(new TextEncoder().encode(A))),H=[...A].map((I,O)=>Number.parseInt(T[O]??"0",16)>=8?I.toUpperCase():I).join(""),L=N.replace(/^0x/,"");if(/[A-F]/.test(L)&&/[a-f]/.test(L)&&L!==H)throw Error(`bad address checksum: ${N}`);return`0x${H}`}function BA(N){if(typeof N!=="string"||!OA.test(N))return!1;try{return XN(N),!0}catch{return!1}}var xP=[`${B.Maya}.MAYA`,`${B.Maya}.CACAO`,`${B.Ethereum}.THOR`,`${B.Ethereum}.vTHOR`,`${B.Kujira}.USK`,`${B.Ethereum}.FLIP`,`${B.Radix}.XRD`],YA=[B.Arbitrum,B.Aurora,B.Base,B.Ethereum,B.Optimism,B.Robinhood];async function xT(N){let{baseDecimal:A}=p(B.Radix);try{let T=await r(B.Radix),{manager:H}=await _.post(`${T}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:N}),headers:{Accept:"*/*","Content-Type":"application/json"}});return H?.divisibility?.value?.divisibility}catch(T){let H=T instanceof Error?T.message:String(T);return console.warn(`Failed to fetch Radix asset decimals for ${N}: ${H}`),A}}async function qT(N){try{let A=await r(B.Radix);return(await _.post(`${A}/state/entity/details`,{body:JSON.stringify({addresses:[N],opt_ins:{explicit_metadata:["symbol"]}}),headers:{Accept:"*/*","Content-Type":"application/json"}})).items[0]?.explicit_metadata?.items.find((L)=>L.key==="symbol")?.value.typed.value||void 0}catch(A){let T=A instanceof Error?A.message:String(A);return console.warn(`Failed to fetch Radix asset symbol for ${N}: ${T}`),""}}async function MA({chain:N,address:A,methodHex:T,id:H}){let L=await r(N);return _.post(L,{body:JSON.stringify({id:H,jsonrpc:"2.0",method:"eth_call",params:[{data:T,to:A.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}})}function vT(N){if(!N||N==="0x")return"UNKNOWN";try{return _A(N.replace(/^0x/,""))?.trim()||"UNKNOWN"}catch(A){return console.warn(`Failed to decode ABI string from ${N}: ${A}`),"UNKNOWN"}}function nT(N,A){if(!N||N==="0x")return A;try{return Number(N)}catch(T){return console.warn(`Failed to decode ABI uint8 from ${N}: ${T}`),A}}async function kT({chain:N,address:A}){let{baseDecimal:T}=p(N),H=A.toLowerCase();if(A===""||!H.startsWith("0x"))return T;let L=await MA({address:A,chain:N,id:2,methodHex:"0x313ce567"}).catch((O)=>{return console.warn(`Could not fetch decimals for ${A} on ${N}: ${O.message}`),{result:""}});return nT(L.result,T)}async function KT({chain:N,address:A}){let T=A.toLowerCase();if(T===""||!T.startsWith("0x"))return;let H=await MA({address:A,chain:N,id:1,methodHex:"0x95d89b41"}).catch((I)=>{return console.warn(`Could not fetch symbol for ${A} on ${N}: ${I.message}`),{result:""}});return vT(H.result)}async function $A({rpcUrl:N,contractAddress:A,functionSelector:T}){return(await _.post(`${N}/wallet/triggerconstantcontract`,{body:JSON.stringify({contract_address:A,function_selector:T,owner_address:A,parameter:"",visible:!0}),headers:{accept:"application/json","content-type":"application/json"}}).catch(()=>{return}))?.constant_result?.[0]}function GA(N){let A=N.match(/.{2}/g)?.map((T)=>Number.parseInt(T,16))??[];return new TextDecoder().decode(new Uint8Array(A))}function _A(N){return FN(N).with(void 0,()=>{return}).when((A)=>A.length>=128,(A)=>{let T=Number.parseInt(A.slice(64,128),16),H=A.slice(128,128+T*2).replace(/(00)+$/,"");return H?GA(H):void 0}).when((A)=>A.length===64,(A)=>{let T=A.replace(/(00)+$/,"");if(T.length>0&&T.length%2===0)return GA(T);return}).otherwise(()=>{return})}function DA({chain:N,address:A}){let{baseDecimal:T}=p(N),H={decimals:T,ticker:void 0};return FN(N).with(...jT,async()=>{try{if(!BA(A.replace(/^0X/,"0x")))return H;let[L,I]=await Promise.all([KT({address:A,chain:N}),kT({address:A,chain:N})]);return{decimals:I,ticker:L}}catch(L){return console.warn(`Failed to fetch token info for ${A} on ${N}: ${L?.code} ${L?.message}`),H}}).with(B.Solana,async()=>{if(!A)return H;try{let L=await fetch(`https://lite-api.jup.ag/tokens/v2/search?query=${A}`);if(L.ok){let I=await L.json(),O=Array.isArray(I)?I[0]:I;if(O)return{decimals:O.decimals??T,ticker:O.symbol||void 0}}}catch(L){console.warn(`Failed to fetch Solana token info for ${A}: ${L?.code} ${L?.message}`)}return H}).with(B.Tron,async()=>{if(!A)return H;try{let L=await r(B.Tron),[I,O]=await Promise.all([$A({contractAddress:A,functionSelector:"symbol()",rpcUrl:L}),$A({contractAddress:A,functionSelector:"decimals()",rpcUrl:L})]),G=_A(I);return{decimals:I!==void 0&&O?Number(BigInt(`0x${O}`)):T,ticker:G}}catch(L){let I=L instanceof Error?L.message:String(L);return console.warn(`Failed to fetch Tron token info for ${A}: ${I}`),H}}).with(B.Near,async()=>{if(!A)return H;try{let L=await r(B.Near),I=await _.post(L,{body:JSON.stringify({id:"dontcare",jsonrpc:"2.0",method:"query",params:{account_id:A,args_base64:"e30=",finality:"final",method_name:"ft_metadata",request_type:"call_function"}}),headers:{accept:"application/json","content-type":"application/json"}});if(!I.result?.result)throw Error("NEAR ft_metadata returned no result");let O=JSON.parse(new TextDecoder().decode(new Uint8Array(I.result.result)));return{decimals:O?.decimals||T,ticker:O?.symbol}}catch(L){let I=L instanceof Error?L.message:String(L);return console.warn(`Failed to fetch Near token info for ${A}: ${I}`),H}}).with(B.Radix,async()=>{if(!A)return H;try{let[L,I]=await Promise.all([qT(A),xT(A)]);return{decimals:I,ticker:L}}catch(L){let I=L instanceof Error?L.message:String(L);return console.warn(`Failed to fetch Radix token info for ${A}: ${I}`),H}}).otherwise(async()=>H)}function uA({chain:N,symbol:A}){return FN(N).with(...YA,()=>A==="ETH").with(B.Avalanche,()=>A==="AVAX").with(B.Berachain,()=>A==="BERA").with(B.Hyperevm,()=>A==="HYPE").with(B.Hype,()=>A==="HYPE").with(B.Spark,()=>A==="BTC").with(B.BinanceSmartChain,()=>A==="BNB").with(B.Gnosis,()=>A==="xDAI"||A==="XDAI").with(B.Monad,()=>A==="MON").with(B.XLayer,()=>A==="OKB").with(B.Maya,()=>A==="CACAO").with(B.Cosmos,()=>A==="ATOM").with(B.THORChain,()=>A==="RUNE").with(B.Tron,()=>A==="TRX").with(B.Ripple,()=>A==="XRP").with(B.Radix,()=>`${N}.${A}`===UN(N).identifier).otherwise(()=>A===N)}var UN=(N)=>{let{baseDecimal:A}=p(N);return FN(N.toUpperCase()).with(...YA,(H)=>({decimal:A,identifier:`${H}.ETH`})).with(B.THORChain,(H)=>({decimal:A,identifier:`${H}.RUNE`})).with(B.Cosmos,(H)=>({decimal:A,identifier:`${H}.ATOM`})).with(B.Maya,(H)=>({decimal:10,identifier:`${H}.CACAO`})).with(B.BinanceSmartChain,(H)=>({decimal:A,identifier:`${H}.BNB`})).with(B.Monad,(H)=>({decimal:A,identifier:`${H}.MON`})).with(B.Avalanche,(H)=>({decimal:A,identifier:`${H}.AVAX`})).with(B.Gnosis,(H)=>({decimal:A,identifier:`${H}.xDAI`})).with(B.XLayer,(H)=>({decimal:A,identifier:`${H}.OKB`})).with(B.Berachain,(H)=>({decimal:A,identifier:`${H}.BERA`})).with(B.Hyperevm,(H)=>({decimal:A,identifier:`${H}.HYPE`})).with(B.Hype,(H)=>({decimal:A,identifier:`${H}.HYPE`})).with(B.Spark,(H)=>({decimal:A,identifier:`${H}.BTC`})).with(B.Tron,(H)=>({decimal:A,identifier:`${H}.TRX`})).with(B.Solana,B.Chainflip,B.Kujira,B.Ripple,B.Polkadot,B.Near,...VT,(H)=>({decimal:A,identifier:`${H}.${H}`})).with(B.Radix,"XRD.XRD",()=>({decimal:A,identifier:"XRD.XRD"})).with(B.Polygon,"POL.POL",()=>({decimal:A,identifier:"POL.POL"})).with("KUJI.USK",(H)=>({decimal:6,identifier:H})).with("ETH.FLIP",()=>({decimal:p(B.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:p(B.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:p(B.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(H)=>({decimal:10,identifier:H})).with("MAYA.MAYA",(H)=>({decimal:4,identifier:H})).otherwise(()=>({decimal:A,identifier:N}))};function qN({chain:N,symbol:A}){if(A.includes("/"))return"Synth";if(A.includes("~"))return"Trade";return FN(N).with(B.Radix,()=>A===B.Radix||`${N}.${A}`===UN(N).identifier).with(B.Arbitrum,B.Optimism,B.Base,B.Aurora,B.Robinhood,()=>A===B.Ethereum).with(B.Cosmos,()=>A==="ATOM").with(B.BinanceSmartChain,()=>A==="BNB").with(B.Maya,()=>A==="CACAO").with(B.Monad,()=>A==="MON").with(B.THORChain,()=>A==="RUNE").with(B.Tron,()=>A==="TRX").with(B.Hyperevm,()=>A==="HYPE").with(B.Hype,()=>A==="HYPE").with(B.Spark,()=>A==="BTC").with(B.XLayer,()=>A==="OKB").otherwise(()=>A===N)?"Native":N}var o=(N)=>{let[A,...T]=N.split("."),H=N.includes("/"),L=T.join("."),I=L?.split("-"),O=I?.length?I.length===1?I[0]:I.slice(0,-1).join("-"):void 0;return{chain:A,symbol:L,synth:H,ticker:O}};function IN(N,A){let H=A===B.Near?N.indexOf("-"):N.lastIndexOf("-");if(H===-1)return{address:void 0,ticker:N};return{address:N.slice(H+1),ticker:N.slice(0,H)}}function qP(N){return`https://storage.googleapis.com/token-list-swapkit-dev/images/${N.toLowerCase()}.png`}async function vP(N){let{loadTokenLists:A}=await import("./tokens.js"),T=await A(void 0,{source:b.get("envs").isDev?"dev":"prod"}),H=Object.values(T).flatMap((I)=>I.tokens);if("identifier"in N)return H.find((I)=>I.identifier===N.identifier)?.identifier;let L=N.contract.toLowerCase();for(let I of H){let{chain:O,symbol:G}=o(I.identifier);if(O!==N.chain)continue;let{address:M}=IN(G,O);if(M?.toLowerCase()===L)return I.identifier}return}import{match as EN}from"ts-pattern";var i=8,mT=10,yT=64;function d({value:N,bigIntDecimal:A=i,decimal:T=i}){if(T===0)return N.toString();let H=N<0n,L=N.toString().substring(H?1:0),I=T-(L.length-1);if(I>0)L="0".repeat(I)+L;let O=L.length-T,G=L.slice(-T);if(Number.parseInt(G[A]||"0",10)>=5){let Q=Number.parseInt(G[A-1]||"0",10);G=`${G.substring(0,A-1)}${Q+1}`}else G=G.substring(0,A);return`${H?"-":""}${L.slice(0,O)}.${G}`.replace(/\.?0*$/,"")}class t{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(N,A){return new t({decimal:A,value:d({bigIntDecimal:A,decimal:A,value:N})})}static shiftDecimals({value:N,from:A,to:T}){return t.fromBigInt(N.getBaseValue("bigint")*C(T)/C(A),T)}constructor(N){let A=vN(N),T=typeof N==="object";this.decimal=T?N.decimal:void 0,this.decimalMultiplier=T&&"decimalMultiplier"in N?N.decimalMultiplier:C(Math.max(XA(SN(A)),this.decimal||0)),this.#L(A)}set(N){return new this.constructor({decimal:this.decimal,identifier:this.toString?.({includeSynthProtocol:!0}),value:N})}add(...N){return this.#A("add",...N)}sub(...N){return this.#A("sub",...N)}mul(...N){return this.#A("mul",...N)}div(...N){return this.#A("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,A){let T=RN(this.decimalMultiplier),H=A!==void 0?A:this.decimal,L=H!==void 0?H:T;if(H!==void 0&&H<T){if(this.formatBigIntToSafeValue(this.bigIntValue,H)==="0"&&this.bigIntValue!==0n)L=T}let I=this.formatBigIntToSafeValue(this.bigIntValue,L);return EN(N).with("number",()=>Number(I)).with("string",()=>I).with("bigint",()=>{return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}).otherwise(()=>I)}getBaseValue(N,A){let T=this.decimalMultiplier/C(A||this.decimal||i),H=fT(this.bigIntValue,T);return EN(N).with("number",()=>Number(H)).with("string",()=>H.toString()).otherwise(()=>H)}getBigIntValue(N,A){if(!A&&typeof N==="object")return N.bigIntValue;let T=vN(N),H=SN(T);if(H==="0"||H==="undefined")return 0n;return this.#H(H,A)}toSignificant(N=6){let A=this.getValue("string"),[T="",H=""]=A.split("."),L=Number.parseInt(T,10)>0;if((L?T.length+H.length:H.length)<=N)return A;if(T.length>=N)return T.slice(0,N).padEnd(T.length,"0");if(L)return`${T}.${H.slice(0,N-T.length)}`;let O=H.replace(/^0+/,"")||"0",G=O.slice(0,N),M=H.length-O.length;return`0.${G.padStart(M+G.length,"0")}`}toFixed(N=6){let A=this.getValue("string"),T=A.startsWith("-"),[H="0",L=""]=(T?A.slice(1):A).split("."),I=H==="0"&&Number.parseInt(L.slice(0,N),10)===0,O=T&&!I?"-":"";if(N===0){if(H==="0"&&!L)return"0";return L&&Number.parseInt(L[0]||"0",10)>=5?`${O}${BigInt(H)+1n}.0`:`${O}${H}.0`}if(!L)return`${O}${H}.${"0".repeat(N)}`;let G=L[N];if(!(G&&Number.parseInt(G,10)>=5))return`${O}${H}.${L.slice(0,N).padEnd(N,"0")}`;let Q=BigInt(L.slice(0,N).padEnd(N,"0"))+1n,X=10n**BigInt(N);if(Q>=X)return`${O}${BigInt(H)+1n}.${"0".repeat(N)}`;return`${O}${H}.${Q.toString().padStart(N,"0")}`}toAbbreviation(N=2){let A=this.getValue("string"),T=Number(A),H=["","K","M","B","T","Q","Qi","S"],L=Math.floor(Math.log10(Math.abs(T))/3);if(L===0||!H[L])return A;return`${(T/10**(L*3)).toFixed(N)}${H[L]}`}toCurrency(N="$",{currencyPosition:A="start",decimal:T=2,decimalSeparator:H=".",thousandSeparator:L=",",trimTrailingZeros:I=!0}={}){let O=this.toFixed(T),G=A==="end",[M="0",Q=""]=O.split("."),X=M.replace(/\B(?=(\d{3})+(?!\d))/g,L),S=Q&&Number.parseInt(Q,10)>0,j=S?`${X}${H}${Q}`:X,K=j.length<100&&I&&S?j.replace(/\.?0*$/,""):j;return G?`${K}${N}`:`${N}${K}`}formatBigIntToSafeValue(N,A){let T=A||this.decimal||i,H=Math.max(T,RN(this.decimalMultiplier));return d({bigIntDecimal:T,decimal:H,value:N})}#A(N,...A){let T=this.#T(this,...A),H=RN(this.decimalMultiplier),L=Math.max(T,H),I=Math.min(L+mT,yT),O=C(I),G=A.reduce((X,S)=>{let j=this.getBigIntValue(S,I);return EN(N).with("add",()=>X+j).with("sub",()=>X-j).with("mul",()=>X*j/O).with("div",()=>{if(j===0n)throw RangeError("Division by zero");return X*O/j}).otherwise(()=>X)},this.bigIntValue*O/this.decimalMultiplier),M=d({bigIntDecimal:I,decimal:I,value:G}),Q=this.decimal===void 0?void 0:Math.min(this.decimal,I);return new this.constructor({decimal:Q,decimalMultiplier:C(I),identifier:this.toString(),value:M})}#N(N,...A){let T=this.#T(this,...A),H=this.getBigIntValue(A[0]||"0",T),L=this.getBigIntValue(this,T);return EN(N).with("gt",()=>L>H).with("gte",()=>L>=H).with("lt",()=>L<H).with("lte",()=>L<=H).with("eqValue",()=>L===H).otherwise(()=>!1)}#L(N){let A=SN(N)||"0";this.bigIntValue=this.#H(A)}#T(...N){let A=N.map((T)=>{return typeof T==="object"?T.decimal||RN(T.decimalMultiplier):XA(SN(T))}).filter(Boolean);return Math.max(...A,i)}#H(N,A){let T=A?C(A):this.decimalMultiplier,H=RN(T),[L="",I=""]=N.split(".");return BigInt(`${L}${I.padEnd(H,"0")}`)}}var tT=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function SN(N){let T=`${typeof N==="number"?tT.format(N):vN(N)}`.replaceAll(",",".").split(".");return T.length>1?`${T.slice(0,-1).join("")}.${T.at(-1)}`:T[0]||"0"}function XA(N){let A=N.split(".")[1]?.length||0;return Math.max(A,i)}function vN(N){return typeof N==="object"?"getValue"in N?N.getValue("string"):N.value:N}function fT(N,A){if(A===0n)throw Error("Cannot divide by zero");let T=A/2n;return N>=0n&&A>=0n||N<0n&&A<0n?(N+T)/A:(N-T)/A}function C(N){return 10n**BigInt(N)}function RN(N){return N.toString().length-1}function CT(N=""){let A=N.toUpperCase(),T=b.get("chains"),[H]=A.split(".");if(T.includes(H))return!0;let[L]=A.split("/");if(T.includes(L))return!0;throw new U({errorKey:"helpers_invalid_identifier",info:{identifier:N,message:`Invalid identifier: ${N}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}var f=[z.Hype,z.Near,z.Ripple,z.Solana,z.Stellar,z.Sui,z.Ton,z.Tron],KN=[z.THORChain,z.Maya],s=new Map,bN=new Map,e=new Map,dT=3600000;function hT(N){let A=e.get(N);if(A?.timestamp&&Date.now()-A.timestamp>dT){e.delete(N);return}return A}function cT(N,A){if(e.size>1000){let T=e.keys().next().value;if(T)e.delete(T)}e.set(N,{...A,timestamp:Date.now()})}class n extends t{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:N,decimal:A,tax:T,chain:H,symbol:L,identifier:I}){super(typeof N==="object"?N:{decimal:A,value:N});let O=UA(I||`${H}.${L}`);this.type=qN(O),this.tax=T,this.chain=O.chain,this.ticker=O.ticker,this.symbol=O.symbol,this.address=O.address,this.isSynthetic=O.isSynthetic,this.isTradeAsset=O.isTradeAsset,this.isGasAsset=O.isGasAsset,this.chainId=ON(O.chain).chainId}toString({includeSynthProtocol:N}={}){return(this.isSynthetic||this.isTradeAsset)&&!N?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){if(this.isSynthetic)return`${this.chain}.${this.symbol.replace(/\//g,".")}`;if(this.isTradeAsset)return`${this.chain}.${this.symbol.replace(/~/g,"..")}`;let N=this.symbol.replace(/\./g,"__");return`${this.chain}.${N}`}getIconUrl(){return s.get(this.toString())?.logoURI}eqAsset({chain:N,symbol:A}){return this.chain===N&&this.symbol===A}eq(N){return this.eqAsset(N)&&this.eqValue(N)}static fromUrl(N,A=0){let T=N.indexOf(".");if(T===-1)throw new U({errorKey:"helpers_invalid_asset_url",info:{urlAsset:N}});let H=N.slice(0,T),L=N.slice(T+1),I=kN({chain:H,rest:L}).when(({rest:O})=>O.includes(".."),({chain:O,rest:G})=>`${O}.${G.replace(/\.\./g,"~")}`).when(({chain:O,rest:G})=>KN.includes(O)&&G.includes("."),({chain:O,rest:G})=>`${O}.${G.replace(/\./g,"/")}`).otherwise(({chain:O,rest:G})=>`${O}.${G.replace(/__/g,".")}`);return n.from({asset:I,value:A})}static from({value:N=0,fromBaseDecimal:A,asyncTokenLookup:T,...H}){let L=N instanceof t?N.getValue("string"):N,I="address"in H&&"chain"in H,O=sT(H);if(O===null&&T&&I){let{chain:LN,address:c}=H;return rT({address:c,chain:LN,fromBaseDecimal:A,parsedValue:L})}let G=I&&!O?`${H.chain}.UNKNOWN-${H.address}`:O,{identifier:M,decimal:Q}=UN(G),{chain:X,isSynthetic:S,isTradeAsset:j,address:w}=UA(M),{baseDecimal:K}=ON(X),Z=s.get(f.includes(X)?M:M.toUpperCase());if(!Z&&T&&!S&&!j)return(async()=>{let{ticker:LN}=o(M),c=await EA({address:w,chain:X,ticker:LN});return nN({decimal:c.decimals,identifier:c.identifier,value:A?a(BigInt(L),A):L})})();let W=Z?.decimal||Q;l({condition:!W&&!T,id:`assetValue_static_decimal_not_found_${X}`,warning:`Couldn't find static decimal for one or more tokens on ${X} (Using default ${K} decimal as fallback).
2
+ This can result in incorrect calculations and mess with amount sent on transactions.
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:HN,identifier:h,tax:J}=Z||{decimal:W||K,identifier:M},YN=A?a(BigInt(L),A):a(L,HN);return S||j?lT(h,YN):nN({decimal:HN,identifier:h,tax:J,value:YN})}static async loadStaticAssets(N){let{loadTokenLists:A}=await import("@swapkit/tokens"),T=await A(N,{source:b.get("envs").isDev?"dev":"prod"});for(let{tokens:H}of Object.values(T))for(let L of H){let{identifier:I}=L,{chain:O,symbol:G}=o(I),{address:M}=IN(G,O),{baseDecimal:Q}=ON(O),X=f.includes(O)?I:I.toUpperCase(),S="decimals"in L&&L.decimals!==void 0?L.decimals:Q,j="logoURI"in L&&L.logoURI?L.logoURI:`https://storage.googleapis.com/token-list-swapkit-dev/images/${I.toLowerCase()}.png`,w={decimal:S,identifier:I,logoURI:j,tax:"tax"in L?L.tax:void 0};if(s.set(X,w),M){let K=f.includes(O)?`${O}:${M}`:`${O}:${M.toUpperCase()}`;bN.set(K,I)}}return!0}static setStaticAssets(N){s.clear(),bN.clear();for(let[A,T]of N.entries()){let{identifier:H}=T,{chain:L,symbol:I}=o(H),{address:O}=IN(I,L),{baseDecimal:G}=ON(L),M=T.chain??L,Q=T.address??O,X=f.includes(M)?H:H.toUpperCase(),S=T.decimals??T.decimal??G,j=T.logoURI??`https://storage.googleapis.com/token-list-swapkit-dev/images/${H.toLowerCase()}.png`,w={decimal:S,identifier:X,logoURI:j,tax:T.tax};if(s.set(X,w),Q){let K=f.includes(M)?`${M}:${Q}`:`${M}:${Q.toUpperCase()}`;bN.set(K,H)}}return!0}static get staticAssets(){return s}}function hP(N){let A=n.from({chain:N});return kN(N).with(z.Bitcoin,z.Litecoin,z.BitcoinCash,z.Dash,()=>A.set(0.00010001)).with(z.Dogecoin,()=>A.set(1.00000001)).with(z.Avalanche,z.Ethereum,z.Arbitrum,z.BinanceSmartChain,()=>A.set(0.00000001)).with(z.THORChain,z.Maya,()=>A.set(0)).with(z.Cosmos,z.Kujira,()=>A.set(0.000001)).otherwise(()=>A.set(0.00000001))}async function EA({chain:N,address:A,ticker:T}){let L=f.includes(N)?`${N}:${A||T}`:`${N}:${A||T}`.toUpperCase(),I=hT(L);if(I)return I;if(!A){let{baseDecimal:M}=ON(N);return{decimals:M,identifier:`${N}.${T||"UNKNOWN"}`}}let O=await DA({address:A,chain:N}),G=`${N}.${O.ticker||T||"UNKNOWN"}-${A}`;return l({condition:!!(!O.ticker&&T),id:`async_token_lookup_failed_${N}_${A}`,warning:`Could not fetch token metadata for ${N}:${A} from chain. Using user-provided ticker (${T}) with baseDecimal (${O.decimals}).`}),O.ticker&&cT(L,{decimals:O.decimals,identifier:G}),{decimals:O.decimals,identifier:G}}function nN({identifier:N,decimal:A,value:T,tax:H}){return CT(N),new n({decimal:A,identifier:N,tax:H,value:a(T,A)})}function lT(N,A=0){let T=N.includes(".")?N.split(".")?.[0]?.toUpperCase():void 0,H=T?KN.includes(T):!1,L=N.slice(0,14).includes("~")?"~":"/",[I,O]=H?N.split(".").slice(1).join().split(L):N.split(L);if(!(I&&O))throw new U({errorKey:"helpers_invalid_asset_identifier",info:{identifier:N}});return new n({decimal:8,identifier:`${T||z.THORChain}.${I}${L}${O}`,value:a(A,8)})}async function rT({address:N,chain:A,fromBaseDecimal:T,parsedValue:H}){let{decimals:L,identifier:I}=await EA({address:N,chain:A}),O=T?a(BigInt(H),T):H;return nN({decimal:L,identifier:I,value:O})}function a(N,A){return typeof N==="bigint"?d({bigIntDecimal:A,decimal:A,value:N}):N}function iT(N){let A=kN(N).when((T)=>("chain"in T)&&T.chain!==void 0,({chain:T})=>T).otherwise((T)=>{let H=o(T.asset);return H.synth?z.THORChain:H.chain});if(!pT.includes(A.toUpperCase())){let T="asset"in N?N.asset:A;throw new U({errorKey:"helpers_invalid_asset_identifier",info:{identifier:T,message:`Unsupported chain "${A}" - use the AssetValue constructor directly`}})}}function sT(N){if(iT(N),"chain"in N){let{chain:L,address:I}=N;if(I){let O=f.includes(L)?`${L}:${I}`:`${L}:${I.toUpperCase()}`,G=bN.get(O);if(G)return G;return null}return L}let{chain:A,symbol:T}=o(N.asset);return qN({chain:A,symbol:T})==="Native"?A:N.asset}function eT(N,A,T){let H=N.split("."),L=H[0]?.toUpperCase(),I=KN.includes(L),O=T?"~":"/",[G,M=""]=I?H.slice(1).join(".").split(O):N.split(O);if(!(G&&M))throw new U({errorKey:"helpers_invalid_asset_identifier",info:{identifier:N}});let{ticker:Q,address:X}=SA({chain:G,symbol:M}),S=`${G}${O}${M}`;return{address:X,chain:L,isGasAsset:!1,isSynthetic:A,isTradeAsset:T,symbol:S,ticker:Q}}function aT(N){let A=N.indexOf("."),T=(A===-1?N:N.slice(0,A)).toUpperCase(),H=A===-1?N:N.slice(A+1),{address:L,ticker:I}=SA({chain:T,symbol:H}),O;try{O=L&&oT.includes(T)&&XN(L)?XN(L):L}catch{O=L}let G=O?`${I}-${O}`:H;return{address:O,chain:T,isGasAsset:uA({chain:T,symbol:H}),isSynthetic:!1,isTradeAsset:!1,symbol:G,ticker:I}}function UA(N){let A=N.slice(0,14),T=A.includes("/"),H=A.includes("~");if(T||H)return eT(N,T,H);return aT(N)}function SA({symbol:N,chain:A}){let{ticker:T,address:H}=IN(N,A);return{address:H&&!f.includes(A)?H.toLowerCase():H,ticker:T}}class gN extends t{eq(N){return this.eqValue(N)}static fromBigInt(N,A){return new gN({decimal:A,value:d({bigIntDecimal:A,decimal:A,value:N})})}}function bA(N=!0){return N?"https://gateway.liquify.com/chain/thorchain_midgard":"https://midgard.mayachain.info"}function AH(N=!0){let A=bA(N);return N?`${A}/v2/thorname`:`${A}/v2/mayaname`}function TH(N){return function(T){let H=T?`?status=${T}`:"";return _.get(`${N}/v2/pools${H}`)}}function HH(N){return function(T){return _.get(`${N}/v2/pool/${T}`)}}function LH(N){return function(T,H){let L=H?`?period=${H}`:"";return _.get(`${N}/v2/pool/${T}/stats${L}`)}}function PH(N){return function(T,H){let L=new URLSearchParams;if(H?.interval)L.append("interval",H.interval);if(H?.count)L.append("count",H.count.toString());if(H?.from)L.append("from",H.from.toString());if(H?.to)L.append("to",H.to.toString());let I=L.toString()?`?${L.toString()}`:"";return _.get(`${N}/v2/history/depths/${T}${I}`)}}function FH(N){return function(){return _.get(`${N}/v2/network`)}}function IH(N){return function(){return _.get(`${N}/v2/health`)}}function RH(N){return function(){return _.get(`${N}/v2/nodes`)}}function OH(N){return function(T){return _.get(`${N}/v2/node/${T}`)}}function BH(N){return function(){return _.get(`${N}/v2/mimir/votes`)}}function $H(N){return function(){return _.get(`${N}/v2/mimir`)}}function GH(N){return function(){return _.get(`${N}/v2/constants`)}}function YH(N){return function(){return _.get(`${N}/v2/stats`)}}function MH(N){return function(T){let H=new URLSearchParams;if(T?.interval)H.append("interval",T.interval);if(T?.count)H.append("count",T.count.toString());if(T?.from)H.append("from",T.from.toString());if(T?.to)H.append("to",T.to.toString());let L=H.toString()?`?${H.toString()}`:"";return _.get(`${N}/v2/history/earnings${L}`)}}function _H(N){return function(T,H){let L=new URLSearchParams;if(H?.interval)L.append("interval",H.interval);if(H?.count)L.append("count",H.count.toString());if(H?.from)L.append("from",H.from.toString());if(H?.to)L.append("to",H.to.toString());let I=L.toString()?`?${L.toString()}`:"",O=T?`/swaps/${T}`:"/swaps";return _.get(`${N}/v2/history${O}${I}`)}}function DH(N){return function(T){let H=new URLSearchParams;if(T?.interval)H.append("interval",T.interval);if(T?.count)H.append("count",T.count.toString());if(T?.from)H.append("from",T.from.toString());if(T?.to)H.append("to",T.to.toString());let L=H.toString()?`?${H.toString()}`:"";return _.get(`${N}/v2/history/tvl${L}`)}}function uH(N){if(!N)return"";let A=new URLSearchParams,T=(H,L)=>{if(L!==void 0)A.append(H,typeof L==="number"?L.toString():L)};return T("address",N.address),T("txid",N.txid),T("asset",N.asset),T("type",N.type),T("affiliate",N.affiliate),T("limit",N.limit),T("offset",N.offset),A.toString()?`?${A.toString()}`:""}function XH(N){return function(T){let H=uH(T);return _.get(`${N}/v2/actions${H}`)}}function UH(N){return function(T){return _.get(`${N}/v2/member/${T}`)}}function EH(N){return function(T){let H=T?`/${T}`:"";return _.get(`${N}/v2/members${H}`)}}function SH(N){return function(T,H){let L=H?`&asset=${H}`:"";return _.get(`${N}/v2/saver/${T}${L?`?${L.substring(1)}`:""}`)}}function bH(N){return function(T){return _.get(`${N}/v2/savers/${T}`)}}function gH(N){return function(T,H){let L=new URLSearchParams;if(H?.interval)L.append("interval",H.interval);if(H?.count)L.append("count",H.count.toString());if(H?.from)L.append("from",H.from.toString());if(H?.to)L.append("to",H.to.toString());let I=L.toString()?`?${L.toString()}`:"",O=T?`/savers/${T}`:"/savers";return _.get(`${N}/v2/history${O}${I}`)}}function wH(N){return function(T){return _.get(`${N}/v2/balance/${T}`)}}function zH(N){return async function(T){let H=(L)=>{if(L?.cause?.status===404)return;throw L};return await _.get(`${N}/lookup/${T}`,{onError:H,retry:{maxRetries:1}})}}function JH(N){return async function(T){let H=(L)=>{if(L?.cause?.status===404)return[];throw L};return await _.get(`${N}/rlookup/${T}`,{onError:H,retry:{maxRetries:1}})}}function QH(N){return async function(T){let H=(L)=>{if(L?.cause?.status===404)return[];throw L};return await _.get(`${N}/owner/${T}`,{onError:H,retry:{maxRetries:1}})}}function NN({asset:N,value:A}){return n.from({asset:N,fromBaseDecimal:NH(wN.THORChain).baseDecimal,value:A})}function ZH({liquidityPositionGetter:N,isThorchain:A}){return async function(H){let L=await N(H),I=A?"rune":"cacao";return L.pools.map((O)=>({[`${I}Pending`]:NN({asset:"THOR.RUNE",value:O.runePending}),[`${I}RegisteredAddress`]:O.runeAddress,[`${I}Withdrawn`]:NN({asset:"THOR.RUNE",value:O.runeWithdrawn}),[I]:NN({asset:"THOR.RUNE",value:O.runeAdded}),asset:NN({asset:O.pool,value:O.assetAdded}),assetPending:NN({asset:O.pool,value:O.assetPending}),assetRegisteredAddress:O.assetAddress,assetWithdrawn:NN({asset:O.pool,value:O.assetWithdrawn}),dateFirstAdded:O.dateFirstAdded,dateLastAdded:O.dateLastAdded,poolShare:new gN(O.liquidityUnits).div(O.pool)}))}}function gA(N){let A=N===wN.THORChain,T=bA(A),H=AH(A),L=UH(T);return{getActions:XH(T),getBalance:wH(T),getConstants:GH(T),getEarningsHistory:MH(T),getHealth:IH(T),getLiquidityPosition:ZH({isThorchain:A,liquidityPositionGetter:L}),getLiquidityPositionRaw:L,getMembers:EH(T),getMimir:$H(T),getMimirVotes:BH(T),getNameDetails:zH(H),getNamesByAddress:JH(H),getNamesByOwner:QH(H),getNetworkInfo:FH(T),getNode:OH(T),getNodes:RH(T),getPool:HH(T),getPoolDepthHistory:PH(T),getPoolStats:LH(T),getPools:TH(T),getSaverDetails:SH(T),getSavers:bH(T),getSaversHistory:gH(T),getStats:YH(T),getSwapHistory:_H(T),getTVLHistory:DH(T)}}var wA=gA(wN.THORChain),zA=gA(wN.Maya);var oN={};lN(oN,{searchTokens:()=>UL,getTrackerDetails:()=>GL,getTokenListProviders:()=>uL,getTokenList:()=>XL,getTokenApproval:()=>DL,getSwapTo:()=>ZL,getSwapQuote:()=>YL,getRouteWithTx:()=>ML,getPrice:()=>EL,getNearDepositChannel:()=>gL,getGasRate:()=>SL,getChainflipDepositChannel:()=>bL,getChainBalance:()=>_L,SKRequestClient:()=>v});import{EVMChains as pN}from"@swapkit/types";import{match as $L,P as GN}from"ts-pattern";import{Chain as zN,ChainId as BN}from"@swapkit/types";import{array as g,boolean as m,coerce as WA,number as D,object as Y,optional as $,string as F,union as mN,unknown as yN,z as P}from"zod";var jA;((H)=>{H.CHEAPEST="CHEAPEST";H.FASTEST="FASTEST";H.RECOMMENDED="RECOMMENDED"})(jA||={});var JN;((X)=>{X.PSBT="PSBT";X.EVM="EVM";X.COSMOS="COSMOS";X.RADIX="RADIX";X.NEAR="NEAR";X.STELLAR="STELLAR";X.TON="TON";X.TRON="TRON";X.EIP_712_HYPE_SEND_ASSET="EIP_712_HYPE_SEND_ASSET";X.EIP_712_HYPE_WITHDRAW="EIP_712_HYPE_WITHDRAW"})(JN||={});var VA;((W)=>{W.approve="approve";W.claim="claim";W.deposit="deposit";W.donate="donate";W.lending="lending";W.lp_action="lp_action";W.native_contract_call="native_contract_call";W.native_send="native_send";W.stake="stake";W.streaming_swap="streaming_swap";W.swap="swap";W.thorname_action="thorname_action";W.token_contract_call="token_contract_call";W.token_transfer="token_transfer";W.unknown="unknown";W.unstake="unstake"})(VA||={});var xA;((w)=>{w.swap="swap";w.aggregation="aggregation";w.addLiquidity="addLiquidity";w.withdrawLiquidity="withdrawLiquidity";w.addSavers="addSavers";w.withdrawSavers="withdrawSavers";w.borrow="borrow";w.repay="repay";w.name="name";w.donate="donate";w.claim="claim";w.stake="stake";w.unstake="unstake"})(xA||={});var qA;((G)=>{G.unknown="unknown";G.not_started="not_started";G.pending="pending";G.swapping="swapping";G.completed="completed";G.refunded="refunded";G.failed="failed"})(qA||={});var vA;((Z)=>{Z.not_started="not_started";Z.starting="starting";Z.broadcasted="broadcasted";Z.mempool="mempool";Z.inbound="inbound";Z.outbound="outbound";Z.swapping="swapping";Z.completed="completed";Z.refunded="refunded";Z.partially_refunded="partially_refunded";Z.dropped="dropped";Z.reverted="reverted";Z.replaced="replaced";Z.retries_exceeded="retries_exceeded";Z.parsing_error="parsing_error"})(vA||={});var LF=Y({address:$(F()),chain:P.enum(zN).optional(),chainId:P.enum(BN),coingeckoId:$(F()),decimals:WA.number(),extensions:$(P.looseObject({})),identifier:F(),logoURI:$(F()),name:$(F()),shortCode:$(F()),symbol:$(F()),ticker:F()}),PF=P.object({block:P.optional(P.number().describe("Block number. Required for Polkadot chain. e.g. `123456`")),chainId:P.optional(P.string().describe("ChainId for the hash. e.g. `thorchain-1`")),depositChannelId:P.optional(P.string().describe("Deposit channel ID, required for Chainflip if tx was broadcasted without wallet connection")),hash:P.optional(P.string().describe("Hash for the first transaction broadcasted by the end user. e.g. `88D1819378ECD09E5284C54937CDC1E99B52F253C007617A02DD1200710CE677`"))}).refine((N)=>N.hash&&N.chainId||N.depositChannelId,{message:"Either `hash` and `chainId` or `depositChannelId` must be provided"}),FF=P.object({forceUpdate:P.string().toLowerCase().transform((N)=>N==="true").pipe(P.boolean()).optional()}),IF=Y({error:F(),message:F()}),AN=Y({address:$(F()),chain:P.enum(zN),decimal:$(D()),isGasAsset:m(),isSynthetic:m(),symbol:F(),tax:$(Y({buy:D(),sell:D()})),ticker:F()}),nA=Y({id:F(),market_cap:D(),name:F(),price_change_24h_usd:D(),price_change_percentage_24h_usd:D(),sparkline_in_7d:g(D()),timestamp:F(),total_volume:D()}).partial(),RF=Y({cg:$(nA),identifier:F(),price_usd:D(),provider:F(),timestamp:D()}),kA=g(Y({cg:$(nA),identifier:F(),price_usd:D(),provider:F(),timestamp:D()}).partial()),OF=Y({affiliate:$(F().describe("Affiliate thorname")),affiliateFee:$(D().describe("Affiliate fee in basis points").refine((N)=>N===Math.floor(N)&&N>=0,{message:"affiliateFee must be a positive integer",path:["affiliateFee"]})),allowSmartContractReceiver:$(m().describe("Allow smart contract as recipient")),allowSmartContractSender:$(m().describe("Allow smart contract as sender")),buyAsset:F().describe("Asset to buy"),cfBoost:$(m().describe("Set to true to enable CF boost to speed up Chainflip swaps. BTC only.")),destinationAddress:$(F().describe("Address to send asset to")),disableSecurityChecks:$(m().describe("Disable security checks")),includeTx:$(m().describe("Set to true to include an transaction object (EVM only)")),providers:$(g(F().describe("List of providers to use").refine((N)=>V[N]!==void 0,{message:"Invalid provider",path:["providers"]}))),referrer:$(F().describe("Referrer address (referral program)")),sellAmount:F().describe("Amount of asset to sell").refine((N)=>+N>0,{message:"sellAmount must be greater than 0",path:["sellAmount"]}),sellAsset:F().describe("Asset to sell"),slippage:$(D().describe("Slippage tolerance as a percentage. Default is 3%.")),sourceAddress:$(F().describe("Address to send asset from"))}).refine((N)=>N.sellAsset!==N.buyAsset,{message:"Must be different",path:["sellAsset","buyAsset"]}),BF=Y({metadata:m(),tokens:g(Y({identifier:F()}))}),KA=Y({destinationAddress:F()}),WH=KA.extend({affiliateFees:g(Y({brokerAddress:F(),feeBps:D()})).optional(),brokerCommissionBps:D().optional(),buyAsset:Y({asset:F(),chain:F()}),channelMetadata:Y({cfParameters:F().optional(),gasBudget:F().optional(),message:F().optional()}).optional(),dcaParameters:Y({chunkInterval:D().optional(),numberOfChunks:D().optional()}).optional(),maxBoostFeeBps:D().optional(),refundParameters:Y({minPrice:F().optional(),refundAddress:F().optional(),retryDuration:D().optional()}).optional(),sellAsset:Y({asset:F(),chain:F()})}),mA=Y({channelId:F(),depositAddress:F()}),JA=KA.extend({affiliateFees:Y({feeBps:D(),nearId:F()}).optional(),buyAsset:F(),sellAmount:F(),sellAsset:F(),slippage:WA.number(),sourceAddress:F()}),QA=Y({amountIn:F(),amountInFormatted:F(),amountInUsd:F(),amountOut:F(),amountOutFormatted:F(),amountOutUsd:F(),deadline:F().optional(),minAmountIn:F(),minAmountOut:F(),timeEstimate:D().optional(),timeWhenInactive:F().optional()}),$F=QA.extend({depositAddress:F(),quote:QA,signature:F(),timestamp:F(),tx:yN()}),yA=Y({buyAsset:F(),buyAssetAmount:F(),buyAssetAmountMaxSlippage:F(),deadline:F().optional(),depositAddress:F(),depositAmount:F(),depositAsset:F(),tx:yN()}),jH=Y({evmCalldata:P.optional(P.string()),intentHash:P.optional(P.string()),logs:P.optional(P.unknown()),manifest:P.optional(P.unknown()),memo:P.optional(P.string()),spender:P.optional(P.string()),thorname:P.optional(P.string())}),VH=Y({currentStage:F(),inboundConfirmation:D(),inboundObservation:D(),outboundDelay:D(),outboundObservation:D(),streamingSwap:D()}),xH=Y({count:$(D()),interval:$(D()),quantity:$(D()),subSwapsMap:$(g(D()))}),qH=P.object({currentLegIndex:P.optional(P.number()),estimatedTimeToComplete:P.number(),estimates:P.optional(VH),providerDetails:P.optional(P.object({streamingDetails:P.optional(xH)}))}),vH=Y({affiliate:$(AN),liquidity:$(AN),network:$(AN),protocol:$(AN),tax:$(AN)}),nH=Y({affiliate:F(),bps:F(),isReferrer:m()}),kH=Y({affiliate:$(F()),affiliateFees:$(g(nH)),broadcastedAt:$(D()),explorerUrl:$(F()),fees:$(vH),images:$(Y({chain:$(F()),from:$(F()),provider:$(F()),to:$(F())})),provider:$(P.enum(V)),providerAction:P.optional(P.enum(xA)),quoteId:$(F()),wallet:$(F())}),TN=P.object({block:P.number(),chainId:P.enum(BN),finalAddress:P.optional(P.string()),finalAsset:P.optional(AN),finalisedAt:P.number(),fromAddress:P.string(),fromAmount:P.string(),fromAsset:P.string(),hash:P.string(),meta:P.optional(kH),payload:P.optional(jH),status:P.enum(qA),toAddress:P.string(),toAmount:P.string(),toAsset:P.string(),trackingStatus:P.optional(P.enum(vA)),transient:P.optional(qH),type:P.enum(VA)}),tA=TN.extend({legs:P.array(TN)}),GF=TN.extend({legs:g(TN)}),YF=TN.extend({legs:g(TN)}),tN=g(Y({amount:F(),asset:F(),chain:F(),protocol:P.enum(V),type:P.enum(WN)})),fN=P.object({inbound:P.optional(P.number().describe("Time to receive inbound asset in seconds")),outbound:P.optional(P.number().describe("Time to receive outbound asset in seconds")),swap:P.optional(P.number().describe("Time to swap assets in seconds")),total:P.number().describe("Total time in seconds")}),KH=/^(?:0x[0-9a-fA-F]+|[0-9]+)$/;function mH(N){return N===""||KH.test(N)}function MF(N){return N?BigInt(N):0n}function _F(N){let A=typeof N==="bigint"?N:BigInt(N);return A>0n?`0x${A.toString(16)}`:"0x0"}var $N=F().refine(mH,{message:"Value must be a base-10 integer string or 0x-prefixed hex integer string"}).describe("Value to send in base units as a base-10 integer string or 0x-prefixed hex integer string"),yH=Y({data:F().describe("Data to send"),from:F().describe("Address of the sender"),to:F().describe("Address of the recipient"),value:$N}),tH=P.object({data:P.string().optional(),raw_data:P.object({contract:P.any(),data:P.string().optional(),expiration:P.number(),fee_limit:P.number().optional(),ref_block_bytes:P.string(),ref_block_hash:P.string(),timestamp:P.number()}).passthrough(),raw_data_hex:P.string(),txID:P.string(),value:$N.optional(),visible:P.boolean()}),fH=g(mN([F(),D(),g(F()),Y({from:F(),value:$N}).describe("Parameters to pass to the contract method")])),DF=Y({approvalSpender:$(F().describe("Address of the spender to approve")),approvalToken:$(F().describe("Address of the token to approve spending of")),contractAddress:F().describe("Address of the contract to interact with"),contractMethod:F().describe("Name of the method to call"),contractParamNames:g(F().describe("Names of the parameters to pass to the contract method")),contractParams:fH}),pH=Y({typeUrl:F("/types.MsgDeposit"),value:Y({coins:g(Y({amount:F(),asset:Y({chain:F(),symbol:F(),synth:m(),ticker:F()})})),memo:F(),signer:F()})}),oH=Y({typeUrl:F("/types.MsgSend"),value:Y({amount:g(Y({amount:F(),denom:F()})),fromAddress:F(),toAddress:F()})}),CH=Y({typeUrl:F(),value:oH.shape.value.or(pH.shape.value)}),dH=Y({amount:g(Y({amount:F(),denom:F()})),gas:F()}),hH=Y({accountNumber:D(),chainId:P.enum(BN),fee:dH,memo:F(),msgs:g(CH),sequence:D()}),cH=P.array(P.object({calldata:P.array(P.string()),contractAddress:P.string(),entrypoint:P.string()})),lH=P.object({address:P.string().describe("Destination address in friendly format"),amount:P.string().describe("Amount in nanotons"),payload:P.string().optional().describe("Base64 BOC of body cell"),stateInit:P.string().optional().describe("Base64 BOC of state init")}),rH=P.object({messages:P.array(lH),sendMode:P.number().describe("TON wallet send mode for the whole transfer")}),uF="USDC:0x6d1e7cde53ba9467b783cb7c530ce054",iH=P.looseObject({domain:P.looseObject({chainId:$(mN([D(),F()])),name:$(F()),verifyingContract:$(F()),version:$(F())}),message:P.record(F(),yN()),primaryType:F(),types:P.record(F(),g(P.looseObject({name:F(),type:F()})))}),sH=P.looseObject({amount:F(),destination:F(),destinationDex:F(),fromSubAccount:F(),hyperliquidChain:F(),nonce:D().int(),signatureChainId:F(),sourceDex:F(),token:F(),type:P.literal("sendAsset")}),fA=P.looseObject({action:P.looseObject({type:F()}),submitTo:F(),typedData:iH}),XF=fA.extend({action:sH}),pA=mN([yH,hH,tH,rH,fA,F()]),eH=pA.or(cH),aH=Y({affiliate:F().describe("Affiliate address").optional(),affiliateFee:D().describe("Affiliate fee").optional(),buyAsset:F().describe("Asset to buy"),destinationAddress:F().describe("Destination address"),estimatedTime:fN.optional(),provider:P.enum(V),sellAsset:F().describe("Asset to sell"),slipPercentage:D().describe("Slippage as a percentage"),sourceAddress:F().describe("Source address")}),UF=aH.omit({destinationAddress:!0,slipPercentage:!0,sourceAddress:!0}),NL=Y({asset:F().describe("Asset name"),image:F().describe("Asset image"),price:D().describe("Price in USD")}),AL=WH,oA=Y({assets:$(g(NL)),maxStreamingQuantity:D().optional(),referrer:F().optional(),streamingInterval:D().optional(),tags:g(P.enum(jA))}),CA=oA.extend({affiliate:$(F()),affiliateFee:$(F()),approvalAddress:$(F().describe("Approval address for swap")),chainflip:AL.optional(),garden:JA.optional(),near:JA.optional(),priceImpact:$(D().describe("Price impact")),referrer:$(F()),txType:$(P.enum(JN))}),dA=g(Y({code:P.enum(ZN),display:F(),tooltip:F().optional()})),TL=Y({buyAmount:F().describe("Buy amount"),buyAmountMaxSlippage:F().describe("Buy amount max slippage"),buyAsset:F().describe("Asset to buy"),fees:$(tN),provider:P.enum(V),sellAmount:F().describe("Sell amount"),sellAsset:F().describe("Asset to sell")}),HL=Y({buyAsset:F().describe("Asset to buy"),destinationAddress:$(F().describe("Destination address")),estimatedTime:$(fN),expectedBuyAmount:F().describe("Expected Buy amount"),expectedBuyAmountMaxSlippage:F().describe("Expected Buy amount max slippage"),expiration:$(F().describe("Expiration")),fees:tN,inboundAddress:$(F().describe("Inbound address")),legs:g(TL),memo:$(F().describe("Memo")),meta:CA,providers:g(P.enum(V)),routeId:F().describe("Route ID"),sellAmount:F().describe("Sell amount"),sellAsset:F().describe("Asset to sell"),sourceAddress:$(F().describe("Source address")),targetAddress:$(F().describe("Target address")),totalSlippageBps:D().describe("Total slippage in bps"),tx:$(eH),txType:$(P.enum(JN)),warnings:dA}),hA=Y({error:$(F().describe("Error message")),providerErrors:$(g(Y({errorCode:$(P.enum(PN)),message:$(F()),provider:P.enum(V).optional()}))),quoteId:F().describe("Quote ID"),routes:g(HL)}),cA=P.object({chainId:P.enum(BN),createdAt:P.date(),id:P.number(),unit:P.string(),value:P.string()}),LL=P.array(cA),lA=P.union([cA,LL]),EF=g(Y({chain:P.enum(zN),decimal:D(),identifier:F(),symbol:F(),ticker:F(),value:F()})),SF=P.union([P.object({amount:P.string(),spender:P.string(),tokenIdentifier:P.string(),userWalletAddress:P.string()}),P.object({amount:P.string(),chainId:P.enum(BN),spender:P.string(),tokenContractAddress:P.string(),userWalletAddress:P.string()}),P.object({routeId:P.string()})]),bF=P.object({approvalTransaction:P.optional(P.object({data:P.string(),from:P.string(),gasLimit:P.optional(P.string()),gasPrice:P.optional(P.string()),to:P.string(),value:$N})),approvedAmount:P.string(),isApproved:P.boolean()}),PL=P.object({data:P.string().describe("Encoded approval call data"),from:P.string().describe("User wallet address"),gasLimit:P.string().optional().describe("Estimated gas limit"),gasPrice:P.string().optional().describe("Current gas price"),to:P.string().describe("Token contract address"),value:$N.describe("ETH value (always '0' for approvals)")}),FL=P.object({tx:P.string(),txType:P.literal("STELLAR")}),IL=P.union([PL,FL]),ZA=P.object({buyAmount:P.string().describe("Buy amount").optional(),buyAmountMaxSlippage:P.string().describe("Buy amount max slippage").optional(),buyAsset:P.string().describe("Asset to buy"),expectedBuyAmount:P.string().describe("Expected Buy amount").optional(),expectedBuyAmountMaxSlippage:P.string().describe("Expected Buy amount max slippage").optional(),fees:tN,provider:P.enum(V),sellAmount:P.string().describe("Sell amount"),sellAsset:P.string().describe("Asset to sell")}),rA=ZA.extend({estimatedTime:P.optional(fN),expiration:P.optional(P.string().describe("Expiration")),legs:P.array(ZA),providers:P.array(P.enum(V)),routeId:P.string().describe("Route ID"),totalSlippageBps:P.number().describe("Total slippage in bps"),warnings:dA}).omit({provider:!0}),iA=P.object({method:P.string(),payload:P.optional(P.unknown()),url:P.string()}),RL=rA.extend({meta:oA,nextActions:P.optional(P.array(iA))}),gF=P.object({error:P.optional(P.string().describe("Error message")),providerErrors:P.optional(P.array(P.object({errorCode:P.optional(P.enum(PN)),message:P.optional(P.string()),provider:P.enum(V).optional()}))),quoteId:P.string().describe("Quote ID"),routes:P.array(RL)}),wF=P.object({providers:P.array(P.enum(V)).optional().describe("Optional list of providers to query for trading pairs"),sellAsset:P.string().describe("Asset identifier to sell (e.g., 'BTC.BTC' or 'ETH.ETH')")}),OL=P.object({chain:P.enum(zN).describe("Chain the asset is on"),identifier:P.string().describe("Asset identifier (e.g., 'ETH.USDC-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')"),providers:P.array(P.enum(V)).describe("Providers that support this trading pair"),symbol:P.string().describe("Asset symbol"),ticker:P.string().describe("Asset ticker")}),zF=P.object({buyAssets:P.array(OL).describe("List of assets that can be swapped to"),sellAsset:P.string().describe("The input sell asset identifier")}),sA=rA.extend({destinationAddress:P.string().describe("Destination address"),inboundAddress:P.optional(P.string().describe("Inbound address")),memo:P.optional(P.string().describe("Memo to include in the transaction")),meta:CA,sourceAddress:P.string().describe("Source address"),targetAddress:P.optional(P.string().describe("Target address")),tx:$(pA),txType:P.optional(P.enum(JN))}),BL=P.object({data:P.optional(P.record(P.string(),P.string().optional())),errorCode:P.enum(PN),message:P.string().optional(),provider:P.enum(V).optional()}),JF=P.object({error:P.optional(P.string().describe("Error message")),providerErrors:P.optional(P.array(BL)),quoteId:P.string().describe("Quote ID"),routes:P.array(sA)}),eA=sA.extend({approvalTx:IL.optional().describe("Optional approval transaction required before swap execution"),nextActions:P.optional(P.array(iA)),swapId:P.string().describe("The unique swap ID for tracking")});var v=_.extend({dynamicHeader:async()=>{let N=b.get("widgetId"),A=b.get("widgetKey");if(N&&A&&typeof window<"u"){let H=Math.floor(Date.now()/1000),L=window.location.origin,I=await AA(A,N,L,H);return{Origin:L,"X-Signature":I,"X-Timestamp":H.toString(),"x-widget-id":N}}let{swapKit:T}=b.get("apiKeys");return T?{"x-api-key":T}:{}}});async function GL(N){let A=await v.post(q("/track"),{json:N});try{let T=tA.safeParse(A);if(!T.success)throw new U("api_v2_invalid_response",T.error);return T.data}catch(T){return A}}async function YL(N){let{getQuote:A}=b.get("endpoints");if(A)return A(N);let H=b.get("v3SwapFlow")?.enabled?"/v3/quote":"/quote",L=await v.post(q(H),{json:N});if(L.error)throw new U("api_v2_server_error",{message:L.error});try{let I=hA.safeParse(L);if(!I.success)throw new U("api_v2_invalid_response",I.error);return I.data}catch{return L}}async function ML(N){let{getRouteWithTx:A}=b.get("endpoints");if(A)return A(N);let H=b.get("v3SwapFlow")?.enabled?"/v3/swap":"/swap",L=await v.post(q(H),{json:N});try{let I=eA.safeParse(L);if(!I.success)throw new U("api_v2_invalid_response",I.error);return I.data}catch(I){return console.error(new U("api_v2_invalid_response",I)),L}}async function _L({chain:N,address:A,scamFilter:T=!0}){let{getBalance:H}=b.get("endpoints");if(H)return H({address:A,chain:N});let L=q(`/balance?chain=${N}&address=${A}`),I=await v.get(L),O=Array.isArray(I)?I:[];return T?QL(O):O}function DL(N){let A=$L(N).with({routeId:GN.string,spender:GN.string},({routeId:T,spender:H})=>q(`/approve?routeId=${T}&sourceAddress=${H}`)).with({assetValue:GN.instanceOf(n),spender:GN.string,userWallet:GN.string},({spender:T,userWallet:H,assetValue:L})=>q(`/approve?tokenIdentifier=${L.toString()}&userWalletAddress=${H}&spender=${T}&amount=${L.getValue("string")}`)).exhaustive();return v.get(A)}function uL(){let N=q("/providers");return v.get(N)}function XL(N){let A=q(`/tokens?provider=${N}`);return v.get(A)}function UL({query:N,chain:A,page:T,limit:H}){let L=new URLSearchParams({query:N});if(A!==void 0)L.set("chain",A);if(T!==void 0)L.set("page",T.toString());if(H!==void 0)L.set("limit",H.toString());let I=q(`/tokens/search?${L.toString()}`);return v.get(I)}async function EL(N){let A=q("/price"),T=await v.post(A,{json:N});try{let H=kA.safeParse(T);if(!H.success)throw new U("api_v2_invalid_response",H.error);return H.data}catch(H){throw new U("api_v2_invalid_response",H)}}async function SL(){let N=q("/gas"),A=await v.get(N);try{let T=lA.safeParse(A);if(!T.success)throw new U("api_v2_invalid_response",T.error);return Array.isArray(T)?T:[T]}catch(T){throw new U("api_v2_invalid_response",T)}}async function bL(N){let{destinationAddress:A}=N;if(!A)throw new U("chainflip_broker_invalid_params");let T=b.get("integrations").chainflip?.brokerUrl||q("/chainflip/broker/channel"),H=await v.post(T,{json:N});try{let L=mA.safeParse(H);if(!L.success)throw new U("api_v2_invalid_response",L.error);return L.data}catch(L){throw new U("api_v2_invalid_response",L)}}async function gL(N){let{destinationAddress:A}=N;if(!A)throw new U("chainflip_broker_invalid_params");let T=q("/near/channel"),H=await v.post(T,{json:N});try{let L=yA.safeParse(H);if(!L.success)throw new U("api_v2_invalid_response",L.error);return L.data}catch(L){throw new U("api_v2_invalid_response",L)}}function q(N){let{isDev:A,apiUrl:T,devApiUrl:H}=b.get("envs"),{enabled:L,quoteUrl:I,swapUrl:O}=b.get("localMode");if(L&&N){let[M]=N.split("?");if(M==="/quote"||M==="/v3/quote")return`${I}${N}`;if(M==="/swap"||M==="/v3/swap")return`${O}${N}`}return`${A?H:T}${N}`}function wL(N){try{return n.from({asset:N.identifier})}catch{return}}var zL=new Set(["OP.OP"]),JL=/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/im;function QL(N){return N.filter((A)=>{let T=wL(A);if(!T)return!1;if(zL.has(T.toString().toUpperCase()))return!0;return(!pN.includes(T.chain)||T.isGasAsset||!!T.address)&&!JL.test(T.ticker)})}async function ZL(N){let{getSwapTo:A}=b.get("endpoints");if(A)return A(N);let T=new URLSearchParams({sellAsset:N.sellAsset});if(N.providers?.length)for(let O of N.providers)T.append("providers",O);let H=q(`/swapTo?${T.toString()}`),L=await v.get(H);if(!Array.isArray(L))return{buyAssets:[],sellAsset:N.sellAsset};let I=[];for(let O of L)try{let G=n.from({asset:O});I.push({chain:G.chain,identifier:G.toString(),providers:[],symbol:G.symbol,ticker:G.ticker})}catch{}return{buyAssets:I,sellAsset:N.sellAsset}}var CN={};lN(CN,{getThorchainQueue:()=>xL,getTcyStakers:()=>tL,getTcyStaker:()=>yL,getTcyClaimers:()=>pL,getTcyClaimer:()=>fL,getTNSPreferredAsset:()=>kL,getTHORNodeTNSDetails:()=>aA,getRunePoolProviderInfo:()=>mL,getRunePoolInfo:()=>KL,getNodes:()=>qL,getMimirInfo:()=>vL,getLastBlock:()=>VL,getInboundAddresses:()=>nL});import{match as WL}from"ts-pattern";function k(N){let{isStagenet:A}=b.get("envs"),T=b.get("thornodeUrls");return`${WL({isStagenet:A,type:N}).with({type:"mayachain"},({isStagenet:L})=>L?T.MAYA_STAGENET:T.MAYA).otherwise(({isStagenet:L})=>L?T.THOR_STAGENET:T.THOR)}/${N??"thorchain"}`}function jL(N){let A=N==="mayachain"?"mayaname":"thorname";return`${k(N)}/${A}`}function VL(N="thorchain"){return _.get(`${k(N)}/lastblock`)}function xL(N){return _.get(`${k(N)}/queue`)}function qL(N){return _.get(`${k(N)}/nodes`)}function vL(N){return _.get(`${k(N)}/mimir`)}function nL(N){return _.get(`${k(N)}/inbound_addresses`)}async function aA({type:N,name:A}){try{return await _.get(`${jL(N)}/${A}`)}catch{return{affiliate_collector_rune:"",aliases:[],expire_block_height:0,name:A,owner:"",preferred_asset:""}}}async function kL({type:N,tns:A}){let T=await aA({name:A,type:N});if(!T.preferred_asset||T.preferred_asset===".")return;return n.from({asset:T.preferred_asset,asyncTokenLookup:!0})}function KL(N){return _.get(`${k(N)}/runepool`)}function mL({type:N,thorAddress:A}){return _.get(`${k(N)}/rune_provider/${A}`)}function yL({type:N,address:A}){return _.get(`${k(N)}/tcy_staker/${A}`)}function tL(N){return _.get(`${k(N)}/tcy_stakers`)}function fL({type:N,address:A}){return _.get(`${k(N)}/tcy_claimer/${A}`)}function pL(N){return _.get(`${k(N)}/tcy_claimers`)}var tF={...oN,mayachainMidgard:zA,thorchainMidgard:wA,thornode:CN};
5
+ export{dL as a,PN as b,ZN as c,V as d,WN as e,FT as f,IT as g,RT as h,jN as i,OT as j,x as k,b as l,U as m,_ as n,AA as o,$P as p,l as q,xN as r,QT as s,r as t,XP as u,UP as v,EP as w,SP as x,xP as y,vT as z,_A as A,DA as B,uA as C,UN as D,qN as E,o as F,IN as G,qP as H,vP as I,d as J,t as K,CT as L,n as M,hP as N,gN as O,jA as P,JN as Q,VA as R,xA as S,qA as T,vA as U,LF as V,PF as W,FF as X,IF as Y,AN as Z,nA as _,RF as $,kA as aa,OF as ba,BF as ca,KA as da,WH as ea,mA as fa,JA as ga,$F as ha,yA as ia,tA as ja,GF as ka,YF as la,tN as ma,fN as na,mH as oa,MF as pa,_F as qa,yH as ra,tH as sa,fH as ta,DF as ua,hH as va,cH as wa,lH as xa,rH as ya,uF as za,iH as Aa,sH as Ba,fA as Ca,XF as Da,aH as Ea,UF as Fa,NL as Ga,AL as Ha,oA as Ia,CA as Ja,dA as Ka,HL as La,hA as Ma,cA as Na,lA as Oa,SF as Pa,bF as Qa,PL as Ra,FL as Sa,IL as Ta,gF as Ua,wF as Va,OL as Wa,zF as Xa,sA as Ya,BL as Za,JF as _a,eA as $a,tF as ab};
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 xg,Qa as xR,R as Bg,Ra as BR,S as Mg,Sa as MR,T as Yg,Ta as YR,U as Gg,Ua as GR,V as zg,Va as zR,W as Jg,Wa as JR,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 Wg,d as Tf,da as Cg,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 wf,wa as wg,x as vf,xa as vg,y as cf,ya as cg,z as rf,za as rg}from"./chunk-8pyeeg27.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 w($="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}=w(f);return $*g/R}function G$($,f="average",g=!1){let R=I(f),x=$*R;return g?Math.floor(x):x}import{Chain as T,EVMChains as v}from"@swapkit/types";function j($,f){if("index"in f)return[...$.slice(0,$.length-1),f.index];if("change"in f){let[g,R,x,,B]=$;return[g,R,x,f.change,B]}if("account"in f){let[g,R,,x,B]=$;return[g,R,f.account,x,B]}return $}function c([$,f,g,R,x],{allHardened:B}={}){let Y=B?"'":"",G=typeof x!=="number";if(typeof R!=="number")return`m/${$}'/${f}'/${g}'`;return`m/${$}'/${f}'/${g}'/${R}${Y}${G?"":`/${x}${Y}`}`}function P$({chain:$,index:f,addressIndex:g=0,type:R}){if(v.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 x=$===T.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,x,f,0,g];case"segwit":return[49,x,0,0,f];case"legacy":return[44,x,0,0,f];default:return j(X[$],{index:f})}}function Q$($){let[f,g,R]=$.split("/").map((x)=>Number.parseInt(x,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 z,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 W$({chain:$,txHash:f}){let{explorerUrl:g}=S($);return q($).with(...r,z.Solana,()=>`${g}/tx/${f.startsWith("0x")?f.slice(2):f}`).with(...h,...o,()=>`${g}/tx/${f.startsWith("0x")?f:`0x${f}`}`).with(...u,z.Radix,z.Tron,()=>`${g}/transaction/${f.toLowerCase()}`).with(z.Near,()=>`${g}/txns/${f}`).with(z.Ripple,()=>`${g}/transactions/${f}`).with(z.Stellar,()=>`${g}/explorer/public/tx/${f}`).with(z.Sui,()=>`${g}/txblock/${f}`).with(z.Cardano,z.Hype,z.Spark,z.Ton,()=>`${g}/tx/${f}`).otherwise(()=>"")}function C$({chain:$,address:f}){let{explorerUrl:g}=S($);return q($).with(z.Solana,z.Sui,z.Radix,()=>`${g}/account/${f}`).with(z.Stellar,()=>`${g}/explorer/public/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=J($),x=J(f),B=J(g),Y=R.mul(B),G=x.mul(x).mul(2),M=x.mul(R).mul(2),L=R.mul(R),Q=x.mul(x).mul(x);return Y.mul(G.sub(M).add(L)).div(Q)}function n({liquidityUnits:$,poolUnits:f,assetDepth:g}){let R=J($),x=J(f),B=J(g),Y=R.mul(B),G=x.mul(x).mul(2),M=x.mul(R).mul(2),L=R.mul(R),Q=Y.mul(G.sub(M).add(L)),Z=x.mul(x).mul(x);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 J($){return P.fromBigInt(BigInt($),d(s.THORChain).baseDecimal)}function p({liquidityUnits:$,poolUnits:f,runeDepth:g,assetDepth:R}){return{assetAmount:J(R).mul($).div(f),runeAmount:J(g).mul($).div(f)}}function T$({liquidityUnits:$,poolUnits:f,runeDepth:g,assetDepth:R,percent:x}){return Object.fromEntries(Object.entries(p({assetDepth:R,liquidityUnits:$,poolUnits:f,runeDepth:g})).map(([B,Y])=>[B,Y.mul(x)]))}function S$({runeDepth:$,poolUnits:f,assetDepth:g,liquidityUnits:R,runeAmount:x,assetAmount:B}){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:x}),Q=new P({decimal:8,value:B}),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),C=J(R).add(H);if(H.getBaseValue("number")===0)return C.div(M).getBaseValue("number");let k=M.add(C);return C.div(k).getBaseValue("number")}function q$({runeAmount:$,assetAmount:f,runeDepth:g,assetDepth:R}){if($==="0"||f==="0"||g==="0"||R==="0")return 0;let x=J(g),B=J(R),Y=J(f),G=J($),M=Y.mul(x).sub(B.mul(G)),L=B.mul(G).add(x.mul(B));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 W("POOL+",$)}function k$({chain:$,symbol:f,address:g,...R}){let x=a({chain:$,symbol:f}),B=g?`:${g}:`:":";return W(`${"+"}:${x}${B}`,R)}function b$({chain:$,symbol:f,ticker:g,basisPoints:R,targetAsset:x}){let B=$==="ETH"&&g!=="ETH"?`${g}-${f.slice(-3)}`:f,Y=x?`:${x}`:"";return`${"-"}:${$}.${B}:${R}${Y}`}function m$({basisPoints:$,...f}){return W(`${"POOL-"}:${$}`,f)}function w$({name:$,chain:f,address:g,owner:R}){let x=`${"~"}:${$}:${f}:${g}`,B=R?`:${R}`:"";return`${x}${B}`}function v$({name:$,chain:f,asset:g,payout:R,owner:x}){return`${"~"}:${$}:${f}:${R}:${x}:${g}`}function c$($,{address:f}){return`${$}:${f}`}function r$($,{unstakeBps:f,...g}){let R=f?`:${f}`:"",x=`${$}${R}`;return W(`${x}`,g)}function W($,{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,x=window?.ethereum?.isTrust||window?.trustwallet,B=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(x)M.push("TRUSTWALLET_WEB");if(B)M.push("COINBASE_WEB");if(x$())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(x){if(!g)throw new _("helpers_failed_to_switch_network",{error:x,reason:"networkParams not provided"});await R$($,g)}}function p$({chains:$,supportedChains:f,walletType:g}){let R=$.filter((B)=>!B||f.includes(B));if(R.length===0)throw new _("wallet_chain_not_supported",{chain:$.join(", "),wallet:g});let x=$.filter((B)=>!f.includes(B));return N({condition:x.length>0,id:`wallet_chain_not_supported_${g}`,warning:`${g} wallet does not support the following chains: ${x.join(", ")}. These chains will be ignored.`}),R}function g$($,f,g){return async(...R)=>{let{chainIdHex:x}=K(g);if((await f.getNetwork()).chainId.toString()===x)return $(...R);try{await f$(f,g)}catch(B){throw new _({errorKey:"helpers_failed_to_switch_network",info:{error:B}})}return $(...R)}}function i$({toolbox:$,chain:f,provider:g,methodNames:R=[]}){let B=[...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{...$,...B}}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:x}=window?.ethereum||{};if($)return"TRUSTWALLET_WEB";if(f)return"BRAVE";if(R&&x?.isCoinbaseWallet)return"COINBASE_WEB";if(g)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function e$(){let $=[];function f(R){if($.map((x)=>x.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 x$(){let $=navigator.userAgent,f=/iphone|ipad|ipod|ios/i.test($),g=/android|XiaoMi|MiuiBrowser/i.test($),R=f||g,x=/OKApp/i.test($);return R&&x}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,Og as toHexTransactionValue,f$ as switchEVMWalletNetwork,Kf as swapKitConfigStore,fg as signWidgetRequest,A as providerRequest,i$ as prepareNetworkSwitch,Ag as parseTransactionValue,sf as parseSymbolForAddress,x$ as okxMobileEnabled,$$ as listWeb3EVMWallets,l$ as isWeb3Detected,Kg as isTransactionValue,rf as isGasAsset,n$ as isDetected,wf 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,w$ as getMemoForNameRegister,v$ as getMemoForNamePreferredAssetRegister,U$ as getMemoForLeaveAndBond,k$ as getMemoForDeposit,Uf as getMAYANameCost,q$ as getLiquiditySlippage,w as getFeeMultiplierAsBigInt,I as getFeeMultiplier,W$ as getExplorerTxUrl,C$ 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,xg as TxnType,Mg as TxnStatus,Dg 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,vg as TONTransactionSchema,wg as TONTransactionMessageSchema,BR as SwapToResponseSchema,RR as SwapToRequestSchema,xR as SwapToAssetSchema,zR as SwapRouteV2ResponseSchema,P as SwapKitNumber,_ as SwapKitError,JR as SwapKitApi,fR as SwapApprovalTransactionSchema,$R as StellarApprovalTransactionSchema,mg as StarknetTransactionSchema,E as SKConfig,dg as RouteQuoteWarningSchema,Rg as RouteQuoteTxType,YR as RouteQuoteProviderErrorSchema,sg as RouteQuoteMetadataV2Schema,ug as RouteQuoteMetadataSchema,hg as RouteQuoteMetadataAssetSchema,rg as RouteLegWithoutAddressesSchema,cg as RouteLegSchema,Af as RequestClient,gR as QuoteV3ResponseSchema,GR as QuoteV2ResponseSchema,MR as QuoteRouteV2Response,ng as QuoteResponseSchema,lg as QuoteResponseRouteItem,_g as QuoteRequestSchema,Tf as ProviderName,Bg 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,pg as GasSchema,ig as GasResponseSchema,qg as FeesSchema,Sf as FeeTypeEnum,b as FeeOption,Ng as EstimatedTimeSchema,Ef as ErrorCode,Ug as EVMTransactionSchema,kg as EVMTransactionDetailsSchema,yg as EVMTransactionDetailsParamsSchema,X$ as DerivationPath,jg as DepositChannelResponseSchema,Wg as DepositChannelParamsSchema,m as DEFAULT_FEE_MULTIPLIERS,bg as CosmosTransactionSchema,vf as CommonAssetStrings,Qg as CoinGeckoMetadataSchema,og as ChainflipMetadataSchema,Cg as BrokerDepositChannelParamsSchema,af as BigIntArithmetics,Pg as AssetValueSchema,ef as AssetValue,ag as ApproveResponseSchema,tg as ApproveRequestParams,qf as ApproveMode,eg as ApprovalTransactionSchema,Lg as ApiV2ErrorSchema};
1
+ import{$ as QJ,$a as QQ,A as TG,Aa as kJ,B as OG,Ba as TJ,C as vG,Ca as OJ,D as AG,Da as vJ,E as fG,Ea as AJ,F as yG,Fa as fJ,G as wG,Ga as yJ,H as bG,Ha as wJ,I as cG,Ia as bJ,J as hG,Ja as cJ,K as mG,Ka as hJ,L as uG,La as mJ,M as dG,Ma as uJ,N as lG,Na as dJ,O as L,Oa as lJ,P as pG,Pa as pJ,Q as oG,Qa as oJ,R as rG,Ra as rJ,S as sG,Sa as sJ,T as nG,Ta as nJ,U as iG,Ua as iJ,V as aG,Va as aJ,W as tG,Wa as tJ,X as eG,Xa as eJ,Y as zJ,Ya as zQ,Z as GJ,Za as GQ,_ as JJ,_a as JQ,a as Y,aa as ZJ,ab as ZQ,b as LG,ba as $J,c as RG,ca as XJ,d as YG,da as HJ,e as FG,ea as VJ,f as v,fa as jJ,g as xG,ga as _J,h as d,ha as BJ,i as o,ia as LJ,j as WG,ja as RJ,k as qG,ka as YJ,l as E,la as FJ,m as B,ma as xJ,n as IG,na as WJ,o as KG,oa as qJ,p as MG,pa as IJ,q as S,qa as KJ,r as EG,ra as MJ,s as NG,sa as EJ,t as PG,ta as NJ,u as SG,ua as PJ,v as CG,va as SJ,w as DG,wa as CJ,x as gG,xa as DJ,y as UG,ya as gJ,z as kG,za as UJ}from"./chunk-g60m4sgr.js";export*from"@swapkit/tokens";export*from"@swapkit/types";var A={average:1,fast:1.5,fastest:2};function N(z="average"){let G=E.get("feeMultipliers");if(G&&G[z]!==void 0)return G[z];return A[z]}function f(z="average"){let G=N(z),Q=10n,J=BigInt(Math.round(G*10));return{denominator:Q,numerator:J}}function zz(z,G="average"){let{numerator:Q,denominator:J}=f(G);return z*Q/J}function Gz(z,G="average",Q=!1){let J=N(G),Z=z*J;return Q?Math.floor(Z):Z}import{Chain as P,EVMChains as y}from"@swapkit/types";function I(z,G){if("index"in G)return[...z.slice(0,z.length-1),G.index];if("change"in G){let[Q,J,Z,,$]=z;return[Q,J,Z,G.change,$]}if("account"in G){let[Q,J,,Z,$]=z;return[Q,J,G.account,Z,$]}return z}function w([z,G,Q,J,Z],{allHardened:$}={}){let H=$?"'":"",V=typeof Z!=="number";if(typeof J!=="number")return`m/${z}'/${G}'/${Q}'`;return`m/${z}'/${G}'/${Q}'/${J}${H}${V?"":`/${Z}${H}`}`}function $z({chain:z,index:G,addressIndex:Q=0,type:J}){if(y.includes(z)){if(J&&["legacy","account"].includes(J))return[44,60,0,G];if(J==="ledgerLive")return[44,60,G,0,Q];return I(Y[z],{index:G})}if(z===P.Solana){if(J==="account")return[44,501,0,G];return I(Y[z],{index:G})}let Z=z===P.Litecoin?2:0;switch(J){case"nativeSegwitMiddleAccount":return[84,Z,G,0,Q];case"segwit":return[49,Z,0,0,G];case"legacy":return[44,Z,0,0,G];default:return I(Y[z],{index:G})}}function Xz(z){let[G,Q,J]=z.split("/").map((Z)=>Number.parseInt(Z,10));switch(Q){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Hz=Object.keys(Y).reduce((z,G)=>{return z[G]=w(Y[G]),z},{});import{Chain as b,getChainConfig as c}from"@swapkit/types";function h({liquidityUnits:z,poolUnits:G,runeDepth:Q}){let J=j(z),Z=j(G),$=j(Q),H=J.mul($),V=Z.mul(Z).mul(2),X=Z.mul(J).mul(2),_=J.mul(J),R=Z.mul(Z).mul(Z);return H.mul(V.sub(X).add(_)).div(R)}function m({liquidityUnits:z,poolUnits:G,assetDepth:Q}){let J=j(z),Z=j(G),$=j(Q),H=J.mul($),V=Z.mul(Z).mul(2),X=Z.mul(J).mul(2),_=J.mul(J),R=H.mul(V.sub(X).add(_)),F=Z.mul(Z).mul(Z);return R.div(F)}function Bz({percent:z,runeDepth:G,liquidityUnits:Q,poolUnits:J}){return h({liquidityUnits:Q,poolUnits:J,runeDepth:G}).mul(z)}function Lz({percent:z,assetDepth:G,liquidityUnits:Q,poolUnits:J}){return m({assetDepth:G,liquidityUnits:Q,poolUnits:J}).mul(z)}function j(z){return L.fromBigInt(BigInt(z),c(b.THORChain).baseDecimal)}function u({liquidityUnits:z,poolUnits:G,runeDepth:Q,assetDepth:J}){return{assetAmount:j(J).mul(z).div(G),runeAmount:j(Q).mul(z).div(G)}}function Rz({liquidityUnits:z,poolUnits:G,runeDepth:Q,assetDepth:J,percent:Z}){return Object.fromEntries(Object.entries(u({assetDepth:J,liquidityUnits:z,poolUnits:G,runeDepth:Q})).map(([$,H])=>[$,H.mul(Z)]))}function Yz({runeDepth:z,poolUnits:G,assetDepth:Q,liquidityUnits:J,runeAmount:Z,assetAmount:$}){let H=new L({decimal:8,value:z}),V=new L({decimal:8,value:Q}),X=new L({decimal:8,value:G}),_=new L({decimal:8,value:Z}),R=new L({decimal:8,value:$}),F=_.mul(V),K=R.mul(H),g=_.mul(R),U=H.mul(V),k=X.mul(F.add(K.add(g.mul(2)))),T=F.add(K.add(U.mul(2))),M=k.div(T),q=j(J).add(M);if(M.getBaseValue("number")===0)return q.div(X).getBaseValue("number");let O=X.add(q);return q.div(O).getBaseValue("number")}function Fz({runeAmount:z,assetAmount:G,runeDepth:Q,assetDepth:J}){if(z==="0"||G==="0"||Q==="0"||J==="0")return 0;let Z=j(Q),$=j(J),H=j(G),V=j(z),X=H.mul(Z).sub($.mul(V)),_=$.mul(V).add(Z.mul($));return Math.abs(X.div(_).getBaseValue("number"))}import{Chain as x}from"@swapkit/types";import{match as l}from"ts-pattern";function Mz({type:z,address:G}){return`${z}:${G}`}function Ez({address:z,unbondAmount:G}){return`${"UNBOND"}:${z}:${G}`}function Nz(z){return W("POOL+",z)}function Pz({chain:z,symbol:G,address:Q,...J}){let Z=p({chain:z,symbol:G}),$=Q?`:${Q}:`:":";return W(`${"+"}:${Z}${$}`,J)}function Sz({chain:z,symbol:G,ticker:Q,basisPoints:J,targetAsset:Z}){let $=z==="ETH"&&Q!=="ETH"?`${Q}-${G.slice(-3)}`:G,H=Z?`:${Z}`:"";return`${"-"}:${z}.${$}:${J}${H}`}function Cz({basisPoints:z,...G}){return W(`${"POOL-"}:${z}`,G)}function Dz({name:z,chain:G,address:Q,owner:J}){let Z=`${"~"}:${z}:${G}:${Q}`,$=J?`:${J}`:"";return`${Z}${$}`}function gz({name:z,chain:G,asset:Q,payout:J,owner:Z}){return`${"~"}:${z}:${G}:${J}:${Z}:${Q}`}function Uz(z,{address:G}){return`${z}:${G}`}function kz(z,{unstakeBps:G,...Q}){let J=G?`:${G}`:"",Z=`${z}${J}`;return W(`${Z}`,Q)}function W(z,{affiliateAddress:G,affiliateBasisPoints:Q}={}){let J=`${z}${G?`:${G}:${Q||0}`:""}`;return J.endsWith(":")?J.slice(0,-1):J}function p({chain:z,symbol:G}){return l(z).with(x.Bitcoin,x.Dogecoin,x.Litecoin,()=>z.slice(0,1).toLowerCase()).with(x.BitcoinCash,()=>"c").otherwise(()=>`${z}.${G}`)}function Tz(z){if(z<0)throw new B({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:z}});return 10+z}function Oz(z){if(z<0)throw new B({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:z}});return Math.round((10+z*1.0512)*10000000000)/10000000000}function vz(z){if(z.length>30)return!1;let G=/^[a-zA-Z0-9+_-]+$/g;return!!z.match(G)}import{getChainConfig as C}from"@swapkit/types";function cz(){return typeof window.ethereum<"u"}function hz(z){return r().includes(z)}function r(){let z=window?.ethereum&&!window.ethereum?.isBraveWallet,G=window?.ctrl||window?.ethereum?.__XDEFI,Q=window?.vultisig,J=window?.ethereum?.isBraveWallet,Z=window?.ethereum?.isTrust||window?.trustwallet,$=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=window?.bitkeep?.ethereum,V=window?.$onekey?.ethereum,X=[];if(z)X.push("METAMASK");if(G)X.push("CTRL");if(Q)X.push("VULTISIG");if(J)X.push("BRAVE");if(Z)X.push("TRUSTWALLET_WEB");if($)X.push("COINBASE_WEB");if(a())X.push("OKX_MOBILE");if(H)X.push("BITGET");if(V)X.push("ONEKEY");return X}async function s(z,G,Q){let J=C(G);try{await D({method:"wallet_switchEthereumChain",params:[{chainId:J.chainIdHex}],provider:z})}catch(Z){if(!Q)throw new B("helpers_failed_to_switch_network",{error:Z,reason:"networkParams not provided"});await i(z,Q)}}function mz({chains:z,supportedChains:G,walletType:Q}){let J=z.filter(($)=>!$||G.includes($));if(J.length===0)throw new B("wallet_chain_not_supported",{chain:z.join(", "),wallet:Q});let Z=z.filter(($)=>!G.includes($));return S({condition:Z.length>0,id:`wallet_chain_not_supported_${Q}`,warning:`${Q} wallet does not support the following chains: ${Z.join(", ")}. These chains will be ignored.`}),J}function n(z,G,Q){return async(...J)=>{let{chainIdHex:Z}=C(Q);if((await G.getNetwork()).chainId.toString()===Z)return z(...J);try{await s(G,Q)}catch($){throw new B({errorKey:"helpers_failed_to_switch_network",info:{error:$}})}return z(...J)}}function uz({toolbox:z,chain:G,provider:Q,methodNames:J=[]}){let $=[...J,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((H,V)=>{if(!z[V])return H;let X=z[V];if(typeof X!=="function")return H;let _=n(X,Q,G);return{...H,[V]:_}},{});return{...z,...$}}function i(z,G){return D({method:"wallet_addEthereumChain",params:[G],provider:z})}function dz(z){window.ethereum?.on("accountsChanged",()=>z()),window.ctrl?.ethereum.on("accountsChanged",()=>z())}function lz(){let{isTrust:z,isBraveWallet:G,__XDEFI:Q,overrideIsMetaMask:J,selectedProvider:Z}=window?.ethereum||{};if(z)return"TRUSTWALLET_WEB";if(G)return"BRAVE";if(J&&Z?.isCoinbaseWallet)return"COINBASE_WEB";if(Q)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function pz(){let z=[];function G(J){if(z.map((Z)=>Z.info.uuid).includes(J.detail.info.uuid))return;z.push(J.detail)}window.addEventListener("eip6963:announceProvider",G),window.dispatchEvent(new Event("eip6963:requestProvider"));function Q(){window.removeEventListener("eip6963:announceProvider",G)}return{providers:z,removeEIP6963EventListener:Q}}function a(){let z=navigator.userAgent,G=/iphone|ipad|ipod|ios/i.test(z),Q=/android|XiaoMi|MiuiBrowser/i.test(z),J=G||Q,Z=/OKApp/i.test(z);return J&&Z}function D({provider:z,params:G,method:Q}){if(!z?.send)throw new B("helpers_not_found_provider");let J=G?Array.isArray(G)?G:[G]:[];return z.send(Q,J)}export{MG as wrapWithThrow,n as wrapMethodWithNetworkSwitch,S as warnOnce,vz as validateTNS,uG as validateIdentifier,I as updateDerivationPath,KJ as toHexTransactionValue,s as switchEVMWalletNetwork,qG as swapKitConfigStore,KG as signWidgetRequest,D as providerRequest,uz as prepareNetworkSwitch,IJ as parseTransactionValue,wG as parseSymbolForAddress,a as okxMobileEnabled,r as listWeb3EVMWallets,cz as isWeb3Detected,qJ as isTransactionValue,vG as isGasAsset,hz as isDetected,SG as initializeRPCUrlsWithFallback,Xz as getWalletFormatFor,bG as getTokenLogoURI,Tz as getTHORNameCost,Rz as getSymmetricWithdraw,u as getSymmetricPoolShare,NG as getRPCUrlSync,PG as getRPCUrl,lG as getMinAmountByChain,Sz as getMemoForWithdraw,Ez as getMemoForUnbond,kz as getMemoForTcyStake,Uz as getMemoForTcyClaim,Cz as getMemoForRunePoolWithdraw,Nz as getMemoForRunePoolDeposit,Dz as getMemoForNameRegister,gz as getMemoForNamePreferredAssetRegister,Mz as getMemoForLeaveAndBond,Pz as getMemoForDeposit,Oz as getMAYANameCost,Fz as getLiquiditySlippage,f as getFeeMultiplierAsBigInt,N as getFeeMultiplier,CG as getExplorerTxUrl,DG as getExplorerAddressUrl,Yz as getEstimatedPoolShare,lz as getETHDefaultWallet,pz as getEIP6963Wallets,$z as getDerivationPathFor,AG as getCommonAssetInfo,gG as getChainIdentifier,Bz as getAsymmetricRuneWithdrawAmount,h as getAsymmetricRuneShare,Lz as getAsymmetricAssetWithdrawAmount,m as getAsymmetricAssetShare,fG as getAssetType,hG as formatBigIntToSafeValue,cG as findAssetBy,mz as filterSupportedChains,OG as fetchTokenInfo,w as derivationPathToString,kG as decodeABIString,TG as decodeABIDynamicString,yG as assetFromString,zz as applyFeeMultiplierToBigInt,Gz as applyFeeMultiplier,i as addEVMWalletNetwork,dz as addAccountsChangedCallback,EG as _rpcCache,RG as WarningCodeEnum,o as WalletOption,rG as TxnType,nG as TxnStatus,EJ as TronTransactionSchema,YJ as TransactionSchema,FJ as TransactionDTOSchema,iG as TrackingStatus,tG as TrackingRequestSchema,eG as TrackingRequestQuerySchema,RJ as TrackerResponseSchema,aG as TokenSchema,QJ as TokenDetailsMetadataSchema,gJ as TONTransactionSchema,DJ as TONTransactionMessageSchema,eJ as SwapToResponseSchema,aJ as SwapToRequestSchema,tJ as SwapToAssetSchema,QQ as SwapRouteV2ResponseSchema,L as SwapKitNumber,B as SwapKitError,ZQ as SwapKitApi,nJ as SwapApprovalTransactionSchema,sJ as StellarApprovalTransactionSchema,CJ as StarknetTransactionSchema,E as SKConfig,hJ as RouteQuoteWarningSchema,oG as RouteQuoteTxType,GQ as RouteQuoteProviderErrorSchema,cJ as RouteQuoteMetadataV2Schema,bJ as RouteQuoteMetadataSchema,yJ as RouteQuoteMetadataAssetSchema,fJ as RouteLegWithoutAddressesSchema,AJ as RouteLegSchema,IG as RequestClient,iJ as QuoteV3ResponseSchema,JQ as QuoteV2ResponseSchema,zQ as QuoteRouteV2Response,uJ as QuoteResponseSchema,mJ as QuoteResponseRouteItem,$J as QuoteRequestSchema,YG as ProviderName,sG as ProviderAction,pG as PriorityLabel,ZJ as PriceResponseSchema,XJ as PriceRequestSchema,Y as NetworkDerivationPath,LJ as NearSwapResponseSchema,BJ as NearDepositChannelResultSchema,_J as NearDepositChannelParamsSchema,d as MemoType,WG as LedgerErrorCode,OJ as HyperCoreTypedDataTransactionSchema,vJ as HyperCoreSendAssetTransactionSchema,TJ as HyperCoreSendAssetActionSchema,kJ as HyperCoreEip712TypedDataSchema,UJ as HYPERCORE_USDC_TOKEN_ID,dJ as GasSchema,lJ as GasResponseSchema,xJ as FeesSchema,FG as FeeTypeEnum,v as FeeOption,WJ as EstimatedTimeSchema,LG as ErrorCode,MJ as EVMTransactionSchema,PJ as EVMTransactionDetailsSchema,NJ as EVMTransactionDetailsParamsSchema,Hz as DerivationPath,jJ as DepositChannelResponseSchema,HJ as DepositChannelParamsSchema,A as DEFAULT_FEE_MULTIPLIERS,SJ as CosmosTransactionSchema,UG as CommonAssetStrings,JJ as CoinGeckoMetadataSchema,wJ as ChainflipMetadataSchema,VJ as BrokerDepositChannelParamsSchema,mG as BigIntArithmetics,GJ as AssetValueSchema,dG as AssetValue,oJ as ApproveResponseSchema,pJ as ApproveRequestParams,xG as ApproveMode,rJ as ApprovalTransactionSchema,zJ as ApiV2ErrorSchema};
@@ -264,6 +264,30 @@ export declare const SwapKitApi: {
264
264
  stateInit?: string | undefined;
265
265
  }[];
266
266
  sendMode: number;
267
+ } | {
268
+ [x: string]: unknown;
269
+ action: {
270
+ [x: string]: unknown;
271
+ type: string;
272
+ };
273
+ submitTo: string;
274
+ typedData: {
275
+ [x: string]: unknown;
276
+ domain: {
277
+ [x: string]: unknown;
278
+ chainId?: string | number | undefined;
279
+ name?: string | undefined;
280
+ verifyingContract?: string | undefined;
281
+ version?: string | undefined;
282
+ };
283
+ message: Record<string, unknown>;
284
+ primaryType: string;
285
+ types: Record<string, {
286
+ [x: string]: unknown;
287
+ name: string;
288
+ type: string;
289
+ }[]>;
290
+ };
267
291
  } | {
268
292
  calldata: string[];
269
293
  contractAddress: string;
@@ -238,6 +238,30 @@ export declare function getSwapQuote(json: QuoteRequest): Promise<{
238
238
  stateInit?: string | undefined;
239
239
  }[];
240
240
  sendMode: number;
241
+ } | {
242
+ [x: string]: unknown;
243
+ action: {
244
+ [x: string]: unknown;
245
+ type: string;
246
+ };
247
+ submitTo: string;
248
+ typedData: {
249
+ [x: string]: unknown;
250
+ domain: {
251
+ [x: string]: unknown;
252
+ chainId?: string | number | undefined;
253
+ name?: string | undefined;
254
+ verifyingContract?: string | undefined;
255
+ version?: string | undefined;
256
+ };
257
+ message: Record<string, unknown>;
258
+ primaryType: string;
259
+ types: Record<string, {
260
+ [x: string]: unknown;
261
+ name: string;
262
+ type: string;
263
+ }[]>;
264
+ };
241
265
  } | {
242
266
  calldata: string[];
243
267
  contractAddress: string;