@xchainjs/xchain-mayachain-amm 1.0.7 → 1.0.9

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.d.ts CHANGED
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Re-exports all members from the "mayachain-amm" module.
3
+ * This allows users to import members from "mayachain-amm" directly from this module.
4
+ */
1
5
  export * from './mayachain-amm';
6
+ /**
7
+ * Re-exports all members from the "types" module.
8
+ * This allows users to import members from "types" directly from this module.
9
+ */
2
10
  export * from './types';
package/lib/index.esm.js CHANGED
@@ -44,8 +44,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
44
44
  class MayachainAMM {
45
45
  /**
46
46
  * Constructor to create a MayachainAMM
47
- * @param mayachainQuery - an instance of the MayachainQuery
48
- * @returns MayachainAMM
47
+ * @param mayachainQuery - An instance of the MayachainQuery
48
+ * @returns MayachainAMM Returns the MayachainAMM
49
49
  */
50
50
  constructor(mayachainQuery = new MayachainQuery(), wallet = new Wallet({
51
51
  BTC: new Client(Object.assign(Object.assign({}, defaultBTCParams), { network: Network.Mainnet })),
@@ -109,25 +109,29 @@ class MayachainAMM {
109
109
  });
110
110
  }
111
111
  /**
112
- * Validate swap params
113
- * @param {QuoteSwapParams} quoteSwapParams Swap params
114
- * @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
112
+ * Validate swap params before performing a swap operation
113
+ * @param {QuoteSwapParams} quoteSwapParams - Swap parameters
114
+ * @returns {string[]} - Reasons the swap cannot be executed. Empty array if the swap is valid.
115
115
  */
116
116
  validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }) {
117
117
  return __awaiter(this, void 0, void 0, function* () {
118
118
  const errors = [];
119
+ // Validate destination address if provided
119
120
  if (destinationAddress && !this.wallet.validateAddress(destinationAsset.chain, destinationAddress)) {
120
121
  errors.push(`destinationAddress ${destinationAddress} is not a valid address`);
121
122
  }
123
+ // Validate affiliate address if provided
122
124
  if (affiliateAddress) {
123
125
  const isMayaAddress = this.wallet.validateAddress(MAYAChain, affiliateAddress);
124
126
  const isMayaName = yield this.isMAYAName(affiliateAddress);
125
127
  if (!(isMayaAddress || isMayaName))
126
128
  errors.push(`affiliateAddress ${affiliateAddress} is not a valid MAYA address`);
127
129
  }
130
+ // Validate affiliate basis points if provided
128
131
  if (affiliateBps && (affiliateBps < 0 || affiliateBps > 10000)) {
129
132
  errors.push(`affiliateBps ${affiliateBps} out of range [0 - 10000]`);
130
133
  }
134
+ // Validate approval if asset is an ERC20 token and fromAddress is provided
131
135
  if (this.isERC20Asset(fromAsset) && fromAddress) {
132
136
  const approveErrors = yield this.isRouterApprovedToSpend({
133
137
  asset: fromAsset,
@@ -140,9 +144,9 @@ class MayachainAMM {
140
144
  });
141
145
  }
142
146
  /**
143
- * Do swap between assets
144
- * @param {QuoteSwapParams} quoteSwapParams Swap params
145
- * @returns {TxSubmitted} the swap transaction hash and url
147
+ * Perform a swap operation between assets
148
+ * @param {QuoteSwapParams} quoteSwapParams Swap parameters
149
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
146
150
  */
147
151
  doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }) {
148
152
  return __awaiter(this, void 0, void 0, function* () {
@@ -156,24 +160,28 @@ class MayachainAMM {
156
160
  affiliateBps,
157
161
  toleranceBps,
158
162
  });
163
+ // Check if the swap can be performed
159
164
  if (!quoteSwap.canSwap)
160
165
  throw Error(`Can not swap. ${quoteSwap.errors.join(' ')}`);
166
+ // Perform the swap based on the asset chain
161
167
  return fromAsset.chain === MAYAChain || fromAsset.synth
162
168
  ? this.doProtocolAssetSwap(amount, quoteSwap.memo)
163
169
  : this.doNonProtocolAssetSwap(amount, quoteSwap.toAddress, quoteSwap.memo);
164
170
  });
165
171
  }
166
172
  /**
167
- * Approve Mayachain router in the chain of the asset to spend the amount in name of the address
168
- * @param {ApproveParams} approveParams contains the asset and amount the router will be allowed. If amount is not defined,
169
- * an infinity approve will be done
173
+ * Approve Mayachain router to spend a certain amount in the chain of the asset
174
+ * @param {ApproveParams} approveParams Parameters for approving the router to spend
170
175
  */
171
176
  approveRouterToSpend({ asset, amount }) {
172
177
  return __awaiter(this, void 0, void 0, function* () {
178
+ // Get inbound details for the asset chain
173
179
  const inboundDetails = yield this.mayachainQuery.getChainInboundDetails(asset.chain);
174
180
  if (!inboundDetails.router)
175
181
  throw Error(`Unknown router address for ${asset.chain}`);
182
+ // Perform approval
176
183
  const tx = yield this.wallet.approve(asset, (amount === null || amount === void 0 ? void 0 : amount.baseAmount) || baseAmount(MAX_APPROVAL.toString(), yield this.mayachainQuery.getAssetDecimals(asset)), inboundDetails.router);
184
+ // Return transaction hash and URL
177
185
  return {
178
186
  hash: tx.hash,
179
187
  url: yield this.wallet.getExplorerTxUrl(asset.chain, tx.hash),
@@ -181,17 +189,18 @@ class MayachainAMM {
181
189
  });
182
190
  }
183
191
  /**
184
- * Validate if the asset router is allowed to spend the asset amount in name of the address
185
- * @param {IsApprovedParams} isApprovedParams contains the asset and the amount the router is supposed to spend
186
- * int name of address
187
- * @returns {string[]} the reasons the router of the asset is not allowed to spend the amount. If it is empty, the asset router is allowed to spend the amount
192
+ * Validate if the asset router is allowed to spend the asset amount on behalf of the address
193
+ * @param {IsApprovedParams} isApprovedParams Parameters for checking approval
194
+ * @returns {string[]} Reasons the asset router is not allowed to spend the amount. Empty array if the router is approved.
188
195
  */
189
196
  isRouterApprovedToSpend({ asset, amount, address }) {
190
197
  return __awaiter(this, void 0, void 0, function* () {
191
198
  const errors = [];
199
+ // Get inbound details for the asset chain
192
200
  const inboundDetails = yield this.mayachainQuery.getChainInboundDetails(asset.chain);
193
201
  if (!inboundDetails.router)
194
202
  throw Error(`Unknown router address for ${asset.chain}`);
203
+ // Check if the router is approved to spend the amount
195
204
  const isApprovedResult = yield this.wallet.isApproved(asset, amount.baseAmount, address, inboundDetails.router);
196
205
  if (!isApprovedResult)
197
206
  errors.push('Maya router has not been approved to spend this amount');
@@ -200,8 +209,8 @@ class MayachainAMM {
200
209
  }
201
210
  /**
202
211
  * Check if a name is a valid MAYAName
203
- * @param {string} name MAYAName
204
- * @returns {boolean} true if is a registered MAYAName, otherwise, false
212
+ * @param {string} name MAYAName to check
213
+ * @returns {boolean} True if the name is registered as a MAYAName, otherwise false
205
214
  */
206
215
  isMAYAName(name) {
207
216
  return __awaiter(this, void 0, void 0, function* () {
@@ -209,13 +218,14 @@ class MayachainAMM {
209
218
  });
210
219
  }
211
220
  /**
212
- * Do swap from native protocol asset to any other asset
221
+ * Perform a swap from a native protocol asset to any other asset
213
222
  * @param {CryptoAmount} amount Amount to swap
214
- * @param {string} memo Memo to add to the transaction to successfully make the swap
215
- * @returns {TxSubmitted} the swap transaction hash and url
223
+ * @param {string} memo Memo to add to the transaction
224
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
216
225
  */
217
226
  doProtocolAssetSwap(amount, memo) {
218
227
  return __awaiter(this, void 0, void 0, function* () {
228
+ // Deposit the amount and return transaction hash and URL
219
229
  const hash = yield this.wallet.deposit({ asset: amount.asset, amount: amount.baseAmount, memo });
220
230
  return {
221
231
  hash,
@@ -224,15 +234,15 @@ class MayachainAMM {
224
234
  });
225
235
  }
226
236
  /**
227
- * Do swap between assets
237
+ * Perform a swap between assets
228
238
  * @param {CryptoAmount} amount Amount to swap
229
239
  * @param {string} memo Memo to add to the transaction to successfully make the swap
230
240
  * @param {string} recipient inbound address to make swap transaction to
231
- * @returns {TxSubmitted} the swap transaction hash and url
241
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
232
242
  */
233
243
  doNonProtocolAssetSwap(amount, recipient, memo) {
234
244
  return __awaiter(this, void 0, void 0, function* () {
235
- // Non ERC20 swaps
245
+ // For non-ERC20 assets, perform a transfer and return transaction hash and URL
236
246
  if (!this.isERC20Asset(amount.asset)) {
237
247
  const hash = yield this.wallet.transfer({
238
248
  asset: amount.asset,
@@ -245,7 +255,7 @@ class MayachainAMM {
245
255
  url: yield this.wallet.getExplorerTxUrl(amount.asset.chain, hash),
246
256
  };
247
257
  }
248
- // ERC20 swaps
258
+ // For ERC20 assets, perform a deposit with expiry and return transaction hash and URL
249
259
  const inboundDetails = yield this.mayachainQuery.getChainInboundDetails(amount.asset.chain);
250
260
  if (!inboundDetails.router)
251
261
  throw Error(`Unknown router for ${amount.asset.chain} chain`);
@@ -276,19 +286,21 @@ class MayachainAMM {
276
286
  });
277
287
  }
278
288
  /**
279
- * Check if asset is ERC20
280
- * @param {Asset} asset to check
281
- * @returns true if asset is ERC20, otherwise, false
289
+ * Check if the asset is an ERC20 token
290
+ * @param {Asset} asset Asset to check
291
+ * @returns True if the asset is an ERC20 token, otherwise false
282
292
  */
283
293
  isERC20Asset(asset) {
294
+ // Check if the asset's chain is an EVM chain and if the symbol matches AssetETH.symbol
284
295
  return this.isEVMChain(asset.chain) ? [AssetETH.symbol].includes(asset.symbol) : false;
285
296
  }
286
297
  /**
287
- * Check if asset chain is EVM
288
- * @param {Chain} chain to check
289
- * @returns true if chain is EVM, otherwise, false
298
+ * Check if the chain is an EVM (Ethereum Virtual Machine) chain
299
+ * @param {Chain} chain Chain to check
300
+ * @returns True if the chain is an EVM chain, otherwise false
290
301
  */
291
302
  isEVMChain(chain) {
303
+ // Check if the chain matches AssetETH.chain
292
304
  return [AssetETH.chain].includes(chain);
293
305
  }
294
306
  }
package/lib/index.js CHANGED
@@ -48,8 +48,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
48
48
  class MayachainAMM {
49
49
  /**
50
50
  * Constructor to create a MayachainAMM
51
- * @param mayachainQuery - an instance of the MayachainQuery
52
- * @returns MayachainAMM
51
+ * @param mayachainQuery - An instance of the MayachainQuery
52
+ * @returns MayachainAMM Returns the MayachainAMM
53
53
  */
54
54
  constructor(mayachainQuery = new xchainMayachainQuery.MayachainQuery(), wallet = new xchainWallet.Wallet({
55
55
  BTC: new xchainBitcoin.Client(Object.assign(Object.assign({}, xchainBitcoin.defaultBTCParams), { network: xchainClient.Network.Mainnet })),
@@ -113,25 +113,29 @@ class MayachainAMM {
113
113
  });
114
114
  }
115
115
  /**
116
- * Validate swap params
117
- * @param {QuoteSwapParams} quoteSwapParams Swap params
118
- * @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
116
+ * Validate swap params before performing a swap operation
117
+ * @param {QuoteSwapParams} quoteSwapParams - Swap parameters
118
+ * @returns {string[]} - Reasons the swap cannot be executed. Empty array if the swap is valid.
119
119
  */
120
120
  validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }) {
121
121
  return __awaiter(this, void 0, void 0, function* () {
122
122
  const errors = [];
123
+ // Validate destination address if provided
123
124
  if (destinationAddress && !this.wallet.validateAddress(destinationAsset.chain, destinationAddress)) {
124
125
  errors.push(`destinationAddress ${destinationAddress} is not a valid address`);
125
126
  }
127
+ // Validate affiliate address if provided
126
128
  if (affiliateAddress) {
127
129
  const isMayaAddress = this.wallet.validateAddress(xchainMayachain.MAYAChain, affiliateAddress);
128
130
  const isMayaName = yield this.isMAYAName(affiliateAddress);
129
131
  if (!(isMayaAddress || isMayaName))
130
132
  errors.push(`affiliateAddress ${affiliateAddress} is not a valid MAYA address`);
131
133
  }
134
+ // Validate affiliate basis points if provided
132
135
  if (affiliateBps && (affiliateBps < 0 || affiliateBps > 10000)) {
133
136
  errors.push(`affiliateBps ${affiliateBps} out of range [0 - 10000]`);
134
137
  }
138
+ // Validate approval if asset is an ERC20 token and fromAddress is provided
135
139
  if (this.isERC20Asset(fromAsset) && fromAddress) {
136
140
  const approveErrors = yield this.isRouterApprovedToSpend({
137
141
  asset: fromAsset,
@@ -144,9 +148,9 @@ class MayachainAMM {
144
148
  });
145
149
  }
146
150
  /**
147
- * Do swap between assets
148
- * @param {QuoteSwapParams} quoteSwapParams Swap params
149
- * @returns {TxSubmitted} the swap transaction hash and url
151
+ * Perform a swap operation between assets
152
+ * @param {QuoteSwapParams} quoteSwapParams Swap parameters
153
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
150
154
  */
151
155
  doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }) {
152
156
  return __awaiter(this, void 0, void 0, function* () {
@@ -160,24 +164,28 @@ class MayachainAMM {
160
164
  affiliateBps,
161
165
  toleranceBps,
162
166
  });
167
+ // Check if the swap can be performed
163
168
  if (!quoteSwap.canSwap)
164
169
  throw Error(`Can not swap. ${quoteSwap.errors.join(' ')}`);
170
+ // Perform the swap based on the asset chain
165
171
  return fromAsset.chain === xchainMayachain.MAYAChain || fromAsset.synth
166
172
  ? this.doProtocolAssetSwap(amount, quoteSwap.memo)
167
173
  : this.doNonProtocolAssetSwap(amount, quoteSwap.toAddress, quoteSwap.memo);
168
174
  });
169
175
  }
170
176
  /**
171
- * Approve Mayachain router in the chain of the asset to spend the amount in name of the address
172
- * @param {ApproveParams} approveParams contains the asset and amount the router will be allowed. If amount is not defined,
173
- * an infinity approve will be done
177
+ * Approve Mayachain router to spend a certain amount in the chain of the asset
178
+ * @param {ApproveParams} approveParams Parameters for approving the router to spend
174
179
  */
175
180
  approveRouterToSpend({ asset, amount }) {
176
181
  return __awaiter(this, void 0, void 0, function* () {
182
+ // Get inbound details for the asset chain
177
183
  const inboundDetails = yield this.mayachainQuery.getChainInboundDetails(asset.chain);
178
184
  if (!inboundDetails.router)
179
185
  throw Error(`Unknown router address for ${asset.chain}`);
186
+ // Perform approval
180
187
  const tx = yield this.wallet.approve(asset, (amount === null || amount === void 0 ? void 0 : amount.baseAmount) || xchainUtil.baseAmount(xchainEvm.MAX_APPROVAL.toString(), yield this.mayachainQuery.getAssetDecimals(asset)), inboundDetails.router);
188
+ // Return transaction hash and URL
181
189
  return {
182
190
  hash: tx.hash,
183
191
  url: yield this.wallet.getExplorerTxUrl(asset.chain, tx.hash),
@@ -185,17 +193,18 @@ class MayachainAMM {
185
193
  });
186
194
  }
187
195
  /**
188
- * Validate if the asset router is allowed to spend the asset amount in name of the address
189
- * @param {IsApprovedParams} isApprovedParams contains the asset and the amount the router is supposed to spend
190
- * int name of address
191
- * @returns {string[]} the reasons the router of the asset is not allowed to spend the amount. If it is empty, the asset router is allowed to spend the amount
196
+ * Validate if the asset router is allowed to spend the asset amount on behalf of the address
197
+ * @param {IsApprovedParams} isApprovedParams Parameters for checking approval
198
+ * @returns {string[]} Reasons the asset router is not allowed to spend the amount. Empty array if the router is approved.
192
199
  */
193
200
  isRouterApprovedToSpend({ asset, amount, address }) {
194
201
  return __awaiter(this, void 0, void 0, function* () {
195
202
  const errors = [];
203
+ // Get inbound details for the asset chain
196
204
  const inboundDetails = yield this.mayachainQuery.getChainInboundDetails(asset.chain);
197
205
  if (!inboundDetails.router)
198
206
  throw Error(`Unknown router address for ${asset.chain}`);
207
+ // Check if the router is approved to spend the amount
199
208
  const isApprovedResult = yield this.wallet.isApproved(asset, amount.baseAmount, address, inboundDetails.router);
200
209
  if (!isApprovedResult)
201
210
  errors.push('Maya router has not been approved to spend this amount');
@@ -204,8 +213,8 @@ class MayachainAMM {
204
213
  }
205
214
  /**
206
215
  * Check if a name is a valid MAYAName
207
- * @param {string} name MAYAName
208
- * @returns {boolean} true if is a registered MAYAName, otherwise, false
216
+ * @param {string} name MAYAName to check
217
+ * @returns {boolean} True if the name is registered as a MAYAName, otherwise false
209
218
  */
210
219
  isMAYAName(name) {
211
220
  return __awaiter(this, void 0, void 0, function* () {
@@ -213,13 +222,14 @@ class MayachainAMM {
213
222
  });
214
223
  }
215
224
  /**
216
- * Do swap from native protocol asset to any other asset
225
+ * Perform a swap from a native protocol asset to any other asset
217
226
  * @param {CryptoAmount} amount Amount to swap
218
- * @param {string} memo Memo to add to the transaction to successfully make the swap
219
- * @returns {TxSubmitted} the swap transaction hash and url
227
+ * @param {string} memo Memo to add to the transaction
228
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
220
229
  */
221
230
  doProtocolAssetSwap(amount, memo) {
222
231
  return __awaiter(this, void 0, void 0, function* () {
232
+ // Deposit the amount and return transaction hash and URL
223
233
  const hash = yield this.wallet.deposit({ asset: amount.asset, amount: amount.baseAmount, memo });
224
234
  return {
225
235
  hash,
@@ -228,15 +238,15 @@ class MayachainAMM {
228
238
  });
229
239
  }
230
240
  /**
231
- * Do swap between assets
241
+ * Perform a swap between assets
232
242
  * @param {CryptoAmount} amount Amount to swap
233
243
  * @param {string} memo Memo to add to the transaction to successfully make the swap
234
244
  * @param {string} recipient inbound address to make swap transaction to
235
- * @returns {TxSubmitted} the swap transaction hash and url
245
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
236
246
  */
237
247
  doNonProtocolAssetSwap(amount, recipient, memo) {
238
248
  return __awaiter(this, void 0, void 0, function* () {
239
- // Non ERC20 swaps
249
+ // For non-ERC20 assets, perform a transfer and return transaction hash and URL
240
250
  if (!this.isERC20Asset(amount.asset)) {
241
251
  const hash = yield this.wallet.transfer({
242
252
  asset: amount.asset,
@@ -249,7 +259,7 @@ class MayachainAMM {
249
259
  url: yield this.wallet.getExplorerTxUrl(amount.asset.chain, hash),
250
260
  };
251
261
  }
252
- // ERC20 swaps
262
+ // For ERC20 assets, perform a deposit with expiry and return transaction hash and URL
253
263
  const inboundDetails = yield this.mayachainQuery.getChainInboundDetails(amount.asset.chain);
254
264
  if (!inboundDetails.router)
255
265
  throw Error(`Unknown router for ${amount.asset.chain} chain`);
@@ -280,19 +290,21 @@ class MayachainAMM {
280
290
  });
281
291
  }
282
292
  /**
283
- * Check if asset is ERC20
284
- * @param {Asset} asset to check
285
- * @returns true if asset is ERC20, otherwise, false
293
+ * Check if the asset is an ERC20 token
294
+ * @param {Asset} asset Asset to check
295
+ * @returns True if the asset is an ERC20 token, otherwise false
286
296
  */
287
297
  isERC20Asset(asset) {
298
+ // Check if the asset's chain is an EVM chain and if the symbol matches AssetETH.symbol
288
299
  return this.isEVMChain(asset.chain) ? [xchainEthereum.AssetETH.symbol].includes(asset.symbol) : false;
289
300
  }
290
301
  /**
291
- * Check if asset chain is EVM
292
- * @param {Chain} chain to check
293
- * @returns true if chain is EVM, otherwise, false
302
+ * Check if the chain is an EVM (Ethereum Virtual Machine) chain
303
+ * @param {Chain} chain Chain to check
304
+ * @returns True if the chain is an EVM chain, otherwise false
294
305
  */
295
306
  isEVMChain(chain) {
307
+ // Check if the chain matches AssetETH.chain
296
308
  return [xchainEthereum.AssetETH.chain].includes(chain);
297
309
  }
298
310
  }
@@ -11,8 +11,8 @@ export declare class MayachainAMM {
11
11
  private wallet;
12
12
  /**
13
13
  * Constructor to create a MayachainAMM
14
- * @param mayachainQuery - an instance of the MayachainQuery
15
- * @returns MayachainAMM
14
+ * @param mayachainQuery - An instance of the MayachainQuery
15
+ * @returns MayachainAMM Returns the MayachainAMM
16
16
  */
17
17
  constructor(mayachainQuery?: MayachainQuery, wallet?: Wallet);
18
18
  /**
@@ -22,61 +22,59 @@ export declare class MayachainAMM {
22
22
  */
23
23
  estimateSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }: QuoteSwapParams): Promise<QuoteSwap>;
24
24
  /**
25
- * Validate swap params
26
- * @param {QuoteSwapParams} quoteSwapParams Swap params
27
- * @returns {string[]} the reasons the swap can not be done. If it is empty there are no reason to avoid the swap
25
+ * Validate swap params before performing a swap operation
26
+ * @param {QuoteSwapParams} quoteSwapParams - Swap parameters
27
+ * @returns {string[]} - Reasons the swap cannot be executed. Empty array if the swap is valid.
28
28
  */
29
29
  validateSwap({ fromAsset, fromAddress, destinationAsset, destinationAddress, amount, affiliateAddress, affiliateBps, }: QuoteSwapParams): Promise<string[]>;
30
30
  /**
31
- * Do swap between assets
32
- * @param {QuoteSwapParams} quoteSwapParams Swap params
33
- * @returns {TxSubmitted} the swap transaction hash and url
31
+ * Perform a swap operation between assets
32
+ * @param {QuoteSwapParams} quoteSwapParams Swap parameters
33
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
34
34
  */
35
35
  doSwap({ fromAsset, fromAddress, amount, destinationAsset, destinationAddress, affiliateAddress, affiliateBps, toleranceBps, }: QuoteSwapParams): Promise<TxSubmitted>;
36
36
  /**
37
- * Approve Mayachain router in the chain of the asset to spend the amount in name of the address
38
- * @param {ApproveParams} approveParams contains the asset and amount the router will be allowed. If amount is not defined,
39
- * an infinity approve will be done
37
+ * Approve Mayachain router to spend a certain amount in the chain of the asset
38
+ * @param {ApproveParams} approveParams Parameters for approving the router to spend
40
39
  */
41
40
  approveRouterToSpend({ asset, amount }: ApproveParams): Promise<TxSubmitted>;
42
41
  /**
43
- * Validate if the asset router is allowed to spend the asset amount in name of the address
44
- * @param {IsApprovedParams} isApprovedParams contains the asset and the amount the router is supposed to spend
45
- * int name of address
46
- * @returns {string[]} the reasons the router of the asset is not allowed to spend the amount. If it is empty, the asset router is allowed to spend the amount
42
+ * Validate if the asset router is allowed to spend the asset amount on behalf of the address
43
+ * @param {IsApprovedParams} isApprovedParams Parameters for checking approval
44
+ * @returns {string[]} Reasons the asset router is not allowed to spend the amount. Empty array if the router is approved.
47
45
  */
48
46
  isRouterApprovedToSpend({ asset, amount, address }: IsApprovedParams): Promise<string[]>;
49
47
  /**
50
48
  * Check if a name is a valid MAYAName
51
- * @param {string} name MAYAName
52
- * @returns {boolean} true if is a registered MAYAName, otherwise, false
49
+ * @param {string} name MAYAName to check
50
+ * @returns {boolean} True if the name is registered as a MAYAName, otherwise false
53
51
  */
54
52
  private isMAYAName;
55
53
  /**
56
- * Do swap from native protocol asset to any other asset
54
+ * Perform a swap from a native protocol asset to any other asset
57
55
  * @param {CryptoAmount} amount Amount to swap
58
- * @param {string} memo Memo to add to the transaction to successfully make the swap
59
- * @returns {TxSubmitted} the swap transaction hash and url
56
+ * @param {string} memo Memo to add to the transaction
57
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
60
58
  */
61
59
  private doProtocolAssetSwap;
62
60
  /**
63
- * Do swap between assets
61
+ * Perform a swap between assets
64
62
  * @param {CryptoAmount} amount Amount to swap
65
63
  * @param {string} memo Memo to add to the transaction to successfully make the swap
66
64
  * @param {string} recipient inbound address to make swap transaction to
67
- * @returns {TxSubmitted} the swap transaction hash and url
65
+ * @returns {TxSubmitted} Transaction hash and URL of the swap
68
66
  */
69
67
  private doNonProtocolAssetSwap;
70
68
  /**
71
- * Check if asset is ERC20
72
- * @param {Asset} asset to check
73
- * @returns true if asset is ERC20, otherwise, false
69
+ * Check if the asset is an ERC20 token
70
+ * @param {Asset} asset Asset to check
71
+ * @returns True if the asset is an ERC20 token, otherwise false
74
72
  */
75
73
  private isERC20Asset;
76
74
  /**
77
- * Check if asset chain is EVM
78
- * @param {Chain} chain to check
79
- * @returns true if chain is EVM, otherwise, false
75
+ * Check if the chain is an EVM (Ethereum Virtual Machine) chain
76
+ * @param {Chain} chain Chain to check
77
+ * @returns True if the chain is an EVM chain, otherwise false
80
78
  */
81
79
  private isEVMChain;
82
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-mayachain-amm",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "module that exposes estimating & swapping cryptocurrency assets on mayachain",
5
5
  "keywords": [
6
6
  "MAYAChain",
@@ -37,10 +37,11 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@xchainjs/xchain-ethereum": "0.31.5",
40
- "@xchainjs/xchain-kujira": "0.1.9",
40
+ "@xchainjs/xchain-kujira": "0.1.11",
41
41
  "@xchainjs/xchain-mayachain-query": "0.1.7",
42
- "@xchainjs/xchain-thorchain": "1.0.1",
43
- "@xchainjs/xchain-wallet": "0.1.3"
42
+ "@xchainjs/xchain-mayachain": "1.0.0",
43
+ "@xchainjs/xchain-thorchain": "1.0.3",
44
+ "@xchainjs/xchain-wallet": "0.1.5"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@cosmos-client/core": "0.46.1",
@@ -52,7 +53,6 @@
52
53
  "@xchainjs/xchain-mayanode": "^0.1.3",
53
54
  "@xchainjs/xchain-mayachain-query": "^0.1.7",
54
55
  "@xchainjs/xchain-evm": "^0.4.4",
55
- "@xchainjs/xchain-mayachain": "^0.2.16",
56
56
  "@xchainjs/xchain-mayamidgard": "^0.1.1",
57
57
  "@xchainjs/xchain-util": "^0.13.1",
58
58
  "@xchainjs/xchain-utxo": "^0.1.2",
@@ -77,7 +77,6 @@
77
77
  "@xchainjs/xchain-mayanode": "^0.1.3",
78
78
  "@xchainjs/xchain-mayachain-query": "^0.1.7",
79
79
  "@xchainjs/xchain-evm": "^0.4.4",
80
- "@xchainjs/xchain-mayachain": "^0.2.16",
81
80
  "@xchainjs/xchain-mayamidgard": "^0.1.1",
82
81
  "@xchainjs/xchain-util": "^0.13.1",
83
82
  "@xchainjs/xchain-utxo": "^0.1.2",