@swapkit/helpers 4.5.9 → 4.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +246 -0
- package/dist/api/index.cjs +0 -4
- package/dist/api/index.js +1 -4
- package/dist/chunk-1m30h0t9.js +1 -0
- package/dist/chunk-57tjgeg1.js +5 -0
- package/dist/chunk-7xv3mp86.js +4 -0
- package/dist/contracts.cjs +0 -3
- package/dist/contracts.js +0 -3
- package/dist/index.cjs +1 -7
- package/dist/index.js +1 -7
- package/dist/tokens.cjs +0 -3
- package/dist/tokens.js +0 -3
- package/dist/types/api/index.d.ts +129 -153
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/midgard/endpoints.d.ts +2 -1
- package/dist/types/api/midgard/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts +137 -159
- package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/types.d.ts +1050 -23
- package/dist/types/api/swapkitApi/types.d.ts.map +1 -1
- package/dist/types/api/thornode/endpoints.d.ts +1 -1
- package/dist/types/api/thornode/endpoints.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/assetValue.d.ts +6 -7
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/modules/requestClient.d.ts +1 -1
- package/dist/types/modules/requestClient.d.ts.map +1 -1
- package/dist/types/modules/swapKitConfig.d.ts +24 -78
- package/dist/types/modules/swapKitConfig.d.ts.map +1 -1
- package/dist/types/modules/swapKitError.d.ts +150 -14
- package/dist/types/modules/swapKitError.d.ts.map +1 -1
- package/dist/types/modules/widgetAuth.d.ts +6 -0
- package/dist/types/modules/widgetAuth.d.ts.map +1 -0
- package/dist/types/types/derivationPath.d.ts +1 -1
- package/dist/types/types/derivationPath.d.ts.map +1 -1
- package/dist/types/types/quotes.d.ts +2 -6
- package/dist/types/types/quotes.d.ts.map +1 -1
- package/dist/types/types/sdk.d.ts +6 -0
- package/dist/types/types/sdk.d.ts.map +1 -1
- package/dist/types/types/wallet.d.ts +12 -3
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/dist/types/utils/asset.d.ts +17 -1
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/dist/types/utils/chains.d.ts +5 -0
- package/dist/types/utils/chains.d.ts.map +1 -1
- package/dist/types/utils/derivationPath.d.ts +4 -2
- package/dist/types/utils/derivationPath.d.ts.map +1 -1
- package/dist/types/utils/wallets.d.ts +18 -2
- package/dist/types/utils/wallets.d.ts.map +1 -1
- package/package.json +12 -30
- package/dist/api/index.cjs.map +0 -14
- package/dist/api/index.js.map +0 -14
- package/dist/chunk-pfmeq01a.js +0 -5
- package/dist/chunk-pfmeq01a.js.map +0 -9
- package/dist/chunk-vb4wtm2w.js +0 -4
- package/dist/chunk-vb4wtm2w.js.map +0 -9
- package/dist/contracts.cjs.map +0 -10
- package/dist/contracts.js.map +0 -10
- package/dist/index.cjs.map +0 -30
- package/dist/index.js.map +0 -30
- package/dist/tokens.cjs.map +0 -10
- package/dist/tokens.js.map +0 -10
- package/src/api/index.ts +0 -9
- package/src/api/midgard/endpoints.ts +0 -348
- package/src/api/midgard/types.ts +0 -515
- package/src/api/swapkitApi/endpoints.ts +0 -247
- package/src/api/swapkitApi/types.ts +0 -624
- package/src/api/thornode/endpoints.ts +0 -105
- package/src/api/thornode/types.ts +0 -247
- package/src/contracts.ts +0 -1
- package/src/index.ts +0 -28
- package/src/modules/__tests__/assetValue.test.ts +0 -2452
- package/src/modules/__tests__/bigIntArithmetics.test.ts +0 -410
- package/src/modules/__tests__/feeMultiplier.test.ts +0 -125
- package/src/modules/__tests__/swapKitConfig.test.ts +0 -425
- package/src/modules/__tests__/swapKitNumber.test.ts +0 -435
- package/src/modules/assetValue.ts +0 -532
- package/src/modules/bigIntArithmetics.ts +0 -362
- package/src/modules/feeMultiplier.ts +0 -80
- package/src/modules/requestClient.ts +0 -110
- package/src/modules/swapKitConfig.ts +0 -174
- package/src/modules/swapKitError.ts +0 -470
- package/src/modules/swapKitNumber.ts +0 -13
- package/src/tokens.ts +0 -1
- package/src/types/commonTypes.ts +0 -10
- package/src/types/derivationPath.ts +0 -11
- package/src/types/errors/apiV1.ts +0 -0
- package/src/types/index.ts +0 -5
- package/src/types/quotes.ts +0 -174
- package/src/types/sdk.ts +0 -38
- package/src/types/wallet.ts +0 -124
- package/src/utils/__tests__/asset.test.ts +0 -186
- package/src/utils/__tests__/derivationPath.test.ts +0 -142
- package/src/utils/__tests__/explorerUrls.test.ts +0 -59
- package/src/utils/__tests__/liquidity.test.ts +0 -302
- package/src/utils/__tests__/memo.test.ts +0 -99
- package/src/utils/__tests__/others.test.ts +0 -165
- package/src/utils/__tests__/validators.test.ts +0 -84
- package/src/utils/__tests__/wallets.test.ts +0 -621
- package/src/utils/asset.ts +0 -399
- package/src/utils/chains.ts +0 -100
- package/src/utils/derivationPath.ts +0 -101
- package/src/utils/explorerUrls.ts +0 -32
- package/src/utils/liquidity.ts +0 -150
- package/src/utils/memo.ts +0 -102
- package/src/utils/others.ts +0 -62
- package/src/utils/validators.ts +0 -32
- package/src/utils/wallets.ts +0 -237
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
var M={};S(M,{wrapWithThrow:()=>B$,wrapMethodWithNetworkSwitch:()=>lF,warnOnce:()=>V,validateTNS:()=>S$,validateIdentifier:()=>JF,useSwapKitStore:()=>U,useSwapKitConfig:()=>N$,updateDerivationPath:()=>AF,switchEVMWalletNetwork:()=>dF,providerRequest:()=>WF,prepareNetworkSwitch:()=>TP,okxMobileEnabled:()=>iF,listWeb3EVMWallets:()=>cF,isWeb3Detected:()=>AP,isGasAsset:()=>LF,isDetected:()=>xP,initializeRPCUrlsWithFallback:()=>z$,getWalletFormatFor:()=>f$,getTHORNameCost:()=>G$,getSymmetricWithdraw:()=>h$,getSymmetricPoolShare:()=>hF,getRPCUrl:()=>u,getMinAmountByChain:()=>g$,getMemoForWithdraw:()=>e$,getMemoForUnbond:()=>i$,getMemoForTcyStake:()=>RP,getMemoForTcyClaim:()=>NP,getMemoForRunePoolWithdraw:()=>FP,getMemoForRunePoolDeposit:()=>r$,getMemoForNameRegister:()=>$P,getMemoForNamePreferredAssetRegister:()=>PP,getMemoForLeaveAndBond:()=>s$,getMemoForDeposit:()=>a$,getMAYANameCost:()=>T$,getLiquiditySlippage:()=>c$,getFeeMultiplierAsBigInt:()=>uF,getFeeMultiplier:()=>SF,getExplorerTxUrl:()=>u$,getExplorerAddressUrl:()=>C$,getEstimatedPoolShare:()=>t$,getETHDefaultWallet:()=>MP,getEIP6963Wallets:()=>QP,getDerivationPathFor:()=>p$,getCommonAssetInfo:()=>s,getChainIdentifier:()=>M$,getAsymmetricRuneWithdrawAmount:()=>n$,getAsymmetricRuneShare:()=>nF,getAsymmetricAssetWithdrawAmount:()=>m$,getAsymmetricAssetShare:()=>mF,getAssetType:()=>NF,formatBigIntToSafeValue:()=>y,findAssetBy:()=>X$,filterSupportedChains:()=>GP,fetchTokenInfo:()=>YF,derivationPathToString:()=>CF,assetFromString:()=>i,applyFeeMultiplierToBigInt:()=>O$,applyFeeMultiplier:()=>v$,addEVMWalletNetwork:()=>sF,addAccountsChangedCallback:()=>BP,WarningCodeEnum:()=>gF,WalletOption:()=>d,SwapKitNumber:()=>I,SwapKitError:()=>J,SKConfig:()=>g,RequestClient:()=>E,ProviderName:()=>IF,NetworkDerivationPath:()=>b,MemoType:()=>_F,LedgerErrorCode:()=>OF,FeeTypeEnum:()=>kF,FeeOption:()=>QF,ErrorCode:()=>wF,DerivationPath:()=>b$,DEFAULT_FEE_MULTIPLIERS:()=>EF,CommonAssetStrings:()=>Y$,BigIntArithmetics:()=>O,AssetValue:()=>h,ApproveMode:()=>VF});module.exports=hP(M);Q(M,require("@swapkit/tokens"),module.exports);Q(M,require("@swapkit/types"),module.exports);var V$={};S(V$,{getMinAmountByChain:()=>g$,AssetValue:()=>h});var K=require("@swapkit/types"),pF=require("ethers"),jF=require("ts-pattern");var Z$={};S(Z$,{isGasAsset:()=>LF,getCommonAssetInfo:()=>s,getAssetType:()=>NF,findAssetBy:()=>X$,fetchTokenInfo:()=>YF,assetFromString:()=>i,CommonAssetStrings:()=>Y$});var G=require("@swapkit/types"),PF=require("ts-pattern");var A$={};S(A$,{RequestClient:()=>E});var R$={};S(R$,{useSwapKitStore:()=>U,useSwapKitConfig:()=>N$,SKConfig:()=>g});var W=require("@swapkit/types"),F$=require("zustand"),$$=require("zustand/shallow");var eF={};S(eF,{WarningCodeEnum:()=>gF,WalletOption:()=>d,ProviderName:()=>IF,NetworkDerivationPath:()=>b,MemoType:()=>_F,LedgerErrorCode:()=>OF,FeeTypeEnum:()=>kF,FeeOption:()=>QF,ErrorCode:()=>wF,ApproveMode:()=>VF});var MF=require("@swapkit/types"),b=MF.AllChains.reduce((F,$)=>{return F[$]=MF.getChainConfig($).networkDerivationPath,F},{});var wF;((H)=>{H.unknownError="unknownError";H.test_error="test_error";H.providerDetailsError="providerDetailsError";H.blockHeaderNotFound="blockHeaderNotFound";H.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";H.blockHashNotFoundAtHash="blockHashNotFoundAtHash";H.txHashMissing="txHashMissing";H.assetValueMissingInfo="assetValueMissingInfo";H.invalidAsset="invalidAsset";H.blockIsRequired="blockIsRequired";H.currentBlockHeaderNotFound="currentBlockHeaderNotFound";H.failedToRetrieveBalance="failedToRetrieveBalance";H.failedToRetrieveBlock="failedToRetrieveBlock";H.failedToRetrieveFees="failedToRetrieveFees";H.notImplementedBCH="notImplementedBCH";H.notImplementedDoge="notImplementedDoge";H.noPoolsFound="noPoolsFound";H.noVaultsFound="noVaultsFound";H.noTxFound="noTxFound";H.noInputCoinFound="noInputCoinFound";H.noBlockDataFound="noBlockDataFound";H.multipleCosmosMessages="multipleCosmosMessages";H.heightOrHashNotProvided="heightOrHashNotProvided";H.unknownDenom="unknownDenom";H.invalidBlockHeight="invalidBlockHeight";H.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";H.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";H.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";H.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";H.txMemoUndefined="txMemoUndefined";H.txMemoIncorrect="txMemoIncorrect";H.txTypeNotFound="txTypeNotFound";H.txNoMessage="txNoMessage";H.txNotFound="txNotFound";H.txReceiptNotFound="txReceiptNotFound";H.txParsingError="txParsingError";H.txLogsParsingError="txLogsParsingError";H.blockNotFound="blockNotFound";H.balanceNotFound="balanceNotFound";H.configError="configError";H.synthSwapDisallowed="synthSwapDisallowed";H.providerQuoteTimeout="providerQuoteTimeout";H.noQuoteResponse="noQuoteResponse";H.noPoolAssetsFound="noPoolAssetsFound";H.noThorchainPools="noThorchainPools";H.noMayachainPools="noMayachainPools";H.noThorchainNetworkInfo="noThorchainNetworkInfo";H.invalidAffiliateFee="invalidAffiliateFee";H.invalidBuyAssetAddress="invalidBuyAssetAddress";H.invalidSellAssetAddress="invalidSellAssetAddress";H.invalidSourceAddress="invalidSourceAddress";H.invalidDestinationAddress="invalidDestinationAddress";H.sourceAddressIsSmartContract="sourceAddressIsSmartContract";H.destinationAddressIsSmartContract="destinationAddressIsSmartContract";H.invalidChainId="invalidChainId";H.unsupportedChainId="unsupportedChainId";H.unsupportedEVMChainId="unsupportedEVMChainId";H.unsupportedMethod="unsupportedMethod";H.unsupportedProvider="unsupportedProvider";H.invalidParamsForMethod="invalidParamsForMethod";H.unsupportedAdapter="unsupportedAdapter";H.noWhitelistTokens="noWhitelistTokens";H.failedFetchGasPrice="failedFetchGasPrice";H.failedToCreateDepositChannel="failedToCreateDepositChannel";H.noProviderDetailsFound="noProviderDetailsFound";H.noTokenListsFound="noTokenListsFound";H.tokenNotFound="tokenNotFound";H.tokenPriceNotFound="tokenPriceNotFound";H.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";H.swapAmountTooSmall="swapAmountTooSmall";H.legsArrayIsEmpty="legsArrayIsEmpty";H.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";H.noBlockHeaderFound="noBlockHeaderFound";H.failedToSimulateSwap="failedToSimulateSwap";H.addressScreeningFailed="addressScreeningFailed";H.noLiquidtyProvidersFound="noLiquidtyProvidersFound";H.insufficientLiquidity="insufficientLiquidity";H.noInboundDataFound="noInbounDataFound";H.noInboundAddressesFound="noInboundAddressesFound";H.noInboundAddressFoundForChain="noInboundAddressFoundForChain";H.noLastBlocksFound="noLastBlocksFound";H.noVersionFound="noVersionFound";H.noConstantsFound="noConstantsFound";H.noMimirsFound="noMimirsFound";H.noRoutesFound="noRoutesFound";H.quoteNotFound="quoteNotFound";H.ledgerSignFailed="ledgerSignFailed";H.ledgerWrongPayload="ledgerWrongPayload";H.ledgerFetchSwapFailed="ledgerFetchSwapFailed";H.failedToFetchTx="failedToFetchTx";H.failedBuildTransactionDetails="failedBuildTransactionDetails";H.noLegsForRoute="noLegsForRoute";H.noRouterAddressFound="noRouterAddressFound";H.noAggregatorAddressFound="noAggregatorAddressFound";H.noContractInstanceFound="noContractInstanceFound";H.noContractAddressFound="noContractAddressFound";H.invalidAffiliate="invalidAffiliate";H.thornameAffiliate="thornameAffiliate";H.providerNotfound="No provider found";H.noRecordFound="No Record found";H.slippageTooLow="Slippage too low";H.tradingHalted="tradingHalted";H.noWrappedGasAsset="noWrappedGasAsset";H.aggregatorAddressNotFound="aggregatorAddressNotFound";H.routerAddressNotFound="routerAddressNotFound";H.dummyAddressNotFound="dummyAddressNotFound";H.trackerError="trackerError";H.thorchainPoolUnavailable="thorchainPoolUnavailable";H.noOhlcvDataFound="noOhlcvDataFound";H.noTradingPairs="noTradingPairs";H.noLendingAvailability="noLendingAvailability";H.lendingRepayTooSmall="lendingRepayTooSmall";H.missingState="missingState";H.ledgerSwapNotFound="ledgerSwapNotFound";H.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";H.errorEstimatingGas="errorEstimatingGas";H.apiKeyInvalid="apiKeyInvalid";H.apiKeyFailedToUpdate="apiKeyFailedToUpdate";H.apiKeyExpired="apiKeyExpired";H.unauthorized="unauthorized";H.failedToCreateMemo="failedToCreateMemo";H.radixIncorrectInstructions="radixIncorrectInstructions";H.radixTxMissedParam="radixTxMissedParam";H.radixTxMissedAccount="radixTxMissedAccount";H.radixManifestParseError="radixManifestParseError";H.radixManifestBuildError="radixManifestBuildError";H.invalidAddressForChain="invalidAddressForChain";H.riskyAddress="riskyAddress";H.noRoutesToProcess="noRoutesToProcess";H.sellAssetAmountTooSmall="sellAssetAmountTooSmall";H.missingPrivateKey="missingPrivateKey";H.noMemoPriceProtection="noMemoPriceProtection"})(wF||={});var gF;((P)=>{P.highSlippage="highSlippage";P.highPriceImpact="highPriceImpact"})(gF||={});var IF;((X)=>{X.CAVIAR_V1="CAVIAR_V1";X.CAMELOT_V3="CAMELOT_V3";X.CHAINFLIP="CHAINFLIP";X.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";X.JUPITER="JUPITER";X.MAYACHAIN="MAYACHAIN";X.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";X.OCISWAP_V1="OCISWAP_V1";X.ONEINCH="ONEINCH";X.OPENOCEAN_V2="OPENOCEAN_V2";X.PANCAKESWAP="PANCAKESWAP";X.PANGOLIN_V1="PANGOLIN_V1";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"})(IF||={});var kF;((B)=>{B.LIQUIDITY="liquidity";B.NETWORK="network";B.INBOUND="inbound";B.OUTBOUND="outbound";B.AFFILIATE="affiliate";B.TAX="tax";B.PRIORITY="priority";B.SERVICE="service"})(kF||={});var QF;((N)=>{N.Average="average";N.Fast="fast";N.Fastest="fastest"})(QF||={});var VF;((P)=>{P.Approve="approve";P.CheckOnly="checkOnly"})(VF||={});var _F;((_)=>{_.NAME_REGISTER="~";_.BOND="BOND";_.DEPOSIT="+";_.LEAVE="LEAVE";_.UNBOND="UNBOND";_.WITHDRAW="-";_.RUNEPOOL_DEPOSIT="POOL+";_.RUNEPOOL_WITHDRAW="POOL-";_.CLAIM_TCY="tcy";_.STAKE_TCY="tcy+";_.UNSTAKE_TCY="tcy-"})(_F||={});var d;((Y)=>{Y.BITGET="BITGET";Y.BRAVE="BRAVE";Y.COINBASE_MOBILE="COINBASE_MOBILE";Y.COINBASE_WEB="COINBASE_WEB";Y.COSMOSTATION="COSMOSTATION";Y.CTRL="CTRL";Y.EIP6963="EIP6963";Y.EXODUS="EXODUS";Y.KEEPKEY="KEEPKEY";Y.KEEPKEY_BEX="KEEPKEY_BEX";Y.KEPLR="KEPLR";Y.KEYSTORE="KEYSTORE";Y.LEAP="LEAP";Y.LEDGER="LEDGER";Y.LEDGER_LIVE="LEDGER_LIVE";Y.METAMASK="METAMASK";Y.OKX="OKX";Y.OKX_MOBILE="OKX_MOBILE";Y.ONEKEY="ONEKEY";Y.PASSKEYS="PASSKEYS";Y.PHANTOM="PHANTOM";Y.POLKADOT_JS="POLKADOT_JS";Y.RADIX_WALLET="RADIX_WALLET";Y.TALISMAN="TALISMAN";Y.TREZOR="TREZOR";Y.TRONLINK="TRONLINK";Y.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Y.VULTISIG="VULTISIG";Y.WALLETCONNECT="WALLETCONNECT";Y.WALLET_SELECTOR="WALLET_SELECTOR";Y.XAMAN="XAMAN"})(d||={});var OF;((N)=>{N[N.NoError=36864]="NoError";N[N.LockedDevice=21781]="LockedDevice";N[N.TC_NotFound=65535]="TC_NotFound"})(OF||={});var zP=W.AllChains.reduce((F,$)=>{if(!F.THOR_STAGENET)F[W.StagenetChain.Maya]=W.StagenetMAYAConfig.rpcUrls,F[W.StagenetChain.THORChain]=W.StagenetTHORConfig.rpcUrls;return F[$]=W.getChainConfig($).rpcUrls,F},{}),P$={apiKeys:{blockchair:"",keepKey:"",passkeys:"",swapKit:"",walletConnectProjectId:"",xaman:""},chains:W.AllChains,endpoints:{},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",experimental_apiKey:null,experimental_apiUrlQuote:null,experimental_apiUrlSwap:null,isDev:!1,isStagenet:!1},feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:zP,wallets:Object.values(d)},U=F$.create((F)=>({...P$,setApiKey:($,P)=>F((N)=>({apiKeys:{...N.apiKeys,[$]:P}})),setConfig:($)=>F((P)=>({apiKeys:{...P.apiKeys,...$?.apiKeys},chains:P.chains.concat($?.chains||[]),endpoints:{...P.endpoints,...$?.endpoints},envs:{...P.envs,...$?.envs},feeMultipliers:$?.feeMultipliers||P.feeMultipliers,integrations:{...P.integrations,...$?.integrations},rpcUrls:{...P.rpcUrls,...$?.rpcUrls},wallets:P.wallets.concat($?.wallets||[])})),setEndpoint:($,P)=>F((N)=>({endpoints:{...N.endpoints,[$]:P}})),setEnv:($,P)=>F((N)=>({envs:{...N.envs,[$]:P}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,P)=>F((N)=>({integrations:{...N.integrations,[$]:P}})),setRequestOptions:($)=>F((P)=>({requestOptions:{retry:{...P.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||P.requestOptions.timeoutMs}})),setRpcUrl:($,P)=>F((N)=>({rpcUrls:{...N.rpcUrls,[$]:P}}))})),N$=()=>U($$.useShallow((F)=>({apiKeys:F?.apiKeys,chains:F?.chains,endpoints:F?.endpoints,envs:F?.envs,feeMultipliers:F?.feeMultipliers,integrations:F?.integrations,rpcUrls:F?.rpcUrls,wallets:F?.wallets}))),g={get:(F)=>U.getState()[F],getState:U.getState,reinitialize:()=>U.setState(P$),set:(F)=>U.getState().setConfig(F),setApiKey:(F,$)=>U.getState().setApiKey(F,$),setEndpoint:(F,$)=>U.getState().setEndpoint(F,$),setEnv:(F,$)=>U.getState().setEnv(F,$),setFeeMultipliers:(F)=>U.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>U.getState().setIntegrationConfig(F,$),setRequestOptions:(F)=>U.getState().setRequestOptions(F),setRpcUrl:(F,$)=>U.getState().setRpcUrl(F,$)};var H$={};S(H$,{SwapKitError:()=>J});var KP={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_wallet_create_not_supported:10115,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_ledger_webhid_not_supported:20124,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_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_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_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,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_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_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,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_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,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_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_not_supported:59901,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,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,not_implemented:99999};class J extends Error{static ErrorCode=KP;constructor(F,$){let P=typeof F==="string",N=P?F:F.errorKey,R=P?void 0:F.info,x=`${N}${R?`: ${JSON.stringify(R)}`:""}`;super(x);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$){let A=$ instanceof Error?`${$.message}${$.cause?` (${$.cause})`:""}`:JSON.stringify($);console.error(`SwapKitError [${N}]: ${A}`)}else if(R)console.error(`SwapKitError [${N}]: ${JSON.stringify(R)}`)}}var YP=(F)=>new Promise(($)=>setTimeout($,F)),LP=(F,{baseDelay:$,backoffMultiplier:P,maxDelay:N})=>Math.min($*P**F,N),JP=async(F,$)=>{let P=await fetch(F,$);if(!P.ok){let N={status:P.status,statusText:P.statusText};throw new J({errorKey:"helpers_invalid_response",info:N},N)}return P.json()};function zF(F,$={}){return async function(N,R={}){let{searchParams:x,json:A,body:T,headers:B,dynamicHeader:z,retry:L,timeoutMs:_,abortController:w,onError:v,onSuccess:D,responseHandler:o,...t}={...$,...R},p=g.get("requestOptions"),k={...p.retry,...L},c=!!A||N.endsWith(".json"),TF=ZP(N,x),X=XP(c,{...B,...z?.()}),$F=c?JSON.stringify(A):T,f;for(let BF=0;BF<=k.maxRetries;BF++){let rF=w||new AbortController,aF=setTimeout(()=>rF.abort(),_||p.timeoutMs);try{let n=await JP(TF,{...t,body:$F,headers:X,method:F,signal:rF.signal});return clearTimeout(aF),D?.(n)||o?.(n)||n}catch(n){if(clearTimeout(aF),f=n,BF>=k.maxRetries)return v?v(n):Promise.reject(n);await YP(LP(BF,k))}}return v?v(f):Promise.reject(f)}}function XP(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function ZP(F,$){let P=new URL(F);if($)P.search=new URLSearchParams($).toString();return P.toString()}var E={extend:(F)=>({extend:($)=>E.extend({...F,...$}),get:zF("GET",F),post:zF("POST",F)}),get:zF("GET"),post:zF("POST")};var K$={};S(K$,{initializeRPCUrlsWithFallback:()=>z$,getRPCUrl:()=>u});var j=require("@swapkit/types"),DF=require("ts-pattern");var Q$={};S(Q$,{wrapWithThrow:()=>B$,warnOnce:()=>V,getTHORNameCost:()=>G$,getMAYANameCost:()=>T$,getChainIdentifier:()=>M$});var KF=require("@swapkit/types");function G$(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function T$(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function B$(F,$){try{return F()}catch(P){if($)throw new J($,P);return}}function M$(F){switch(F){case KF.Chain.THORChain:return`${F}.RUNE`;case KF.Chain.Cosmos:return`${F}.ATOM`;case KF.Chain.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var x$=new Set;function V({condition:F,id:$,warning:P}){if(F){if(x$.has($))return;console.warn(P),x$.add($)}}function jP(F){return DF.match(F).with(...j.EVMChains,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...j.UTXOChains,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...j.CosmosChains,...j.StagenetChains,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(j.Chain.Polkadot,j.Chain.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(j.Chain.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(j.Chain.Sui,()=>({id:1,jsonrpc:"2.0",method:"sui_getSystemState",params:[]})).with(j.Chain.Ton,()=>({id:1,jsonrpc:"2.0",method:"getAddressInformation",params:{address:""}})).with(j.Chain.Tron,j.Chain.Radix,()=>"").with(j.Chain.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(j.Chain.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:F})})}function SP(F){return DF.match(F).with(j.Chain.Radix,()=>"/status/network-configuration").with(j.Chain.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function _$(F,$){try{let P=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${P}${SP(F)}`,{body:JSON.stringify(jP(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var vF=new Map,UP=120000;async function u(F){let{isStagenet:$}=g.get("envs"),[P="",...N]=g.get("rpcUrls")[F];if(!P)throw V({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 ${F}.`}),new J("helpers_chain_no_public_or_set_rpc_url",{chain:F});if($)return P;let R=vF.get(F);if(R&&Date.now()-R.timestamp<UP)return R.url;if(!await _$(F,P)){for(let A of N)if(await _$(F,A))return vF.set(F,{timestamp:Date.now(),url:A}),A}return vF.set(F,{timestamp:Date.now(),url:P}),P}function z$(F){V({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}var Y$=[`${G.Chain.Maya}.MAYA`,`${G.Chain.Maya}.CACAO`,`${G.Chain.Ethereum}.THOR`,`${G.Chain.Ethereum}.vTHOR`,`${G.Chain.Kujira}.USK`,`${G.Chain.Ethereum}.FLIP`,`${G.Chain.Radix}.XRD`],L$=[G.Chain.Arbitrum,G.Chain.Aurora,G.Chain.Base,G.Chain.Ethereum,G.Chain.Optimism];async function qP(F){let{baseDecimal:$}=G.getChainConfig(G.Chain.Radix);try{let P=await u(G.Chain.Radix),{manager:N}=await E.post(`${P}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:F}),headers:{Accept:"*/*","Content-Type":"application/json"}});return N?.divisibility?.value?.divisibility}catch(P){let N=P instanceof Error?P.message:String(P);return console.warn(`Failed to fetch Radix asset decimals for ${F}: ${N}`),$}}async function WP(F){try{let $=await u(G.Chain.Radix);return(await E.post(`${$}/state/entity/details`,{body:JSON.stringify({addresses:[F],opt_ins:{explicit_metadata:["symbol"]}}),headers:{Accept:"*/*","Content-Type":"application/json"}})).items[0]?.explicit_metadata?.items.find((R)=>R.key==="symbol")?.value.typed.value||void 0}catch($){let P=$ instanceof Error?$.message:String($);return console.warn(`Failed to fetch Radix asset symbol for ${F}: ${P}`),""}}async function J$({chain:F,address:$,methodHex:P,id:N}){let R=await u(F);return E.post(R,{body:JSON.stringify({id:N,jsonrpc:"2.0",method:"eth_call",params:[{data:P,to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}})}async function wP(F){if(!F||F==="0x")return"UNKNOWN";try{let{AbiCoder:$}=await import("ethers");return $.defaultAbiCoder().decode(["string"],F)[0].trim()}catch($){return console.warn(`Failed to decode ABI string from ${F}: ${$}`),"UNKNOWN"}}function gP(F,$){if(!F||F==="0x")return $;try{return Number(F)}catch(P){return console.warn(`Failed to decode ABI uint8 from ${F}: ${P}`),$}}async function IP({chain:F,address:$}){let{baseDecimal:P}=G.getChainConfig(F),N=$.toLowerCase();if($===""||!N.startsWith("0x"))return P;let R=await J$({address:$,chain:F,id:2,methodHex:"0x313ce567"}).catch((A)=>{return console.warn(`Could not fetch decimals for ${$} on ${F}: ${A.message}`),{result:""}});return gP(R.result,P)}async function kP({chain:F,address:$}){let P=$.toLowerCase();if(P===""||!P.startsWith("0x"))return;let N=await J$({address:$,chain:F,id:1,methodHex:"0x95d89b41"}).catch((x)=>{return console.warn(`Could not fetch symbol for ${$} on ${F}: ${x.message}`),{result:""}});return await wP(N.result)}function YF({chain:F,address:$}){let{baseDecimal:P}=G.getChainConfig(F),N={decimals:P,ticker:void 0};return PF.match(F).with(...G.EVMChains,async()=>{try{let{isAddress:R,getAddress:x}=await import("ethers");if(!R(x($.replace(/^0X/,"0x"))))return N;let[A,T]=await Promise.all([kP({address:$,chain:F}),IP({address:$,chain:F})]);return{decimals:T,ticker:A}}catch(R){return console.warn(`Failed to fetch token info for ${$} on ${F}: ${R?.code} ${R?.message}`),N}}).with(G.Chain.Solana,async()=>{if(!$)return N;try{let R=await fetch(`https://lite-api.jup.ag/tokens/v2/search?query=${$}`);if(R.ok){let x=await R.json(),A=Array.isArray(x)?x[0]:x;if(A)return{decimals:A.decimals??P,ticker:A.symbol||void 0}}}catch(R){console.warn(`Failed to fetch Solana token info for ${$}: ${R?.code} ${R?.message}`)}return N}).with(G.Chain.Tron,async()=>{if(!$)return N;try{let R=await import("tronweb"),x=R.TronWeb??R.default?.TronWeb,A=await u(G.Chain.Tron),B=await new x({fullHost:A,privateKey:"0000000000000000000000000000000000000000000000000000000000000001"}).contract().at($),[z,L]=await Promise.all([B.symbol().call().catch((_)=>{console.warn(`Could not fetch symbol for ${$} on Tron:`,_);return}),B.decimals().call().catch((_)=>{return console.warn(`Could not fetch decimals for ${$} on Tron:`,_),P})]);return{decimals:typeof L==="number"?L:Number(L||P),ticker:z||void 0}}catch(R){let x=R instanceof Error?R.message:String(R);return console.warn(`Failed to fetch Tron token info for ${$}: ${x}`),N}}).with(G.Chain.Near,async()=>{if(!$)return N;try{let{JsonRpcProvider:R}=await import("@near-js/providers"),x=await u(G.Chain.Near),T=await new R({url:x}).query({account_id:$,args_base64:Buffer.from("{}").toString("base64"),finality:"final",method_name:"ft_metadata",request_type:"call_function"}),B=JSON.parse(Buffer.from(T.result).toString());return{decimals:B?.decimals||P,ticker:B?.symbol}}catch(R){let x=R instanceof Error?R.message:String(R);return console.warn(`Failed to fetch Near token info for ${$}: ${x}`),N}}).with(G.Chain.Radix,async()=>{if(!$)return N;try{let[R,x]=await Promise.all([WP($),qP($)]);return{decimals:x,ticker:R}}catch(R){let x=R instanceof Error?R.message:String(R);return console.warn(`Failed to fetch Radix token info for ${$}: ${x}`),N}}).otherwise(async()=>N)}function LF({chain:F,symbol:$}){return PF.match(F).with(...L$,()=>$==="ETH").with(G.Chain.Avalanche,()=>$==="AVAX").with(G.Chain.Berachain,()=>$==="BERA").with(G.Chain.BinanceSmartChain,()=>$==="BNB").with(G.Chain.Gnosis,()=>$==="xDAI"||$==="XDAI").with(G.Chain.Monad,()=>$==="MON").with(G.Chain.XLayer,()=>$==="OKB").with(G.Chain.Maya,()=>$==="CACAO").with(G.Chain.Cosmos,()=>$==="ATOM").with(G.Chain.THORChain,()=>$==="RUNE").with(G.Chain.Tron,()=>$==="TRX").with(G.Chain.Radix,()=>`${F}.${$}`===s(F).identifier).otherwise(()=>$===F)}var s=(F)=>{let{baseDecimal:$}=G.getChainConfig(F);return PF.match(F.toUpperCase()).with(...L$,(N)=>({decimal:$,identifier:`${N}.ETH`})).with(G.Chain.THORChain,(N)=>({decimal:$,identifier:`${N}.RUNE`})).with(G.Chain.Cosmos,(N)=>({decimal:$,identifier:`${N}.ATOM`})).with(G.Chain.Maya,(N)=>({decimal:10,identifier:`${N}.CACAO`})).with(G.Chain.BinanceSmartChain,(N)=>({decimal:$,identifier:`${N}.BNB`})).with(G.Chain.Monad,(N)=>({decimal:$,identifier:`${N}.MON`})).with(G.Chain.Avalanche,(N)=>({decimal:$,identifier:`${N}.AVAX`})).with(G.Chain.Gnosis,(N)=>({decimal:$,identifier:`${N}.xDAI`})).with(G.Chain.XLayer,(N)=>({decimal:$,identifier:`${N}.OKB`})).with(G.Chain.Berachain,(N)=>({decimal:$,identifier:`${N}.BERA`})).with(G.Chain.Tron,(N)=>({decimal:$,identifier:`${N}.TRX`})).with(G.Chain.Solana,G.Chain.Chainflip,G.Chain.Kujira,G.Chain.Ripple,G.Chain.Polkadot,G.Chain.Near,...G.UTXOChains,(N)=>({decimal:$,identifier:`${N}.${N}`})).with(G.Chain.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(G.Chain.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(N)=>({decimal:6,identifier:N})).with("ETH.FLIP",()=>({decimal:G.getChainConfig(G.Chain.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:G.getChainConfig(G.Chain.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:G.getChainConfig(G.Chain.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(N)=>({decimal:10,identifier:N})).with("MAYA.MAYA",(N)=>({decimal:4,identifier:N})).otherwise(()=>({decimal:$,identifier:F}))};function NF({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return PF.match(F).with(G.Chain.Radix,()=>$===G.Chain.Radix||`${F}.${$}`===s(F).identifier).with(G.Chain.Arbitrum,G.Chain.Optimism,G.Chain.Base,G.Chain.Aurora,()=>$===G.Chain.Ethereum).with(G.Chain.Cosmos,()=>$==="ATOM").with(G.Chain.BinanceSmartChain,()=>$==="BNB").with(G.Chain.Maya,()=>$==="CACAO").with(G.Chain.Monad,()=>$==="MON").with(G.Chain.THORChain,()=>$==="RUNE").with(G.Chain.Tron,()=>$==="TRX").with(G.Chain.XLayer,()=>$==="OKB").otherwise(()=>$===F)?"Native":F}var i=(F)=>{let[$,...P]=F.split("."),N=F.includes("/"),R=P.join("."),x=R?.split("-"),A=x?.length?x.length===1?x[0]:x.slice(0,-1).join("-"):void 0;return{chain:$,symbol:R,synth:N,ticker:A}};async function X$(F){let{loadTokenLists:$}=await import("./tokens.cjs"),P=await $();for(let N of Object.values(P))for(let{identifier:R,chain:x,...A}of N.tokens){if("identifier"in F&&R===F.identifier)return R;if("address"in A&&"chain"in F&&x===F.chain&&A.address&&A.address.toLowerCase()===F.contract.toLowerCase())return R}return}var U$={};S(U$,{validateTNS:()=>S$,validateIdentifier:()=>JF});var j$=["TERRA",...g.get("chains")];function JF(F=""){let $=F.toUpperCase(),[P]=$.split(".");if(j$.includes(P))return!0;let[N]=$.split("/");if(j$.includes(N))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function S$(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var W$={};S(W$,{formatBigIntToSafeValue:()=>y,BigIntArithmetics:()=>O});var HF=require("ts-pattern"),r=8,VP=10;function y({value:F,bigIntDecimal:$=r,decimal:P=r}){if(P===0)return F.toString();let N=F<0n,R=F.toString().substring(N?1:0),x=P-(R.length-1);if(x>0)R="0".repeat(x)+R;let A=R.length-P,T=R.slice(-P);if(Number.parseInt(T[$]||"0",10)>=5){let z=Number.parseInt(T[$-1]||"0",10);T=`${T.substring(0,$-1)}${z+1}`}else T=T.substring(0,$);return`${N?"-":""}${R.slice(0,A)}.${T}`.replace(/\.?0*$/,"")}class O{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new O({decimal:$,value:y({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:P}){return O.fromBigInt(F.getBaseValue("bigint")*m(P)/m($),P)}constructor(F){let $=yF(F),P=typeof F==="object";this.decimal=P?F.decimal:void 0,this.decimalMultiplier=P&&"decimalMultiplier"in F?F.decimalMultiplier:m(Math.max(q$(XF($)),this.decimal||0)),this.#R($)}set(F){return new this.constructor({decimal:this.decimal,identifier:this.toString?.({includeSynthProtocol:!0}),value:F})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let P=RF(this.decimalMultiplier),N=$!==void 0?$:this.decimal,R=N!==void 0?N:P;if(N!==void 0&&N<P){if(this.formatBigIntToSafeValue(this.bigIntValue,N)==="0"&&this.bigIntValue!==0n)R=P}let x=this.formatBigIntToSafeValue(this.bigIntValue,R);return HF.match(F).with("number",()=>Number(x)).with("string",()=>x).with("bigint",()=>{return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}).otherwise(()=>x)}getBaseValue(F,$){let P=this.decimalMultiplier/m($||this.decimal||r),N=vP(this.bigIntValue,P);return HF.match(F).with("number",()=>Number(N)).with("string",()=>N.toString()).otherwise(()=>N)}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let P=yF(F),N=XF(P);if(N==="0"||N==="undefined")return 0n;return this.#N(N,$)}toSignificant(F=6){let $=this.getValue("string"),[P="",N=""]=$.split("."),R=Number.parseInt(P,10)>0;if((R?P.length+N.length:N.length)<=F)return $;if(P.length>=F)return P.slice(0,F).padEnd(P.length,"0");if(R)return`${P}.${N.slice(0,F-P.length)}`;let A=Number.parseInt(N,10).toString(),T=A.slice(0,F),B=N.length-A.length;return`0.${T.padStart(B+T.length,"0")}`}toFixed(F=6){let $=this.getValue("string"),P=$.startsWith("-"),[N="0",R=""]=(P?$.slice(1):$).split("."),x=N==="0"&&Number.parseInt(R.slice(0,F),10)===0,A=P&&!x?"-":"";if(F===0){if(N==="0"&&!R)return"0";return R&&Number.parseInt(R[0]||"0",10)>=5?`${A}${BigInt(N)+1n}.0`:`${A}${N}.0`}if(!R)return`${A}${N}.${"0".repeat(F)}`;let T=R[F];if(!(T&&Number.parseInt(T,10)>=5))return`${A}${N}.${R.slice(0,F).padEnd(F,"0")}`;let z=BigInt(R.slice(0,F).padEnd(F,"0"))+1n,L=10n**BigInt(F);if(z>=L)return`${A}${BigInt(N)+1n}.${"0".repeat(F)}`;return`${A}${N}.${z.toString().padStart(F,"0")}`}toAbbreviation(F=2){let $=this.getValue("string"),P=Number($),N=["","K","M","B","T","Q","Qi","S"],R=Math.floor(Math.log10(Math.abs(P))/3);if(R===0||!N[R])return $;return`${(P/10**(R*3)).toFixed(F)}${N[R]}`}toCurrency(F="$",{currencyPosition:$="start",decimal:P=2,decimalSeparator:N=".",thousandSeparator:R=",",trimTrailingZeros:x=!0}={}){let A=this.toFixed(P),T=$==="end",[B="0",z=""]=A.split("."),L=B.replace(/\B(?=(\d{3})+(?!\d))/g,R),_=z&&Number.parseInt(z,10)>0,w=_?`${L}${N}${z}`:L,D=w.length<100&&x&&_?w.replace(/\.?0*$/,""):w;return T?`${D}${F}`:`${F}${D}`}formatBigIntToSafeValue(F,$){let P=$||this.decimal||r,N=Math.max(P,RF(this.decimalMultiplier));return y({bigIntDecimal:P,decimal:N,value:F})}#$(F,...$){let P=this.#P(this,...$),N=RF(this.decimalMultiplier),x=Math.max(P,N)+VP,A=m(x),T=$.reduce((z,L)=>{let _=this.getBigIntValue(L,x);return HF.match(F).with("add",()=>z+_).with("sub",()=>z-_).with("mul",()=>z*_/A).with("div",()=>{if(_===0n)throw RangeError("Division by zero");return z*A/_}).otherwise(()=>z)},this.bigIntValue*A/this.decimalMultiplier),B=y({bigIntDecimal:x,decimal:x,value:T});return new this.constructor({decimal:this.decimal,decimalMultiplier:m(x),identifier:this.toString(),value:B})}#F(F,...$){let P=this.#P(this,...$),N=this.getBigIntValue($[0]||"0",P),R=this.getBigIntValue(this,P);return HF.match(F).with("gt",()=>R>N).with("gte",()=>R>=N).with("lt",()=>R<N).with("lte",()=>R<=N).with("eqValue",()=>R===N).otherwise(()=>!1)}#R(F){let $=XF(F)||"0";this.bigIntValue=this.#N($)}#P(...F){let $=F.map((P)=>{return typeof P==="object"?P.decimal||RF(P.decimalMultiplier):q$(XF(P))}).filter(Boolean);return Math.max(...$,r)}#N(F,$){let P=$?m($):this.decimalMultiplier,N=RF(P),[R="",x=""]=F.split(".");return BigInt(`${R}${x.padEnd(N,"0")}`)}}var OP=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function XF(F){let P=`${typeof F==="number"?OP.format(F):yF(F)}`.replaceAll(",",".").split(".");return P.length>1?`${P.slice(0,-1).join("")}.${P.at(-1)}`:P[0]||"0"}function q$(F){let $=F.split(".")[1]?.length||0;return Math.max($,r)}function yF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}function vP(F,$){if($===0n)throw Error("Cannot divide by zero");let P=$/2n;return F>=0n&&$>=0n||F<0n&&$<0n?(F+P)/$:(F-P)/$}function m(F){return 10n**BigInt(F)}function RF(F){return Math.log10(Number.parseFloat(F.toString()))}var C=[K.Chain.Solana,K.Chain.Tron,K.Chain.Near,K.Chain.Sui],bF=[K.Chain.THORChain,K.Chain.Maya],a=new Map,ZF=new Map,e=new Map,DP=3600000;function yP(F){let $=e.get(F);if($?.timestamp&&Date.now()-$.timestamp>DP){e.delete(F);return}return $}function pP(F,$){if(e.size>1000){let P=e.keys().next().value;if(P)e.delete(P)}e.set(F,{...$,timestamp:Date.now()})}class h extends O{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:P,chain:N,symbol:R,identifier:x}){super(typeof F==="object"?F:{decimal:$,value:F});let A=w$(x||`${N}.${R}`);this.type=NF(A),this.tax=P,this.chain=A.chain,this.ticker=A.ticker,this.symbol=A.symbol,this.address=A.address,this.isSynthetic=A.isSynthetic,this.isTradeAsset=A.isTradeAsset,this.isGasAsset=A.isGasAsset,this.chainId=K.getChainConfig(A.chain).chainId}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?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 F=this.symbol.replace(/\./g,"__");return`${this.chain}.${F}`}getIconUrl(){return a.get(this.toString())?.logoURI}eqAsset({chain:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let P=F.indexOf(".");if(P===-1)throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let N=F.slice(0,P),R=F.slice(P+1),x=jF.match({chain:N,rest:R}).when(({rest:A})=>A.includes(".."),({chain:A,rest:T})=>`${A}.${T.replace(/\.\./g,"~")}`).when(({chain:A,rest:T})=>bF.includes(A)&&T.includes("."),({chain:A,rest:T})=>`${A}.${T.replace(/\./g,"/")}`).otherwise(({chain:A,rest:T})=>`${A}.${T.replace(/__/g,".")}`);return h.from({asset:x,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:P,...N}){let R=F instanceof O?F.getValue("string"):F,x=uP(N),A=!x.startsWith(K.Chain.Sui)&&x.includes(":");if(P&&A){let[$F,f]=x.split(":");return bP({address:f,chain:$F,fromBaseDecimal:$,parsedValue:R})}let T=A?x.split(":").join(".UNKNOWN-"):x,{identifier:B,decimal:z}=s(T),{chain:L,isSynthetic:_,isTradeAsset:w,address:v}=w$(B),{baseDecimal:D}=K.getChainConfig(L),o=a.get(C.includes(L)?B:B.toUpperCase());if(!o&&P&&!_&&!w)return(async()=>{let{ticker:$F}=i(B),f=await I$({address:v,chain:L,ticker:$F});return fF({decimal:f.decimals,identifier:f.identifier,value:$?FF(BigInt(R),$):R})})();let t=o?.decimal||z;V({condition:!t&&!P,id:`assetValue_static_decimal_not_found_${L}`,warning:`Couldn't find static decimal for one or more tokens on ${L} (Using default ${D} 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:p,identifier:k,tax:c}=o||{decimal:t||D,identifier:B},TF=$?FF(BigInt(R),$):FF(R,p);return _||w?fP(k,TF):fF({decimal:p,identifier:k,tax:c,value:TF})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),P=await $(F);for(let{tokens:N}of Object.values(P))for(let{identifier:R,chain:x,...A}of N){let T=K.getChainConfig(x),B=C.includes(T.chain)?R:R.toUpperCase(),L={decimal:"decimals"in A?A.decimals:T.baseDecimal,identifier:R,logoURI:"logoURI"in A?A.logoURI:void 0,tax:"tax"in A?A.tax:void 0};if(a.set(B,L),"address"in A&&A.address){let _=C.includes(T.chain)?`${T.chain}:${A.address}`:`${T.chain}:${A.address.toUpperCase()}`;ZF.set(_,R)}}return!0}static setStaticAssets(F){a.clear(),ZF.clear();for(let[$,P]of F.entries()){let N=C.includes(P.chain)?P.identifier:P.identifier.toUpperCase(),R="decimals"in P?P.decimals:P.decimal,x={...P,decimal:R,identifier:N};if(a.set($,x),P.address){let A=C.includes(P.chain)?`${P.chain}:${P.address}`:`${P.chain}:${P.address.toUpperCase()}`;ZF.set(A,P.identifier)}}return!0}static get staticAssets(){return a}}function g$(F){let $=h.from({chain:F});return jF.match(F).with(K.Chain.Bitcoin,K.Chain.Litecoin,K.Chain.BitcoinCash,K.Chain.Dash,()=>$.set(0.00010001)).with(K.Chain.Dogecoin,()=>$.set(1.00000001)).with(K.Chain.Avalanche,K.Chain.Ethereum,K.Chain.Arbitrum,K.Chain.BinanceSmartChain,()=>$.set(0.00000001)).with(K.Chain.THORChain,K.Chain.Maya,()=>$.set(0)).with(K.Chain.Cosmos,K.Chain.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function I$({chain:F,address:$,ticker:P}){let R=C.includes(F)?`${F}:${$||P}`:`${F}:${$||P}`.toUpperCase(),x=yP(R);if(x)return x;if(!$){let{baseDecimal:B}=K.getChainConfig(F);return{decimals:B,identifier:`${F}.${P||"UNKNOWN"}`}}let A=await YF({address:$,chain:F}),T=`${F}.${A.ticker||P||"UNKNOWN"}-${$}`;return V({condition:!!(!A.ticker&&P),id:`async_token_lookup_failed_${F}_${$}`,warning:`Could not fetch token metadata for ${F}:${$} from chain. Using user-provided ticker (${P}) with baseDecimal (${A.decimals}).`}),A.ticker&&pP(R,{decimals:A.decimals,identifier:T}),{decimals:A.decimals,identifier:T}}function fF({identifier:F,decimal:$,value:P,tax:N}){return JF(F),new h({decimal:$,identifier:F,tax:N,value:FF(P,$)})}function fP(F,$=0){let P=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,N=P?bF.includes(P):!1,R=F.slice(0,14).includes("~")?"~":"/",[x,A]=N?F.split(".").slice(1).join().split(R):F.split(R);if(!(x&&A))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new h({decimal:8,identifier:`${P||K.Chain.THORChain}.${x}${R}${A}`,value:FF($,8)})}async function bP({address:F,chain:$,fromBaseDecimal:P,parsedValue:N}){let{decimals:R,identifier:x}=await I$({address:F,chain:$}),A=P?FF(BigInt(N),P):N;return fF({decimal:R,identifier:x,value:A})}function FF(F,$){return typeof F==="bigint"?y({bigIntDecimal:$,decimal:$,value:F}):F}function EP(F){let $=jF.match(F).when((P)=>("chain"in P)&&P.chain!==void 0,({chain:P})=>P).otherwise((P)=>{let N=i(P.asset);return N.synth?K.Chain.THORChain:N.chain});if(!K.AllChains.includes($.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function uP(F){if(EP(F),"chain"in F){let{chain:R,address:x}=F;if(x){let A=C.includes(R)?`${R}:${x}`:`${R}:${x.toUpperCase()}`,T=ZF.get(A);if(T)return T;return A}return R}let{chain:$,symbol:P}=i(F.asset);return NF({chain:$,symbol:P})==="Native"?$:F.asset}function CP(F,$,P){let N=F.split("."),R=N[0]?.toUpperCase(),x=bF.includes(R),A=P?"~":"/",[T,B=""]=x?N.slice(1).join(".").split(A):F.split(A);if(!(T&&B))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:z,address:L}=k$({chain:T,symbol:B}),_=`${T}${A}${B}`;return{address:L,chain:R,isGasAsset:!1,isSynthetic:$,isTradeAsset:P,symbol:_,ticker:z}}function oP(F){let $=F.indexOf("."),P=($===-1?F:F.slice(0,$)).toUpperCase(),N=$===-1?F:F.slice($+1),{address:R,ticker:x}=k$({chain:P,symbol:N}),A;try{A=R&&K.EVMChains.includes(P)&&pF.getAddress(R)?pF.getAddress(R):R}catch{A=R}let T=A?`${x}-${A}`:N;return{address:A,chain:P,isGasAsset:LF({chain:P,symbol:N}),isSynthetic:!1,isTradeAsset:!1,symbol:T,ticker:x}}function w$(F){let $=F.slice(0,14),P=$.includes("/"),N=$.includes("~");if(P||N)return CP(F,P,N);return oP(F)}function nP(F,$=!1){let P=$?F.indexOf("-"):F.lastIndexOf("-");if(P===-1)return{address:void 0,ticker:F};let N=F.slice(0,P);return{address:F.slice(P+1),ticker:N}}function k$({symbol:F,chain:$}){let{ticker:P,address:N}=nP(F,$===K.Chain.Near);return{address:N&&!C.includes($)?N.toLowerCase():N,ticker:P}}var D$={};S(D$,{getFeeMultiplierAsBigInt:()=>uF,getFeeMultiplier:()=>SF,applyFeeMultiplierToBigInt:()=>O$,applyFeeMultiplier:()=>v$,DEFAULT_FEE_MULTIPLIERS:()=>EF});var EF={average:1,fast:1.5,fastest:2};function SF(F="average"){let $=g.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return EF[F]}function uF(F="average"){let $=SF(F),P=10n,N=BigInt(Math.round($*10));return{denominator:P,numerator:N}}function O$(F,$="average"){let{numerator:P,denominator:N}=uF($);return F*P/N}function v$(F,$="average",P=!1){let N=SF($),R=F*N;return P?Math.floor(R):R}var y$={};S(y$,{SwapKitNumber:()=>I});class I extends O{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new I({decimal:$,value:y({bigIntDecimal:$,decimal:$,value:F})})}}var E$={};S(E$,{updateDerivationPath:()=>AF,getWalletFormatFor:()=>f$,getDerivationPathFor:()=>p$,derivationPathToString:()=>CF,DerivationPath:()=>b$});var xF=require("@swapkit/types");function AF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[P,N,R,,x]=F;return[P,N,R,$.change,x]}if("account"in $){let[P,N,,R,x]=F;return[P,N,$.account,R,x]}return F}function CF([F,$,P,N,R]){let x=typeof R!=="number";if(typeof N!=="number")return`m/${F}'/${$}'/${P}'`;return`m/${F}'/${$}'/${P}'/${N}${x?"":`/${R}`}`}function p$({chain:F,index:$,addressIndex:P=0,type:N}){if(xF.EVMChains.includes(F)){if(N&&["legacy","account"].includes(N))return[44,60,0,$];if(N==="ledgerLive")return[44,60,$,0,P];return AF(b[F],{index:$})}if(F===xF.Chain.Solana){if(N==="account")return[44,501,0,$];return AF(b[F],{index:$})}let R=F===xF.Chain.Litecoin?2:0;switch(N){case"nativeSegwitMiddleAccount":return[84,R,$,0,P];case"segwit":return[49,R,0,0,$];case"legacy":return[44,R,0,0,$];default:return AF(b[F],{index:$})}}function f$(F){let[$,P,N]=F.split("/").map((R)=>Number.parseInt(R,10));switch(P){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var b$=Object.keys(b).reduce((F,$)=>{return F[$]=CF(b[$]),F},{});var o$={};S(o$,{getExplorerTxUrl:()=>u$,getExplorerAddressUrl:()=>C$});var Z=require("@swapkit/types"),oF=require("ts-pattern");function u$({chain:F,txHash:$}){let{explorerUrl:P}=Z.getChainConfig(F);return oF.match(F).with(...Z.CosmosChains,Z.Chain.Solana,()=>`${P}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(...Z.EVMChains,...Z.SubstrateChains,()=>`${P}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(...Z.UTXOChains,Z.Chain.Radix,Z.Chain.Tron,()=>`${P}/transaction/${$.toLowerCase()}`).with(Z.Chain.Near,()=>`${P}/txns/${$}`).with(Z.Chain.Ripple,()=>`${P}/transactions/${$}`).with(Z.Chain.Sui,()=>`${P}/txblock/${$}`).with(Z.Chain.Cardano,Z.Chain.Ton,()=>`${P}/tx/${$}`).otherwise(()=>"")}function C$({chain:F,address:$}){let{explorerUrl:P}=Z.getChainConfig(F);return oF.match(F).with(Z.Chain.Solana,Z.Chain.Sui,Z.Chain.Radix,()=>`${P}/account/${$}`).otherwise(()=>`${P}/address/${$}`)}var d$={};S(d$,{getSymmetricWithdraw:()=>h$,getSymmetricPoolShare:()=>hF,getLiquiditySlippage:()=>c$,getEstimatedPoolShare:()=>t$,getAsymmetricRuneWithdrawAmount:()=>n$,getAsymmetricRuneShare:()=>nF,getAsymmetricAssetWithdrawAmount:()=>m$,getAsymmetricAssetShare:()=>mF});var UF=require("@swapkit/types");function nF({liquidityUnits:F,poolUnits:$,runeDepth:P}){let N=q(F),R=q($),x=q(P),A=N.mul(x),T=R.mul(R).mul(2),B=R.mul(N).mul(2),z=N.mul(N),L=R.mul(R).mul(R);return A.mul(T.sub(B).add(z)).div(L)}function mF({liquidityUnits:F,poolUnits:$,assetDepth:P}){let N=q(F),R=q($),x=q(P),A=N.mul(x),T=R.mul(R).mul(2),B=R.mul(N).mul(2),z=N.mul(N),L=A.mul(T.sub(B).add(z)),_=R.mul(R).mul(R);return L.div(_)}function n$({percent:F,runeDepth:$,liquidityUnits:P,poolUnits:N}){return nF({liquidityUnits:P,poolUnits:N,runeDepth:$}).mul(F)}function m$({percent:F,assetDepth:$,liquidityUnits:P,poolUnits:N}){return mF({assetDepth:$,liquidityUnits:P,poolUnits:N}).mul(F)}function q(F){return I.fromBigInt(BigInt(F),UF.getChainConfig(UF.Chain.THORChain).baseDecimal)}function hF({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N}){return{assetAmount:q(N).mul(F).div($),runeAmount:q(P).mul(F).div($)}}function h$({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N,percent:R}){return Object.fromEntries(Object.entries(hF({assetDepth:N,liquidityUnits:F,poolUnits:$,runeDepth:P})).map(([x,A])=>[x,A.mul(R)]))}function t$({runeDepth:F,poolUnits:$,assetDepth:P,liquidityUnits:N,runeAmount:R,assetAmount:x}){let A=new I({decimal:8,value:F}),T=new I({decimal:8,value:P}),B=new I({decimal:8,value:$}),z=new I({decimal:8,value:R}),L=new I({decimal:8,value:x}),_=z.mul(T),w=L.mul(A),v=z.mul(L),D=A.mul(T),o=B.mul(_.add(w.add(v.mul(2)))),t=_.add(w.add(D.mul(2))),p=o.div(t),k=q(N).add(p);if(p.getBaseValue("number")===0)return k.div(B).getBaseValue("number");let c=B.add(k);return k.div(c).getBaseValue("number")}function c$({runeAmount:F,assetAmount:$,runeDepth:P,assetDepth:N}){if(F==="0"||$==="0"||P==="0"||N==="0")return 0;let R=q(P),x=q(N),A=q($),T=q(F),B=A.mul(R).sub(x.mul(T)),z=x.mul(T).add(R.mul(x));return Math.abs(B.div(z).getBaseValue("number"))}var HP={};S(HP,{getMemoForWithdraw:()=>e$,getMemoForUnbond:()=>i$,getMemoForTcyStake:()=>RP,getMemoForTcyClaim:()=>NP,getMemoForRunePoolWithdraw:()=>FP,getMemoForRunePoolDeposit:()=>r$,getMemoForNameRegister:()=>$P,getMemoForNamePreferredAssetRegister:()=>PP,getMemoForLeaveAndBond:()=>s$,getMemoForDeposit:()=>a$});var GF=require("@swapkit/types"),l$=require("ts-pattern");function s$({type:F,address:$}){return`${F}:${$}`}function i$({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function r$(F){return qF("POOL+",F)}function a$({chain:F,symbol:$,address:P,...N}){let R=mP({chain:F,symbol:$}),x=P?`:${P}:`:":";return qF(`${"+"}:${R}${x}`,N)}function e$({chain:F,symbol:$,ticker:P,basisPoints:N,targetAsset:R}){let x=F==="ETH"&&P!=="ETH"?`${P}-${$.slice(-3)}`:$,A=R?`:${R}`:"";return`${"-"}:${F}.${x}:${N}${A}`}function FP({basisPoints:F,...$}){return qF(`${"POOL-"}:${F}`,$)}function $P({name:F,chain:$,address:P,owner:N}){let R=`${"~"}:${F}:${$}:${P}`,x=N?`:${N}`:"";return`${R}${x}`}function PP({name:F,chain:$,asset:P,payout:N,owner:R}){return`${"~"}:${F}:${$}:${N}:${R}:${P}`}function NP(F,{address:$}){return`${F}:${$}`}function RP(F,{unstakeBps:$,...P}){let N=$?`:${$}`:"",R=`${F}${N}`;return qF(`${R}`,P)}function qF(F,{affiliateAddress:$,affiliateBasisPoints:P}={}){let N=`${F}${$?`:${$}:${P||0}`:""}`;return N.endsWith(":")?N.slice(0,-1):N}function mP({chain:F,symbol:$}){return l$.match(F).with(GF.Chain.Bitcoin,GF.Chain.Dogecoin,GF.Chain.Litecoin,()=>F.slice(0,1).toLowerCase()).with(GF.Chain.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}var _P={};S(_P,{wrapMethodWithNetworkSwitch:()=>lF,switchEVMWalletNetwork:()=>dF,providerRequest:()=>WF,prepareNetworkSwitch:()=>TP,okxMobileEnabled:()=>iF,listWeb3EVMWallets:()=>cF,isWeb3Detected:()=>AP,isDetected:()=>xP,getETHDefaultWallet:()=>MP,getEIP6963Wallets:()=>QP,filterSupportedChains:()=>GP,addEVMWalletNetwork:()=>sF,addAccountsChangedCallback:()=>BP});var tF=require("@swapkit/types");function AP(){return typeof window.ethereum<"u"}function xP(F){return cF().includes(F)}function cF(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.ctrl||window?.ethereum?.__XDEFI,P=window?.vultisig,N=window?.ethereum?.isBraveWallet,R=window?.ethereum?.isTrust||window?.trustwallet,x=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,T=window?.$onekey?.ethereum,B=[];if(F)B.push("METAMASK");if($)B.push("CTRL");if(P)B.push("VULTISIG");if(N)B.push("BRAVE");if(R)B.push("TRUSTWALLET_WEB");if(x)B.push("COINBASE_WEB");if(iF())B.push("OKX_MOBILE");if(A)B.push("BITGET");if(T)B.push("ONEKEY");return B}async function dF(F,$,P){let N=tF.getChainConfig($);try{await WF({method:"wallet_switchEthereumChain",params:[{chainId:N.chainIdHex}],provider:F})}catch(R){if(!P)throw new J("helpers_failed_to_switch_network",{error:R,reason:"networkParams not provided"});await sF(F,P)}}function GP({chains:F,supportedChains:$,walletType:P}){let N=F.filter((x)=>!x||$.includes(x));if(N.length===0)throw new J("wallet_chain_not_supported",{chain:F.join(", "),wallet:P});let R=F.filter((x)=>!$.includes(x));return V({condition:R.length>0,id:`wallet_chain_not_supported_${P}`,warning:`${P} wallet does not support the following chains: ${R.join(", ")}. These chains will be ignored.`}),N}function lF(F,$,P){return async(...N)=>{let{chainIdHex:R}=tF.getChainConfig(P);if((await $.getNetwork()).chainId.toString()===R)return F(...N);try{await dF($,P)}catch(x){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return F(...N)}}function TP({toolbox:F,chain:$,provider:P=window.ethereum,methodNames:N=[]}){let x=[...N,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((A,T)=>{if(!F[T])return A;let B=F[T];if(typeof B!=="function")return A;let z=lF(B,P,$);return{...A,[T]:z}},{});return{...F,...x}}function sF(F,$){return WF({method:"wallet_addEthereumChain",params:[$],provider:F})}function BP(F){window.ethereum?.on("accountsChanged",()=>F()),window.ctrl?.ethereum.on("accountsChanged",()=>F())}function MP(){let{isTrust:F,isBraveWallet:$,__XDEFI:P,overrideIsMetaMask:N,selectedProvider:R}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(N&&R?.isCoinbaseWallet)return"COINBASE_WEB";if(P)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function QP(){let F=[];function $(N){if(F.map((R)=>R.info.uuid).includes(N.detail.info.uuid))return;F.push(N.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function P(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:P}}function iF(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),P=/android|XiaoMi|MiuiBrowser/i.test(F),N=$||P,R=/OKApp/i.test(F);return N&&R}function WF({provider:F,params:$,method:P}){if(!F?.send)throw new J("helpers_not_found_provider");let N=$?Array.isArray($)?$:[$]:[];return F.send(P,N)}
|
|
5
|
-
|
|
6
|
-
//# debugId=DFC11C4C04063E7664756E2164756E21
|
|
7
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
var x={};_(x,{wrapWithThrow:()=>e$,wrapMethodWithNetworkSwitch:()=>r,warnOnce:()=>m,validateTNS:()=>jf,validateIdentifier:()=>Wf,updateDerivationPath:()=>V,switchEVMWalletNetwork:()=>c,swapKitConfigStore:()=>s$,supportsV3SwapFlow:()=>K$,signWidgetRequest:()=>Tf,providerRequest:()=>T,prepareNetworkSwitch:()=>q$,parseSymbolForAddress:()=>Xf,okxMobileEnabled:()=>u,listWeb3EVMWallets:()=>w,isWeb3Detected:()=>E$,isGasAsset:()=>zf,isDetected:()=>I$,initializeRPCUrlsWithFallback:()=>xf,getWalletFormatFor:()=>t,getTokenLogoURI:()=>Zf,getTHORNameCost:()=>t$,getSymmetricWithdraw:()=>x$,getSymmetricPoolShare:()=>y,getRPCUrlSync:()=>Rf,getRPCUrl:()=>gf,getMinAmountByChain:()=>If,getMemoForWithdraw:()=>_$,getMemoForUnbond:()=>Q$,getMemoForTcyStake:()=>H$,getMemoForTcyClaim:()=>C$,getMemoForRunePoolWithdraw:()=>P$,getMemoForRunePoolDeposit:()=>X$,getMemoForNameRegister:()=>W$,getMemoForNamePreferredAssetRegister:()=>j$,getMemoForLeaveAndBond:()=>L$,getMemoForDeposit:()=>Z$,getMAYANameCost:()=>a$,getLiquiditySlippage:()=>Y$,getFeeMultiplierAsBigInt:()=>K,getFeeMultiplier:()=>I,getExplorerTxUrl:()=>$$,getExplorerAddressUrl:()=>f$,getEstimatedPoolShare:()=>M$,getETHDefaultWallet:()=>S$,getEIP6963Wallets:()=>A$,getDerivationPathFor:()=>i,getCommonAssetInfo:()=>Jf,getChainIdentifier:()=>$f,getAsymmetricRuneWithdrawAmount:()=>R$,getAsymmetricRuneShare:()=>O,getAsymmetricAssetWithdrawAmount:()=>g$,getAsymmetricAssetShare:()=>k,getAssetType:()=>Lf,formatBigIntToSafeValue:()=>Hf,findAssetBy:()=>_f,filterSupportedChains:()=>N$,fetchTokenInfo:()=>Gf,derivationPathToString:()=>U,assetFromString:()=>Qf,applyFeeMultiplierToBigInt:()=>l,applyFeeMultiplier:()=>n,addEVMWalletNetwork:()=>h,addAccountsChangedCallback:()=>T$,_rpcCache:()=>Bf,WarningCodeEnum:()=>c$,WalletOption:()=>F$,V3SwapFlowSupport:()=>b,TxnType:()=>Uf,TxnStatus:()=>Of,TronTransactionSchema:()=>gB,TransactionSchema:()=>ef,TransactionDTOSchema:()=>$B,TrackingStatus:()=>kf,TrackingRequestSchema:()=>bf,TrackingRequestQuerySchema:()=>mf,TrackerResponseSchema:()=>af,TokenSchema:()=>yf,TokenDetailsMetadataSchema:()=>rf,TONTransactionSchema:()=>zB,SwapToResponseSchema:()=>TB,SwapToRequestSchema:()=>NB,SwapToAssetSchema:()=>qB,SwapRouteV2ResponseSchema:()=>UB,SwapKitNumber:()=>Z,SwapKitError:()=>C,SwapKitApi:()=>DB,StarknetTransactionSchema:()=>GB,SKConfig:()=>j,RouteQuoteWarningSchema:()=>PB,RouteQuoteTxType:()=>Kf,RouteQuoteProviderErrorSchema:()=>AB,RouteQuoteMetadataV2Schema:()=>_B,RouteQuoteMetadataSchema:()=>ZB,RouteQuoteMetadataAssetSchema:()=>QB,RouteLegWithoutAddressesSchema:()=>LB,RouteLegSchema:()=>JB,RequestClient:()=>p$,QuoteV3ResponseSchema:()=>IB,QuoteV2ResponseSchema:()=>KB,QuoteRouteV2Response:()=>SB,QuoteResponseSchema:()=>jB,QuoteResponseRouteItem:()=>WB,QuoteRequestSchema:()=>uf,ProviderName:()=>r$,ProviderAction:()=>Df,PriorityLabel:()=>Af,PriceResponseSchema:()=>hf,PriceRequestSchema:()=>df,NetworkDerivationPath:()=>P,NearSwapResponseSchema:()=>tf,NearDepositChannelResultSchema:()=>pf,NearDepositChannelParamsSchema:()=>nf,MemoType:()=>z$,LedgerErrorCode:()=>d$,GasSchema:()=>CB,GasResponseSchema:()=>HB,FeesSchema:()=>fB,FeeTypeEnum:()=>h$,FeeOption:()=>s,EstimatedTimeSchema:()=>BB,ErrorCode:()=>w$,EVMTransactionSchema:()=>RB,EVMTransactionDetailsSchema:()=>MB,EVMTransactionDetailsParamsSchema:()=>xB,DerivationPath:()=>a,DepositChannelResponseSchema:()=>lf,DepositChannelParamsSchema:()=>of,DEFAULT_FEE_MULTIPLIERS:()=>A,CosmosTransactionSchema:()=>YB,CommonAssetStrings:()=>Yf,CoinGeckoMetadataSchema:()=>cf,ChainflipMetadataSchema:()=>XB,BrokerDepositChannelParamsSchema:()=>sf,BigIntArithmetics:()=>Vf,AssetValueSchema:()=>wf,AssetValue:()=>Ef,ApproveResponseSchema:()=>FB,ApproveRequestParams:()=>VB,ApproveMode:()=>u$,ApprovalTransactionSchema:()=>EB,ApiV2ErrorSchema:()=>vf});module.exports=v$(x);M(x,require("@swapkit/tokens"),module.exports);M(x,require("@swapkit/types"),module.exports);var p={};_(p,{getFeeMultiplierAsBigInt:()=>K,getFeeMultiplier:()=>I,applyFeeMultiplierToBigInt:()=>l,applyFeeMultiplier:()=>n,DEFAULT_FEE_MULTIPLIERS:()=>A});var A={average:1,fast:1.5,fastest:2};function I($="average"){let f=j.get("feeMultipliers");if(f&&f[$]!==void 0)return f[$];return A[$]}function K($="average"){let f=I($),B=10n,R=BigInt(Math.round(f*10));return{denominator:B,numerator:R}}function l($,f="average"){let{numerator:B,denominator:R}=K(f);return $*B/R}function n($,f="average",B=!1){let R=I(f),g=$*R;return B?Math.floor(g):g}var e={};_(e,{updateDerivationPath:()=>V,getWalletFormatFor:()=>t,getDerivationPathFor:()=>i,derivationPathToString:()=>U,DerivationPath:()=>a});var F=require("@swapkit/types");function V($,f){if("index"in f)return[...$.slice(0,$.length-1),f.index];if("change"in f){let[B,R,g,,Y]=$;return[B,R,g,f.change,Y]}if("account"in f){let[B,R,,g,Y]=$;return[B,R,f.account,g,Y]}return $}function U([$,f,B,R,g],{allHardened:Y}={}){let J=Y?"'":"",L=typeof g!=="number";if(typeof R!=="number")return`m/${$}'/${f}'/${B}'`;return`m/${$}'/${f}'/${B}'/${R}${J}${L?"":`/${g}${J}`}`}function i({chain:$,index:f,addressIndex:B=0,type:R}){if(F.EVMChains.includes($)){if(R&&["legacy","account"].includes(R))return[44,60,0,f];if(R==="ledgerLive")return[44,60,f,0,B];return V(P[$],{index:f})}if($===F.Chain.Solana){if(R==="account")return[44,501,0,f];return V(P[$],{index:f})}let g=$===F.Chain.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,g,f,0,B];case"segwit":return[49,g,0,0,f];case"legacy":return[44,g,0,0,f];default:return V(P[$],{index:f})}}function t($){let[f,B,R]=$.split("/").map((g)=>Number.parseInt(g,10));switch(B){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var a=Object.keys(P).reduce(($,f)=>{return $[f]=U(P[f]),$},{});var B$={};_(B$,{getExplorerTxUrl:()=>$$,getExplorerAddressUrl:()=>f$});var z=require("@swapkit/types"),D=require("ts-pattern");function $$({chain:$,txHash:f}){let{explorerUrl:B}=z.getChainConfig($);return D.match($).with(...z.CosmosChains,z.Chain.Solana,()=>`${B}/tx/${f.startsWith("0x")?f.slice(2):f}`).with(...z.EVMChains,...z.SubstrateChains,()=>`${B}/tx/${f.startsWith("0x")?f:`0x${f}`}`).with(...z.UTXOChains,z.Chain.Radix,z.Chain.Tron,()=>`${B}/transaction/${f.toLowerCase()}`).with(z.Chain.Near,()=>`${B}/txns/${f}`).with(z.Chain.Ripple,()=>`${B}/transactions/${f}`).with(z.Chain.Sui,()=>`${B}/txblock/${f}`).with(z.Chain.Cardano,z.Chain.Ton,()=>`${B}/tx/${f}`).otherwise(()=>"")}function f$({chain:$,address:f}){let{explorerUrl:B}=z.getChainConfig($);return D.match($).with(z.Chain.Solana,z.Chain.Sui,z.Chain.Radix,()=>`${B}/account/${f}`).otherwise(()=>`${B}/address/${f}`)}var G$={};_(G$,{getSymmetricWithdraw:()=>x$,getSymmetricPoolShare:()=>y,getLiquiditySlippage:()=>Y$,getEstimatedPoolShare:()=>M$,getAsymmetricRuneWithdrawAmount:()=>R$,getAsymmetricRuneShare:()=>O,getAsymmetricAssetWithdrawAmount:()=>g$,getAsymmetricAssetShare:()=>k});var N=require("@swapkit/types");function O({liquidityUnits:$,poolUnits:f,runeDepth:B}){let R=Q($),g=Q(f),Y=Q(B),J=R.mul(Y),L=g.mul(g).mul(2),G=g.mul(R).mul(2),X=R.mul(R),W=g.mul(g).mul(g);return J.mul(L.sub(G).add(X)).div(W)}function k({liquidityUnits:$,poolUnits:f,assetDepth:B}){let R=Q($),g=Q(f),Y=Q(B),J=R.mul(Y),L=g.mul(g).mul(2),G=g.mul(R).mul(2),X=R.mul(R),W=J.mul(L.sub(G).add(X)),H=g.mul(g).mul(g);return W.div(H)}function R$({percent:$,runeDepth:f,liquidityUnits:B,poolUnits:R}){return O({liquidityUnits:B,poolUnits:R,runeDepth:f}).mul($)}function g$({percent:$,assetDepth:f,liquidityUnits:B,poolUnits:R}){return k({assetDepth:f,liquidityUnits:B,poolUnits:R}).mul($)}function Q($){return Z.fromBigInt(BigInt($),N.getChainConfig(N.Chain.THORChain).baseDecimal)}function y({liquidityUnits:$,poolUnits:f,runeDepth:B,assetDepth:R}){return{assetAmount:Q(R).mul($).div(f),runeAmount:Q(B).mul($).div(f)}}function x$({liquidityUnits:$,poolUnits:f,runeDepth:B,assetDepth:R,percent:g}){return Object.fromEntries(Object.entries(y({assetDepth:R,liquidityUnits:$,poolUnits:f,runeDepth:B})).map(([Y,J])=>[Y,J.mul(g)]))}function M$({runeDepth:$,poolUnits:f,assetDepth:B,liquidityUnits:R,runeAmount:g,assetAmount:Y}){let J=new Z({decimal:8,value:$}),L=new Z({decimal:8,value:B}),G=new Z({decimal:8,value:f}),X=new Z({decimal:8,value:g}),W=new Z({decimal:8,value:Y}),H=X.mul(L),d=W.mul(J),D$=X.mul(W),O$=J.mul(L),k$=G.mul(H.add(d.add(D$.mul(2)))),y$=H.add(d.add(O$.mul(2))),o=k$.div(y$),S=Q(R).add(o);if(o.getBaseValue("number")===0)return S.div(G).getBaseValue("number");let b$=G.add(S);return S.div(b$).getBaseValue("number")}function Y$({runeAmount:$,assetAmount:f,runeDepth:B,assetDepth:R}){if($==="0"||f==="0"||B==="0"||R==="0")return 0;let g=Q(B),Y=Q(R),J=Q(f),L=Q($),G=J.mul(g).sub(Y.mul(L)),X=Y.mul(L).add(g.mul(Y));return Math.abs(G.div(X).getBaseValue("number"))}var V$={};_(V$,{getMemoForWithdraw:()=>_$,getMemoForUnbond:()=>Q$,getMemoForTcyStake:()=>H$,getMemoForTcyClaim:()=>C$,getMemoForRunePoolWithdraw:()=>P$,getMemoForRunePoolDeposit:()=>X$,getMemoForNameRegister:()=>W$,getMemoForNamePreferredAssetRegister:()=>j$,getMemoForLeaveAndBond:()=>L$,getMemoForDeposit:()=>Z$});var E=require("@swapkit/types"),J$=require("ts-pattern");function L$({type:$,address:f}){return`${$}:${f}`}function Q$({address:$,unbondAmount:f}){return`${"UNBOND"}:${$}:${f}`}function X$($){return q("POOL+",$)}function Z$({chain:$,symbol:f,address:B,...R}){let g=m$({chain:$,symbol:f}),Y=B?`:${B}:`:":";return q(`${"+"}:${g}${Y}`,R)}function _$({chain:$,symbol:f,ticker:B,basisPoints:R,targetAsset:g}){let Y=$==="ETH"&&B!=="ETH"?`${B}-${f.slice(-3)}`:f,J=g?`:${g}`:"";return`${"-"}:${$}.${Y}:${R}${J}`}function P$({basisPoints:$,...f}){return q(`${"POOL-"}:${$}`,f)}function W$({name:$,chain:f,address:B,owner:R}){let g=`${"~"}:${$}:${f}:${B}`,Y=R?`:${R}`:"";return`${g}${Y}`}function j$({name:$,chain:f,asset:B,payout:R,owner:g}){return`${"~"}:${$}:${f}:${R}:${g}:${B}`}function C$($,{address:f}){return`${$}:${f}`}function H$($,{unstakeBps:f,...B}){let R=f?`:${f}`:"",g=`${$}${R}`;return q(`${g}`,B)}function q($,{affiliateAddress:f,affiliateBasisPoints:B}={}){let R=`${$}${f?`:${f}:${B||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function m$({chain:$,symbol:f}){return J$.match($).with(E.Chain.Bitcoin,E.Chain.Dogecoin,E.Chain.Litecoin,()=>$.slice(0,1).toLowerCase()).with(E.Chain.BitcoinCash,()=>"c").otherwise(()=>`${$}.${f}`)}var U$={};_(U$,{wrapMethodWithNetworkSwitch:()=>r,switchEVMWalletNetwork:()=>c,supportsV3SwapFlow:()=>K$,providerRequest:()=>T,prepareNetworkSwitch:()=>q$,okxMobileEnabled:()=>u,listWeb3EVMWallets:()=>w,isWeb3Detected:()=>E$,isDetected:()=>I$,getETHDefaultWallet:()=>S$,getEIP6963Wallets:()=>A$,filterSupportedChains:()=>N$,addEVMWalletNetwork:()=>h,addAccountsChangedCallback:()=>T$});var v=require("@swapkit/types");function E$(){return typeof window.ethereum<"u"}function I$($){return w().includes($)}function w(){let $=window?.ethereum&&!window.ethereum?.isBraveWallet,f=window?.ctrl||window?.ethereum?.__XDEFI,B=window?.vultisig,R=window?.ethereum?.isBraveWallet,g=window?.ethereum?.isTrust||window?.trustwallet,Y=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,J=window?.bitkeep?.ethereum,L=window?.$onekey?.ethereum,G=[];if($)G.push("METAMASK");if(f)G.push("CTRL");if(B)G.push("VULTISIG");if(R)G.push("BRAVE");if(g)G.push("TRUSTWALLET_WEB");if(Y)G.push("COINBASE_WEB");if(u())G.push("OKX_MOBILE");if(J)G.push("BITGET");if(L)G.push("ONEKEY");return G}async function c($,f,B){let R=v.getChainConfig(f);try{await T({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:$})}catch(g){if(!B)throw new C("helpers_failed_to_switch_network",{error:g,reason:"networkParams not provided"});await h($,B)}}function N$({chains:$,supportedChains:f,walletType:B}){let R=$.filter((Y)=>!Y||f.includes(Y));if(R.length===0)throw new C("wallet_chain_not_supported",{chain:$.join(", "),wallet:B});let g=$.filter((Y)=>!f.includes(Y));return m({condition:g.length>0,id:`wallet_chain_not_supported_${B}`,warning:`${B} wallet does not support the following chains: ${g.join(", ")}. These chains will be ignored.`}),R}function r($,f,B){return async(...R)=>{let{chainIdHex:g}=v.getChainConfig(B);if((await f.getNetwork()).chainId.toString()===g)return $(...R);try{await c(f,B)}catch(Y){throw new C({errorKey:"helpers_failed_to_switch_network",info:{error:Y}})}return $(...R)}}function q$({toolbox:$,chain:f,provider:B=window.ethereum,methodNames:R=[]}){let Y=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((J,L)=>{if(!$[L])return J;let G=$[L];if(typeof G!=="function")return J;let X=r(G,B,f);return{...J,[L]:X}},{});return{...$,...Y}}function h($,f){return T({method:"wallet_addEthereumChain",params:[f],provider:$})}function T$($){window.ethereum?.on("accountsChanged",()=>$()),window.ctrl?.ethereum.on("accountsChanged",()=>$())}function S$(){let{isTrust:$,isBraveWallet:f,__XDEFI:B,overrideIsMetaMask:R,selectedProvider:g}=window?.ethereum||{};if($)return"TRUSTWALLET_WEB";if(f)return"BRAVE";if(R&&g?.isCoinbaseWallet)return"COINBASE_WEB";if(B)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function A$(){let $=[];function f(R){if($.map((g)=>g.info.uuid).includes(R.detail.info.uuid))return;$.push(R.detail)}window.addEventListener("eip6963:announceProvider",f),window.dispatchEvent(new Event("eip6963:requestProvider"));function B(){window.removeEventListener("eip6963:announceProvider",f)}return{providers:$,removeEIP6963EventListener:B}}function u(){let $=navigator.userAgent,f=/iphone|ipad|ipod|ios/i.test($),B=/android|XiaoMi|MiuiBrowser/i.test($),R=f||B,g=/OKApp/i.test($);return R&&g}function T({provider:$,params:f,method:B}){if(!$?.send)throw new C("helpers_not_found_provider");let R=f?Array.isArray(f)?f:[f]:[];return $.send(B,R)}function K$($,f){if(!j.get("v3SwapFlow")?.enabled)return!1;return b[f]?.includes($)??!1}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import{a as m,c as h}from"./chunk-pfmeq01a.js";export*from"@swapkit/tokens";export*from"@swapkit/types";import{AllChains as V$,Chain as L,EVMChains as O$,getChainConfig as xF}from"@swapkit/types";import{getAddress as fF}from"ethers";import{match as YF}from"ts-pattern";import{Chain as G,EVMChains as X$,getChainConfig as p,UTXOChains as Z$}from"@swapkit/types";import{match as PF}from"ts-pattern";import{AllChains as qF,getChainConfig as F$,StagenetChain as UF,StagenetMAYAConfig as $$,StagenetTHORConfig as P$}from"@swapkit/types";import{create as N$}from"zustand";import{useShallow as R$}from"zustand/shallow";import{AllChains as cF,getChainConfig as dF}from"@swapkit/types";var C=cF.reduce((F,$)=>{return F[$]=dF($).networkDerivationPath,F},{});var lF;((H)=>{H.unknownError="unknownError";H.test_error="test_error";H.providerDetailsError="providerDetailsError";H.blockHeaderNotFound="blockHeaderNotFound";H.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";H.blockHashNotFoundAtHash="blockHashNotFoundAtHash";H.txHashMissing="txHashMissing";H.assetValueMissingInfo="assetValueMissingInfo";H.invalidAsset="invalidAsset";H.blockIsRequired="blockIsRequired";H.currentBlockHeaderNotFound="currentBlockHeaderNotFound";H.failedToRetrieveBalance="failedToRetrieveBalance";H.failedToRetrieveBlock="failedToRetrieveBlock";H.failedToRetrieveFees="failedToRetrieveFees";H.notImplementedBCH="notImplementedBCH";H.notImplementedDoge="notImplementedDoge";H.noPoolsFound="noPoolsFound";H.noVaultsFound="noVaultsFound";H.noTxFound="noTxFound";H.noInputCoinFound="noInputCoinFound";H.noBlockDataFound="noBlockDataFound";H.multipleCosmosMessages="multipleCosmosMessages";H.heightOrHashNotProvided="heightOrHashNotProvided";H.unknownDenom="unknownDenom";H.invalidBlockHeight="invalidBlockHeight";H.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";H.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";H.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";H.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";H.txMemoUndefined="txMemoUndefined";H.txMemoIncorrect="txMemoIncorrect";H.txTypeNotFound="txTypeNotFound";H.txNoMessage="txNoMessage";H.txNotFound="txNotFound";H.txReceiptNotFound="txReceiptNotFound";H.txParsingError="txParsingError";H.txLogsParsingError="txLogsParsingError";H.blockNotFound="blockNotFound";H.balanceNotFound="balanceNotFound";H.configError="configError";H.synthSwapDisallowed="synthSwapDisallowed";H.providerQuoteTimeout="providerQuoteTimeout";H.noQuoteResponse="noQuoteResponse";H.noPoolAssetsFound="noPoolAssetsFound";H.noThorchainPools="noThorchainPools";H.noMayachainPools="noMayachainPools";H.noThorchainNetworkInfo="noThorchainNetworkInfo";H.invalidAffiliateFee="invalidAffiliateFee";H.invalidBuyAssetAddress="invalidBuyAssetAddress";H.invalidSellAssetAddress="invalidSellAssetAddress";H.invalidSourceAddress="invalidSourceAddress";H.invalidDestinationAddress="invalidDestinationAddress";H.sourceAddressIsSmartContract="sourceAddressIsSmartContract";H.destinationAddressIsSmartContract="destinationAddressIsSmartContract";H.invalidChainId="invalidChainId";H.unsupportedChainId="unsupportedChainId";H.unsupportedEVMChainId="unsupportedEVMChainId";H.unsupportedMethod="unsupportedMethod";H.unsupportedProvider="unsupportedProvider";H.invalidParamsForMethod="invalidParamsForMethod";H.unsupportedAdapter="unsupportedAdapter";H.noWhitelistTokens="noWhitelistTokens";H.failedFetchGasPrice="failedFetchGasPrice";H.failedToCreateDepositChannel="failedToCreateDepositChannel";H.noProviderDetailsFound="noProviderDetailsFound";H.noTokenListsFound="noTokenListsFound";H.tokenNotFound="tokenNotFound";H.tokenPriceNotFound="tokenPriceNotFound";H.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";H.swapAmountTooSmall="swapAmountTooSmall";H.legsArrayIsEmpty="legsArrayIsEmpty";H.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";H.noBlockHeaderFound="noBlockHeaderFound";H.failedToSimulateSwap="failedToSimulateSwap";H.addressScreeningFailed="addressScreeningFailed";H.noLiquidtyProvidersFound="noLiquidtyProvidersFound";H.insufficientLiquidity="insufficientLiquidity";H.noInboundDataFound="noInbounDataFound";H.noInboundAddressesFound="noInboundAddressesFound";H.noInboundAddressFoundForChain="noInboundAddressFoundForChain";H.noLastBlocksFound="noLastBlocksFound";H.noVersionFound="noVersionFound";H.noConstantsFound="noConstantsFound";H.noMimirsFound="noMimirsFound";H.noRoutesFound="noRoutesFound";H.quoteNotFound="quoteNotFound";H.ledgerSignFailed="ledgerSignFailed";H.ledgerWrongPayload="ledgerWrongPayload";H.ledgerFetchSwapFailed="ledgerFetchSwapFailed";H.failedToFetchTx="failedToFetchTx";H.failedBuildTransactionDetails="failedBuildTransactionDetails";H.noLegsForRoute="noLegsForRoute";H.noRouterAddressFound="noRouterAddressFound";H.noAggregatorAddressFound="noAggregatorAddressFound";H.noContractInstanceFound="noContractInstanceFound";H.noContractAddressFound="noContractAddressFound";H.invalidAffiliate="invalidAffiliate";H.thornameAffiliate="thornameAffiliate";H.providerNotfound="No provider found";H.noRecordFound="No Record found";H.slippageTooLow="Slippage too low";H.tradingHalted="tradingHalted";H.noWrappedGasAsset="noWrappedGasAsset";H.aggregatorAddressNotFound="aggregatorAddressNotFound";H.routerAddressNotFound="routerAddressNotFound";H.dummyAddressNotFound="dummyAddressNotFound";H.trackerError="trackerError";H.thorchainPoolUnavailable="thorchainPoolUnavailable";H.noOhlcvDataFound="noOhlcvDataFound";H.noTradingPairs="noTradingPairs";H.noLendingAvailability="noLendingAvailability";H.lendingRepayTooSmall="lendingRepayTooSmall";H.missingState="missingState";H.ledgerSwapNotFound="ledgerSwapNotFound";H.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";H.errorEstimatingGas="errorEstimatingGas";H.apiKeyInvalid="apiKeyInvalid";H.apiKeyFailedToUpdate="apiKeyFailedToUpdate";H.apiKeyExpired="apiKeyExpired";H.unauthorized="unauthorized";H.failedToCreateMemo="failedToCreateMemo";H.radixIncorrectInstructions="radixIncorrectInstructions";H.radixTxMissedParam="radixTxMissedParam";H.radixTxMissedAccount="radixTxMissedAccount";H.radixManifestParseError="radixManifestParseError";H.radixManifestBuildError="radixManifestBuildError";H.invalidAddressForChain="invalidAddressForChain";H.riskyAddress="riskyAddress";H.noRoutesToProcess="noRoutesToProcess";H.sellAssetAmountTooSmall="sellAssetAmountTooSmall";H.missingPrivateKey="missingPrivateKey";H.noMemoPriceProtection="noMemoPriceProtection"})(lF||={});var sF;((P)=>{P.highSlippage="highSlippage";P.highPriceImpact="highPriceImpact"})(sF||={});var iF;((K)=>{K.CAVIAR_V1="CAVIAR_V1";K.CAMELOT_V3="CAMELOT_V3";K.CHAINFLIP="CHAINFLIP";K.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";K.JUPITER="JUPITER";K.MAYACHAIN="MAYACHAIN";K.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";K.OCISWAP_V1="OCISWAP_V1";K.ONEINCH="ONEINCH";K.OPENOCEAN_V2="OPENOCEAN_V2";K.PANCAKESWAP="PANCAKESWAP";K.PANGOLIN_V1="PANGOLIN_V1";K.SUSHISWAP_V2="SUSHISWAP_V2";K.THORCHAIN="THORCHAIN";K.THORCHAIN_STREAMING="THORCHAIN_STREAMING";K.TRADERJOE_V2="TRADERJOE_V2";K.UNISWAP_V2="UNISWAP_V2";K.UNISWAP_V3="UNISWAP_V3";K.NEAR="NEAR";K.GARDEN="GARDEN";K.OKX="OKX"})(iF||={});var rF;((B)=>{B.LIQUIDITY="liquidity";B.NETWORK="network";B.INBOUND="inbound";B.OUTBOUND="outbound";B.AFFILIATE="affiliate";B.TAX="tax";B.PRIORITY="priority";B.SERVICE="service"})(rF||={});var jF;((N)=>{N.Average="average";N.Fast="fast";N.Fastest="fastest"})(jF||={});var aF;((P)=>{P.Approve="approve";P.CheckOnly="checkOnly"})(aF||={});var SF;((M)=>{M.NAME_REGISTER="~";M.BOND="BOND";M.DEPOSIT="+";M.LEAVE="LEAVE";M.UNBOND="UNBOND";M.WITHDRAW="-";M.RUNEPOOL_DEPOSIT="POOL+";M.RUNEPOOL_WITHDRAW="POOL-";M.CLAIM_TCY="tcy";M.STAKE_TCY="tcy+";M.UNSTAKE_TCY="tcy-"})(SF||={});var FF;((_)=>{_.BITGET="BITGET";_.BRAVE="BRAVE";_.COINBASE_MOBILE="COINBASE_MOBILE";_.COINBASE_WEB="COINBASE_WEB";_.COSMOSTATION="COSMOSTATION";_.CTRL="CTRL";_.EIP6963="EIP6963";_.EXODUS="EXODUS";_.KEEPKEY="KEEPKEY";_.KEEPKEY_BEX="KEEPKEY_BEX";_.KEPLR="KEPLR";_.KEYSTORE="KEYSTORE";_.LEAP="LEAP";_.LEDGER="LEDGER";_.LEDGER_LIVE="LEDGER_LIVE";_.METAMASK="METAMASK";_.OKX="OKX";_.OKX_MOBILE="OKX_MOBILE";_.ONEKEY="ONEKEY";_.PASSKEYS="PASSKEYS";_.PHANTOM="PHANTOM";_.POLKADOT_JS="POLKADOT_JS";_.RADIX_WALLET="RADIX_WALLET";_.TALISMAN="TALISMAN";_.TREZOR="TREZOR";_.TRONLINK="TRONLINK";_.TRUSTWALLET_WEB="TRUSTWALLET_WEB";_.VULTISIG="VULTISIG";_.WALLETCONNECT="WALLETCONNECT";_.WALLET_SELECTOR="WALLET_SELECTOR";_.XAMAN="XAMAN"})(FF||={});var eF;((N)=>{N[N.NoError=36864]="NoError";N[N.LockedDevice=21781]="LockedDevice";N[N.TC_NotFound=65535]="TC_NotFound"})(eF||={});var H$=qF.reduce((F,$)=>{if(!F.THOR_STAGENET)F[UF.Maya]=$$.rpcUrls,F[UF.THORChain]=P$.rpcUrls;return F[$]=F$($).rpcUrls,F},{}),WF={apiKeys:{blockchair:"",keepKey:"",passkeys:"",swapKit:"",walletConnectProjectId:"",xaman:""},chains:qF,endpoints:{},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",experimental_apiKey:null,experimental_apiUrlQuote:null,experimental_apiUrlSwap:null,isDev:!1,isStagenet:!1},feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:H$,wallets:Object.values(FF)},X=N$((F)=>({...WF,setApiKey:($,P)=>F((N)=>({apiKeys:{...N.apiKeys,[$]:P}})),setConfig:($)=>F((P)=>({apiKeys:{...P.apiKeys,...$?.apiKeys},chains:P.chains.concat($?.chains||[]),endpoints:{...P.endpoints,...$?.endpoints},envs:{...P.envs,...$?.envs},feeMultipliers:$?.feeMultipliers||P.feeMultipliers,integrations:{...P.integrations,...$?.integrations},rpcUrls:{...P.rpcUrls,...$?.rpcUrls},wallets:P.wallets.concat($?.wallets||[])})),setEndpoint:($,P)=>F((N)=>({endpoints:{...N.endpoints,[$]:P}})),setEnv:($,P)=>F((N)=>({envs:{...N.envs,[$]:P}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,P)=>F((N)=>({integrations:{...N.integrations,[$]:P}})),setRequestOptions:($)=>F((P)=>({requestOptions:{retry:{...P.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||P.requestOptions.timeoutMs}})),setRpcUrl:($,P)=>F((N)=>({rpcUrls:{...N.rpcUrls,[$]:P}}))})),UP=()=>X(R$((F)=>({apiKeys:F?.apiKeys,chains:F?.chains,endpoints:F?.endpoints,envs:F?.envs,feeMultipliers:F?.feeMultipliers,integrations:F?.integrations,rpcUrls:F?.rpcUrls,wallets:F?.wallets}))),w={get:(F)=>X.getState()[F],getState:X.getState,reinitialize:()=>X.setState(WF),set:(F)=>X.getState().setConfig(F),setApiKey:(F,$)=>X.getState().setApiKey(F,$),setEndpoint:(F,$)=>X.getState().setEndpoint(F,$),setEnv:(F,$)=>X.getState().setEnv(F,$),setFeeMultipliers:(F)=>X.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>X.getState().setIntegrationConfig(F,$),setRequestOptions:(F)=>X.getState().setRequestOptions(F),setRpcUrl:(F,$)=>X.getState().setRpcUrl(F,$)};var A$={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_wallet_create_not_supported:10115,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_ledger_webhid_not_supported:20124,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_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_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_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,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_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_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,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_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,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_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_not_supported:59901,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,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,not_implemented:99999};class Y extends Error{static ErrorCode=A$;constructor(F,$){let P=typeof F==="string",N=P?F:F.errorKey,R=P?void 0:F.info,x=`${N}${R?`: ${JSON.stringify(R)}`:""}`;super(x);if(Object.setPrototypeOf(this,Y.prototype),this.name="SwapKitError",this.cause=$,$){let A=$ instanceof Error?`${$.message}${$.cause?` (${$.cause})`:""}`:JSON.stringify($);console.error(`SwapKitError [${N}]: ${A}`)}else if(R)console.error(`SwapKitError [${N}]: ${JSON.stringify(R)}`)}}var x$=(F)=>new Promise(($)=>setTimeout($,F)),G$=(F,{baseDelay:$,backoffMultiplier:P,maxDelay:N})=>Math.min($*P**F,N),T$=async(F,$)=>{let P=await fetch(F,$);if(!P.ok){let N={status:P.status,statusText:P.statusText};throw new Y({errorKey:"helpers_invalid_response",info:N},N)}return P.json()};function $F(F,$={}){return async function(N,R={}){let{searchParams:x,json:A,body:T,headers:B,dynamicHeader:Q,retry:z,timeoutMs:M,abortController:Z,onError:q,onSuccess:W,responseHandler:D,...E}={...$,...R},I=w.get("requestOptions"),U={...I.retry,...z},u=!!A||N.endsWith(".json"),a=M$(N,x),K=B$(u,{...B,...Q?.()}),s=u?JSON.stringify(A):T,k;for(let e=0;e<=U.maxRetries;e++){let XF=Z||new AbortController,ZF=setTimeout(()=>XF.abort(),M||I.timeoutMs);try{let y=await T$(a,{...E,body:s,headers:K,method:F,signal:XF.signal});return clearTimeout(ZF),W?.(y)||D?.(y)||y}catch(y){if(clearTimeout(ZF),k=y,e>=U.maxRetries)return q?q(y):Promise.reject(y);await x$(G$(e,U))}}return q?q(k):Promise.reject(k)}}function B$(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function M$(F,$){let P=new URL(F);if($)P.search=new URLSearchParams($).toString();return P.toString()}var o={extend:(F)=>({extend:($)=>o.extend({...F,...$}),get:$F("GET",F),post:$F("POST",F)}),get:$F("GET"),post:$F("POST")};import{Chain as j,CosmosChains as Q$,EVMChains as _$,StagenetChains as z$,UTXOChains as K$}from"@swapkit/types";import{match as IF}from"ts-pattern";import{Chain as MF}from"@swapkit/types";function OP(F){if(F<0)throw new Y({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function vP(F){if(F<0)throw new Y({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function DP(F,$){try{return F()}catch(P){if($)throw new Y($,P);return}}function yP(F){switch(F){case MF.THORChain:return`${F}.RUNE`;case MF.Cosmos:return`${F}.ATOM`;case MF.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var wF=new Set;function V({condition:F,id:$,warning:P}){if(F){if(wF.has($))return;console.warn(P),wF.add($)}}function Y$(F){return IF(F).with(..._$,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...K$,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...Q$,...z$,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(j.Polkadot,j.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(j.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(j.Sui,()=>({id:1,jsonrpc:"2.0",method:"sui_getSystemState",params:[]})).with(j.Ton,()=>({id:1,jsonrpc:"2.0",method:"getAddressInformation",params:{address:""}})).with(j.Tron,j.Radix,()=>"").with(j.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(j.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new Y("helpers_chain_not_supported",{chain:F})})}function L$(F){return IF(F).with(j.Radix,()=>"/status/network-configuration").with(j.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function gF(F,$){try{let P=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${P}${L$(F)}`,{body:JSON.stringify(Y$(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var QF=new Map,J$=120000;async function n(F){let{isStagenet:$}=w.get("envs"),[P="",...N]=w.get("rpcUrls")[F];if(!P)throw V({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 ${F}.`}),new Y("helpers_chain_no_public_or_set_rpc_url",{chain:F});if($)return P;let R=QF.get(F);if(R&&Date.now()-R.timestamp<J$)return R.url;if(!await gF(F,P)){for(let A of N)if(await gF(F,A))return QF.set(F,{timestamp:Date.now(),url:A}),A}return QF.set(F,{timestamp:Date.now(),url:P}),P}function oP(F){V({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}var dP=[`${G.Maya}.MAYA`,`${G.Maya}.CACAO`,`${G.Ethereum}.THOR`,`${G.Ethereum}.vTHOR`,`${G.Kujira}.USK`,`${G.Ethereum}.FLIP`,`${G.Radix}.XRD`],kF=[G.Arbitrum,G.Aurora,G.Base,G.Ethereum,G.Optimism];async function j$(F){let{baseDecimal:$}=p(G.Radix);try{let P=await n(G.Radix),{manager:N}=await o.post(`${P}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:F}),headers:{Accept:"*/*","Content-Type":"application/json"}});return N?.divisibility?.value?.divisibility}catch(P){let N=P instanceof Error?P.message:String(P);return console.warn(`Failed to fetch Radix asset decimals for ${F}: ${N}`),$}}async function S$(F){try{let $=await n(G.Radix);return(await o.post(`${$}/state/entity/details`,{body:JSON.stringify({addresses:[F],opt_ins:{explicit_metadata:["symbol"]}}),headers:{Accept:"*/*","Content-Type":"application/json"}})).items[0]?.explicit_metadata?.items.find((R)=>R.key==="symbol")?.value.typed.value||void 0}catch($){let P=$ instanceof Error?$.message:String($);return console.warn(`Failed to fetch Radix asset symbol for ${F}: ${P}`),""}}async function VF({chain:F,address:$,methodHex:P,id:N}){let R=await n(F);return o.post(R,{body:JSON.stringify({id:N,jsonrpc:"2.0",method:"eth_call",params:[{data:P,to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}})}async function U$(F){if(!F||F==="0x")return"UNKNOWN";try{let{AbiCoder:$}=await import("ethers");return $.defaultAbiCoder().decode(["string"],F)[0].trim()}catch($){return console.warn(`Failed to decode ABI string from ${F}: ${$}`),"UNKNOWN"}}function q$(F,$){if(!F||F==="0x")return $;try{return Number(F)}catch(P){return console.warn(`Failed to decode ABI uint8 from ${F}: ${P}`),$}}async function W$({chain:F,address:$}){let{baseDecimal:P}=p(F),N=$.toLowerCase();if($===""||!N.startsWith("0x"))return P;let R=await VF({address:$,chain:F,id:2,methodHex:"0x313ce567"}).catch((A)=>{return console.warn(`Could not fetch decimals for ${$} on ${F}: ${A.message}`),{result:""}});return q$(R.result,P)}async function w$({chain:F,address:$}){let P=$.toLowerCase();if(P===""||!P.startsWith("0x"))return;let N=await VF({address:$,chain:F,id:1,methodHex:"0x95d89b41"}).catch((x)=>{return console.warn(`Could not fetch symbol for ${$} on ${F}: ${x.message}`),{result:""}});return await U$(N.result)}function OF({chain:F,address:$}){let{baseDecimal:P}=p(F),N={decimals:P,ticker:void 0};return PF(F).with(...X$,async()=>{try{let{isAddress:R,getAddress:x}=await import("ethers");if(!R(x($.replace(/^0X/,"0x"))))return N;let[A,T]=await Promise.all([w$({address:$,chain:F}),W$({address:$,chain:F})]);return{decimals:T,ticker:A}}catch(R){return console.warn(`Failed to fetch token info for ${$} on ${F}: ${R?.code} ${R?.message}`),N}}).with(G.Solana,async()=>{if(!$)return N;try{let R=await fetch(`https://lite-api.jup.ag/tokens/v2/search?query=${$}`);if(R.ok){let x=await R.json(),A=Array.isArray(x)?x[0]:x;if(A)return{decimals:A.decimals??P,ticker:A.symbol||void 0}}}catch(R){console.warn(`Failed to fetch Solana token info for ${$}: ${R?.code} ${R?.message}`)}return N}).with(G.Tron,async()=>{if(!$)return N;try{let R=await import("tronweb"),x=R.TronWeb??R.default?.TronWeb,A=await n(G.Tron),B=await new x({fullHost:A,privateKey:"0000000000000000000000000000000000000000000000000000000000000001"}).contract().at($),[Q,z]=await Promise.all([B.symbol().call().catch((M)=>{console.warn(`Could not fetch symbol for ${$} on Tron:`,M);return}),B.decimals().call().catch((M)=>{return console.warn(`Could not fetch decimals for ${$} on Tron:`,M),P})]);return{decimals:typeof z==="number"?z:Number(z||P),ticker:Q||void 0}}catch(R){let x=R instanceof Error?R.message:String(R);return console.warn(`Failed to fetch Tron token info for ${$}: ${x}`),N}}).with(G.Near,async()=>{if(!$)return N;try{let{JsonRpcProvider:R}=await import("@near-js/providers"),x=await n(G.Near),T=await new R({url:x}).query({account_id:$,args_base64:Buffer.from("{}").toString("base64"),finality:"final",method_name:"ft_metadata",request_type:"call_function"}),B=JSON.parse(Buffer.from(T.result).toString());return{decimals:B?.decimals||P,ticker:B?.symbol}}catch(R){let x=R instanceof Error?R.message:String(R);return console.warn(`Failed to fetch Near token info for ${$}: ${x}`),N}}).with(G.Radix,async()=>{if(!$)return N;try{let[R,x]=await Promise.all([S$($),j$($)]);return{decimals:x,ticker:R}}catch(R){let x=R instanceof Error?R.message:String(R);return console.warn(`Failed to fetch Radix token info for ${$}: ${x}`),N}}).otherwise(async()=>N)}function vF({chain:F,symbol:$}){return PF(F).with(...kF,()=>$==="ETH").with(G.Avalanche,()=>$==="AVAX").with(G.Berachain,()=>$==="BERA").with(G.BinanceSmartChain,()=>$==="BNB").with(G.Gnosis,()=>$==="xDAI"||$==="XDAI").with(G.Monad,()=>$==="MON").with(G.XLayer,()=>$==="OKB").with(G.Maya,()=>$==="CACAO").with(G.Cosmos,()=>$==="ATOM").with(G.THORChain,()=>$==="RUNE").with(G.Tron,()=>$==="TRX").with(G.Radix,()=>`${F}.${$}`===NF(F).identifier).otherwise(()=>$===F)}var NF=(F)=>{let{baseDecimal:$}=p(F);return PF(F.toUpperCase()).with(...kF,(N)=>({decimal:$,identifier:`${N}.ETH`})).with(G.THORChain,(N)=>({decimal:$,identifier:`${N}.RUNE`})).with(G.Cosmos,(N)=>({decimal:$,identifier:`${N}.ATOM`})).with(G.Maya,(N)=>({decimal:10,identifier:`${N}.CACAO`})).with(G.BinanceSmartChain,(N)=>({decimal:$,identifier:`${N}.BNB`})).with(G.Monad,(N)=>({decimal:$,identifier:`${N}.MON`})).with(G.Avalanche,(N)=>({decimal:$,identifier:`${N}.AVAX`})).with(G.Gnosis,(N)=>({decimal:$,identifier:`${N}.xDAI`})).with(G.XLayer,(N)=>({decimal:$,identifier:`${N}.OKB`})).with(G.Berachain,(N)=>({decimal:$,identifier:`${N}.BERA`})).with(G.Tron,(N)=>({decimal:$,identifier:`${N}.TRX`})).with(G.Solana,G.Chainflip,G.Kujira,G.Ripple,G.Polkadot,G.Near,...Z$,(N)=>({decimal:$,identifier:`${N}.${N}`})).with(G.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(G.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(N)=>({decimal:6,identifier:N})).with("ETH.FLIP",()=>({decimal:p(G.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:p(G.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:p(G.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(N)=>({decimal:10,identifier:N})).with("MAYA.MAYA",(N)=>({decimal:4,identifier:N})).otherwise(()=>({decimal:$,identifier:F}))};function _F({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return PF(F).with(G.Radix,()=>$===G.Radix||`${F}.${$}`===NF(F).identifier).with(G.Arbitrum,G.Optimism,G.Base,G.Aurora,()=>$===G.Ethereum).with(G.Cosmos,()=>$==="ATOM").with(G.BinanceSmartChain,()=>$==="BNB").with(G.Maya,()=>$==="CACAO").with(G.Monad,()=>$==="MON").with(G.THORChain,()=>$==="RUNE").with(G.Tron,()=>$==="TRX").with(G.XLayer,()=>$==="OKB").otherwise(()=>$===F)?"Native":F}var RF=(F)=>{let[$,...P]=F.split("."),N=F.includes("/"),R=P.join("."),x=R?.split("-"),A=x?.length?x.length===1?x[0]:x.slice(0,-1).join("-"):void 0;return{chain:$,symbol:R,synth:N,ticker:A}};async function lP(F){let{loadTokenLists:$}=await import("./tokens.js"),P=await $();for(let N of Object.values(P))for(let{identifier:R,chain:x,...A}of N.tokens){if("identifier"in F&&R===F.identifier)return R;if("address"in A&&"chain"in F&&x===F.chain&&A.address&&A.address.toLowerCase()===F.contract.toLowerCase())return R}return}var DF=["TERRA",...w.get("chains")];function yF(F=""){let $=F.toUpperCase(),[P]=$.split(".");if(DF.includes(P))return!0;let[N]=$.split("/");if(DF.includes(N))return!0;throw new Y({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function aP(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}import{match as HF}from"ts-pattern";var t=8,g$=10;function b({value:F,bigIntDecimal:$=t,decimal:P=t}){if(P===0)return F.toString();let N=F<0n,R=F.toString().substring(N?1:0),x=P-(R.length-1);if(x>0)R="0".repeat(x)+R;let A=R.length-P,T=R.slice(-P);if(Number.parseInt(T[$]||"0",10)>=5){let Q=Number.parseInt(T[$-1]||"0",10);T=`${T.substring(0,$-1)}${Q+1}`}else T=T.substring(0,$);return`${N?"-":""}${R.slice(0,A)}.${T}`.replace(/\.?0*$/,"")}class O{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new O({decimal:$,value:b({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:P}){return O.fromBigInt(F.getBaseValue("bigint")*f(P)/f($),P)}constructor(F){let $=zF(F),P=typeof F==="object";this.decimal=P?F.decimal:void 0,this.decimalMultiplier=P&&"decimalMultiplier"in F?F.decimalMultiplier:f(Math.max(pF(AF($)),this.decimal||0)),this.#R($)}set(F){return new this.constructor({decimal:this.decimal,identifier:this.toString?.({includeSynthProtocol:!0}),value:F})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let P=i(this.decimalMultiplier),N=$!==void 0?$:this.decimal,R=N!==void 0?N:P;if(N!==void 0&&N<P){if(this.formatBigIntToSafeValue(this.bigIntValue,N)==="0"&&this.bigIntValue!==0n)R=P}let x=this.formatBigIntToSafeValue(this.bigIntValue,R);return HF(F).with("number",()=>Number(x)).with("string",()=>x).with("bigint",()=>{return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}).otherwise(()=>x)}getBaseValue(F,$){let P=this.decimalMultiplier/f($||this.decimal||t),N=k$(this.bigIntValue,P);return HF(F).with("number",()=>Number(N)).with("string",()=>N.toString()).otherwise(()=>N)}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let P=zF(F),N=AF(P);if(N==="0"||N==="undefined")return 0n;return this.#N(N,$)}toSignificant(F=6){let $=this.getValue("string"),[P="",N=""]=$.split("."),R=Number.parseInt(P,10)>0;if((R?P.length+N.length:N.length)<=F)return $;if(P.length>=F)return P.slice(0,F).padEnd(P.length,"0");if(R)return`${P}.${N.slice(0,F-P.length)}`;let A=Number.parseInt(N,10).toString(),T=A.slice(0,F),B=N.length-A.length;return`0.${T.padStart(B+T.length,"0")}`}toFixed(F=6){let $=this.getValue("string"),P=$.startsWith("-"),[N="0",R=""]=(P?$.slice(1):$).split("."),x=N==="0"&&Number.parseInt(R.slice(0,F),10)===0,A=P&&!x?"-":"";if(F===0){if(N==="0"&&!R)return"0";return R&&Number.parseInt(R[0]||"0",10)>=5?`${A}${BigInt(N)+1n}.0`:`${A}${N}.0`}if(!R)return`${A}${N}.${"0".repeat(F)}`;let T=R[F];if(!(T&&Number.parseInt(T,10)>=5))return`${A}${N}.${R.slice(0,F).padEnd(F,"0")}`;let Q=BigInt(R.slice(0,F).padEnd(F,"0"))+1n,z=10n**BigInt(F);if(Q>=z)return`${A}${BigInt(N)+1n}.${"0".repeat(F)}`;return`${A}${N}.${Q.toString().padStart(F,"0")}`}toAbbreviation(F=2){let $=this.getValue("string"),P=Number($),N=["","K","M","B","T","Q","Qi","S"],R=Math.floor(Math.log10(Math.abs(P))/3);if(R===0||!N[R])return $;return`${(P/10**(R*3)).toFixed(F)}${N[R]}`}toCurrency(F="$",{currencyPosition:$="start",decimal:P=2,decimalSeparator:N=".",thousandSeparator:R=",",trimTrailingZeros:x=!0}={}){let A=this.toFixed(P),T=$==="end",[B="0",Q=""]=A.split("."),z=B.replace(/\B(?=(\d{3})+(?!\d))/g,R),M=Q&&Number.parseInt(Q,10)>0,Z=M?`${z}${N}${Q}`:z,W=Z.length<100&&x&&M?Z.replace(/\.?0*$/,""):Z;return T?`${W}${F}`:`${F}${W}`}formatBigIntToSafeValue(F,$){let P=$||this.decimal||t,N=Math.max(P,i(this.decimalMultiplier));return b({bigIntDecimal:P,decimal:N,value:F})}#$(F,...$){let P=this.#P(this,...$),N=i(this.decimalMultiplier),x=Math.max(P,N)+g$,A=f(x),T=$.reduce((Q,z)=>{let M=this.getBigIntValue(z,x);return HF(F).with("add",()=>Q+M).with("sub",()=>Q-M).with("mul",()=>Q*M/A).with("div",()=>{if(M===0n)throw RangeError("Division by zero");return Q*A/M}).otherwise(()=>Q)},this.bigIntValue*A/this.decimalMultiplier),B=b({bigIntDecimal:x,decimal:x,value:T});return new this.constructor({decimal:this.decimal,decimalMultiplier:f(x),identifier:this.toString(),value:B})}#F(F,...$){let P=this.#P(this,...$),N=this.getBigIntValue($[0]||"0",P),R=this.getBigIntValue(this,P);return HF(F).with("gt",()=>R>N).with("gte",()=>R>=N).with("lt",()=>R<N).with("lte",()=>R<=N).with("eqValue",()=>R===N).otherwise(()=>!1)}#R(F){let $=AF(F)||"0";this.bigIntValue=this.#N($)}#P(...F){let $=F.map((P)=>{return typeof P==="object"?P.decimal||i(P.decimalMultiplier):pF(AF(P))}).filter(Boolean);return Math.max(...$,t)}#N(F,$){let P=$?f($):this.decimalMultiplier,N=i(P),[R="",x=""]=F.split(".");return BigInt(`${R}${x.padEnd(N,"0")}`)}}var I$=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function AF(F){let P=`${typeof F==="number"?I$.format(F):zF(F)}`.replaceAll(",",".").split(".");return P.length>1?`${P.slice(0,-1).join("")}.${P.at(-1)}`:P[0]||"0"}function pF(F){let $=F.split(".")[1]?.length||0;return Math.max($,t)}function zF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}function k$(F,$){if($===0n)throw Error("Cannot divide by zero");let P=$/2n;return F>=0n&&$>=0n||F<0n&&$<0n?(F+P)/$:(F-P)/$}function f(F){return 10n**BigInt(F)}function i(F){return Math.log10(Number.parseFloat(F.toString()))}var v=[L.Solana,L.Tron,L.Near,L.Sui],LF=[L.THORChain,L.Maya],c=new Map,GF=new Map,d=new Map,v$=3600000;function D$(F){let $=d.get(F);if($?.timestamp&&Date.now()-$.timestamp>v$){d.delete(F);return}return $}function y$(F,$){if(d.size>1000){let P=d.keys().next().value;if(P)d.delete(P)}d.set(F,{...$,timestamp:Date.now()})}class r extends O{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:P,chain:N,symbol:R,identifier:x}){super(typeof F==="object"?F:{decimal:$,value:F});let A=bF(x||`${N}.${R}`);this.type=_F(A),this.tax=P,this.chain=A.chain,this.ticker=A.ticker,this.symbol=A.symbol,this.address=A.address,this.isSynthetic=A.isSynthetic,this.isTradeAsset=A.isTradeAsset,this.isGasAsset=A.isGasAsset,this.chainId=xF(A.chain).chainId}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?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 F=this.symbol.replace(/\./g,"__");return`${this.chain}.${F}`}getIconUrl(){return c.get(this.toString())?.logoURI}eqAsset({chain:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let P=F.indexOf(".");if(P===-1)throw new Y({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let N=F.slice(0,P),R=F.slice(P+1),x=YF({chain:N,rest:R}).when(({rest:A})=>A.includes(".."),({chain:A,rest:T})=>`${A}.${T.replace(/\.\./g,"~")}`).when(({chain:A,rest:T})=>LF.includes(A)&&T.includes("."),({chain:A,rest:T})=>`${A}.${T.replace(/\./g,"/")}`).otherwise(({chain:A,rest:T})=>`${A}.${T.replace(/__/g,".")}`);return r.from({asset:x,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:P,...N}){let R=F instanceof O?F.getValue("string"):F,x=E$(N),A=!x.startsWith(L.Sui)&&x.includes(":");if(P&&A){let[s,k]=x.split(":");return f$({address:k,chain:s,fromBaseDecimal:$,parsedValue:R})}let T=A?x.split(":").join(".UNKNOWN-"):x,{identifier:B,decimal:Q}=NF(T),{chain:z,isSynthetic:M,isTradeAsset:Z,address:q}=bF(B),{baseDecimal:W}=xF(z),D=c.get(v.includes(z)?B:B.toUpperCase());if(!D&&P&&!M&&!Z)return(async()=>{let{ticker:s}=RF(B),k=await EF({address:q,chain:z,ticker:s});return KF({decimal:k.decimals,identifier:k.identifier,value:$?l(BigInt(R),$):R})})();let E=D?.decimal||Q;V({condition:!E&&!P,id:`assetValue_static_decimal_not_found_${z}`,warning:`Couldn't find static decimal for one or more tokens on ${z} (Using default ${W} 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:I,identifier:U,tax:u}=D||{decimal:E||W,identifier:B},a=$?l(BigInt(R),$):l(R,I);return M||Z?p$(U,a):KF({decimal:I,identifier:U,tax:u,value:a})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),P=await $(F);for(let{tokens:N}of Object.values(P))for(let{identifier:R,chain:x,...A}of N){let T=xF(x),B=v.includes(T.chain)?R:R.toUpperCase(),z={decimal:"decimals"in A?A.decimals:T.baseDecimal,identifier:R,logoURI:"logoURI"in A?A.logoURI:void 0,tax:"tax"in A?A.tax:void 0};if(c.set(B,z),"address"in A&&A.address){let M=v.includes(T.chain)?`${T.chain}:${A.address}`:`${T.chain}:${A.address.toUpperCase()}`;GF.set(M,R)}}return!0}static setStaticAssets(F){c.clear(),GF.clear();for(let[$,P]of F.entries()){let N=v.includes(P.chain)?P.identifier:P.identifier.toUpperCase(),R="decimals"in P?P.decimals:P.decimal,x={...P,decimal:R,identifier:N};if(c.set($,x),P.address){let A=v.includes(P.chain)?`${P.chain}:${P.address}`:`${P.chain}:${P.address.toUpperCase()}`;GF.set(A,P.identifier)}}return!0}static get staticAssets(){return c}}function BN(F){let $=r.from({chain:F});return YF(F).with(L.Bitcoin,L.Litecoin,L.BitcoinCash,L.Dash,()=>$.set(0.00010001)).with(L.Dogecoin,()=>$.set(1.00000001)).with(L.Avalanche,L.Ethereum,L.Arbitrum,L.BinanceSmartChain,()=>$.set(0.00000001)).with(L.THORChain,L.Maya,()=>$.set(0)).with(L.Cosmos,L.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function EF({chain:F,address:$,ticker:P}){let R=v.includes(F)?`${F}:${$||P}`:`${F}:${$||P}`.toUpperCase(),x=D$(R);if(x)return x;if(!$){let{baseDecimal:B}=xF(F);return{decimals:B,identifier:`${F}.${P||"UNKNOWN"}`}}let A=await OF({address:$,chain:F}),T=`${F}.${A.ticker||P||"UNKNOWN"}-${$}`;return V({condition:!!(!A.ticker&&P),id:`async_token_lookup_failed_${F}_${$}`,warning:`Could not fetch token metadata for ${F}:${$} from chain. Using user-provided ticker (${P}) with baseDecimal (${A.decimals}).`}),A.ticker&&y$(R,{decimals:A.decimals,identifier:T}),{decimals:A.decimals,identifier:T}}function KF({identifier:F,decimal:$,value:P,tax:N}){return yF(F),new r({decimal:$,identifier:F,tax:N,value:l(P,$)})}function p$(F,$=0){let P=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,N=P?LF.includes(P):!1,R=F.slice(0,14).includes("~")?"~":"/",[x,A]=N?F.split(".").slice(1).join().split(R):F.split(R);if(!(x&&A))throw new Y({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new r({decimal:8,identifier:`${P||L.THORChain}.${x}${R}${A}`,value:l($,8)})}async function f$({address:F,chain:$,fromBaseDecimal:P,parsedValue:N}){let{decimals:R,identifier:x}=await EF({address:F,chain:$}),A=P?l(BigInt(N),P):N;return KF({decimal:R,identifier:x,value:A})}function l(F,$){return typeof F==="bigint"?b({bigIntDecimal:$,decimal:$,value:F}):F}function b$(F){let $=YF(F).when((P)=>("chain"in P)&&P.chain!==void 0,({chain:P})=>P).otherwise((P)=>{let N=RF(P.asset);return N.synth?L.THORChain:N.chain});if(!V$.includes($.toUpperCase()))throw new Y({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function E$(F){if(b$(F),"chain"in F){let{chain:R,address:x}=F;if(x){let A=v.includes(R)?`${R}:${x}`:`${R}:${x.toUpperCase()}`,T=GF.get(A);if(T)return T;return A}return R}let{chain:$,symbol:P}=RF(F.asset);return _F({chain:$,symbol:P})==="Native"?$:F.asset}function u$(F,$,P){let N=F.split("."),R=N[0]?.toUpperCase(),x=LF.includes(R),A=P?"~":"/",[T,B=""]=x?N.slice(1).join(".").split(A):F.split(A);if(!(T&&B))throw new Y({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:Q,address:z}=uF({chain:T,symbol:B}),M=`${T}${A}${B}`;return{address:z,chain:R,isGasAsset:!1,isSynthetic:$,isTradeAsset:P,symbol:M,ticker:Q}}function C$(F){let $=F.indexOf("."),P=($===-1?F:F.slice(0,$)).toUpperCase(),N=$===-1?F:F.slice($+1),{address:R,ticker:x}=uF({chain:P,symbol:N}),A;try{A=R&&O$.includes(P)&&fF(R)?fF(R):R}catch{A=R}let T=A?`${x}-${A}`:N;return{address:A,chain:P,isGasAsset:vF({chain:P,symbol:N}),isSynthetic:!1,isTradeAsset:!1,symbol:T,ticker:x}}function bF(F){let $=F.slice(0,14),P=$.includes("/"),N=$.includes("~");if(P||N)return u$(F,P,N);return C$(F)}function o$(F,$=!1){let P=$?F.indexOf("-"):F.lastIndexOf("-");if(P===-1)return{address:void 0,ticker:F};let N=F.slice(0,P);return{address:F.slice(P+1),ticker:N}}function uF({symbol:F,chain:$}){let{ticker:P,address:N}=o$(F,$===L.Near);return{address:N&&!v.includes($)?N.toLowerCase():N,ticker:P}}var n$={average:1,fast:1.5,fastest:2};function CF(F="average"){let $=w.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return n$[F]}function m$(F="average"){let $=CF(F),P=10n,N=BigInt(Math.round($*10));return{denominator:P,numerator:N}}function zN(F,$="average"){let{numerator:P,denominator:N}=m$($);return F*P/N}function KN(F,$="average",P=!1){let N=CF($),R=F*N;return P?Math.floor(R):R}class g extends O{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new g({decimal:$,value:b({bigIntDecimal:$,decimal:$,value:F})})}}import{Chain as oF,EVMChains as h$}from"@swapkit/types";function JF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[P,N,R,,x]=F;return[P,N,R,$.change,x]}if("account"in $){let[P,N,,R,x]=F;return[P,N,$.account,R,x]}return F}function t$([F,$,P,N,R]){let x=typeof R!=="number";if(typeof N!=="number")return`m/${F}'/${$}'/${P}'`;return`m/${F}'/${$}'/${P}'/${N}${x?"":`/${R}`}`}function jN({chain:F,index:$,addressIndex:P=0,type:N}){if(h$.includes(F)){if(N&&["legacy","account"].includes(N))return[44,60,0,$];if(N==="ledgerLive")return[44,60,$,0,P];return JF(C[F],{index:$})}if(F===oF.Solana){if(N==="account")return[44,501,0,$];return JF(C[F],{index:$})}let R=F===oF.Litecoin?2:0;switch(N){case"nativeSegwitMiddleAccount":return[84,R,$,0,P];case"segwit":return[49,R,0,0,$];case"legacy":return[44,R,0,0,$];default:return JF(C[F],{index:$})}}function SN(F){let[$,P,N]=F.split("/").map((R)=>Number.parseInt(R,10));switch(P){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var UN=Object.keys(C).reduce((F,$)=>{return F[$]=t$(C[$]),F},{});import{Chain as S,CosmosChains as c$,EVMChains as d$,getChainConfig as nF,SubstrateChains as l$,UTXOChains as s$}from"@swapkit/types";import{match as mF}from"ts-pattern";function gN({chain:F,txHash:$}){let{explorerUrl:P}=nF(F);return mF(F).with(...c$,S.Solana,()=>`${P}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(...d$,...l$,()=>`${P}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(...s$,S.Radix,S.Tron,()=>`${P}/transaction/${$.toLowerCase()}`).with(S.Near,()=>`${P}/txns/${$}`).with(S.Ripple,()=>`${P}/transactions/${$}`).with(S.Sui,()=>`${P}/txblock/${$}`).with(S.Cardano,S.Ton,()=>`${P}/tx/${$}`).otherwise(()=>"")}function IN({chain:F,address:$}){let{explorerUrl:P}=nF(F);return mF(F).with(S.Solana,S.Sui,S.Radix,()=>`${P}/account/${$}`).otherwise(()=>`${P}/address/${$}`)}import{Chain as i$,getChainConfig as r$}from"@swapkit/types";function a$({liquidityUnits:F,poolUnits:$,runeDepth:P}){let N=J(F),R=J($),x=J(P),A=N.mul(x),T=R.mul(R).mul(2),B=R.mul(N).mul(2),Q=N.mul(N),z=R.mul(R).mul(R);return A.mul(T.sub(B).add(Q)).div(z)}function e$({liquidityUnits:F,poolUnits:$,assetDepth:P}){let N=J(F),R=J($),x=J(P),A=N.mul(x),T=R.mul(R).mul(2),B=R.mul(N).mul(2),Q=N.mul(N),z=A.mul(T.sub(B).add(Q)),M=R.mul(R).mul(R);return z.div(M)}function vN({percent:F,runeDepth:$,liquidityUnits:P,poolUnits:N}){return a$({liquidityUnits:P,poolUnits:N,runeDepth:$}).mul(F)}function DN({percent:F,assetDepth:$,liquidityUnits:P,poolUnits:N}){return e$({assetDepth:$,liquidityUnits:P,poolUnits:N}).mul(F)}function J(F){return g.fromBigInt(BigInt(F),r$(i$.THORChain).baseDecimal)}function FP({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N}){return{assetAmount:J(N).mul(F).div($),runeAmount:J(P).mul(F).div($)}}function yN({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N,percent:R}){return Object.fromEntries(Object.entries(FP({assetDepth:N,liquidityUnits:F,poolUnits:$,runeDepth:P})).map(([x,A])=>[x,A.mul(R)]))}function pN({runeDepth:F,poolUnits:$,assetDepth:P,liquidityUnits:N,runeAmount:R,assetAmount:x}){let A=new g({decimal:8,value:F}),T=new g({decimal:8,value:P}),B=new g({decimal:8,value:$}),Q=new g({decimal:8,value:R}),z=new g({decimal:8,value:x}),M=Q.mul(T),Z=z.mul(A),q=Q.mul(z),W=A.mul(T),D=B.mul(M.add(Z.add(q.mul(2)))),E=M.add(Z.add(W.mul(2))),I=D.div(E),U=J(N).add(I);if(I.getBaseValue("number")===0)return U.div(B).getBaseValue("number");let u=B.add(U);return U.div(u).getBaseValue("number")}function fN({runeAmount:F,assetAmount:$,runeDepth:P,assetDepth:N}){if(F==="0"||$==="0"||P==="0"||N==="0")return 0;let R=J(P),x=J(N),A=J($),T=J(F),B=A.mul(R).sub(x.mul(T)),Q=x.mul(T).add(R.mul(x));return Math.abs(B.div(Q).getBaseValue("number"))}import{Chain as TF}from"@swapkit/types";import{match as $P}from"ts-pattern";function oN({type:F,address:$}){return`${F}:${$}`}function nN({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function mN(F){return BF("POOL+",F)}function hN({chain:F,symbol:$,address:P,...N}){let R=PP({chain:F,symbol:$}),x=P?`:${P}:`:":";return BF(`${"+"}:${R}${x}`,N)}function tN({chain:F,symbol:$,ticker:P,basisPoints:N,targetAsset:R}){let x=F==="ETH"&&P!=="ETH"?`${P}-${$.slice(-3)}`:$,A=R?`:${R}`:"";return`${"-"}:${F}.${x}:${N}${A}`}function cN({basisPoints:F,...$}){return BF(`${"POOL-"}:${F}`,$)}function dN({name:F,chain:$,address:P,owner:N}){let R=`${"~"}:${F}:${$}:${P}`,x=N?`:${N}`:"";return`${R}${x}`}function lN({name:F,chain:$,asset:P,payout:N,owner:R}){return`${"~"}:${F}:${$}:${N}:${R}:${P}`}function sN(F,{address:$}){return`${F}:${$}`}function iN(F,{unstakeBps:$,...P}){let N=$?`:${$}`:"",R=`${F}${N}`;return BF(`${R}`,P)}function BF(F,{affiliateAddress:$,affiliateBasisPoints:P}={}){let N=`${F}${$?`:${$}:${P||0}`:""}`;return N.endsWith(":")?N.slice(0,-1):N}function PP({chain:F,symbol:$}){return $P(F).with(TF.Bitcoin,TF.Dogecoin,TF.Litecoin,()=>F.slice(0,1).toLowerCase()).with(TF.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}import{getChainConfig as hF}from"@swapkit/types";function PR(){return typeof window.ethereum<"u"}function NR(F){return NP().includes(F)}function NP(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.ctrl||window?.ethereum?.__XDEFI,P=window?.vultisig,N=window?.ethereum?.isBraveWallet,R=window?.ethereum?.isTrust||window?.trustwallet,x=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,T=window?.$onekey?.ethereum,B=[];if(F)B.push("METAMASK");if($)B.push("CTRL");if(P)B.push("VULTISIG");if(N)B.push("BRAVE");if(R)B.push("TRUSTWALLET_WEB");if(x)B.push("COINBASE_WEB");if(xP())B.push("OKX_MOBILE");if(A)B.push("BITGET");if(T)B.push("ONEKEY");return B}async function RP(F,$,P){let N=hF($);try{await tF({method:"wallet_switchEthereumChain",params:[{chainId:N.chainIdHex}],provider:F})}catch(R){if(!P)throw new Y("helpers_failed_to_switch_network",{error:R,reason:"networkParams not provided"});await AP(F,P)}}function RR({chains:F,supportedChains:$,walletType:P}){let N=F.filter((x)=>!x||$.includes(x));if(N.length===0)throw new Y("wallet_chain_not_supported",{chain:F.join(", "),wallet:P});let R=F.filter((x)=>!$.includes(x));return V({condition:R.length>0,id:`wallet_chain_not_supported_${P}`,warning:`${P} wallet does not support the following chains: ${R.join(", ")}. These chains will be ignored.`}),N}function HP(F,$,P){return async(...N)=>{let{chainIdHex:R}=hF(P);if((await $.getNetwork()).chainId.toString()===R)return F(...N);try{await RP($,P)}catch(x){throw new Y({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return F(...N)}}function HR({toolbox:F,chain:$,provider:P=window.ethereum,methodNames:N=[]}){let x=[...N,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((A,T)=>{if(!F[T])return A;let B=F[T];if(typeof B!=="function")return A;let Q=HP(B,P,$);return{...A,[T]:Q}},{});return{...F,...x}}function AP(F,$){return tF({method:"wallet_addEthereumChain",params:[$],provider:F})}function AR(F){window.ethereum?.on("accountsChanged",()=>F()),window.ctrl?.ethereum.on("accountsChanged",()=>F())}function xR(){let{isTrust:F,isBraveWallet:$,__XDEFI:P,overrideIsMetaMask:N,selectedProvider:R}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(N&&R?.isCoinbaseWallet)return"COINBASE_WEB";if(P)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function GR(){let F=[];function $(N){if(F.map((R)=>R.info.uuid).includes(N.detail.info.uuid))return;F.push(N.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function P(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:P}}function xP(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),P=/android|XiaoMi|MiuiBrowser/i.test(F),N=$||P,R=/OKApp/i.test(F);return N&&R}function tF({provider:F,params:$,method:P}){if(!F?.send)throw new Y("helpers_not_found_provider");let N=$?Array.isArray($)?$:[$]:[];return F.send(P,N)}export{DP as wrapWithThrow,HP as wrapMethodWithNetworkSwitch,V as warnOnce,aP as validateTNS,yF as validateIdentifier,X as useSwapKitStore,UP as useSwapKitConfig,JF as updateDerivationPath,RP as switchEVMWalletNetwork,tF as providerRequest,HR as prepareNetworkSwitch,xP as okxMobileEnabled,NP as listWeb3EVMWallets,PR as isWeb3Detected,vF as isGasAsset,NR as isDetected,oP as initializeRPCUrlsWithFallback,SN as getWalletFormatFor,OP as getTHORNameCost,yN as getSymmetricWithdraw,FP as getSymmetricPoolShare,n as getRPCUrl,BN as getMinAmountByChain,tN as getMemoForWithdraw,nN as getMemoForUnbond,iN as getMemoForTcyStake,sN as getMemoForTcyClaim,cN as getMemoForRunePoolWithdraw,mN as getMemoForRunePoolDeposit,dN as getMemoForNameRegister,lN as getMemoForNamePreferredAssetRegister,oN as getMemoForLeaveAndBond,hN as getMemoForDeposit,vP as getMAYANameCost,fN as getLiquiditySlippage,m$ as getFeeMultiplierAsBigInt,CF as getFeeMultiplier,gN as getExplorerTxUrl,IN as getExplorerAddressUrl,pN as getEstimatedPoolShare,xR as getETHDefaultWallet,GR as getEIP6963Wallets,jN as getDerivationPathFor,NF as getCommonAssetInfo,yP as getChainIdentifier,vN as getAsymmetricRuneWithdrawAmount,a$ as getAsymmetricRuneShare,DN as getAsymmetricAssetWithdrawAmount,e$ as getAsymmetricAssetShare,_F as getAssetType,b as formatBigIntToSafeValue,lP as findAssetBy,RR as filterSupportedChains,OF as fetchTokenInfo,t$ as derivationPathToString,RF as assetFromString,zN as applyFeeMultiplierToBigInt,KN as applyFeeMultiplier,AP as addEVMWalletNetwork,AR as addAccountsChangedCallback,sF as WarningCodeEnum,FF as WalletOption,g as SwapKitNumber,Y as SwapKitError,w as SKConfig,o as RequestClient,iF as ProviderName,C as NetworkDerivationPath,SF as MemoType,eF as LedgerErrorCode,rF as FeeTypeEnum,jF as FeeOption,lF as ErrorCode,UN as DerivationPath,n$ as DEFAULT_FEE_MULTIPLIERS,dP as CommonAssetStrings,O as BigIntArithmetics,r as AssetValue,aF as ApproveMode};
|
|
5
|
-
|
|
6
|
-
//# debugId=B662814C92109C1E64756E2164756E21
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{$ as WB,A as df,Aa as dB,B as of,Ba as oB,C as sf,Ca as sB,D as lf,Da as lB,E as nf,Ea as nB,F as pf,Fa as pB,G as tf,Ga as iB,H as af,Ha as tB,I as ef,Ia as aB,J as $B,Ja as eB,K as fB,Ka as $R,L as BB,La as fR,M as RB,Ma as BR,N as Q,Na as RR,O as gB,Oa as gR,P as xB,Pa as xR,Q as MB,Qa as MR,R as YB,Ra as YR,S as GB,T as zB,U as JB,V as LB,W as QB,X as XB,Y as ZB,Z as _B,_ as PB,a as Z,aa as jB,b as qf,ba as CB,c as Tf,ca as HB,d as Sf,da as VB,e as Af,ea as FB,f as m,fa as EB,g as Kf,ga as IB,h as t,ha as NB,i as $$,ia as qB,j as Uf,ja as TB,k as S,ka as SB,l as Df,la as AB,m as P,ma as KB,n as W,na as UB,o as Of,oa as DB,p as kf,pa as OB,q as yf,qa as kB,r as bf,ra as yB,s as mf,sa as bB,t as A,ta as mB,u as vf,ua as vB,v as wf,va as wB,w as cf,wa as cB,x as rf,xa as rB,y as hf,ya as hB,z as uf,za as uB}from"./chunk-57tjgeg1.js";export*from"@swapkit/tokens";export*from"@swapkit/types";var v={average:1,fast:1.5,fastest:2};function I($="average"){let f=P.get("feeMultipliers");if(f&&f[$]!==void 0)return f[$];return v[$]}function w($="average"){let f=I($),B=10n,R=BigInt(Math.round(f*10));return{denominator:B,numerator:R}}function G$($,f="average"){let{numerator:B,denominator:R}=w(f);return $*B/R}function z$($,f="average",B=!1){let R=I(f),g=$*R;return B?Math.floor(g):g}import{Chain as N,EVMChains as c}from"@swapkit/types";function V($,f){if("index"in f)return[...$.slice(0,$.length-1),f.index];if("change"in f){let[B,R,g,,x]=$;return[B,R,g,f.change,x]}if("account"in f){let[B,R,,g,x]=$;return[B,R,f.account,g,x]}return $}function r([$,f,B,R,g],{allHardened:x}={}){let Y=x?"'":"",G=typeof g!=="number";if(typeof R!=="number")return`m/${$}'/${f}'/${B}'`;return`m/${$}'/${f}'/${B}'/${R}${Y}${G?"":`/${g}${Y}`}`}function X$({chain:$,index:f,addressIndex:B=0,type:R}){if(c.includes($)){if(R&&["legacy","account"].includes(R))return[44,60,0,f];if(R==="ledgerLive")return[44,60,f,0,B];return V(Z[$],{index:f})}if($===N.Solana){if(R==="account")return[44,501,0,f];return V(Z[$],{index:f})}let g=$===N.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,g,f,0,B];case"segwit":return[49,g,0,0,f];case"legacy":return[44,g,0,0,f];default:return V(Z[$],{index:f})}}function Z$($){let[f,B,R]=$.split("/").map((g)=>Number.parseInt(g,10));switch(B){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var _$=Object.keys(Z).reduce(($,f)=>{return $[f]=r(Z[f]),$},{});import{Chain as J,CosmosChains as h,EVMChains as u,getChainConfig as q,SubstrateChains as d,UTXOChains as o}from"@swapkit/types";import{match as T}from"ts-pattern";function C$({chain:$,txHash:f}){let{explorerUrl:B}=q($);return T($).with(...h,J.Solana,()=>`${B}/tx/${f.startsWith("0x")?f.slice(2):f}`).with(...u,...d,()=>`${B}/tx/${f.startsWith("0x")?f:`0x${f}`}`).with(...o,J.Radix,J.Tron,()=>`${B}/transaction/${f.toLowerCase()}`).with(J.Near,()=>`${B}/txns/${f}`).with(J.Ripple,()=>`${B}/transactions/${f}`).with(J.Sui,()=>`${B}/txblock/${f}`).with(J.Cardano,J.Ton,()=>`${B}/tx/${f}`).otherwise(()=>"")}function H$({chain:$,address:f}){let{explorerUrl:B}=q($);return T($).with(J.Solana,J.Sui,J.Radix,()=>`${B}/account/${f}`).otherwise(()=>`${B}/address/${f}`)}import{Chain as s,getChainConfig as l}from"@swapkit/types";function n({liquidityUnits:$,poolUnits:f,runeDepth:B}){let R=z($),g=z(f),x=z(B),Y=R.mul(x),G=g.mul(g).mul(2),M=g.mul(R).mul(2),L=R.mul(R),X=g.mul(g).mul(g);return Y.mul(G.sub(M).add(L)).div(X)}function p({liquidityUnits:$,poolUnits:f,assetDepth:B}){let R=z($),g=z(f),x=z(B),Y=R.mul(x),G=g.mul(g).mul(2),M=g.mul(R).mul(2),L=R.mul(R),X=Y.mul(G.sub(M).add(L)),_=g.mul(g).mul(g);return X.div(_)}function I$({percent:$,runeDepth:f,liquidityUnits:B,poolUnits:R}){return n({liquidityUnits:B,poolUnits:R,runeDepth:f}).mul($)}function N$({percent:$,assetDepth:f,liquidityUnits:B,poolUnits:R}){return p({assetDepth:f,liquidityUnits:B,poolUnits:R}).mul($)}function z($){return Q.fromBigInt(BigInt($),l(s.THORChain).baseDecimal)}function i({liquidityUnits:$,poolUnits:f,runeDepth:B,assetDepth:R}){return{assetAmount:z(R).mul($).div(f),runeAmount:z(B).mul($).div(f)}}function q$({liquidityUnits:$,poolUnits:f,runeDepth:B,assetDepth:R,percent:g}){return Object.fromEntries(Object.entries(i({assetDepth:R,liquidityUnits:$,poolUnits:f,runeDepth:B})).map(([x,Y])=>[x,Y.mul(g)]))}function T$({runeDepth:$,poolUnits:f,assetDepth:B,liquidityUnits:R,runeAmount:g,assetAmount:x}){let Y=new Q({decimal:8,value:$}),G=new Q({decimal:8,value:B}),M=new Q({decimal:8,value:f}),L=new Q({decimal:8,value:g}),X=new Q({decimal:8,value:x}),_=L.mul(G),F=X.mul(Y),D=L.mul(X),O=Y.mul(G),k=M.mul(_.add(F.add(D.mul(2)))),y=_.add(F.add(O.mul(2))),E=k.div(y),H=z(R).add(E);if(E.getBaseValue("number")===0)return H.div(M).getBaseValue("number");let b=M.add(H);return H.div(b).getBaseValue("number")}function S$({runeAmount:$,assetAmount:f,runeDepth:B,assetDepth:R}){if($==="0"||f==="0"||B==="0"||R==="0")return 0;let g=z(B),x=z(R),Y=z(f),G=z($),M=Y.mul(g).sub(x.mul(G)),L=x.mul(G).add(g.mul(x));return Math.abs(M.div(L).getBaseValue("number"))}import{Chain as j}from"@swapkit/types";import{match as a}from"ts-pattern";function O$({type:$,address:f}){return`${$}:${f}`}function k$({address:$,unbondAmount:f}){return`${"UNBOND"}:${$}:${f}`}function y$($){return C("POOL+",$)}function b$({chain:$,symbol:f,address:B,...R}){let g=e({chain:$,symbol:f}),x=B?`:${B}:`:":";return C(`${"+"}:${g}${x}`,R)}function m$({chain:$,symbol:f,ticker:B,basisPoints:R,targetAsset:g}){let x=$==="ETH"&&B!=="ETH"?`${B}-${f.slice(-3)}`:f,Y=g?`:${g}`:"";return`${"-"}:${$}.${x}:${R}${Y}`}function v$({basisPoints:$,...f}){return C(`${"POOL-"}:${$}`,f)}function w$({name:$,chain:f,address:B,owner:R}){let g=`${"~"}:${$}:${f}:${B}`,x=R?`:${R}`:"";return`${g}${x}`}function c$({name:$,chain:f,asset:B,payout:R,owner:g}){return`${"~"}:${$}:${f}:${R}:${g}:${B}`}function r$($,{address:f}){return`${$}:${f}`}function h$($,{unstakeBps:f,...B}){let R=f?`:${f}`:"",g=`${$}${R}`;return C(`${g}`,B)}function C($,{affiliateAddress:f,affiliateBasisPoints:B}={}){let R=`${$}${f?`:${f}:${B||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function e({chain:$,symbol:f}){return a($).with(j.Bitcoin,j.Dogecoin,j.Litecoin,()=>$.slice(0,1).toLowerCase()).with(j.BitcoinCash,()=>"c").otherwise(()=>`${$}.${f}`)}import{getChainConfig as K}from"@swapkit/types";function p$(){return typeof window.ethereum<"u"}function i$($){return f$().includes($)}function f$(){let $=window?.ethereum&&!window.ethereum?.isBraveWallet,f=window?.ctrl||window?.ethereum?.__XDEFI,B=window?.vultisig,R=window?.ethereum?.isBraveWallet,g=window?.ethereum?.isTrust||window?.trustwallet,x=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,Y=window?.bitkeep?.ethereum,G=window?.$onekey?.ethereum,M=[];if($)M.push("METAMASK");if(f)M.push("CTRL");if(B)M.push("VULTISIG");if(R)M.push("BRAVE");if(g)M.push("TRUSTWALLET_WEB");if(x)M.push("COINBASE_WEB");if(x$())M.push("OKX_MOBILE");if(Y)M.push("BITGET");if(G)M.push("ONEKEY");return M}async function B$($,f,B){let R=K(f);try{await U({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:$})}catch(g){if(!B)throw new W("helpers_failed_to_switch_network",{error:g,reason:"networkParams not provided"});await g$($,B)}}function t$({chains:$,supportedChains:f,walletType:B}){let R=$.filter((x)=>!x||f.includes(x));if(R.length===0)throw new W("wallet_chain_not_supported",{chain:$.join(", "),wallet:B});let g=$.filter((x)=>!f.includes(x));return A({condition:g.length>0,id:`wallet_chain_not_supported_${B}`,warning:`${B} wallet does not support the following chains: ${g.join(", ")}. These chains will be ignored.`}),R}function R$($,f,B){return async(...R)=>{let{chainIdHex:g}=K(B);if((await f.getNetwork()).chainId.toString()===g)return $(...R);try{await B$(f,B)}catch(x){throw new W({errorKey:"helpers_failed_to_switch_network",info:{error:x}})}return $(...R)}}function a$({toolbox:$,chain:f,provider:B=window.ethereum,methodNames:R=[]}){let x=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((Y,G)=>{if(!$[G])return Y;let M=$[G];if(typeof M!=="function")return Y;let L=R$(M,B,f);return{...Y,[G]:L}},{});return{...$,...x}}function g$($,f){return U({method:"wallet_addEthereumChain",params:[f],provider:$})}function e$($){window.ethereum?.on("accountsChanged",()=>$()),window.ctrl?.ethereum.on("accountsChanged",()=>$())}function $f(){let{isTrust:$,isBraveWallet:f,__XDEFI:B,overrideIsMetaMask:R,selectedProvider:g}=window?.ethereum||{};if($)return"TRUSTWALLET_WEB";if(f)return"BRAVE";if(R&&g?.isCoinbaseWallet)return"COINBASE_WEB";if(B)return"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function ff(){let $=[];function f(R){if($.map((g)=>g.info.uuid).includes(R.detail.info.uuid))return;$.push(R.detail)}window.addEventListener("eip6963:announceProvider",f),window.dispatchEvent(new Event("eip6963:requestProvider"));function B(){window.removeEventListener("eip6963:announceProvider",f)}return{providers:$,removeEIP6963EventListener:B}}function x$(){let $=navigator.userAgent,f=/iphone|ipad|ipod|ios/i.test($),B=/android|XiaoMi|MiuiBrowser/i.test($),R=f||B,g=/OKApp/i.test($);return R&&g}function U({provider:$,params:f,method:B}){if(!$?.send)throw new W("helpers_not_found_provider");let R=f?Array.isArray(f)?f:[f]:[];return $.send(B,R)}function Bf($,f){if(!P.get("v3SwapFlow")?.enabled)return!1;return S[f]?.includes($)??!1}export{bf as wrapWithThrow,R$ as wrapMethodWithNetworkSwitch,A as warnOnce,ef as validateTNS,af as validateIdentifier,V as updateDerivationPath,B$ as switchEVMWalletNetwork,Df as swapKitConfigStore,Bf as supportsV3SwapFlow,gB as signWidgetRequest,U as providerRequest,a$ as prepareNetworkSwitch,nf as parseSymbolForAddress,x$ as okxMobileEnabled,f$ as listWeb3EVMWallets,p$ as isWeb3Detected,df as isGasAsset,i$ as isDetected,rf as initializeRPCUrlsWithFallback,Z$ as getWalletFormatFor,pf as getTokenLogoURI,kf as getTHORNameCost,q$ as getSymmetricWithdraw,i as getSymmetricPoolShare,wf as getRPCUrlSync,cf as getRPCUrl,RB as getMinAmountByChain,m$ as getMemoForWithdraw,k$ as getMemoForUnbond,h$ as getMemoForTcyStake,r$ as getMemoForTcyClaim,v$ as getMemoForRunePoolWithdraw,y$ as getMemoForRunePoolDeposit,w$ as getMemoForNameRegister,c$ as getMemoForNamePreferredAssetRegister,O$ as getMemoForLeaveAndBond,b$ as getMemoForDeposit,yf as getMAYANameCost,S$ as getLiquiditySlippage,w as getFeeMultiplierAsBigInt,I as getFeeMultiplier,C$ as getExplorerTxUrl,H$ as getExplorerAddressUrl,T$ as getEstimatedPoolShare,$f as getETHDefaultWallet,ff as getEIP6963Wallets,X$ as getDerivationPathFor,of as getCommonAssetInfo,mf as getChainIdentifier,I$ as getAsymmetricRuneWithdrawAmount,n as getAsymmetricRuneShare,N$ as getAsymmetricAssetWithdrawAmount,p as getAsymmetricAssetShare,sf as getAssetType,$B as formatBigIntToSafeValue,tf as findAssetBy,t$ as filterSupportedChains,uf as fetchTokenInfo,r as derivationPathToString,lf as assetFromString,G$ as applyFeeMultiplierToBigInt,z$ as applyFeeMultiplier,g$ as addEVMWalletNetwork,e$ as addAccountsChangedCallback,vf as _rpcCache,Tf as WarningCodeEnum,$$ as WalletOption,S as V3SwapFlowSupport,YB as TxnType,zB as TxnStatus,OB as TronTransactionSchema,SB as TransactionSchema,AB as TransactionDTOSchema,JB as TrackingStatus,QB as TrackingRequestSchema,XB as TrackingRequestQuerySchema,TB as TrackerResponseSchema,LB as TokenSchema,WB as TokenDetailsMetadataSchema,vB as TONTransactionSchema,BR as SwapToResponseSchema,$R as SwapToRequestSchema,fR as SwapToAssetSchema,MR as SwapRouteV2ResponseSchema,Q as SwapKitNumber,W as SwapKitError,YR as SwapKitApi,mB as StarknetTransactionSchema,P as SKConfig,oB as RouteQuoteWarningSchema,MB as RouteQuoteTxType,gR as RouteQuoteProviderErrorSchema,dB as RouteQuoteMetadataV2Schema,uB as RouteQuoteMetadataSchema,rB as RouteQuoteMetadataAssetSchema,cB as RouteLegWithoutAddressesSchema,wB as RouteLegSchema,Of as RequestClient,eB as QuoteV3ResponseSchema,xR as QuoteV2ResponseSchema,RR as QuoteRouteV2Response,lB as QuoteResponseSchema,sB as QuoteResponseRouteItem,CB as QuoteRequestSchema,Sf as ProviderName,GB as ProviderAction,xB as PriorityLabel,jB as PriceResponseSchema,HB as PriceRequestSchema,Z as NetworkDerivationPath,qB as NearSwapResponseSchema,NB as NearDepositChannelResultSchema,IB as NearDepositChannelParamsSchema,t as MemoType,Uf as LedgerErrorCode,nB as GasSchema,pB as GasResponseSchema,KB as FeesSchema,Af as FeeTypeEnum,m as FeeOption,UB as EstimatedTimeSchema,qf as ErrorCode,DB as EVMTransactionSchema,yB as EVMTransactionDetailsSchema,kB as EVMTransactionDetailsParamsSchema,_$ as DerivationPath,EB as DepositChannelResponseSchema,VB as DepositChannelParamsSchema,v as DEFAULT_FEE_MULTIPLIERS,bB as CosmosTransactionSchema,hf as CommonAssetStrings,PB as CoinGeckoMetadataSchema,hB as ChainflipMetadataSchema,FB as BrokerDepositChannelParamsSchema,fB as BigIntArithmetics,_B as AssetValueSchema,BB as AssetValue,tB as ApproveResponseSchema,iB as ApproveRequestParams,Kf as ApproveMode,aB as ApprovalTransactionSchema,ZB as ApiV2ErrorSchema};
|
package/dist/tokens.cjs
CHANGED
package/dist/tokens.js
CHANGED