@xchainjs/xchain-mayachain-query 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -135,26 +135,30 @@ const getBaseAmountWithDiffDecimals = (inputAmount, outDecimals) => {
135
135
  };
136
136
 
137
137
  /**
138
- * This class manages retrieving information from up to date Mayachain
138
+ * This class manages retrieving information from up-to-date Mayachain.
139
139
  */
140
140
  class MayachainCache {
141
141
  /**
142
- * Constructor to create a MayachainCache
142
+ * Constructor to create a MayachainCache.
143
143
  *
144
- * @param midgardQuery - an instance of the Maya MidgardQuery API
145
- * @param mayanode
146
- * @returns MayachainCache
144
+ * @param midgardQuery - An instance of the Maya MidgardQuery API.
145
+ * @param mayanode - An instance of the Maya Mayanode API.
146
+ * @param configuration - Optional configuration for the cache.
147
+ * @returns MayachainCache.
147
148
  */
148
149
  constructor(midgardQuery = new MidgardQuery(), mayanode = new Mayanode(), configuration) {
150
+ // Initialize instances and configuration
149
151
  this.midgardQuery = midgardQuery;
150
152
  this.mayanode = mayanode;
151
153
  this.conf = Object.assign({ expirationTimeInboundAddress: 6000 }, configuration);
154
+ // Initialize cached values
152
155
  this.inboundDetailCache = new CachedValue(() => this.refreshInboundDetailCache(), this.conf.expirationTimeInboundAddress);
153
156
  this.assetDecimalsCache = new CachedValue(() => this.refreshAssetDecimalsCache());
154
157
  }
155
158
  /**
156
- * Get inbound addresses details
157
- * @returns Inbound details
159
+ * Get inbound addresses details.
160
+ *
161
+ * @returns Inbound details.
158
162
  */
159
163
  getInboundDetails() {
160
164
  return __awaiter(this, void 0, void 0, function* () {
@@ -164,8 +168,9 @@ class MayachainCache {
164
168
  });
165
169
  }
166
170
  /**
167
- * Get the number of the decimals of the supported Mayachain tokens
168
- * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value
171
+ * Get the number of decimals of the supported Mayachain tokens.
172
+ *
173
+ * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value.
169
174
  */
170
175
  getAssetDecimals() {
171
176
  return __awaiter(this, void 0, void 0, function* () {
@@ -175,10 +180,11 @@ class MayachainCache {
175
180
  });
176
181
  }
177
182
  /**
178
- * Refreshes the InboundDetailCache Cache
183
+ * Refreshes the InboundDetailCache cache.
179
184
  */
180
185
  refreshInboundDetailCache() {
181
186
  return __awaiter(this, void 0, void 0, function* () {
187
+ // Implementation details for refreshing the inbound detail cache
182
188
  const [mimirDetails, allInboundAddresses] = yield Promise.all([
183
189
  this.mayanode.getMimir(),
184
190
  this.mayanode.getInboundAddresses(),
@@ -224,10 +230,11 @@ class MayachainCache {
224
230
  });
225
231
  }
226
232
  /**
227
- * Refreshes the number of decimals of the supported Mayachain tokens
233
+ * Refreshes the number of decimals of the supported Mayachain tokens.
228
234
  */
229
235
  refreshAssetDecimalsCache() {
230
236
  return __awaiter(this, void 0, void 0, function* () {
237
+ // Implementation details for refreshing the asset decimals cache
231
238
  // TODO: As soon as Mayachain returns native decimals from any endpoint of its API, refactor the function
232
239
  return {
233
240
  'BTC.BTC': 8,
@@ -258,19 +265,20 @@ class MayachainQuery {
258
265
  * @returns MayachainAMM
259
266
  */
260
267
  constructor(mayachainCache = new MayachainCache()) {
268
+ // Initialize MayachainCache instance
261
269
  this.mayachainCache = mayachainCache;
262
270
  }
263
271
  /**
264
- * Get the mayachain query is working with
272
+ * Get the Mayachain network.
265
273
  * @returns
266
274
  */
267
275
  getNetwork() {
268
276
  return this.mayachainCache.midgardQuery.getNetwork();
269
277
  }
270
278
  /**
271
- * Quote a swap
272
- * @param {QuoteSwapParams} quoteSwapParams - quote swap input params
273
- * @returns {QuoteSwap}
279
+ * Quote a swap operation.
280
+ * @param {QuoteSwapParams} quoteSwapParams - Parameters for the quote swap operation.
281
+ * @returns {QuoteSwap} A quote for the swap operation.
274
282
  */
275
283
  quoteSwap({ fromAsset, destinationAsset, amount, destinationAddress, toleranceBps, affiliateBps, affiliateAddress, height, }) {
276
284
  return __awaiter(this, void 0, void 0, function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/utils/mayanode.ts","../src/utils/const.ts","../src/utils/utils.ts","../src/mayachain-cache.ts","../src/mayachain-query.ts"],"sourcesContent":["import { Network } from '@xchainjs/xchain-client'\nimport {\n Configuration,\n InboundAddress,\n MimirApi,\n MimirResponse,\n NetworkApi,\n QuoteApi,\n QuoteSwapResponse,\n} from '@xchainjs/xchain-mayanode'\nimport axios from 'axios'\nimport axiosRetry from 'axios-retry'\n\nexport type MayanodeConfig = {\n apiRetries: number\n mayanodeBaseUrls: string[]\n}\n\nconst defaultMayanodeConfig: Record<Network, MayanodeConfig> = {\n mainnet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://mayanode.mayachain.info'],\n },\n stagenet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n testnet: {\n apiRetries: 3,\n // There is no testnet for mayanode\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n}\n\nexport class Mayanode {\n private config: MayanodeConfig\n private network: Network\n private quoteApis: QuoteApi[]\n private mimirApis: MimirApi[]\n private networkApis: NetworkApi[]\n\n constructor(network: Network = Network.Mainnet, config?: MayanodeConfig) {\n this.network = network\n this.config = config ?? defaultMayanodeConfig[this.network]\n this.quoteApis = this.config.mayanodeBaseUrls.map((url) => new QuoteApi(new Configuration({ basePath: url })))\n this.mimirApis = this.config.mayanodeBaseUrls.map((url) => new MimirApi(new Configuration({ basePath: url })))\n this.networkApis = this.config.mayanodeBaseUrls.map((url) => new NetworkApi(new Configuration({ basePath: url })))\n\n axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay })\n }\n\n /**\n * TODO\n * @param fromAsset - input asset\n * @param toAsset - output asset\n * @param amount - amount to swap\n * @param destinationAddress - destination address for the swap\n * @param toleranceBps - slip percent\n * @param affiliateBps - affiliate percent\n * @param affiliate - affiliate address\n * @param height - block height\n * @returns quotes swap object response\n */\n public async getSwapQuote(\n fromAsset: string,\n toAsset: string,\n amount: number,\n destinationAddress?: string,\n toleranceBps?: number,\n affiliateBps?: number,\n affiliate?: string,\n height?: number,\n ): Promise<QuoteSwapResponse> {\n for (const api of this.quoteApis) {\n try {\n return (\n await api.quoteswap(\n height,\n fromAsset,\n toAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliate,\n )\n ).data\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n\n /**\n * Get current active mimir configuration.\n * @returns mimir configuration\n */\n public async getMimir(): Promise<MimirResponse> {\n for (const api of this.mimirApis) {\n try {\n return (await api.mimir()).data\n } catch (e) {}\n }\n throw Error(`MAYANode not responding`)\n }\n\n /**\n * Get the set of asgard addresses that should be used for inbound transactions.\n * @returns MAYA inbound addresses\n */\n public async getInboundAddresses(): Promise<InboundAddress[]> {\n for (const api of this.networkApis) {\n try {\n const resp = (await api.inboundAddresses()).data\n return resp\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n}\n","import { assetFromStringEx } from '@xchainjs/xchain-util'\n\nexport const BtcAsset = assetFromStringEx('BTC.BTC')\nexport const EthAsset = assetFromStringEx('ETH.ETH')\nexport const CacaoAsset = assetFromStringEx('MAYA.CACAO')\nexport const RuneAsset = assetFromStringEx('THOR.RUNE')\nexport const DashAsset = assetFromStringEx('DASH.DASH')\nexport const KujiraAsset = assetFromStringEx('KUJI.KUJI')\n\nexport const BtcChain = 'BTC'\nexport const EthChain = 'ETH'\nexport const MayaChain = 'MAYA'\nexport const ThorChain = 'THOR'\nexport const DashChain = 'DASH'\nexport const KujiraChain = 'KUJI'\n\nexport const DEFAULT_MAYACHAIN_DECIMALS = 8\n","import { Asset, CryptoAmount, assetToString, baseAmount } from '@xchainjs/xchain-util'\nimport BigNumber from 'bignumber.js'\n\nimport { CacaoAsset } from './const'\n\nexport const isCacaoAsset = (asset: Asset): boolean => assetToString(asset) === assetToString(CacaoAsset)\n\nexport const getBaseAmountWithDiffDecimals = (inputAmount: CryptoAmount, outDecimals: number): BigNumber => {\n const inDecimals = inputAmount.baseAmount.decimal\n let baseAmountOut = inputAmount.baseAmount.amount()\n const adjustDecimals = outDecimals - inDecimals\n baseAmountOut = baseAmountOut.times(10 ** adjustDecimals)\n return baseAmount(baseAmountOut, outDecimals).amount()\n}\n","import { MidgardQuery } from '@xchainjs/xchain-mayamidgard-query'\nimport { CachedValue } from '@xchainjs/xchain-util'\nimport { BigNumber } from 'bignumber.js'\n\nimport { InboundDetail } from './types'\nimport { MayaChain, Mayanode } from './utils'\n\nexport type MayachainCacheConf = {\n expirationTimeInboundAddress: number\n}\n/**\n * This class manages retrieving information from up to date Mayachain\n */\nexport class MayachainCache {\n readonly midgardQuery: MidgardQuery\n readonly mayanode: Mayanode\n private conf: MayachainCacheConf\n private readonly inboundDetailCache: CachedValue<Record<string, InboundDetail>>\n private readonly assetDecimalsCache: CachedValue<Record<string, number>>\n /**\n * Constructor to create a MayachainCache\n *\n * @param midgardQuery - an instance of the Maya MidgardQuery API\n * @param mayanode\n * @returns MayachainCache\n */\n constructor(\n midgardQuery = new MidgardQuery(),\n mayanode = new Mayanode(),\n configuration?: Partial<MayachainCacheConf>,\n ) {\n this.midgardQuery = midgardQuery\n this.mayanode = mayanode\n this.conf = { expirationTimeInboundAddress: 6000, ...configuration }\n\n this.inboundDetailCache = new CachedValue<Record<string, InboundDetail>>(\n () => this.refreshInboundDetailCache(),\n this.conf.expirationTimeInboundAddress,\n )\n this.assetDecimalsCache = new CachedValue<Record<string, number>>(() => this.refreshAssetDecimalsCache())\n }\n\n /**\n * Get inbound addresses details\n * @returns Inbound details\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n if (!this.inboundDetailCache) throw Error(`Could not refresh inbound details`)\n return await this.inboundDetailCache.getValue()\n }\n\n /**\n * Get the number of the decimals of the supported Mayachain tokens\n * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value\n */\n public async getAssetDecimals(): Promise<Record<string, number>> {\n if (!this.assetDecimalsCache) throw Error(`Could not refresh assets decimals`)\n return await this.assetDecimalsCache.getValue()\n }\n\n /**\n * Refreshes the InboundDetailCache Cache\n */\n private async refreshInboundDetailCache(): Promise<Record<string, InboundDetail>> {\n const [mimirDetails, allInboundAddresses] = await Promise.all([\n this.mayanode.getMimir(),\n this.mayanode.getInboundAddresses(),\n ])\n const inboundDetails: Record<string, InboundDetail> = {}\n for (const inbound of allInboundAddresses) {\n const chain = inbound.chain\n if (\n !chain ||\n !inbound.gas_rate ||\n !inbound.address ||\n !inbound.gas_rate_units ||\n !inbound.outbound_tx_size ||\n !inbound.outbound_fee ||\n !inbound.gas_rate_units\n )\n throw new Error(`Missing required inbound info`)\n\n inboundDetails[chain] = {\n chain: chain,\n address: inbound.address,\n router: inbound.router,\n gasRate: new BigNumber(inbound.gas_rate),\n gasRateUnits: inbound.gas_rate_units,\n outboundTxSize: new BigNumber(inbound.outbound_tx_size),\n outboundFee: new BigNumber(inbound.outbound_fee),\n haltedChain: inbound?.halted || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],\n haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],\n haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],\n }\n }\n // add mock MAYAChain inbound details\n inboundDetails[MayaChain] = {\n chain: MayaChain,\n address: '',\n router: '',\n gasRate: new BigNumber(0),\n gasRateUnits: '',\n outboundTxSize: new BigNumber(0),\n outboundFee: new BigNumber(0),\n haltedChain: false,\n haltedTrading: !!mimirDetails['HALTTRADING'],\n haltedLP: false, //\n }\n\n return inboundDetails\n }\n\n /**\n * Refreshes the number of decimals of the supported Mayachain tokens\n */\n private async refreshAssetDecimalsCache(): Promise<Record<string, number>> {\n // TODO: As soon as Mayachain returns native decimals from any endpoint of its API, refactor the function\n return {\n 'BTC.BTC': 8,\n 'ETH.ETH': 18,\n 'DASH.DASH': 8,\n 'KUJI.KUJI': 6,\n 'THOR.RUNE': 8,\n 'MAYA.CACAO': 8,\n 'ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7': 6,\n 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': 6,\n 'ETH.WSTETH-0X7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0': 18,\n 'KUJI.USK': 6,\n }\n }\n}\n","import { Network } from '@xchainjs/xchain-client'\nimport { MAYANameDetails } from '@xchainjs/xchain-mayamidgard-query'\nimport { QuoteSwapResponse } from '@xchainjs/xchain-mayanode'\nimport { Asset, CryptoAmount, assetFromStringEx, assetToString, baseAmount, isSynthAsset } from '@xchainjs/xchain-util'\n\nimport { MayachainCache } from './mayachain-cache'\nimport { InboundDetail, QuoteSwap, QuoteSwapParams } from './types'\nimport {\n BtcAsset,\n BtcChain,\n CacaoAsset,\n DEFAULT_MAYACHAIN_DECIMALS,\n DashAsset,\n DashChain,\n EthAsset,\n EthChain,\n KujiraAsset,\n KujiraChain,\n MayaChain,\n RuneAsset,\n ThorChain,\n getBaseAmountWithDiffDecimals,\n} from './utils'\n\n/**\n * MAYAChain Class for interacting with MAYAChain.\n * Recommended main class to use for swapping with MAYAChain\n * Has access to Midgard and MAYANode data\n */\nexport class MayachainQuery {\n private mayachainCache: MayachainCache\n\n /**\n * Constructor to create a MayachainAMM\n * @param mayachainCache - an instance of the MayachainCache (could be pointing to stagenet,testnet,mainnet)\n * @param chainAttributes - attributes used to calculate waitTime & conf counting\n * @returns MayachainAMM\n */\n constructor(mayachainCache = new MayachainCache()) {\n this.mayachainCache = mayachainCache\n }\n\n /**\n * Get the mayachain query is working with\n * @returns\n */\n public getNetwork(): Network {\n return this.mayachainCache.midgardQuery.getNetwork()\n }\n\n /**\n * Quote a swap\n * @param {QuoteSwapParams} quoteSwapParams - quote swap input params\n * @returns {QuoteSwap}\n */\n public async quoteSwap({\n fromAsset,\n destinationAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n }: QuoteSwapParams): Promise<QuoteSwap> {\n const fromAssetString = assetToString(fromAsset)\n const toAssetString = assetToString(destinationAsset)\n // Endpoint allows 10 decimals for Cacao, 8 for the rest of assets\n const inputAmount =\n fromAssetString === assetToString(CacaoAsset)\n ? amount.baseAmount.amount()\n : getBaseAmountWithDiffDecimals(amount, 8)\n\n const swapQuote: QuoteSwapResponse = await this.mayachainCache.mayanode.getSwapQuote(\n fromAssetString,\n toAssetString,\n inputAmount.toNumber(),\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n )\n\n const response: { error?: string } = JSON.parse(JSON.stringify(swapQuote))\n if (response.error) {\n return {\n toAddress: ``,\n memo: ``,\n expectedAmount: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: destinationAsset,\n affiliateFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n outboundFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n },\n outboundDelayBlocks: 0,\n outboundDelaySeconds: 0,\n inboundConfirmationSeconds: 0,\n inboundConfirmationBlocks: 0,\n canSwap: false,\n errors: [`Mayanode request quote: ${response.error}`],\n slipBasisPoints: 0,\n totalSwapSeconds: 0,\n warning: '',\n }\n }\n\n const feeAsset = assetFromStringEx(swapQuote.fees.asset)\n\n const errors: string[] = []\n if (swapQuote.memo === undefined) errors.push(`Error parsing swap quote: Memo is ${swapQuote.memo}`)\n\n const isFeeAssetCacao = swapQuote.fees.asset === assetToString(CacaoAsset)\n return {\n toAddress: swapQuote.inbound_address || '',\n memo: swapQuote.memo || '',\n expectedAmount: new CryptoAmount(\n baseAmount(swapQuote.expected_amount_out, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: feeAsset,\n affiliateFee: new CryptoAmount(baseAmount(swapQuote.fees.affiliate, isFeeAssetCacao ? 10 : 8), feeAsset),\n outboundFee: new CryptoAmount(baseAmount(swapQuote.fees.outbound, isFeeAssetCacao ? 10 : 8), feeAsset),\n },\n slipBasisPoints: swapQuote.slippage_bps,\n outboundDelayBlocks: swapQuote.outbound_delay_blocks,\n outboundDelaySeconds: swapQuote.outbound_delay_seconds,\n inboundConfirmationSeconds: swapQuote.inbound_confirmation_seconds,\n inboundConfirmationBlocks: swapQuote.inbound_confirmation_blocks,\n totalSwapSeconds: (swapQuote.inbound_confirmation_seconds || 0) + swapQuote.outbound_delay_seconds,\n canSwap: !(!swapQuote.memo || errors.length > 0),\n errors,\n warning: '',\n }\n }\n\n /**\n * Return mayachain supported chains dust amounts\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getDustValues(): Record<string, CryptoAmount> {\n // TODO: Find out how to fetch native asset decimals\n return {\n [BtcChain]: new CryptoAmount(baseAmount(10000, 8), BtcAsset),\n [EthChain]: new CryptoAmount(baseAmount(0, 18), EthAsset),\n [DashChain]: new CryptoAmount(baseAmount(10000, 8), DashAsset),\n [KujiraChain]: new CryptoAmount(baseAmount(0, 6), KujiraAsset),\n [ThorChain]: new CryptoAmount(baseAmount(0, 8), RuneAsset),\n [MayaChain]: new CryptoAmount(baseAmount(0, 10), CacaoAsset),\n }\n }\n\n /**\n * Return the dust crypto amount from the given chain\n * @param {string} chain Chain to retrieve the dust amount of\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getChainDustValue(chain: string): CryptoAmount {\n const dustValue = this.getDustValues()[chain]\n if (!dustValue) throw Error(`No dust value known for ${chain} chain`)\n return dustValue\n }\n\n /**\n * Get MAYAname details\n * @param {string} MAYAName\n * @returns {MAYANameDetails | undefined} MAYANames details or undefined it is does not exist\n */\n public async getMAYANameDetails(MAYAName: string): Promise<MAYANameDetails | undefined> {\n return this.mayachainCache.midgardQuery.getMAYANameDetails(MAYAName)\n }\n\n /**\n * Get inbound addresses details\n * @returns Inbound details\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n return this.mayachainCache.getInboundDetails()\n }\n\n /**\n * Get chain inbound address details\n * @returns Inbound details\n */\n public async getChainInboundDetails(chain: string): Promise<InboundDetail> {\n const inboundDetails = await this.getInboundDetails()\n if (!inboundDetails[chain]) throw Error(`No inbound details known for ${chain} chain`)\n return inboundDetails[chain]\n }\n\n /**\n * Get asset decimals\n * @param {Asset} asset\n * @returns the asset decimals\n * @throws {Error} if the asset is not supported in Mayachain\n */\n public async getAssetDecimals(asset: Asset): Promise<number> {\n if (isSynthAsset(asset)) return DEFAULT_MAYACHAIN_DECIMALS\n\n const assetNotation = assetToString(asset)\n const assetsDecimals = await this.mayachainCache.getAssetDecimals()\n if (!assetsDecimals[assetNotation]) throw Error(`Can not get decimals for ${assetNotation}`)\n\n return assetsDecimals[assetNotation]\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB,GAAoC;AAC7D,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,CAAC;QACb,gBAAgB,EAAE,CAAC,iCAAiC,CAAC;AACtD,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,CAAC;QACb,gBAAgB,EAAE,CAAC,0CAA0C,CAAC;AAC/D,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,CAAC;;QAEb,gBAAgB,EAAE,CAAC,0CAA0C,CAAC;AAC/D,KAAA;CACF,CAAA;MAEY,QAAQ,CAAA;AAOnB,IAAA,WAAA,CAAY,OAAmB,GAAA,OAAO,CAAC,OAAO,EAAE,MAAuB,EAAA;AACrE,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;AACtB,QAAA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AAc,CAAC,aAAa,CAAC,CAAA;SACrC,CAAA,CAAA;AAAA,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/utils/mayanode.ts","../src/utils/const.ts","../src/utils/utils.ts","../src/mayachain-cache.ts","../src/mayachain-query.ts"],"sourcesContent":["import { Network } from '@xchainjs/xchain-client'\nimport {\n Configuration,\n InboundAddress,\n MimirApi,\n MimirResponse,\n NetworkApi,\n QuoteApi,\n QuoteSwapResponse,\n} from '@xchainjs/xchain-mayanode'\nimport axios from 'axios'\nimport axiosRetry from 'axios-retry'\n\nexport type MayanodeConfig = {\n apiRetries: number\n mayanodeBaseUrls: string[]\n}\n\nconst defaultMayanodeConfig: Record<Network, MayanodeConfig> = {\n mainnet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://mayanode.mayachain.info'],\n },\n stagenet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n testnet: {\n apiRetries: 3,\n // There is no testnet for mayanode\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n}\n\nexport class Mayanode {\n private config: MayanodeConfig\n private network: Network\n private quoteApis: QuoteApi[]\n private mimirApis: MimirApi[]\n private networkApis: NetworkApi[]\n\n constructor(network: Network = Network.Mainnet, config?: MayanodeConfig) {\n this.network = network\n this.config = config ?? defaultMayanodeConfig[this.network]\n this.quoteApis = this.config.mayanodeBaseUrls.map((url) => new QuoteApi(new Configuration({ basePath: url })))\n this.mimirApis = this.config.mayanodeBaseUrls.map((url) => new MimirApi(new Configuration({ basePath: url })))\n this.networkApis = this.config.mayanodeBaseUrls.map((url) => new NetworkApi(new Configuration({ basePath: url })))\n\n axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay })\n }\n\n /**\n * TODO\n * @param fromAsset - input asset\n * @param toAsset - output asset\n * @param amount - amount to swap\n * @param destinationAddress - destination address for the swap\n * @param toleranceBps - slip percent\n * @param affiliateBps - affiliate percent\n * @param affiliate - affiliate address\n * @param height - block height\n * @returns quotes swap object response\n */\n public async getSwapQuote(\n fromAsset: string,\n toAsset: string,\n amount: number,\n destinationAddress?: string,\n toleranceBps?: number,\n affiliateBps?: number,\n affiliate?: string,\n height?: number,\n ): Promise<QuoteSwapResponse> {\n for (const api of this.quoteApis) {\n try {\n return (\n await api.quoteswap(\n height,\n fromAsset,\n toAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliate,\n )\n ).data\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n\n /**\n * Get current active mimir configuration.\n * @returns mimir configuration\n */\n public async getMimir(): Promise<MimirResponse> {\n for (const api of this.mimirApis) {\n try {\n return (await api.mimir()).data\n } catch (e) {}\n }\n throw Error(`MAYANode not responding`)\n }\n\n /**\n * Get the set of asgard addresses that should be used for inbound transactions.\n * @returns MAYA inbound addresses\n */\n public async getInboundAddresses(): Promise<InboundAddress[]> {\n for (const api of this.networkApis) {\n try {\n const resp = (await api.inboundAddresses()).data\n return resp\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n}\n","import { assetFromStringEx } from '@xchainjs/xchain-util'\n\nexport const BtcAsset = assetFromStringEx('BTC.BTC')\nexport const EthAsset = assetFromStringEx('ETH.ETH')\nexport const CacaoAsset = assetFromStringEx('MAYA.CACAO')\nexport const RuneAsset = assetFromStringEx('THOR.RUNE')\nexport const DashAsset = assetFromStringEx('DASH.DASH')\nexport const KujiraAsset = assetFromStringEx('KUJI.KUJI')\n\nexport const BtcChain = 'BTC'\nexport const EthChain = 'ETH'\nexport const MayaChain = 'MAYA'\nexport const ThorChain = 'THOR'\nexport const DashChain = 'DASH'\nexport const KujiraChain = 'KUJI'\n\nexport const DEFAULT_MAYACHAIN_DECIMALS = 8\n","import { Asset, CryptoAmount, assetToString, baseAmount } from '@xchainjs/xchain-util'\nimport BigNumber from 'bignumber.js'\n\nimport { CacaoAsset } from './const'\n\nexport const isCacaoAsset = (asset: Asset): boolean => assetToString(asset) === assetToString(CacaoAsset)\n\nexport const getBaseAmountWithDiffDecimals = (inputAmount: CryptoAmount, outDecimals: number): BigNumber => {\n const inDecimals = inputAmount.baseAmount.decimal\n let baseAmountOut = inputAmount.baseAmount.amount()\n const adjustDecimals = outDecimals - inDecimals\n baseAmountOut = baseAmountOut.times(10 ** adjustDecimals)\n return baseAmount(baseAmountOut, outDecimals).amount()\n}\n","import { MidgardQuery } from '@xchainjs/xchain-mayamidgard-query'\nimport { CachedValue } from '@xchainjs/xchain-util'\nimport { BigNumber } from 'bignumber.js'\n\nimport { InboundDetail } from './types'\nimport { MayaChain, Mayanode } from './utils'\n\nexport type MayachainCacheConf = {\n expirationTimeInboundAddress: number // Expiration time for the inbound address cache in milliseconds\n}\n\n/**\n * This class manages retrieving information from up-to-date Mayachain.\n */\nexport class MayachainCache {\n readonly midgardQuery: MidgardQuery // Instance of the Maya MidgardQuery API\n readonly mayanode: Mayanode // Instance of the Maya Mayanode API\n private conf: MayachainCacheConf // Configuration for the cache\n private readonly inboundDetailCache: CachedValue<Record<string, InboundDetail>> // Cached value for inbound details\n private readonly assetDecimalsCache: CachedValue<Record<string, number>> // Cached value for asset decimals\n\n /**\n * Constructor to create a MayachainCache.\n *\n * @param midgardQuery - An instance of the Maya MidgardQuery API.\n * @param mayanode - An instance of the Maya Mayanode API.\n * @param configuration - Optional configuration for the cache.\n * @returns MayachainCache.\n */\n constructor(\n midgardQuery = new MidgardQuery(),\n mayanode = new Mayanode(),\n configuration?: Partial<MayachainCacheConf>,\n ) {\n // Initialize instances and configuration\n this.midgardQuery = midgardQuery\n this.mayanode = mayanode\n this.conf = { expirationTimeInboundAddress: 6000, ...configuration }\n\n // Initialize cached values\n this.inboundDetailCache = new CachedValue<Record<string, InboundDetail>>(\n () => this.refreshInboundDetailCache(),\n this.conf.expirationTimeInboundAddress,\n )\n this.assetDecimalsCache = new CachedValue<Record<string, number>>(() => this.refreshAssetDecimalsCache())\n }\n\n /**\n * Get inbound addresses details.\n *\n * @returns Inbound details.\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n if (!this.inboundDetailCache) throw Error(`Could not refresh inbound details`)\n return await this.inboundDetailCache.getValue()\n }\n\n /**\n * Get the number of decimals of the supported Mayachain tokens.\n *\n * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value.\n */\n public async getAssetDecimals(): Promise<Record<string, number>> {\n if (!this.assetDecimalsCache) throw Error(`Could not refresh assets decimals`)\n return await this.assetDecimalsCache.getValue()\n }\n\n /**\n * Refreshes the InboundDetailCache cache.\n */\n private async refreshInboundDetailCache(): Promise<Record<string, InboundDetail>> {\n // Implementation details for refreshing the inbound detail cache\n const [mimirDetails, allInboundAddresses] = await Promise.all([\n this.mayanode.getMimir(),\n this.mayanode.getInboundAddresses(),\n ])\n const inboundDetails: Record<string, InboundDetail> = {}\n for (const inbound of allInboundAddresses) {\n const chain = inbound.chain\n if (\n !chain ||\n !inbound.gas_rate ||\n !inbound.address ||\n !inbound.gas_rate_units ||\n !inbound.outbound_tx_size ||\n !inbound.outbound_fee ||\n !inbound.gas_rate_units\n )\n throw new Error(`Missing required inbound info`)\n\n inboundDetails[chain] = {\n chain: chain,\n address: inbound.address,\n router: inbound.router,\n gasRate: new BigNumber(inbound.gas_rate),\n gasRateUnits: inbound.gas_rate_units,\n outboundTxSize: new BigNumber(inbound.outbound_tx_size),\n outboundFee: new BigNumber(inbound.outbound_fee),\n haltedChain: inbound?.halted || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],\n haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],\n haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],\n }\n }\n // add mock MAYAChain inbound details\n inboundDetails[MayaChain] = {\n chain: MayaChain,\n address: '',\n router: '',\n gasRate: new BigNumber(0),\n gasRateUnits: '',\n outboundTxSize: new BigNumber(0),\n outboundFee: new BigNumber(0),\n haltedChain: false,\n haltedTrading: !!mimirDetails['HALTTRADING'],\n haltedLP: false, //\n }\n\n return inboundDetails\n }\n\n /**\n * Refreshes the number of decimals of the supported Mayachain tokens.\n */\n private async refreshAssetDecimalsCache(): Promise<Record<string, number>> {\n // Implementation details for refreshing the asset decimals cache\n // TODO: As soon as Mayachain returns native decimals from any endpoint of its API, refactor the function\n return {\n 'BTC.BTC': 8,\n 'ETH.ETH': 18,\n 'DASH.DASH': 8,\n 'KUJI.KUJI': 6,\n 'THOR.RUNE': 8,\n 'MAYA.CACAO': 8,\n 'ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7': 6,\n 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': 6,\n 'ETH.WSTETH-0X7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0': 18,\n 'KUJI.USK': 6,\n }\n }\n}\n","import { Network } from '@xchainjs/xchain-client'\nimport { MAYANameDetails } from '@xchainjs/xchain-mayamidgard-query'\nimport { QuoteSwapResponse } from '@xchainjs/xchain-mayanode'\nimport { Asset, CryptoAmount, assetFromStringEx, assetToString, baseAmount, isSynthAsset } from '@xchainjs/xchain-util'\n\nimport { MayachainCache } from './mayachain-cache'\nimport { InboundDetail, QuoteSwap, QuoteSwapParams } from './types'\nimport {\n BtcAsset,\n BtcChain,\n CacaoAsset,\n DEFAULT_MAYACHAIN_DECIMALS,\n DashAsset,\n DashChain,\n EthAsset,\n EthChain,\n KujiraAsset,\n KujiraChain,\n MayaChain,\n RuneAsset,\n ThorChain,\n getBaseAmountWithDiffDecimals,\n} from './utils'\n\n/**\n * MAYAChain Class for interacting with MAYAChain.\n * Recommended main class to use for swapping with MAYAChain\n * Has access to Midgard and MAYANode data\n */\nexport class MayachainQuery {\n private mayachainCache: MayachainCache\n\n /**\n * Constructor to create a MayachainAMM\n * @param mayachainCache - an instance of the MayachainCache (could be pointing to stagenet,testnet,mainnet)\n * @param chainAttributes - attributes used to calculate waitTime & conf counting\n * @returns MayachainAMM\n */\n constructor(mayachainCache = new MayachainCache()) {\n // Initialize MayachainCache instance\n this.mayachainCache = mayachainCache\n }\n\n /**\n * Get the Mayachain network.\n * @returns\n */\n public getNetwork(): Network {\n return this.mayachainCache.midgardQuery.getNetwork()\n }\n\n /**\n * Quote a swap operation.\n * @param {QuoteSwapParams} quoteSwapParams - Parameters for the quote swap operation.\n * @returns {QuoteSwap} A quote for the swap operation.\n */\n public async quoteSwap({\n fromAsset,\n destinationAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n }: QuoteSwapParams): Promise<QuoteSwap> {\n const fromAssetString = assetToString(fromAsset)\n const toAssetString = assetToString(destinationAsset)\n // Endpoint allows 10 decimals for Cacao, 8 for the rest of assets\n const inputAmount =\n fromAssetString === assetToString(CacaoAsset)\n ? amount.baseAmount.amount()\n : getBaseAmountWithDiffDecimals(amount, 8)\n\n const swapQuote: QuoteSwapResponse = await this.mayachainCache.mayanode.getSwapQuote(\n fromAssetString,\n toAssetString,\n inputAmount.toNumber(),\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n )\n\n const response: { error?: string } = JSON.parse(JSON.stringify(swapQuote))\n if (response.error) {\n return {\n toAddress: ``,\n memo: ``,\n expectedAmount: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: destinationAsset,\n affiliateFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n outboundFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n },\n outboundDelayBlocks: 0,\n outboundDelaySeconds: 0,\n inboundConfirmationSeconds: 0,\n inboundConfirmationBlocks: 0,\n canSwap: false,\n errors: [`Mayanode request quote: ${response.error}`],\n slipBasisPoints: 0,\n totalSwapSeconds: 0,\n warning: '',\n }\n }\n\n const feeAsset = assetFromStringEx(swapQuote.fees.asset)\n\n const errors: string[] = []\n if (swapQuote.memo === undefined) errors.push(`Error parsing swap quote: Memo is ${swapQuote.memo}`)\n\n const isFeeAssetCacao = swapQuote.fees.asset === assetToString(CacaoAsset)\n return {\n toAddress: swapQuote.inbound_address || '',\n memo: swapQuote.memo || '',\n expectedAmount: new CryptoAmount(\n baseAmount(swapQuote.expected_amount_out, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: feeAsset,\n affiliateFee: new CryptoAmount(baseAmount(swapQuote.fees.affiliate, isFeeAssetCacao ? 10 : 8), feeAsset),\n outboundFee: new CryptoAmount(baseAmount(swapQuote.fees.outbound, isFeeAssetCacao ? 10 : 8), feeAsset),\n },\n slipBasisPoints: swapQuote.slippage_bps,\n outboundDelayBlocks: swapQuote.outbound_delay_blocks,\n outboundDelaySeconds: swapQuote.outbound_delay_seconds,\n inboundConfirmationSeconds: swapQuote.inbound_confirmation_seconds,\n inboundConfirmationBlocks: swapQuote.inbound_confirmation_blocks,\n totalSwapSeconds: (swapQuote.inbound_confirmation_seconds || 0) + swapQuote.outbound_delay_seconds,\n canSwap: !(!swapQuote.memo || errors.length > 0),\n errors,\n warning: '',\n }\n }\n\n /**\n * Return mayachain supported chains dust amounts\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getDustValues(): Record<string, CryptoAmount> {\n // TODO: Find out how to fetch native asset decimals\n return {\n [BtcChain]: new CryptoAmount(baseAmount(10000, 8), BtcAsset),\n [EthChain]: new CryptoAmount(baseAmount(0, 18), EthAsset),\n [DashChain]: new CryptoAmount(baseAmount(10000, 8), DashAsset),\n [KujiraChain]: new CryptoAmount(baseAmount(0, 6), KujiraAsset),\n [ThorChain]: new CryptoAmount(baseAmount(0, 8), RuneAsset),\n [MayaChain]: new CryptoAmount(baseAmount(0, 10), CacaoAsset),\n }\n }\n\n /**\n * Return the dust crypto amount from the given chain\n * @param {string} chain Chain to retrieve the dust amount of\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getChainDustValue(chain: string): CryptoAmount {\n const dustValue = this.getDustValues()[chain]\n if (!dustValue) throw Error(`No dust value known for ${chain} chain`)\n return dustValue\n }\n\n /**\n * Get MAYAname details\n * @param {string} MAYAName\n * @returns {MAYANameDetails | undefined} MAYANames details or undefined it is does not exist\n */\n public async getMAYANameDetails(MAYAName: string): Promise<MAYANameDetails | undefined> {\n return this.mayachainCache.midgardQuery.getMAYANameDetails(MAYAName)\n }\n\n /**\n * Get inbound addresses details\n * @returns Inbound details\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n return this.mayachainCache.getInboundDetails()\n }\n\n /**\n * Get chain inbound address details\n * @returns Inbound details\n */\n public async getChainInboundDetails(chain: string): Promise<InboundDetail> {\n const inboundDetails = await this.getInboundDetails()\n if (!inboundDetails[chain]) throw Error(`No inbound details known for ${chain} chain`)\n return inboundDetails[chain]\n }\n\n /**\n * Get asset decimals\n * @param {Asset} asset\n * @returns the asset decimals\n * @throws {Error} if the asset is not supported in Mayachain\n */\n public async getAssetDecimals(asset: Asset): Promise<number> {\n if (isSynthAsset(asset)) return DEFAULT_MAYACHAIN_DECIMALS\n\n const assetNotation = assetToString(asset)\n const assetsDecimals = await this.mayachainCache.getAssetDecimals()\n if (!assetsDecimals[assetNotation]) throw Error(`Can not get decimals for ${assetNotation}`)\n\n return assetsDecimals[assetNotation]\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB,GAAoC;AAC7D,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,CAAC;QACb,gBAAgB,EAAE,CAAC,iCAAiC,CAAC;AACtD,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,CAAC;QACb,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AK,CAAC;AAAE,gBAAA,OAAO,0BAA0B,CAAA;AAE1D,YAAA,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;YAC1C,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAA;AACnE,YAAA,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;AAAE,gBAAA,MAAM,KAAK,CAAC,CAAA,yBAAA,EAA4B,aAAa,CAAA,CAAE,CAAC,CAAA;AAE5F,YAAA,OAAO,cAAc,CAAC,aAAa,CAAC,CAAA;SACrC,CAAA,CAAA;AAAA,KAAA;AACF;;;;"}
package/lib/index.js CHANGED
@@ -144,26 +144,30 @@ const getBaseAmountWithDiffDecimals = (inputAmount, outDecimals) => {
144
144
  };
145
145
 
146
146
  /**
147
- * This class manages retrieving information from up to date Mayachain
147
+ * This class manages retrieving information from up-to-date Mayachain.
148
148
  */
149
149
  class MayachainCache {
150
150
  /**
151
- * Constructor to create a MayachainCache
151
+ * Constructor to create a MayachainCache.
152
152
  *
153
- * @param midgardQuery - an instance of the Maya MidgardQuery API
154
- * @param mayanode
155
- * @returns MayachainCache
153
+ * @param midgardQuery - An instance of the Maya MidgardQuery API.
154
+ * @param mayanode - An instance of the Maya Mayanode API.
155
+ * @param configuration - Optional configuration for the cache.
156
+ * @returns MayachainCache.
156
157
  */
157
158
  constructor(midgardQuery = new xchainMayamidgardQuery.MidgardQuery(), mayanode = new Mayanode(), configuration) {
159
+ // Initialize instances and configuration
158
160
  this.midgardQuery = midgardQuery;
159
161
  this.mayanode = mayanode;
160
162
  this.conf = Object.assign({ expirationTimeInboundAddress: 6000 }, configuration);
163
+ // Initialize cached values
161
164
  this.inboundDetailCache = new xchainUtil.CachedValue(() => this.refreshInboundDetailCache(), this.conf.expirationTimeInboundAddress);
162
165
  this.assetDecimalsCache = new xchainUtil.CachedValue(() => this.refreshAssetDecimalsCache());
163
166
  }
164
167
  /**
165
- * Get inbound addresses details
166
- * @returns Inbound details
168
+ * Get inbound addresses details.
169
+ *
170
+ * @returns Inbound details.
167
171
  */
168
172
  getInboundDetails() {
169
173
  return __awaiter(this, void 0, void 0, function* () {
@@ -173,8 +177,9 @@ class MayachainCache {
173
177
  });
174
178
  }
175
179
  /**
176
- * Get the number of the decimals of the supported Mayachain tokens
177
- * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value
180
+ * Get the number of decimals of the supported Mayachain tokens.
181
+ *
182
+ * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value.
178
183
  */
179
184
  getAssetDecimals() {
180
185
  return __awaiter(this, void 0, void 0, function* () {
@@ -184,10 +189,11 @@ class MayachainCache {
184
189
  });
185
190
  }
186
191
  /**
187
- * Refreshes the InboundDetailCache Cache
192
+ * Refreshes the InboundDetailCache cache.
188
193
  */
189
194
  refreshInboundDetailCache() {
190
195
  return __awaiter(this, void 0, void 0, function* () {
196
+ // Implementation details for refreshing the inbound detail cache
191
197
  const [mimirDetails, allInboundAddresses] = yield Promise.all([
192
198
  this.mayanode.getMimir(),
193
199
  this.mayanode.getInboundAddresses(),
@@ -233,10 +239,11 @@ class MayachainCache {
233
239
  });
234
240
  }
235
241
  /**
236
- * Refreshes the number of decimals of the supported Mayachain tokens
242
+ * Refreshes the number of decimals of the supported Mayachain tokens.
237
243
  */
238
244
  refreshAssetDecimalsCache() {
239
245
  return __awaiter(this, void 0, void 0, function* () {
246
+ // Implementation details for refreshing the asset decimals cache
240
247
  // TODO: As soon as Mayachain returns native decimals from any endpoint of its API, refactor the function
241
248
  return {
242
249
  'BTC.BTC': 8,
@@ -267,19 +274,20 @@ class MayachainQuery {
267
274
  * @returns MayachainAMM
268
275
  */
269
276
  constructor(mayachainCache = new MayachainCache()) {
277
+ // Initialize MayachainCache instance
270
278
  this.mayachainCache = mayachainCache;
271
279
  }
272
280
  /**
273
- * Get the mayachain query is working with
281
+ * Get the Mayachain network.
274
282
  * @returns
275
283
  */
276
284
  getNetwork() {
277
285
  return this.mayachainCache.midgardQuery.getNetwork();
278
286
  }
279
287
  /**
280
- * Quote a swap
281
- * @param {QuoteSwapParams} quoteSwapParams - quote swap input params
282
- * @returns {QuoteSwap}
288
+ * Quote a swap operation.
289
+ * @param {QuoteSwapParams} quoteSwapParams - Parameters for the quote swap operation.
290
+ * @returns {QuoteSwap} A quote for the swap operation.
283
291
  */
284
292
  quoteSwap({ fromAsset, destinationAsset, amount, destinationAddress, toleranceBps, affiliateBps, affiliateAddress, height, }) {
285
293
  return __awaiter(this, void 0, void 0, function* () {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils/mayanode.ts","../src/utils/const.ts","../src/utils/utils.ts","../src/mayachain-cache.ts","../src/mayachain-query.ts"],"sourcesContent":["import { Network } from '@xchainjs/xchain-client'\nimport {\n Configuration,\n InboundAddress,\n MimirApi,\n MimirResponse,\n NetworkApi,\n QuoteApi,\n QuoteSwapResponse,\n} from '@xchainjs/xchain-mayanode'\nimport axios from 'axios'\nimport axiosRetry from 'axios-retry'\n\nexport type MayanodeConfig = {\n apiRetries: number\n mayanodeBaseUrls: string[]\n}\n\nconst defaultMayanodeConfig: Record<Network, MayanodeConfig> = {\n mainnet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://mayanode.mayachain.info'],\n },\n stagenet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n testnet: {\n apiRetries: 3,\n // There is no testnet for mayanode\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n}\n\nexport class Mayanode {\n private config: MayanodeConfig\n private network: Network\n private quoteApis: QuoteApi[]\n private mimirApis: MimirApi[]\n private networkApis: NetworkApi[]\n\n constructor(network: Network = Network.Mainnet, config?: MayanodeConfig) {\n this.network = network\n this.config = config ?? defaultMayanodeConfig[this.network]\n this.quoteApis = this.config.mayanodeBaseUrls.map((url) => new QuoteApi(new Configuration({ basePath: url })))\n this.mimirApis = this.config.mayanodeBaseUrls.map((url) => new MimirApi(new Configuration({ basePath: url })))\n this.networkApis = this.config.mayanodeBaseUrls.map((url) => new NetworkApi(new Configuration({ basePath: url })))\n\n axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay })\n }\n\n /**\n * TODO\n * @param fromAsset - input asset\n * @param toAsset - output asset\n * @param amount - amount to swap\n * @param destinationAddress - destination address for the swap\n * @param toleranceBps - slip percent\n * @param affiliateBps - affiliate percent\n * @param affiliate - affiliate address\n * @param height - block height\n * @returns quotes swap object response\n */\n public async getSwapQuote(\n fromAsset: string,\n toAsset: string,\n amount: number,\n destinationAddress?: string,\n toleranceBps?: number,\n affiliateBps?: number,\n affiliate?: string,\n height?: number,\n ): Promise<QuoteSwapResponse> {\n for (const api of this.quoteApis) {\n try {\n return (\n await api.quoteswap(\n height,\n fromAsset,\n toAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliate,\n )\n ).data\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n\n /**\n * Get current active mimir configuration.\n * @returns mimir configuration\n */\n public async getMimir(): Promise<MimirResponse> {\n for (const api of this.mimirApis) {\n try {\n return (await api.mimir()).data\n } catch (e) {}\n }\n throw Error(`MAYANode not responding`)\n }\n\n /**\n * Get the set of asgard addresses that should be used for inbound transactions.\n * @returns MAYA inbound addresses\n */\n public async getInboundAddresses(): Promise<InboundAddress[]> {\n for (const api of this.networkApis) {\n try {\n const resp = (await api.inboundAddresses()).data\n return resp\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n}\n","import { assetFromStringEx } from '@xchainjs/xchain-util'\n\nexport const BtcAsset = assetFromStringEx('BTC.BTC')\nexport const EthAsset = assetFromStringEx('ETH.ETH')\nexport const CacaoAsset = assetFromStringEx('MAYA.CACAO')\nexport const RuneAsset = assetFromStringEx('THOR.RUNE')\nexport const DashAsset = assetFromStringEx('DASH.DASH')\nexport const KujiraAsset = assetFromStringEx('KUJI.KUJI')\n\nexport const BtcChain = 'BTC'\nexport const EthChain = 'ETH'\nexport const MayaChain = 'MAYA'\nexport const ThorChain = 'THOR'\nexport const DashChain = 'DASH'\nexport const KujiraChain = 'KUJI'\n\nexport const DEFAULT_MAYACHAIN_DECIMALS = 8\n","import { Asset, CryptoAmount, assetToString, baseAmount } from '@xchainjs/xchain-util'\nimport BigNumber from 'bignumber.js'\n\nimport { CacaoAsset } from './const'\n\nexport const isCacaoAsset = (asset: Asset): boolean => assetToString(asset) === assetToString(CacaoAsset)\n\nexport const getBaseAmountWithDiffDecimals = (inputAmount: CryptoAmount, outDecimals: number): BigNumber => {\n const inDecimals = inputAmount.baseAmount.decimal\n let baseAmountOut = inputAmount.baseAmount.amount()\n const adjustDecimals = outDecimals - inDecimals\n baseAmountOut = baseAmountOut.times(10 ** adjustDecimals)\n return baseAmount(baseAmountOut, outDecimals).amount()\n}\n","import { MidgardQuery } from '@xchainjs/xchain-mayamidgard-query'\nimport { CachedValue } from '@xchainjs/xchain-util'\nimport { BigNumber } from 'bignumber.js'\n\nimport { InboundDetail } from './types'\nimport { MayaChain, Mayanode } from './utils'\n\nexport type MayachainCacheConf = {\n expirationTimeInboundAddress: number\n}\n/**\n * This class manages retrieving information from up to date Mayachain\n */\nexport class MayachainCache {\n readonly midgardQuery: MidgardQuery\n readonly mayanode: Mayanode\n private conf: MayachainCacheConf\n private readonly inboundDetailCache: CachedValue<Record<string, InboundDetail>>\n private readonly assetDecimalsCache: CachedValue<Record<string, number>>\n /**\n * Constructor to create a MayachainCache\n *\n * @param midgardQuery - an instance of the Maya MidgardQuery API\n * @param mayanode\n * @returns MayachainCache\n */\n constructor(\n midgardQuery = new MidgardQuery(),\n mayanode = new Mayanode(),\n configuration?: Partial<MayachainCacheConf>,\n ) {\n this.midgardQuery = midgardQuery\n this.mayanode = mayanode\n this.conf = { expirationTimeInboundAddress: 6000, ...configuration }\n\n this.inboundDetailCache = new CachedValue<Record<string, InboundDetail>>(\n () => this.refreshInboundDetailCache(),\n this.conf.expirationTimeInboundAddress,\n )\n this.assetDecimalsCache = new CachedValue<Record<string, number>>(() => this.refreshAssetDecimalsCache())\n }\n\n /**\n * Get inbound addresses details\n * @returns Inbound details\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n if (!this.inboundDetailCache) throw Error(`Could not refresh inbound details`)\n return await this.inboundDetailCache.getValue()\n }\n\n /**\n * Get the number of the decimals of the supported Mayachain tokens\n * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value\n */\n public async getAssetDecimals(): Promise<Record<string, number>> {\n if (!this.assetDecimalsCache) throw Error(`Could not refresh assets decimals`)\n return await this.assetDecimalsCache.getValue()\n }\n\n /**\n * Refreshes the InboundDetailCache Cache\n */\n private async refreshInboundDetailCache(): Promise<Record<string, InboundDetail>> {\n const [mimirDetails, allInboundAddresses] = await Promise.all([\n this.mayanode.getMimir(),\n this.mayanode.getInboundAddresses(),\n ])\n const inboundDetails: Record<string, InboundDetail> = {}\n for (const inbound of allInboundAddresses) {\n const chain = inbound.chain\n if (\n !chain ||\n !inbound.gas_rate ||\n !inbound.address ||\n !inbound.gas_rate_units ||\n !inbound.outbound_tx_size ||\n !inbound.outbound_fee ||\n !inbound.gas_rate_units\n )\n throw new Error(`Missing required inbound info`)\n\n inboundDetails[chain] = {\n chain: chain,\n address: inbound.address,\n router: inbound.router,\n gasRate: new BigNumber(inbound.gas_rate),\n gasRateUnits: inbound.gas_rate_units,\n outboundTxSize: new BigNumber(inbound.outbound_tx_size),\n outboundFee: new BigNumber(inbound.outbound_fee),\n haltedChain: inbound?.halted || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],\n haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],\n haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],\n }\n }\n // add mock MAYAChain inbound details\n inboundDetails[MayaChain] = {\n chain: MayaChain,\n address: '',\n router: '',\n gasRate: new BigNumber(0),\n gasRateUnits: '',\n outboundTxSize: new BigNumber(0),\n outboundFee: new BigNumber(0),\n haltedChain: false,\n haltedTrading: !!mimirDetails['HALTTRADING'],\n haltedLP: false, //\n }\n\n return inboundDetails\n }\n\n /**\n * Refreshes the number of decimals of the supported Mayachain tokens\n */\n private async refreshAssetDecimalsCache(): Promise<Record<string, number>> {\n // TODO: As soon as Mayachain returns native decimals from any endpoint of its API, refactor the function\n return {\n 'BTC.BTC': 8,\n 'ETH.ETH': 18,\n 'DASH.DASH': 8,\n 'KUJI.KUJI': 6,\n 'THOR.RUNE': 8,\n 'MAYA.CACAO': 8,\n 'ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7': 6,\n 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': 6,\n 'ETH.WSTETH-0X7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0': 18,\n 'KUJI.USK': 6,\n }\n }\n}\n","import { Network } from '@xchainjs/xchain-client'\nimport { MAYANameDetails } from '@xchainjs/xchain-mayamidgard-query'\nimport { QuoteSwapResponse } from '@xchainjs/xchain-mayanode'\nimport { Asset, CryptoAmount, assetFromStringEx, assetToString, baseAmount, isSynthAsset } from '@xchainjs/xchain-util'\n\nimport { MayachainCache } from './mayachain-cache'\nimport { InboundDetail, QuoteSwap, QuoteSwapParams } from './types'\nimport {\n BtcAsset,\n BtcChain,\n CacaoAsset,\n DEFAULT_MAYACHAIN_DECIMALS,\n DashAsset,\n DashChain,\n EthAsset,\n EthChain,\n KujiraAsset,\n KujiraChain,\n MayaChain,\n RuneAsset,\n ThorChain,\n getBaseAmountWithDiffDecimals,\n} from './utils'\n\n/**\n * MAYAChain Class for interacting with MAYAChain.\n * Recommended main class to use for swapping with MAYAChain\n * Has access to Midgard and MAYANode data\n */\nexport class MayachainQuery {\n private mayachainCache: MayachainCache\n\n /**\n * Constructor to create a MayachainAMM\n * @param mayachainCache - an instance of the MayachainCache (could be pointing to stagenet,testnet,mainnet)\n * @param chainAttributes - attributes used to calculate waitTime & conf counting\n * @returns MayachainAMM\n */\n constructor(mayachainCache = new MayachainCache()) {\n this.mayachainCache = mayachainCache\n }\n\n /**\n * Get the mayachain query is working with\n * @returns\n */\n public getNetwork(): Network {\n return this.mayachainCache.midgardQuery.getNetwork()\n }\n\n /**\n * Quote a swap\n * @param {QuoteSwapParams} quoteSwapParams - quote swap input params\n * @returns {QuoteSwap}\n */\n public async quoteSwap({\n fromAsset,\n destinationAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n }: QuoteSwapParams): Promise<QuoteSwap> {\n const fromAssetString = assetToString(fromAsset)\n const toAssetString = assetToString(destinationAsset)\n // Endpoint allows 10 decimals for Cacao, 8 for the rest of assets\n const inputAmount =\n fromAssetString === assetToString(CacaoAsset)\n ? amount.baseAmount.amount()\n : getBaseAmountWithDiffDecimals(amount, 8)\n\n const swapQuote: QuoteSwapResponse = await this.mayachainCache.mayanode.getSwapQuote(\n fromAssetString,\n toAssetString,\n inputAmount.toNumber(),\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n )\n\n const response: { error?: string } = JSON.parse(JSON.stringify(swapQuote))\n if (response.error) {\n return {\n toAddress: ``,\n memo: ``,\n expectedAmount: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: destinationAsset,\n affiliateFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n outboundFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n },\n outboundDelayBlocks: 0,\n outboundDelaySeconds: 0,\n inboundConfirmationSeconds: 0,\n inboundConfirmationBlocks: 0,\n canSwap: false,\n errors: [`Mayanode request quote: ${response.error}`],\n slipBasisPoints: 0,\n totalSwapSeconds: 0,\n warning: '',\n }\n }\n\n const feeAsset = assetFromStringEx(swapQuote.fees.asset)\n\n const errors: string[] = []\n if (swapQuote.memo === undefined) errors.push(`Error parsing swap quote: Memo is ${swapQuote.memo}`)\n\n const isFeeAssetCacao = swapQuote.fees.asset === assetToString(CacaoAsset)\n return {\n toAddress: swapQuote.inbound_address || '',\n memo: swapQuote.memo || '',\n expectedAmount: new CryptoAmount(\n baseAmount(swapQuote.expected_amount_out, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: feeAsset,\n affiliateFee: new CryptoAmount(baseAmount(swapQuote.fees.affiliate, isFeeAssetCacao ? 10 : 8), feeAsset),\n outboundFee: new CryptoAmount(baseAmount(swapQuote.fees.outbound, isFeeAssetCacao ? 10 : 8), feeAsset),\n },\n slipBasisPoints: swapQuote.slippage_bps,\n outboundDelayBlocks: swapQuote.outbound_delay_blocks,\n outboundDelaySeconds: swapQuote.outbound_delay_seconds,\n inboundConfirmationSeconds: swapQuote.inbound_confirmation_seconds,\n inboundConfirmationBlocks: swapQuote.inbound_confirmation_blocks,\n totalSwapSeconds: (swapQuote.inbound_confirmation_seconds || 0) + swapQuote.outbound_delay_seconds,\n canSwap: !(!swapQuote.memo || errors.length > 0),\n errors,\n warning: '',\n }\n }\n\n /**\n * Return mayachain supported chains dust amounts\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getDustValues(): Record<string, CryptoAmount> {\n // TODO: Find out how to fetch native asset decimals\n return {\n [BtcChain]: new CryptoAmount(baseAmount(10000, 8), BtcAsset),\n [EthChain]: new CryptoAmount(baseAmount(0, 18), EthAsset),\n [DashChain]: new CryptoAmount(baseAmount(10000, 8), DashAsset),\n [KujiraChain]: new CryptoAmount(baseAmount(0, 6), KujiraAsset),\n [ThorChain]: new CryptoAmount(baseAmount(0, 8), RuneAsset),\n [MayaChain]: new CryptoAmount(baseAmount(0, 10), CacaoAsset),\n }\n }\n\n /**\n * Return the dust crypto amount from the given chain\n * @param {string} chain Chain to retrieve the dust amount of\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getChainDustValue(chain: string): CryptoAmount {\n const dustValue = this.getDustValues()[chain]\n if (!dustValue) throw Error(`No dust value known for ${chain} chain`)\n return dustValue\n }\n\n /**\n * Get MAYAname details\n * @param {string} MAYAName\n * @returns {MAYANameDetails | undefined} MAYANames details or undefined it is does not exist\n */\n public async getMAYANameDetails(MAYAName: string): Promise<MAYANameDetails | undefined> {\n return this.mayachainCache.midgardQuery.getMAYANameDetails(MAYAName)\n }\n\n /**\n * Get inbound addresses details\n * @returns Inbound details\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n return this.mayachainCache.getInboundDetails()\n }\n\n /**\n * Get chain inbound address details\n * @returns Inbound details\n */\n public async getChainInboundDetails(chain: string): Promise<InboundDetail> {\n const inboundDetails = await this.getInboundDetails()\n if (!inboundDetails[chain]) throw Error(`No inbound details known for ${chain} chain`)\n return inboundDetails[chain]\n }\n\n /**\n * Get asset decimals\n * @param {Asset} asset\n * @returns the asset decimals\n * @throws {Error} if the asset is not supported in Mayachain\n */\n public async getAssetDecimals(asset: Asset): Promise<number> {\n if (isSynthAsset(asset)) return DEFAULT_MAYACHAIN_DECIMALS\n\n const assetNotation = assetToString(asset)\n const assetsDecimals = await this.mayachainCache.getAssetDecimals()\n if (!assetsDecimals[assetNotation]) throw Error(`Can not get decimals for ${assetNotation}`)\n\n return assetsDecimals[assetNotation]\n }\n}\n"],"names":["Network","QuoteApi","Configuration","MimirApi","NetworkApi","axiosRetry","axios","assetFromStringEx","assetToString","baseAmount","MidgardQuery","CachedValue","BigNumber","CryptoAmount","isSynthAsset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB,GAAoC;AAC7D,IAAA,OAAO,EAAE;AACP,QAAA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;AAAE,gBAAA,MAAM,KAAK,CAAC,CAAA,6BAAA,EAAgC,KAAK,CAAA,MAAA,CAAQ,CAAC,CAAA;AACtF,YAAA,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;SAC7B,CAAA,CAAA;AAAA,KAAA;AAED;;;;;AAKG;AACU,IAAA,gBAAgB,CAAC,KAAY,EAAA;;YACxC,IAAIK,uBAAY,CAAC,KAAK,CAAC;AAAE,gBAAA,OAAO,0BAA0B,CAAA;AAE1D,YAAA,MAAM,aAAa,GAAGN,wBAAa,CAAC,KAAK,CAAC,CAAA;YAC1C,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAA;AACnE,YAAA,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;AAAE,gBAAA,MAAM,KAAK,CAAC,CAAA,yBAAA,EAA4B,aAAa,CAAA,CAAE,CAAC,CAAA;AAE5F,YAAA,OAAO,cAAc,CAAC,aAAa,CAAC,CAAA;SACrC,CAAA,CAAA;AAAA,KAAA;AACF;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/utils/mayanode.ts","../src/utils/const.ts","../src/utils/utils.ts","../src/mayachain-cache.ts","../src/mayachain-query.ts"],"sourcesContent":["import { Network } from '@xchainjs/xchain-client'\nimport {\n Configuration,\n InboundAddress,\n MimirApi,\n MimirResponse,\n NetworkApi,\n QuoteApi,\n QuoteSwapResponse,\n} from '@xchainjs/xchain-mayanode'\nimport axios from 'axios'\nimport axiosRetry from 'axios-retry'\n\nexport type MayanodeConfig = {\n apiRetries: number\n mayanodeBaseUrls: string[]\n}\n\nconst defaultMayanodeConfig: Record<Network, MayanodeConfig> = {\n mainnet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://mayanode.mayachain.info'],\n },\n stagenet: {\n apiRetries: 3,\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n testnet: {\n apiRetries: 3,\n // There is no testnet for mayanode\n mayanodeBaseUrls: ['https://stagenet.mayanode.mayachain.info'],\n },\n}\n\nexport class Mayanode {\n private config: MayanodeConfig\n private network: Network\n private quoteApis: QuoteApi[]\n private mimirApis: MimirApi[]\n private networkApis: NetworkApi[]\n\n constructor(network: Network = Network.Mainnet, config?: MayanodeConfig) {\n this.network = network\n this.config = config ?? defaultMayanodeConfig[this.network]\n this.quoteApis = this.config.mayanodeBaseUrls.map((url) => new QuoteApi(new Configuration({ basePath: url })))\n this.mimirApis = this.config.mayanodeBaseUrls.map((url) => new MimirApi(new Configuration({ basePath: url })))\n this.networkApis = this.config.mayanodeBaseUrls.map((url) => new NetworkApi(new Configuration({ basePath: url })))\n\n axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay })\n }\n\n /**\n * TODO\n * @param fromAsset - input asset\n * @param toAsset - output asset\n * @param amount - amount to swap\n * @param destinationAddress - destination address for the swap\n * @param toleranceBps - slip percent\n * @param affiliateBps - affiliate percent\n * @param affiliate - affiliate address\n * @param height - block height\n * @returns quotes swap object response\n */\n public async getSwapQuote(\n fromAsset: string,\n toAsset: string,\n amount: number,\n destinationAddress?: string,\n toleranceBps?: number,\n affiliateBps?: number,\n affiliate?: string,\n height?: number,\n ): Promise<QuoteSwapResponse> {\n for (const api of this.quoteApis) {\n try {\n return (\n await api.quoteswap(\n height,\n fromAsset,\n toAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliate,\n )\n ).data\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n\n /**\n * Get current active mimir configuration.\n * @returns mimir configuration\n */\n public async getMimir(): Promise<MimirResponse> {\n for (const api of this.mimirApis) {\n try {\n return (await api.mimir()).data\n } catch (e) {}\n }\n throw Error(`MAYANode not responding`)\n }\n\n /**\n * Get the set of asgard addresses that should be used for inbound transactions.\n * @returns MAYA inbound addresses\n */\n public async getInboundAddresses(): Promise<InboundAddress[]> {\n for (const api of this.networkApis) {\n try {\n const resp = (await api.inboundAddresses()).data\n return resp\n } catch (e) {}\n }\n throw new Error(`MAYANode not responding`)\n }\n}\n","import { assetFromStringEx } from '@xchainjs/xchain-util'\n\nexport const BtcAsset = assetFromStringEx('BTC.BTC')\nexport const EthAsset = assetFromStringEx('ETH.ETH')\nexport const CacaoAsset = assetFromStringEx('MAYA.CACAO')\nexport const RuneAsset = assetFromStringEx('THOR.RUNE')\nexport const DashAsset = assetFromStringEx('DASH.DASH')\nexport const KujiraAsset = assetFromStringEx('KUJI.KUJI')\n\nexport const BtcChain = 'BTC'\nexport const EthChain = 'ETH'\nexport const MayaChain = 'MAYA'\nexport const ThorChain = 'THOR'\nexport const DashChain = 'DASH'\nexport const KujiraChain = 'KUJI'\n\nexport const DEFAULT_MAYACHAIN_DECIMALS = 8\n","import { Asset, CryptoAmount, assetToString, baseAmount } from '@xchainjs/xchain-util'\nimport BigNumber from 'bignumber.js'\n\nimport { CacaoAsset } from './const'\n\nexport const isCacaoAsset = (asset: Asset): boolean => assetToString(asset) === assetToString(CacaoAsset)\n\nexport const getBaseAmountWithDiffDecimals = (inputAmount: CryptoAmount, outDecimals: number): BigNumber => {\n const inDecimals = inputAmount.baseAmount.decimal\n let baseAmountOut = inputAmount.baseAmount.amount()\n const adjustDecimals = outDecimals - inDecimals\n baseAmountOut = baseAmountOut.times(10 ** adjustDecimals)\n return baseAmount(baseAmountOut, outDecimals).amount()\n}\n","import { MidgardQuery } from '@xchainjs/xchain-mayamidgard-query'\nimport { CachedValue } from '@xchainjs/xchain-util'\nimport { BigNumber } from 'bignumber.js'\n\nimport { InboundDetail } from './types'\nimport { MayaChain, Mayanode } from './utils'\n\nexport type MayachainCacheConf = {\n expirationTimeInboundAddress: number // Expiration time for the inbound address cache in milliseconds\n}\n\n/**\n * This class manages retrieving information from up-to-date Mayachain.\n */\nexport class MayachainCache {\n readonly midgardQuery: MidgardQuery // Instance of the Maya MidgardQuery API\n readonly mayanode: Mayanode // Instance of the Maya Mayanode API\n private conf: MayachainCacheConf // Configuration for the cache\n private readonly inboundDetailCache: CachedValue<Record<string, InboundDetail>> // Cached value for inbound details\n private readonly assetDecimalsCache: CachedValue<Record<string, number>> // Cached value for asset decimals\n\n /**\n * Constructor to create a MayachainCache.\n *\n * @param midgardQuery - An instance of the Maya MidgardQuery API.\n * @param mayanode - An instance of the Maya Mayanode API.\n * @param configuration - Optional configuration for the cache.\n * @returns MayachainCache.\n */\n constructor(\n midgardQuery = new MidgardQuery(),\n mayanode = new Mayanode(),\n configuration?: Partial<MayachainCacheConf>,\n ) {\n // Initialize instances and configuration\n this.midgardQuery = midgardQuery\n this.mayanode = mayanode\n this.conf = { expirationTimeInboundAddress: 6000, ...configuration }\n\n // Initialize cached values\n this.inboundDetailCache = new CachedValue<Record<string, InboundDetail>>(\n () => this.refreshInboundDetailCache(),\n this.conf.expirationTimeInboundAddress,\n )\n this.assetDecimalsCache = new CachedValue<Record<string, number>>(() => this.refreshAssetDecimalsCache())\n }\n\n /**\n * Get inbound addresses details.\n *\n * @returns Inbound details.\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n if (!this.inboundDetailCache) throw Error(`Could not refresh inbound details`)\n return await this.inboundDetailCache.getValue()\n }\n\n /**\n * Get the number of decimals of the supported Mayachain tokens.\n *\n * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value.\n */\n public async getAssetDecimals(): Promise<Record<string, number>> {\n if (!this.assetDecimalsCache) throw Error(`Could not refresh assets decimals`)\n return await this.assetDecimalsCache.getValue()\n }\n\n /**\n * Refreshes the InboundDetailCache cache.\n */\n private async refreshInboundDetailCache(): Promise<Record<string, InboundDetail>> {\n // Implementation details for refreshing the inbound detail cache\n const [mimirDetails, allInboundAddresses] = await Promise.all([\n this.mayanode.getMimir(),\n this.mayanode.getInboundAddresses(),\n ])\n const inboundDetails: Record<string, InboundDetail> = {}\n for (const inbound of allInboundAddresses) {\n const chain = inbound.chain\n if (\n !chain ||\n !inbound.gas_rate ||\n !inbound.address ||\n !inbound.gas_rate_units ||\n !inbound.outbound_tx_size ||\n !inbound.outbound_fee ||\n !inbound.gas_rate_units\n )\n throw new Error(`Missing required inbound info`)\n\n inboundDetails[chain] = {\n chain: chain,\n address: inbound.address,\n router: inbound.router,\n gasRate: new BigNumber(inbound.gas_rate),\n gasRateUnits: inbound.gas_rate_units,\n outboundTxSize: new BigNumber(inbound.outbound_tx_size),\n outboundFee: new BigNumber(inbound.outbound_fee),\n haltedChain: inbound?.halted || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],\n haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],\n haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],\n }\n }\n // add mock MAYAChain inbound details\n inboundDetails[MayaChain] = {\n chain: MayaChain,\n address: '',\n router: '',\n gasRate: new BigNumber(0),\n gasRateUnits: '',\n outboundTxSize: new BigNumber(0),\n outboundFee: new BigNumber(0),\n haltedChain: false,\n haltedTrading: !!mimirDetails['HALTTRADING'],\n haltedLP: false, //\n }\n\n return inboundDetails\n }\n\n /**\n * Refreshes the number of decimals of the supported Mayachain tokens.\n */\n private async refreshAssetDecimalsCache(): Promise<Record<string, number>> {\n // Implementation details for refreshing the asset decimals cache\n // TODO: As soon as Mayachain returns native decimals from any endpoint of its API, refactor the function\n return {\n 'BTC.BTC': 8,\n 'ETH.ETH': 18,\n 'DASH.DASH': 8,\n 'KUJI.KUJI': 6,\n 'THOR.RUNE': 8,\n 'MAYA.CACAO': 8,\n 'ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7': 6,\n 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': 6,\n 'ETH.WSTETH-0X7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0': 18,\n 'KUJI.USK': 6,\n }\n }\n}\n","import { Network } from '@xchainjs/xchain-client'\nimport { MAYANameDetails } from '@xchainjs/xchain-mayamidgard-query'\nimport { QuoteSwapResponse } from '@xchainjs/xchain-mayanode'\nimport { Asset, CryptoAmount, assetFromStringEx, assetToString, baseAmount, isSynthAsset } from '@xchainjs/xchain-util'\n\nimport { MayachainCache } from './mayachain-cache'\nimport { InboundDetail, QuoteSwap, QuoteSwapParams } from './types'\nimport {\n BtcAsset,\n BtcChain,\n CacaoAsset,\n DEFAULT_MAYACHAIN_DECIMALS,\n DashAsset,\n DashChain,\n EthAsset,\n EthChain,\n KujiraAsset,\n KujiraChain,\n MayaChain,\n RuneAsset,\n ThorChain,\n getBaseAmountWithDiffDecimals,\n} from './utils'\n\n/**\n * MAYAChain Class for interacting with MAYAChain.\n * Recommended main class to use for swapping with MAYAChain\n * Has access to Midgard and MAYANode data\n */\nexport class MayachainQuery {\n private mayachainCache: MayachainCache\n\n /**\n * Constructor to create a MayachainAMM\n * @param mayachainCache - an instance of the MayachainCache (could be pointing to stagenet,testnet,mainnet)\n * @param chainAttributes - attributes used to calculate waitTime & conf counting\n * @returns MayachainAMM\n */\n constructor(mayachainCache = new MayachainCache()) {\n // Initialize MayachainCache instance\n this.mayachainCache = mayachainCache\n }\n\n /**\n * Get the Mayachain network.\n * @returns\n */\n public getNetwork(): Network {\n return this.mayachainCache.midgardQuery.getNetwork()\n }\n\n /**\n * Quote a swap operation.\n * @param {QuoteSwapParams} quoteSwapParams - Parameters for the quote swap operation.\n * @returns {QuoteSwap} A quote for the swap operation.\n */\n public async quoteSwap({\n fromAsset,\n destinationAsset,\n amount,\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n }: QuoteSwapParams): Promise<QuoteSwap> {\n const fromAssetString = assetToString(fromAsset)\n const toAssetString = assetToString(destinationAsset)\n // Endpoint allows 10 decimals for Cacao, 8 for the rest of assets\n const inputAmount =\n fromAssetString === assetToString(CacaoAsset)\n ? amount.baseAmount.amount()\n : getBaseAmountWithDiffDecimals(amount, 8)\n\n const swapQuote: QuoteSwapResponse = await this.mayachainCache.mayanode.getSwapQuote(\n fromAssetString,\n toAssetString,\n inputAmount.toNumber(),\n destinationAddress,\n toleranceBps,\n affiliateBps,\n affiliateAddress,\n height,\n )\n\n const response: { error?: string } = JSON.parse(JSON.stringify(swapQuote))\n if (response.error) {\n return {\n toAddress: ``,\n memo: ``,\n expectedAmount: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: destinationAsset,\n affiliateFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n outboundFee: new CryptoAmount(\n baseAmount(0, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n },\n outboundDelayBlocks: 0,\n outboundDelaySeconds: 0,\n inboundConfirmationSeconds: 0,\n inboundConfirmationBlocks: 0,\n canSwap: false,\n errors: [`Mayanode request quote: ${response.error}`],\n slipBasisPoints: 0,\n totalSwapSeconds: 0,\n warning: '',\n }\n }\n\n const feeAsset = assetFromStringEx(swapQuote.fees.asset)\n\n const errors: string[] = []\n if (swapQuote.memo === undefined) errors.push(`Error parsing swap quote: Memo is ${swapQuote.memo}`)\n\n const isFeeAssetCacao = swapQuote.fees.asset === assetToString(CacaoAsset)\n return {\n toAddress: swapQuote.inbound_address || '',\n memo: swapQuote.memo || '',\n expectedAmount: new CryptoAmount(\n baseAmount(swapQuote.expected_amount_out, toAssetString === assetToString(CacaoAsset) ? 10 : 8),\n destinationAsset,\n ),\n dustThreshold: this.getChainDustValue(fromAsset.chain),\n fees: {\n asset: feeAsset,\n affiliateFee: new CryptoAmount(baseAmount(swapQuote.fees.affiliate, isFeeAssetCacao ? 10 : 8), feeAsset),\n outboundFee: new CryptoAmount(baseAmount(swapQuote.fees.outbound, isFeeAssetCacao ? 10 : 8), feeAsset),\n },\n slipBasisPoints: swapQuote.slippage_bps,\n outboundDelayBlocks: swapQuote.outbound_delay_blocks,\n outboundDelaySeconds: swapQuote.outbound_delay_seconds,\n inboundConfirmationSeconds: swapQuote.inbound_confirmation_seconds,\n inboundConfirmationBlocks: swapQuote.inbound_confirmation_blocks,\n totalSwapSeconds: (swapQuote.inbound_confirmation_seconds || 0) + swapQuote.outbound_delay_seconds,\n canSwap: !(!swapQuote.memo || errors.length > 0),\n errors,\n warning: '',\n }\n }\n\n /**\n * Return mayachain supported chains dust amounts\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getDustValues(): Record<string, CryptoAmount> {\n // TODO: Find out how to fetch native asset decimals\n return {\n [BtcChain]: new CryptoAmount(baseAmount(10000, 8), BtcAsset),\n [EthChain]: new CryptoAmount(baseAmount(0, 18), EthAsset),\n [DashChain]: new CryptoAmount(baseAmount(10000, 8), DashAsset),\n [KujiraChain]: new CryptoAmount(baseAmount(0, 6), KujiraAsset),\n [ThorChain]: new CryptoAmount(baseAmount(0, 8), RuneAsset),\n [MayaChain]: new CryptoAmount(baseAmount(0, 10), CacaoAsset),\n }\n }\n\n /**\n * Return the dust crypto amount from the given chain\n * @param {string} chain Chain to retrieve the dust amount of\n * @returns a map where chain is the key and dust amount cryptoAmount as value\n */\n public getChainDustValue(chain: string): CryptoAmount {\n const dustValue = this.getDustValues()[chain]\n if (!dustValue) throw Error(`No dust value known for ${chain} chain`)\n return dustValue\n }\n\n /**\n * Get MAYAname details\n * @param {string} MAYAName\n * @returns {MAYANameDetails | undefined} MAYANames details or undefined it is does not exist\n */\n public async getMAYANameDetails(MAYAName: string): Promise<MAYANameDetails | undefined> {\n return this.mayachainCache.midgardQuery.getMAYANameDetails(MAYAName)\n }\n\n /**\n * Get inbound addresses details\n * @returns Inbound details\n */\n public async getInboundDetails(): Promise<Record<string, InboundDetail>> {\n return this.mayachainCache.getInboundDetails()\n }\n\n /**\n * Get chain inbound address details\n * @returns Inbound details\n */\n public async getChainInboundDetails(chain: string): Promise<InboundDetail> {\n const inboundDetails = await this.getInboundDetails()\n if (!inboundDetails[chain]) throw Error(`No inbound details known for ${chain} chain`)\n return inboundDetails[chain]\n }\n\n /**\n * Get asset decimals\n * @param {Asset} asset\n * @returns the asset decimals\n * @throws {Error} if the asset is not supported in Mayachain\n */\n public async getAssetDecimals(asset: Asset): Promise<number> {\n if (isSynthAsset(asset)) return DEFAULT_MAYACHAIN_DECIMALS\n\n const assetNotation = assetToString(asset)\n const assetsDecimals = await this.mayachainCache.getAssetDecimals()\n if (!assetsDecimals[assetNotation]) throw Error(`Can not get decimals for ${assetNotation}`)\n\n return assetsDecimals[assetNotation]\n }\n}\n"],"names":["Network","QuoteApi","Configuration","MimirApi","NetworkApi","axiosRetry","axios","assetFromStringEx","assetToString","baseAmount","MidgardQuery","CachedValue","BigNumber","CryptoAmount","isSynthAsset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB,GAAoC;AAC7D,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,CAAC;QACb,gBAAgB,EAAE,CAAC,iCAAiC,CAAC;AACtD,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,CAAC;QACb,gBAAgB,EAAE,CAAC,0CAA0C,CAAC;AAC/D,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,UAAU,EAAE,CAAC;;QAEb,gBAAgB,EAAE,CAAC,0CAA0C,CAAC;AAC/D,KAAA;CACF,CAAA;MAEY,QAAQ,CAAA;AAOnB,IAAA,WAAA,CAAY,OAAmB,GAAAA,oBAAO,CAAC,OAAO,EAAE,MAAuB,EAAA;AACrE,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;AACtB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,KAAA,KAAA,CAAA,GAAN,MAAM,GAAI,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC3D,QAAA,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAA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AA,CAAA;AAAA,KAAA;AACF;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ export type MayachainCacheConf = {
5
5
  expirationTimeInboundAddress: number;
6
6
  };
7
7
  /**
8
- * This class manages retrieving information from up to date Mayachain
8
+ * This class manages retrieving information from up-to-date Mayachain.
9
9
  */
10
10
  export declare class MayachainCache {
11
11
  readonly midgardQuery: MidgardQuery;
@@ -14,29 +14,32 @@ export declare class MayachainCache {
14
14
  private readonly inboundDetailCache;
15
15
  private readonly assetDecimalsCache;
16
16
  /**
17
- * Constructor to create a MayachainCache
17
+ * Constructor to create a MayachainCache.
18
18
  *
19
- * @param midgardQuery - an instance of the Maya MidgardQuery API
20
- * @param mayanode
21
- * @returns MayachainCache
19
+ * @param midgardQuery - An instance of the Maya MidgardQuery API.
20
+ * @param mayanode - An instance of the Maya Mayanode API.
21
+ * @param configuration - Optional configuration for the cache.
22
+ * @returns MayachainCache.
22
23
  */
23
24
  constructor(midgardQuery?: MidgardQuery, mayanode?: Mayanode, configuration?: Partial<MayachainCacheConf>);
24
25
  /**
25
- * Get inbound addresses details
26
- * @returns Inbound details
26
+ * Get inbound addresses details.
27
+ *
28
+ * @returns Inbound details.
27
29
  */
28
30
  getInboundDetails(): Promise<Record<string, InboundDetail>>;
29
31
  /**
30
- * Get the number of the decimals of the supported Mayachain tokens
31
- * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value
32
+ * Get the number of decimals of the supported Mayachain tokens.
33
+ *
34
+ * @returns {Record<string, number>} A record with the string asset notation as key and the number of decimals as value.
32
35
  */
33
36
  getAssetDecimals(): Promise<Record<string, number>>;
34
37
  /**
35
- * Refreshes the InboundDetailCache Cache
38
+ * Refreshes the InboundDetailCache cache.
36
39
  */
37
40
  private refreshInboundDetailCache;
38
41
  /**
39
- * Refreshes the number of decimals of the supported Mayachain tokens
42
+ * Refreshes the number of decimals of the supported Mayachain tokens.
40
43
  */
41
44
  private refreshAssetDecimalsCache;
42
45
  }
@@ -18,14 +18,14 @@ export declare class MayachainQuery {
18
18
  */
19
19
  constructor(mayachainCache?: MayachainCache);
20
20
  /**
21
- * Get the mayachain query is working with
21
+ * Get the Mayachain network.
22
22
  * @returns
23
23
  */
24
24
  getNetwork(): Network;
25
25
  /**
26
- * Quote a swap
27
- * @param {QuoteSwapParams} quoteSwapParams - quote swap input params
28
- * @returns {QuoteSwap}
26
+ * Quote a swap operation.
27
+ * @param {QuoteSwapParams} quoteSwapParams - Parameters for the quote swap operation.
28
+ * @returns {QuoteSwap} A quote for the swap operation.
29
29
  */
30
30
  quoteSwap({ fromAsset, destinationAsset, amount, destinationAddress, toleranceBps, affiliateBps, affiliateAddress, height, }: QuoteSwapParams): Promise<QuoteSwap>;
31
31
  /**
package/lib/types.d.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import { Address, Asset, Chain, CryptoAmount } from '@xchainjs/xchain-util';
2
2
  import { BigNumber } from 'bignumber.js';
3
3
  /**
4
- * Quote swap types
4
+ * Represents fees associated with a swap.
5
5
  */
6
6
  export type Fees = {
7
7
  asset: Asset;
8
8
  affiliateFee: CryptoAmount;
9
9
  outboundFee: CryptoAmount;
10
10
  };
11
+ /**
12
+ * Represents a quote for a swap operation.
13
+ */
11
14
  export type QuoteSwap = {
12
15
  toAddress: Address;
13
16
  memo: string;
@@ -24,6 +27,9 @@ export type QuoteSwap = {
24
27
  errors: string[];
25
28
  warning: string;
26
29
  };
30
+ /**
31
+ * Represents parameters for quoting a swap operation.
32
+ */
27
33
  export type QuoteSwapParams = {
28
34
  fromAsset: Asset;
29
35
  destinationAsset: Asset;
@@ -36,7 +42,7 @@ export type QuoteSwapParams = {
36
42
  affiliateAddress?: string;
37
43
  };
38
44
  /**
39
- * Inbound address
45
+ * Represents details about an inbound address.
40
46
  */
41
47
  export type InboundDetail = {
42
48
  chain: Chain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-mayachain-query",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "license": "MIT",
5
5
  "description": "Mayachain query module that is responsible for estimating swap calculations and add/remove liquidity for thorchain",
6
6
  "keywords": [
@@ -24,7 +24,7 @@
24
24
  "url": "git@github.com:xchainjs/xchainjs-lib.git"
25
25
  },
26
26
  "scripts": {
27
- "clean": "rimraf lib/**",
27
+ "clean": "rimraf --glob ./lib/**",
28
28
  "build": "yarn clean && rollup -c",
29
29
  "test": "jest",
30
30
  "e2e": "jest --config jest.config.e2e.js",
@@ -33,19 +33,19 @@
33
33
  "postversion": "git push --follow-tags"
34
34
  },
35
35
  "devDependencies": {
36
- "@xchainjs/xchain-client": "^0.16.1",
37
- "@xchainjs/xchain-mayamidgard-query": "^0.1.5",
36
+ "@xchainjs/xchain-client": "^0.16.2",
37
+ "@xchainjs/xchain-mayamidgard-query": "^0.1.6",
38
38
  "@xchainjs/xchain-mayanode": "^0.1.3",
39
- "@xchainjs/xchain-util": "^0.13.0",
39
+ "@xchainjs/xchain-util": "^0.13.3",
40
40
  "axios": "^1.3.6",
41
41
  "axios-retry": "^3.2.5",
42
42
  "bignumber.js": "^9.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@xchainjs/xchain-client": "^0.16.1",
46
- "@xchainjs/xchain-mayamidgard-query": "^0.1.5",
45
+ "@xchainjs/xchain-client": "^0.16.2",
46
+ "@xchainjs/xchain-mayamidgard-query": "^0.1.6",
47
47
  "@xchainjs/xchain-mayanode": "^0.1.3",
48
- "@xchainjs/xchain-util": "^0.13.0",
48
+ "@xchainjs/xchain-util": "^0.13.3",
49
49
  "axios": "^1.3.6",
50
50
  "axios-retry": "^3.2.5",
51
51
  "bignumber.js": "^9.0.0"
@@ -53,4 +53,4 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  }
56
- }
56
+ }