@swapkit/helpers
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -1,6 +0,6 @@ | ||
var _n=Object.create;var{getPrototypeOf:Pn,defineProperty:tn,getOwnPropertyNames:$n}=Object;var Ln=Object.prototype.hasOwnProperty;var on=(n,h,t)=>{t=n!=null?_n(Pn(n)):{};let o=h||!n||!n.__esModule?tn(t,"default",{value:n,enumerable:!0}):t;for(let c of $n(n))if(!Ln.call(o,c))tn(o,c,{get:()=>n[c],enumerable:!0});return o};var cn=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,t)=>(typeof require!=="undefined"?require:h)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var _;((x)=>{x.Arbitrum="ARB";x.Avalanche="AVAX";x.Base="BASE";x.BinanceSmartChain="BSC";x.Bitcoin="BTC";x.BitcoinCash="BCH";x.Cosmos="GAIA";x.Dash="DASH";x.Dogecoin="DOGE";x.Ethereum="ETH";x.Fiat="FIAT";x.Kujira="KUJI";x.Litecoin="LTC";x.Maya="MAYA";x.Optimism="OP";x.Polkadot="DOT";x.Chainflip="FLIP";x.Polygon="MATIC";x.Radix="XRD";x.THORChain="THOR";x.Solana="SOL"})(_||={});var v;((t)=>{t.THORChain="THOR_STAGENET";t.Maya="MAYA_STAGENET"})(v||={});var f;((H)=>{H.Arbitrum="42161";H.ArbitrumHex="0xa4b1";H.Avalanche="43114";H.AvalancheHex="0xa86a";H.Base="8453";H.BaseHex="0x2105";H.BinanceSmartChain="56";H.BinanceSmartChainHex="0x38";H.Bitcoin="bitcoin";H.BitcoinCash="bitcoincash";H.Chainflip="chainflip";H.Cosmos="cosmoshub-4";H.Dash="dash";H.Dogecoin="dogecoin";H.Kujira="kaiyo-1";H.Ethereum="1";H.EthereumHex="0x1";H.Fiat="fiat";H.Litecoin="litecoin";H.Maya="mayachain-mainnet-v1";H.MayaStagenet="mayachain-stagenet-v1";H.Optimism="10";H.OptimismHex="0xa";H.Polkadot="polkadot";H.Polygon="137";H.PolygonHex="0x89";H.Radix="radix-mainnet";H.THORChain="thorchain-1";H.THORChainStagenet="thorchain-stagenet-v2";H.Solana="solana"})(f||={});var _h={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},jn=Object.keys(_),z=Object.values(_),p={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,OP:18,SOL:9,THOR:8,XRD:18},Ph={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["SOL"]:0.4,["THOR"]:6},$h=["DOT","FLIP"],Q=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Lh=["BTC","BCH","DASH","DOGE","LTC"],jh=["GAIA","THOR","MAYA","KUJI"],Gh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Ih=["ARB","DASH","ETH","KUJI","MAYA","THOR"],Cn={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://avalanche-c-chain-rpc.publicnode.com",["BASE"]:"https://base.llamarpc.com",["BSC"]:"https://bsc-dataseed.binance.org",["BTC"]:"https://bitcoin-rpc.publicnode.com",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://rpc-kujira.synergynodes.com/",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["THOR"]:"https://rpc.thorswap.net",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["SOL"]:"https://solana-rpc.publicnode.com"},Gn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.quickapi.com","https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://rpc.ankr.com/eth"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://kujira-rpc.ibs.team"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["THOR"]:["https://thornode.ninerealms.com","https://thornode.thorswap.net"],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},In={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},d=Cn,W=(n)=>{return d[n]},yn=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{jsonrpc:"2.0",method:"eth_blockNumber",params:[],id:1};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{jsonrpc:"1.0",id:"test",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{jsonrpc:"2.0",id:1,method:"system_health",params:[]};case"XRD":return"";case"SOL":return{jsonrpc:"2.0",id:1,method:"getHealth"};default:throw new Error(`Unsupported chain: ${n}`)}};function wn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var sn=async(n,h)=>{try{let t=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${t}${wn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(yn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},Xn=async(n)=>{let h=Cn[n];if(await sn(n,h))return h;for(let t of Gn[n])if(await sn(n,t))return t;return h},yh=async(n=[...Object.values(_),...Object.values(v)])=>{let h={};await Promise.all(n.map(async(t)=>{let o=await Xn(t);h[t]=o})),d={...d,...h}},an=z.reduce((n,h)=>{let t=jn.find((o)=>_[o]===h);if(t)n[h]=t;return n},{}),xn=z.reduce((n,h)=>{return n[h]=f[an[h]],n},{}),E=z.reduce((n,h)=>{return n[h]=W(h),n},{}),wh=z.reduce((n,h)=>{let t=`${an[h]}Hex`;return n[h]=f[t],n},{}),Xh=z.reduce((n,h)=>{return n[h]=In[h],n},{});var Jn;((T)=>{T.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";T.TC_SUPPORTED_TO_ETH="TC-ERC20";T.TC_SUPPORTED_TO_AVAX="TC-ARC20";T.TC_SUPPORTED_TO_BSC="TC-BEP20";T.ETH_TO_TC_SUPPORTED="ERC20-TC";T.ETH_TO_ETH="ERC20-ERC20";T.ETH_TO_AVAX="ERC20-ARC20";T.ETH_TO_BSC="ERC20-BEP20";T.AVAX_TO_TC_SUPPORTED="ARC20-TC";T.AVAX_TO_ETH="ARC20-ERC20";T.AVAX_TO_AVAX="ARC20-ARC20";T.AVAX_TO_BSC="ARC20-BEP20";T.BSC_TO_TC_SUPPORTED="BEP20-TC";T.BSC_TO_ETH="BEP20-ERC20";T.BSC_TO_AVAX="BEP20-ARC20";T.BSC_TO_BSC="BEP20-BEP20"})(Jn||={});var bh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],fh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],zh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var bn;((i)=>{i.ARB="0x0000000000000000000000000000000000000000";i.AVAX="0x0000000000000000000000000000000000000000";i.BASE="0x0000000000000000000000000000000000000000";i.ETH="0x0000000000000000000000000000000000000000";i.BSC="0x0000000000000000000000000000000000000000";i.MATIC="0x0000000000000000000000000000000000001010";i.OP="0x4200000000000000000000000000000000000042"})(bn||={});var fn;((x)=>{x.ARB="m/44'/60'/0'/0";x.AVAX="m/44'/60'/0'/0";x.BASE="m/44'/60'/0'/0";x.BCH="m/44'/145'/0'/0";x.BSC="m/44'/60'/0'/0";x.BTC="m/84'/0'/0'/0";x.DASH="m/44'/5'/0'/0";x.DOGE="m/44'/3'/0'/0";x.DOT="////";x.ETH="m/44'/60'/0'/0";x.FLIP="////";x.GAIA="m/44'/118'/0'/0";x.KUJI="m/44'/118'/0'/0";x.LTC="m/84'/2'/0'/0";x.MATIC="m/44'/60'/0'/0";x.MAYA="m/44'/931'/0'/0";x.OP="m/44'/60'/0'/0";x.SOL="m/44'/501'/0'/0";x.THOR="m/44'/931'/0'/0";x.XRD="////";x.FIAT="////"})(fn||={});var K={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,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],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0]};var zn;((N)=>{N.Arbitrum="https://arb1.arbitrum.io/rpc";N.Avalanche="https://avalanche-c-chain-rpc.publicnode.com";N.Base="https://base.llamarpc.com";N.BinanceSmartChain="https://bsc-dataseed.binance.org";N.Bitcoin="https://bitcoin-rpc.publicnode.com";N.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";N.Chainflip="wss://mainnet-archive.chainflip.io";N.Cosmos="https://node-router.thorswap.net/cosmos/rpc";N.Dash="https://dash-rpc.publicnode.com";N.Dogecoin="https://node-router.thorswap.net/dogecoin";N.Ethereum="https://ethereum-rpc.publicnode.com";N.Kujira="https://rpc-kujira.synergynodes.com/";N.Litecoin="https://node-router.thorswap.net/litecoin";N.Maya="https://tendermint.mayachain.info";N.MayaStagenet="https://stagenet.tendermint.mayachain.info";N.Optimism="https://mainnet.optimism.io";N.Polkadot="wss://rpc.polkadot.io";N.Polygon="https://polygon-rpc.com";N.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";N.THORChain="https://rpc.thorswap.net";N.THORChainStagenet="https://stagenet-rpc.ninerealms.com";N.Solana="https://solana-rpc.publicnode.com"})(zn||={});var Zn;((g)=>{g.Arbitrum="https://arbiscan.io";g.Avalanche="https://snowtrace.io";g.Base="https://basescan.org";g.BinanceSmartChain="https://bscscan.com";g.Bitcoin="https://blockchair.com/bitcoin";g.BitcoinCash="https://www.blockchair.com/bitcoin-cash";g.Chainflip="https://explorer.polkascan.io/polkadot";g.Cosmos="https://www.mintscan.io/cosmos";g.Dash="https://blockchair.com/dash";g.Dogecoin="https://blockchair.com/dogecoin";g.Ethereum="https://etherscan.io";g.Kujira="https://finder.kujira.network/kaiyo-1";g.Litecoin="https://blockchair.com/litecoin";g.Maya="https://www.mayascan.org";g.Optimism="https://optimistic.etherscan.io";g.Polkadot="https://polkadot.subscan.io";g.Polygon="https://polygonscan.com";g.Radix="https://dashboard.radixdlt.com";g.THORChain="https://runescan.io";g.Solana="https://solscan.io"})(Zn||={});var Rn;((B)=>{B.BITGET="BITGET";B.BRAVE="BRAVE";B.COINBASE_MOBILE="COINBASE_MOBILE";B.COINBASE_WEB="COINBASE_WEB";B.CTRL="CTRL";B.EIP6963="EIP6963";B.EXODUS="EXODUS";B.KEEPKEY="KEEPKEY";B.KEEPKEY_BEX="KEEPKEY_BEX";B.KEPLR="KEPLR";B.KEYSTORE="KEYSTORE";B.LEAP="LEAP";B.LEDGER="LEDGER";B.LEDGER_LIVE="LEDGER_LIVE";B.METAMASK="METAMASK";B.OKX="OKX";B.OKX_MOBILE="OKX_MOBILE";B.PHANTOM="PHANTOM";B.POLKADOT_JS="POLKADOT_JS";B.RADIX_WALLET="RADIX_WALLET";B.TREZOR="TREZOR";B.TALISMAN="TALISMAN";B.TRUSTWALLET_WEB="TRUSTWALLET_WEB";B.WALLETCONNECT="WALLETCONNECT"})(Rn||={});var Yn;((o)=>{o[o.NoError=36864]="NoError";o[o.LockedDevice=21781]="LockedDevice";o[o.TC_NotFound=65535]="TC_NotFound"})(Yn||={});var Mn;((o)=>{o.Average="average";o.Fast="fast";o.Fastest="fastest"})(Mn||={});var qn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(qn||={});var Hn;((F)=>{F.NAME_REGISTER="~";F.BOND="BOND";F.DEPOSIT="+";F.LEAVE="LEAVE";F.UNBOND="UNBOND";F.WITHDRAW="-";F.OPEN_LOAN="$+";F.CLOSE_LOAN="$-";F.RUNEPOOL_DEPOSIT="POOL+";F.RUNEPOOL_WITHDRAW="POOL-"})(Hn||={});var Qn;((s)=>{s.unknownError="unknownError";s.test_error="test_error";s.providerDetailsError="providerDetailsError";s.blockHeaderNotFound="blockHeaderNotFound";s.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";s.blockHashNotFoundAtHash="blockHashNotFoundAtHash";s.txHashMissing="txHashMissing";s.assetValueMissingInfo="assetValueMissingInfo";s.invalidAsset="invalidAsset";s.blockIsRequired="blockIsRequired";s.currentBlockHeaderNotFound="currentBlockHeaderNotFound";s.failedToRetrieveBalance="failedToRetrieveBalance";s.failedToRetrieveBlock="failedToRetrieveBlock";s.failedToRetrieveFees="failedToRetrieveFees";s.notImplementedBCH="notImplementedBCH";s.notImplementedDoge="notImplementedDoge";s.noPoolsFound="noPoolsFound";s.noVaultsFound="noVaultsFound";s.noTxFound="noTxFound";s.noInputCoinFound="noInputCoinFound";s.noBlockDataFound="noBlockDataFound";s.multipleCosmosMessages="multipleCosmosMessages";s.heightOrHashNotProvided="heightOrHashNotProvided";s.unknownDenom="unknownDenom";s.invalidBlockHeight="invalidBlockHeight";s.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";s.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";s.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";s.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";s.txMemoUndefined="txMemoUndefined";s.txMemoIncorrect="txMemoIncorrect";s.txTypeNotFound="txTypeNotFound";s.txNoMessage="txNoMessage";s.txNotFound="txNotFound";s.txReceiptNotFound="txReceiptNotFound";s.txParsingError="txParsingError";s.txLogsParsingError="txLogsParsingError";s.blockNotFound="blockNotFound";s.balanceNotFound="balanceNotFound";s.configError="configError";s.synthSwapDisallowed="synthSwapDisallowed";s.providerQuoteTimeout="providerQuoteTimeout";s.noQuoteResponse="noQuoteResponse";s.noPoolAssetsFound="noPoolAssetsFound";s.noThorchainPools="noThorchainPools";s.noMayachainPools="noMayachainPools";s.noThorchainNetworkInfo="noThorchainNetworkInfo";s.invalidAffiliateFee="invalidAffiliateFee";s.invalidBuyAssetAddress="invalidBuyAssetAddress";s.invalidSellAssetAddress="invalidSellAssetAddress";s.invalidSourceAddress="invalidSourceAddress";s.invalidDestinationAddress="invalidDestinationAddress";s.sourceAddressIsSmartContract="sourceAddressIsSmartContract";s.destinationAddressIsSmartContract="destinationAddressIsSmartContract";s.invalidChainId="invalidChainId";s.unsupportedChainId="unsupportedChainId";s.unsupportedEVMChainId="unsupportedEVMChainId";s.unsupportedMethod="unsupportedMethod";s.unsupportedProvider="unsupportedProvider";s.invalidParamsForMethod="invalidParamsForMethod";s.unsupportedAdapter="unsupportedAdapter";s.noWhitelistTokens="noWhitelistTokens";s.failedFetchGasPrice="failedFetchGasPrice";s.failedToCreateDepositChannel="failedToCreateDepositChannel";s.noProviderDetailsFound="noProviderDetailsFound";s.noTokenListsFound="noTokenListsFound";s.tokenNotFound="tokenNotFound";s.tokenPriceNotFound="tokenPriceNotFound";s.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";s.swapAmountTooSmall="swapAmountTooSmall";s.legsArrayIsEmpty="legsArrayIsEmpty";s.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";s.noBlockHeaderFound="noBlockHeaderFound";s.failedToSimulateSwap="failedToSimulateSwap";s.addressScreeningFailed="addressScreeningFailed";s.noLiquidtyProvidersFound="noLiquidtyProvidersFound";s.insufficientLiquidity="insufficientLiquidity";s.noSaversFound="noSaversFound";s.noInboundDataFound="noInbounDataFound";s.noInboundAddressesFound="noInboundAddressesFound";s.noInboundAddressFoundForChain="noInboundAddressFoundForChain";s.noLastBlocksFound="noLastBlocksFound";s.noVersionFound="noVersionFound";s.noConstantsFound="noConstantsFound";s.noMimirsFound="noMimirsFound";s.noRoutesFound="noRoutesFound";s.quoteNotFound="quoteNotFound";s.ledgerSignFailed="ledgerSignFailed";s.ledgerWrongPayload="ledgerWrongPayload";s.ledgerFetchSwapFailed="ledgerFetchSwapFailed";s.failedToFetchTx="failedToFetchTx";s.failedBuildTransactionDetails="failedBuildTransactionDetails";s.noLegsForRoute="noLegsForRoute";s.noRouterAddressFound="noRouterAddressFound";s.noAggregatorAddressFound="noAggregatorAddressFound";s.noContractInstanceFound="noContractInstanceFound";s.noContractAddressFound="noContractAddressFound";s.invalidAffiliate="invalidAffiliate";s.thornameAffiliate="thornameAffiliate";s.providerNotfound="No provider found";s.noRecordFound="No Record found";s.slippageTooLow="Slippage too low";s.tradingHalted="tradingHalted";s.noWrappedGasAsset="noWrappedGasAsset";s.aggregatorAddressNotFound="aggregatorAddressNotFound";s.routerAddressNotFound="routerAddressNotFound";s.dummyAddressNotFound="dummyAddressNotFound";s.trackerError="trackerError";s.thorchainPoolUnavailable="thorchainPoolUnavailable";s.noOhlcvDataFound="noOhlcvDataFound";s.noTradingPairs="noTradingPairs";s.noLoanPositionFound="noLoanPositionFound";s.noLendingAvailability="noLendingAvailability";s.lendingRepayTooSmall="lendingRepayTooSmall";s.missingState="missingState";s.ledgerSwapNotFound="ledgerSwapNotFound";s.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";s.errorEstimatingGas="errorEstimatingGas";s.apiKeyInvalid="apiKeyInvalid";s.apiKeyFailedToUpdate="apiKeyFailedToUpdate";s.apiKeyExpired="apiKeyExpired";s.unauthorized="unauthorized";s.failedToCreateMemo="failedToCreateMemo";s.radixIncorrectInstructions="radixIncorrectInstructions";s.radixTxMissedParam="radixTxMissedParam";s.radixTxMissedAccount="radixTxMissedAccount";s.radixManifestParseError="radixManifestParseError";s.radixManifestBuildError="radixManifestBuildError";s.invalidAddressForChain="invalidAddressForChain";s.riskyAddress="riskyAddress";s.noRoutesToProcess="noRoutesToProcess";s.sellAssetAmountTooSmall="sellAssetAmountTooSmall";s.missingPrivateKey="missingPrivateKey";s.noMemoPriceProtection="noMemoPriceProtection"})(Qn||={});var Wn;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(Wn||={});var Kn;((k)=>{k.CAVIAR_V1="CAVIAR_V1";k.CAMELOT_V3="CAMELOT_V3";k.CHAINFLIP="CHAINFLIP";k.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";k.JUPITER="JUPITER";k.MAYACHAIN="MAYACHAIN";k.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";k.OCISWAP_V1="OCISWAP_V1";k.ONEINCH="ONEINCH";k.OPENOCEAN_V2="OPENOCEAN_V2";k.PANCAKESWAP="PANCAKESWAP";k.PANGOLIN_V1="PANGOLIN_V1";k.SUSHISWAP_V2="SUSHISWAP_V2";k.THORCHAIN="THORCHAIN";k.THORCHAIN_STREAMING="THORCHAIN_STREAMING";k.TRADERJOE_V2="TRADERJOE_V2";k.UNISWAP_V2="UNISWAP_V2";k.UNISWAP_V3="UNISWAP_V3";k.KADO="KADO"})(Kn||={});var Vn;((i)=>{i.LIQUIDITY="liquidity";i.NETWORK="network";i.INBOUND="inbound";i.OUTBOUND="outbound";i.AFFILIATE="affiliate";i.TAX="tax";i.PRIORITY="priority"})(Vn||={});var l={},mn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"};function eh({apiKey:n,...h}){l={...h,apiKey:n}}async function V(n,h){let{apiKey:t,...o}=l,{searchParams:c,json:C,body:a}=h,i={...mn,...o.headers,...h.headers,...C?{"Content-Type":"application/json"}:{}},A=C?JSON.stringify(C):a,R=new URL(n);if(c)R.search=new URLSearchParams(c).toString();if(t)i["x-api-key"]=t;try{let S=await(await fetch(R.toString(),{...o,...h,body:A,headers:i})).json();if(h.responseHandler)return h.responseHandler(S);return S}catch(F){if(h.onError)return h.onError(F);console.error(F)}}var J={get:async(n,h)=>V(n,{...h,method:"GET"}),post:async(n,h)=>V(n,{...h,method:"POST"}),extend:(n)=>{let h={...l,...n};return{get:async(t,o)=>V(t,{...h,...o,method:"GET"}),post:async(t,o)=>V(t,{...h,...o,method:"POST"}),extend:(t)=>J.extend({...h,...t})}}};var Un={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_ctrl_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_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_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,wallet_bitkeep_not_found:21001,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,api_v2_invalid_method_key_hash:50003,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class u extends Error{static ErrorCode=Un;constructor(n,h){let t=typeof n==="string",o=t?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(o,{cause:{code:u.ErrorCode[o],message:`${o}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,u.prototype)}}function st(n){if(n<0)throw new u({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function Ct(n){if(n<0)throw new u({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function at(n,h){try{return n()}catch(t){if(h)throw new u(h,t);return console.error(t)}}function it(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Dn=["production","test"].includes("development"),Fn=new Set;function pn(n,h){if(!Dn&&n){if(Fn.has(h))return;Fn.add(h),console.warn(h)}}async function xt(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{return(await J.get(`${n!=="thorchain-1"?W("THOR_STAGENET"):W("THOR")}/status`)).result.node_info.network}catch(h){return n}}var An=[...Object.values(_),"TERRA"];function Bn(n=""){let h=n.toUpperCase(),[t]=h.split(".");if(An.includes(t))return!0;let[o]=h.split("/");if(An.includes(o))return!0;throw new u({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function pt(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var Y=8,X=(n)=>10n**BigInt(n),Z=(n)=>Math.log10(Number.parseFloat(n.toString()));function b({value:n,bigIntDecimal:h=Y,decimal:t=Y}){if(t===0)return n.toString();let o=n<0n,c=n.toString().substring(o?1:0),C=t-(c.length-1);if(C>0)c="0".repeat(C)+c;let a=c.length-t,i=c.slice(-t);if(Number.parseInt(i[h]||"0")>=5)i=`${i.substring(0,h-1)}${(Number.parseInt(i[h-1]||"0")+1).toString()}`;else i=i.substring(0,h);return`${o?"-":""}${c.slice(0,a)}.${i}`.replace(/\.?0*$/,"")}class G{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new G({decimal:h,value:b({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return G.fromBigInt(n.getBaseValue("bigint")*X(t)/X(h),t)}constructor(n){let h=r(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:X(Math.max(Tn(m(h)),this.decimal||0)),this.#c(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let t=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||Z(this.decimalMultiplier));switch(n){case"number":return Number(t);case"string":return t;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n,h){let t=this.decimalMultiplier/X(h||this.decimal||p.THOR),o=this.bigIntValue/t;switch(n){case"number":return Number(o);case"string":return o.toString();case"bigint":return o}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let t=r(n),o=m(t);if(o==="0"||o==="undefined")return 0n;return this.#o(o,h)}toSignificant(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if((Number.parseInt(o)?o.length+c.length:c.length)<=n)return this.getValue("string");if(o.length>=n)return o.slice(0,n).padEnd(o.length,"0");if(Number.parseInt(o))return`${o}.${c.slice(0,n-o.length)}`.padEnd(n-o.length,"0");let a=Number.parseInt(c),i=`${a}`.slice(0,n);return`0.${i.padStart(c.length-`${a}`.length+i.length,"0")}`}toFixed(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if(Number.parseInt(o))return`${o}.${c.slice(0,n)}`.padEnd(n,"0");let C=Number.parseInt(c),a=`${C}`.slice(0,n);return`0.${a.padStart(c.length-`${C}`.length+a.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],o=Math.floor(Math.log10(Math.abs(h))/3),c=t[o];if(!c)return this.getValue("string");let C=10**(o*3);return`${(h/C).toFixed(n)}${c}`}toCurrency(n="$",{currencyPosition:h="start",decimal:t=2,decimalSeparator:o=".",thousandSeparator:c=","}={}){let C=this.getValue("number"),[a="",i=""]=C.toFixed(6).split("."),A=a.replace(/\B(?=(\d{3})+(?!\d))/g,c),R=a||i?a==="0"?`${Number.parseFloat(`0.${i}`)}`.replace(".",o):`${A}${Number.parseInt(i)?`${o}${i.slice(0,t)}`:""}`:"0.00";return`${h==="start"?n:""}${R}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let t=h||this.decimal||Y,o=Math.max(t,Z(this.decimalMultiplier)),c=n<0n,C=n.toString().substring(c?1:0),a=o-(C.length-1),i=a>0?"0".repeat(a)+C:C,A=i.length-o,R=i.slice(-o);if(Number.parseInt(R[t]||"0")>=5)R=`${R.substring(0,t-1)}${(Number.parseInt(R[t-1]||"0")+1).toString()}`;else R=R.substring(0,t);return`${c?"-":""}${i.slice(0,A)}.${R}`.replace(/\.?0*$/,"")}#h(n,...h){let t=this.#t(this,...h),o=Math.max(t,Z(this.decimalMultiplier)),c=X(o),C=h.reduce((i,A)=>{let R=this.getBigIntValue(A,o);switch(n){case"add":return i+R;case"sub":return i-R;case"mul":return i*R/c;case"div":{if(R===0n)throw new RangeError("Division by zero");return i*c/R}default:return i}},this.bigIntValue*c/this.decimalMultiplier),a=b({bigIntDecimal:o,decimal:o,value:C});return new this.constructor({decimalMultiplier:X(o),decimal:this.decimal,value:a,identifier:this.toString()})}#n(n,...h){let t=this.#t(this,...h),o=this.getBigIntValue(h[0]||"0",t),c=this.getBigIntValue(this,t);switch(n){case"gt":return c>o;case"gte":return c>=o;case"lt":return c<o;case"lte":return c<=o;case"eqValue":return c===o}}#c(n){let h=m(n)||"0";this.bigIntValue=this.#o(h)}#t(...n){let h=n.map((t)=>{return typeof t==="object"?t.decimal||Z(t.decimalMultiplier):Tn(m(t))}).filter(Boolean);return Math.max(...h,Y)}#o(n,h){let t=h?X(h):this.decimalMultiplier,o=Z(t),[c="",C=""]=n.split(".");return BigInt(`${c}${C.padEnd(o,"0")}`)}}var dn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function m(n){let t=`${typeof n==="number"?dn.format(n):r(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function Tn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,Y)}function r(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var U=new Map;class O extends G{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:t,chain:o,symbol:c,identifier:C}){super(typeof n==="object"?n:{decimal:h,value:n});let a=e(C||`${o}.${c}`);this.type=gn(a),this.tax=t,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=xn[a.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[t,o,c]=n.split(".");if(!(t&&o))throw new u({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let C=t==="THOR"&&c?`${t}.${o}/${c}`:n;return O.from({asset:C,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...o}){let c=n instanceof G?n.getValue("string"):n,C="chain"in o,a=C?o.chain:o.asset,i=C||kn.includes(a),{identifier:A,decimal:R}=i?On(a):{identifier:a,decimal:void 0},{chain:F,isSynthetic:S,isTradeAsset:$}=e(A),I=U.get(F==="SOL"?A:A.toUpperCase()),y=I?.decimal||R;pn(!(t||y),`Couldn't find static decimal for ${A} (Using default ${p[F]} decimal as fallback). | ||
var _n=Object.create;var{getPrototypeOf:$n,defineProperty:tn,getOwnPropertyNames:Ln}=Object;var Pn=Object.prototype.hasOwnProperty;var on=(n,h,t)=>{t=n!=null?_n($n(n)):{};let o=h||!n||!n.__esModule?tn(t,"default",{value:n,enumerable:!0}):t;for(let c of Ln(n))if(!Pn.call(o,c))tn(o,c,{get:()=>n[c],enumerable:!0});return o};var cn=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,t)=>(typeof require!=="undefined"?require:h)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var _;((x)=>{x.Arbitrum="ARB";x.Avalanche="AVAX";x.Base="BASE";x.BinanceSmartChain="BSC";x.Bitcoin="BTC";x.BitcoinCash="BCH";x.Cosmos="GAIA";x.Dash="DASH";x.Dogecoin="DOGE";x.Ethereum="ETH";x.Fiat="FIAT";x.Kujira="KUJI";x.Litecoin="LTC";x.Maya="MAYA";x.Optimism="OP";x.Polkadot="DOT";x.Chainflip="FLIP";x.Polygon="MATIC";x.Radix="XRD";x.THORChain="THOR";x.Solana="SOL"})(_||={});var v;((t)=>{t.THORChain="THOR_STAGENET";t.Maya="MAYA_STAGENET"})(v||={});var J;((R)=>{R.Arbitrum="42161";R.ArbitrumHex="0xa4b1";R.Avalanche="43114";R.AvalancheHex="0xa86a";R.Base="8453";R.BaseHex="0x2105";R.BinanceSmartChain="56";R.BinanceSmartChainHex="0x38";R.Bitcoin="bitcoin";R.BitcoinCash="bitcoincash";R.Chainflip="chainflip";R.Cosmos="cosmoshub-4";R.Dash="dash";R.Dogecoin="dogecoin";R.Kujira="kaiyo-1";R.Ethereum="1";R.EthereumHex="0x1";R.Fiat="fiat";R.Litecoin="litecoin";R.Maya="mayachain-mainnet-v1";R.MayaStagenet="mayachain-stagenet-v1";R.Optimism="10";R.OptimismHex="0xa";R.Polkadot="polkadot";R.Polygon="137";R.PolygonHex="0x89";R.Radix="radix-mainnet";R.THORChain="thorchain-1";R.THORChainStagenet="thorchain-stagenet-v2";R.Solana="solana"})(J||={});var $h={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},jn=Object.keys(_),z=Object.values(_),F={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,OP:18,SOL:9,THOR:8,XRD:18},Lh={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["SOL"]:0.4,["THOR"]:6},Ph=["DOT","FLIP"],Q=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],jh=["BTC","BCH","DASH","DOGE","LTC"],yh=["GAIA","THOR","MAYA","KUJI"],Gh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Ih=["ARB","DASH","ETH","KUJI","MAYA","THOR"],Cn={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://avalanche-c-chain-rpc.publicnode.com",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BTC"]:"https://bitcoin-rpc.publicnode.com",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://rpc-kujira.synergynodes.com/",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["THOR"]:"https://rpc.thorswap.net",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["SOL"]:"https://solana-rpc.publicnode.com"},yn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.quickapi.com","https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://rpc.ankr.com/eth"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://kujira-rpc.ibs.team"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["THOR"]:["https://thornode.ninerealms.com","https://thornode.thorswap.net"],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},Gn={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},d=Cn,W=(n)=>{return d[n]},In=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{jsonrpc:"2.0",method:"eth_blockNumber",params:[],id:1};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{jsonrpc:"1.0",id:"test",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{jsonrpc:"2.0",id:1,method:"system_health",params:[]};case"XRD":return"";case"SOL":return{jsonrpc:"2.0",id:1,method:"getHealth"};default:throw new Error(`Unsupported chain: ${n}`)}};function wn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var sn=async(n,h)=>{try{let t=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${t}${wn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(In(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},fn=async(n)=>{let h=Cn[n];if(await sn(n,h))return h;for(let t of yn[n])if(await sn(n,t))return t;return h},wh=async(n=[...Object.values(_),...Object.values(v)])=>{let h={};await Promise.all(n.map(async(t)=>{let o=await fn(t);h[t]=o})),d={...d,...h}},an=z.reduce((n,h)=>{let t=jn.find((o)=>_[o]===h);if(t)n[h]=t;return n},{}),xn=z.reduce((n,h)=>{return n[h]=J[an[h]],n},{}),E=z.reduce((n,h)=>{return n[h]=W(h),n},{}),fh=z.reduce((n,h)=>{let t=`${an[h]}Hex`;return n[h]=J[t],n},{}),Xh=z.reduce((n,h)=>{return n[h]=Gn[h],n},{});var Xn;((B)=>{B.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";B.TC_SUPPORTED_TO_ETH="TC-ERC20";B.TC_SUPPORTED_TO_AVAX="TC-ARC20";B.TC_SUPPORTED_TO_BSC="TC-BEP20";B.ETH_TO_TC_SUPPORTED="ERC20-TC";B.ETH_TO_ETH="ERC20-ERC20";B.ETH_TO_AVAX="ERC20-ARC20";B.ETH_TO_BSC="ERC20-BEP20";B.AVAX_TO_TC_SUPPORTED="ARC20-TC";B.AVAX_TO_ETH="ARC20-ERC20";B.AVAX_TO_AVAX="ARC20-ARC20";B.AVAX_TO_BSC="ARC20-BEP20";B.BSC_TO_TC_SUPPORTED="BEP20-TC";B.BSC_TO_ETH="BEP20-ERC20";B.BSC_TO_AVAX="BEP20-ARC20";B.BSC_TO_BSC="BEP20-BEP20"})(Xn||={});var Jh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],zh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Zh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var bn;((i)=>{i.ARB="0x0000000000000000000000000000000000000000";i.AVAX="0x0000000000000000000000000000000000000000";i.BASE="0x0000000000000000000000000000000000000000";i.ETH="0x0000000000000000000000000000000000000000";i.BSC="0x0000000000000000000000000000000000000000";i.MATIC="0x0000000000000000000000000000000000001010";i.OP="0x4200000000000000000000000000000000000042"})(bn||={});var Jn;((x)=>{x.ARB="m/44'/60'/0'/0";x.AVAX="m/44'/60'/0'/0";x.BASE="m/44'/60'/0'/0";x.BCH="m/44'/145'/0'/0";x.BSC="m/44'/60'/0'/0";x.BTC="m/84'/0'/0'/0";x.DASH="m/44'/5'/0'/0";x.DOGE="m/44'/3'/0'/0";x.DOT="////";x.ETH="m/44'/60'/0'/0";x.FLIP="////";x.GAIA="m/44'/118'/0'/0";x.KUJI="m/44'/118'/0'/0";x.LTC="m/84'/2'/0'/0";x.MATIC="m/44'/60'/0'/0";x.MAYA="m/44'/931'/0'/0";x.OP="m/44'/60'/0'/0";x.SOL="m/44'/501'/0'/0";x.THOR="m/44'/931'/0'/0";x.XRD="////";x.FIAT="////"})(Jn||={});var K={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,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],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0]};var zn;((k)=>{k.Arbitrum="https://arb1.arbitrum.io/rpc";k.Avalanche="https://avalanche-c-chain-rpc.publicnode.com";k.Base="https://base.llamarpc.com";k.BinanceSmartChain="https://bsc-dataseed.binance.org";k.Bitcoin="https://bitcoin-rpc.publicnode.com";k.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";k.Chainflip="wss://mainnet-archive.chainflip.io";k.Cosmos="https://node-router.thorswap.net/cosmos/rpc";k.Dash="https://dash-rpc.publicnode.com";k.Dogecoin="https://node-router.thorswap.net/dogecoin";k.Ethereum="https://ethereum-rpc.publicnode.com";k.Kujira="https://rpc-kujira.synergynodes.com/";k.Litecoin="https://node-router.thorswap.net/litecoin";k.Maya="https://tendermint.mayachain.info";k.MayaStagenet="https://stagenet.tendermint.mayachain.info";k.Optimism="https://mainnet.optimism.io";k.Polkadot="wss://rpc.polkadot.io";k.Polygon="https://polygon-rpc.com";k.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";k.THORChain="https://rpc.thorswap.net";k.THORChainStagenet="https://stagenet-rpc.ninerealms.com";k.Solana="https://solana-rpc.publicnode.com"})(zn||={});var Zn;((u)=>{u.Arbitrum="https://arbiscan.io";u.Avalanche="https://snowtrace.io";u.Base="https://basescan.org";u.BinanceSmartChain="https://bscscan.com";u.Bitcoin="https://blockchair.com/bitcoin";u.BitcoinCash="https://www.blockchair.com/bitcoin-cash";u.Chainflip="https://explorer.polkascan.io/polkadot";u.Cosmos="https://www.mintscan.io/cosmos";u.Dash="https://blockchair.com/dash";u.Dogecoin="https://blockchair.com/dogecoin";u.Ethereum="https://etherscan.io";u.Kujira="https://finder.kujira.network/kaiyo-1";u.Litecoin="https://blockchair.com/litecoin";u.Maya="https://www.mayascan.org";u.Optimism="https://optimistic.etherscan.io";u.Polkadot="https://polkadot.subscan.io";u.Polygon="https://polygonscan.com";u.Radix="https://dashboard.radixdlt.com";u.THORChain="https://runescan.io";u.Solana="https://solscan.io"})(Zn||={});var pn;((T)=>{T.BITGET="BITGET";T.BRAVE="BRAVE";T.COINBASE_MOBILE="COINBASE_MOBILE";T.COINBASE_WEB="COINBASE_WEB";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.PHANTOM="PHANTOM";T.POLKADOT_JS="POLKADOT_JS";T.RADIX_WALLET="RADIX_WALLET";T.TREZOR="TREZOR";T.TALISMAN="TALISMAN";T.TRUSTWALLET_WEB="TRUSTWALLET_WEB";T.WALLETCONNECT="WALLETCONNECT"})(pn||={});var Yn;((o)=>{o[o.NoError=36864]="NoError";o[o.LockedDevice=21781]="LockedDevice";o[o.TC_NotFound=65535]="TC_NotFound"})(Yn||={});var Mn;((o)=>{o.Average="average";o.Fast="fast";o.Fastest="fastest"})(Mn||={});var qn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(qn||={});var Rn;((H)=>{H.NAME_REGISTER="~";H.BOND="BOND";H.DEPOSIT="+";H.LEAVE="LEAVE";H.UNBOND="UNBOND";H.WITHDRAW="-";H.OPEN_LOAN="$+";H.CLOSE_LOAN="$-";H.RUNEPOOL_DEPOSIT="POOL+";H.RUNEPOOL_WITHDRAW="POOL-"})(Rn||={});var Qn;((s)=>{s.unknownError="unknownError";s.test_error="test_error";s.providerDetailsError="providerDetailsError";s.blockHeaderNotFound="blockHeaderNotFound";s.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";s.blockHashNotFoundAtHash="blockHashNotFoundAtHash";s.txHashMissing="txHashMissing";s.assetValueMissingInfo="assetValueMissingInfo";s.invalidAsset="invalidAsset";s.blockIsRequired="blockIsRequired";s.currentBlockHeaderNotFound="currentBlockHeaderNotFound";s.failedToRetrieveBalance="failedToRetrieveBalance";s.failedToRetrieveBlock="failedToRetrieveBlock";s.failedToRetrieveFees="failedToRetrieveFees";s.notImplementedBCH="notImplementedBCH";s.notImplementedDoge="notImplementedDoge";s.noPoolsFound="noPoolsFound";s.noVaultsFound="noVaultsFound";s.noTxFound="noTxFound";s.noInputCoinFound="noInputCoinFound";s.noBlockDataFound="noBlockDataFound";s.multipleCosmosMessages="multipleCosmosMessages";s.heightOrHashNotProvided="heightOrHashNotProvided";s.unknownDenom="unknownDenom";s.invalidBlockHeight="invalidBlockHeight";s.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";s.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";s.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";s.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";s.txMemoUndefined="txMemoUndefined";s.txMemoIncorrect="txMemoIncorrect";s.txTypeNotFound="txTypeNotFound";s.txNoMessage="txNoMessage";s.txNotFound="txNotFound";s.txReceiptNotFound="txReceiptNotFound";s.txParsingError="txParsingError";s.txLogsParsingError="txLogsParsingError";s.blockNotFound="blockNotFound";s.balanceNotFound="balanceNotFound";s.configError="configError";s.synthSwapDisallowed="synthSwapDisallowed";s.providerQuoteTimeout="providerQuoteTimeout";s.noQuoteResponse="noQuoteResponse";s.noPoolAssetsFound="noPoolAssetsFound";s.noThorchainPools="noThorchainPools";s.noMayachainPools="noMayachainPools";s.noThorchainNetworkInfo="noThorchainNetworkInfo";s.invalidAffiliateFee="invalidAffiliateFee";s.invalidBuyAssetAddress="invalidBuyAssetAddress";s.invalidSellAssetAddress="invalidSellAssetAddress";s.invalidSourceAddress="invalidSourceAddress";s.invalidDestinationAddress="invalidDestinationAddress";s.sourceAddressIsSmartContract="sourceAddressIsSmartContract";s.destinationAddressIsSmartContract="destinationAddressIsSmartContract";s.invalidChainId="invalidChainId";s.unsupportedChainId="unsupportedChainId";s.unsupportedEVMChainId="unsupportedEVMChainId";s.unsupportedMethod="unsupportedMethod";s.unsupportedProvider="unsupportedProvider";s.invalidParamsForMethod="invalidParamsForMethod";s.unsupportedAdapter="unsupportedAdapter";s.noWhitelistTokens="noWhitelistTokens";s.failedFetchGasPrice="failedFetchGasPrice";s.failedToCreateDepositChannel="failedToCreateDepositChannel";s.noProviderDetailsFound="noProviderDetailsFound";s.noTokenListsFound="noTokenListsFound";s.tokenNotFound="tokenNotFound";s.tokenPriceNotFound="tokenPriceNotFound";s.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";s.swapAmountTooSmall="swapAmountTooSmall";s.legsArrayIsEmpty="legsArrayIsEmpty";s.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";s.noBlockHeaderFound="noBlockHeaderFound";s.failedToSimulateSwap="failedToSimulateSwap";s.addressScreeningFailed="addressScreeningFailed";s.noLiquidtyProvidersFound="noLiquidtyProvidersFound";s.insufficientLiquidity="insufficientLiquidity";s.noSaversFound="noSaversFound";s.noInboundDataFound="noInbounDataFound";s.noInboundAddressesFound="noInboundAddressesFound";s.noInboundAddressFoundForChain="noInboundAddressFoundForChain";s.noLastBlocksFound="noLastBlocksFound";s.noVersionFound="noVersionFound";s.noConstantsFound="noConstantsFound";s.noMimirsFound="noMimirsFound";s.noRoutesFound="noRoutesFound";s.quoteNotFound="quoteNotFound";s.ledgerSignFailed="ledgerSignFailed";s.ledgerWrongPayload="ledgerWrongPayload";s.ledgerFetchSwapFailed="ledgerFetchSwapFailed";s.failedToFetchTx="failedToFetchTx";s.failedBuildTransactionDetails="failedBuildTransactionDetails";s.noLegsForRoute="noLegsForRoute";s.noRouterAddressFound="noRouterAddressFound";s.noAggregatorAddressFound="noAggregatorAddressFound";s.noContractInstanceFound="noContractInstanceFound";s.noContractAddressFound="noContractAddressFound";s.invalidAffiliate="invalidAffiliate";s.thornameAffiliate="thornameAffiliate";s.providerNotfound="No provider found";s.noRecordFound="No Record found";s.slippageTooLow="Slippage too low";s.tradingHalted="tradingHalted";s.noWrappedGasAsset="noWrappedGasAsset";s.aggregatorAddressNotFound="aggregatorAddressNotFound";s.routerAddressNotFound="routerAddressNotFound";s.dummyAddressNotFound="dummyAddressNotFound";s.trackerError="trackerError";s.thorchainPoolUnavailable="thorchainPoolUnavailable";s.noOhlcvDataFound="noOhlcvDataFound";s.noTradingPairs="noTradingPairs";s.noLoanPositionFound="noLoanPositionFound";s.noLendingAvailability="noLendingAvailability";s.lendingRepayTooSmall="lendingRepayTooSmall";s.missingState="missingState";s.ledgerSwapNotFound="ledgerSwapNotFound";s.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";s.errorEstimatingGas="errorEstimatingGas";s.apiKeyInvalid="apiKeyInvalid";s.apiKeyFailedToUpdate="apiKeyFailedToUpdate";s.apiKeyExpired="apiKeyExpired";s.unauthorized="unauthorized";s.failedToCreateMemo="failedToCreateMemo";s.radixIncorrectInstructions="radixIncorrectInstructions";s.radixTxMissedParam="radixTxMissedParam";s.radixTxMissedAccount="radixTxMissedAccount";s.radixManifestParseError="radixManifestParseError";s.radixManifestBuildError="radixManifestBuildError";s.invalidAddressForChain="invalidAddressForChain";s.riskyAddress="riskyAddress";s.noRoutesToProcess="noRoutesToProcess";s.sellAssetAmountTooSmall="sellAssetAmountTooSmall";s.missingPrivateKey="missingPrivateKey";s.noMemoPriceProtection="noMemoPriceProtection"})(Qn||={});var Wn;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(Wn||={});var Kn;((N)=>{N.CAVIAR_V1="CAVIAR_V1";N.CAMELOT_V3="CAMELOT_V3";N.CHAINFLIP="CHAINFLIP";N.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";N.JUPITER="JUPITER";N.MAYACHAIN="MAYACHAIN";N.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";N.OCISWAP_V1="OCISWAP_V1";N.ONEINCH="ONEINCH";N.OPENOCEAN_V2="OPENOCEAN_V2";N.PANCAKESWAP="PANCAKESWAP";N.PANGOLIN_V1="PANGOLIN_V1";N.SUSHISWAP_V2="SUSHISWAP_V2";N.THORCHAIN="THORCHAIN";N.THORCHAIN_STREAMING="THORCHAIN_STREAMING";N.TRADERJOE_V2="TRADERJOE_V2";N.UNISWAP_V2="UNISWAP_V2";N.UNISWAP_V3="UNISWAP_V3";N.KADO="KADO"})(Kn||={});var Vn;((i)=>{i.LIQUIDITY="liquidity";i.NETWORK="network";i.INBOUND="inbound";i.OUTBOUND="outbound";i.AFFILIATE="affiliate";i.TAX="tax";i.PRIORITY="priority"})(Vn||={});var l={},mn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"};function nt({apiKey:n,...h}){l={...h,apiKey:n}}async function V(n,h){let{apiKey:t,...o}=l,{searchParams:c,json:C,body:a}=h,i={...mn,...o.headers,...h.headers,...C?{"Content-Type":"application/json"}:{}},A=C?JSON.stringify(C):a,p=new URL(n);if(c)p.search=new URLSearchParams(c).toString();if(t)i["x-api-key"]=t;try{let S=await(await fetch(p.toString(),{...o,...h,body:A,headers:i})).json();if(h.responseHandler)return h.responseHandler(S);return S}catch(H){if(h.onError)return h.onError(H);console.error(H)}}var X={get:async(n,h)=>V(n,{...h,method:"GET"}),post:async(n,h)=>V(n,{...h,method:"POST"}),extend:(n)=>{let h={...l,...n};return{get:async(t,o)=>V(t,{...h,...o,method:"GET"}),post:async(t,o)=>V(t,{...h,...o,method:"POST"}),extend:(t)=>X.extend({...h,...t})}}};var Un={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_ctrl_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_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_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,wallet_bitkeep_not_found:21001,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,api_v2_invalid_method_key_hash:50003,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class g extends Error{static ErrorCode=Un;constructor(n,h){let t=typeof n==="string",o=t?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(o,{cause:{code:g.ErrorCode[o],message:`${o}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,g.prototype)}}function Ct(n){if(n<0)throw new g({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function at(n){if(n<0)throw new g({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function it(n,h){try{return n()}catch(t){if(h)throw new g(h,t);return console.error(t)}}function xt(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Dn=["production","test"].includes("development"),Hn=new Set;function Fn(n,h){if(!Dn&&n){if(Hn.has(h))return;Hn.add(h),console.warn(h)}}async function pt(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{return(await X.get(`${n!=="thorchain-1"?W("THOR_STAGENET"):W("THOR")}/status`)).result.node_info.network}catch(h){return n}}var An=[...Object.values(_),"TERRA"];function Tn(n=""){let h=n.toUpperCase(),[t]=h.split(".");if(An.includes(t))return!0;let[o]=h.split("/");if(An.includes(o))return!0;throw new g({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function At(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var Y=8,f=(n)=>10n**BigInt(n),Z=(n)=>Math.log10(Number.parseFloat(n.toString()));function b({value:n,bigIntDecimal:h=Y,decimal:t=Y}){if(t===0)return n.toString();let o=n<0n,c=n.toString().substring(o?1:0),C=t-(c.length-1);if(C>0)c="0".repeat(C)+c;let a=c.length-t,i=c.slice(-t);if(Number.parseInt(i[h]||"0")>=5)i=`${i.substring(0,h-1)}${(Number.parseInt(i[h-1]||"0")+1).toString()}`;else i=i.substring(0,h);return`${o?"-":""}${c.slice(0,a)}.${i}`.replace(/\.?0*$/,"")}class y{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new y({decimal:h,value:b({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return y.fromBigInt(n.getBaseValue("bigint")*f(t)/f(h),t)}constructor(n){let h=r(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:f(Math.max(Bn(m(h)),this.decimal||0)),this.#c(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let t=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||Z(this.decimalMultiplier));switch(n){case"number":return Number(t);case"string":return t;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n,h){let t=this.decimalMultiplier/f(h||this.decimal||F.THOR),o=this.bigIntValue/t;switch(n){case"number":return Number(o);case"string":return o.toString();case"bigint":return o}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let t=r(n),o=m(t);if(o==="0"||o==="undefined")return 0n;return this.#o(o,h)}toSignificant(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if((Number.parseInt(o)?o.length+c.length:c.length)<=n)return this.getValue("string");if(o.length>=n)return o.slice(0,n).padEnd(o.length,"0");if(Number.parseInt(o))return`${o}.${c.slice(0,n-o.length)}`.padEnd(n-o.length,"0");let a=Number.parseInt(c),i=`${a}`.slice(0,n);return`0.${i.padStart(c.length-`${a}`.length+i.length,"0")}`}toFixed(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if(Number.parseInt(o))return`${o}.${c.slice(0,n)}`.padEnd(n,"0");let C=Number.parseInt(c),a=`${C}`.slice(0,n);return`0.${a.padStart(c.length-`${C}`.length+a.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],o=Math.floor(Math.log10(Math.abs(h))/3),c=t[o];if(!c)return this.getValue("string");let C=10**(o*3);return`${(h/C).toFixed(n)}${c}`}toCurrency(n="$",{currencyPosition:h="start",decimal:t=2,decimalSeparator:o=".",thousandSeparator:c=","}={}){let C=this.getValue("number"),[a="",i=""]=C.toFixed(6).split("."),A=a.replace(/\B(?=(\d{3})+(?!\d))/g,c),p=a||i?a==="0"?`${Number.parseFloat(`0.${i}`)}`.replace(".",o):`${A}${Number.parseInt(i)?`${o}${i.slice(0,t)}`:""}`:"0.00";return`${h==="start"?n:""}${p}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let t=h||this.decimal||Y,o=Math.max(t,Z(this.decimalMultiplier)),c=n<0n,C=n.toString().substring(c?1:0),a=o-(C.length-1),i=a>0?"0".repeat(a)+C:C,A=i.length-o,p=i.slice(-o);if(Number.parseInt(p[t]||"0")>=5)p=`${p.substring(0,t-1)}${(Number.parseInt(p[t-1]||"0")+1).toString()}`;else p=p.substring(0,t);return`${c?"-":""}${i.slice(0,A)}.${p}`.replace(/\.?0*$/,"")}#h(n,...h){let t=this.#t(this,...h),o=Math.max(t,Z(this.decimalMultiplier)),c=f(o),C=h.reduce((i,A)=>{let p=this.getBigIntValue(A,o);switch(n){case"add":return i+p;case"sub":return i-p;case"mul":return i*p/c;case"div":{if(p===0n)throw new RangeError("Division by zero");return i*c/p}default:return i}},this.bigIntValue*c/this.decimalMultiplier),a=b({bigIntDecimal:o,decimal:o,value:C});return new this.constructor({decimalMultiplier:f(o),decimal:this.decimal,value:a,identifier:this.toString()})}#n(n,...h){let t=this.#t(this,...h),o=this.getBigIntValue(h[0]||"0",t),c=this.getBigIntValue(this,t);switch(n){case"gt":return c>o;case"gte":return c>=o;case"lt":return c<o;case"lte":return c<=o;case"eqValue":return c===o}}#c(n){let h=m(n)||"0";this.bigIntValue=this.#o(h)}#t(...n){let h=n.map((t)=>{return typeof t==="object"?t.decimal||Z(t.decimalMultiplier):Bn(m(t))}).filter(Boolean);return Math.max(...h,Y)}#o(n,h){let t=h?f(h):this.decimalMultiplier,o=Z(t),[c="",C=""]=n.split(".");return BigInt(`${c}${C.padEnd(o,"0")}`)}}var dn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function m(n){let t=`${typeof n==="number"?dn.format(n):r(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function Bn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,Y)}function r(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var U=new Map;class O extends y{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:t,chain:o,symbol:c,identifier:C}){super(typeof n==="object"?n:{decimal:h,value:n});let a=e(C||`${o}.${c}`);this.type=On(a),this.tax=t,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=xn[a.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[t,o,c]=n.split(".");if(!(t&&o))throw new g({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let C=t==="THOR"&&c?`${t}.${o}/${c}`:n;return O.from({asset:C,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...o}){let c=n instanceof y?n.getValue("string"):n,C="chain"in o,a=C?o.chain:o.asset,i=C||Nn.includes(a),{identifier:A,decimal:p}=i?gn(a):{identifier:a,decimal:void 0},{chain:H,isSynthetic:S,isTradeAsset:L}=e(A),G=U.get(H==="SOL"?A:A.toUpperCase()),I=G?.decimal||p;Fn(!(t||I),`Couldn't find static decimal for ${A} (Using default ${F[H]} decimal as fallback). | ||
This can result in incorrect calculations and mess with amount sent on transactions. | ||
You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets() | ||
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:j,identifier:T,tax:q}=I||{decimal:y||p[F],identifier:A},w=h?D(BigInt(c),h):D(c,j);return t?vn(T,h?w:c):S||$?En(T,w):new O({tax:q,decimal:j,identifier:T,value:w})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((t)=>{for(let o of Object.values(t))for(let{identifier:c,chain:C,...a}of o.tokens)U.set(C!=="SOL"?c.toUpperCase():c,{identifier:c,decimal:"decimals"in a?a.decimals:p[C]});n({ok:!0})})}catch(t){console.error(t),h({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return O.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return O.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return O.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=p.THOR){return O.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=p.THOR){return O.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return O.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(_).includes(n))return O.from({chain:n,value:h});return O.from({asset:n,value:h})}}function _t(n){let h=O.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function vn(n,h=0){Bn(n);let o=n.includes("SOL.")?n:n.toUpperCase(),c=U.get(o),C=c?.decimal||await Nn(e(n));if(!c)U.set(o,{identifier:n,decimal:C});return new O({decimal:C,value:D(h,C),identifier:n})}function En(n,h=0){let t=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,o=t?["MAYA","THOR"].includes(t):!1,c=n.slice(0,14).includes("~")?"~":"/",[C,a]=o?n.split(".").slice(1).join().split(c):n.split(c);if(!(C&&a))throw new u({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new O({decimal:8,value:D(h,8),identifier:`${t||"THOR"}.${C}${c}${a}`})}function D(n,h){return typeof n==="bigint"?b({value:n,bigIntDecimal:h,decimal:h}):n}function e(n){let h=n.slice(0,14).includes("/"),t=n.slice(0,14).includes("~"),o=t?"~":"/",c=n.split(".")?.[0]?.toUpperCase()==="THOR",C=n.split(".")?.[0]?.toUpperCase()==="MAYA",[a,i=""]=c||C?n.split(".").slice(1).join().split(o):n.split(o);if((h||t)&&!(a&&i))throw new u({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let A=n.includes(".")&&!h&&!t?n:`${C?"MAYA":"THOR"}.${i}`,[R,...F]=A.split("."),S=h||t?i:F.join("."),$=S.split("-"),I=$.length===1?$[0]:$.slice(0,-1).join("-"),y=$.length===1?void 0:$[$.length-1],j=R==="SOL"?y:y?.toLowerCase();return{address:j,chain:R,isGasAsset:nn({chain:R,symbol:S}),isSynthetic:h,isTradeAsset:t,ticker:I,symbol:(h||t?`${a}${o}`:"")+(j?`${I}-${j??""}`:S)}}var ln="0x313ce567",kn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],un=async({chain:n,to:h})=>{try{let{result:t}=await J.post(E[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:ln},"latest"]})});return Number.parseInt(BigInt(t||p[n]).toString())}catch(t){return console.error(t),p[n]}},rn=async({symbol:n})=>{try{let h=n.split("-")[1]?.toLowerCase(),{manager:t}=await J.post(`${E["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return t.divisibility.value.divisibility}catch(h){return console.error(h),p["XRD"]}},en=(n)=>{if(n==="ETH")return p.ETH;let h=n.split("-"),t=h.length===1?void 0:h[h.length-1]?.toLowerCase();return t?.startsWith("0x")?un({chain:"ETH",to:t}):p.ETH},nh=(n)=>{let h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?un({chain:"AVAX",to:t.toLowerCase()}):p.AVAX},hh=(n)=>{if(n==="BSC")return p.BSC;return p.BSC},th=(n)=>{if(n==="XRD")return p.XRD;return rn({symbol:n})},Nn=({chain:n,symbol:h})=>{switch(n){case"ETH":return en(h);case"AVAX":return nh(h);case"BSC":return hh(h);case"XRD":return th(h);default:return p[n]}},Gt=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return O.from({asset:`${n}.ETH`});case"MAYA":return O.from({asset:`${n}.CACAO`});case"GAIA":return O.from({asset:`${n}.ATOM`});case"BSC":return O.from({asset:`${n}.BNB`});case"THOR":return O.from({asset:`${n}.RUNE`});default:return O.from({asset:`${n}.${n}`})}},nn=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},On=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:p[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:p[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:p[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:p[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:p[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:p[n]}}},gn=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},It=(n)=>{let[h,...t]=n.split("."),o=n.includes("/"),c=t.join("."),C=c?.split("-"),a=C?.length?C.length===1?C[0]:C.slice(0,-1).join("-"):void 0;return{chain:h,symbol:c,ticker:a,synth:o}},oh=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),ch=(n)=>{let[h,t]=n.split(".");if(!Q.includes(h))return!0;let o=t.split("-"),c=o.length===1?void 0:o[o.length-1];return nn({chain:h,symbol:t})||!!c},yt=(n)=>n.filter(({chain:h,value:t,symbol:o})=>{let c=`${h}.${o}`;return!oh.test(c)&&ch(c)&&t!=="0"});async function wt(n){let h=await import("@swapkit/tokens");for(let t of Object.values(h))for(let{identifier:o,chain:c,...C}of t.tokens){if("identifier"in n&&o===n.identifier)return o;if("address"in C&&"chain"in n&&c===n.chain&&C.address.toLowerCase()===n.contract.toLowerCase())return o}return}var Xt={ARB:1,AVAX:3,BASE:1,BSC:3,BTC:600,BCH:600,FLIP:5,GAIA:1.5,DASH:150,DOGE:600,ETH:12.5,FIAT:60,KUJI:2.2,LTC:150,MAYA:6,OP:1,DOT:6,MATIC:2.1,XRD:5,SOL:1,THOR:6};var hn=(n,h)=>{return[...n.slice(0,n.length-1),h]};function ft([n,h,t,o,c]){return`m/${n}'/${h}'/${t}'/${o}${typeof c!=="number"?"":`/${c}`}`}function zt({chain:n,index:h,addressIndex:t=0,type:o}){if(Q.includes(n)){if(o&&["legacy","account"].includes(o))return[44,60,0,h];if(o==="ledgerLive")return[44,60,h,0,t];return hn(K[n],h)}if(n==="SOL"){if(o==="account")return[44,501,0,h];return hn(K[n],h)}let c=n==="LTC"?2:0;switch(o){case"nativeSegwitMiddleAccount":return[84,c,h,0,t];case"segwit":return[49,c,0,0,h];case"legacy":return[44,c,0,0,h];default:return hn(K[n],h)}}function Zt(n){let[h,t,o]=n.split("/").map((c)=>Number.parseInt(c,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}function sh({liquidityUnits:n,poolUnits:h,runeDepth:t}){let o=P(n),c=P(h),C=P(t),a=o.mul(C),i=c.mul(c).mul(2),A=c.mul(o).mul(2),R=o.mul(o),F=c.mul(c).mul(c);return a.mul(i.sub(A).add(R)).div(F)}function Ch({liquidityUnits:n,poolUnits:h,assetDepth:t}){let o=P(n),c=P(h),C=P(t),a=o.mul(C),i=c.mul(c).mul(2),A=c.mul(o).mul(2),R=o.mul(o),F=a.mul(i.sub(A).add(R)),S=c.mul(c).mul(c);return F.div(S)}function Qt({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:o}){return sh({runeDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function Wt({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:o}){return Ch({assetDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function P(n){return L.fromBigInt(BigInt(n),p.THOR)}function ah({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o}){return{assetAmount:P(o).mul(n).div(h),runeAmount:P(t).mul(n).div(h)}}function Kt({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o,percent:c}){return Object.fromEntries(Object.entries(ah({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o})).map(([C,a])=>[C,a.mul(c)]))}function Vt({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:o,runeAmount:c,assetAmount:C}){let a=new L({value:n,decimal:8}),i=new L({value:t,decimal:8}),A=new L({value:h,decimal:8}),R=new L({value:c,decimal:8}),F=new L({value:C,decimal:8}),S=R.mul(i),$=F.mul(a),I=R.mul(F),y=a.mul(i),j=A.mul(S.add($.add(I.mul(2)))),T=S.add($.add(y.mul(2))),q=j.div(T),w=P(o).add(q);if(q.getBaseValue("number")===0)return w.div(A).getBaseValue("number");let k=A.add(w);return w.div(k).getBaseValue("number")}function mt({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:o}){if(n==="0"||h==="0"||t==="0"||o==="0")return 0;let c=P(t),C=P(o),a=P(h),i=P(n),A=a.mul(c).sub(C.mul(i)),R=C.mul(i).add(c.mul(C));return Math.abs(A.div(R).getBaseValue("number"))}function ih({type:n,address:h}){return`${n}:${h}`}function xh({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function Et(n){return M("POOL+",n)}function Rh({chain:n,symbol:h,...t}){return M(`${"+"}:${n}/${h}`,t)}function Hh({chain:n,symbol:h,address:t,...o}){let c=Th({chain:n,symbol:h}),C=t?`:${t}:`:":";return M(`${"+"}:${c}${C}`,o)}function Fh({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function ph({chain:n,symbol:h,ticker:t,basisPoints:o,targetAsset:c}){let C=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,a=c?`:${c}`:"";return`${"-"}:${n}.${C}:${o}${a}`}function lt({basisPoints:n,...h}){return M(`${"POOL-"}:${n}`,h)}function Ah({name:n,chain:h,address:t,owner:o}){let c=`${"~"}:${n}:${h}:${t}`,C=o?`:${o}`:"";return`${c}${C}`}function rt({name:n,chain:h,asset:t,payout:o,owner:c}){return`${"~"}:${n}:${h}:${o}:${c}:${t}`}function Bh(n,{asset:h,address:t,minAmount:o,...c}){let C=`${n}:${h}:${t}`,a=o?`:${o}`:"";return M(`${C}${a}`,c)}function M(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){let o=`${n}${h?`:${h}:${t||0}`:""}`;return o.endsWith(":")?o.slice(0,-1):o}function Th({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var et=(n,h)=>{switch(n){case"LEAVE":case"BOND":return ih({type:n,address:h?.address});case"UNBOND":return xh({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return Ah(h);case"$+":case"$-":return Bh(n,h);case"+":{let{chain:t,symbol:o,address:c,singleSide:C}=h;if(C)return Rh({chain:t,symbol:o});return Hh({chain:t,symbol:o,address:c})}case"-":{let{chain:t,ticker:o,symbol:c,basisPoints:C,targetAssetString:a,singleSide:i}=h;if(i)return Fh({chain:t,symbol:c,basisPoints:C});return ph({chain:t,ticker:o,symbol:c,basisPoints:C,targetAsset:a})}default:throw new u({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};var kh=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],Nh=(n,h,t)=>async(...o)=>{try{await Oh(h,t)}catch(c){throw new u({errorKey:"helpers_failed_to_switch_network",info:{error:c}})}return n(...o)},Sn=({provider:n,params:h,method:t})=>{if(!n?.send)throw new u("helpers_not_found_provider");let o=h?Array.isArray(h)?h:[h]:[];return n.send(t,o)},oo=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{let o=kh.reduce((c,C)=>{if(!n[C])return c;let a=n[C];if(typeof a!=="function")return c;return{...c,[C]:Nh(a,t,h)}},{});return{...n,...o}},co=(n,h)=>Sn({provider:n,method:"wallet_addEthereumChain",params:[h]}),Oh=(n,h="0x1")=>Sn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]}),so=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},Co=()=>{let{isTrust:n,isBraveWallet:h,__XDEFI:t,overrideIsMetaMask:o,selectedProvider:c}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(o&&c?.isCoinbaseWallet)return"COINBASE_WEB";if(t)"CTRL";return"METAMASK"},ao=(n)=>{return gh().includes(n)},gh=()=>{let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,o=window?.ethereum?.isTrust||window?.trustwallet,c=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,C=window?.bitkeep?.ethereum,a=[];if(n)a.push("METAMASK");if(h)a.push("CTRL");if(t)a.push("BRAVE");if(o)a.push("TRUSTWALLET_WEB");if(c)a.push("COINBASE_WEB");if(uh())a.push("OKX_MOBILE");if(C)a.push("BITGET");return a};function io({chain:n,covalentApiKey:h,ethplorerApiKey:t}){let o=n!=="ETH"&&!h?"covalentApiKey":t?void 0:"ethplorerApiKey";if(o)throw new u({errorKey:"wallet_missing_api_key",info:{missingKey:o}});return{covalentApiKey:h,ethplorerApiKey:t}}function xo(){let n=[];function h(o){if(n.map((c)=>c.info.uuid).includes(o.detail.info.uuid))return;n.push(o.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:t}}var uh=()=>{let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),o=h||t,c=/OKApp/i.test(n);return o&&c},Ro=()=>typeof window.ethereum!=="undefined";class L extends G{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new L({decimal:h,value:b({value:n,bigIntDecimal:h,decimal:h})})}}export{at as wrapWithThrow,Nh as wrapMethodWithNetworkSwitch,pn as warnOnce,pt as validateTNS,Bn as validateIdentifier,hn as updatedLastIndex,Oh as switchEVMWalletNetwork,eh as setRequestClientConfig,oo as prepareNetworkSwitch,uh as okxMobileEnabled,gh as listWeb3EVMWallets,Ro as isWeb3Detected,nn as isGasAsset,ao as isDetected,yh as initializeRPCUrlsWithFallback,Zt as getWalletFormatFor,st as getTHORNameCost,Kt as getSymmetricWithdraw,ah as getSymmetricPoolShare,W as getRPCUrl,_t as getMinAmountByChain,ph as getMemoForWithdraw,xh as getMemoForUnbond,Fh as getMemoForSaverWithdraw,Rh as getMemoForSaverDeposit,lt as getMemoForRunePoolWithdraw,Et as getMemoForRunePoolDeposit,Ah as getMemoForNameRegister,rt as getMemoForNamePreferredAssetRegister,Bh as getMemoForLoan,ih as getMemoForLeaveAndBond,Hh as getMemoForDeposit,et as getMemoFor,Ct as getMAYANameCost,mt as getLiquiditySlippage,Gt as getGasAsset,Vt as getEstimatedPoolShare,Co as getETHDefaultWallet,xo as getEIP6963Wallets,xt as getDynamicChainId,zt as getDerivationPathFor,Nn as getDecimal,On as getCommonAssetInfo,it as getChainIdentifier,Qt as getAsymmetricRuneWithdrawAmount,sh as getAsymmetricRuneShare,Wt as getAsymmetricAssetWithdrawAmount,Ch as getAsymmetricAssetShare,gn as getAssetType,b as formatBigIntToSafeValue,wt as findAssetBy,yt as filterAssets,io as ensureEVMApiKeys,ft as derivationPathToString,mn as defaultRequestHeaders,Xt as blockTimes,It as assetFromString,co as addEVMWalletNetwork,so as addAccountsChangedCallback,Wn as WarningCodeEnum,Rn as WalletOption,Lh as UTXOChains,Gh as TCSupportedChains,L as SwapKitNumber,u as SwapKitError,$h as SubstrateChains,v as StagenetChain,zh as SWAP_OUT,fh as SWAP_IN,J as RequestClient,Cn as RPC_URLS,zn as RPCUrl,Jn as QuoteMode,Kn as ProviderName,K as NetworkDerivationPath,Hn as MemoType,Ih as MAYASupportedChains,Yn as LedgerErrorCode,Vn as FeeTypeEnum,Mn as FeeOption,Gn as FALLBACK_URLS,Zn as ExplorerUrl,Qn as ErrorCode,In as EXPLORER_URLS,Q as EVMChains,fn as DerivationPath,jh as CosmosChains,bn as ContractAddress,kn as CommonAssetStrings,E as ChainToRPC,wh as ChainToHexChainId,Xh as ChainToExplorerUrl,xn as ChainToChainId,_h as ChainIdToChain,f as ChainId,_ as Chain,Ph as BlockTimes,G as BigIntArithmetics,p as BaseDecimal,O as AssetValue,qn as ApproveMode,bh as AGG_SWAP}; | ||
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:j,identifier:B,tax:q}=G||{decimal:I||F[H],identifier:A},w=h?D(BigInt(c),h):D(c,j);return t?vn(B,h?w:c):S||L?En(B,w):new O({tax:q,decimal:j,identifier:B,value:w})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((t)=>{for(let o of Object.values(t.tokenLists))for(let{identifier:c,chain:C,...a}of o.tokens)U.set(C!=="SOL"?c.toUpperCase():c,{identifier:c,decimal:"decimals"in a?a.decimals:F[C]});n({ok:!0})})}catch(t){console.error(t),h({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return O.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return O.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return O.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=F.THOR){return O.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=F.THOR){return O.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return O.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(_).includes(n))return O.from({chain:n,value:h});return O.from({asset:n,value:h})}}function $t(n){let h=O.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function vn(n,h=0){Tn(n);let o=n.includes("SOL.")?n:n.toUpperCase(),c=U.get(o),C=c?.decimal||await kn(e(n));if(!c)U.set(o,{identifier:n,decimal:C});return new O({decimal:C,value:D(h,C),identifier:n})}function En(n,h=0){let t=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,o=t?["MAYA","THOR"].includes(t):!1,c=n.slice(0,14).includes("~")?"~":"/",[C,a]=o?n.split(".").slice(1).join().split(c):n.split(c);if(!(C&&a))throw new g({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new O({decimal:8,value:D(h,8),identifier:`${t||"THOR"}.${C}${c}${a}`})}function D(n,h){return typeof n==="bigint"?b({value:n,bigIntDecimal:h,decimal:h}):n}function e(n){let h=n.slice(0,14).includes("/"),t=n.slice(0,14).includes("~"),o=t?"~":"/",c=n.split(".")?.[0]?.toUpperCase()==="THOR",C=n.split(".")?.[0]?.toUpperCase()==="MAYA",[a,i=""]=c||C?n.split(".").slice(1).join().split(o):n.split(o);if((h||t)&&!(a&&i))throw new g({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let A=n.includes(".")&&!h&&!t?n:`${C?"MAYA":"THOR"}.${i}`,[p,...H]=A.split("."),S=h||t?i:H.join("."),L=S.split("-"),G=L.length===1?L[0]:L.slice(0,-1).join("-"),I=L.length===1?void 0:L[L.length-1],j=p==="SOL"?I:I?.toLowerCase();return{address:j,chain:p,isGasAsset:nn({chain:p,symbol:S}),isSynthetic:h,isTradeAsset:t,ticker:G,symbol:(h||t?`${a}${o}`:"")+(j?`${G}-${j??""}`:S)}}var ln="0x313ce567",Nn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],un=async({chain:n,to:h})=>{try{let{result:t}=await X.post(E[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:ln},"latest"]})});return Number.parseInt(BigInt(t||F[n]).toString())}catch(t){return console.error(t),F[n]}},rn=async({symbol:n})=>{try{let h=n.split("-")[1]?.toLowerCase(),{manager:t}=await X.post(`${E["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return t.divisibility.value.divisibility}catch(h){return console.error(h),F["XRD"]}},en=(n)=>{if(n==="ETH")return F.ETH;let h=n.split("-"),t=h.length===1?void 0:h[h.length-1]?.toLowerCase();return t?.startsWith("0x")?un({chain:"ETH",to:t}):F.ETH},nh=(n)=>{let h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?un({chain:"AVAX",to:t.toLowerCase()}):F.AVAX},hh=(n)=>{if(n==="BSC")return F.BSC;return F.BSC},th=(n)=>{if(n==="XRD")return F.XRD;return rn({symbol:n})},kn=({chain:n,symbol:h})=>{switch(n){case"ETH":return en(h);case"AVAX":return nh(h);case"BSC":return hh(h);case"XRD":return th(h);default:return F[n]}},Gt=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return O.from({asset:`${n}.ETH`});case"MAYA":return O.from({asset:`${n}.CACAO`});case"GAIA":return O.from({asset:`${n}.ATOM`});case"BSC":return O.from({asset:`${n}.BNB`});case"THOR":return O.from({asset:`${n}.RUNE`});default:return O.from({asset:`${n}.${n}`})}},nn=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},gn=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:F[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:F[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:F[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:F[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:F[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:F[n]}}},On=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},It=(n)=>{let[h,...t]=n.split("."),o=n.includes("/"),c=t.join("."),C=c?.split("-"),a=C?.length?C.length===1?C[0]:C.slice(0,-1).join("-"):void 0;return{chain:h,symbol:c,ticker:a,synth:o}},oh=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),ch=(n)=>{let[h,t]=n.split(".");if(!Q.includes(h))return!0;let o=t.split("-"),c=o.length===1?void 0:o[o.length-1];return nn({chain:h,symbol:t})||!!c},wt=(n)=>n.filter(({chain:h,value:t,symbol:o})=>{let c=`${h}.${o}`;return!oh.test(c)&&ch(c)&&t!=="0"});async function ft(n){let h=await import("@swapkit/tokens");for(let t of Object.values(h.tokenLists))for(let{identifier:o,chain:c,...C}of t.tokens){if("identifier"in n&&o===n.identifier)return o;if("address"in C&&"chain"in n&&c===n.chain&&C.address.toLowerCase()===n.contract.toLowerCase())return o}return}var Xt={ARB:1,AVAX:3,BASE:1,BSC:3,BTC:600,BCH:600,FLIP:5,GAIA:1.5,DASH:150,DOGE:600,ETH:12.5,FIAT:60,KUJI:2.2,LTC:150,MAYA:6,OP:1,DOT:6,MATIC:2.1,XRD:5,SOL:1,THOR:6};var hn=(n,h)=>{return[...n.slice(0,n.length-1),h]};function zt([n,h,t,o,c]){return`m/${n}'/${h}'/${t}'/${o}${typeof c!=="number"?"":`/${c}`}`}function Zt({chain:n,index:h,addressIndex:t=0,type:o}){if(Q.includes(n)){if(o&&["legacy","account"].includes(o))return[44,60,0,h];if(o==="ledgerLive")return[44,60,h,0,t];return hn(K[n],h)}if(n==="SOL"){if(o==="account")return[44,501,0,h];return hn(K[n],h)}let c=n==="LTC"?2:0;switch(o){case"nativeSegwitMiddleAccount":return[84,c,h,0,t];case"segwit":return[49,c,0,0,h];case"legacy":return[44,c,0,0,h];default:return hn(K[n],h)}}function Yt(n){let[h,t,o]=n.split("/").map((c)=>Number.parseInt(c,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}function sh({liquidityUnits:n,poolUnits:h,runeDepth:t}){let o=$(n),c=$(h),C=$(t),a=o.mul(C),i=c.mul(c).mul(2),A=c.mul(o).mul(2),p=o.mul(o),H=c.mul(c).mul(c);return a.mul(i.sub(A).add(p)).div(H)}function Ch({liquidityUnits:n,poolUnits:h,assetDepth:t}){let o=$(n),c=$(h),C=$(t),a=o.mul(C),i=c.mul(c).mul(2),A=c.mul(o).mul(2),p=o.mul(o),H=a.mul(i.sub(A).add(p)),S=c.mul(c).mul(c);return H.div(S)}function Wt({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:o}){return sh({runeDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function Kt({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:o}){return Ch({assetDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function $(n){return P.fromBigInt(BigInt(n),F.THOR)}function ah({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o}){return{assetAmount:$(o).mul(n).div(h),runeAmount:$(t).mul(n).div(h)}}function Vt({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o,percent:c}){return Object.fromEntries(Object.entries(ah({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o})).map(([C,a])=>[C,a.mul(c)]))}function mt({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:o,runeAmount:c,assetAmount:C}){let a=new P({value:n,decimal:8}),i=new P({value:t,decimal:8}),A=new P({value:h,decimal:8}),p=new P({value:c,decimal:8}),H=new P({value:C,decimal:8}),S=p.mul(i),L=H.mul(a),G=p.mul(H),I=a.mul(i),j=A.mul(S.add(L.add(G.mul(2)))),B=S.add(L.add(I.mul(2))),q=j.div(B),w=$(o).add(q);if(q.getBaseValue("number")===0)return w.div(A).getBaseValue("number");let N=A.add(w);return w.div(N).getBaseValue("number")}function Ut({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:o}){if(n==="0"||h==="0"||t==="0"||o==="0")return 0;let c=$(t),C=$(o),a=$(h),i=$(n),A=a.mul(c).sub(C.mul(i)),p=C.mul(i).add(c.mul(C));return Math.abs(A.div(p).getBaseValue("number"))}function ih({type:n,address:h}){return`${n}:${h}`}function xh({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function lt(n){return M("POOL+",n)}function ph({chain:n,symbol:h,...t}){return M(`${"+"}:${n}/${h}`,t)}function Rh({chain:n,symbol:h,address:t,...o}){let c=Bh({chain:n,symbol:h}),C=t?`:${t}:`:":";return M(`${"+"}:${c}${C}`,o)}function Hh({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function Fh({chain:n,symbol:h,ticker:t,basisPoints:o,targetAsset:c}){let C=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,a=c?`:${c}`:"";return`${"-"}:${n}.${C}:${o}${a}`}function rt({basisPoints:n,...h}){return M(`${"POOL-"}:${n}`,h)}function Ah({name:n,chain:h,address:t,owner:o}){let c=`${"~"}:${n}:${h}:${t}`,C=o?`:${o}`:"";return`${c}${C}`}function et({name:n,chain:h,asset:t,payout:o,owner:c}){return`${"~"}:${n}:${h}:${o}:${c}:${t}`}function Th(n,{asset:h,address:t,minAmount:o,...c}){let C=`${n}:${h}:${t}`,a=o?`:${o}`:"";return M(`${C}${a}`,c)}function M(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){let o=`${n}${h?`:${h}:${t||0}`:""}`;return o.endsWith(":")?o.slice(0,-1):o}function Bh({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var no=(n,h)=>{switch(n){case"LEAVE":case"BOND":return ih({type:n,address:h?.address});case"UNBOND":return xh({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return Ah(h);case"$+":case"$-":return Th(n,h);case"+":{let{chain:t,symbol:o,address:c,singleSide:C}=h;if(C)return ph({chain:t,symbol:o});return Rh({chain:t,symbol:o,address:c})}case"-":{let{chain:t,ticker:o,symbol:c,basisPoints:C,targetAssetString:a,singleSide:i}=h;if(i)return Hh({chain:t,symbol:c,basisPoints:C});return Fh({chain:t,ticker:o,symbol:c,basisPoints:C,targetAsset:a})}default:throw new g({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};var Nh=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],kh=(n,h,t)=>async(...o)=>{try{await Oh(h,t)}catch(c){throw new g({errorKey:"helpers_failed_to_switch_network",info:{error:c}})}return n(...o)},Sn=({provider:n,params:h,method:t})=>{if(!n?.send)throw new g("helpers_not_found_provider");let o=h?Array.isArray(h)?h:[h]:[];return n.send(t,o)},co=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{let o=Nh.reduce((c,C)=>{if(!n[C])return c;let a=n[C];if(typeof a!=="function")return c;return{...c,[C]:kh(a,t,h)}},{});return{...n,...o}},gh=(n,h)=>Sn({provider:n,method:"wallet_addEthereumChain",params:[h]}),Oh=(n,h="0x1",t)=>{try{Sn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]})}catch(o){if(!t)throw new Error("Failed to switch network, networkParams not provided");gh(n,t)}},so=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},Co=()=>{let{isTrust:n,isBraveWallet:h,__XDEFI:t,overrideIsMetaMask:o,selectedProvider:c}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(o&&c?.isCoinbaseWallet)return"COINBASE_WEB";if(t)"CTRL";return"METAMASK"},ao=(n)=>{return uh().includes(n)},uh=()=>{let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,o=window?.ethereum?.isTrust||window?.trustwallet,c=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,C=window?.bitkeep?.ethereum,a=[];if(n)a.push("METAMASK");if(h)a.push("CTRL");if(t)a.push("BRAVE");if(o)a.push("TRUSTWALLET_WEB");if(c)a.push("COINBASE_WEB");if(Sh())a.push("OKX_MOBILE");if(C)a.push("BITGET");return a};function io({chain:n,covalentApiKey:h,ethplorerApiKey:t}){let o=n!=="ETH"&&!h?"covalentApiKey":t?void 0:"ethplorerApiKey";if(o)throw new g({errorKey:"wallet_missing_api_key",info:{missingKey:o}});return{covalentApiKey:h,ethplorerApiKey:t}}function xo(){let n=[];function h(o){if(n.map((c)=>c.info.uuid).includes(o.detail.info.uuid))return;n.push(o.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:t}}var Sh=()=>{let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),o=h||t,c=/OKApp/i.test(n);return o&&c},po=()=>typeof window.ethereum!=="undefined";class P extends y{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new P({decimal:h,value:b({value:n,bigIntDecimal:h,decimal:h})})}}function To(n,h,t){let o=n.filter((C)=>h.includes(C));if(o.length===0)throw new g("wallet_chain_not_supported",{wallet:t,chain:n.join(", ")});let c=n.filter((C)=>!h.includes(C));if(c.length>0)console.warn(`${t} wallet does not support the following chains: ${c.join(", ")}. These chains will be ignored.`);return o}export{it as wrapWithThrow,kh as wrapMethodWithNetworkSwitch,Fn as warnOnce,At as validateTNS,Tn as validateIdentifier,hn as updatedLastIndex,Oh as switchEVMWalletNetwork,nt as setRequestClientConfig,co as prepareNetworkSwitch,Sh as okxMobileEnabled,uh as listWeb3EVMWallets,po as isWeb3Detected,nn as isGasAsset,ao as isDetected,wh as initializeRPCUrlsWithFallback,Yt as getWalletFormatFor,Ct as getTHORNameCost,Vt as getSymmetricWithdraw,ah as getSymmetricPoolShare,W as getRPCUrl,$t as getMinAmountByChain,Fh as getMemoForWithdraw,xh as getMemoForUnbond,Hh as getMemoForSaverWithdraw,ph as getMemoForSaverDeposit,rt as getMemoForRunePoolWithdraw,lt as getMemoForRunePoolDeposit,Ah as getMemoForNameRegister,et as getMemoForNamePreferredAssetRegister,Th as getMemoForLoan,ih as getMemoForLeaveAndBond,Rh as getMemoForDeposit,no as getMemoFor,at as getMAYANameCost,Ut as getLiquiditySlippage,Gt as getGasAsset,mt as getEstimatedPoolShare,Co as getETHDefaultWallet,xo as getEIP6963Wallets,pt as getDynamicChainId,Zt as getDerivationPathFor,kn as getDecimal,gn as getCommonAssetInfo,xt as getChainIdentifier,Wt as getAsymmetricRuneWithdrawAmount,sh as getAsymmetricRuneShare,Kt as getAsymmetricAssetWithdrawAmount,Ch as getAsymmetricAssetShare,On as getAssetType,b as formatBigIntToSafeValue,ft as findAssetBy,To as filterSupportedChains,wt as filterAssets,io as ensureEVMApiKeys,zt as derivationPathToString,mn as defaultRequestHeaders,Xt as blockTimes,It as assetFromString,gh as addEVMWalletNetwork,so as addAccountsChangedCallback,Wn as WarningCodeEnum,pn as WalletOption,jh as UTXOChains,Gh as TCSupportedChains,P as SwapKitNumber,g as SwapKitError,Ph as SubstrateChains,v as StagenetChain,Zh as SWAP_OUT,zh as SWAP_IN,X as RequestClient,Cn as RPC_URLS,zn as RPCUrl,Xn as QuoteMode,Kn as ProviderName,K as NetworkDerivationPath,Rn as MemoType,Ih as MAYASupportedChains,Yn as LedgerErrorCode,Vn as FeeTypeEnum,Mn as FeeOption,yn as FALLBACK_URLS,Zn as ExplorerUrl,Qn as ErrorCode,Gn as EXPLORER_URLS,Q as EVMChains,Jn as DerivationPath,yh as CosmosChains,bn as ContractAddress,Nn as CommonAssetStrings,E as ChainToRPC,fh as ChainToHexChainId,Xh as ChainToExplorerUrl,xn as ChainToChainId,$h as ChainIdToChain,J as ChainId,_ as Chain,Lh as BlockTimes,y as BigIntArithmetics,F as BaseDecimal,O as AssetValue,qn as ApproveMode,Jh as AGG_SWAP}; | ||
//# debugId=9D706BB2AB45797564756E2164756E21 | ||
//# debugId=EA7BEB74CB5ADB6F64756E2164756E21 |
@@ -6,11 +6,11 @@ { | ||
"@swapkit/contracts": "1.0.6", | ||
"@swapkit/tokens": "1.11.0" | ||
"@swapkit/tokens": "2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@swapkit/toolbox-cosmos": "1.7.3", | ||
"@swapkit/toolbox-evm": "1.7.11", | ||
"@swapkit/toolbox-radix": "1.2.27", | ||
"@swapkit/toolbox-solana": "1.3.12", | ||
"@swapkit/toolbox-substrate": "1.3.11", | ||
"@swapkit/toolbox-utxo": "1.2.11" | ||
"@swapkit/toolbox-cosmos": "1.8.0", | ||
"@swapkit/toolbox-evm": "1.8.0", | ||
"@swapkit/toolbox-radix": "1.2.28", | ||
"@swapkit/toolbox-solana": "1.4.0", | ||
"@swapkit/toolbox-substrate": "1.3.12", | ||
"@swapkit/toolbox-utxo": "1.2.12" | ||
}, | ||
@@ -39,3 +39,3 @@ "files": [ | ||
"types": "./src/index.ts", | ||
"version": "2.2.1" | ||
"version": "2.3.0" | ||
} |
@@ -263,3 +263,3 @@ import { AssetValue } from "../modules/assetValue"; | ||
for (const tokenList of Object.values(tokenPackages)) { | ||
for (const tokenList of Object.values(tokenPackages.tokenLists)) { | ||
for (const { identifier, chain: tokenChain, ...rest } of tokenList.tokens) { | ||
@@ -266,0 +266,0 @@ if ("identifier" in params && identifier === params.identifier) { |
@@ -32,2 +32,3 @@ import type { BrowserProvider } from "ethers"; | ||
bitkeep?: { ethereum: EthereumWindowProvider }; | ||
xfi?: { ethereum: EthereumWindowProvider }; | ||
} & Window; | ||
@@ -129,8 +130,19 @@ | ||
export const switchEVMWalletNetwork = (provider: BrowserProvider, chainId = ChainId.EthereumHex) => | ||
providerRequest({ provider, method: "wallet_switchEthereumChain", params: [{ chainId }] }); | ||
export const switchEVMWalletNetwork = ( | ||
provider: BrowserProvider, | ||
chainId = ChainId.EthereumHex, | ||
networkParams?: NetworkParams, | ||
) => { | ||
try { | ||
providerRequest({ provider, method: "wallet_switchEthereumChain", params: [{ chainId }] }); | ||
} catch (_error) { | ||
if (!networkParams) { | ||
throw new Error("Failed to switch network, networkParams not provided"); | ||
} | ||
addEVMWalletNetwork(provider, networkParams); | ||
} | ||
}; | ||
export const addAccountsChangedCallback = (callback: () => void) => { | ||
window.ethereum?.on("accountsChanged", () => callback()); | ||
// @ts-expect-error that should be implemented in ctrl and hooked up via swapkit core | ||
window.xfi?.ethereum.on("accountsChanged", () => callback()); | ||
@@ -137,0 +149,0 @@ }; |
@@ -23,1 +23,2 @@ export * from "@swapkit/contracts"; | ||
export * from "./modules/swapKitNumber"; | ||
export * from "./modules/walletUtils"; |
@@ -173,4 +173,4 @@ import { | ||
try { | ||
import("@swapkit/tokens").then((tokenPackages) => { | ||
for (const tokenList of Object.values(tokenPackages)) { | ||
import("@swapkit/tokens").then((tokenPackage) => { | ||
for (const tokenList of Object.values(tokenPackage.tokenLists)) { | ||
for (const { identifier, chain, ...rest } of tokenList.tokens) { | ||
@@ -177,0 +177,0 @@ staticTokensMap.set( |
@@ -210,3 +210,3 @@ export enum Chain { | ||
[Chain.Avalanche]: "https://avalanche-c-chain-rpc.publicnode.com", | ||
[Chain.Base]: "https://base.llamarpc.com", | ||
[Chain.Base]: "https://base-rpc.publicnode.com", | ||
[Chain.BinanceSmartChain]: "https://bsc-dataseed.binance.org", | ||
@@ -213,0 +213,0 @@ [Chain.Bitcoin]: "https://bitcoin-rpc.publicnode.com", |
@@ -1,17 +0,2 @@ | ||
import type { | ||
CaviarV1List, | ||
ChainflipList, | ||
JupiterList, | ||
MayaList, | ||
// OciswapV1List, | ||
OneInchList, | ||
OpenOceanV2List, | ||
PancakeswapList, | ||
PangolinList, | ||
SushiswapList, | ||
ThorchainList, | ||
TraderjoeV2List, | ||
UniswapV2List, | ||
UniswapV3List, | ||
} from "@swapkit/tokens"; | ||
import type { tokenLists } from "@swapkit/tokens"; | ||
@@ -21,15 +6,16 @@ export type TokenTax = { buy: number; sell: number }; | ||
export type TokenNames = | ||
| (typeof CaviarV1List)["tokens"][number]["identifier"] | ||
| (typeof ChainflipList)["tokens"][number]["identifier"] | ||
| (typeof JupiterList)["tokens"][number]["identifier"] | ||
| (typeof MayaList)["tokens"][number]["identifier"] | ||
// | (typeof OciswapV1List)["tokens"][number]["identifier"] | ||
| (typeof OneInchList)["tokens"][number]["identifier"] | ||
| (typeof OpenOceanV2List)["tokens"][number]["identifier"] | ||
| (typeof PancakeswapList)["tokens"][number]["identifier"] | ||
| (typeof PangolinList)["tokens"][number]["identifier"] | ||
| (typeof SushiswapList)["tokens"][number]["identifier"] | ||
| (typeof ThorchainList)["tokens"][number]["identifier"] | ||
| (typeof TraderjoeV2List)["tokens"][number]["identifier"] | ||
| (typeof UniswapV2List)["tokens"][number]["identifier"] | ||
| (typeof UniswapV3List)["tokens"][number]["identifier"]; | ||
| (typeof tokenLists)["CaviarV1List"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["ChainflipList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["JupiterList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["KadoList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["MayaList"]["tokens"][number]["identifier"] | ||
// | (typeof tokenLists)['OciswapV1List']["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["OneInchList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["OpenOceanV2List"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["PancakeswapList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["PangolinList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["SushiswapList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["ThorchainList"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["TraderjoeV2List"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["UniswapV2List"]["tokens"][number]["identifier"] | ||
| (typeof tokenLists)["UniswapV3List"]["tokens"][number]["identifier"]; |
Sorry, the diff of this file is not supported yet
364165
36
4791
+ Added@swapkit/tokens@2.0.0(transitive)
- Removed@swapkit/tokens@1.11.0(transitive)
Updated@swapkit/tokens@2.0.0