@swapkit/helpers 4.0.27 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +2 -2
- package/dist/api/index.cjs.map +7 -8
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +7 -8
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +13 -14
- package/dist/index.js +3 -3
- package/dist/index.js.map +13 -14
- package/dist/types/api/index.d.ts +12 -4
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts +12 -0
- package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/types.d.ts +181 -22
- package/dist/types/api/swapkitApi/types.d.ts.map +1 -1
- package/dist/types/api/thornode/endpoints.d.ts.map +1 -1
- package/dist/types/modules/assetValue.d.ts +2 -0
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/modules/feeMultiplier.d.ts.map +1 -1
- package/dist/types/modules/swapKitConfig.d.ts +41 -22
- package/dist/types/modules/swapKitConfig.d.ts.map +1 -1
- package/dist/types/modules/swapKitError.d.ts +36 -0
- package/dist/types/modules/swapKitError.d.ts.map +1 -1
- package/dist/types/types/derivationPath.d.ts +3 -15
- package/dist/types/types/derivationPath.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/quotes.d.ts +2 -1
- package/dist/types/types/quotes.d.ts.map +1 -1
- package/dist/types/utils/asset.d.ts +6 -3
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/dist/types/utils/chains.d.ts.map +1 -1
- package/dist/types/utils/derivationPath.d.ts +2 -2
- package/dist/types/utils/derivationPath.d.ts.map +1 -1
- package/dist/types/utils/explorerUrls.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/types/api/thorswapStatic/endpoints.d.ts +0 -5
- package/dist/types/api/thorswapStatic/endpoints.d.ts.map +0 -1
- package/dist/types/api/thorswapStatic/types.d.ts +0 -21
- package/dist/types/api/thorswapStatic/types.d.ts.map +0 -1
- package/dist/types/types/chains.d.ts +0 -34
- package/dist/types/types/chains.d.ts.map +0 -1
- package/dist/types/types/radix.d.ts +0 -15
- package/dist/types/types/radix.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Q={};W(Q,{wrapWithThrow:()=>NF,wrapMethodWithNetworkSwitch:()=>c0,warnOnce:()=>E,validateTNS:()=>zF,validateIdentifier:()=>G0,updateDerivationPath:()=>a,switchEVMWalletNetwork:()=>o0,providerRequest:()=>X0,prepareNetworkSwitch:()=>$$,okxMobileEnabled:()=>l0,listWeb3EVMWallets:()=>C0,isWeb3Detected:()=>aF,isGasAsset:()=>_0,isDetected:()=>eF,initializeRPCUrlsWithFallback:()=>BF,getWalletFormatFor:()=>wF,getTHORNameCost:()=>AF,getSymmetricWithdraw:()=>fF,getSymmetricPoolShare:()=>d0,getRPCUrl:()=>n,getMinAmountByChain:()=>IF,getMemoForWithdraw:()=>hF,getMemoForUnbond:()=>CF,getMemoForTcyStake:()=>rF,getMemoForTcyClaim:()=>tF,getMemoForRunePoolWithdraw:()=>lF,getMemoForRunePoolDeposit:()=>oF,getMemoForNameRegister:()=>nF,getMemoForNamePreferredAssetRegister:()=>sF,getMemoForLeaveAndBond:()=>mF,getMemoForDeposit:()=>cF,getMAYANameCost:()=>RF,getLiquiditySlippage:()=>uF,getFeeMultiplierAsBigInt:()=>g0,getFeeMultiplier:()=>z0,getExplorerTxUrl:()=>SF,getExplorerAddressUrl:()=>vF,getEstimatedPoolShare:()=>yF,getETHDefaultWallet:()=>R$,getEIP6963Wallets:()=>N$,getDerivationPathFor:()=>KF,getDecimal:()=>T0,getCommonAssetInfo:()=>c,getChainIdentifier:()=>PF,getAsymmetricRuneWithdrawAmount:()=>bF,getAsymmetricRuneShare:()=>u0,getAsymmetricAssetWithdrawAmount:()=>gF,getAsymmetricAssetShare:()=>p0,getAssetType:()=>t,formatBigIntToSafeValue:()=>b,findAssetBy:()=>LF,filterSupportedChains:()=>F$,derivationPathToString:()=>f0,assetFromString:()=>r,applyFeeMultiplierToBigInt:()=>qF,applyFeeMultiplier:()=>VF,addEVMWalletNetwork:()=>h0,addAccountsChangedCallback:()=>A$,WarningCodeEnum:()=>q0,WalletOption:()=>C,SwapKitNumber:()=>K,SwapKitError:()=>I,SKConfig:()=>k,RequestClient:()=>o,RPC_URLS:()=>A0,ProviderName:()=>V0,NetworkDerivationPath:()=>v,NODE_URLS:()=>l,MemoType:()=>x0,LedgerErrorCode:()=>K0,FeeTypeEnum:()=>U0,FeeOption:()=>P0,FALLBACK_URLS:()=>R0,ErrorCode:()=>W0,EXPLORER_URLS:()=>N0,DerivationPath:()=>OF,DEFAULT_FEE_MULTIPLIERS:()=>b0,ContractAddress:()=>j0,CommonAssetStrings:()=>GF,BigIntArithmetics:()=>w,AssetValue:()=>g,ApproveMode:()=>k0});module.exports=v$(Q);L(Q,require("@swapkit/tokens"),module.exports);L(Q,require("@swapkit/types"),module.exports);var WF={};W(WF,{getMinAmountByChain:()=>IF,AssetValue:()=>g});var Y=require("@swapkit/types"),S0=require("ethers"),Z0=require("ts-pattern");var MF={};W(MF,{isGasAsset:()=>_0,getDecimal:()=>T0,getCommonAssetInfo:()=>c,getAssetType:()=>t,findAssetBy:()=>LF,assetFromString:()=>r,CommonAssetStrings:()=>GF});var T=require("@swapkit/types"),s=require("ts-pattern");var FF={};W(FF,{RequestClient:()=>o});var a0={};W(a0,{SKConfig:()=>k});var r0=require("@swapkit/types"),i0=require("zustand/vanilla");var t0={};W(t0,{WarningCodeEnum:()=>q0,WalletOption:()=>C,RPC_URLS:()=>A0,ProviderName:()=>V0,NetworkDerivationPath:()=>v,NODE_URLS:()=>l,MemoType:()=>x0,LedgerErrorCode:()=>K0,FeeTypeEnum:()=>U0,FeeOption:()=>P0,FALLBACK_URLS:()=>R0,ErrorCode:()=>W0,EXPLORER_URLS:()=>N0,ContractAddress:()=>j0,ApproveMode:()=>k0});var x=require("@swapkit/types"),A0={[x.Chain.Arbitrum]:"https://arb1.arbitrum.io/rpc",[x.Chain.Aurora]:"https://aurora-rpc.publicnode.com",[x.Chain.Avalanche]:"https://api.avax.network/ext/bc/C/rpc",[x.Chain.Base]:"https://base-rpc.publicnode.com",[x.Chain.Berachain]:"https://berachain-rpc.publicnode.com",[x.Chain.BinanceSmartChain]:"https://bsc-dataseed.binance.org",[x.Chain.BitcoinCash]:"https://node-router.thorswap.net/bitcoin-cash",[x.Chain.Bitcoin]:"https://bitcoin-rpc.publicnode.com",[x.Chain.Chainflip]:"wss://mainnet-archive.chainflip.io",[x.Chain.Cosmos]:"https://cosmos-rpc.publicnode.com:443",[x.Chain.Dash]:"https://dash-rpc.publicnode.com",[x.Chain.Dogecoin]:"https://node-router.thorswap.net/dogecoin",[x.Chain.Ethereum]:"https://ethereum-rpc.publicnode.com",[x.Chain.Gnosis]:"https://gnosis-rpc.publicnode.com",[x.Chain.Harbor]:x.getChainConfig(x.Chain.Harbor).rpcUrl,[x.Chain.Kujira]:"https://kujira-rpc.ibs.team",[x.Chain.Litecoin]:"https://node-router.thorswap.net/litecoin",[x.Chain.Maya]:"https://tendermint.mayachain.info",[x.Chain.Near]:"https://rpc.mainnet.near.org",[x.Chain.Noble]:"https://noble-rpc.polkachu.com",[x.Chain.Optimism]:"https://mainnet.optimism.io",[x.Chain.Polkadot]:"wss://rpc.polkadot.io",[x.Chain.Polygon]:"https://polygon-rpc.com",[x.Chain.Radix]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",[x.Chain.Ripple]:"wss://xrpl.ws/",[x.Chain.Solana]:"https://solana-rpc.publicnode.com",[x.Chain.THORChain]:"https://rpc.ninerealms.com",[x.Chain.Tron]:"https://tron-rpc.publicnode.com",[x.Chain.Zcash]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",[x.StagenetChain.Maya]:"",[x.StagenetChain.THORChain]:"https://stagenet-rpc.ninerealms.com",[x.StagenetChain.Harbor]:x.getChainConfig(x.Chain.Harbor).rpcUrl},l={[x.Chain.THORChain]:"https://thornode.ninerealms.com",[x.Chain.Maya]:"https://mayanode.mayachain.info",[x.Chain.Harbor]:x.getChainConfig(x.Chain.Harbor).rpcUrl,[x.StagenetChain.THORChain]:"https://stagenet-thornode.ninerealms.com",[x.StagenetChain.Maya]:"https://stagenet.mayanode.mayachain.info"},R0={[x.Chain.Arbitrum]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],[x.Chain.Aurora]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],[x.Chain.Avalanche]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],[x.Chain.Base]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],[x.Chain.BinanceSmartChain]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],[x.Chain.Berachain]:["https://rpc.berachain.com","https://berachain.drpc.org"],[x.Chain.Bitcoin]:["https://bitcoin.publicnode.com"],[x.Chain.BitcoinCash]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],[x.Chain.Chainflip]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],[x.Chain.Cosmos]:["https://cosmos-rpc.publicnode.com"],[x.Chain.Dash]:["https://dash-rpc.publicnode.com"],[x.Chain.Dogecoin]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],[x.Chain.Ethereum]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],[x.Chain.Gnosis]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],[x.Chain.Harbor]:[],[x.Chain.Kujira]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],[x.Chain.Litecoin]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],[x.Chain.Maya]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],[x.StagenetChain.Maya]:[],[x.Chain.Near]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],[x.Chain.Noble]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],[x.Chain.Optimism]:["https://optimism.llamarpc.com","https://1rpc.io/op"],[x.Chain.Polkadot]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],[x.Chain.Polygon]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],[x.Chain.Radix]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],[x.Chain.Ripple]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],[x.Chain.THORChain]:["https://thornode.ninerealms.com",l[x.Chain.THORChain]],[x.StagenetChain.THORChain]:[],[x.StagenetChain.Harbor]:[],[x.Chain.Solana]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],[x.Chain.Tron]:["https://api.tronstack.io","https://api.tron.network"],[x.Chain.Zcash]:[]},N0={[x.Chain.Arbitrum]:"https://arbiscan.io",[x.Chain.Aurora]:"https://explorer.mainnet.aurora.dev",[x.Chain.Avalanche]:"https://snowtrace.io",[x.Chain.Base]:"https://basescan.org",[x.Chain.Berachain]:"https://berascan.com",[x.Chain.BinanceSmartChain]:"https://bscscan.com",[x.Chain.Bitcoin]:"https://blockchair.com/bitcoin",[x.Chain.BitcoinCash]:"https://www.blockchair.com/bitcoin-cash",[x.Chain.Chainflip]:"https://explorer.polkascan.io/polkadot",[x.Chain.Cosmos]:"https://www.mintscan.io/cosmos",[x.Chain.Dash]:"https://blockchair.com/dash",[x.Chain.Dogecoin]:"https://blockchair.com/dogecoin",[x.Chain.Ethereum]:"https://etherscan.io",[x.Chain.Gnosis]:"https://gnosisscan.io",[x.Chain.Harbor]:"",[x.Chain.Kujira]:"https://finder.kujira.network/kaiyo-1",[x.Chain.Litecoin]:"https://blockchair.com/litecoin",[x.Chain.Maya]:"https://www.mayascan.org",[x.Chain.Near]:"https://nearblocks.io",[x.Chain.Noble]:"https://www.mintscan.io/noble",[x.Chain.Optimism]:"https://optimistic.etherscan.io",[x.Chain.Polkadot]:"https://polkadot.subscan.io",[x.Chain.Polygon]:"https://polygonscan.com",[x.Chain.Radix]:"https://dashboard.radixdlt.com",[x.Chain.Ripple]:"https://livenet.xrpl.org/",[x.Chain.THORChain]:"https://runescan.io",[x.Chain.Solana]:"https://solscan.io",[x.Chain.Tron]:"https://tronscan.org",[x.Chain.Zcash]:"https://blockchair.com/zcash"};var j0;((j)=>{j.ARB="0x0000000000000000000000000000000000000000";j.AURORA="0x0000000000000000000000000000000000000000";j.AVAX="0x0000000000000000000000000000000000000000";j.BASE="0x0000000000000000000000000000000000000000";j.BERA="0x0000000000000000000000000000000000000000";j.ETH="0x0000000000000000000000000000000000000000";j.BSC="0x0000000000000000000000000000000000000000";j.GNO="0x0000000000000000000000000000000000000000";j.MATIC="0x0000000000000000000000000000000000001010";j.OP="0x4200000000000000000000000000000000000042"})(j0||={});var v={ARB:[44,60,0,0,0],AURORA:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BERA:[44,60,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],DOT:[0,0,0,0,0],ETH:[44,60,0,0,0],FLIP:[0,0,0,0,0],GAIA:[44,118,0,0,0],GNO:[44,60,0,0,0],HARBOR:[44,931,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],NOBLE:[44,118,0,0,0],OP:[44,60,0,0,0],POL:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRON:[44,195,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0],ZEC:[44,133,0,0,0]};var W0;((P)=>{P.unknownError="unknownError";P.test_error="test_error";P.providerDetailsError="providerDetailsError";P.blockHeaderNotFound="blockHeaderNotFound";P.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";P.blockHashNotFoundAtHash="blockHashNotFoundAtHash";P.txHashMissing="txHashMissing";P.assetValueMissingInfo="assetValueMissingInfo";P.invalidAsset="invalidAsset";P.blockIsRequired="blockIsRequired";P.currentBlockHeaderNotFound="currentBlockHeaderNotFound";P.failedToRetrieveBalance="failedToRetrieveBalance";P.failedToRetrieveBlock="failedToRetrieveBlock";P.failedToRetrieveFees="failedToRetrieveFees";P.notImplementedBCH="notImplementedBCH";P.notImplementedDoge="notImplementedDoge";P.noPoolsFound="noPoolsFound";P.noVaultsFound="noVaultsFound";P.noTxFound="noTxFound";P.noInputCoinFound="noInputCoinFound";P.noBlockDataFound="noBlockDataFound";P.multipleCosmosMessages="multipleCosmosMessages";P.heightOrHashNotProvided="heightOrHashNotProvided";P.unknownDenom="unknownDenom";P.invalidBlockHeight="invalidBlockHeight";P.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";P.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";P.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";P.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";P.txMemoUndefined="txMemoUndefined";P.txMemoIncorrect="txMemoIncorrect";P.txTypeNotFound="txTypeNotFound";P.txNoMessage="txNoMessage";P.txNotFound="txNotFound";P.txReceiptNotFound="txReceiptNotFound";P.txParsingError="txParsingError";P.txLogsParsingError="txLogsParsingError";P.blockNotFound="blockNotFound";P.balanceNotFound="balanceNotFound";P.configError="configError";P.synthSwapDisallowed="synthSwapDisallowed";P.providerQuoteTimeout="providerQuoteTimeout";P.noQuoteResponse="noQuoteResponse";P.noPoolAssetsFound="noPoolAssetsFound";P.noThorchainPools="noThorchainPools";P.noMayachainPools="noMayachainPools";P.noThorchainNetworkInfo="noThorchainNetworkInfo";P.invalidAffiliateFee="invalidAffiliateFee";P.invalidBuyAssetAddress="invalidBuyAssetAddress";P.invalidSellAssetAddress="invalidSellAssetAddress";P.invalidSourceAddress="invalidSourceAddress";P.invalidDestinationAddress="invalidDestinationAddress";P.sourceAddressIsSmartContract="sourceAddressIsSmartContract";P.destinationAddressIsSmartContract="destinationAddressIsSmartContract";P.invalidChainId="invalidChainId";P.unsupportedChainId="unsupportedChainId";P.unsupportedEVMChainId="unsupportedEVMChainId";P.unsupportedMethod="unsupportedMethod";P.unsupportedProvider="unsupportedProvider";P.invalidParamsForMethod="invalidParamsForMethod";P.unsupportedAdapter="unsupportedAdapter";P.noWhitelistTokens="noWhitelistTokens";P.failedFetchGasPrice="failedFetchGasPrice";P.failedToCreateDepositChannel="failedToCreateDepositChannel";P.noProviderDetailsFound="noProviderDetailsFound";P.noTokenListsFound="noTokenListsFound";P.tokenNotFound="tokenNotFound";P.tokenPriceNotFound="tokenPriceNotFound";P.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";P.swapAmountTooSmall="swapAmountTooSmall";P.legsArrayIsEmpty="legsArrayIsEmpty";P.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";P.noBlockHeaderFound="noBlockHeaderFound";P.failedToSimulateSwap="failedToSimulateSwap";P.addressScreeningFailed="addressScreeningFailed";P.noLiquidtyProvidersFound="noLiquidtyProvidersFound";P.insufficientLiquidity="insufficientLiquidity";P.noInboundDataFound="noInbounDataFound";P.noInboundAddressesFound="noInboundAddressesFound";P.noInboundAddressFoundForChain="noInboundAddressFoundForChain";P.noLastBlocksFound="noLastBlocksFound";P.noVersionFound="noVersionFound";P.noConstantsFound="noConstantsFound";P.noMimirsFound="noMimirsFound";P.noRoutesFound="noRoutesFound";P.quoteNotFound="quoteNotFound";P.ledgerSignFailed="ledgerSignFailed";P.ledgerWrongPayload="ledgerWrongPayload";P.ledgerFetchSwapFailed="ledgerFetchSwapFailed";P.failedToFetchTx="failedToFetchTx";P.failedBuildTransactionDetails="failedBuildTransactionDetails";P.noLegsForRoute="noLegsForRoute";P.noRouterAddressFound="noRouterAddressFound";P.noAggregatorAddressFound="noAggregatorAddressFound";P.noContractInstanceFound="noContractInstanceFound";P.noContractAddressFound="noContractAddressFound";P.invalidAffiliate="invalidAffiliate";P.thornameAffiliate="thornameAffiliate";P.providerNotfound="No provider found";P.noRecordFound="No Record found";P.slippageTooLow="Slippage too low";P.tradingHalted="tradingHalted";P.noWrappedGasAsset="noWrappedGasAsset";P.aggregatorAddressNotFound="aggregatorAddressNotFound";P.routerAddressNotFound="routerAddressNotFound";P.dummyAddressNotFound="dummyAddressNotFound";P.trackerError="trackerError";P.thorchainPoolUnavailable="thorchainPoolUnavailable";P.noOhlcvDataFound="noOhlcvDataFound";P.noTradingPairs="noTradingPairs";P.noLendingAvailability="noLendingAvailability";P.lendingRepayTooSmall="lendingRepayTooSmall";P.missingState="missingState";P.ledgerSwapNotFound="ledgerSwapNotFound";P.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";P.errorEstimatingGas="errorEstimatingGas";P.apiKeyInvalid="apiKeyInvalid";P.apiKeyFailedToUpdate="apiKeyFailedToUpdate";P.apiKeyExpired="apiKeyExpired";P.unauthorized="unauthorized";P.failedToCreateMemo="failedToCreateMemo";P.radixIncorrectInstructions="radixIncorrectInstructions";P.radixTxMissedParam="radixTxMissedParam";P.radixTxMissedAccount="radixTxMissedAccount";P.radixManifestParseError="radixManifestParseError";P.radixManifestBuildError="radixManifestBuildError";P.invalidAddressForChain="invalidAddressForChain";P.riskyAddress="riskyAddress";P.noRoutesToProcess="noRoutesToProcess";P.sellAssetAmountTooSmall="sellAssetAmountTooSmall";P.missingPrivateKey="missingPrivateKey";P.noMemoPriceProtection="noMemoPriceProtection"})(W0||={});var q0;((A)=>{A.highSlippage="highSlippage";A.highPriceImpact="highPriceImpact"})(q0||={});var V0;((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"})(V0||={});var U0;((_)=>{_.LIQUIDITY="liquidity";_.NETWORK="network";_.INBOUND="inbound";_.OUTBOUND="outbound";_.AFFILIATE="affiliate";_.TAX="tax";_.PRIORITY="priority"})(U0||={});var P0;((R)=>{R.Average="average";R.Fast="fast";R.Fastest="fastest"})(P0||={});var k0;((A)=>{A.Approve="approve";A.CheckOnly="checkOnly"})(k0||={});var x0;((J)=>{J.NAME_REGISTER="~";J.BOND="BOND";J.DEPOSIT="+";J.LEAVE="LEAVE";J.UNBOND="UNBOND";J.WITHDRAW="-";J.RUNEPOOL_DEPOSIT="POOL+";J.RUNEPOOL_WITHDRAW="POOL-";J.CLAIM_TCY="tcy";J.STAKE_TCY="tcy+";J.UNSTAKE_TCY="tcy-"})(x0||={});var C;((z)=>{z.BITGET="BITGET";z.BRAVE="BRAVE";z.COINBASE_MOBILE="COINBASE_MOBILE";z.COINBASE_WEB="COINBASE_WEB";z.COSMOSTATION="COSMOSTATION";z.CTRL="CTRL";z.EIP6963="EIP6963";z.EXODUS="EXODUS";z.KEEPKEY="KEEPKEY";z.KEEPKEY_BEX="KEEPKEY_BEX";z.KEPLR="KEPLR";z.KEYSTORE="KEYSTORE";z.LEAP="LEAP";z.LEDGER="LEDGER";z.LEDGER_LIVE="LEDGER_LIVE";z.METAMASK="METAMASK";z.OKX="OKX";z.OKX_MOBILE="OKX_MOBILE";z.ONEKEY="ONEKEY";z.PHANTOM="PHANTOM";z.POLKADOT_JS="POLKADOT_JS";z.RADIX_WALLET="RADIX_WALLET";z.TREZOR="TREZOR";z.TALISMAN="TALISMAN";z.TRONLINK="TRONLINK";z.TRUSTWALLET_WEB="TRUSTWALLET_WEB";z.VULTISIG="VULTISIG";z.WALLETCONNECT="WALLETCONNECT";z.XAMAN="XAMAN"})(C||={});var K0;((R)=>{R[R.NoError=36864]="NoError";R[R.LockedDevice=21781]="LockedDevice";R[R.TC_NotFound=65535]="TC_NotFound"})(K0||={});var T$={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:Object.values(r0.Chain),envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},explorerUrls:N0,fallbackRpcUrls:R0,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"}}},nodeUrls:l,requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:A0,wallets:Object.values(C)},U=i0.createStore((F)=>({...T$,setApiKey:($,A)=>F((R)=>({apiKeys:{...R.apiKeys,[$]:A}})),setConfig:($)=>F((A)=>({apiKeys:{...A.apiKeys,...$.apiKeys},chains:A.chains.concat($.chains||[]),envs:{...A.envs,...$.envs},explorerUrls:{...A.explorerUrls,...$.explorerUrls},feeMultipliers:$.feeMultipliers||A.feeMultipliers,integrations:{...A.integrations,...$.integrations},nodeUrls:{...A.nodeUrls,...$.nodeUrls},rpcUrls:{...A.rpcUrls,...$.rpcUrls},wallets:A.wallets.concat($.wallets||[])})),setEnv:($,A)=>F((R)=>({envs:{...R.envs,[$]:A}})),setExplorerUrl:($,A)=>F((R)=>({explorerUrls:{...R.explorerUrls,[$]:A}})),setFallbackRpcUrls:($,A)=>F((R)=>({fallbackRpcUrls:{...R.fallbackRpcUrls,[$]:A}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,A)=>F((R)=>({integrations:{...R.integrations,[$]:A}})),setNodeUrl:($,A)=>F((R)=>({nodeUrls:{...R.nodeUrls,[$]:A}})),setRequestOptions:($)=>F((A)=>({requestOptions:{retry:{...A.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||A.requestOptions.timeoutMs}})),setRpcUrl:($,A)=>F((R)=>({rpcUrls:{...R.rpcUrls,[$]:A}}))})),k={get:(F)=>U.getState()[F],getState:U.getState,set:(F)=>U.getState().setConfig(F),setApiKey:(F,$)=>U.getState().setApiKey(F,$),setEnv:(F,$)=>U.getState().setEnv(F,$),setExplorerUrl:(F,$)=>U.getState().setExplorerUrl(F,$),setFallbackRpcUrls:(F,$)=>U.getState().setFallbackRpcUrls(F,$),setFeeMultipliers:(F)=>U.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>U.getState().setIntegrationConfig(F,$),setNodeUrl:(F,$)=>U.getState().setNodeUrl(F,$),setRequestOptions:(F)=>U.getState().setRequestOptions(F),setRpcUrl:(F,$)=>U.getState().setRpcUrl(F,$)};var e0={};W(e0,{SwapKitError:()=>I});var _$={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_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_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_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_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_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported: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_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,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,not_implemented:99999};class I extends Error{static ErrorCode=_$;constructor(F,$){let A=typeof F==="string",R=A?F:F.errorKey,N=A?void 0:F.info,H=`${R}${N?`: ${JSON.stringify(N)}`:""}`;super(H);if(Object.setPrototypeOf(this,I.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${R}]:`,$);else if(N)console.error(`SwapKitError [${R}]:`,N)}}var G$=(F)=>new Promise(($)=>setTimeout($,F)),Q$=(F,{baseDelay:$,backoffMultiplier:A,maxDelay:R})=>Math.min($*A**F,R),L$=async(F,$)=>{let A=await fetch(F,$);if(!A.ok){let N={message:await A.text(),status:A.status,statusText:A.statusText};throw new I({errorKey:"helpers_invalid_response",info:N},N)}return A.json()};function H0(F,$={}){return async function(R,N={}){let{searchParams:H,json:B,body:_,headers:G,dynamicHeader:M,retry:j,timeoutMs:J,abortController:f,onError:O,onSuccess:m,responseHandler:y,...h}={...$,...N},D=k.get("requestOptions"),S={...D.retry,...j},X=!!B||R.endsWith(".json"),x$=Z$(R,H),H$=M$(X,{...G,...M?.()}),B$=X?JSON.stringify(B):_,I0;for(let $0=0;$0<=S.maxRetries;$0++){let n0=f||new AbortController,s0=setTimeout(()=>n0.abort(),J||D.timeoutMs);try{let u=await L$(x$,{...h,body:B$,headers:H$,method:F,signal:n0.signal});return clearTimeout(s0),m?.(u)||y?.(u)||u}catch(u){if(clearTimeout(s0),I0=u,$0>=S.maxRetries)return O?O(u):Promise.reject(u);await G$(Q$($0,S))}}return O?O(I0):Promise.reject(I0)}}function M$(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function Z$(F,$){let A=new URL(F);if($)A.search=new URLSearchParams($).toString();return A.toString()}var o={extend:(F)=>({extend:($)=>o.extend({...F,...$}),get:H0("GET",F),post:H0("POST",F)}),get:H0("GET"),post:H0("POST")};var TF={};W(TF,{initializeRPCUrlsWithFallback:()=>BF,getRPCUrl:()=>n});var q=require("@swapkit/types"),O0=require("ts-pattern");var xF={};W(xF,{wrapWithThrow:()=>NF,warnOnce:()=>E,getTHORNameCost:()=>AF,getMAYANameCost:()=>RF,getChainIdentifier:()=>PF});var B0=require("@swapkit/types");function AF(F){if(F<0)throw new I({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function RF(F){if(F<0)throw new I({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function NF(F,$){try{return F()}catch(A){if($)throw new I($,A);return}}function PF(F){switch(F){case B0.Chain.THORChain:return`${F}.RUNE`;case B0.Chain.Cosmos:return`${F}.ATOM`;case B0.Chain.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var $F=new Set;function E({condition:F,id:$,warning:A}){if(F){if($F.has($))return;console.warn(A),$F.add($)}}function z$(F){return O0.match(F).with(...q.EVMChains,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...q.UTXOChains,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...q.CosmosChains,...q.StagenetChains,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(q.Chain.Polkadot,q.Chain.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(q.Chain.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(q.Chain.Tron,q.Chain.Radix,()=>"").with(q.Chain.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(q.Chain.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new I("helpers_chain_not_supported",{chain:F})})}function Y$(F){return O0.match(F).with(q.Chain.Radix,()=>"/status/network-configuration").with(q.Chain.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function HF(F,$){try{let A=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${A}${Y$(F)}`,{body:JSON.stringify(z$(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var w0=new Map,J$=120000;async function n(F){let{isStagenet:$}=k.get("envs"),A=k.get("rpcUrls"),R=k.get("fallbackRpcUrls");if($)return A[F];let N=w0.get(F);if(N&&Date.now()-N.timestamp<J$)return N.url;let H=A[F];if(!await HF(F,H)){for(let _ of R[F])if(await HF(F,_))return w0.set(F,{timestamp:Date.now(),url:_}),_}return w0.set(F,{timestamp:Date.now(),url:H}),H}function BF(F){E({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 GF=[`${T.Chain.Maya}.MAYA`,`${T.Chain.Maya}.CACAO`,`${T.Chain.Ethereum}.THOR`,`${T.Chain.Ethereum}.vTHOR`,`${T.Chain.Kujira}.USK`,`${T.Chain.Ethereum}.FLIP`,`${T.Chain.Radix}.XRD`],QF=[T.Chain.Arbitrum,T.Chain.Aurora,T.Chain.Base,T.Chain.Ethereum,T.Chain.Optimism];async function X$({chain:F,to:$}){let{baseDecimal:R}=T.getChainConfig(F);try{let N=await n(F),{result:H}=await o.post(N,{body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{data:"0x313ce567",to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}});return Number.parseInt(BigInt(H||R).toString(),10)}catch(N){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,N),R}}async function I$(F){let{baseDecimal:$}=T.getChainConfig(T.Chain.Radix);if(F===T.Chain.Radix)return $;try{let A=F.split("-")[1]?.toLowerCase(),R=await n(T.Chain.Radix),{manager:N}=await o.post(`${R}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:A}),headers:{Accept:"*/*","Content-Type":"application/json"}});return N.divisibility.value.divisibility}catch(A){return console.error(`Failed to fetch Radix asset decimal for ${F}:`,A),$}}async function j$({chain:F,symbol:$}){let{baseDecimal:A}=T.getChainConfig(F);if(T.EVMChains.includes($))return A;let R=$.split("-"),N=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(N?.startsWith("0x")?X$({chain:F,to:N}):A)}function T0({chain:F,symbol:$}){let{baseDecimal:A}=T.getChainConfig(F);return s.match(F).with(...T.EVMChains,(R)=>j$({chain:R,symbol:$})).with(T.Chain.Radix,()=>I$($)).otherwise(()=>A)}function _0({chain:F,symbol:$}){return s.match(F).with(...QF,()=>$==="ETH").with(T.Chain.Avalanche,()=>$==="AVAX").with(T.Chain.Berachain,()=>$==="BERA").with(T.Chain.BinanceSmartChain,()=>$==="BNB").with(T.Chain.Gnosis,()=>$==="XDAI").with(T.Chain.Maya,()=>$==="CACAO").with(T.Chain.Cosmos,()=>$==="ATOM").with(T.Chain.THORChain,()=>$==="RUNE").with(T.Chain.Tron,()=>$==="TRX").with(T.Chain.Radix,()=>`${F}.${$}`===c(F).identifier).otherwise(()=>$===F)}var c=(F)=>{let{baseDecimal:$}=T.getChainConfig(F);return s.match(F.toUpperCase()).with(...QF,(R)=>({decimal:$,identifier:`${R}.ETH`})).with(T.Chain.THORChain,(R)=>({decimal:$,identifier:`${R}.RUNE`})).with(T.Chain.Cosmos,(R)=>({decimal:$,identifier:`${R}.ATOM`})).with(T.Chain.Maya,(R)=>({decimal:10,identifier:`${R}.CACAO`})).with(T.Chain.BinanceSmartChain,(R)=>({decimal:$,identifier:`${R}.BNB`})).with(T.Chain.Avalanche,(R)=>({decimal:$,identifier:`${R}.AVAX`})).with(T.Chain.Gnosis,(R)=>({decimal:$,identifier:`${R}.XDAI`})).with(T.Chain.Berachain,(R)=>({decimal:$,identifier:`${R}.BERA`})).with(T.Chain.Tron,(R)=>({decimal:$,identifier:`${R}.TRX`})).with(T.Chain.Solana,T.Chain.Chainflip,T.Chain.Kujira,T.Chain.Ripple,T.Chain.Polkadot,T.Chain.Near,...T.UTXOChains,(R)=>({decimal:$,identifier:`${R}.${R}`})).with(T.Chain.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(T.Chain.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(R)=>({decimal:6,identifier:R})).with("ETH.FLIP",()=>({decimal:T.getChainConfig(T.Chain.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:T.getChainConfig(T.Chain.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:T.getChainConfig(T.Chain.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(R)=>({decimal:10,identifier:R})).with("MAYA.MAYA",(R)=>({decimal:4,identifier:R})).otherwise(()=>({decimal:$,identifier:F}))};function t({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return s.match(F).with(T.Chain.Radix,()=>$===T.Chain.Radix||`${F}.${$}`===c(F).identifier).with(T.Chain.Arbitrum,T.Chain.Optimism,T.Chain.Base,T.Chain.Aurora,()=>$===T.Chain.Ethereum).with(T.Chain.Cosmos,()=>$==="ATOM").with(T.Chain.BinanceSmartChain,()=>$==="BNB").with(T.Chain.Maya,()=>$==="CACAO").with(T.Chain.THORChain,()=>$==="RUNE").with(T.Chain.Tron,()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var r=(F)=>{let[$,...A]=F.split("."),R=F.includes("/"),N=A.join("."),H=N?.split("-"),B=H?.length?H.length===1?H[0]:H.slice(0,-1).join("-"):void 0;return{chain:$,symbol:N,synth:R,ticker:B}};async function LF(F){let{loadTokenLists:$}=await import("./tokens.cjs"),A=await $();for(let R of Object.values(A))for(let{identifier:N,chain:H,...B}of R.tokens){if("identifier"in F&&N===F.identifier)return N;if("address"in B&&"chain"in F&&H===F.chain&&B.address&&B.address.toLowerCase()===F.contract.toLowerCase())return N}return}var YF={};W(YF,{validateTNS:()=>zF,validateIdentifier:()=>G0});var ZF=["TERRA",...k.get("chains")];function G0(F=""){let $=F.toUpperCase(),[A]=$.split(".");if(ZF.includes(A))return!0;let[R]=$.split("/");if(ZF.includes(R))return!0;throw new I({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function zF(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var XF={};W(XF,{formatBigIntToSafeValue:()=>b,BigIntArithmetics:()=>w});var p=(F)=>10n**BigInt(F),i=(F)=>Math.log10(Number.parseFloat(F.toString()));function b({value:F,bigIntDecimal:$=8,decimal:A=8}){if(A===0)return F.toString();let R=F<0n,N=F.toString().substring(R?1:0),H=A-(N.length-1);if(H>0)N="0".repeat(H)+N;let B=N.length-A,_=N.slice(-A);if(Number.parseInt(_[$]||"0",10)>=5)_=`${_.substring(0,$-1)}${(Number.parseInt(_[$-1]||"0",10)+1).toString()}`;else _=_.substring(0,$);return`${R?"-":""}${N.slice(0,B)}.${_}`.replace(/\.?0*$/,"")}function W$(F,$){if($===0n)throw Error("Cannot divide by zero");let A=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+A)/$;return(F-A)/$}class w{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new w({decimal:$,value:b({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:A}){return w.fromBigInt(F.getBaseValue("bigint")*p(A)/p($),A)}constructor(F){let $=D0(F),A=typeof F==="object";this.decimal=A?F.decimal:void 0,this.decimalMultiplier=A&&"decimalMultiplier"in F?F.decimalMultiplier:p(Math.max(JF(Q0($)),this.decimal||0)),this.#N($)}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 A=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||i(this.decimalMultiplier));switch(F){case"number":return Number(A);case"string":return A;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return A}}getBaseValue(F,$){let A=this.decimalMultiplier/p($||this.decimal||8),R=W$(this.bigIntValue,A);switch(F){case"number":return Number(R);case"string":return R.toString();case"bigint":return R;default:return R}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let A=D0(F),R=Q0(A);if(R==="0"||R==="undefined")return 0n;return this.#R(R,$)}toSignificant(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",N=A||"";if((Number.parseInt(R,10)?R.length+N.length:N.length)<=F)return this.getValue("string");if(R.length>=F)return R.slice(0,F).padEnd(R.length,"0");if(Number.parseInt(R,10))return`${R}.${N.slice(0,F-R.length)}`.padEnd(F-R.length,"0");let B=Number.parseInt(N,10),_=`${B}`.slice(0,F);return`0.${_.padStart(N.length-`${B}`.length+_.length,"0")}`}toFixed(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",N=A||"";if(Number.parseInt(R,10))return`${R}.${N.slice(0,F)}`.padEnd(F,"0");let H=Number.parseInt(N,10),B=`${H}`.slice(0,F);return`0.${B.padStart(N.length-`${H}`.length+B.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),A=["","K","M","B","T","Q","Qi","S"],R=Math.floor(Math.log10(Math.abs($))/3),N=A[R];if(!N)return this.getValue("string");let H=10**(R*3);return`${($/H).toFixed(F)}${N}`}toCurrency(F="$",{currencyPosition:$="start",decimal:A=2,decimalSeparator:R=".",thousandSeparator:N=","}={}){let H=this.getValue("number"),[B="",_=""]=H.toFixed(6).split("."),G=B.replace(/\B(?=(\d{3})+(?!\d))/g,N),M=B||_?B==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",R):`${G}${Number.parseInt(_,10)?`${R}${_.slice(0,A)}`:""}`:"0.00";return`${$==="start"?F:""}${M}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let A=$||this.decimal||8,R=Math.max(A,i(this.decimalMultiplier)),N=F<0n,H=F.toString().substring(N?1:0),B=R-(H.length-1),_=B>0?"0".repeat(B)+H:H,G=_.length-R,M=_.slice(-R);if(Number.parseInt(M[A]||"0",10)>=5)M=`${M.substring(0,A-1)}${(Number.parseInt(M[A-1]||"0",10)+1).toString()}`;else M=M.substring(0,A);return`${N?"-":""}${_.slice(0,G)}.${M}`.replace(/\.?0*$/,"")}#$(F,...$){let A=this.#A(this,...$),R=Math.max(A,i(this.decimalMultiplier)),N=p(R),H=$.reduce((_,G)=>{let M=this.getBigIntValue(G,R);switch(F){case"add":return _+M;case"sub":return _-M;case"mul":return _*M/N;case"div":{if(M===0n)throw RangeError("Division by zero");return _*N/M}default:return _}},this.bigIntValue*N/this.decimalMultiplier),B=b({bigIntDecimal:R,decimal:R,value:H});return new this.constructor({decimal:this.decimal,decimalMultiplier:p(R),identifier:this.toString(),value:B})}#F(F,...$){let A=this.#A(this,...$),R=this.getBigIntValue($[0]||"0",A),N=this.getBigIntValue(this,A);switch(F){case"gt":return N>R;case"gte":return N>=R;case"lt":return N<R;case"lte":return N<=R;case"eqValue":return N===R;default:return!1}}#N(F){let $=Q0(F)||"0";this.bigIntValue=this.#R($)}#A(...F){let $=F.map((A)=>{return typeof A==="object"?A.decimal||i(A.decimalMultiplier):JF(Q0(A))}).filter(Boolean);return Math.max(...$,8)}#R(F,$){let A=$?p($):this.decimalMultiplier,R=i(A),[N="",H=""]=F.split(".");return BigInt(`${N}${H.padEnd(R,"0")}`)}}var q$=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function Q0(F){let A=`${typeof F==="number"?q$.format(F):D0(F)}`.replaceAll(",",".").split(".");return A.length>1?`${A.slice(0,-1).join("")}.${A.at(-1)}`:A[0]||"0"}function JF(F){let $=F.split(".")[1]?.length||0;return Math.max($,8)}function D0(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var L0=[Y.Chain.Solana,Y.Chain.Tron,Y.Chain.Near],E0=[Y.Chain.THORChain,Y.Chain.Maya],d=new Map;class g extends w{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:A,chain:R,symbol:N,identifier:H}){super(typeof F==="object"?F:{decimal:$,value:F});let B=v0(H||`${R}.${N}`);this.type=t(B),this.tax=A,this.chain=B.chain,this.ticker=B.ticker,this.symbol=B.symbol,this.address=B.address,this.isSynthetic=B.isSynthetic,this.isTradeAsset=B.isTradeAsset,this.isGasAsset=B.isGasAsset,this.chainId=Y.getChainConfig(B.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 d.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 A=F.indexOf(".");if(A===-1)throw new I({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let R=F.slice(0,A),N=F.slice(A+1),H=Z0.match({chain:R,rest:N}).when(({rest:B})=>B.includes(".."),({chain:B,rest:_})=>`${B}.${_.replace(/\.\./g,"~")}`).when(({chain:B,rest:_})=>E0.includes(B)&&_.includes("."),({chain:B,rest:_})=>`${B}.${_.replace(/\./g,"/")}`).otherwise(({chain:B,rest:_})=>`${B}.${_.replace(/__/g,".")}`);return g.from({asset:H,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:A,...R}){let N=F instanceof w?F.getValue("string"):F,H=K$(R),{identifier:B,decimal:_}=c(H),{chain:G,isSynthetic:M,isTradeAsset:j}=v0(B),{baseDecimal:J}=Y.getChainConfig(G),f=d.get(L0.includes(G)?B:B.toUpperCase()),O=f?.decimal||_;E({condition:!(A||O),id:`assetValue_static_decimal_not_found_${G}`,warning:`Couldn't find static decimal for one or more tokens on ${G} (Using default ${J} decimal as fallback).
|
|
1
|
+
var L={};q(L,{wrapWithThrow:()=>A$,wrapMethodWithNetworkSwitch:()=>cF,warnOnce:()=>D,validateTNS:()=>M$,validateIdentifier:()=>JF,updateDerivationPath:()=>RF,switchEVMWalletNetwork:()=>dF,providerRequest:()=>qF,prepareNetworkSwitch:()=>RP,okxMobileEnabled:()=>lF,listWeb3EVMWallets:()=>oF,isWeb3Detected:()=>PP,isGasAsset:()=>ZF,isDetected:()=>NP,initializeRPCUrlsWithFallback:()=>x$,getWalletFormatFor:()=>v$,getTHORNameCost:()=>H$,getSymmetricWithdraw:()=>p$,getSymmetricPoolShare:()=>mF,getRPCUrl:()=>y,getMinAmountByChain:()=>I$,getMemoForWithdraw:()=>s$,getMemoForUnbond:()=>n$,getMemoForTcyStake:()=>FP,getMemoForTcyClaim:()=>e$,getMemoForRunePoolWithdraw:()=>r$,getMemoForRunePoolDeposit:()=>l$,getMemoForNameRegister:()=>i$,getMemoForNamePreferredAssetRegister:()=>a$,getMemoForLeaveAndBond:()=>c$,getMemoForDeposit:()=>t$,getMAYANameCost:()=>R$,getLiquiditySlippage:()=>h$,getFeeMultiplierAsBigInt:()=>yF,getFeeMultiplier:()=>XF,getExplorerTxUrl:()=>b$,getExplorerAddressUrl:()=>y$,getEstimatedPoolShare:()=>m$,getETHDefaultWallet:()=>BP,getEIP6963Wallets:()=>GP,getDerivationPathFor:()=>S$,getCommonAssetInfo:()=>r,getChainIdentifier:()=>B$,getAsymmetricRuneWithdrawAmount:()=>u$,getAsymmetricRuneShare:()=>CF,getAsymmetricAssetWithdrawAmount:()=>C$,getAsymmetricAssetShare:()=>pF,getAssetType:()=>PF,formatBigIntToSafeValue:()=>f,findAssetBy:()=>J$,filterSupportedChains:()=>HP,fetchTokenInfo:()=>zF,derivationPathToString:()=>fF,assetFromString:()=>i,applyFeeMultiplierToBigInt:()=>K$,applyFeeMultiplier:()=>O$,addEVMWalletNetwork:()=>nF,addAccountsChangedCallback:()=>AP,WarningCodeEnum:()=>IF,WalletOption:()=>t,SwapKitNumber:()=>w,SwapKitError:()=>X,SKConfig:()=>V,RequestClient:()=>b,ProviderName:()=>VF,NetworkDerivationPath:()=>E,MemoType:()=>xF,LedgerErrorCode:()=>OF,FeeTypeEnum:()=>wF,FeeOption:()=>_F,ErrorCode:()=>UF,DerivationPath:()=>g$,DEFAULT_FEE_MULTIPLIERS:()=>bF,CommonAssetStrings:()=>Q$,BigIntArithmetics:()=>k,AssetValue:()=>d,ApproveMode:()=>KF});module.exports=uP(L);Q(L,require("@swapkit/tokens"),module.exports);Q(L,require("@swapkit/types"),module.exports);var w$={};q(w$,{getMinAmountByChain:()=>I$,AssetValue:()=>d});var J=require("@swapkit/types"),gF=require("ethers"),MF=require("ts-pattern");var T$={};q(T$,{isGasAsset:()=>ZF,getCommonAssetInfo:()=>r,getAssetType:()=>PF,findAssetBy:()=>J$,fetchTokenInfo:()=>zF,assetFromString:()=>i,CommonAssetStrings:()=>Q$});var _=require("@swapkit/types"),$F=require("ts-pattern");var P$={};q(P$,{RequestClient:()=>b});var F$={};q(F$,{SKConfig:()=>V});var I=require("@swapkit/types"),aF=require("zustand/vanilla");var iF={};q(iF,{WarningCodeEnum:()=>IF,WalletOption:()=>t,ProviderName:()=>VF,NetworkDerivationPath:()=>E,MemoType:()=>xF,LedgerErrorCode:()=>OF,FeeTypeEnum:()=>wF,FeeOption:()=>_F,ErrorCode:()=>UF,ApproveMode:()=>KF});var GF=require("@swapkit/types"),E=GF.AllChains.reduce((F,$)=>{return F[$]=GF.getChainConfig($).networkDerivationPath,F},{});var UF;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(UF||={});var IF;((P)=>{P.highSlippage="highSlippage";P.highPriceImpact="highPriceImpact"})(IF||={});var VF;((M)=>{M.CAVIAR_V1="CAVIAR_V1";M.CAMELOT_V3="CAMELOT_V3";M.CHAINFLIP="CHAINFLIP";M.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";M.JUPITER="JUPITER";M.MAYACHAIN="MAYACHAIN";M.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";M.OCISWAP_V1="OCISWAP_V1";M.ONEINCH="ONEINCH";M.OPENOCEAN_V2="OPENOCEAN_V2";M.PANCAKESWAP="PANCAKESWAP";M.PANGOLIN_V1="PANGOLIN_V1";M.SUSHISWAP_V2="SUSHISWAP_V2";M.THORCHAIN="THORCHAIN";M.THORCHAIN_STREAMING="THORCHAIN_STREAMING";M.TRADERJOE_V2="TRADERJOE_V2";M.UNISWAP_V2="UNISWAP_V2";M.UNISWAP_V3="UNISWAP_V3";M.NEAR="NEAR";M.GARDEN="GARDEN"})(VF||={});var wF;((G)=>{G.LIQUIDITY="liquidity";G.NETWORK="network";G.INBOUND="inbound";G.OUTBOUND="outbound";G.AFFILIATE="affiliate";G.TAX="tax";G.PRIORITY="priority"})(wF||={});var _F;((N)=>{N.Average="average";N.Fast="fast";N.Fastest="fastest"})(_F||={});var KF;((P)=>{P.Approve="approve";P.CheckOnly="checkOnly"})(KF||={});var xF;((Y)=>{Y.NAME_REGISTER="~";Y.BOND="BOND";Y.DEPOSIT="+";Y.LEAVE="LEAVE";Y.UNBOND="UNBOND";Y.WITHDRAW="-";Y.RUNEPOOL_DEPOSIT="POOL+";Y.RUNEPOOL_WITHDRAW="POOL-";Y.CLAIM_TCY="tcy";Y.STAKE_TCY="tcy+";Y.UNSTAKE_TCY="tcy-"})(xF||={});var t;((T)=>{T.BITGET="BITGET";T.BRAVE="BRAVE";T.COINBASE_MOBILE="COINBASE_MOBILE";T.COINBASE_WEB="COINBASE_WEB";T.COSMOSTATION="COSMOSTATION";T.CTRL="CTRL";T.EIP6963="EIP6963";T.EXODUS="EXODUS";T.KEEPKEY="KEEPKEY";T.KEEPKEY_BEX="KEEPKEY_BEX";T.KEPLR="KEPLR";T.KEYSTORE="KEYSTORE";T.LEAP="LEAP";T.LEDGER="LEDGER";T.LEDGER_LIVE="LEDGER_LIVE";T.METAMASK="METAMASK";T.OKX="OKX";T.OKX_MOBILE="OKX_MOBILE";T.ONEKEY="ONEKEY";T.PHANTOM="PHANTOM";T.POLKADOT_JS="POLKADOT_JS";T.RADIX_WALLET="RADIX_WALLET";T.TREZOR="TREZOR";T.TALISMAN="TALISMAN";T.TRONLINK="TRONLINK";T.TRUSTWALLET_WEB="TRUSTWALLET_WEB";T.VULTISIG="VULTISIG";T.WALLETCONNECT="WALLETCONNECT";T.XAMAN="XAMAN"})(t||={});var OF;((N)=>{N[N.NoError=36864]="NoError";N[N.LockedDevice=21781]="LockedDevice";N[N.TC_NotFound=65535]="TC_NotFound"})(OF||={});var xP=I.AllChains.reduce((F,$)=>{if(!F.THOR_STAGENET)F[I.StagenetChain.Maya]=I.StagenetMAYAConfig.rpcUrls,F[I.StagenetChain.THORChain]=I.StagenetTHORConfig.rpcUrls;return F[$]=I.getChainConfig($).rpcUrls,F},{}),eF={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:I.AllChains,rpcUrls:xP,envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},wallets:Object.values(t)},O=aF.createStore((F)=>({...eF,setApiKey:($,P)=>F((N)=>({apiKeys:{...N.apiKeys,[$]:P}})),setConfig:($)=>F((P)=>({apiKeys:{...P.apiKeys,...$.apiKeys},chains:P.chains.concat($.chains||[]),envs:{...P.envs,...$.envs},feeMultipliers:$.feeMultipliers||P.feeMultipliers,integrations:{...P.integrations,...$.integrations},rpcUrls:{...P.rpcUrls,...$.rpcUrls},wallets:P.wallets.concat($.wallets||[])})),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}}))})),V={get:(F)=>O.getState()[F],getState:O.getState,reinitialize:()=>O.setState(eF),set:(F)=>O.getState().setConfig(F),setApiKey:(F,$)=>O.getState().setApiKey(F,$),setEnv:(F,$)=>O.getState().setEnv(F,$),setFeeMultipliers:(F)=>O.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>O.getState().setIntegrationConfig(F,$),setRequestOptions:(F)=>O.getState().setRequestOptions(F),setRpcUrl:(F,$)=>O.getState().setRpcUrl(F,$)};var $$={};q($$,{SwapKitError:()=>X});var LP={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_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_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_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_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported: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_meta_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 X extends Error{static ErrorCode=LP;constructor(F,$){let P=typeof F==="string",N=P?F:F.errorKey,H=P?void 0:F.info,B=`${N}${H?`: ${JSON.stringify(H)}`:""}`;super(B);if(Object.setPrototypeOf(this,X.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${N}]:`,$);else if(H)console.error(`SwapKitError [${N}]:`,H)}}var QP=(F)=>new Promise(($)=>setTimeout($,F)),zP=(F,{baseDelay:$,backoffMultiplier:P,maxDelay:N})=>Math.min($*P**F,N),ZP=async(F,$)=>{let P=await fetch(F,$);if(!P.ok){let H={message:await P.text(),status:P.status,statusText:P.statusText};throw new X({errorKey:"helpers_invalid_response",info:H},H)}return P.json()};function LF(F,$={}){return async function(N,H={}){let{searchParams:B,json:A,body:G,headers:x,dynamicHeader:z,retry:W,timeoutMs:Y,abortController:C,onError:S,onSuccess:c,responseHandler:p,...n}={...$,...H},v=V.get("requestOptions"),K={...v.retry,...W},l=!!A||N.endsWith(".json"),M=TP(N,B),tF=JP(l,{...x,...z?.()}),FF=l?JSON.stringify(A):G,g;for(let m=0;m<=K.maxRetries;m++){let sF=C||new AbortController,rF=setTimeout(()=>sF.abort(),Y||v.timeoutMs);try{let h=await ZP(M,{...n,body:FF,headers:tF,method:F,signal:sF.signal});return clearTimeout(rF),c?.(h)||p?.(h)||h}catch(h){if(clearTimeout(rF),g=h,m>=K.maxRetries)return S?S(h):Promise.reject(h);await QP(zP(m,K))}}return S?S(g):Promise.reject(g)}}function JP(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function TP(F,$){let P=new URL(F);if($)P.search=new URLSearchParams($).toString();return P.toString()}var b={extend:(F)=>({extend:($)=>b.extend({...F,...$}),get:LF("GET",F),post:LF("POST",F)}),get:LF("GET"),post:LF("POST")};var L$={};q(L$,{initializeRPCUrlsWithFallback:()=>x$,getRPCUrl:()=>y});var j=require("@swapkit/types"),kF=require("ts-pattern");var G$={};q(G$,{wrapWithThrow:()=>A$,warnOnce:()=>D,getTHORNameCost:()=>H$,getMAYANameCost:()=>R$,getChainIdentifier:()=>B$});var QF=require("@swapkit/types");function H$(F){if(F<0)throw new X({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function R$(F){if(F<0)throw new X({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function A$(F,$){try{return F()}catch(P){if($)throw new X($,P);return}}function B$(F){switch(F){case QF.Chain.THORChain:return`${F}.RUNE`;case QF.Chain.Cosmos:return`${F}.ATOM`;case QF.Chain.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var N$=new Set;function D({condition:F,id:$,warning:P}){if(F){if(N$.has($))return;console.warn(P),N$.add($)}}function YP(F){return kF.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 X("helpers_chain_not_supported",{chain:F})})}function MP(F){return kF.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}${MP(F)}`,{body:JSON.stringify(YP(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var DF=new Map,XP=120000;async function y(F){let{isStagenet:$}=V.get("envs"),[P="",...N]=V.get("rpcUrls")[F];if(!P)throw D({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 X("helpers_chain_no_public_or_set_rpc_url",{chain:F});if($)return P;let H=DF.get(F);if(H&&Date.now()-H.timestamp<XP)return H.url;if(!await _$(F,P)){for(let A of N)if(await _$(F,A))return DF.set(F,{timestamp:Date.now(),url:A}),A}return DF.set(F,{timestamp:Date.now(),url:P}),P}function x$(F){D({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 Q$=[`${_.Chain.Maya}.MAYA`,`${_.Chain.Maya}.CACAO`,`${_.Chain.Ethereum}.THOR`,`${_.Chain.Ethereum}.vTHOR`,`${_.Chain.Kujira}.USK`,`${_.Chain.Ethereum}.FLIP`,`${_.Chain.Radix}.XRD`],z$=[_.Chain.Arbitrum,_.Chain.Aurora,_.Chain.Base,_.Chain.Ethereum,_.Chain.Optimism];async function jP(F){let{baseDecimal:$}=_.getChainConfig(_.Chain.Radix);try{let P=await y(_.Chain.Radix),{manager:N}=await b.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){return console.warn(`Failed to fetch Radix asset decimals for ${F}:`,P),$}}async function WP(F){try{let $=await y(_.Chain.Radix);return(await b.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((H)=>H.key==="symbol")?.value.typed.value||void 0}catch($){console.warn(`Failed to fetch Radix asset symbol for ${F}:`,$);return}}async function Z$({chain:F,address:$,methodHex:P,id:N}){let H=await y(F);return b.post(H,{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 qP(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 UP(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}=_.getChainConfig(F),N=$.toLowerCase();if($===""||!N.startsWith("0x"))return P;let H=await Z$({address:$,chain:F,id:2,methodHex:"0x313ce567"}).catch((A)=>{return console.warn(`Could not fetch decimals for ${$} on ${F}: ${A.message}`),{result:""}});return UP(H.result,P)}async function VP({chain:F,address:$}){let P=$.toLowerCase();if(P===""||!P.startsWith("0x"))return;let N=await Z$({address:$,chain:F,id:1,methodHex:"0x95d89b41"}).catch((B)=>{return console.warn(`Could not fetch symbol for ${$} on ${F}: ${B.message}`),{result:""}});return await qP(N.result)}function zF({chain:F,address:$}){let{baseDecimal:P}=_.getChainConfig(F);return $F.match(F).with(..._.EVMChains,async()=>{try{let{isAddress:N,getAddress:H}=await import("ethers");if(!N(H($.replace(/^0X/,"0x"))))return{decimals:P,ticker:void 0};let[B,A]=await Promise.all([VP({address:$,chain:F}),IP({address:$,chain:F})]);return{decimals:A,ticker:B}}catch(N){return console.warn(`Failed to fetch token info for ${$} on ${F}:`,N),{decimals:P,ticker:void 0}}}).with(_.Chain.Solana,async()=>{if(!$)return{decimals:P,ticker:void 0};try{let N=await fetch(`https://lite-api.jup.ag/tokens/v2/search?query=${$}`);if(N.ok){let H=await N.json(),B=Array.isArray(H)?H[0]:H;if(B)return{decimals:B.decimals??P,ticker:B.symbol||void 0}}}catch(N){console.warn(`Failed to fetch Solana token info for ${$}:`,N)}return{decimals:P,ticker:void 0}}).with(_.Chain.Tron,async()=>{if(!$)return{decimals:P,ticker:void 0};try{let{TronWeb:N}=await import("tronweb"),H=await y(_.Chain.Tron),A=await new N({fullHost:H,privateKey:"0000000000000000000000000000000000000000000000000000000000000001"}).contract().at($),[G,x]=await Promise.all([A.symbol().call().catch((z)=>{console.warn(`Could not fetch symbol for ${$} on Tron:`,z);return}),A.decimals().call().catch((z)=>{return console.warn(`Could not fetch decimals for ${$} on Tron:`,z),P})]);return{decimals:typeof x==="number"?x:Number(x||P),ticker:G||void 0}}catch(N){return console.warn(`Failed to fetch Tron token info for ${$}:`,N),{decimals:P,ticker:void 0}}}).with(_.Chain.Near,async()=>{if(!$)return{decimals:P,ticker:"UNKNOWN"};try{let{providers:N}=await import("near-api-js"),H=await y(_.Chain.Near),A=await new N.JsonRpcProvider({url:H}).query({account_id:$,args_base64:Buffer.from("{}").toString("base64"),finality:"final",method_name:"ft_metadata",request_type:"call_function"}),G=JSON.parse(Buffer.from(A.result).toString());return{decimals:G?.decimals||P,ticker:G?.symbol}}catch(N){return console.warn(`Failed to fetch Near token info for ${$}:`,N),{decimals:P,ticker:void 0}}}).with(_.Chain.Radix,async()=>{if(!$)return{decimals:P,ticker:void 0};try{let[N,H]=await Promise.all([WP($),jP($)]);return{decimals:H,ticker:N}}catch(N){return console.warn(`Failed to fetch Radix token info for ${$}:`,N),{decimals:P,ticker:void 0}}}).otherwise(async()=>({decimals:P,ticker:void 0}))}function ZF({chain:F,symbol:$}){return $F.match(F).with(...z$,()=>$==="ETH").with(_.Chain.Avalanche,()=>$==="AVAX").with(_.Chain.Berachain,()=>$==="BERA").with(_.Chain.BinanceSmartChain,()=>$==="BNB").with(_.Chain.Gnosis,()=>$==="XDAI").with(_.Chain.Maya,()=>$==="CACAO").with(_.Chain.Cosmos,()=>$==="ATOM").with(_.Chain.THORChain,()=>$==="RUNE").with(_.Chain.Tron,()=>$==="TRX").with(_.Chain.Radix,()=>`${F}.${$}`===r(F).identifier).otherwise(()=>$===F)}var r=(F)=>{let{baseDecimal:$}=_.getChainConfig(F);return $F.match(F.toUpperCase()).with(...z$,(N)=>({decimal:$,identifier:`${N}.ETH`})).with(_.Chain.THORChain,(N)=>({decimal:$,identifier:`${N}.RUNE`})).with(_.Chain.Cosmos,(N)=>({decimal:$,identifier:`${N}.ATOM`})).with(_.Chain.Maya,(N)=>({decimal:10,identifier:`${N}.CACAO`})).with(_.Chain.BinanceSmartChain,(N)=>({decimal:$,identifier:`${N}.BNB`})).with(_.Chain.Avalanche,(N)=>({decimal:$,identifier:`${N}.AVAX`})).with(_.Chain.Gnosis,(N)=>({decimal:$,identifier:`${N}.XDAI`})).with(_.Chain.Berachain,(N)=>({decimal:$,identifier:`${N}.BERA`})).with(_.Chain.Tron,(N)=>({decimal:$,identifier:`${N}.TRX`})).with(_.Chain.Solana,_.Chain.Chainflip,_.Chain.Kujira,_.Chain.Ripple,_.Chain.Polkadot,_.Chain.Near,..._.UTXOChains,(N)=>({decimal:$,identifier:`${N}.${N}`})).with(_.Chain.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(_.Chain.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(N)=>({decimal:6,identifier:N})).with("ETH.FLIP",()=>({decimal:_.getChainConfig(_.Chain.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:_.getChainConfig(_.Chain.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:_.getChainConfig(_.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 PF({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return $F.match(F).with(_.Chain.Radix,()=>$===_.Chain.Radix||`${F}.${$}`===r(F).identifier).with(_.Chain.Arbitrum,_.Chain.Optimism,_.Chain.Base,_.Chain.Aurora,()=>$===_.Chain.Ethereum).with(_.Chain.Cosmos,()=>$==="ATOM").with(_.Chain.BinanceSmartChain,()=>$==="BNB").with(_.Chain.Maya,()=>$==="CACAO").with(_.Chain.THORChain,()=>$==="RUNE").with(_.Chain.Tron,()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var i=(F)=>{let[$,...P]=F.split("."),N=F.includes("/"),H=P.join("."),B=H?.split("-"),A=B?.length?B.length===1?B[0]:B.slice(0,-1).join("-"):void 0;return{chain:$,symbol:H,synth:N,ticker:A}};async function J$(F){let{loadTokenLists:$}=await import("./tokens.cjs"),P=await $();for(let N of Object.values(P))for(let{identifier:H,chain:B,...A}of N.tokens){if("identifier"in F&&H===F.identifier)return H;if("address"in A&&"chain"in F&&B===F.chain&&A.address&&A.address.toLowerCase()===F.contract.toLowerCase())return H}return}var X$={};q(X$,{validateTNS:()=>M$,validateIdentifier:()=>JF});var Y$=["TERRA",...V.get("chains")];function JF(F=""){let $=F.toUpperCase(),[P]=$.split(".");if(Y$.includes(P))return!0;let[N]=$.split("/");if(Y$.includes(N))return!0;throw new X({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function M$(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var W$={};q(W$,{formatBigIntToSafeValue:()=>f,BigIntArithmetics:()=>k});var o=(F)=>10n**BigInt(F),NF=(F)=>Math.log10(Number.parseFloat(F.toString()));function f({value:F,bigIntDecimal:$=8,decimal:P=8}){if(P===0)return F.toString();let N=F<0n,H=F.toString().substring(N?1:0),B=P-(H.length-1);if(B>0)H="0".repeat(B)+H;let A=H.length-P,G=H.slice(-P);if(Number.parseInt(G[$]||"0",10)>=5)G=`${G.substring(0,$-1)}${(Number.parseInt(G[$-1]||"0",10)+1).toString()}`;else G=G.substring(0,$);return`${N?"-":""}${H.slice(0,A)}.${G}`.replace(/\.?0*$/,"")}function wP(F,$){if($===0n)throw Error("Cannot divide by zero");let P=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+P)/$;return(F-P)/$}class k{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new k({decimal:$,value:f({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:P}){return k.fromBigInt(F.getBaseValue("bigint")*o(P)/o($),P)}constructor(F){let $=SF(F),P=typeof F==="object";this.decimal=P?F.decimal:void 0,this.decimalMultiplier=P&&"decimalMultiplier"in F?F.decimalMultiplier:o(Math.max(j$(TF($)),this.decimal||0)),this.#H($)}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=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||NF(this.decimalMultiplier));switch(F){case"number":return Number(P);case"string":return P;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return P}}getBaseValue(F,$){let P=this.decimalMultiplier/o($||this.decimal||8),N=wP(this.bigIntValue,P);switch(F){case"number":return Number(N);case"string":return N.toString();case"bigint":return N;default:return N}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let P=SF(F),N=TF(P);if(N==="0"||N==="undefined")return 0n;return this.#N(N,$)}toSignificant(F=6){let[$,P]=this.getValue("string").split("."),N=$||"",H=P||"";if((Number.parseInt(N,10)?N.length+H.length:H.length)<=F)return this.getValue("string");if(N.length>=F)return N.slice(0,F).padEnd(N.length,"0");if(Number.parseInt(N,10))return`${N}.${H.slice(0,F-N.length)}`.padEnd(F-N.length,"0");let A=Number.parseInt(H,10),G=`${A}`.slice(0,F);return`0.${G.padStart(H.length-`${A}`.length+G.length,"0")}`}toFixed(F=6){let[$,P]=this.getValue("string").split("."),N=$||"",H=P||"";if(Number.parseInt(N,10))return`${N}.${H.slice(0,F)}`.padEnd(F,"0");let B=Number.parseInt(H,10),A=`${B}`.slice(0,F);return`0.${A.padStart(H.length-`${B}`.length+A.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),P=["","K","M","B","T","Q","Qi","S"],N=Math.floor(Math.log10(Math.abs($))/3),H=P[N];if(!H)return this.getValue("string");let B=10**(N*3);return`${($/B).toFixed(F)}${H}`}toCurrency(F="$",{currencyPosition:$="start",decimal:P=2,decimalSeparator:N=".",thousandSeparator:H=","}={}){let B=this.getValue("number"),[A="",G=""]=B.toFixed(6).split("."),x=A.replace(/\B(?=(\d{3})+(?!\d))/g,H),z=A||G?A==="0"?`${Number.parseFloat(`0.${G}`)}`.replace(".",N):`${x}${Number.parseInt(G,10)?`${N}${G.slice(0,P)}`:""}`:"0.00";return`${$==="start"?F:""}${z}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let P=$||this.decimal||8,N=Math.max(P,NF(this.decimalMultiplier)),H=F<0n,B=F.toString().substring(H?1:0),A=N-(B.length-1),G=A>0?"0".repeat(A)+B:B,x=G.length-N,z=G.slice(-N);if(Number.parseInt(z[P]||"0",10)>=5)z=`${z.substring(0,P-1)}${(Number.parseInt(z[P-1]||"0",10)+1).toString()}`;else z=z.substring(0,P);return`${H?"-":""}${G.slice(0,x)}.${z}`.replace(/\.?0*$/,"")}#$(F,...$){let P=this.#P(this,...$),N=Math.max(P,NF(this.decimalMultiplier)),H=o(N),B=$.reduce((G,x)=>{let z=this.getBigIntValue(x,N);switch(F){case"add":return G+z;case"sub":return G-z;case"mul":return G*z/H;case"div":{if(z===0n)throw RangeError("Division by zero");return G*H/z}default:return G}},this.bigIntValue*H/this.decimalMultiplier),A=f({bigIntDecimal:N,decimal:N,value:B});return new this.constructor({decimal:this.decimal,decimalMultiplier:o(N),identifier:this.toString(),value:A})}#F(F,...$){let P=this.#P(this,...$),N=this.getBigIntValue($[0]||"0",P),H=this.getBigIntValue(this,P);switch(F){case"gt":return H>N;case"gte":return H>=N;case"lt":return H<N;case"lte":return H<=N;case"eqValue":return H===N;default:return!1}}#H(F){let $=TF(F)||"0";this.bigIntValue=this.#N($)}#P(...F){let $=F.map((P)=>{return typeof P==="object"?P.decimal||NF(P.decimalMultiplier):j$(TF(P))}).filter(Boolean);return Math.max(...$,8)}#N(F,$){let P=$?o($):this.decimalMultiplier,N=NF(P),[H="",B=""]=F.split(".");return BigInt(`${H}${B.padEnd(N,"0")}`)}}var KP=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function TF(F){let P=`${typeof F==="number"?KP.format(F):SF(F)}`.replaceAll(",",".").split(".");return P.length>1?`${P.slice(0,-1).join("")}.${P.at(-1)}`:P[0]||"0"}function j$(F){let $=F.split(".")[1]?.length||0;return Math.max($,8)}function SF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var u=[J.Chain.Solana,J.Chain.Tron,J.Chain.Near],EF=[J.Chain.THORChain,J.Chain.Maya],HF=new Map,YF=new Map,a=new Map,OP=3600000;function DP(F){let $=a.get(F);if($?.timestamp&&Date.now()-$.timestamp>OP){a.delete(F);return}return $}function kP(F,$){if(a.size>1000){let P=a.keys().next().value;if(P)a.delete(P)}a.set(F,{...$,timestamp:Date.now()})}class d extends k{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:P,chain:N,symbol:H,identifier:B}){super(typeof F==="object"?F:{decimal:$,value:F});let A=U$(B||`${N}.${H}`);this.type=PF(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=J.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 HF.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 X({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let N=F.slice(0,P),H=F.slice(P+1),B=MF.match({chain:N,rest:H}).when(({rest:A})=>A.includes(".."),({chain:A,rest:G})=>`${A}.${G.replace(/\.\./g,"~")}`).when(({chain:A,rest:G})=>EF.includes(A)&&G.includes("."),({chain:A,rest:G})=>`${A}.${G.replace(/\./g,"/")}`).otherwise(({chain:A,rest:G})=>`${A}.${G.replace(/__/g,".")}`);return d.from({asset:B,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:P,...N}){let H=F instanceof k?F.getValue("string"):F,B=gP(N),A=B.includes(":");if(P&&A){let[FF,g]=B.split(":");return(async()=>{let m=await q$({address:g,chain:FF});return vF({decimal:m.decimals,identifier:m.identifier,value:$?e(BigInt(H),$):H})})()}let G=A?B.split(":").join(".UNKNOWN-"):B,{identifier:x,decimal:z}=r(G),{chain:W,isSynthetic:Y,isTradeAsset:C,address:S}=U$(x),{baseDecimal:c}=J.getChainConfig(W),p=HF.get(u.includes(W)?x:x.toUpperCase());if(!p&&P&&!Y&&!C)return(async()=>{let{ticker:FF}=i(x),g=await q$({address:S,chain:W,ticker:FF});return vF({decimal:g.decimals,identifier:g.identifier,value:$?e(BigInt(H),$):H})})();let n=p?.decimal||z;D({condition:!n&&!P,id:`assetValue_static_decimal_not_found_${W}`,warning:`Couldn't find static decimal for one or more tokens on ${W} (Using default ${c} decimal as fallback).
|
|
2
2
|
This can result in incorrect calculations and mess with amount sent on transactions.
|
|
3
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:m,identifier:y,tax:h}=f||{decimal:O||J,identifier:B},D=$?M0(BigInt(N),$):M0(N,m);return A?V$(y,$?D:N):M||j?U$(y,D):new g({decimal:m,identifier:y,tax:h,value:D})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),A=await $(F);for(let{tokens:R}of Object.values(A))for(let{identifier:N,chain:H,...B}of R){let _=Y.getChainConfig(H),G=L0.includes(_.chain)?N:N.toUpperCase(),M="decimals"in B?B.decimals:_.baseDecimal;d.set(G,{decimal:M,identifier:N})}return!0}static setStaticAssets(F){d.clear();for(let[$,A]of F.entries()){let R=L0.includes(A.chain)?A.identifier:A.identifier.toUpperCase(),N="decimals"in A?A.decimals:A.decimal;d.set($,{...A,decimal:N,identifier:R})}return!0}}function IF(F){let $=g.from({chain:F});return Z0.match(F).with(Y.Chain.Bitcoin,Y.Chain.Litecoin,Y.Chain.BitcoinCash,Y.Chain.Dash,()=>$.set(0.00010001)).with(Y.Chain.Dogecoin,()=>$.set(1.00000001)).with(Y.Chain.Avalanche,Y.Chain.Ethereum,Y.Chain.Arbitrum,Y.Chain.BinanceSmartChain,()=>$.set(0.00000001)).with(Y.Chain.THORChain,Y.Chain.Maya,()=>$.set(0)).with(Y.Chain.Cosmos,Y.Chain.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function V$(F,$=0){G0(F);let R=F.includes("SOL.")?F:F.toUpperCase(),N=d.get(R),H=N?.decimal||await T0(v0(F));if(!N)d.set(R,{decimal:H,identifier:F});return new g({decimal:H,identifier:F,value:M0($,H)})}function U$(F,$=0){let A=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,R=A?E0.includes(A):!1,N=F.slice(0,14).includes("~")?"~":"/",[H,B]=R?F.split(".").slice(1).join().split(N):F.split(N);if(!(H&&B))throw new I({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new g({decimal:8,identifier:`${A||Y.Chain.THORChain}.${H}${N}${B}`,value:M0($,8)})}function M0(F,$){return typeof F==="bigint"?b({bigIntDecimal:$,decimal:$,value:F}):F}function k$(F){let $=Z0.match(F).when((A)=>("chain"in A)&&A.chain!==void 0,({chain:A})=>A).otherwise((A)=>{let R=r(A.asset);return R.synth?Y.Chain.THORChain:R.chain});if(!Object.values(Y.Chain).includes($.toUpperCase()))throw new I({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function K$(F){if(k$(F),"chain"in F)return F.chain;let{chain:$,symbol:A}=r(F.asset);return t({chain:$,symbol:A})==="Native"?$:F.asset}function w$(F,$,A){let R=F.split("."),N=R[0]?.toUpperCase(),H=E0.includes(N),B=A?"~":"/",[_,G=""]=H?R.slice(1).join(".").split(B):F.split(B);if(!(_&&G))throw new I({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:M,address:j}=jF({chain:_,symbol:G}),J=`${_}${B}${G}`;return{address:j,chain:N,isGasAsset:!1,isSynthetic:$,isTradeAsset:A,symbol:J,ticker:M}}function O$(F){let $=F.indexOf("."),A=($===-1?F:F.slice(0,$)).toUpperCase(),R=$===-1?F:F.slice($+1),{address:N,ticker:H}=jF({chain:A,symbol:R}),B;try{B=N&&Y.EVMChains.includes(A)&&S0.getAddress(N)?S0.getAddress(N):N}catch(G){B=N}let _=B?`${H}-${B}`:R;return{address:B,chain:A,isGasAsset:_0({chain:A,symbol:R}),isSynthetic:!1,isTradeAsset:!1,symbol:_,ticker:H}}function v0(F){let $=F.slice(0,14),A=$.includes("/"),R=$.includes("~");if(A||R)return w$(F,A,R);return O$(F)}function D$(F,$=!1){let A=$?F.indexOf("-"):F.lastIndexOf("-");if(A===-1)return{address:void 0,ticker:F};let R=F.slice(0,A);return{address:F.slice(A+1),ticker:R}}function jF({symbol:F,chain:$}){let{ticker:A,address:R}=D$(F,$===Y.Chain.Near);return{address:R&&!L0.includes($)?R.toLowerCase():R,ticker:A}}var UF={};W(UF,{getFeeMultiplierAsBigInt:()=>g0,getFeeMultiplier:()=>z0,applyFeeMultiplierToBigInt:()=>qF,applyFeeMultiplier:()=>VF,DEFAULT_FEE_MULTIPLIERS:()=>b0});var b0={average:1,fast:1.5,fastest:2};function z0(F="average"){let $=k.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return b0[F]}function g0(F="average"){let $=z0(F),A=10n,R=BigInt(Math.round($*10));return{denominator:A,numerator:R}}function qF(F,$="average"){let{numerator:A,denominator:R}=g0($);return F*A/R}function VF(F,$="average",A=!1){let R=z0($),N=F*R;return A?Math.floor(N):N}var kF={};W(kF,{SwapKitNumber:()=>K});class K extends w{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new K({decimal:$,value:b({bigIntDecimal:$,decimal:$,value:F})})}}var DF={};W(DF,{updateDerivationPath:()=>a,getWalletFormatFor:()=>wF,getDerivationPathFor:()=>KF,derivationPathToString:()=>f0,DerivationPath:()=>OF});var e=require("@swapkit/types");function a(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[A,R,N,,H]=F;return[A,R,N,$.change,H]}if("account"in $){let[A,R,,N,H]=F;return[A,R,$.account,N,H]}return F}function f0([F,$,A,R,N]){let H=typeof N!=="number";if(typeof R!=="number")return`m/${F}'/${$}'/${A}'`;return`m/${F}'/${$}'/${A}'/${R}${H?"":`/${N}`}`}function KF({chain:F,index:$,addressIndex:A=0,type:R}){if(e.EVMChains.includes(F)){if(R&&["legacy","account"].includes(R))return[44,60,0,$];if(R==="ledgerLive")return[44,60,$,0,A];return a(v[F],{index:$})}if(F===e.Chain.Solana){if(R==="account")return[44,501,0,$];return a(v[F],{index:$})}let N=F===e.Chain.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,N,$,0,A];case"segwit":return[49,N,0,0,$];case"legacy":return[44,N,0,0,$];default:return a(v[F],{index:$})}}function wF(F){let[$,A,R]=F.split("/").map((N)=>Number.parseInt(N,10));switch(A){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var OF=Object.keys(v).reduce((F,$)=>{return F[$]=f0(v[$]),F},{});var EF={};W(EF,{getExplorerTxUrl:()=>SF,getExplorerAddressUrl:()=>vF});var Z=require("@swapkit/types"),y0=require("ts-pattern");function SF({chain:F,txHash:$}){let{explorerUrl:A}=Z.getChainConfig(F);return y0.match(F).with(Z.Chain.Maya,Z.Chain.Kujira,Z.Chain.Noble,Z.Chain.Cosmos,Z.Chain.THORChain,Z.Chain.Harbor,Z.Chain.Solana,()=>`${A}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(Z.Chain.Arbitrum,Z.Chain.Aurora,Z.Chain.Avalanche,Z.Chain.BinanceSmartChain,Z.Chain.Base,Z.Chain.Berachain,Z.Chain.Ethereum,Z.Chain.Gnosis,Z.Chain.Optimism,Z.Chain.Polkadot,Z.Chain.Polygon,()=>`${A}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(Z.Chain.Litecoin,Z.Chain.Bitcoin,Z.Chain.BitcoinCash,Z.Chain.Dogecoin,Z.Chain.Zcash,Z.Chain.Radix,()=>`${A}/transaction/${$.toLowerCase()}`).with(Z.Chain.Near,()=>`${A}/txns/${$}`).with(Z.Chain.Ripple,()=>`${A}/transactions/${$}`).with(Z.Chain.Tron,()=>`${A}/#/transaction/${$}`).otherwise(()=>"")}function vF({chain:F,address:$}){let{explorerUrl:A}=Z.getChainConfig(F);return y0.match(F).with(Z.Chain.Solana,Z.Chain.Radix,()=>`${A}/account/${$}`).with(Z.Chain.Tron,()=>`${A}/#/address/${$}`).otherwise(()=>`${A}/address/${$}`)}var pF={};W(pF,{getSymmetricWithdraw:()=>fF,getSymmetricPoolShare:()=>d0,getLiquiditySlippage:()=>uF,getEstimatedPoolShare:()=>yF,getAsymmetricRuneWithdrawAmount:()=>bF,getAsymmetricRuneShare:()=>u0,getAsymmetricAssetWithdrawAmount:()=>gF,getAsymmetricAssetShare:()=>p0});var Y0=require("@swapkit/types");function u0({liquidityUnits:F,poolUnits:$,runeDepth:A}){let R=V(F),N=V($),H=V(A),B=R.mul(H),_=N.mul(N).mul(2),G=N.mul(R).mul(2),M=R.mul(R),j=N.mul(N).mul(N);return B.mul(_.sub(G).add(M)).div(j)}function p0({liquidityUnits:F,poolUnits:$,assetDepth:A}){let R=V(F),N=V($),H=V(A),B=R.mul(H),_=N.mul(N).mul(2),G=N.mul(R).mul(2),M=R.mul(R),j=B.mul(_.sub(G).add(M)),J=N.mul(N).mul(N);return j.div(J)}function bF({percent:F,runeDepth:$,liquidityUnits:A,poolUnits:R}){return u0({liquidityUnits:A,poolUnits:R,runeDepth:$}).mul(F)}function gF({percent:F,assetDepth:$,liquidityUnits:A,poolUnits:R}){return p0({assetDepth:$,liquidityUnits:A,poolUnits:R}).mul(F)}function V(F){return K.fromBigInt(BigInt(F),Y0.getChainConfig(Y0.Chain.THORChain).baseDecimal)}function d0({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R}){return{assetAmount:V(R).mul(F).div($),runeAmount:V(A).mul(F).div($)}}function fF({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R,percent:N}){return Object.fromEntries(Object.entries(d0({assetDepth:R,liquidityUnits:F,poolUnits:$,runeDepth:A})).map(([H,B])=>[H,B.mul(N)]))}function yF({runeDepth:F,poolUnits:$,assetDepth:A,liquidityUnits:R,runeAmount:N,assetAmount:H}){let B=new K({decimal:8,value:F}),_=new K({decimal:8,value:A}),G=new K({decimal:8,value:$}),M=new K({decimal:8,value:N}),j=new K({decimal:8,value:H}),J=M.mul(_),f=j.mul(B),O=M.mul(j),m=B.mul(_),y=G.mul(J.add(f.add(O.mul(2)))),h=J.add(f.add(m.mul(2))),D=y.div(h),S=V(R).add(D);if(D.getBaseValue("number")===0)return S.div(G).getBaseValue("number");let X=G.add(S);return S.div(X).getBaseValue("number")}function uF({runeAmount:F,assetAmount:$,runeDepth:A,assetDepth:R}){if(F==="0"||$==="0"||A==="0"||R==="0")return 0;let N=V(A),H=V(R),B=V($),_=V(F),G=B.mul(N).sub(H.mul(_)),M=H.mul(_).add(N.mul(H));return Math.abs(G.div(M).getBaseValue("number"))}var iF={};W(iF,{getMemoForWithdraw:()=>hF,getMemoForUnbond:()=>CF,getMemoForTcyStake:()=>rF,getMemoForTcyClaim:()=>tF,getMemoForRunePoolWithdraw:()=>lF,getMemoForRunePoolDeposit:()=>oF,getMemoForNameRegister:()=>nF,getMemoForNamePreferredAssetRegister:()=>sF,getMemoForLeaveAndBond:()=>mF,getMemoForDeposit:()=>cF});var F0=require("@swapkit/types"),dF=require("ts-pattern");function mF({type:F,address:$}){return`${F}:${$}`}function CF({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function oF(F){return J0("POOL+",F)}function cF({chain:F,symbol:$,address:A,...R}){let N=S$({chain:F,symbol:$}),H=A?`:${A}:`:":";return J0(`${"+"}:${N}${H}`,R)}function hF({chain:F,symbol:$,ticker:A,basisPoints:R,targetAsset:N}){let H=F==="ETH"&&A!=="ETH"?`${A}-${$.slice(-3)}`:$,B=N?`:${N}`:"";return`${"-"}:${F}.${H}:${R}${B}`}function lF({basisPoints:F,...$}){return J0(`${"POOL-"}:${F}`,$)}function nF({name:F,chain:$,address:A,owner:R}){let N=`${"~"}:${F}:${$}:${A}`,H=R?`:${R}`:"";return`${N}${H}`}function sF({name:F,chain:$,asset:A,payout:R,owner:N}){return`${"~"}:${F}:${$}:${R}:${N}:${A}`}function tF(F,{address:$}){return`${F}:${$}`}function rF(F,{unstakeBps:$,...A}){let R=$?`:${$}`:"",N=`${F}${R}`;return J0(`${N}`,A)}function J0(F,{affiliateAddress:$,affiliateBasisPoints:A}={}){let R=`${F}${$?`:${$}:${A||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function S$({chain:F,symbol:$}){return dF.match(F).with(F0.Chain.Bitcoin,F0.Chain.Dogecoin,F0.Chain.Litecoin,()=>F.slice(0,1).toLowerCase()).with(F0.Chain.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}var P$={};W(P$,{wrapMethodWithNetworkSwitch:()=>c0,switchEVMWalletNetwork:()=>o0,providerRequest:()=>X0,prepareNetworkSwitch:()=>$$,okxMobileEnabled:()=>l0,listWeb3EVMWallets:()=>C0,isWeb3Detected:()=>aF,isDetected:()=>eF,getETHDefaultWallet:()=>R$,getEIP6963Wallets:()=>N$,filterSupportedChains:()=>F$,addEVMWalletNetwork:()=>h0,addAccountsChangedCallback:()=>A$});var m0=require("@swapkit/types");function aF(){return typeof window.ethereum<"u"}function eF(F){return C0().includes(F)}function C0(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,A=window?.vultisig,R=window?.ethereum?.isBraveWallet,N=window?.ethereum?.isTrust||window?.trustwallet,H=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,B=window?.bitkeep?.ethereum,_=window?.$onekey?.ethereum,G=[];if(F)G.push("METAMASK");if($)G.push("CTRL");if(A)G.push("VULTISIG");if(R)G.push("BRAVE");if(N)G.push("TRUSTWALLET_WEB");if(H)G.push("COINBASE_WEB");if(l0())G.push("OKX_MOBILE");if(B)G.push("BITGET");if(_)G.push("ONEKEY");return G}async function o0(F,$,A){let R=m0.getChainConfig($);try{await X0({method:"wallet_switchEthereumChain",params:[{chainId:R.chainIdHex}],provider:F})}catch(N){if(!A)throw new I("helpers_failed_to_switch_network",{error:N,reason:"networkParams not provided"});await h0(F,A)}}function F$({chains:F,supportedChains:$,walletType:A}){let R=F.filter((H)=>!H||$.includes(H));if(R.length===0)throw new I("wallet_chain_not_supported",{chain:F.join(", "),wallet:A});let N=F.filter((H)=>!$.includes(H));return E({condition:N.length>0,id:`wallet_chain_not_supported_${A}`,warning:`${A} wallet does not support the following chains: ${N.join(", ")}. These chains will be ignored.`}),R}function c0(F,$,A){return async(...R)=>{let{chainIdHex:N}=m0.getChainConfig(A);if((await $.getNetwork()).chainId.toString()===N)return F(...R);try{await o0($,A)}catch(H){throw new I({errorKey:"helpers_failed_to_switch_network",info:{error:H}})}return F(...R)}}function $$({toolbox:F,chain:$,provider:A=window.ethereum,methodNames:R=[]}){let H=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((B,_)=>{if(!F[_])return B;let G=F[_];if(typeof G!=="function")return B;let M=c0(G,A,$);return{...B,[_]:M}},{});return{...F,...H}}function h0(F,$){return X0({method:"wallet_addEthereumChain",params:[$],provider:F})}function A$(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function R$(){let{isTrust:F,isBraveWallet:$,__XDEFI:A,overrideIsMetaMask:R,selectedProvider:N}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(R&&N?.isCoinbaseWallet)return"COINBASE_WEB";if(A)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function N$(){let F=[];function $(R){if(F.map((N)=>N.info.uuid).includes(R.detail.info.uuid))return;F.push(R.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function A(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:A}}function l0(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),A=/android|XiaoMi|MiuiBrowser/i.test(F),R=$||A,N=/OKApp/i.test(F);return R&&N}function X0({provider:F,params:$,method:A}){if(!F?.send)throw new I("helpers_not_found_provider");let R=$?Array.isArray($)?$:[$]:[];return F.send(A,R)}
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`});let{decimal:v,identifier:K,tax:l}=p||{decimal:n||c,identifier:x},M=$?e(BigInt(H),$):e(H,v);return Y||C?SP(K,M):vF({decimal:v,identifier:K,tax:l,value:M})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),P=await $(F);for(let{tokens:N}of Object.values(P))for(let{identifier:H,chain:B,...A}of N){let G=J.getChainConfig(B),x=u.includes(G.chain)?H:H.toUpperCase(),W={decimal:"decimals"in A?A.decimals:G.baseDecimal,identifier:H,logoURI:"logoURI"in A?A.logoURI:void 0,tax:"tax"in A?A.tax:void 0};if(HF.set(x,W),"address"in A&&A.address){let Y=u.includes(G.chain)?`${G.chain}:${A.address}`:`${G.chain}:${A.address.toUpperCase()}`;YF.set(Y,H)}}return!0}static setStaticAssets(F){HF.clear(),YF.clear();for(let[$,P]of F.entries()){let N=u.includes(P.chain)?P.identifier:P.identifier.toUpperCase(),H="decimals"in P?P.decimals:P.decimal,B={...P,decimal:H,identifier:N};if(HF.set($,B),P.address){let A=u.includes(P.chain)?`${P.chain}:${P.address}`:`${P.chain}:${P.address.toUpperCase()}`;YF.set(A,P.identifier)}}return!0}}function I$(F){let $=d.from({chain:F});return MF.match(F).with(J.Chain.Bitcoin,J.Chain.Litecoin,J.Chain.BitcoinCash,J.Chain.Dash,()=>$.set(0.00010001)).with(J.Chain.Dogecoin,()=>$.set(1.00000001)).with(J.Chain.Avalanche,J.Chain.Ethereum,J.Chain.Arbitrum,J.Chain.BinanceSmartChain,()=>$.set(0.00000001)).with(J.Chain.THORChain,J.Chain.Maya,()=>$.set(0)).with(J.Chain.Cosmos,J.Chain.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function q$({chain:F,address:$,ticker:P}){let H=u.includes(F)?`${F}:${$||P}`:`${F}:${$||P}`.toUpperCase(),B=DP(H);if(B)return B;if(!$){let{baseDecimal:x}=J.getChainConfig(F);return{decimals:x,identifier:`${F}.${P||"UNKNOWN"}`}}let A=await zF({address:$,chain:F}),G=`${F}.${A.ticker||P||"UNKNOWN"}-${$}`;return D({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&&kP(H,{decimals:A.decimals,identifier:G}),{decimals:A.decimals,identifier:G}}function vF({identifier:F,decimal:$,value:P,tax:N}){return JF(F),new d({decimal:$,identifier:F,tax:N,value:e(P,$)})}function SP(F,$=0){let P=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,N=P?EF.includes(P):!1,H=F.slice(0,14).includes("~")?"~":"/",[B,A]=N?F.split(".").slice(1).join().split(H):F.split(H);if(!(B&&A))throw new X({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new d({decimal:8,identifier:`${P||J.Chain.THORChain}.${B}${H}${A}`,value:e($,8)})}function e(F,$){return typeof F==="bigint"?f({bigIntDecimal:$,decimal:$,value:F}):F}function vP(F){let $=MF.match(F).when((P)=>("chain"in P)&&P.chain!==void 0,({chain:P})=>P).otherwise((P)=>{let N=i(P.asset);return N.synth?J.Chain.THORChain:N.chain});if(!J.AllChains.includes($.toUpperCase()))throw new X({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function gP(F){if(vP(F),"chain"in F){let{chain:H,address:B}=F;if(B){let A=u.includes(H)?`${H}:${B}`:`${H}:${B.toUpperCase()}`,G=YF.get(A);if(G)return G;return A}return H}let{chain:$,symbol:P}=i(F.asset);return PF({chain:$,symbol:P})==="Native"?$:F.asset}function EP(F,$,P){let N=F.split("."),H=N[0]?.toUpperCase(),B=EF.includes(H),A=P?"~":"/",[G,x=""]=B?N.slice(1).join(".").split(A):F.split(A);if(!(G&&x))throw new X({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:z,address:W}=V$({chain:G,symbol:x}),Y=`${G}${A}${x}`;return{address:W,chain:H,isGasAsset:!1,isSynthetic:$,isTradeAsset:P,symbol:Y,ticker:z}}function bP(F){let $=F.indexOf("."),P=($===-1?F:F.slice(0,$)).toUpperCase(),N=$===-1?F:F.slice($+1),{address:H,ticker:B}=V$({chain:P,symbol:N}),A;try{A=H&&J.EVMChains.includes(P)&&gF.getAddress(H)?gF.getAddress(H):H}catch{A=H}let G=A?`${B}-${A}`:N;return{address:A,chain:P,isGasAsset:ZF({chain:P,symbol:N}),isSynthetic:!1,isTradeAsset:!1,symbol:G,ticker:B}}function U$(F){let $=F.slice(0,14),P=$.includes("/"),N=$.includes("~");if(P||N)return EP(F,P,N);return bP(F)}function yP(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 V$({symbol:F,chain:$}){let{ticker:P,address:N}=yP(F,$===J.Chain.Near);return{address:N&&!u.includes($)?N.toLowerCase():N,ticker:P}}var D$={};q(D$,{getFeeMultiplierAsBigInt:()=>yF,getFeeMultiplier:()=>XF,applyFeeMultiplierToBigInt:()=>K$,applyFeeMultiplier:()=>O$,DEFAULT_FEE_MULTIPLIERS:()=>bF});var bF={average:1,fast:1.5,fastest:2};function XF(F="average"){let $=V.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return bF[F]}function yF(F="average"){let $=XF(F),P=10n,N=BigInt(Math.round($*10));return{denominator:P,numerator:N}}function K$(F,$="average"){let{numerator:P,denominator:N}=yF($);return F*P/N}function O$(F,$="average",P=!1){let N=XF($),H=F*N;return P?Math.floor(H):H}var k$={};q(k$,{SwapKitNumber:()=>w});class w extends k{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new w({decimal:$,value:f({bigIntDecimal:$,decimal:$,value:F})})}}var E$={};q(E$,{updateDerivationPath:()=>RF,getWalletFormatFor:()=>v$,getDerivationPathFor:()=>S$,derivationPathToString:()=>fF,DerivationPath:()=>g$});var AF=require("@swapkit/types");function RF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[P,N,H,,B]=F;return[P,N,H,$.change,B]}if("account"in $){let[P,N,,H,B]=F;return[P,N,$.account,H,B]}return F}function fF([F,$,P,N,H]){let B=typeof H!=="number";if(typeof N!=="number")return`m/${F}'/${$}'/${P}'`;return`m/${F}'/${$}'/${P}'/${N}${B?"":`/${H}`}`}function S$({chain:F,index:$,addressIndex:P=0,type:N}){if(AF.EVMChains.includes(F)){if(N&&["legacy","account"].includes(N))return[44,60,0,$];if(N==="ledgerLive")return[44,60,$,0,P];return RF(E[F],{index:$})}if(F===AF.Chain.Solana){if(N==="account")return[44,501,0,$];return RF(E[F],{index:$})}let H=F===AF.Chain.Litecoin?2:0;switch(N){case"nativeSegwitMiddleAccount":return[84,H,$,0,P];case"segwit":return[49,H,0,0,$];case"legacy":return[44,H,0,0,$];default:return RF(E[F],{index:$})}}function v$(F){let[$,P,N]=F.split("/").map((H)=>Number.parseInt(H,10));switch(P){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var g$=Object.keys(E).reduce((F,$)=>{return F[$]=fF(E[$]),F},{});var f$={};q(f$,{getExplorerTxUrl:()=>b$,getExplorerAddressUrl:()=>y$});var Z=require("@swapkit/types"),uF=require("ts-pattern");function b$({chain:F,txHash:$}){let{explorerUrl:P}=Z.getChainConfig(F);return uF.match(F).with(Z.Chain.Maya,Z.Chain.Kujira,Z.Chain.Noble,Z.Chain.Cosmos,Z.Chain.THORChain,Z.Chain.Harbor,Z.Chain.Solana,()=>`${P}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(Z.Chain.Arbitrum,Z.Chain.Aurora,Z.Chain.Avalanche,Z.Chain.BinanceSmartChain,Z.Chain.Base,Z.Chain.Berachain,Z.Chain.Ethereum,Z.Chain.Gnosis,Z.Chain.Optimism,Z.Chain.Polkadot,Z.Chain.Polygon,()=>`${P}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(Z.Chain.Litecoin,Z.Chain.Bitcoin,Z.Chain.BitcoinCash,Z.Chain.Dogecoin,Z.Chain.Zcash,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 y$({chain:F,address:$}){let{explorerUrl:P}=Z.getChainConfig(F);return uF.match(F).with(Z.Chain.Solana,Z.Chain.Sui,Z.Chain.Radix,()=>`${P}/account/${$}`).otherwise(()=>`${P}/address/${$}`)}var o$={};q(o$,{getSymmetricWithdraw:()=>p$,getSymmetricPoolShare:()=>mF,getLiquiditySlippage:()=>h$,getEstimatedPoolShare:()=>m$,getAsymmetricRuneWithdrawAmount:()=>u$,getAsymmetricRuneShare:()=>CF,getAsymmetricAssetWithdrawAmount:()=>C$,getAsymmetricAssetShare:()=>pF});var jF=require("@swapkit/types");function CF({liquidityUnits:F,poolUnits:$,runeDepth:P}){let N=U(F),H=U($),B=U(P),A=N.mul(B),G=H.mul(H).mul(2),x=H.mul(N).mul(2),z=N.mul(N),W=H.mul(H).mul(H);return A.mul(G.sub(x).add(z)).div(W)}function pF({liquidityUnits:F,poolUnits:$,assetDepth:P}){let N=U(F),H=U($),B=U(P),A=N.mul(B),G=H.mul(H).mul(2),x=H.mul(N).mul(2),z=N.mul(N),W=A.mul(G.sub(x).add(z)),Y=H.mul(H).mul(H);return W.div(Y)}function u$({percent:F,runeDepth:$,liquidityUnits:P,poolUnits:N}){return CF({liquidityUnits:P,poolUnits:N,runeDepth:$}).mul(F)}function C$({percent:F,assetDepth:$,liquidityUnits:P,poolUnits:N}){return pF({assetDepth:$,liquidityUnits:P,poolUnits:N}).mul(F)}function U(F){return w.fromBigInt(BigInt(F),jF.getChainConfig(jF.Chain.THORChain).baseDecimal)}function mF({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N}){return{assetAmount:U(N).mul(F).div($),runeAmount:U(P).mul(F).div($)}}function p$({liquidityUnits:F,poolUnits:$,runeDepth:P,assetDepth:N,percent:H}){return Object.fromEntries(Object.entries(mF({assetDepth:N,liquidityUnits:F,poolUnits:$,runeDepth:P})).map(([B,A])=>[B,A.mul(H)]))}function m$({runeDepth:F,poolUnits:$,assetDepth:P,liquidityUnits:N,runeAmount:H,assetAmount:B}){let A=new w({decimal:8,value:F}),G=new w({decimal:8,value:P}),x=new w({decimal:8,value:$}),z=new w({decimal:8,value:H}),W=new w({decimal:8,value:B}),Y=z.mul(G),C=W.mul(A),S=z.mul(W),c=A.mul(G),p=x.mul(Y.add(C.add(S.mul(2)))),n=Y.add(C.add(c.mul(2))),v=p.div(n),K=U(N).add(v);if(v.getBaseValue("number")===0)return K.div(x).getBaseValue("number");let l=x.add(K);return K.div(l).getBaseValue("number")}function h$({runeAmount:F,assetAmount:$,runeDepth:P,assetDepth:N}){if(F==="0"||$==="0"||P==="0"||N==="0")return 0;let H=U(P),B=U(N),A=U($),G=U(F),x=A.mul(H).sub(B.mul(G)),z=B.mul(G).add(H.mul(B));return Math.abs(x.div(z).getBaseValue("number"))}var $P={};q($P,{getMemoForWithdraw:()=>s$,getMemoForUnbond:()=>n$,getMemoForTcyStake:()=>FP,getMemoForTcyClaim:()=>e$,getMemoForRunePoolWithdraw:()=>r$,getMemoForRunePoolDeposit:()=>l$,getMemoForNameRegister:()=>i$,getMemoForNamePreferredAssetRegister:()=>a$,getMemoForLeaveAndBond:()=>c$,getMemoForDeposit:()=>t$});var BF=require("@swapkit/types"),d$=require("ts-pattern");function c$({type:F,address:$}){return`${F}:${$}`}function n$({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function l$(F){return WF("POOL+",F)}function t$({chain:F,symbol:$,address:P,...N}){let H=fP({chain:F,symbol:$}),B=P?`:${P}:`:":";return WF(`${"+"}:${H}${B}`,N)}function s$({chain:F,symbol:$,ticker:P,basisPoints:N,targetAsset:H}){let B=F==="ETH"&&P!=="ETH"?`${P}-${$.slice(-3)}`:$,A=H?`:${H}`:"";return`${"-"}:${F}.${B}:${N}${A}`}function r$({basisPoints:F,...$}){return WF(`${"POOL-"}:${F}`,$)}function i$({name:F,chain:$,address:P,owner:N}){let H=`${"~"}:${F}:${$}:${P}`,B=N?`:${N}`:"";return`${H}${B}`}function a$({name:F,chain:$,asset:P,payout:N,owner:H}){return`${"~"}:${F}:${$}:${N}:${H}:${P}`}function e$(F,{address:$}){return`${F}:${$}`}function FP(F,{unstakeBps:$,...P}){let N=$?`:${$}`:"",H=`${F}${N}`;return WF(`${H}`,P)}function WF(F,{affiliateAddress:$,affiliateBasisPoints:P}={}){let N=`${F}${$?`:${$}:${P||0}`:""}`;return N.endsWith(":")?N.slice(0,-1):N}function fP({chain:F,symbol:$}){return d$.match(F).with(BF.Chain.Bitcoin,BF.Chain.Dogecoin,BF.Chain.Litecoin,()=>F.slice(0,1).toLowerCase()).with(BF.Chain.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}var _P={};q(_P,{wrapMethodWithNetworkSwitch:()=>cF,switchEVMWalletNetwork:()=>dF,providerRequest:()=>qF,prepareNetworkSwitch:()=>RP,okxMobileEnabled:()=>lF,listWeb3EVMWallets:()=>oF,isWeb3Detected:()=>PP,isDetected:()=>NP,getETHDefaultWallet:()=>BP,getEIP6963Wallets:()=>GP,filterSupportedChains:()=>HP,addEVMWalletNetwork:()=>nF,addAccountsChangedCallback:()=>AP});var hF=require("@swapkit/types");function PP(){return typeof window.ethereum<"u"}function NP(F){return oF().includes(F)}function oF(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,P=window?.vultisig,N=window?.ethereum?.isBraveWallet,H=window?.ethereum?.isTrust||window?.trustwallet,B=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,G=window?.$onekey?.ethereum,x=[];if(F)x.push("METAMASK");if($)x.push("CTRL");if(P)x.push("VULTISIG");if(N)x.push("BRAVE");if(H)x.push("TRUSTWALLET_WEB");if(B)x.push("COINBASE_WEB");if(lF())x.push("OKX_MOBILE");if(A)x.push("BITGET");if(G)x.push("ONEKEY");return x}async function dF(F,$,P){let N=hF.getChainConfig($);try{await qF({method:"wallet_switchEthereumChain",params:[{chainId:N.chainIdHex}],provider:F})}catch(H){if(!P)throw new X("helpers_failed_to_switch_network",{error:H,reason:"networkParams not provided"});await nF(F,P)}}function HP({chains:F,supportedChains:$,walletType:P}){let N=F.filter((B)=>!B||$.includes(B));if(N.length===0)throw new X("wallet_chain_not_supported",{chain:F.join(", "),wallet:P});let H=F.filter((B)=>!$.includes(B));return D({condition:H.length>0,id:`wallet_chain_not_supported_${P}`,warning:`${P} wallet does not support the following chains: ${H.join(", ")}. These chains will be ignored.`}),N}function cF(F,$,P){return async(...N)=>{let{chainIdHex:H}=hF.getChainConfig(P);if((await $.getNetwork()).chainId.toString()===H)return F(...N);try{await dF($,P)}catch(B){throw new X({errorKey:"helpers_failed_to_switch_network",info:{error:B}})}return F(...N)}}function RP({toolbox:F,chain:$,provider:P=window.ethereum,methodNames:N=[]}){let B=[...N,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((A,G)=>{if(!F[G])return A;let x=F[G];if(typeof x!=="function")return A;let z=cF(x,P,$);return{...A,[G]:z}},{});return{...F,...B}}function nF(F,$){return qF({method:"wallet_addEthereumChain",params:[$],provider:F})}function AP(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function BP(){let{isTrust:F,isBraveWallet:$,__XDEFI:P,overrideIsMetaMask:N,selectedProvider:H}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(N&&H?.isCoinbaseWallet)return"COINBASE_WEB";if(P)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function GP(){let F=[];function $(N){if(F.map((H)=>H.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 lF(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),P=/android|XiaoMi|MiuiBrowser/i.test(F),N=$||P,H=/OKApp/i.test(F);return N&&H}function qF({provider:F,params:$,method:P}){if(!F?.send)throw new X("helpers_not_found_provider");let N=$?Array.isArray($)?$:[$]:[];return F.send(P,N)}
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=EEC240FC3FBD5D7A64756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.cjs.map
|