@swapkit/helpers 6.4.2 → 6.5.0

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,5 +1,19 @@
1
1
  # @swapkit/helpers
2
2
 
3
+ ## 6.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#486](https://github.com/swapkit/sdk/pull/486) [`8b15231`](https://github.com/swapkit/sdk/commit/8b15231a8af87f7cdbbd6c40e308cb01e80e6186) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Allow quote and swap requests to opt into selling the full balance of a native asset, and expose whether a route was adjusted for it
8
+ - [#489](https://github.com/swapkit/sdk/pull/489) [`3fb0f51`](https://github.com/swapkit/sdk/commit/3fb0f511c3c1a460bcc768f4dd05689786cc1a9d) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - `helpers_chain_rpc_connection_failed` now says which chain failed and why each configured RPC endpoint was rejected in its message and `info`. The reason is always one of a fixed set (an HTTP status, `timeout`, `invalid_url`, `dns_error`, `connection_refused` or `network_error`), never the raw error text, so the error stays small and carries nothing from upstream. Before, the details were passed as the error's cause, so the message only showed the error key. Endpoints are reported by origin only, so API keys in RPC URLs never reach the logs. `helpers_chain_no_public_or_set_rpc_url` also carries the chain in its message now.
9
+ - [#484](https://github.com/swapkit/sdk/pull/484) [`c03235b`](https://github.com/swapkit/sdk/commit/c03235b7a06fc3c71c67c0407a2c8c5159b4cb17) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated token lists. (via @swapkit/tokens@5.0.20)
10
+
11
+ ## 6.4.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#484](https://github.com/swapkit/sdk/pull/484) [`c03235b`](https://github.com/swapkit/sdk/commit/c03235b7a06fc3c71c67c0407a2c8c5159b4cb17) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated token lists. (via @swapkit/tokens@5.0.19)
16
+
3
17
  ## 6.4.2
4
18
 
5
19
  ### Patch Changes
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as j,$a as ka,Aa as K,Ba as L,Ca as M,Da as N,Ea as O,Fa as P,Ga as Q,Ha as R,Ia as S,Ja as T,Ka as U,La as V,Ma as W,Na as X,Oa as Y,Pa as Z,Qa as _,Ra as aa,S as a,Sa as ba,T as b,Ta as ca,U as c,Ua as da,V as d,Va as ea,W as e,Wa as fa,X as f,Xa as ga,Y as g,Ya as ha,Z as h,Za as ia,_ as i,_a as ja,aa as k,ab as la,ba as l,bb as ma,ca as m,cb as na,da as n,db as oa,ea as o,eb as pa,fa as p,fb as qa,ga as q,gb as ra,ha as r,hb as sa,ia as s,ib as ta,ja as t,jb as ua,ka as u,kb as va,la as v,lb as wa,ma as w,mb as xa,na as x,nb as ya,oa as y,ob as za,pa as z,pb as Aa,qa as A,qb as Ba,ra as B,rb as Ca,sa as C,sb as Da,ta as D,tb as Ea,ua as E,ub as Fa,va as F,vb as Ga,wa as G,wb as Ha,xa as H,xb as Ia,ya as I,za as J}from"../chunk-yd6dt60k.js";export{j as ApiV2ErrorSchema,da as ApprovalTransactionSchema,ba as ApproveRequestParams,ca as ApproveResponseSchema,k as AssetValueSchema,r as BrokerDepositChannelParamsSchema,U as ChainflipMetadataSchema,l as CoinGeckoMetadataSchema,I as CosmosTransactionSchema,q as DepositChannelParamsSchema,s as DepositChannelResponseSchema,G as EVMTransactionDetailsParamsSchema,H as EVMTransactionDetailsSchema,E as EVMTransactionSchema,A as EstimatedTimeSchema,z as FeesSchema,aa as GasResponseSchema,_ as GasSchema,M as HYPERCORE_USDC_TOKEN_ID,N as HyperCoreEip712TypedDataSchema,O as HyperCoreSendAssetActionSchema,Q as HyperCoreSendAssetTransactionSchema,P as HyperCoreTypedDataTransactionSchema,ya as LimitOrderApprovalTxSchema,ua as LimitOrderBuildRequestSchema,za as LimitOrderBuildResponseSchema,Ga as LimitOrderCancelBuildResponseSchema,Ha as LimitOrderCancelSubmitResponseSchema,Fa as LimitOrderCancelTxSchema,Ea as LimitOrderCancelTypedDataSchema,wa as LimitOrderEVMTransactionSchema,Da as LimitOrderListResponseSchema,ra as LimitOrderQuoteRequestSchema,ta as LimitOrderQuoteResponseSchema,sa as LimitOrderQuoteRouteSchema,Ca as LimitOrderSchema,oa as LimitOrderStatus,Aa as LimitOrderSubmitResponseSchema,qa as LimitOrderTokensResponseSchema,Ba as LimitOrderTxHashSchema,xa as LimitOrderTxMetaSchema,pa as LimitOrderTxType,va as LimitOrderTypedDataSchema,t as NearDepositChannelParamsSchema,u as NearDepositChannelResultSchema,v as NearSwapResponseSchema,p as PriceRequestSchema,n as PriceResponseSchema,a as PriorityLabel,d as ProviderAction,o as QuoteRequestSchema,Y as QuoteResponseRouteItem,Z as QuoteResponseSchema,ka as QuoteRouteV2Response,ma as QuoteV2ResponseSchema,ga as QuoteV3ResponseSchema,R as RouteLegSchema,S as RouteLegWithoutAddressesSchema,T as RouteQuoteMetadataAssetSchema,V as RouteQuoteMetadataSchema,W as RouteQuoteMetadataV2Schema,la as RouteQuoteProviderErrorSchema,b as RouteQuoteTxType,X as RouteQuoteWarningSchema,J as StarknetTransactionSchema,ea as StellarApprovalTransactionSchema,fa as SwapApprovalTransactionSchema,Ia as SwapKitApi,na as SwapRouteV2ResponseSchema,ia as SwapToAssetSchema,ha as SwapToRequestSchema,ja as SwapToResponseSchema,K as TONTransactionMessageSchema,L as TONTransactionSchema,m as TokenDetailsMetadataSchema,g as TokenSchema,w as TrackerResponseSchema,i as TrackingRequestQuerySchema,h as TrackingRequestSchema,f as TrackingStatus,y as TransactionDTOSchema,x as TransactionSchema,F as TronTransactionSchema,e as TxnStatus,c as TxnType,B as isTransactionValue,C as parseTransactionValue,D as toHexTransactionValue};
1
+ import{$ as j,$a as ka,Aa as K,Ba as L,Ca as M,Da as N,Ea as O,Fa as P,Ga as Q,Ha as R,Ia as S,Ja as T,Ka as U,La as V,Ma as W,Na as X,Oa as Y,Pa as Z,Qa as _,Ra as aa,S as a,Sa as ba,T as b,Ta as ca,U as c,Ua as da,V as d,Va as ea,W as e,Wa as fa,X as f,Xa as ga,Y as g,Ya as ha,Z as h,Za as ia,_ as i,_a as ja,aa as k,ab as la,ba as l,bb as ma,ca as m,cb as na,da as n,db as oa,ea as o,eb as pa,fa as p,fb as qa,ga as q,gb as ra,ha as r,hb as sa,ia as s,ib as ta,ja as t,jb as ua,ka as u,kb as va,la as v,lb as wa,ma as w,mb as xa,na as x,nb as ya,oa as y,ob as za,pa as z,pb as Aa,qa as A,qb as Ba,ra as B,rb as Ca,sa as C,sb as Da,ta as D,tb as Ea,ua as E,ub as Fa,va as F,vb as Ga,wa as G,wb as Ha,xa as H,xb as Ia,ya as I,za as J}from"../chunk-qcbm6whm.js";export{j as ApiV2ErrorSchema,da as ApprovalTransactionSchema,ba as ApproveRequestParams,ca as ApproveResponseSchema,k as AssetValueSchema,r as BrokerDepositChannelParamsSchema,U as ChainflipMetadataSchema,l as CoinGeckoMetadataSchema,I as CosmosTransactionSchema,q as DepositChannelParamsSchema,s as DepositChannelResponseSchema,G as EVMTransactionDetailsParamsSchema,H as EVMTransactionDetailsSchema,E as EVMTransactionSchema,A as EstimatedTimeSchema,z as FeesSchema,aa as GasResponseSchema,_ as GasSchema,M as HYPERCORE_USDC_TOKEN_ID,N as HyperCoreEip712TypedDataSchema,O as HyperCoreSendAssetActionSchema,Q as HyperCoreSendAssetTransactionSchema,P as HyperCoreTypedDataTransactionSchema,ya as LimitOrderApprovalTxSchema,ua as LimitOrderBuildRequestSchema,za as LimitOrderBuildResponseSchema,Ga as LimitOrderCancelBuildResponseSchema,Ha as LimitOrderCancelSubmitResponseSchema,Fa as LimitOrderCancelTxSchema,Ea as LimitOrderCancelTypedDataSchema,wa as LimitOrderEVMTransactionSchema,Da as LimitOrderListResponseSchema,ra as LimitOrderQuoteRequestSchema,ta as LimitOrderQuoteResponseSchema,sa as LimitOrderQuoteRouteSchema,Ca as LimitOrderSchema,oa as LimitOrderStatus,Aa as LimitOrderSubmitResponseSchema,qa as LimitOrderTokensResponseSchema,Ba as LimitOrderTxHashSchema,xa as LimitOrderTxMetaSchema,pa as LimitOrderTxType,va as LimitOrderTypedDataSchema,t as NearDepositChannelParamsSchema,u as NearDepositChannelResultSchema,v as NearSwapResponseSchema,p as PriceRequestSchema,n as PriceResponseSchema,a as PriorityLabel,d as ProviderAction,o as QuoteRequestSchema,Y as QuoteResponseRouteItem,Z as QuoteResponseSchema,ka as QuoteRouteV2Response,ma as QuoteV2ResponseSchema,ga as QuoteV3ResponseSchema,R as RouteLegSchema,S as RouteLegWithoutAddressesSchema,T as RouteQuoteMetadataAssetSchema,V as RouteQuoteMetadataSchema,W as RouteQuoteMetadataV2Schema,la as RouteQuoteProviderErrorSchema,b as RouteQuoteTxType,X as RouteQuoteWarningSchema,J as StarknetTransactionSchema,ea as StellarApprovalTransactionSchema,fa as SwapApprovalTransactionSchema,Ia as SwapKitApi,na as SwapRouteV2ResponseSchema,ia as SwapToAssetSchema,ha as SwapToRequestSchema,ja as SwapToResponseSchema,K as TONTransactionMessageSchema,L as TONTransactionSchema,m as TokenDetailsMetadataSchema,g as TokenSchema,w as TrackerResponseSchema,i as TrackingRequestQuerySchema,h as TrackingRequestSchema,f as TrackingStatus,y as TransactionDTOSchema,x as TransactionSchema,F as TronTransactionSchema,e as TxnStatus,c as TxnType,B as isTransactionValue,C as parseTransactionValue,D as toHexTransactionValue};
@@ -0,0 +1,5 @@
1
+ var yn=Object.defineProperty;var Sn=(e)=>e;function An(e,t){this[e]=Sn.bind(null,t)}var nt=(e,t)=>{for(var r in t)yn(e,r,{get:t[r],enumerable:!0,configurable:!0,set:An.bind(t,r)})};var rt=((e)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{Chain as Ce,getChainConfig as yr}from"@swapkit/types";import{AllChains as ar,Chain as R,EVMChains as lr,getChainConfig as ce}from"@swapkit/types";import{match as Be}from"ts-pattern";import{Chain as u,EVMChains as jn,getChainConfig as j,UTXOChains as Yn}from"@swapkit/types";import{match as le}from"ts-pattern";import{AllChains as at,Chain as ot,getChainConfig as Cn,MAYAConfig as On,THORConfig as kn}from"@swapkit/types";import{createStore as Pn}from"zustand/vanilla";import{AllChains as Tn,getChainConfig as wn}from"@swapkit/types";var Is=Object.freeze(Object.fromEntries(Tn.map((e)=>[e,Object.freeze(wn(e).networkDerivationPath)])));var oe;((l)=>{l.unknownError="unknownError";l.test_error="test_error";l.providerDetailsError="providerDetailsError";l.blockHeaderNotFound="blockHeaderNotFound";l.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";l.blockHashNotFoundAtHash="blockHashNotFoundAtHash";l.txHashMissing="txHashMissing";l.assetValueMissingInfo="assetValueMissingInfo";l.invalidAsset="invalidAsset";l.blockIsRequired="blockIsRequired";l.currentBlockHeaderNotFound="currentBlockHeaderNotFound";l.failedToRetrieveBalance="failedToRetrieveBalance";l.failedToRetrieveBlock="failedToRetrieveBlock";l.failedToRetrieveFees="failedToRetrieveFees";l.notImplementedBCH="notImplementedBCH";l.notImplementedDoge="notImplementedDoge";l.noPoolsFound="noPoolsFound";l.noVaultsFound="noVaultsFound";l.noTxFound="noTxFound";l.noInputCoinFound="noInputCoinFound";l.noBlockDataFound="noBlockDataFound";l.multipleCosmosMessages="multipleCosmosMessages";l.heightOrHashNotProvided="heightOrHashNotProvided";l.unknownDenom="unknownDenom";l.invalidBlockHeight="invalidBlockHeight";l.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";l.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";l.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";l.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";l.txMemoUndefined="txMemoUndefined";l.txMemoIncorrect="txMemoIncorrect";l.txTypeNotFound="txTypeNotFound";l.txNoMessage="txNoMessage";l.txNotFound="txNotFound";l.txReceiptNotFound="txReceiptNotFound";l.txParsingError="txParsingError";l.txLogsParsingError="txLogsParsingError";l.blockNotFound="blockNotFound";l.balanceNotFound="balanceNotFound";l.configError="configError";l.synthSwapDisallowed="synthSwapDisallowed";l.providerQuoteTimeout="providerQuoteTimeout";l.noQuoteResponse="noQuoteResponse";l.noPoolAssetsFound="noPoolAssetsFound";l.noThorchainPools="noThorchainPools";l.noMayachainPools="noMayachainPools";l.noThorchainNetworkInfo="noThorchainNetworkInfo";l.invalidAffiliateFee="invalidAffiliateFee";l.invalidBuyAssetAddress="invalidBuyAssetAddress";l.invalidSellAssetAddress="invalidSellAssetAddress";l.invalidSourceAddress="invalidSourceAddress";l.invalidDestinationAddress="invalidDestinationAddress";l.sourceAddressIsSmartContract="sourceAddressIsSmartContract";l.destinationAddressIsSmartContract="destinationAddressIsSmartContract";l.invalidChainId="invalidChainId";l.unsupportedChainId="unsupportedChainId";l.unsupportedEVMChainId="unsupportedEVMChainId";l.unsupportedMethod="unsupportedMethod";l.unsupportedProvider="unsupportedProvider";l.invalidParamsForMethod="invalidParamsForMethod";l.unsupportedAdapter="unsupportedAdapter";l.noWhitelistTokens="noWhitelistTokens";l.failedFetchGasPrice="failedFetchGasPrice";l.failedToCreateDepositChannel="failedToCreateDepositChannel";l.noProviderDetailsFound="noProviderDetailsFound";l.noTokenListsFound="noTokenListsFound";l.tokenNotFound="tokenNotFound";l.tokenPriceNotFound="tokenPriceNotFound";l.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";l.swapAmountTooSmall="swapAmountTooSmall";l.legsArrayIsEmpty="legsArrayIsEmpty";l.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";l.noBlockHeaderFound="noBlockHeaderFound";l.failedToSimulateSwap="failedToSimulateSwap";l.addressScreeningFailed="addressScreeningFailed";l.noLiquidtyProvidersFound="noLiquidtyProvidersFound";l.insufficientLiquidity="insufficientLiquidity";l.noInboundDataFound="noInbounDataFound";l.noInboundAddressesFound="noInboundAddressesFound";l.noInboundAddressFoundForChain="noInboundAddressFoundForChain";l.noLastBlocksFound="noLastBlocksFound";l.noVersionFound="noVersionFound";l.noConstantsFound="noConstantsFound";l.noMimirsFound="noMimirsFound";l.noRoutesFound="noRoutesFound";l.quoteNotFound="quoteNotFound";l.ledgerSignFailed="ledgerSignFailed";l.ledgerWrongPayload="ledgerWrongPayload";l.ledgerFetchSwapFailed="ledgerFetchSwapFailed";l.failedToFetchTx="failedToFetchTx";l.failedBuildTransactionDetails="failedBuildTransactionDetails";l.noLegsForRoute="noLegsForRoute";l.noRouterAddressFound="noRouterAddressFound";l.noAggregatorAddressFound="noAggregatorAddressFound";l.noContractInstanceFound="noContractInstanceFound";l.noContractAddressFound="noContractAddressFound";l.invalidAffiliate="invalidAffiliate";l.thornameAffiliate="thornameAffiliate";l.providerNotfound="No provider found";l.noRecordFound="No Record found";l.slippageTooLow="Slippage too low";l.tradingHalted="tradingHalted";l.noWrappedGasAsset="noWrappedGasAsset";l.aggregatorAddressNotFound="aggregatorAddressNotFound";l.routerAddressNotFound="routerAddressNotFound";l.dummyAddressNotFound="dummyAddressNotFound";l.trackerError="trackerError";l.thorchainPoolUnavailable="thorchainPoolUnavailable";l.noOhlcvDataFound="noOhlcvDataFound";l.noTradingPairs="noTradingPairs";l.noLendingAvailability="noLendingAvailability";l.lendingRepayTooSmall="lendingRepayTooSmall";l.missingState="missingState";l.ledgerSwapNotFound="ledgerSwapNotFound";l.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";l.errorEstimatingGas="errorEstimatingGas";l.apiKeyInvalid="apiKeyInvalid";l.apiKeyFailedToUpdate="apiKeyFailedToUpdate";l.apiKeyExpired="apiKeyExpired";l.unauthorized="unauthorized";l.failedToCreateMemo="failedToCreateMemo";l.radixIncorrectInstructions="radixIncorrectInstructions";l.radixTxMissedParam="radixTxMissedParam";l.radixTxMissedAccount="radixTxMissedAccount";l.radixManifestParseError="radixManifestParseError";l.radixManifestBuildError="radixManifestBuildError";l.invalidAddressForChain="invalidAddressForChain";l.riskyAddress="riskyAddress";l.noRoutesToProcess="noRoutesToProcess";l.sellAssetAmountTooSmall="sellAssetAmountTooSmall";l.missingPrivateKey="missingPrivateKey";l.noMemoPriceProtection="noMemoPriceProtection"})(oe||={});var Ee;((i)=>{i.highSlippage="highSlippage";i.highPriceImpact="highPriceImpact";i.insufficientBalance="insufficientBalance"})(Ee||={});var O;((x)=>{x.CHAINFLIP="CHAINFLIP";x.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";x.JUPITER="JUPITER";x.MAYACHAIN="MAYACHAIN";x.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";x.ONEINCH="ONEINCH";x.PANCAKESWAP="PANCAKESWAP";x.SUSHISWAP_V2="SUSHISWAP_V2";x.THORCHAIN="THORCHAIN";x.THORCHAIN_STREAMING="THORCHAIN_STREAMING";x.TRADERJOE_V2="TRADERJOE_V2";x.UNISWAP_V2="UNISWAP_V2";x.UNISWAP_V3="UNISWAP_V3";x.NEAR="NEAR";x.GARDEN="GARDEN";x.OKX="OKX";x.HARBOR="HARBOR";x.FLASHNET="FLASHNET";x.MAYAN="MAYAN";x.PACTSWAP="PACTSWAP";x.RELAY="RELAY"})(O||={});var _e;((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"})(_e||={});var xn;((i)=>{i.Average="average";i.Fast="fast";i.Fastest="fastest"})(xn||={});var Rn;((r)=>{r.Approve="approve";r.CheckOnly="checkOnly"})(Rn||={});var vn;((w)=>{w.NAME_REGISTER="~";w.BOND="BOND";w.DEPOSIT="+";w.LEAVE="LEAVE";w.UNBOND="UNBOND";w.WITHDRAW="-";w.RUNEPOOL_DEPOSIT="POOL+";w.RUNEPOOL_WITHDRAW="POOL-";w.CLAIM_TCY="tcy";w.STAKE_TCY="tcy+";w.UNSTAKE_TCY="tcy-"})(vn||={});var it={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_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_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_keystore_invalid_word_count:21903,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_evm_nonce_conflict:50218,toolbox_evm_tx_already_known:50219,toolbox_evm_typed_data_domain_mismatch:50220,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_utxo_unsupported_script_type:50315,toolbox_solana_no_signer:50401,toolbox_solana_insufficient_balance:50402,toolbox_solana_unsupported_token_program:50403,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_tron_insufficient_balance:50811,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_lightspark_missing_credentials:91301,toolbox_lightspark_invalid_invoice:91302,toolbox_lightspark_invoice_amount_mismatch:91303,toolbox_lightspark_invoice_destination_mismatch:91304,toolbox_lightspark_invoice_expired:91305,toolbox_lightspark_invoice_already_settled:91306,toolbox_lightspark_fee_limit_exceeded:91307,toolbox_lightspark_invalid_params:91308,toolbox_lightspark_api_error:91309,toolbox_lightspark_invalid_amount:91310,toolbox_lightspark_invalid_destination:91311,toolbox_lightspark_network_mismatch:91312,toolbox_lightspark_signing_key_unavailable:91313,toolbox_not_supported:59901,toolbox_fee_estimation_failed:59902,toolbox_sweep_amount_too_low:59903,toolbox_derivation_slot_unsupported:59904,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,plugin_swapkit_limit_order_invalid_build:43005,plugin_swapkit_limit_order_unsupported_sign_shape:43006,plugin_swapkit_limit_order_unsupported_cancel_shape:43007,plugin_swapkit_limit_order_wallet_cannot_sign:43008,plugin_swapkit_limit_order_no_signable_provider:43009,plugin_swapkit_limit_order_submit_failed:43010,plugin_swapkit_limit_order_cancel_submit_failed:43011,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 Le(e){return JSON.stringify(e,(t,r)=>typeof r==="bigint"?r.toString():r)}class y extends Error{static ErrorCode=it;errorKey;info;constructor(e,t){let r=typeof e==="string",i=r?e:e.errorKey,s=r?void 0:e.info,a=`${i}${s?`: ${Le(s)}`:""}`;super(a);if(Object.setPrototypeOf(this,y.prototype),this.name="SwapKitError",this.errorKey=i,this.info=s,this.cause=t,t){let d=t instanceof Error?`${t.message}${t.cause?` (${t.cause})`:""}`:Le(t);console.error(`SwapKitError [${i}]: ${d}`)}else if(s)console.error(`SwapKitError [${i}]: ${Le(s)}`)}}function Ps(e){let t=it;for(let[r,i]of Object.entries(e)){if(Object.hasOwn(t,r)){if(t[r]===i)continue;throw new y({errorKey:"helpers_invalid_params",info:{code:i,existingCode:t[r],key:r}})}let s=Object.keys(t).find((a)=>t[a]===i);if(s)throw new y({errorKey:"helpers_invalid_params",info:{code:i,existingKey:s,key:r}});t[r]=i}}var he={BITGET:"BITGET",BRAVE:"BRAVE",COINBASE_MOBILE:"COINBASE_MOBILE",COINBASE_WEB:"COINBASE_WEB",COSMOSTATION:"COSMOSTATION",EIP6963:"EIP6963",EXODUS:"EXODUS",KEEPKEY:"KEEPKEY",KEEPKEY_BEX:"KEEPKEY_BEX",KEPLR:"KEPLR",KEYSTORE:"KEYSTORE",LEDGER:"LEDGER",METAMASK:"METAMASK",OKX:"OKX",OKX_MOBILE:"OKX_MOBILE",ONEKEY:"ONEKEY",PASSKEY_WALLET:"PASSKEY_WALLET",PASSKEYS:"PASSKEYS",PETRA:"PETRA",PHANTOM:"PHANTOM",POLKADOT_JS:"POLKADOT_JS",RADIX_WALLET:"RADIX_WALLET",TALISMAN:"TALISMAN",TREZOR:"TREZOR",TRONLINK:"TRONLINK",TRUSTWALLET_WEB:"TRUSTWALLET_WEB",VULTISIG:"VULTISIG",WALLET_SELECTOR:"WALLET_SELECTOR",WALLETCONNECT:"WALLETCONNECT",XAMAN:"XAMAN"},Ne=new Set;function st(e){return Ne.add(e),()=>Ne.delete(e)}function Ns(e,t){let r=he;if(Object.hasOwn(r,e)){if(r[e]===t)return;throw new y({errorKey:"helpers_invalid_params",info:{existingValue:r[e],key:e,value:t}})}r[e]=t;for(let i of Ne)i(t)}var In;((i)=>{i[i.NoError=36864]="NoError";i[i.LockedDevice=21781]="LockedDevice";i[i.TC_NotFound=65535]="TC_NotFound"})(In||={});var Ds={BtcMessage:"btcMessage",Direct:"direct",TypedData:"typedData"};var En=at.reduce((e,t)=>(e[t]=Cn(t).rpcUrls,e),{}),Ln={[ot.THORChain]:kn.nodeUrl,[ot.Maya]:On.nodeUrl},lt={apiKeys:{blockchair:"",keepKey:"",passkeys:"",swapKit:"",walletConnectProjectId:"",xaman:""},blockchairApiUrl:"",chains:at,endpoints:{},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!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:En,thornodeUrls:Ln,v3SwapFlow:{enabled:typeof process<"u"&&process.env?.SWAPKIT_V3_SWAP_FLOW==="true"},wallets:Object.values(he),widgetId:"",widgetKey:""},L=Pn((e)=>({...lt,setApiKey:(t,r)=>e((i)=>({apiKeys:{...i.apiKeys,[t]:r}})),setConfig:(t)=>e((r)=>({apiKeys:{...r.apiKeys,...t?.apiKeys},blockchairApiUrl:t?.blockchairApiUrl||r.blockchairApiUrl,chains:r.chains.concat(t?.chains||[]),endpoints:{...r.endpoints,...t?.endpoints},envs:{...r.envs,...t?.envs},feeMultipliers:t?.feeMultipliers||r.feeMultipliers,integrations:{...r.integrations,...t?.integrations},localMode:{...r.localMode,...t?.localMode},rpcUrls:{...r.rpcUrls,...t?.rpcUrls},thornodeUrls:{...r.thornodeUrls,...t?.thornodeUrls},v3SwapFlow:{...r.v3SwapFlow,...t?.v3SwapFlow},wallets:r.wallets.concat(t?.wallets||[]),widgetId:t?.widgetId||r.widgetId,widgetKey:t?.widgetKey||r.widgetKey})),setEndpoint:(t,r)=>e((i)=>({endpoints:{...i.endpoints,[t]:r}})),setEnv:(t,r)=>e((i)=>({envs:{...i.envs,[t]:r}})),setFeeMultipliers:(t)=>e(()=>({feeMultipliers:t})),setIntegrationConfig:(t,r)=>e((i)=>({integrations:{...i.integrations,[t]:r}})),setRequestOptions:(t)=>e((r)=>({requestOptions:{retry:{...r.requestOptions.retry,...t.retry},timeoutMs:t.timeoutMs||r.requestOptions.timeoutMs}})),setRpcUrl:(t,r)=>e((i)=>({rpcUrls:{...i.rpcUrls,[t]:r}})),setThornodeUrl:(t,r)=>e((i)=>({thornodeUrls:{...i.thornodeUrls,[t]:r}})),setWidgetId:(t)=>e({widgetId:t}),setWidgetKey:(t)=>e({widgetKey:t})}));st((e)=>{L.setState((t)=>t.wallets.includes(e)?t:{wallets:[...t.wallets,e]})});var A={get:(e)=>L.getState()[e],getState:L.getState,reinitialize:()=>L.setState({...lt,wallets:Object.values(he)}),set:(e)=>L.getState().setConfig(e),setApiKey:(e,t)=>L.getState().setApiKey(e,t),setEndpoint:(e,t)=>L.getState().setEndpoint(e,t),setEnv:(e,t)=>L.getState().setEnv(e,t),setFeeMultipliers:(e)=>L.getState().setFeeMultipliers(e),setIntegrationConfig:(e,t)=>L.getState().setIntegrationConfig(e,t),setRequestOptions:(e)=>L.getState().setRequestOptions(e),setRpcUrl:(e,t)=>L.getState().setRpcUrl(e,t),setThornodeUrl:(e,t)=>L.getState().setThornodeUrl(e,t),setWidgetId:(e)=>L.getState().setWidgetId(e),setWidgetKey:(e)=>L.getState().setWidgetKey(e)};var Nn=(e)=>new Promise((t)=>setTimeout(t,e)),Dn=(e,{baseDelay:t,backoffMultiplier:r,maxDelay:i})=>Math.min(t*r**e,i);function Mn(e,t){if(e instanceof Error&&e.name==="AbortError")return!0;if(e instanceof TypeError)return!0;if(t===429)return!0;if(t&&t>=500&&t<600)return!0;return!1}var Vn=async(e,t)=>{let r=await fetch(e,t),i;try{i=await r.json()}catch{if(!r.ok)throw new y({errorKey:"helpers_invalid_response",info:{status:r.status,statusText:r.statusText}},{status:r.status,statusText:r.statusText});return{}}if(!r.ok){let a={data:i?.data,error:i?.error,message:i?.message,status:r.status};throw new y({errorKey:i?.error||"helpers_invalid_response",info:a},a)}let s=i?.routes?.length||i?.result||i?.data&&!i?.error;if(i?.error&&!s){let a={data:i.data,error:i.error,message:i.message,status:r.status};throw new y({errorKey:i.error,info:a},a)}if(i?.providerErrors?.length||i?.error&&s)console.warn("[SwapKit] Partial errors in response:",i.providerErrors||i.error);return i};function fe(e,t={}){return async function(i,s={}){let{searchParams:a,json:d,body:p,headers:m,dynamicHeader:S,retry:f,timeoutMs:w,abortController:E,onError:T,onSuccess:N,...I}={...t,...s},C=A.get("requestOptions"),Q={...C.retry,...f},ue=!!d||i.endsWith(".json"),me=Un(i,a),Ze=S?await S():{},x=Hn(ue,{...m,...Ze}),X=ue?JSON.stringify(d):p,Pe;for(let ge=0;ge<=Q.maxRetries;ge++){let et=E||new AbortController,tt=setTimeout(()=>et.abort(),w||C.timeoutMs);try{let G=await Vn(me,{...I,body:X,headers:x,method:e,signal:et.signal});return clearTimeout(tt),N?.(G)||G}catch(G){clearTimeout(tt),Pe=G;let bn=G?.cause?.status;if(ge>=Q.maxRetries||!Mn(G,bn))return T?T(G):Promise.reject(G);await Nn(Dn(ge,Q))}}return T?T(Pe):Promise.reject(Pe)}}function Hn(e,t){return{...t,...e&&{"Content-Type":"application/json"}}}function Un(e,t){let r=new URL(e);if(t)r.search=new URLSearchParams(t).toString();return r.toString()}var _={extend:(e)=>({extend:(t)=>_.extend({...e,...t}),get:fe("GET",e),post:fe("POST",e)}),get:fe("GET"),post:fe("POST")};async function dt(e,t,r,i){let s=`${t}:${r}:${i}`,a=new TextEncoder,d=await crypto.subtle.importKey("raw",a.encode(e),{hash:"SHA-256",name:"HMAC"},!1,["sign"]),p=await crypto.subtle.sign("HMAC",d,a.encode(s));return Array.from(new Uint8Array(p)).map((m)=>m.toString(16).padStart(2,"0")).join("")}import{Chain as b,CosmosChains as _t,EVMChains as ht,getChainConfig as ft,SubstrateChains as Bn,UTXOChains as bt}from"@swapkit/types";import{match as be}from"ts-pattern";function Xs(e,t){try{return e()}catch(r){if(t)throw new y(t,r);return}}var ct=new Set;function ae({condition:e,id:t,warning:r}){if(e){if(ct.has(t))return;console.warn(r),ct.add(t)}}function $n(e){return be(e).with(...ht,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...bt,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(..._t,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(b.Polkadot,b.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(b.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(b.Sui,()=>({id:1,jsonrpc:"2.0",method:"sui_getSystemState",params:[]})).with(b.Ton,()=>({id:1,jsonrpc:"2.0",method:"getMasterchainInfo",params:{}})).with(b.Aleo,b.Aptos,b.Tron,b.Radix,b.Stellar,()=>"").with(b.Hype,()=>({type:"meta"})).with(b.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(b.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).with(b.Starknet,()=>({id:1,jsonrpc:"2.0",method:"starknet_chainId",params:[]})).otherwise(()=>{throw new y("helpers_chain_not_supported",{chain:e})})}function pt(e){return be(e).with(b.Aptos,()=>"/-/healthy").with(b.Aleo,()=>"/mainnet/block/height/latest").with(b.Hype,()=>"/info").with(b.Radix,()=>"/status/network-configuration").with(b.Stellar,()=>"").with(b.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}function ut(e){if(e.ok)return{status:"up"};return{reason:`HTTP ${e.status}`,status:e.status===429?"rateLimited":"down"}}function Fn(e){if(e instanceof Error&&(e.name==="TimeoutError"||e.name==="AbortError"))return"timeout";let t=e,r=t?.code??t?.cause?.code;if(r==="ERR_INVALID_URL")return"invalid_url";if(r==="ENOTFOUND"||r==="EAI_AGAIN")return"dns_error";if(r==="ECONNREFUSED"||r==="ECONNRESET")return"connection_refused";return"network_error"}function mt(e){try{let{host:t,protocol:r}=new URL(e);return`${r}//${t}`}catch{return"invalid-url"}}async function gt(e,t){try{let r=t.startsWith("wss")?t.replace("wss","https"):t;if(e===b.Aleo||e===b.Stellar){let s=await fetch(`${r}${pt(e)}`,{cache:"no-store",method:"GET",signal:AbortSignal.timeout(3000)});return ut(s)}let i=await fetch(`${r}${pt(e)}`,{body:JSON.stringify($n(e)),cache:"no-store",headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)});return ut(i)}catch(r){return{reason:Fn(r),status:"down"}}}var De=new Map,Kn=120000;function qn(e){let[t=""]=A.get("rpcUrls")[e];if(!t)throw ae({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 ${e}.`}),new y({errorKey:"helpers_chain_no_public_or_set_rpc_url",info:{chain:e}});let r=De.get(e);if(r&&Date.now()-r.timestamp<Kn)return r.url;return De.set(e,{timestamp:Date.now(),url:t}),t}async function J(e,{allowRateLimited:t=!1}={}){let r=qn(e),[,...i]=A.get("rpcUrls")[e],s=[],a=await gt(e,r);if(a.status==="up")return r;s.push({url:mt(r),...a});let d=a.status==="rateLimited"?r:void 0;for(let p of i){let m=await gt(e,p);if(m.status==="up")return De.set(e,{timestamp:Date.now(),url:p}),p;s.push({url:mt(p),...m}),d??=m.status==="rateLimited"?p:void 0}if(t&&d)return d;throw new y({errorKey:"helpers_chain_rpc_connection_failed",info:{chain:e,failures:s}})}function io({chain:e,txHash:t}){let{explorerUrl:r}=ft(e);return be(e).with(..._t,b.Solana,()=>`${r}/tx/${t.startsWith("0x")?t.slice(2):t}`).with(...ht,...Bn,()=>`${r}/tx/${t.startsWith("0x")?t:`0x${t}`}`).with(...bt,b.Radix,b.Tron,()=>`${r}/transaction/${t.toLowerCase()}`).with(b.Near,()=>`${r}/txns/${t}`).with(b.Ripple,()=>`${r}/transactions/${t}`).with(b.Stellar,()=>`${r}/explorer/public/tx/${t}`).with(b.Sui,()=>`${r}/txblock/${t}`).with(b.Cardano,b.Hype,b.Spark,b.Ton,()=>`${r}/tx/${t}`).otherwise(()=>"")}function so({chain:e,address:t}){let{explorerUrl:r}=ft(e);return be(e).with(b.Solana,b.Sui,b.Radix,()=>`${r}/account/${t}`).with(b.Stellar,()=>`${r}/explorer/public/account/${t}`).otherwise(()=>`${r}/address/${t}`)}function oo(e){switch(e){case b.THORChain:return`${e}.RUNE`;case b.Cosmos:return`${e}.ATOM`;case b.BinanceSmartChain:return`${e}`;default:return`${e}.${e}`}}import{keccak_256 as Wn}from"@noble/hashes/sha3.js";import{bytesToHex as Gn}from"@noble/hashes/utils.js";var yt=/^(0x)?[0-9a-fA-F]{40}$/;function ye(e){if(typeof e!=="string"||!yt.test(e))throw Error(`invalid address: ${e}`);let t=e.toLowerCase().replace(/^0x/,""),r=Gn(Wn(new TextEncoder().encode(t))),i=[...t].map((a,d)=>Number.parseInt(r[d]??"0",16)>=8?a.toUpperCase():a).join(""),s=e.replace(/^0x/,"");if(/[A-F]/.test(s)&&/[a-f]/.test(s)&&s!==i)throw Error(`bad address checksum: ${e}`);return`0x${i}`}function St(e){if(typeof e!=="string"||!yt.test(e))return!1;try{return ye(e),!0}catch{return!1}}var bo=[`${u.Maya}.MAYA`,`${u.Maya}.CACAO`,`${u.Ethereum}.THOR`,`${u.Ethereum}.vTHOR`,`${u.Kujira}.USK`,`${u.Ethereum}.FLIP`,`${u.Radix}.XRD`],zn=[u.Arbitrum,u.Aurora,u.Base,u.Ethereum,u.Optimism,u.Robinhood];async function Qn(e){let{baseDecimal:t}=j(u.Radix);try{let r=await J(u.Radix),{manager:i}=await _.post(`${r}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:e}),headers:{Accept:"*/*","Content-Type":"application/json"}});return i?.divisibility?.value?.divisibility}catch(r){let i=r instanceof Error?r.message:String(r);return console.warn(`Failed to fetch Radix asset decimals for ${e}: ${i}`),t}}async function Xn(e){try{let t=await J(u.Radix);return(await _.post(`${t}/state/entity/details`,{body:JSON.stringify({addresses:[e],opt_ins:{explicit_metadata:["symbol"]}}),headers:{Accept:"*/*","Content-Type":"application/json"}})).items[0]?.explicit_metadata?.items.find((s)=>s.key==="symbol")?.value.typed.value||void 0}catch(t){let r=t instanceof Error?t.message:String(t);return console.warn(`Failed to fetch Radix asset symbol for ${e}: ${r}`),""}}async function wt({chain:e,address:t,methodHex:r,id:i}){let s=await J(e);return _.post(s,{body:JSON.stringify({id:i,jsonrpc:"2.0",method:"eth_call",params:[{data:r,to:t.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}})}function Jn(e){if(!e||e==="0x")return"UNKNOWN";try{return xt(e.replace(/^0x/,""))?.trim()||"UNKNOWN"}catch(t){return console.warn(`Failed to decode ABI string from ${e}: ${t}`),"UNKNOWN"}}function Zn(e,t){if(!e||e==="0x")return t;try{return Number(e)}catch(r){return console.warn(`Failed to decode ABI uint8 from ${e}: ${r}`),t}}async function er({chain:e,address:t}){let{baseDecimal:r}=j(e),i=t.toLowerCase();if(t===""||!i.startsWith("0x"))return r;let s=await wt({address:t,chain:e,id:2,methodHex:"0x313ce567"}).catch((d)=>(console.warn(`Could not fetch decimals for ${t} on ${e}: ${d.message}`),{result:""}));return Zn(s.result,r)}async function tr({chain:e,address:t}){let r=t.toLowerCase();if(r===""||!r.startsWith("0x"))return;let i=await wt({address:t,chain:e,id:1,methodHex:"0x95d89b41"}).catch((a)=>(console.warn(`Could not fetch symbol for ${t} on ${e}: ${a.message}`),{result:""}));return Jn(i.result)}async function At({rpcUrl:e,contractAddress:t,functionSelector:r}){return(await _.post(`${e}/wallet/triggerconstantcontract`,{body:JSON.stringify({contract_address:t,function_selector:r,owner_address:t,parameter:"",visible:!0}),headers:{accept:"application/json","content-type":"application/json"}}).catch(()=>{return}))?.constant_result?.[0]}function Tt(e){let t=e.match(/.{2}/g)?.map((r)=>Number.parseInt(r,16))??[];return new TextDecoder().decode(new Uint8Array(t))}function xt(e){return le(e).with(void 0,()=>{return}).when((t)=>t.length>=128,(t)=>{let r=Number.parseInt(t.slice(64,128),16),i=t.slice(128,128+r*2).replace(/(00)+$/,"");return i?Tt(i):void 0}).when((t)=>t.length===64,(t)=>{let r=t.replace(/(00)+$/,"");if(r.length>0&&r.length%2===0)return Tt(r);return}).otherwise(()=>{return})}function Rt({chain:e,address:t}){let{baseDecimal:r}=j(e),i={decimals:r,ticker:void 0};return le(e).with(...jn,async()=>{try{if(!St(t.replace(/^0X/,"0x")))return i;let[s,a]=await Promise.all([tr({address:t,chain:e}),er({address:t,chain:e})]);return{decimals:a,ticker:s}}catch(s){return console.warn(`Failed to fetch token info for ${t} on ${e}: ${s?.code} ${s?.message}`),i}}).with(u.Solana,async()=>{if(!t)return i;try{let s=await fetch(`https://lite-api.jup.ag/tokens/v2/search?query=${t}`);if(s.ok){let a=await s.json(),d=Array.isArray(a)?a[0]:a;if(d)return{decimals:d.decimals??r,ticker:d.symbol||void 0}}}catch(s){console.warn(`Failed to fetch Solana token info for ${t}: ${s?.code} ${s?.message}`)}return i}).with(u.Tron,async()=>{if(!t)return i;try{let s=await J(u.Tron),[a,d]=await Promise.all([At({contractAddress:t,functionSelector:"symbol()",rpcUrl:s}),At({contractAddress:t,functionSelector:"decimals()",rpcUrl:s})]),p=xt(a);return{decimals:a!==void 0&&d?Number(BigInt(`0x${d}`)):r,ticker:p}}catch(s){let a=s instanceof Error?s.message:String(s);return console.warn(`Failed to fetch Tron token info for ${t}: ${a}`),i}}).with(u.Near,async()=>{if(!t)return i;try{let s=await J(u.Near),a=await _.post(s,{body:JSON.stringify({id:"dontcare",jsonrpc:"2.0",method:"query",params:{account_id:t,args_base64:"e30=",finality:"final",method_name:"ft_metadata",request_type:"call_function"}}),headers:{accept:"application/json","content-type":"application/json"}});if(!a.result?.result)throw Error("NEAR ft_metadata returned no result");let d=JSON.parse(new TextDecoder().decode(new Uint8Array(a.result.result)));return{decimals:d?.decimals||r,ticker:d?.symbol}}catch(s){let a=s instanceof Error?s.message:String(s);return console.warn(`Failed to fetch Near token info for ${t}: ${a}`),i}}).with(u.Radix,async()=>{if(!t)return i;try{let[s,a]=await Promise.all([Xn(t),Qn(t)]);return{decimals:a,ticker:s}}catch(s){let a=s instanceof Error?s.message:String(s);return console.warn(`Failed to fetch Radix token info for ${t}: ${a}`),i}}).otherwise(async()=>i)}function Me(e){let t=j(e);return t.chain===e?t.nativeCurrency:void 0}function vt({chain:e,symbol:t}){return le(e).with(u.Gnosis,()=>t==="xDAI"||t==="XDAI").with(u.Ton,()=>t==="GRAM"||t==="TON").with(u.Radix,()=>`${e}.${t}`===Se(e).identifier).otherwise(()=>t===(Me(e)??e))}var Se=(e)=>{let{baseDecimal:t}=j(e);return le(e.toUpperCase()).with(...zn,(i)=>({decimal:t,identifier:`${i}.ETH`})).with(u.Arc,(i)=>({decimal:t,identifier:`${i}.USDC`})).with(u.THORChain,(i)=>({decimal:t,identifier:`${i}.RUNE`})).with(u.Cosmos,(i)=>({decimal:t,identifier:`${i}.ATOM`})).with(u.Maya,(i)=>({decimal:10,identifier:`${i}.CACAO`})).with(u.BinanceSmartChain,(i)=>({decimal:t,identifier:`${i}.BNB`})).with(u.Monad,(i)=>({decimal:t,identifier:`${i}.MON`})).with(u.Avalanche,(i)=>({decimal:t,identifier:`${i}.AVAX`})).with(u.Gnosis,(i)=>({decimal:t,identifier:`${i}.xDAI`})).with(u.XLayer,(i)=>({decimal:t,identifier:`${i}.OKB`})).with(u.Berachain,(i)=>({decimal:t,identifier:`${i}.BERA`})).with(u.Hyperevm,(i)=>({decimal:t,identifier:`${i}.HYPE`})).with(u.Hype,(i)=>({decimal:t,identifier:`${i}.HYPE`})).with(u.Spark,(i)=>({decimal:t,identifier:`${i}.BTC`})).with(u.Tron,(i)=>({decimal:t,identifier:`${i}.TRX`})).with(u.Ton,(i)=>({decimal:t,identifier:`${i}.GRAM`})).with(u.Solana,u.Chainflip,u.Kujira,u.Ripple,u.Polkadot,u.Near,...Yn,(i)=>({decimal:t,identifier:`${i}.${i}`})).with(u.Radix,"XRD.XRD",()=>({decimal:t,identifier:"XRD.XRD"})).with(u.Polygon,"POL.POL",()=>({decimal:t,identifier:"POL.POL"})).with("KUJI.USK",(i)=>({decimal:6,identifier:i})).with("ETH.FLIP",()=>({decimal:j(u.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:j(u.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:j(u.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(i)=>({decimal:10,identifier:i})).with("MAYA.MAYA",(i)=>({decimal:4,identifier:i})).otherwise(()=>{let i=Me(e);return{decimal:t,identifier:i?`${e}.${i}`:e}})};function Ve({chain:e,symbol:t}){if(t.includes("/"))return"Synth";if(t.includes("~"))return"Trade";return le(e).with(u.Radix,()=>t===u.Radix||`${e}.${t}`===Se(e).identifier).with(u.Ton,()=>t==="GRAM"||t==="TON").with(u.Gnosis,()=>t===u.Gnosis).otherwise(()=>t===(Me(e)??e))?"Native":e}var Y=(e)=>{let[t,...r]=e.split("."),i=e.includes("/"),s=r.join("."),a=s?.split("-"),d=a?.length?a.length===1?a[0]:a.slice(0,-1).join("-"):void 0;return{chain:t,symbol:s,synth:i,ticker:d}};function de(e,t){let i=t===u.Near?e.indexOf("-"):e.lastIndexOf("-");if(i===-1)return{address:void 0,ticker:e};return{address:e.slice(i+1),ticker:e.slice(0,i)}}function yo(e){return`https://tokens.swapkit.dev/images/${e.toLowerCase()}.png`}async function So(e){let{loadTokenLists:t}=await import("./tokens.js"),r=await t(void 0,{source:A.get("envs").isDev?"dev":"prod"}),i=Object.values(r).flatMap((a)=>a.tokens);if("identifier"in e)return i.find((a)=>a.identifier===e.identifier)?.identifier;let s=e.contract.toLowerCase();for(let a of i){let{chain:d,symbol:p}=Y(a.identifier);if(d!==e.chain)continue;let{address:m}=de(p,d);if(m?.toLowerCase()===s)return a.identifier}return}import{match as Ae}from"ts-pattern";var z=8,nr=10,rr=64;function Z({value:e,bigIntDecimal:t=z,decimal:r=z}){if(r===0)return e.toString();let i=Math.min(t,r),s=i<r?It(e,F(r-i)):e,a=s<0n,d=(a?-s:s).toString().padStart(i+1,"0"),p=d.length-i;return`${a?"-":""}${d.slice(0,p)}.${d.slice(p)}`.replace(/\.?0*$/,"")}class K{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(e,t){return new K({decimal:t,value:Z({bigIntDecimal:t,decimal:t,value:e})})}static shiftDecimals({value:e,from:t,to:r}){return K.fromBigInt(e.getBaseValue("bigint")*F(r)/F(t),r)}constructor(e){this.decimal=typeof e==="object"?e.decimal:void 0;let t=Te(typeof e==="object"&&"value"in e?e.value:e),r=typeof e==="object"&&"decimalMultiplier"in e?e.decimalMultiplier:F(this.decimal??0);this.decimalMultiplier=r!==void 0&&r>t.decimalMultiplier?r:t.decimalMultiplier,this.bigIntValue=t.bigIntValue*this.decimalMultiplier/t.decimalMultiplier}toString(e={}){return this.getValue("string")}set(e){return this.#n({decimal:this.decimal,value:new K(e)})}#n(e){return new this.constructor({...e,identifier:this.toString({includeSynthProtocol:!0})})}add(...e){return this.#t("add",...e)}sub(...e){return this.#t("sub",...e)}mul(...e){return this.#t("mul",...e)}div(...e){return this.#t("div",...e)}gt(e){return this.#e("gt",e)}gte(e){return this.#e("gte",e)}lt(e){return this.#e("lt",e)}lte(e){return this.#e("lte",e)}eqValue(e){return this.#e("eqValue",e)}getValue(e,t){let r=we(this.decimalMultiplier),i=t!==void 0?t:this.decimal,s=i!==void 0?i:r;if(i!==void 0&&i<r){if(this.formatBigIntToSafeValue(this.bigIntValue,i)==="0"&&this.bigIntValue!==0n)s=r}let a=this.formatBigIntToSafeValue(this.bigIntValue,s);return Ae(e).with("number",()=>Number(a)).with("string",()=>a).with("bigint",()=>this.bigIntValue*F(this.decimal??z)/this.decimalMultiplier).otherwise(()=>a)}getBaseValue(e,t){let r=F(t??this.decimal??z),i=It(this.bigIntValue*r,this.decimalMultiplier);return Ae(e).with("number",()=>Number(i)).with("string",()=>i.toString()).otherwise(()=>i)}getBigIntValue(e,t){if(t===void 0&&typeof e==="object")return e.bigIntValue;let r=Te(e),i=t===void 0?this.decimalMultiplier:F(t);return r.bigIntValue*i/r.decimalMultiplier}toSignificant(e=6){let t=this.getValue("string"),r=t.startsWith("-"),i=r?t.slice(1):t,[s="",a=""]=i.split("."),d=Number.parseInt(s,10)>0;if((d?s.length+a.length:a.length)<=e)return B(r,i);if(s.length>=e)return B(r,s.slice(0,e).padEnd(s.length,"0"));if(d)return B(r,`${s}.${a.slice(0,e-s.length)}`);let m=a.replace(/^0+/,"")||"0",S=m.slice(0,e),f=a.length-m.length;return B(r,`0.${S.padStart(f+S.length,"0")}`)}toFixed(e=6){let t=this.getValue("string"),r=t.startsWith("-"),[i="0",s=""]=(r?t.slice(1):t).split(".");if(e===0){if(i==="0"&&!s)return"0";let f=s&&Number.parseInt(s[0]||"0",10)>=5?`${BigInt(i)+1n}.0`:`${i}.0`;return B(r,f)}if(!s)return B(r,`${i}.${"0".repeat(e)}`);let a=s[e];if(!(a&&Number.parseInt(a,10)>=5))return B(r,`${i}.${s.slice(0,e).padEnd(e,"0")}`);let p=BigInt(s.slice(0,e).padEnd(e,"0"))+1n,m=10n**BigInt(e);if(p>=m)return B(r,`${BigInt(i)+1n}.${"0".repeat(e)}`);return B(r,`${i}.${p.toString().padStart(e,"0")}`)}toAbbreviation(e=2){let t=this.getValue("string"),r=Number(t),i=["","K","M","B","T","Q","Qi","S"],s=Math.floor(Math.log10(Math.abs(r))/3);if(s===0||!i[s])return t;return`${(r/10**(s*3)).toFixed(e)}${i[s]}`}toCurrency(e="$",{currencyPosition:t="start",decimal:r=2,decimalSeparator:i=".",thousandSeparator:s=",",trimTrailingZeros:a=!0}={}){let d=this.toFixed(r),p=t==="end",[m="0",S=""]=d.split("."),f=m.replace(/\B(?=(\d{3})+(?!\d))/g,s),w=S&&Number.parseInt(S,10)>0,E=w?`${f}${i}${S}`:f,N=E.length<100&&a&&w?E.replace(/\.?0*$/,""):E;return p?`${N}${e}`:`${e}${N}`}formatBigIntToSafeValue(e,t){return Z({bigIntDecimal:t||this.decimal||z,decimal:we(this.decimalMultiplier),value:e})}#t(e,...t){let r=t.map(Te),i=Math.max(z,we(this.decimalMultiplier),...r.map(({decimalMultiplier:S})=>we(S))),s=Math.min(i+nr,rr),a=F(s),d=r.reduce((S,f)=>{let w=S.decimalMultiplier*f.decimalMultiplier,E=Ae(e).with("add",()=>S.bigIntValue*f.decimalMultiplier+f.bigIntValue*S.decimalMultiplier).with("sub",()=>S.bigIntValue*f.decimalMultiplier-f.bigIntValue*S.decimalMultiplier).with("mul",()=>S.bigIntValue*f.bigIntValue).with("div",()=>{if(f.bigIntValue===0n)throw RangeError("Division by zero");return S.bigIntValue*f.decimalMultiplier}).exhaustive(),T=e==="div"?S.decimalMultiplier*f.bigIntValue:w;return{bigIntValue:E*a/T,decimalMultiplier:a}},this),p=this.decimal===void 0?void 0:Math.min(this.decimal,s),m=d.decimalMultiplier===a?d:{bigIntValue:d.bigIntValue*a/d.decimalMultiplier,decimalMultiplier:a};return this.#n({decimal:p,value:m})}#e(e,t){let r=Te(t),i=this.bigIntValue*r.decimalMultiplier,s=r.bigIntValue*this.decimalMultiplier;return Ae(e).with("gt",()=>i>s).with("gte",()=>i>=s).with("lt",()=>i<s).with("lte",()=>i<=s).with("eqValue",()=>i===s).exhaustive()}}var ir=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function sr(e){let r=`${typeof e==="number"?ir.format(e):e}`.replaceAll(",",".").split(".");return r.length>1?`${r.slice(0,-1).join("")}.${r.at(-1)}`:r[0]||"0"}function or(e){let t=e.split(".")[1]?.length||0;return Math.max(t,z)}function Te(e){if(typeof e==="object")return e;let t=e==="undefined"?"0":sr(e),r=or(t),[i="",s=""]=t.split(".");return{bigIntValue:BigInt(`${i}${s.padEnd(r,"0")}`),decimalMultiplier:F(r)}}function B(e,t){return e&&!/^0(?:\.0*)?$/.test(t)?`-${t}`:t}function It(e,t){if(t===0n)throw Error("Cannot divide by zero");let r=t/2n;return e>=0n&&t>=0n||e<0n&&t<0n?(e+r)/t:(e-r)/t}function F(e){return 10n**BigInt(e)}function we(e){return e.toString().length-1}function dr(e=""){let t=e.toUpperCase(),r=A.get("chains"),[i]=t.split(".");if(r.includes(i))return!0;let[s]=t.split("/");if(r.includes(s))return!0;throw new y({errorKey:"helpers_invalid_identifier",info:{identifier:e,message:`Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}var ne=[R.Hype,R.Near,R.Ripple,R.Solana,R.Stellar,R.Sui,R.Ton,R.Tron],$e=[R.THORChain,R.Maya];function xe(e,t){return ne.includes(e)?t:t.toUpperCase()}var ee=new Map,Re=new Map,te=new Map,cr=3600000;function pr(e){let t=te.get(e);if(t?.timestamp&&Date.now()-t.timestamp>cr){te.delete(e);return}return t}function ur(e,t){if(te.size>1000){let r=te.keys().next().value;if(r)te.delete(r)}te.set(e,{...t,timestamp:Date.now()})}class D extends K{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:e,decimal:t,tax:r,chain:i,symbol:s,identifier:a}){super({decimal:t,value:e});let d=Ct(a||`${i}.${s}`);this.type=Ve(d),this.tax=r,this.chain=d.chain,this.ticker=d.ticker,this.symbol=d.symbol,this.address=d.address,this.isSynthetic=d.isSynthetic,this.isTradeAsset=d.isTradeAsset,this.isGasAsset=d.isGasAsset,this.chainId=ce(d.chain).chainId}toString({includeSynthProtocol:e}={}){return(this.isSynthetic||this.isTradeAsset)&&!e?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 e=this.symbol.replace(/\./g,"__");return`${this.chain}.${e}`}getIconUrl(){return ee.get(xe(this.chain,this.toString()))?.logoURI}eqAsset({chain:e,symbol:t}){return this.chain===e&&this.symbol===t}eq(e){return this.eqAsset(e)&&this.eqValue(e)}static fromUrl(e,t=0){let r=e.indexOf(".");if(r===-1)throw new y({errorKey:"helpers_invalid_asset_url",info:{urlAsset:e}});let i=e.slice(0,r),s=e.slice(r+1),a=Be({chain:i,rest:s}).when(({rest:d})=>d.includes(".."),({chain:d,rest:p})=>`${d}.${p.replace(/\.\./g,"~")}`).when(({chain:d,rest:p})=>$e.includes(d)&&p.includes("."),({chain:d,rest:p})=>`${d}.${p.replace(/\./g,"/")}`).otherwise(({chain:d,rest:p})=>`${d}.${p.replace(/__/g,".")}`);return D.from({asset:a,value:t})}static from({value:e=0,fromBaseDecimal:t,asyncTokenLookup:r,...i}){let s="address"in i&&"chain"in i,a=hr(i);if(a===null&&r&&s){let{chain:x,address:X}=i;return gr({address:X,chain:x,fromBaseDecimal:t,parsedValue:e})}let d=s&&!a?`${i.chain}.UNKNOWN-${i.address}`:a,{identifier:p,decimal:m}=Se(d),{chain:S,isSynthetic:f,isTradeAsset:w,address:E}=Ct(p),{baseDecimal:T}=ce(S),N=ee.get(xe(S,p));if(!N&&r&&!f&&!w)return(async()=>{let{ticker:x}=Y(p),X=await Ot({address:E,chain:S,ticker:x});return He({decimal:X.decimals,identifier:X.identifier,value:t?Ue(e,t):e})})();let I=N?.decimal||m;ae({condition:!I&&!r,id:`assetValue_static_decimal_not_found_${S}`,warning:`Couldn't find static decimal for one or more tokens on ${S} (Using default ${T} 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:C,identifier:Q,tax:ue}=N||{decimal:I||T,identifier:p},me=t?Ue(e,t):ve(e,C);return f||w?mr(Q,me):He({decimal:C,identifier:Q,tax:ue,value:me})}static async loadStaticAssets(e){let{loadTokenLists:t}=await import("@swapkit/tokens"),r=await t(e,{source:A.get("envs").isDev?"dev":"prod"});for(let{tokens:i}of Object.values(r))for(let s of i){let{identifier:a}=s,{chain:d,symbol:p}=Y(a),{address:m}=de(p,d),{baseDecimal:S}=ce(d),f=xe(d,a),w="decimals"in s&&s.decimals!==void 0?s.decimals:S,E="logoURI"in s&&s.logoURI?s.logoURI:`https://tokens.swapkit.dev/images/${a.toLowerCase()}.png`,T={decimal:w,identifier:a,logoURI:E,tax:"tax"in s?s.tax:void 0};if(ee.set(f,T),m){let N=ne.includes(d)?`${d}:${m}`:`${d}:${m.toUpperCase()}`;Re.set(N,a)}}return!0}static setStaticAssets(e){ee.clear(),Re.clear();for(let[t,r]of e.entries()){let{identifier:i}=r,{chain:s,symbol:a}=Y(i),{address:d}=de(a,s),{baseDecimal:p}=ce(s),m=r.chain??s,S=r.address??d,f=xe(m,i),w=r.decimals??r.decimal??p,E=r.logoURI??`https://tokens.swapkit.dev/images/${i.toLowerCase()}.png`,T={decimal:w,identifier:f,logoURI:E,tax:r.tax};if(ee.set(f,T),S){let N=ne.includes(m)?`${m}:${S}`:`${m}:${S.toUpperCase()}`;Re.set(N,i)}}return!0}static get staticAssets(){return ee}}function Eo(e){let t=D.from({chain:e});return Be(e).with(R.Bitcoin,R.Litecoin,R.BitcoinCash,R.Dash,()=>t.set(0.00010001)).with(R.Zcash,()=>t.set(0.00015001)).with(R.Dogecoin,()=>t.set(1.00000001)).with(R.Avalanche,R.Ethereum,R.Arbitrum,R.BinanceSmartChain,()=>t.set(0.00000001)).with(R.THORChain,R.Maya,()=>t.set(0)).with(R.Cosmos,R.Kujira,()=>t.set(0.000001)).otherwise(()=>t.set(0.00000001))}async function Ot({chain:e,address:t,ticker:r}){let s=ne.includes(e)?`${e}:${t||r}`:`${e}:${t||r}`.toUpperCase(),a=pr(s);if(a)return a;if(!t){let{baseDecimal:m}=ce(e);return{decimals:m,identifier:`${e}.${r||"UNKNOWN"}`}}let d=await Rt({address:t,chain:e}),p=`${e}.${d.ticker||r||"UNKNOWN"}-${t}`;return ae({condition:!!(!d.ticker&&r),id:`async_token_lookup_failed_${e}_${t}`,warning:`Could not fetch token metadata for ${e}:${t} from chain. Using user-provided ticker (${r}) with baseDecimal (${d.decimals}).`}),d.ticker&&ur(s,{decimals:d.decimals,identifier:p}),{decimals:d.decimals,identifier:p}}function He({identifier:e,decimal:t,value:r,tax:i}){return dr(e),new D({decimal:t,identifier:e,tax:i,value:ve(r,t)})}function mr(e,t=0){let r=e.includes(".")?e.split(".")[0]?.toUpperCase():void 0,i=r&&!/[/~]/.test(r)?r:void 0,a=(i?$e.includes(i):!1)?e.slice(e.indexOf(".")+1):e;return new D({decimal:8,identifier:`${i||R.THORChain}.${a}`,value:ve(t,8)})}async function gr({address:e,chain:t,fromBaseDecimal:r,parsedValue:i}){let{decimals:s,identifier:a}=await Ot({address:e,chain:t}),d=r?Ue(i,r):i;return He({decimal:s,identifier:a,value:d})}function Ue(e,t){let r=e instanceof K?e.getValue("string"):e;return ve(BigInt(r),t)}function ve(e,t){return typeof e==="bigint"?Z({bigIntDecimal:t,decimal:t,value:e}):e}function _r(e){let t=Be(e).when((r)=>("chain"in r)&&r.chain!==void 0,({chain:r})=>r).otherwise((r)=>{let i=Y(r.asset);return i.synth?R.THORChain:i.chain});if(!ar.includes(t.toUpperCase())){let r="asset"in e?e.asset:t;throw new y({errorKey:"helpers_invalid_asset_identifier",info:{identifier:r,message:`Unsupported chain "${t}" - use the AssetValue constructor directly`}})}}function hr(e){if(_r(e),"chain"in e){let{chain:s,address:a}=e;if(a){let d=ne.includes(s)?`${s}:${a}`:`${s}:${a.toUpperCase()}`,p=Re.get(d);if(p)return p;return null}return s}let{chain:t,symbol:r}=Y(e.asset);return Ve({chain:t,symbol:r})==="Native"?t:e.asset}function fr(e,t,r){let i=e.split("."),s=i[0]?.toUpperCase(),a=$e.includes(s),d=r?"~":"/",p=a?i.slice(1).join("."):e,[m,...S]=p.split(d);if(!m||!S.length||S.some((I)=>!I))throw new y({errorKey:"helpers_invalid_asset_identifier",info:{identifier:e}});let f=S.join(d),w=t&&m.toUpperCase()==="X",{ticker:E,address:T}=w?{address:void 0,ticker:f}:kt({chain:m,symbol:f}),N=`${m}${d}${f}`;return{address:T,chain:s,isGasAsset:!1,isSynthetic:t,isTradeAsset:r,symbol:N,ticker:E}}function br(e){let t=e.indexOf("."),r=(t===-1?e:e.slice(0,t)).toUpperCase(),i=t===-1?e:e.slice(t+1),{address:s,ticker:a}=kt({chain:r,symbol:i}),d;try{d=s&&lr.includes(r)&&ye(s)?ye(s):s}catch{d=s}let p=d?`${a}-${d}`:i;return{address:d,chain:r,isGasAsset:vt({chain:r,symbol:i}),isSynthetic:!1,isTradeAsset:!1,symbol:p,ticker:a}}function Ct(e){let t=e.slice(0,14),r=t.includes("/"),i=t.includes("~");if(r||i)return fr(e,r,i);return br(e)}function kt({symbol:e,chain:t}){let{ticker:r,address:i}=de(e,t);return{address:i&&!ne.includes(t)?i.toLowerCase():i,ticker:r}}class Ie extends K{eq(e){return this.eqValue(e)}static fromBigInt(e,t){return new Ie({decimal:t,value:Z({bigIntDecimal:t,decimal:t,value:e})})}}function Pt(e=!0){return e?"https://gateway.liquify.com/chain/thorchain_midgard":"https://midgard.mayachain.info"}function Sr(e=!0){let t=Pt(e);return e?`${t}/v2/thorname`:`${t}/v2/mayaname`}function Ar(e){return function(r){let i=r?`?status=${r}`:"";return _.get(`${e}/v2/pools${i}`)}}function Tr(e){return function(r){return _.get(`${e}/v2/pool/${r}`)}}function wr(e){return function(r,i){let s=i?`?period=${i}`:"";return _.get(`${e}/v2/pool/${r}/stats${s}`)}}function xr(e){return function(r,i){let s=new URLSearchParams;if(i?.interval)s.append("interval",i.interval);if(i?.count)s.append("count",i.count.toString());if(i?.from)s.append("from",i.from.toString());if(i?.to)s.append("to",i.to.toString());let a=s.toString()?`?${s.toString()}`:"";return _.get(`${e}/v2/history/depths/${r}${a}`)}}function Rr(e){return function(){return _.get(`${e}/v2/network`)}}function vr(e){return function(){return _.get(`${e}/v2/health`)}}function Ir(e){return function(){return _.get(`${e}/v2/nodes`)}}function Cr(e){return function(r){return _.get(`${e}/v2/node/${r}`)}}function Or(e){return function(){return _.get(`${e}/v2/mimir/votes`)}}function kr(e){return function(){return _.get(`${e}/v2/mimir`)}}function Pr(e){return function(){return _.get(`${e}/v2/constants`)}}function Er(e){return function(){return _.get(`${e}/v2/stats`)}}function Lr(e){return function(r){let i=new URLSearchParams;if(r?.interval)i.append("interval",r.interval);if(r?.count)i.append("count",r.count.toString());if(r?.from)i.append("from",r.from.toString());if(r?.to)i.append("to",r.to.toString());let s=i.toString()?`?${i.toString()}`:"";return _.get(`${e}/v2/history/earnings${s}`)}}function Nr(e){return function(r,i){let s=new URLSearchParams;if(i?.interval)s.append("interval",i.interval);if(i?.count)s.append("count",i.count.toString());if(i?.from)s.append("from",i.from.toString());if(i?.to)s.append("to",i.to.toString());let a=s.toString()?`?${s.toString()}`:"",d=r?`/swaps/${r}`:"/swaps";return _.get(`${e}/v2/history${d}${a}`)}}function Dr(e){return function(r){let i=new URLSearchParams;if(r?.interval)i.append("interval",r.interval);if(r?.count)i.append("count",r.count.toString());if(r?.from)i.append("from",r.from.toString());if(r?.to)i.append("to",r.to.toString());let s=i.toString()?`?${i.toString()}`:"";return _.get(`${e}/v2/history/tvl${s}`)}}function Mr(e){if(!e)return"";let t=new URLSearchParams,r=(i,s)=>{if(s!==void 0)t.append(i,typeof s==="number"?s.toString():s)};return r("address",e.address),r("txid",e.txid),r("asset",e.asset),r("type",e.type),r("affiliate",e.affiliate),r("limit",e.limit),r("offset",e.offset),t.toString()?`?${t.toString()}`:""}function Vr(e){return function(r){let i=Mr(r);return _.get(`${e}/v2/actions${i}`)}}function Hr(e){return function(r){return _.get(`${e}/v2/member/${r}`)}}function Ur(e){return function(r){let i=r?`/${r}`:"";return _.get(`${e}/v2/members${i}`)}}function Br(e){return function(r,i){let s=i?`&asset=${i}`:"";return _.get(`${e}/v2/saver/${r}${s?`?${s.substring(1)}`:""}`)}}function $r(e){return function(r){return _.get(`${e}/v2/savers/${r}`)}}function Fr(e){return function(r,i){let s=new URLSearchParams;if(i?.interval)s.append("interval",i.interval);if(i?.count)s.append("count",i.count.toString());if(i?.from)s.append("from",i.from.toString());if(i?.to)s.append("to",i.to.toString());let a=s.toString()?`?${s.toString()}`:"",d=r?`/savers/${r}`:"/savers";return _.get(`${e}/v2/history${d}${a}`)}}function Kr(e){return function(r){return _.get(`${e}/v2/balance/${r}`)}}function qr(e){return async function(r){let i=(s)=>{if(s?.cause?.status===404)return;throw s};return await _.get(`${e}/lookup/${r}`,{onError:i,retry:{maxRetries:1}})}}function Wr(e){return async function(r){let i=(s)=>{if(s?.cause?.status===404)return[];throw s};return await _.get(`${e}/rlookup/${r}`,{onError:i,retry:{maxRetries:1}})}}function Gr(e){return async function(r){let i=(s)=>{if(s?.cause?.status===404)return[];throw s};return await _.get(`${e}/owner/${r}`,{onError:i,retry:{maxRetries:1}})}}function re({asset:e,value:t}){return D.from({asset:e,fromBaseDecimal:yr(Ce.THORChain).baseDecimal,value:t})}function jr({liquidityPositionGetter:e,isThorchain:t}){return async function(i){let s=await e(i),a=t?"rune":"cacao";return s.pools.map((d)=>({[`${a}Pending`]:re({asset:"THOR.RUNE",value:d.runePending}),[`${a}RegisteredAddress`]:d.runeAddress,[`${a}Withdrawn`]:re({asset:"THOR.RUNE",value:d.runeWithdrawn}),[a]:re({asset:"THOR.RUNE",value:d.runeAdded}),asset:re({asset:d.pool,value:d.assetAdded}),assetPending:re({asset:d.pool,value:d.assetPending}),assetRegisteredAddress:d.assetAddress,assetWithdrawn:re({asset:d.pool,value:d.assetWithdrawn}),dateFirstAdded:d.dateFirstAdded,dateLastAdded:d.dateLastAdded,poolShare:new Ie(d.liquidityUnits).div(d.pool)}))}}function Et(e){let t=e===Ce.THORChain,r=Pt(t),i=Sr(t),s=Hr(r);return{getActions:Vr(r),getBalance:Kr(r),getConstants:Pr(r),getEarningsHistory:Lr(r),getHealth:vr(r),getLiquidityPosition:jr({isThorchain:t,liquidityPositionGetter:s}),getLiquidityPositionRaw:s,getMembers:Ur(r),getMimir:kr(r),getMimirVotes:Or(r),getNameDetails:qr(i),getNamesByAddress:Wr(i),getNamesByOwner:Gr(i),getNetworkInfo:Rr(r),getNode:Cr(r),getNodes:Ir(r),getPool:Tr(r),getPoolDepthHistory:xr(r),getPoolStats:wr(r),getPools:Ar(r),getSaverDetails:Br(r),getSavers:$r(r),getSaversHistory:Fr(r),getStats:Er(r),getSwapHistory:Nr(r),getTVLHistory:Dr(r)}}var Lt=Et(Ce.THORChain),Nt=Et(Ce.Maya);var Xe={};nt(Xe,{SKRequestClient:()=>P,buildLimitOrder:()=>ts,buildLimitOrderCancel:()=>ss,getChainBalance:()=>qi,getChainflipDepositChannel:()=>Xi,getGasRate:()=>Qi,getLimitOrder:()=>is,getLimitOrderQuote:()=>es,getLimitOrderTokens:()=>Zi,getLimitOrders:()=>rs,getNearDepositChannel:()=>Ji,getPrice:()=>zi,getRouteWithTx:()=>Ki,getSwapQuote:()=>Fi,getSwapTo:()=>ps,getTokenApproval:()=>Wi,getTokenList:()=>ji,getTokenListProviders:()=>Gi,getTrackerDetails:()=>$i,searchTokens:()=>Yi,submitLimitOrder:()=>ns,submitLimitOrderCancel:()=>os});import{EVMChains as Qe}from"@swapkit/types";import{match as Bi,P as pe}from"ts-pattern";import{Chain as Oe,ChainId as q}from"@swapkit/types";import{array as v,boolean as V,coerce as Ht,number as h,object as g,optional as c,string as o,union as Fe,unknown as Ke,z as n}from"zod";var Ut;((i)=>{i.CHEAPEST="CHEAPEST";i.FASTEST="FASTEST";i.RECOMMENDED="RECOMMENDED"})(Ut||={});var ke;((f)=>{f.PSBT="PSBT";f.EVM="EVM";f.COSMOS="COSMOS";f.RADIX="RADIX";f.NEAR="NEAR";f.STELLAR="STELLAR";f.TON="TON";f.TRON="TRON";f.EIP_712_HYPE_SEND_ASSET="EIP_712_HYPE_SEND_ASSET";f.EIP_712_HYPE_WITHDRAW="EIP_712_HYPE_WITHDRAW"})(ke||={});var Bt;((C)=>{C.approve="approve";C.claim="claim";C.deposit="deposit";C.donate="donate";C.lending="lending";C.lp_action="lp_action";C.native_contract_call="native_contract_call";C.native_send="native_send";C.stake="stake";C.streaming_swap="streaming_swap";C.swap="swap";C.thorname_action="thorname_action";C.token_contract_call="token_contract_call";C.token_transfer="token_transfer";C.unknown="unknown";C.unstake="unstake"})(Bt||={});var $t;((T)=>{T.swap="swap";T.aggregation="aggregation";T.addLiquidity="addLiquidity";T.withdrawLiquidity="withdrawLiquidity";T.addSavers="addSavers";T.withdrawSavers="withdrawSavers";T.borrow="borrow";T.repay="repay";T.name="name";T.donate="donate";T.claim="claim";T.stake="stake";T.unstake="unstake"})($t||={});var Ft;((p)=>{p.unknown="unknown";p.not_started="not_started";p.pending="pending";p.swapping="swapping";p.completed="completed";p.refunded="refunded";p.failed="failed"})(Ft||={});var Kt;((I)=>{I.not_started="not_started";I.starting="starting";I.broadcasted="broadcasted";I.mempool="mempool";I.inbound="inbound";I.outbound="outbound";I.swapping="swapping";I.completed="completed";I.refunded="refunded";I.partially_refunded="partially_refunded";I.dropped="dropped";I.reverted="reverted";I.replaced="replaced";I.retries_exceeded="retries_exceeded";I.parsing_error="parsing_error"})(Kt||={});var qo=g({address:c(o()),chain:n.enum(Oe).optional(),chainId:n.enum(q),coingeckoId:c(o()),decimals:Ht.number(),extensions:c(n.looseObject({})),identifier:o(),logoURI:c(o()),name:c(o()),shortCode:c(o()),symbol:c(o()),ticker:o()}),Wo=n.object({block:n.optional(n.number().describe("Block number. Required for Polkadot chain. e.g. `123456`")),chainId:n.optional(n.string().describe("ChainId for the hash. e.g. `thorchain-1`")),depositChannelId:n.optional(n.string().describe("Deposit channel ID, required for Chainflip if tx was broadcasted without wallet connection")),hash:n.optional(n.string().describe("Hash for the first transaction broadcasted by the end user. e.g. `88D1819378ECD09E5284C54937CDC1E99B52F253C007617A02DD1200710CE677`"))}).refine((e)=>e.hash&&e.chainId||e.depositChannelId,{message:"Either `hash` and `chainId` or `depositChannelId` must be provided"}),Go=n.object({forceUpdate:n.string().toLowerCase().transform((e)=>e==="true").pipe(n.boolean()).optional()}),jo=g({error:o(),message:o()}),ie=g({address:c(o()),chain:n.enum(Oe),decimal:c(h()),isGasAsset:V(),isSynthetic:V(),symbol:o(),tax:c(g({buy:h(),sell:h()})),ticker:o()}),qt=g({id:o(),market_cap:h(),name:o(),price_change_24h_usd:h(),price_change_percentage_24h_usd:h(),sparkline_in_7d:v(h()),timestamp:o(),total_volume:h()}).partial(),Yo=g({cg:c(qt),identifier:o(),price_usd:h(),provider:o(),timestamp:h()}),Wt=v(g({cg:c(qt),identifier:o(),price_usd:h(),provider:o(),timestamp:h()}).partial()),zo=g({affiliate:c(o().describe("Affiliate thorname")),affiliateFee:c(h().describe("Affiliate fee in basis points").refine((e)=>e===Math.floor(e)&&e>=0,{message:"affiliateFee must be a positive integer",path:["affiliateFee"]})),allowSmartContractReceiver:c(V().describe("Allow smart contract as recipient")),allowSmartContractSender:c(V().describe("Allow smart contract as sender")),buyAsset:o().describe("Asset to buy"),cfBoost:c(V().describe("Set to true to enable CF boost to speed up Chainflip swaps. BTC only.")),destinationAddress:c(o().describe("Address to send asset to")),disableSecurityChecks:c(V().describe("Disable security checks")),enableSweep:c(V().describe("Sell the full balance of a native asset, letting the API deduct the network fee (opt-in)")),includeTx:c(V().describe("Set to true to include an transaction object (EVM only)")),providers:c(v(o().describe("List of providers to use").refine((e)=>O[e]!==void 0,{message:"Invalid provider",path:["providers"]}))),referrer:c(o().describe("Referrer address (referral program)")),sellAmount:o().describe("Amount of asset to sell").refine((e)=>+e>0,{message:"sellAmount must be greater than 0",path:["sellAmount"]}),sellAsset:o().describe("Asset to sell"),slippage:c(h().describe("Slippage tolerance as a percentage. Default is 3%.")),sourceAddress:c(o().describe("Address to send asset from"))}).refine((e)=>e.sellAsset!==e.buyAsset,{message:"Must be different",path:["sellAsset","buyAsset"]}),Qo=g({metadata:V(),tokens:v(g({identifier:o()}))}),Gt=g({destinationAddress:o()}),Yr=Gt.extend({affiliateFees:v(g({brokerAddress:o(),feeBps:h()})).optional(),brokerCommissionBps:h().optional(),buyAsset:g({asset:o(),chain:o()}),channelMetadata:g({cfParameters:o().optional(),gasBudget:o().optional(),message:o().optional()}).optional(),dcaParameters:g({chunkInterval:h().optional(),numberOfChunks:h().optional()}).optional(),maxBoostFeeBps:h().optional(),refundParameters:g({minPrice:o().optional(),refundAddress:o().optional(),retryDuration:h().optional()}).optional(),sellAsset:g({asset:o(),chain:o()})}),jt=g({channelId:o(),depositAddress:o()}),Dt=Gt.extend({affiliateFees:g({feeBps:h(),nearId:o()}).optional(),buyAsset:o(),sellAmount:o(),sellAsset:o(),slippage:Ht.number(),sourceAddress:o()}),Mt=g({amountIn:o(),amountInFormatted:o(),amountInUsd:o(),amountOut:o(),amountOutFormatted:o(),amountOutUsd:o(),deadline:o().optional(),minAmountIn:o(),minAmountOut:o(),timeEstimate:h().optional(),timeWhenInactive:o().optional()}),Xo=Mt.extend({depositAddress:o(),quote:Mt,signature:o(),timestamp:o(),tx:Ke()}),Yt=g({buyAsset:o(),buyAssetAmount:o(),buyAssetAmountMaxSlippage:o(),deadline:o().optional(),depositAddress:o(),depositAmount:o(),depositAsset:o(),tx:Ke()}),zr=g({evmCalldata:n.optional(n.string()),intentHash:n.optional(n.string()),logs:n.optional(n.unknown()),manifest:n.optional(n.unknown()),memo:n.optional(n.string()),spender:n.optional(n.string()),thorname:n.optional(n.string())}),Qr=g({currentStage:o(),inboundConfirmation:h(),inboundObservation:h(),outboundDelay:h(),outboundObservation:h(),streamingSwap:h()}),Xr=g({count:c(h()),interval:c(h()),quantity:c(h()),subSwapsMap:c(v(h()))}),Jr=n.object({currentLegIndex:n.optional(n.number()),estimatedTimeToComplete:n.number(),estimates:n.optional(Qr),providerDetails:n.optional(n.object({streamingDetails:n.optional(Xr)}))}),Zr=g({affiliate:c(ie),liquidity:c(ie),network:c(ie),protocol:c(ie),tax:c(ie)}),ei=g({affiliate:o(),bps:o(),isReferrer:V()}),ti=g({affiliate:c(o()),affiliateFees:c(v(ei)),broadcastedAt:c(h()),explorerUrl:c(o()),fees:c(Zr),images:c(g({chain:c(o()),from:c(o()),provider:c(o()),to:c(o())})),provider:c(n.enum(O)),providerAction:n.optional(n.enum($t)),quoteId:c(o()),wallet:c(o())}),se=n.object({block:n.number(),chainId:n.enum(q),finalAddress:n.optional(n.string()),finalAsset:n.optional(ie),finalisedAt:n.number(),fromAddress:n.string(),fromAmount:n.string(),fromAsset:n.string(),hash:n.string(),meta:n.optional(ti),payload:n.optional(zr),status:n.enum(Ft),toAddress:n.string(),toAmount:n.string(),toAsset:n.string(),trackingStatus:n.optional(n.enum(Kt)),transient:n.optional(Jr),type:n.enum(Bt)}),zt=se.extend({legs:n.array(se)}),Jo=se.extend({legs:v(se)}),Zo=se.extend({legs:v(se)}),qe=v(g({amount:o(),asset:o(),chain:o(),protocol:n.enum(O),type:n.enum(_e)})),We=n.object({inbound:n.optional(n.number().describe("Time to receive inbound asset in seconds")),outbound:n.optional(n.number().describe("Time to receive outbound asset in seconds")),swap:n.optional(n.number().describe("Time to swap assets in seconds")),total:n.number().describe("Total time in seconds")}),ni=/^(?:0x[0-9a-fA-F]+|[0-9]+)$/;function ri(e){return e===""||ni.test(e)}function ea(e){return e?BigInt(e):0n}function ta(e){let t=typeof e==="bigint"?e:BigInt(e);return t>0n?`0x${t.toString(16)}`:"0x0"}var U=o().refine(ri,{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"),ii=g({data:o().describe("Data to send"),from:o().describe("Address of the sender"),to:o().describe("Address of the recipient"),value:U}),si=n.object({data:n.string().optional(),raw_data:n.object({contract:n.any(),data:n.string().optional(),expiration:n.number(),fee_limit:n.number().optional(),ref_block_bytes:n.string(),ref_block_hash:n.string(),timestamp:n.number()}).passthrough(),raw_data_hex:n.string(),txID:n.string(),value:U.optional(),visible:n.boolean()}),oi=v(Fe([o(),h(),v(o()),g({from:o(),value:U}).describe("Parameters to pass to the contract method")])),na=g({approvalSpender:c(o().describe("Address of the spender to approve")),approvalToken:c(o().describe("Address of the token to approve spending of")),contractAddress:o().describe("Address of the contract to interact with"),contractMethod:o().describe("Name of the method to call"),contractParamNames:v(o().describe("Names of the parameters to pass to the contract method")),contractParams:oi}),ai=g({typeUrl:o("/types.MsgDeposit"),value:g({coins:v(g({amount:o(),asset:g({chain:o(),symbol:o(),synth:V(),ticker:o()})})),memo:o(),signer:o()})}),li=g({typeUrl:o("/types.MsgSend"),value:g({amount:v(g({amount:o(),denom:o()})),fromAddress:o(),toAddress:o()})}),di=g({typeUrl:o(),value:li.shape.value.or(ai.shape.value)}),ci=g({amount:v(g({amount:o(),denom:o()})),gas:o()}),pi=g({accountNumber:h(),chainId:n.enum(q),fee:ci,memo:o(),msgs:v(di),sequence:h()}),ui=n.array(n.object({calldata:n.array(n.string()),contractAddress:n.string(),entrypoint:n.string()})),mi=n.object({address:n.string().describe("Destination address in friendly format"),amount:n.string().describe("Amount in nanotons"),payload:n.string().optional().describe("Base64 BOC of body cell"),stateInit:n.string().optional().describe("Base64 BOC of state init")}),gi=n.object({messages:n.array(mi),sendMode:n.number().describe("TON wallet send mode for the whole transfer")}),ra="USDC:0x6d1e7cde53ba9467b783cb7c530ce054",_i=n.looseObject({domain:n.looseObject({chainId:c(Fe([h(),o()])),name:c(o()),verifyingContract:c(o()),version:c(o())}),message:n.record(o(),Ke()),primaryType:o(),types:n.record(o(),v(n.looseObject({name:o(),type:o()})))}),hi=n.looseObject({amount:o(),destination:o(),destinationDex:o(),fromSubAccount:o(),hyperliquidChain:o(),nonce:h().int(),signatureChainId:o(),sourceDex:o(),token:o(),type:n.literal("sendAsset")}),Qt=n.looseObject({action:n.looseObject({type:o()}),submitTo:o(),typedData:_i}),ia=Qt.extend({action:hi}),Xt=Fe([ii,pi,si,gi,Qt,o()]),fi=Xt.or(ui),bi=g({affiliate:o().describe("Affiliate address").optional(),affiliateFee:h().describe("Affiliate fee").optional(),buyAsset:o().describe("Asset to buy"),destinationAddress:o().describe("Destination address"),estimatedTime:We.optional(),provider:n.enum(O),sellAsset:o().describe("Asset to sell"),slipPercentage:h().describe("Slippage as a percentage"),sourceAddress:o().describe("Source address")}),sa=bi.omit({destinationAddress:!0,slipPercentage:!0,sourceAddress:!0}),yi=g({asset:o().describe("Asset name"),image:o().describe("Asset image"),price:h().describe("Price in USD")}),Si=Yr,Jt=g({assets:c(v(yi)),isSweep:c(V().describe("True when the sell amount was adjusted to sweep the full balance")),maxStreamingQuantity:h().optional(),referrer:o().optional(),streamingInterval:h().optional(),tags:v(n.enum(Ut))}),Zt=Jt.extend({affiliate:c(o()),affiliateFee:c(o()),approvalAddress:c(o().describe("Approval address for swap")),chainflip:Si.optional(),garden:Dt.optional(),near:Dt.optional(),priceImpact:c(h().describe("Price impact")),referrer:c(o()),txType:c(n.enum(ke))}),en=v(g({code:n.enum(Ee),display:o(),tooltip:o().optional()})),Ai=g({buyAmount:o().describe("Buy amount"),buyAmountMaxSlippage:o().describe("Buy amount max slippage"),buyAsset:o().describe("Asset to buy"),fees:c(qe),provider:n.enum(O),sellAmount:o().describe("Sell amount"),sellAsset:o().describe("Asset to sell")}),Ti=g({buyAsset:o().describe("Asset to buy"),destinationAddress:c(o().describe("Destination address")),estimatedTime:c(We),expectedBuyAmount:o().describe("Expected Buy amount"),expectedBuyAmountMaxSlippage:o().describe("Expected Buy amount max slippage"),expiration:c(o().describe("Expiration")),fees:qe,inboundAddress:c(o().describe("Inbound address")),legs:v(Ai),memo:c(o().describe("Memo")),meta:Zt,providers:v(n.enum(O)),routeId:o().describe("Route ID"),sellAmount:o().describe("Sell amount"),sellAsset:o().describe("Asset to sell"),sourceAddress:c(o().describe("Source address")),targetAddress:c(o().describe("Target address")),totalSlippageBps:h().describe("Total slippage in bps"),tx:c(fi),txType:c(n.enum(ke)),warnings:en}),tn=g({error:c(o().describe("Error message")),providerErrors:c(v(g({errorCode:c(n.enum(oe)),message:c(o()),provider:n.enum(O).optional()}))),quoteId:o().describe("Quote ID"),routes:v(Ti)}),nn=n.object({chainId:n.enum(q),createdAt:n.date(),id:n.number(),unit:n.string(),value:n.string()}),wi=n.array(nn),rn=n.union([nn,wi]),oa=v(g({chain:n.enum(Oe),decimal:h(),identifier:o(),symbol:o(),ticker:o(),value:o()})),aa=n.union([n.object({amount:n.string(),spender:n.string(),tokenIdentifier:n.string(),userWalletAddress:n.string()}),n.object({amount:n.string(),chainId:n.enum(q),spender:n.string(),tokenContractAddress:n.string(),userWalletAddress:n.string()}),n.object({routeId:n.string()})]),la=n.object({approvalTransaction:n.optional(n.object({data:n.string(),from:n.string(),gasLimit:n.optional(n.string()),gasPrice:n.optional(n.string()),to:n.string(),value:U})),approvedAmount:n.string(),isApproved:n.boolean()}),xi=n.object({data:n.string().describe("Encoded approval call data"),from:n.string().describe("User wallet address"),gasLimit:n.string().optional().describe("Estimated gas limit"),gasPrice:n.string().optional().describe("Current gas price"),to:n.string().describe("Token contract address"),value:U.describe("ETH value (always '0' for approvals)")}),Ri=n.object({tx:n.string(),txType:n.literal("STELLAR")}),vi=n.union([xi,Ri]),Vt=n.object({buyAmount:n.string().describe("Buy amount").optional(),buyAmountMaxSlippage:n.string().describe("Buy amount max slippage").optional(),buyAsset:n.string().describe("Asset to buy"),expectedBuyAmount:n.string().describe("Expected Buy amount").optional(),expectedBuyAmountMaxSlippage:n.string().describe("Expected Buy amount max slippage").optional(),fees:qe,provider:n.enum(O),sellAmount:n.string().describe("Sell amount"),sellAsset:n.string().describe("Asset to sell")}),sn=Vt.extend({estimatedTime:n.optional(We),expiration:n.optional(n.string().describe("Expiration")),legs:n.array(Vt),providers:n.array(n.enum(O)),routeId:n.string().describe("Route ID"),totalSlippageBps:n.number().describe("Total slippage in bps"),warnings:en}).omit({provider:!0}),on=n.object({method:n.string(),payload:n.optional(n.unknown()),url:n.string()}),Ii=sn.extend({meta:Jt,nextActions:n.optional(n.array(on))}),da=n.object({error:n.optional(n.string().describe("Error message")),providerErrors:n.optional(n.array(n.object({errorCode:n.optional(n.enum(oe)),message:n.optional(n.string()),provider:n.enum(O).optional()}))),quoteId:n.string().describe("Quote ID"),routes:n.array(Ii)}),ca=n.object({providers:n.array(n.enum(O)).optional().describe("Optional list of providers to query for trading pairs"),sellAsset:n.string().describe("Asset identifier to sell (e.g., 'BTC.BTC' or 'ETH.ETH')")}),Ci=n.object({chain:n.enum(Oe).describe("Chain the asset is on"),identifier:n.string().describe("Asset identifier (e.g., 'ETH.USDC-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')"),providers:n.array(n.enum(O)).describe("Providers that support this trading pair"),symbol:n.string().describe("Asset symbol"),ticker:n.string().describe("Asset ticker")}),pa=n.object({buyAssets:n.array(Ci).describe("List of assets that can be swapped to"),sellAsset:n.string().describe("The input sell asset identifier")}),an=sn.extend({destinationAddress:n.string().describe("Destination address"),inboundAddress:n.optional(n.string().describe("Inbound address")),memo:n.optional(n.string().describe("Memo to include in the transaction")),meta:Zt,sourceAddress:n.string().describe("Source address"),targetAddress:n.optional(n.string().describe("Target address")),tx:c(Xt),txType:n.optional(n.enum(ke))}),Oi=n.object({data:n.optional(n.record(n.string(),n.string().optional())),errorCode:n.enum(oe),message:n.string().optional(),provider:n.enum(O).optional()}),ua=n.object({error:n.optional(n.string().describe("Error message")),providerErrors:n.optional(n.array(Oi)),quoteId:n.string().describe("Quote ID"),routes:n.array(an)}),ln=an.extend({approvalTx:vi.optional().describe("Optional approval transaction required before swap execution"),nextActions:n.optional(n.array(on)),swapId:n.string().describe("The unique swap ID for tracking")}),ki={CANCELLED:"CANCELLED",EXPIRED:"EXPIRED",FAILED:"FAILED",FILLED:"FILLED",OPEN:"OPEN",PARTIAL:"PARTIAL",PENDING:"PENDING",SUBMITTED:"SUBMITTED"},Pi={Cardano:"cardano",Evm:"evm",Near:"near",Psbt:"psbt",Ripple:"ripple",Solana:"solana",Starknet:"starknet",Stellar:"stellar",Sui:"sui",Ton:"ton",Tron:"tron"};function M(e){return n.union([e,n.string()])}var Ge=M(n.enum(ki)),je=n.object({method:n.string(),payload:n.optional(n.unknown()),url:n.string()}),dn=n.array(n.object({code:n.string(),display:n.string(),tooltip:n.string().optional()})),cn=n.array(n.object({amount:n.string(),amountBps:n.number().optional(),asset:n.string(),chain:n.string(),protocol:M(n.enum(O)),type:M(n.enum(_e))})),pn=n.object({crossChain:n.array(n.object({assets:n.array(n.string()),chainIds:n.array(M(n.enum(q))),provider:M(n.enum(O))})),singleChain:n.array(n.object({assets:n.array(n.string()),chainId:M(n.enum(q)),provider:M(n.enum(O))}))}),ma=n.object({affiliateFee:n.number().min(0).max(1000).optional(),buyAmount:n.string().optional(),buyAsset:n.string(),destinationAddress:n.string().optional(),expiresAt:n.number().int().positive().optional(),limitPrice:n.string().optional().describe("buyAsset per 1 sellAsset"),providers:n.array(n.enum(O)).optional(),sellAmount:n.string().optional(),sellAsset:n.string(),sourceAddress:n.string().optional()}),Ei=n.object({buyAmount:n.string(),buyAsset:n.string(),effectiveFillPrice:n.string(),fees:cn.optional(),integratorFeeBps:n.number(),limitPrice:n.string(),maxExpirationSeconds:n.number(),minExpirationSeconds:n.number(),nextActions:n.optional(n.array(je)),provider:M(n.enum(O)),routeId:n.string(),sellAmount:n.string(),sellAsset:n.string(),spotPrice:n.string(),spotPriceDeviationBps:n.number(),takerFeeBps:n.number(),warnings:dn.optional()}),un=n.object({error:n.string().optional(),providerErrors:n.optional(n.array(n.object({errorCode:n.optional(n.string()),message:n.optional(n.string()),provider:M(n.enum(O)).optional()}))),quoteId:n.string(),routes:n.array(Ei)}),ga=n.object({allowMultipleFills:n.boolean().optional(),allowPartialFill:n.boolean().optional(),destinationAddress:n.string().min(1),expiresAt:n.number().int().positive().describe("Unix timestamp in seconds"),routeId:n.string(),sourceAddress:n.string().min(1)}),Li=n.object({domain:n.looseObject({chainId:n.number(),name:n.string(),verifyingContract:n.string(),version:n.string()}),message:n.record(n.string(),n.unknown()),primaryType:n.string(),types:n.record(n.string(),n.array(n.object({name:n.string(),type:n.string()})))}),Ni=n.strictObject({data:n.string(),from:n.string().optional(),gas:U.optional(),gasPrice:U.optional(),maxFeePerGas:U.optional(),maxPriorityFeePerGas:U.optional(),to:n.string(),type:U.optional(),value:U}),Di=n.object({chainId:n.number().optional(),memo:n.string().optional(),txType:n.enum(Pi)}),Mi=n.object({data:n.string(),from:n.string(),gasLimit:n.string().optional(),gasPrice:n.string().optional(),to:n.string(),value:n.string()}),mn=n.object({approvalTx:Mi.optional(),depositAddress:n.string().optional(),depositAmount:n.string().optional(),depositMemo:n.string().optional(),isApproved:n.boolean().optional(),nextActions:n.array(je),orderHash:n.string(),orderId:n.string(),tx:n.union([n.string(),Ni,n.record(n.string(),n.unknown()),n.array(n.unknown())]).nullable(),txMeta:Di.nullable(),typedData:Li.nullable(),warnings:dn.optional()}),gn=n.object({createdAt:n.string(),orderHash:n.string(),orderId:n.string(),status:Ge}),Vi=n.object({blockNumber:n.number().int().optional(),chainId:M(n.enum(q)),txHash:n.string(),type:M(n.enum(["fill","cancel","deposit","withdraw","refund"]))}),Ye=n.object({buyAmount:n.string(),buyAsset:n.string(),cancelRequestedAt:n.string().optional(),chainId:M(n.enum(q)),createdAt:n.string(),depositHash:n.string().optional(),expiresAt:n.string(),fees:cn,filledBuyAmount:n.string(),filledSellAmount:n.string(),limitPrice:n.string(),maker:n.string(),orderHash:n.string(),orderId:n.string(),provider:M(n.enum(O)),receiver:n.string().nullable(),sellAmount:n.string(),sellAsset:n.string(),status:Ge,txHashes:n.array(Vi).optional(),updatedAt:n.string(),usdValueClose:n.string().nullable().optional(),usdValueOpen:n.string().nullable().optional(),withdrawHash:n.string().optional()}),ze=n.object({nextCursor:n.string().optional(),orders:n.array(Ye)}),Hi=n.object({domain:n.looseObject({name:n.string(),version:n.string()}),message:n.looseObject({action:n.literal("cancel_and_withdraw"),chain:n.string(),expiry:n.number(),l1Address:n.string(),nonce:n.number(),payload:n.looseObject({orderId:n.string()})}),primaryType:n.literal("CancelAndWithdraw"),types:n.looseObject({CancelAndWithdraw:n.array(n.object({name:n.string(),type:n.string()})),CancelAndWithdrawPayload:n.array(n.object({name:n.string(),type:n.string()})),EIP712Domain:n.array(n.object({name:n.string(),type:n.string()}))})}),Ui=n.strictObject({chainId:n.number(),data:n.string(),from:n.string(),to:n.string(),value:n.string()}),_n=n.object({btcSignaturePreimage:n.string().nullable(),cancelTx:Ui.nullable(),nextActions:n.array(je),orderId:n.string(),typedData:Hi.nullable()}),hn=n.object({cancelRequestedAt:n.string().optional(),orderId:n.string(),status:Ge,txHash:n.string().optional(),withdrawId:n.string().optional()});var P=_.extend({dynamicHeader:async()=>{let e=A.get("widgetId"),t=A.get("widgetKey");if(e&&t&&typeof window<"u"){let i=Math.floor(Date.now()/1000),s=window.location.origin,a=await dt(t,e,s,i);return{Origin:s,"X-Signature":a,"X-Timestamp":i.toString(),"x-widget-id":e}}let{swapKit:r}=A.get("apiKeys");return r?{"x-api-key":r}:{}}});async function $i(e){let t=await P.post(k("/track"),{json:e});try{let r=zt.safeParse(t);if(!r.success)throw new y("api_v2_invalid_response",r.error);return r.data}catch(r){return t}}async function Fi(e){let{getQuote:t}=A.get("endpoints");if(t)return t(e);let i=A.get("v3SwapFlow")?.enabled?"/v3/quote":"/quote",s=await P.post(k(i),{json:e});if(s.error)throw new y("api_v2_server_error",{message:s.error});try{let a=tn.safeParse(s);if(!a.success)throw new y("api_v2_invalid_response",a.error);return a.data}catch{return s}}async function Ki(e){let{getRouteWithTx:t}=A.get("endpoints");if(t)return t(e);let i=A.get("v3SwapFlow")?.enabled?"/v3/swap":"/swap",s=await P.post(k(i),{json:e});try{let a=ln.safeParse(s);if(!a.success)throw new y("api_v2_invalid_response",a.error);return a.data}catch(a){return console.error(new y("api_v2_invalid_response",a)),s}}async function qi({chain:e,address:t,scamFilter:r=!0}){let{getBalance:i}=A.get("endpoints");if(i)return i({address:t,chain:e});let s=k(`/balance?chain=${e}&address=${t}`),a=await P.get(s),d=Array.isArray(a)?a:[];return r?cs(d):d}function Wi(e){let t=Bi(e).with({routeId:pe.string,spender:pe.string},({routeId:r,spender:i})=>k(`/approve?routeId=${r}&sourceAddress=${i}`)).with({assetValue:pe.instanceOf(D),spender:pe.string,userWallet:pe.string},({spender:r,userWallet:i,assetValue:s})=>k(`/approve?tokenIdentifier=${s.toString()}&userWalletAddress=${i}&spender=${r}&amount=${s.getValue("string")}`)).exhaustive();return P.get(t)}function Gi(){let e=k("/providers");return P.get(e)}function ji(e){let t=k(`/tokens?provider=${e}`);return P.get(t)}function Yi({query:e,chain:t,page:r,limit:i}){let s=new URLSearchParams({query:e});if(t!==void 0)s.set("chain",t);if(r!==void 0)s.set("page",r.toString());if(i!==void 0)s.set("limit",i.toString());let a=k(`/tokens/search?${s.toString()}`);return P.get(a)}async function zi(e){let t=k("/price"),r=await P.post(t,{json:e});try{let i=Wt.safeParse(r);if(!i.success)throw new y("api_v2_invalid_response",i.error);return i.data}catch(i){throw new y("api_v2_invalid_response",i)}}async function Qi(){let e=k("/gas"),t=await P.get(e);try{let r=rn.safeParse(t);if(!r.success)throw new y("api_v2_invalid_response",r.error);return Array.isArray(r)?r:[r]}catch(r){throw new y("api_v2_invalid_response",r)}}async function Xi(e){let{destinationAddress:t}=e;if(!t)throw new y("chainflip_broker_invalid_params");let r=A.get("integrations").chainflip?.brokerUrl||k("/chainflip/broker/channel"),i=await P.post(r,{json:e});try{let s=jt.safeParse(i);if(!s.success)throw new y("api_v2_invalid_response",s.error);return s.data}catch(s){throw new y("api_v2_invalid_response",s)}}async function Ji(e){let{destinationAddress:t}=e;if(!t)throw new y("chainflip_broker_invalid_params");let r=k("/near/channel"),i=await P.post(r,{json:e});try{let s=Yt.safeParse(i);if(!s.success)throw new y("api_v2_invalid_response",s.error);return s.data}catch(s){throw new y("api_v2_invalid_response",s)}}function W(e,t){let r=e.safeParse(t);if(!r.success)throw new y("api_v2_invalid_response",r.error);return r.data}async function Zi(){let{getLimitOrderTokens:e}=A.get("endpoints"),t=e?await e():await P.get(k("/v3/limit/tokens"));return W(pn,t)}async function es(e){let{getLimitOrderQuote:t}=A.get("endpoints"),r=t?await t(e):await P.post(k("/v3/limit/quote"),{json:e});return W(un,r)}async function ts(e){let{buildLimitOrder:t}=A.get("endpoints"),r=t?await t(e):await P.post(k("/v3/limit/build"),{json:e,retry:{maxRetries:0}});return W(mn,r)}async function ns(e){let{submitLimitOrder:t}=A.get("endpoints"),r=t?await t(e):await P.post(k("/v3/limit/submit"),{json:e,retry:{maxRetries:0}});return W(gn,r)}async function rs(e={}){let{getLimitOrders:t}=A.get("endpoints");if(t)return W(ze,await t(e));let{status:r,...i}=e,s=new URLSearchParams;for(let[p,m]of Object.entries(i))if(m!==void 0)s.set(p,String(m));for(let p of r===void 0?[]:[r].flat())s.append("status",p);let a=s.toString(),d=await P.get(k(`/v3/limit/orders${a?`?${a}`:""}`));return W(ze,d)}async function is(e){let{getLimitOrder:t}=A.get("endpoints"),r=t?await t(e):await P.get(k(`/v3/limit/orders/${encodeURIComponent(e)}`));return W(Ye,r)}async function ss(e){let{buildLimitOrderCancel:t}=A.get("endpoints"),r=t?await t(e):await P.post(k("/v3/limit/cancel/build"),{json:e,retry:{maxRetries:0}});return W(_n,r)}async function os(e){let{submitLimitOrderCancel:t}=A.get("endpoints"),r=t?await t(e):await P.post(k("/v3/limit/cancel/submit"),{json:e,retry:{maxRetries:0}});return W(hn,r)}function k(e){let{isDev:t,apiUrl:r,devApiUrl:i}=A.get("envs"),{enabled:s,quoteUrl:a,swapUrl:d}=A.get("localMode");if(s&&e){let[m]=e.split("?");if(m==="/quote"||m==="/v3/quote")return`${a}${e}`;if(m==="/swap"||m==="/v3/swap")return`${d}${e}`}return`${t?i:r}${e}`}function as(e){try{return D.from({asset:e.identifier})}catch{return}}var ls=new Set(["OP.OP"]),ds=/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/im;function cs(e){return e.filter((t)=>{let r=as(t);if(!r)return!1;if(ls.has(r.toString().toUpperCase()))return!0;return(!Qe.includes(r.chain)||r.isGasAsset||!!r.address)&&!ds.test(r.ticker)})}async function ps(e){let{getSwapTo:t}=A.get("endpoints");if(t)return t(e);let r=new URLSearchParams({sellAsset:e.sellAsset});if(e.providers?.length)for(let d of e.providers)r.append("providers",d);let i=k(`/swapTo?${r.toString()}`),s=await P.get(i);if(!Array.isArray(s))return{buyAssets:[],sellAsset:e.sellAsset};let a=[];for(let d of s)try{let p=D.from({asset:d});a.push({chain:p.chain,identifier:p.toString(),providers:[],symbol:p.symbol,ticker:p.ticker})}catch{}return{buyAssets:a,sellAsset:e.sellAsset}}var Je={};nt(Je,{getInboundAddresses:()=>fs,getLastBlock:()=>ms,getMimirInfo:()=>hs,getNodes:()=>_s,getRunePoolInfo:()=>ys,getRunePoolProviderInfo:()=>Ss,getTHORNodeTNSDetails:()=>fn,getTNSPreferredAsset:()=>bs,getTcyClaimer:()=>ws,getTcyClaimers:()=>xs,getTcyStaker:()=>As,getTcyStakers:()=>Ts,getThorchainQueue:()=>gs});function H(e){let t=A.get("thornodeUrls");return`${e==="mayachain"?t.MAYA:t.THOR}/${e??"thorchain"}`}function us(e){let t=e==="mayachain"?"mayaname":"thorname";return`${H(e)}/${t}`}function ms(e="thorchain"){return _.get(`${H(e)}/lastblock`)}function gs(e){return _.get(`${H(e)}/queue`)}function _s(e){return _.get(`${H(e)}/nodes`)}function hs(e){return _.get(`${H(e)}/mimir`)}function fs(e){return _.get(`${H(e)}/inbound_addresses`)}async function fn({type:e,name:t}){try{return await _.get(`${us(e)}/${t}`)}catch{return{affiliate_collector_rune:"",aliases:[],expire_block_height:0,name:t,owner:"",preferred_asset:""}}}async function bs({type:e,tns:t}){let r=await fn({name:t,type:e});if(!r.preferred_asset||r.preferred_asset===".")return;return D.from({asset:r.preferred_asset,asyncTokenLookup:!0})}function ys(e){return _.get(`${H(e)}/runepool`)}function Ss({type:e,thorAddress:t}){return _.get(`${H(e)}/rune_provider/${t}`)}function As({type:e,address:t}){return _.get(`${H(e)}/tcy_staker/${t}`)}function Ts(e){return _.get(`${H(e)}/tcy_stakers`)}function ws({type:e,address:t}){return _.get(`${H(e)}/tcy_claimer/${t}`)}function xs(e){return _.get(`${H(e)}/tcy_claimers`)}var Ia={...Xe,mayachainMidgard:Nt,thorchainMidgard:Lt,thornode:Je};
5
+ export{Is as a,oe as b,Ee as c,O as d,_e as e,xn as f,Rn as g,vn as h,y as i,Ps as j,he as k,st as l,Ns as m,In as n,Ds as o,L as p,A as q,_ as r,dt as s,Xs as t,ae as u,De as v,qn as w,J as x,io as y,so as z,oo as A,bo as B,Jn as C,xt as D,Rt as E,vt as F,Se as G,Ve as H,Y as I,de as J,yo as K,So as L,Z as M,K as N,dr as O,D as P,Eo as Q,Ie as R,Ut as S,ke as T,Bt as U,$t as V,Ft as W,Kt as X,qo as Y,Wo as Z,Go as _,jo as $,ie as aa,qt as ba,Yo as ca,Wt as da,zo as ea,Qo as fa,Gt as ga,Yr as ha,jt as ia,Dt as ja,Xo as ka,Yt as la,zt as ma,Jo as na,Zo as oa,qe as pa,We as qa,ri as ra,ea as sa,ta,ii as ua,si as va,oi as wa,na as xa,pi as ya,ui as za,mi as Aa,gi as Ba,ra as Ca,_i as Da,hi as Ea,Qt as Fa,ia as Ga,bi as Ha,sa as Ia,yi as Ja,Si as Ka,Jt as La,Zt as Ma,en as Na,Ti as Oa,tn as Pa,nn as Qa,rn as Ra,aa as Sa,la as Ta,xi as Ua,Ri as Va,vi as Wa,da as Xa,ca as Ya,Ci as Za,pa as _a,an as $a,Oi as ab,ua as bb,ln as cb,ki as db,Pi as eb,pn as fb,ma as gb,Ei as hb,un as ib,ga as jb,Li as kb,Ni as lb,Di as mb,Mi as nb,mn as ob,gn as pb,Vi as qb,Ye as rb,ze as sb,Hi as tb,Ui as ub,_n as vb,hn as wb,Ia as xb};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as Er,$a as bn,A as Gt,Aa as qr,B as Yt,Ba as Gr,C as Jt,Ca as Yr,D as Qt,Da as Jr,E as Zt,Ea as Qr,F as er,Fa as Zr,G as tr,Ga as en,H as rr,Ha as tn,I as nr,Ia as rn,J as or,Ja as nn,K as ir,Ka as on,L as ar,La as an,M as sr,Ma as sn,N as ur,Na as un,O as cr,Oa as cn,P as pr,Pa as pn,Q as dr,Qa as dn,R as f,Ra as mn,S as mr,Sa as ln,T as lr,Ta as hn,U as hr,Ua as fn,V as fr,Va as gn,W as gr,Wa as wn,X as wr,Xa as Pn,Y as Pr,Ya as vn,Z as vr,Za as yn,_ as yr,_a as En,a as v,aa as br,ab as Tn,b as Wt,ba as Tr,bb as An,c as $t,ca as Ar,cb as xn,d as Rt,da as xr,db as Sn,e as Dt,ea as Sr,eb as _n,f as L,fa as _r,fb as Cn,g as Ot,ga as Cr,gb as Mn,h as re,ha as Mr,hb as Wn,i as m,ia as Wr,ib as $n,j as kt,ja as $r,jb as Rn,k as c,ka as Rr,kb as Dn,l as It,la as Dr,lb as On,m as Nt,ma as Or,mb as kn,n as Ft,na as kr,nb as In,o as Lt,oa as Ir,ob as Nn,p as Bt,pa as Nr,pb as Fn,q as x,qa as Fr,qb as Ln,r as Ut,ra as Lr,rb as Bn,s as Kt,sa as Br,sb as Un,t as Ht,ta as Ur,tb as Kn,u as W,ua as Kr,ub as Hn,v as jt,va as Hr,vb as jn,w as zt,wa as jr,wb as zn,x as Vt,xa as zr,xb as Vn,y as Xt,ya as Vr,z as qt,za as Xr}from"./chunk-yd6dt60k.js";export*from"@swapkit/tokens";export*from"@swapkit/types";var B={average:1,fast:1.5,fastest:2};function S(e="average"){let t=x.get("feeMultipliers");if(t&&t[e]!==void 0)return t[e];return B[e]}function U(e="average"){let t=S(e),r=10n,n=BigInt(Math.round(t*10));return{denominator:r,numerator:n}}function he(e,t="average"){let{numerator:r,denominator:n}=U(t);return e*r/n}function fe(e,t="average",r=!1){let n=S(t),o=e*n;return r?Math.floor(o):o}import{Chain as P,EVMChains as K}from"@swapkit/types";import{match as H}from"ts-pattern";function g(e,t){let r=e.length-1;return e.map((o,i)=>{if(i===r&&t.index!==void 0)return t.index;if(i===0&&t.purpose!==void 0)return t.purpose;if(i===2&&t.account!==void 0)return t.account;if(i===3&&t.change!==void 0)return t.change;return o})}var h={bech32:84,legacy:44,p2sh:49,taproot:86},_;((o)=>{o.P2PKH="P2PKH";o.P2SH_P2WPKH="P2SH_P2WPKH";o.P2WPKH="P2WPKH";o.P2TR="P2TR"})(_||={});var j=Object.freeze({["P2PKH"]:{inputSize:148,outputSize:34,purpose:h.legacy,witness:!1},["P2SH_P2WPKH"]:{inputSize:91,outputSize:32,purpose:h.p2sh,witness:!0},["P2WPKH"]:{inputSize:68,outputSize:31,purpose:h.bech32,witness:!0},["P2TR"]:{inputSize:58,outputSize:43,purpose:h.taproot,witness:!0}}),z=Object.values(_);function V(e){if(e===void 0)return;return z.find((t)=>j[t].purpose===e)}function X(e){if(!e)return;if(typeof e!=="string")return e[0];let t=Number.parseInt(e.replace(/^[mM]'?\//,"").split("/")[0]??"",10);return Number.isNaN(t)?void 0:t}function ye(e){return V(X(e))}var q=Object.freeze([P.Near,P.Stellar,P.Sui]),Ee=Object.freeze([P.Ton]);function G({chain:e,derivationPath:t,index:r=0}){if(t)return t;return g(v[e],q.includes(e)?{account:r}:{index:r})}function Y([e,t,r,n,o],{allHardened:i}={}){let s=i?"'":"",a=typeof o!=="number";if(typeof n!=="number")return`m/${e}'/${t}'/${r}'`;return`m/${e}'/${t}'/${r}'/${n}${s}${a?"":`/${o}${s}`}`}function be({chain:e,index:t,addressIndex:r=0,type:n}){let o=v[e],i=K.includes(e)?"evm":e===P.Solana?"solana":"other";return H([i,n]).with(["evm","legacy"],["evm","account"],()=>[44,60,0,t]).with(["evm","ledgerLive"],()=>[44,60,t,0,r]).with(["evm","nativeSegwitMiddleAccount"],["evm","segwit"],["evm",void 0],()=>g(o,{index:t})).with(["solana","account"],()=>[44,501,0,t]).with(["solana","legacy"],["solana","ledgerLive"],["solana","nativeSegwitMiddleAccount"],["solana","segwit"],["solana",void 0],()=>g(o,{index:t})).with(["other","nativeSegwitMiddleAccount"],()=>g(o,{account:t,index:r,purpose:h.bech32})).with(["other","segwit"],()=>g(o,{account:0,index:t,purpose:h.p2sh})).with(["other","legacy"],()=>g(o,{account:0,index:t,purpose:h.legacy})).with(["other","account"],["other","ledgerLive"],["other",void 0],()=>G({chain:e,index:t})).exhaustive()}function Te(e){let[t,r]=e.split("/").map((n)=>Number.parseInt(n,10));switch(r){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Ae=Object.freeze(Object.fromEntries(Object.keys(v).map((e)=>[e,Y(v[e])])));import{Chain as J,getChainConfig as Q}from"@swapkit/types";function Z({liquidityUnits:e,poolUnits:t,runeDepth:r}){let n=p(e),o=p(t),i=p(r),s=n.mul(i),a=o.mul(o).mul(2),u=o.mul(n).mul(2),d=n.mul(n),l=o.mul(o).mul(o);return s.mul(a.sub(u).add(d)).div(l)}function ee({liquidityUnits:e,poolUnits:t,assetDepth:r}){let n=p(e),o=p(t),i=p(r),s=n.mul(i),a=o.mul(o).mul(2),u=o.mul(n).mul(2),d=n.mul(n),l=s.mul(a.sub(u).add(d)),w=o.mul(o).mul(o);return l.div(w)}function Ce({percent:e,runeDepth:t,liquidityUnits:r,poolUnits:n}){return Z({liquidityUnits:r,poolUnits:n,runeDepth:t}).mul(e)}function Me({percent:e,assetDepth:t,liquidityUnits:r,poolUnits:n}){return ee({assetDepth:t,liquidityUnits:r,poolUnits:n}).mul(e)}function p(e){return f.fromBigInt(BigInt(e),Q(J.THORChain).baseDecimal)}function te({liquidityUnits:e,poolUnits:t,runeDepth:r,assetDepth:n}){return{assetAmount:p(n).mul(e).div(t),runeAmount:p(r).mul(e).div(t)}}function We({liquidityUnits:e,poolUnits:t,runeDepth:r,assetDepth:n,percent:o}){return Object.fromEntries(Object.entries(te({assetDepth:n,liquidityUnits:e,poolUnits:t,runeDepth:r})).map(([i,s])=>[i,s.mul(o)]))}function $e({runeDepth:e,poolUnits:t,assetDepth:r,liquidityUnits:n,runeAmount:o,assetAmount:i}){let s=new f({decimal:8,value:e}),a=new f({decimal:8,value:r}),u=new f({decimal:8,value:t}),d=new f({decimal:8,value:o}),l=new f({decimal:8,value:i}),w=d.mul(a),T=l.mul(s),O=d.mul(l),k=s.mul(a),I=u.mul(w.add(T.add(O.mul(2)))),N=w.add(T.add(k.mul(2))),A=I.div(N),b=p(n).add(A);if(A.getBaseValue("number")===0)return b.div(u).getBaseValue("number");let F=u.add(b);return b.div(F).getBaseValue("number")}function Re({runeAmount:e,assetAmount:t,runeDepth:r,assetDepth:n}){if(e==="0"||t==="0"||r==="0"||n==="0")return 0;let o=p(r),i=p(n),s=p(t),a=p(e),u=s.mul(o).sub(i.mul(a)),d=i.mul(a).add(o.mul(i));return Math.abs(u.div(d).getBaseValue("number"))}import{Chain as y}from"@swapkit/types";import{match as ne}from"ts-pattern";function Fe({type:e,address:t}){return`${e}:${t}`}function Le({address:e,unbondAmount:t}){return`${"UNBOND"}:${e}:${t}`}function Be(e){return E("POOL+",e)}function Ue({chain:e,symbol:t,address:r,...n}){let o=oe({chain:e,symbol:t}),i=r?`:${r}:`:":";return E(`${"+"}:${o}${i}`,n)}function Ke({chain:e,symbol:t,ticker:r,basisPoints:n,targetAsset:o}){let i=e==="ETH"&&r!=="ETH"?`${r}-${t.slice(-3)}`:t,s=o?`:${o}`:"";return`${"-"}:${e}.${i}:${n}${s}`}function He({basisPoints:e,...t}){return E(`${"POOL-"}:${e}`,t)}function je({name:e,chain:t,address:r,owner:n}){let o=`${"~"}:${e}:${t}:${r}`,i=n?`:${n}`:"";return`${o}${i}`}function ze({name:e,chain:t,asset:r,payout:n,owner:o}){return`${"~"}:${e}:${t}:${n}:${o}:${r}`}function Ve(e,{address:t}){return`${e}:${t}`}function Xe(e,{unstakeBps:t,...r}){let n=t?`:${t}`:"",o=`${e}${n}`;return E(`${o}`,r)}function E(e,{affiliateAddress:t,affiliateBasisPoints:r}={}){let n=`${e}${t?`:${t}:${r||0}`:""}`;return n.endsWith(":")?n.slice(0,-1):n}function oe({chain:e,symbol:t}){return ne(e).with(y.Bitcoin,y.Dogecoin,y.Litecoin,()=>e.slice(0,1).toLowerCase()).with(y.BitcoinCash,()=>"c").otherwise(()=>`${e}.${t}`)}function qe(e){if(e<0)throw new m({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:e}});return Math.round((10+Math.max(0,e-1)*1.0512)*1e8)/1e8}function Ge(e){if(e<0)throw new m({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:e}});return Math.round((10+Math.max(0,e-1)*1.0512)*10000000000)/10000000000}function Ye(e){if(e.length>30)return!1;let t=/^[a-zA-Z0-9+_-]+$/g;return!!e.match(t)}import{getChainConfig as R}from"@swapkit/types";function rt(){return typeof window.ethereum<"u"}function nt(e){return ie().includes(e)}function ie(){let e=window?.ethereum&&!window.ethereum?.isBraveWallet,t=window?.vultisig,r=window?.ethereum?.isBraveWallet,n=window?.ethereum?.isTrust||window?.trustwallet,o=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,i=window?.bitkeep?.ethereum,s=window?.$onekey?.ethereum,a=[];if(e)a.push(c.METAMASK);if(t)a.push(c.VULTISIG);if(r)a.push(c.BRAVE);if(n)a.push(c.TRUSTWALLET_WEB);if(o)a.push(c.COINBASE_WEB);if(de())a.push(c.OKX_MOBILE);if(i)a.push(c.BITGET);if(s)a.push(c.ONEKEY);return a}var C=new Set([4001,5000,"ACTION_REJECTED"]);function ot(e){return(e?.signing?.direct??e?.supportsDirectSigning)===!0}function M(e){if(!e||typeof e!=="object")return!1;let{code:t,error:r,info:n,data:o}=e;if(C.has(t))return!0;return[r,n?.error,o?.originalError].some((i)=>!!i&&typeof i==="object"&&C.has(i.code))}async function ae(e,t){if(!t)return!1;try{let{chainId:r}=await e.getNetwork();return BigInt(r)===BigInt(t)}catch{return!1}}async function se(e,t,r){let n=R(t);try{await D({method:"wallet_switchEthereumChain",params:[{chainId:n.chainIdHex}],provider:e})}catch(o){if(M(o))throw new m("helpers_failed_to_switch_network",{chain:t,error:o,reason:"user rejected request"});if(!r)throw new m("helpers_failed_to_switch_network",{chain:t,error:o,reason:"networkParams not provided"});try{await pe(e,r)}catch(i){throw new m("helpers_failed_to_switch_network",{chain:t,error:i,reason:M(i)?"user rejected adding the network":"failed to add the network"})}}}function it({chains:e,supportedChains:t,walletType:r}){let n=e.filter((i)=>!i||t.includes(i));if(n.length===0)throw new m("wallet_chain_not_supported",{chain:e.join(", "),wallet:r});let o=e.filter((i)=>!t.includes(i));return W({condition:o.length>0,id:`wallet_chain_not_supported_${r}`,warning:`${r} wallet does not support the following chains: ${o.join(", ")}. These chains will be ignored.`}),n}function ue(e,t,r,n){return async(...o)=>{let{chainIdHex:i}=R(r);if(await ae(t,i))return e(...o);try{await se(t,r,n)}catch(s){if(s instanceof m)throw s;throw new m({errorKey:"helpers_failed_to_switch_network",info:{chain:r,error:s}})}return e(...o)}}function at({toolbox:e,chain:t,provider:r,methodNames:n=[],networkParams:o=ce(e)}){let s=[...n,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject","signTypedData"].reduce((a,u)=>{if(!e[u])return a;let d=e[u];if(typeof d!=="function")return a;let l=ue(d,r,t,o);return{...a,[u]:l}},{});return{...e,...s}}function ce(e){let t=e.getNetworkParams;if(typeof t!=="function")return;try{let r=t();return r&&typeof r==="object"&&"chainId"in r?r:void 0}catch{return}}function pe(e,t){return D({method:"wallet_addEthereumChain",params:[t],provider:e})}function st(e){window.ethereum?.on("accountsChanged",()=>e())}function ut(){let{isTrust:e,isBraveWallet:t,overrideIsMetaMask:r,selectedProvider:n}=window?.ethereum||{};if(e)return c.TRUSTWALLET_WEB;if(t)return c.BRAVE;if(r&&n?.isCoinbaseWallet)return c.COINBASE_WEB;if(window?.$onekey?.ethereum)return c.ONEKEY;return c.METAMASK}function ct(){let e=[];function t(n){if(e.map((o)=>o.info.uuid).includes(n.detail.info.uuid))return;e.push(n.detail)}window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider"));function r(){window.removeEventListener("eip6963:announceProvider",t)}return{providers:e,removeEIP6963EventListener:r}}function de(){let e=navigator.userAgent,t=/iphone|ipad|ipod|ios/i.test(e),r=/android|XiaoMi|MiuiBrowser/i.test(e),n=t||r,o=/OKApp/i.test(e);return n&&o}function D({provider:e,params:t,method:r}){if(!e?.send)throw new m("helpers_not_found_provider");let n=t?Array.isArray(t)?t:[t]:[];return e.send(r,n)}export{q as ACCOUNT_INDEXED_CHAINS,Er as ApiV2ErrorSchema,fn as ApprovalTransactionSchema,Ot as ApproveMode,ln as ApproveRequestParams,hn as ApproveResponseSchema,pr as AssetValue,br as AssetValueSchema,ur as BigIntArithmetics,Mr as BrokerDepositChannelParamsSchema,on as ChainflipMetadataSchema,Tr as CoinGeckoMetadataSchema,Yt as CommonAssetStrings,Vr as CosmosTransactionSchema,B as DEFAULT_FEE_MULTIPLIERS,Cr as DepositChannelParamsSchema,Wr as DepositChannelResponseSchema,Ae as DerivationPath,jr as EVMTransactionDetailsParamsSchema,zr as EVMTransactionDetailsSchema,Kr as EVMTransactionSchema,Wt as ErrorCode,Fr as EstimatedTimeSchema,L as FeeOption,Dt as FeeTypeEnum,Nr as FeesSchema,mn as GasResponseSchema,dn as GasSchema,Yr as HYPERCORE_USDC_TOKEN_ID,Jr as HyperCoreEip712TypedDataSchema,Qr as HyperCoreSendAssetActionSchema,en as HyperCoreSendAssetTransactionSchema,Zr as HyperCoreTypedDataTransactionSchema,Ft as LedgerErrorCode,In as LimitOrderApprovalTxSchema,Rn as LimitOrderBuildRequestSchema,Nn as LimitOrderBuildResponseSchema,jn as LimitOrderCancelBuildResponseSchema,zn as LimitOrderCancelSubmitResponseSchema,Hn as LimitOrderCancelTxSchema,Kn as LimitOrderCancelTypedDataSchema,On as LimitOrderEVMTransactionSchema,Un as LimitOrderListResponseSchema,Mn as LimitOrderQuoteRequestSchema,$n as LimitOrderQuoteResponseSchema,Wn as LimitOrderQuoteRouteSchema,Bn as LimitOrderSchema,Sn as LimitOrderStatus,Fn as LimitOrderSubmitResponseSchema,Cn as LimitOrderTokensResponseSchema,Ln as LimitOrderTxHashSchema,kn as LimitOrderTxMetaSchema,_n as LimitOrderTxType,Dn as LimitOrderTypedDataSchema,re as MemoType,$r as NearDepositChannelParamsSchema,Rr as NearDepositChannelResultSchema,Dr as NearSwapResponseSchema,v as NetworkDerivationPath,_r as PriceRequestSchema,xr as PriceResponseSchema,mr as PriorityLabel,fr as ProviderAction,Rt as ProviderName,Sr as QuoteRequestSchema,cn as QuoteResponseRouteItem,pn as QuoteResponseSchema,bn as QuoteRouteV2Response,An as QuoteV2ResponseSchema,Pn as QuoteV3ResponseSchema,Ut as RequestClient,tn as RouteLegSchema,rn as RouteLegWithoutAddressesSchema,nn as RouteQuoteMetadataAssetSchema,an as RouteQuoteMetadataSchema,sn as RouteQuoteMetadataV2Schema,Tn as RouteQuoteProviderErrorSchema,lr as RouteQuoteTxType,un as RouteQuoteWarningSchema,Ee as SINGLE_WALLET_CHAINS,x as SKConfig,Lt as SigningCapability,Xr as StarknetTransactionSchema,gn as StellarApprovalTransactionSchema,wn as SwapApprovalTransactionSchema,Vn as SwapKitApi,m as SwapKitError,f as SwapKitNumber,xn as SwapRouteV2ResponseSchema,yn as SwapToAssetSchema,vn as SwapToRequestSchema,En as SwapToResponseSchema,qr as TONTransactionMessageSchema,Gr as TONTransactionSchema,Ar as TokenDetailsMetadataSchema,Pr as TokenSchema,Or as TrackerResponseSchema,yr as TrackingRequestQuerySchema,vr as TrackingRequestSchema,wr as TrackingStatus,Ir as TransactionDTOSchema,kr as TransactionSchema,Hr as TronTransactionSchema,gr as TxnStatus,hr as TxnType,h as UTXOPurpose,_ as UTXOScriptType,j as UTXO_SCRIPT_TYPES,z as UTXO_SCRIPT_TYPE_LIST,c as WalletOption,$t as WarningCodeEnum,jt as _rpcCache,st as addAccountsChangedCallback,pe as addEVMWalletNetwork,fe as applyFeeMultiplier,he as applyFeeMultiplierToBigInt,nr as assetFromString,Qt as decodeABIDynamicString,Jt as decodeABIString,Y as derivationPathToString,Zt as fetchTokenInfo,it as filterSupportedChains,ar as findAssetBy,sr as formatBigIntToSafeValue,rr as getAssetType,ee as getAsymmetricAssetShare,Me as getAsymmetricAssetWithdrawAmount,Z as getAsymmetricRuneShare,Ce as getAsymmetricRuneWithdrawAmount,Gt as getChainIdentifier,tr as getCommonAssetInfo,be as getDerivationPathFor,ct as getEIP6963Wallets,ut as getETHDefaultWallet,$e as getEstimatedPoolShare,qt as getExplorerAddressUrl,Xt as getExplorerTxUrl,S as getFeeMultiplier,U as getFeeMultiplierAsBigInt,Re as getLiquiditySlippage,Ge as getMAYANameCost,Ue as getMemoForDeposit,Fe as getMemoForLeaveAndBond,ze as getMemoForNamePreferredAssetRegister,je as getMemoForNameRegister,Be as getMemoForRunePoolDeposit,He as getMemoForRunePoolWithdraw,Ve as getMemoForTcyClaim,Xe as getMemoForTcyStake,Le as getMemoForUnbond,Ke as getMemoForWithdraw,dr as getMinAmountByChain,X as getPurposeFromPath,Vt as getRPCUrl,zt as getRPCUrlSync,te as getSymmetricPoolShare,We as getSymmetricWithdraw,qe as getTHORNameCost,ir as getTokenLogoURI,ye as getUTXOScriptTypeForPath,V as getUTXOScriptTypeForPurpose,Te as getWalletFormatFor,nt as isDetected,er as isGasAsset,Lr as isTransactionValue,M as isUserRejectedRequest,rt as isWeb3Detected,ie as listWeb3EVMWallets,de as okxMobileEnabled,or as parseSymbolForAddress,Br as parseTransactionValue,at as prepareNetworkSwitch,D as providerRequest,kt as registerErrorCodes,Nt as registerWalletOption,G as resolveDerivationPath,Kt as signWidgetRequest,It as subscribeWalletOptionRegistration,Bt as swapKitConfigStore,se as switchEVMWalletNetwork,Ur as toHexTransactionValue,g as updateDerivationPath,cr as validateIdentifier,Ye as validateTNS,ot as walletSupportsDirectSigning,W as warnOnce,ue as wrapMethodWithNetworkSwitch,Ht as wrapWithThrow};
1
+ import{$ as Er,$a as bn,A as Gt,Aa as qr,B as Yt,Ba as Gr,C as Jt,Ca as Yr,D as Qt,Da as Jr,E as Zt,Ea as Qr,F as er,Fa as Zr,G as tr,Ga as en,H as rr,Ha as tn,I as nr,Ia as rn,J as or,Ja as nn,K as ir,Ka as on,L as ar,La as an,M as sr,Ma as sn,N as ur,Na as un,O as cr,Oa as cn,P as pr,Pa as pn,Q as dr,Qa as dn,R as f,Ra as mn,S as mr,Sa as ln,T as lr,Ta as hn,U as hr,Ua as fn,V as fr,Va as gn,W as gr,Wa as wn,X as wr,Xa as Pn,Y as Pr,Ya as vn,Z as vr,Za as yn,_ as yr,_a as En,a as v,aa as br,ab as Tn,b as Wt,ba as Tr,bb as An,c as $t,ca as Ar,cb as xn,d as Rt,da as xr,db as Sn,e as Dt,ea as Sr,eb as _n,f as L,fa as _r,fb as Cn,g as Ot,ga as Cr,gb as Mn,h as re,ha as Mr,hb as Wn,i as m,ia as Wr,ib as $n,j as kt,ja as $r,jb as Rn,k as c,ka as Rr,kb as Dn,l as It,la as Dr,lb as On,m as Nt,ma as Or,mb as kn,n as Ft,na as kr,nb as In,o as Lt,oa as Ir,ob as Nn,p as Bt,pa as Nr,pb as Fn,q as x,qa as Fr,qb as Ln,r as Ut,ra as Lr,rb as Bn,s as Kt,sa as Br,sb as Un,t as Ht,ta as Ur,tb as Kn,u as W,ua as Kr,ub as Hn,v as jt,va as Hr,vb as jn,w as zt,wa as jr,wb as zn,x as Vt,xa as zr,xb as Vn,y as Xt,ya as Vr,z as qt,za as Xr}from"./chunk-qcbm6whm.js";export*from"@swapkit/tokens";export*from"@swapkit/types";var B={average:1,fast:1.5,fastest:2};function S(e="average"){let t=x.get("feeMultipliers");if(t&&t[e]!==void 0)return t[e];return B[e]}function U(e="average"){let t=S(e),r=10n,n=BigInt(Math.round(t*10));return{denominator:r,numerator:n}}function he(e,t="average"){let{numerator:r,denominator:n}=U(t);return e*r/n}function fe(e,t="average",r=!1){let n=S(t),o=e*n;return r?Math.floor(o):o}import{Chain as P,EVMChains as K}from"@swapkit/types";import{match as H}from"ts-pattern";function g(e,t){let r=e.length-1;return e.map((o,i)=>{if(i===r&&t.index!==void 0)return t.index;if(i===0&&t.purpose!==void 0)return t.purpose;if(i===2&&t.account!==void 0)return t.account;if(i===3&&t.change!==void 0)return t.change;return o})}var h={bech32:84,legacy:44,p2sh:49,taproot:86},_;((o)=>{o.P2PKH="P2PKH";o.P2SH_P2WPKH="P2SH_P2WPKH";o.P2WPKH="P2WPKH";o.P2TR="P2TR"})(_||={});var j=Object.freeze({["P2PKH"]:{inputSize:148,outputSize:34,purpose:h.legacy,witness:!1},["P2SH_P2WPKH"]:{inputSize:91,outputSize:32,purpose:h.p2sh,witness:!0},["P2WPKH"]:{inputSize:68,outputSize:31,purpose:h.bech32,witness:!0},["P2TR"]:{inputSize:58,outputSize:43,purpose:h.taproot,witness:!0}}),z=Object.values(_);function V(e){if(e===void 0)return;return z.find((t)=>j[t].purpose===e)}function X(e){if(!e)return;if(typeof e!=="string")return e[0];let t=Number.parseInt(e.replace(/^[mM]'?\//,"").split("/")[0]??"",10);return Number.isNaN(t)?void 0:t}function ye(e){return V(X(e))}var q=Object.freeze([P.Near,P.Stellar,P.Sui]),Ee=Object.freeze([P.Ton]);function G({chain:e,derivationPath:t,index:r=0}){if(t)return t;return g(v[e],q.includes(e)?{account:r}:{index:r})}function Y([e,t,r,n,o],{allHardened:i}={}){let s=i?"'":"",a=typeof o!=="number";if(typeof n!=="number")return`m/${e}'/${t}'/${r}'`;return`m/${e}'/${t}'/${r}'/${n}${s}${a?"":`/${o}${s}`}`}function be({chain:e,index:t,addressIndex:r=0,type:n}){let o=v[e],i=K.includes(e)?"evm":e===P.Solana?"solana":"other";return H([i,n]).with(["evm","legacy"],["evm","account"],()=>[44,60,0,t]).with(["evm","ledgerLive"],()=>[44,60,t,0,r]).with(["evm","nativeSegwitMiddleAccount"],["evm","segwit"],["evm",void 0],()=>g(o,{index:t})).with(["solana","account"],()=>[44,501,0,t]).with(["solana","legacy"],["solana","ledgerLive"],["solana","nativeSegwitMiddleAccount"],["solana","segwit"],["solana",void 0],()=>g(o,{index:t})).with(["other","nativeSegwitMiddleAccount"],()=>g(o,{account:t,index:r,purpose:h.bech32})).with(["other","segwit"],()=>g(o,{account:0,index:t,purpose:h.p2sh})).with(["other","legacy"],()=>g(o,{account:0,index:t,purpose:h.legacy})).with(["other","account"],["other","ledgerLive"],["other",void 0],()=>G({chain:e,index:t})).exhaustive()}function Te(e){let[t,r]=e.split("/").map((n)=>Number.parseInt(n,10));switch(r){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Ae=Object.freeze(Object.fromEntries(Object.keys(v).map((e)=>[e,Y(v[e])])));import{Chain as J,getChainConfig as Q}from"@swapkit/types";function Z({liquidityUnits:e,poolUnits:t,runeDepth:r}){let n=p(e),o=p(t),i=p(r),s=n.mul(i),a=o.mul(o).mul(2),u=o.mul(n).mul(2),d=n.mul(n),l=o.mul(o).mul(o);return s.mul(a.sub(u).add(d)).div(l)}function ee({liquidityUnits:e,poolUnits:t,assetDepth:r}){let n=p(e),o=p(t),i=p(r),s=n.mul(i),a=o.mul(o).mul(2),u=o.mul(n).mul(2),d=n.mul(n),l=s.mul(a.sub(u).add(d)),w=o.mul(o).mul(o);return l.div(w)}function Ce({percent:e,runeDepth:t,liquidityUnits:r,poolUnits:n}){return Z({liquidityUnits:r,poolUnits:n,runeDepth:t}).mul(e)}function Me({percent:e,assetDepth:t,liquidityUnits:r,poolUnits:n}){return ee({assetDepth:t,liquidityUnits:r,poolUnits:n}).mul(e)}function p(e){return f.fromBigInt(BigInt(e),Q(J.THORChain).baseDecimal)}function te({liquidityUnits:e,poolUnits:t,runeDepth:r,assetDepth:n}){return{assetAmount:p(n).mul(e).div(t),runeAmount:p(r).mul(e).div(t)}}function We({liquidityUnits:e,poolUnits:t,runeDepth:r,assetDepth:n,percent:o}){return Object.fromEntries(Object.entries(te({assetDepth:n,liquidityUnits:e,poolUnits:t,runeDepth:r})).map(([i,s])=>[i,s.mul(o)]))}function $e({runeDepth:e,poolUnits:t,assetDepth:r,liquidityUnits:n,runeAmount:o,assetAmount:i}){let s=new f({decimal:8,value:e}),a=new f({decimal:8,value:r}),u=new f({decimal:8,value:t}),d=new f({decimal:8,value:o}),l=new f({decimal:8,value:i}),w=d.mul(a),T=l.mul(s),O=d.mul(l),k=s.mul(a),I=u.mul(w.add(T.add(O.mul(2)))),N=w.add(T.add(k.mul(2))),A=I.div(N),b=p(n).add(A);if(A.getBaseValue("number")===0)return b.div(u).getBaseValue("number");let F=u.add(b);return b.div(F).getBaseValue("number")}function Re({runeAmount:e,assetAmount:t,runeDepth:r,assetDepth:n}){if(e==="0"||t==="0"||r==="0"||n==="0")return 0;let o=p(r),i=p(n),s=p(t),a=p(e),u=s.mul(o).sub(i.mul(a)),d=i.mul(a).add(o.mul(i));return Math.abs(u.div(d).getBaseValue("number"))}import{Chain as y}from"@swapkit/types";import{match as ne}from"ts-pattern";function Fe({type:e,address:t}){return`${e}:${t}`}function Le({address:e,unbondAmount:t}){return`${"UNBOND"}:${e}:${t}`}function Be(e){return E("POOL+",e)}function Ue({chain:e,symbol:t,address:r,...n}){let o=oe({chain:e,symbol:t}),i=r?`:${r}:`:":";return E(`${"+"}:${o}${i}`,n)}function Ke({chain:e,symbol:t,ticker:r,basisPoints:n,targetAsset:o}){let i=e==="ETH"&&r!=="ETH"?`${r}-${t.slice(-3)}`:t,s=o?`:${o}`:"";return`${"-"}:${e}.${i}:${n}${s}`}function He({basisPoints:e,...t}){return E(`${"POOL-"}:${e}`,t)}function je({name:e,chain:t,address:r,owner:n}){let o=`${"~"}:${e}:${t}:${r}`,i=n?`:${n}`:"";return`${o}${i}`}function ze({name:e,chain:t,asset:r,payout:n,owner:o}){return`${"~"}:${e}:${t}:${n}:${o}:${r}`}function Ve(e,{address:t}){return`${e}:${t}`}function Xe(e,{unstakeBps:t,...r}){let n=t?`:${t}`:"",o=`${e}${n}`;return E(`${o}`,r)}function E(e,{affiliateAddress:t,affiliateBasisPoints:r}={}){let n=`${e}${t?`:${t}:${r||0}`:""}`;return n.endsWith(":")?n.slice(0,-1):n}function oe({chain:e,symbol:t}){return ne(e).with(y.Bitcoin,y.Dogecoin,y.Litecoin,()=>e.slice(0,1).toLowerCase()).with(y.BitcoinCash,()=>"c").otherwise(()=>`${e}.${t}`)}function qe(e){if(e<0)throw new m({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:e}});return Math.round((10+Math.max(0,e-1)*1.0512)*1e8)/1e8}function Ge(e){if(e<0)throw new m({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:e}});return Math.round((10+Math.max(0,e-1)*1.0512)*10000000000)/10000000000}function Ye(e){if(e.length>30)return!1;let t=/^[a-zA-Z0-9+_-]+$/g;return!!e.match(t)}import{getChainConfig as R}from"@swapkit/types";function rt(){return typeof window.ethereum<"u"}function nt(e){return ie().includes(e)}function ie(){let e=window?.ethereum&&!window.ethereum?.isBraveWallet,t=window?.vultisig,r=window?.ethereum?.isBraveWallet,n=window?.ethereum?.isTrust||window?.trustwallet,o=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,i=window?.bitkeep?.ethereum,s=window?.$onekey?.ethereum,a=[];if(e)a.push(c.METAMASK);if(t)a.push(c.VULTISIG);if(r)a.push(c.BRAVE);if(n)a.push(c.TRUSTWALLET_WEB);if(o)a.push(c.COINBASE_WEB);if(de())a.push(c.OKX_MOBILE);if(i)a.push(c.BITGET);if(s)a.push(c.ONEKEY);return a}var C=new Set([4001,5000,"ACTION_REJECTED"]);function ot(e){return(e?.signing?.direct??e?.supportsDirectSigning)===!0}function M(e){if(!e||typeof e!=="object")return!1;let{code:t,error:r,info:n,data:o}=e;if(C.has(t))return!0;return[r,n?.error,o?.originalError].some((i)=>!!i&&typeof i==="object"&&C.has(i.code))}async function ae(e,t){if(!t)return!1;try{let{chainId:r}=await e.getNetwork();return BigInt(r)===BigInt(t)}catch{return!1}}async function se(e,t,r){let n=R(t);try{await D({method:"wallet_switchEthereumChain",params:[{chainId:n.chainIdHex}],provider:e})}catch(o){if(M(o))throw new m("helpers_failed_to_switch_network",{chain:t,error:o,reason:"user rejected request"});if(!r)throw new m("helpers_failed_to_switch_network",{chain:t,error:o,reason:"networkParams not provided"});try{await pe(e,r)}catch(i){throw new m("helpers_failed_to_switch_network",{chain:t,error:i,reason:M(i)?"user rejected adding the network":"failed to add the network"})}}}function it({chains:e,supportedChains:t,walletType:r}){let n=e.filter((i)=>!i||t.includes(i));if(n.length===0)throw new m("wallet_chain_not_supported",{chain:e.join(", "),wallet:r});let o=e.filter((i)=>!t.includes(i));return W({condition:o.length>0,id:`wallet_chain_not_supported_${r}`,warning:`${r} wallet does not support the following chains: ${o.join(", ")}. These chains will be ignored.`}),n}function ue(e,t,r,n){return async(...o)=>{let{chainIdHex:i}=R(r);if(await ae(t,i))return e(...o);try{await se(t,r,n)}catch(s){if(s instanceof m)throw s;throw new m({errorKey:"helpers_failed_to_switch_network",info:{chain:r,error:s}})}return e(...o)}}function at({toolbox:e,chain:t,provider:r,methodNames:n=[],networkParams:o=ce(e)}){let s=[...n,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject","signTypedData"].reduce((a,u)=>{if(!e[u])return a;let d=e[u];if(typeof d!=="function")return a;let l=ue(d,r,t,o);return{...a,[u]:l}},{});return{...e,...s}}function ce(e){let t=e.getNetworkParams;if(typeof t!=="function")return;try{let r=t();return r&&typeof r==="object"&&"chainId"in r?r:void 0}catch{return}}function pe(e,t){return D({method:"wallet_addEthereumChain",params:[t],provider:e})}function st(e){window.ethereum?.on("accountsChanged",()=>e())}function ut(){let{isTrust:e,isBraveWallet:t,overrideIsMetaMask:r,selectedProvider:n}=window?.ethereum||{};if(e)return c.TRUSTWALLET_WEB;if(t)return c.BRAVE;if(r&&n?.isCoinbaseWallet)return c.COINBASE_WEB;if(window?.$onekey?.ethereum)return c.ONEKEY;return c.METAMASK}function ct(){let e=[];function t(n){if(e.map((o)=>o.info.uuid).includes(n.detail.info.uuid))return;e.push(n.detail)}window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider"));function r(){window.removeEventListener("eip6963:announceProvider",t)}return{providers:e,removeEIP6963EventListener:r}}function de(){let e=navigator.userAgent,t=/iphone|ipad|ipod|ios/i.test(e),r=/android|XiaoMi|MiuiBrowser/i.test(e),n=t||r,o=/OKApp/i.test(e);return n&&o}function D({provider:e,params:t,method:r}){if(!e?.send)throw new m("helpers_not_found_provider");let n=t?Array.isArray(t)?t:[t]:[];return e.send(r,n)}export{q as ACCOUNT_INDEXED_CHAINS,Er as ApiV2ErrorSchema,fn as ApprovalTransactionSchema,Ot as ApproveMode,ln as ApproveRequestParams,hn as ApproveResponseSchema,pr as AssetValue,br as AssetValueSchema,ur as BigIntArithmetics,Mr as BrokerDepositChannelParamsSchema,on as ChainflipMetadataSchema,Tr as CoinGeckoMetadataSchema,Yt as CommonAssetStrings,Vr as CosmosTransactionSchema,B as DEFAULT_FEE_MULTIPLIERS,Cr as DepositChannelParamsSchema,Wr as DepositChannelResponseSchema,Ae as DerivationPath,jr as EVMTransactionDetailsParamsSchema,zr as EVMTransactionDetailsSchema,Kr as EVMTransactionSchema,Wt as ErrorCode,Fr as EstimatedTimeSchema,L as FeeOption,Dt as FeeTypeEnum,Nr as FeesSchema,mn as GasResponseSchema,dn as GasSchema,Yr as HYPERCORE_USDC_TOKEN_ID,Jr as HyperCoreEip712TypedDataSchema,Qr as HyperCoreSendAssetActionSchema,en as HyperCoreSendAssetTransactionSchema,Zr as HyperCoreTypedDataTransactionSchema,Ft as LedgerErrorCode,In as LimitOrderApprovalTxSchema,Rn as LimitOrderBuildRequestSchema,Nn as LimitOrderBuildResponseSchema,jn as LimitOrderCancelBuildResponseSchema,zn as LimitOrderCancelSubmitResponseSchema,Hn as LimitOrderCancelTxSchema,Kn as LimitOrderCancelTypedDataSchema,On as LimitOrderEVMTransactionSchema,Un as LimitOrderListResponseSchema,Mn as LimitOrderQuoteRequestSchema,$n as LimitOrderQuoteResponseSchema,Wn as LimitOrderQuoteRouteSchema,Bn as LimitOrderSchema,Sn as LimitOrderStatus,Fn as LimitOrderSubmitResponseSchema,Cn as LimitOrderTokensResponseSchema,Ln as LimitOrderTxHashSchema,kn as LimitOrderTxMetaSchema,_n as LimitOrderTxType,Dn as LimitOrderTypedDataSchema,re as MemoType,$r as NearDepositChannelParamsSchema,Rr as NearDepositChannelResultSchema,Dr as NearSwapResponseSchema,v as NetworkDerivationPath,_r as PriceRequestSchema,xr as PriceResponseSchema,mr as PriorityLabel,fr as ProviderAction,Rt as ProviderName,Sr as QuoteRequestSchema,cn as QuoteResponseRouteItem,pn as QuoteResponseSchema,bn as QuoteRouteV2Response,An as QuoteV2ResponseSchema,Pn as QuoteV3ResponseSchema,Ut as RequestClient,tn as RouteLegSchema,rn as RouteLegWithoutAddressesSchema,nn as RouteQuoteMetadataAssetSchema,an as RouteQuoteMetadataSchema,sn as RouteQuoteMetadataV2Schema,Tn as RouteQuoteProviderErrorSchema,lr as RouteQuoteTxType,un as RouteQuoteWarningSchema,Ee as SINGLE_WALLET_CHAINS,x as SKConfig,Lt as SigningCapability,Xr as StarknetTransactionSchema,gn as StellarApprovalTransactionSchema,wn as SwapApprovalTransactionSchema,Vn as SwapKitApi,m as SwapKitError,f as SwapKitNumber,xn as SwapRouteV2ResponseSchema,yn as SwapToAssetSchema,vn as SwapToRequestSchema,En as SwapToResponseSchema,qr as TONTransactionMessageSchema,Gr as TONTransactionSchema,Ar as TokenDetailsMetadataSchema,Pr as TokenSchema,Or as TrackerResponseSchema,yr as TrackingRequestQuerySchema,vr as TrackingRequestSchema,wr as TrackingStatus,Ir as TransactionDTOSchema,kr as TransactionSchema,Hr as TronTransactionSchema,gr as TxnStatus,hr as TxnType,h as UTXOPurpose,_ as UTXOScriptType,j as UTXO_SCRIPT_TYPES,z as UTXO_SCRIPT_TYPE_LIST,c as WalletOption,$t as WarningCodeEnum,jt as _rpcCache,st as addAccountsChangedCallback,pe as addEVMWalletNetwork,fe as applyFeeMultiplier,he as applyFeeMultiplierToBigInt,nr as assetFromString,Qt as decodeABIDynamicString,Jt as decodeABIString,Y as derivationPathToString,Zt as fetchTokenInfo,it as filterSupportedChains,ar as findAssetBy,sr as formatBigIntToSafeValue,rr as getAssetType,ee as getAsymmetricAssetShare,Me as getAsymmetricAssetWithdrawAmount,Z as getAsymmetricRuneShare,Ce as getAsymmetricRuneWithdrawAmount,Gt as getChainIdentifier,tr as getCommonAssetInfo,be as getDerivationPathFor,ct as getEIP6963Wallets,ut as getETHDefaultWallet,$e as getEstimatedPoolShare,qt as getExplorerAddressUrl,Xt as getExplorerTxUrl,S as getFeeMultiplier,U as getFeeMultiplierAsBigInt,Re as getLiquiditySlippage,Ge as getMAYANameCost,Ue as getMemoForDeposit,Fe as getMemoForLeaveAndBond,ze as getMemoForNamePreferredAssetRegister,je as getMemoForNameRegister,Be as getMemoForRunePoolDeposit,He as getMemoForRunePoolWithdraw,Ve as getMemoForTcyClaim,Xe as getMemoForTcyStake,Le as getMemoForUnbond,Ke as getMemoForWithdraw,dr as getMinAmountByChain,X as getPurposeFromPath,Vt as getRPCUrl,zt as getRPCUrlSync,te as getSymmetricPoolShare,We as getSymmetricWithdraw,qe as getTHORNameCost,ir as getTokenLogoURI,ye as getUTXOScriptTypeForPath,V as getUTXOScriptTypeForPurpose,Te as getWalletFormatFor,nt as isDetected,er as isGasAsset,Lr as isTransactionValue,M as isUserRejectedRequest,rt as isWeb3Detected,ie as listWeb3EVMWallets,de as okxMobileEnabled,or as parseSymbolForAddress,Br as parseTransactionValue,at as prepareNetworkSwitch,D as providerRequest,kt as registerErrorCodes,Nt as registerWalletOption,G as resolveDerivationPath,Kt as signWidgetRequest,It as subscribeWalletOptionRegistration,Bt as swapKitConfigStore,se as switchEVMWalletNetwork,Ur as toHexTransactionValue,g as updateDerivationPath,cr as validateIdentifier,Ye as validateTNS,ot as walletSupportsDirectSigning,W as warnOnce,ue as wrapMethodWithNetworkSwitch,Ht as wrapWithThrow};
@@ -114,6 +114,7 @@ export declare const SwapKitApi: {
114
114
  image: string;
115
115
  price: number;
116
116
  }[] | undefined;
117
+ isSweep?: boolean | undefined;
117
118
  maxStreamingQuantity?: number | undefined;
118
119
  streamingInterval?: number | undefined;
119
120
  affiliate?: string | undefined;
@@ -306,6 +307,7 @@ export declare const SwapKitApi: {
306
307
  routeId: string;
307
308
  sourceAddress: string;
308
309
  destinationAddress: string;
310
+ enableSweep?: boolean;
309
311
  }): Promise<import(".").SwapRouteV2Response>;
310
312
  getChainBalance<T extends import("@swapkit/types").Chain>({ chain, address, scamFilter, }: {
311
313
  chain: T;
@@ -85,6 +85,7 @@ export declare function getSwapQuote(json: QuoteRequest): Promise<{
85
85
  image: string;
86
86
  price: number;
87
87
  }[] | undefined;
88
+ isSweep?: boolean | undefined;
88
89
  maxStreamingQuantity?: number | undefined;
89
90
  streamingInterval?: number | undefined;
90
91
  affiliate?: string | undefined;
@@ -277,6 +278,7 @@ export declare function getRouteWithTx(json: {
277
278
  routeId: string;
278
279
  sourceAddress: string;
279
280
  destinationAddress: string;
281
+ enableSweep?: boolean;
280
282
  }): Promise<SwapRouteV2Response>;
281
283
  export declare function getChainBalance<T extends Chain>({ chain, address, scamFilter, }: {
282
284
  chain: T;
@@ -211,6 +211,7 @@ export declare const QuoteRequestSchema: z.ZodObject<{
211
211
  cfBoost: z.ZodOptional<z.ZodBoolean>;
212
212
  destinationAddress: z.ZodOptional<z.ZodString>;
213
213
  disableSecurityChecks: z.ZodOptional<z.ZodBoolean>;
214
+ enableSweep: z.ZodOptional<z.ZodBoolean>;
214
215
  includeTx: z.ZodOptional<z.ZodBoolean>;
215
216
  providers: z.ZodOptional<z.ZodArray<z.ZodString>>;
216
217
  referrer: z.ZodOptional<z.ZodString>;
@@ -1292,6 +1293,7 @@ export declare const RouteQuoteMetadataSchema: z.ZodObject<{
1292
1293
  image: z.ZodString;
1293
1294
  price: z.ZodNumber;
1294
1295
  }, z.core.$strip>>>;
1296
+ isSweep: z.ZodOptional<z.ZodBoolean>;
1295
1297
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
1296
1298
  referrer: z.ZodOptional<z.ZodString>;
1297
1299
  streamingInterval: z.ZodOptional<z.ZodNumber>;
@@ -1303,6 +1305,7 @@ export declare const RouteQuoteMetadataV2Schema: z.ZodObject<{
1303
1305
  image: z.ZodString;
1304
1306
  price: z.ZodNumber;
1305
1307
  }, z.core.$strip>>>;
1308
+ isSweep: z.ZodOptional<z.ZodBoolean>;
1306
1309
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
1307
1310
  streamingInterval: z.ZodOptional<z.ZodNumber>;
1308
1311
  tags: z.ZodArray<z.ZodEnum<typeof PriorityLabel>>;
@@ -1431,6 +1434,7 @@ export declare const QuoteResponseRouteItem: z.ZodObject<{
1431
1434
  image: z.ZodString;
1432
1435
  price: z.ZodNumber;
1433
1436
  }, z.core.$strip>>>;
1437
+ isSweep: z.ZodOptional<z.ZodBoolean>;
1434
1438
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
1435
1439
  streamingInterval: z.ZodOptional<z.ZodNumber>;
1436
1440
  tags: z.ZodArray<z.ZodEnum<typeof PriorityLabel>>;
@@ -1647,6 +1651,7 @@ export declare const QuoteResponseSchema: z.ZodObject<{
1647
1651
  image: z.ZodString;
1648
1652
  price: z.ZodNumber;
1649
1653
  }, z.core.$strip>>>;
1654
+ isSweep: z.ZodOptional<z.ZodBoolean>;
1650
1655
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
1651
1656
  streamingInterval: z.ZodOptional<z.ZodNumber>;
1652
1657
  tags: z.ZodArray<z.ZodEnum<typeof PriorityLabel>>;
@@ -1959,6 +1964,7 @@ declare const QuoteRouteV3ResponseSchema: z.ZodObject<{
1959
1964
  image: z.ZodString;
1960
1965
  price: z.ZodNumber;
1961
1966
  }, z.core.$strip>>>;
1967
+ isSweep: z.ZodOptional<z.ZodBoolean>;
1962
1968
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
1963
1969
  referrer: z.ZodOptional<z.ZodString>;
1964
1970
  streamingInterval: z.ZodOptional<z.ZodNumber>;
@@ -2031,6 +2037,7 @@ export declare const QuoteV3ResponseSchema: z.ZodObject<{
2031
2037
  image: z.ZodString;
2032
2038
  price: z.ZodNumber;
2033
2039
  }, z.core.$strip>>>;
2040
+ isSweep: z.ZodOptional<z.ZodBoolean>;
2034
2041
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
2035
2042
  referrer: z.ZodOptional<z.ZodString>;
2036
2043
  streamingInterval: z.ZodOptional<z.ZodNumber>;
@@ -2126,6 +2133,7 @@ export declare const QuoteRouteV2Response: z.ZodObject<{
2126
2133
  image: z.ZodString;
2127
2134
  price: z.ZodNumber;
2128
2135
  }, z.core.$strip>>>;
2136
+ isSweep: z.ZodOptional<z.ZodBoolean>;
2129
2137
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
2130
2138
  streamingInterval: z.ZodOptional<z.ZodNumber>;
2131
2139
  tags: z.ZodArray<z.ZodEnum<typeof PriorityLabel>>;
@@ -2350,6 +2358,7 @@ export declare const QuoteV2ResponseSchema: z.ZodObject<{
2350
2358
  image: z.ZodString;
2351
2359
  price: z.ZodNumber;
2352
2360
  }, z.core.$strip>>>;
2361
+ isSweep: z.ZodOptional<z.ZodBoolean>;
2353
2362
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
2354
2363
  streamingInterval: z.ZodOptional<z.ZodNumber>;
2355
2364
  tags: z.ZodArray<z.ZodEnum<typeof PriorityLabel>>;
@@ -2561,6 +2570,7 @@ export declare const SwapRouteV2ResponseSchema: z.ZodObject<{
2561
2570
  image: z.ZodString;
2562
2571
  price: z.ZodNumber;
2563
2572
  }, z.core.$strip>>>;
2573
+ isSweep: z.ZodOptional<z.ZodBoolean>;
2564
2574
  maxStreamingQuantity: z.ZodOptional<z.ZodNumber>;
2565
2575
  streamingInterval: z.ZodOptional<z.ZodNumber>;
2566
2576
  tags: z.ZodArray<z.ZodEnum<typeof PriorityLabel>>;