hermes-swap 0.0.22 → 0.0.24

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.
@@ -62,7 +62,7 @@ var QuoterAbi = [{
62
62
  type: 'uint256[][]',
63
63
  internalType: 'uint256[][]'
64
64
  }],
65
- stateMutability: 'view'
65
+ stateMutability: 'nonpayable'
66
66
  }, {
67
67
  type: 'function',
68
68
  name: 'contractList',
@@ -128,7 +128,7 @@ var QuoterAbi = [{
128
128
  type: 'bool',
129
129
  internalType: 'bool'
130
130
  }],
131
- stateMutability: 'view'
131
+ stateMutability: 'nonpayable'
132
132
  }, {
133
133
  type: 'function',
134
134
  name: 'isWhitelist',
@@ -181,7 +181,7 @@ var QuoterAbi = [{
181
181
  type: 'uint256[]',
182
182
  internalType: 'uint256[]'
183
183
  }],
184
- stateMutability: 'view'
184
+ stateMutability: 'nonpayable'
185
185
  }, {
186
186
  type: 'function',
187
187
  name: 'owner',
@@ -230,47 +230,42 @@ var QuoterAbi = [{
230
230
  type: 'uint256',
231
231
  internalType: 'uint256'
232
232
  }],
233
- stateMutability: 'view'
233
+ stateMutability: 'nonpayable'
234
234
  }, {
235
235
  type: 'function',
236
236
  name: 'quoteBridge',
237
237
  inputs: [{
238
- name: 'bridgeParams',
238
+ name: 'bridgeParam',
239
239
  type: 'tuple',
240
- internalType: 'struct BridgeParams',
240
+ internalType: 'struct BridgeParam',
241
241
  components: [{
242
242
  name: 'bridge',
243
243
  type: 'string',
244
244
  internalType: 'string'
245
245
  }, {
246
- name: 'bridgeParam',
247
- type: 'tuple',
248
- internalType: 'struct BridgeParam',
249
- components: [{
250
- name: 'token',
251
- type: 'address',
252
- internalType: 'address'
253
- }, {
254
- name: 'amount',
255
- type: 'uint256',
256
- internalType: 'uint256'
257
- }, {
258
- name: 'bridgeAddress',
259
- type: 'address',
260
- internalType: 'address'
261
- }, {
262
- name: 'refundAddress',
263
- type: 'address',
264
- internalType: 'address'
265
- }, {
266
- name: 'destinationChain',
267
- type: 'string',
268
- internalType: 'string'
269
- }, {
270
- name: 'adapterParams',
271
- type: 'bytes',
272
- internalType: 'bytes'
273
- }]
246
+ name: 'token',
247
+ type: 'address',
248
+ internalType: 'address'
249
+ }, {
250
+ name: 'amount',
251
+ type: 'uint256',
252
+ internalType: 'uint256'
253
+ }, {
254
+ name: 'bridgeAddress',
255
+ type: 'address',
256
+ internalType: 'address'
257
+ }, {
258
+ name: 'destChain',
259
+ type: 'string',
260
+ internalType: 'string'
261
+ }, {
262
+ name: 'destUser',
263
+ type: 'address',
264
+ internalType: 'address'
265
+ }, {
266
+ name: 'extra',
267
+ type: 'bytes',
268
+ internalType: 'bytes'
274
269
  }]
275
270
  }],
276
271
  outputs: [{
@@ -278,7 +273,7 @@ var QuoterAbi = [{
278
273
  type: 'uint256',
279
274
  internalType: 'uint256'
280
275
  }],
281
- stateMutability: 'view'
276
+ stateMutability: 'nonpayable'
282
277
  }, {
283
278
  type: 'function',
284
279
  name: 'removeContract',
@@ -377,5 +372,29 @@ var QuoterAbi = [{
377
372
  internalType: 'address'
378
373
  }],
379
374
  anonymous: false
375
+ }, {
376
+ type: 'error',
377
+ name: 'NotExecutor',
378
+ inputs: [{
379
+ name: 'caller',
380
+ type: 'address',
381
+ internalType: 'address'
382
+ }, {
383
+ name: 'executor',
384
+ type: 'address',
385
+ internalType: 'address'
386
+ }]
387
+ }, {
388
+ type: 'error',
389
+ name: 'NotOwner',
390
+ inputs: [{
391
+ name: 'caller',
392
+ type: 'address',
393
+ internalType: 'address'
394
+ }, {
395
+ name: 'owner',
396
+ type: 'address',
397
+ internalType: 'address'
398
+ }]
380
399
  }];
381
400
  export default QuoterAbi;
@@ -12,7 +12,9 @@ declare class Hermes {
12
12
  expect(params: IExpectParams): Promise<bigint>;
13
13
  swap(params: ISwapParams): Promise<IReceipt>;
14
14
  bridge(params: IBridgeParams): Promise<IReceipt>;
15
+ estimateBridgeFee(params: IBridgeParams): Promise<bigint>;
15
16
  swapAndBridge(params: ISwapAndBridgeParams): Promise<IReceipt>;
17
+ private checkIsEnoughToken;
16
18
  private validateParams;
17
19
  private getQuoterAddress;
18
20
  private getAggregatorAddress;
package/dist/esm/index.js CHANGED
@@ -90,11 +90,19 @@ var Hermes = /*#__PURE__*/function () {
90
90
  };
91
91
  });
92
92
  _context.next = 10;
93
- return quoter.multiQuote(params.amountInWei, quoteParams);
93
+ return quoter.multiQuote.staticCall(params.amountInWei, quoteParams, {
94
+ from: wallet.address
95
+ });
94
96
  case 10:
95
97
  amountOutList = _context.sent;
96
- return _context.abrupt("return", amountOutList.length ? amountOutList[amountOutList.length - 1] : BigInt(0));
97
- case 12:
98
+ if (amountOutList.length) {
99
+ _context.next = 13;
100
+ break;
101
+ }
102
+ throw new Error('No expect result return from smart contract');
103
+ case 13:
104
+ return _context.abrupt("return", amountOutList[amountOutList.length - 1]);
105
+ case 14:
98
106
  case "end":
99
107
  return _context.stop();
100
108
  }
@@ -156,93 +164,90 @@ var Hermes = /*#__PURE__*/function () {
156
164
  return erc20.allowance(params.user, aggregatorAddress);
157
165
  case 19:
158
166
  currentAllowance = _context2.sent;
159
- console.log(currentAllowance);
160
167
  if (!(currentAllowance < params.amountInWei)) {
161
- _context2.next = 23;
168
+ _context2.next = 22;
162
169
  break;
163
170
  }
164
171
  throw new Error('Insufficient allowance token amount for swap');
165
- case 23:
166
- _context2.prev = 23;
167
- _context2.next = 26;
172
+ case 22:
173
+ _context2.prev = 22;
174
+ _context2.next = 25;
168
175
  return aggregator.getFunction('swap').estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, {
169
176
  from: wallet.address
170
177
  });
171
- case 26:
178
+ case 25:
172
179
  gas = _context2.sent;
173
- console.log("Estimated gas for swap: ".concat(BigInt(gas).toString()));
174
- _context2.next = 34;
180
+ _context2.next = 32;
175
181
  break;
176
- case 30:
177
- _context2.prev = 30;
178
- _context2.t0 = _context2["catch"](23);
182
+ case 28:
183
+ _context2.prev = 28;
184
+ _context2.t0 = _context2["catch"](22);
179
185
  console.warn('Aggregator estimateGas.swap failed', _context2.t0);
180
186
  throw _context2.t0;
181
- case 34:
182
- _context2.prev = 34;
183
- _context2.next = 37;
187
+ case 32:
188
+ _context2.prev = 32;
189
+ _context2.next = 35;
184
190
  return aggregator.getFunction('swap')(params.user, params.amountInWei, swapParams, params.minAmountOutList, {
185
191
  from: wallet.address
186
192
  });
187
- case 37:
193
+ case 35:
188
194
  txResponse = _context2.sent;
189
- _context2.next = 44;
195
+ _context2.next = 42;
190
196
  break;
191
- case 40:
192
- _context2.prev = 40;
193
- _context2.t1 = _context2["catch"](34);
197
+ case 38:
198
+ _context2.prev = 38;
199
+ _context2.t1 = _context2["catch"](32);
194
200
  console.error('Aggregator swap transaction failed', _context2.t1);
195
201
  throw _context2.t1;
196
- case 44:
197
- _context2.next = 46;
202
+ case 42:
203
+ _context2.next = 44;
198
204
  return txResponse.wait();
199
- case 46:
205
+ case 44:
200
206
  receipt = _context2.sent;
201
- console.log("Swap transaction mined in block ".concat(receipt.blockNumber, " (tx: ").concat(receipt.hash, ")"));
202
207
  iface = new ethers.Interface(AggregatorAbi);
203
208
  amountOut = params.amountInWei;
204
209
  _iterator = _createForOfIteratorHelper(receipt.logs);
205
- _context2.prev = 51;
210
+ _context2.prev = 48;
206
211
  _iterator.s();
207
- case 53:
212
+ case 50:
208
213
  if ((_step = _iterator.n()).done) {
209
- _context2.next = 67;
214
+ _context2.next = 64;
210
215
  break;
211
216
  }
212
217
  log = _step.value;
213
218
  if (!(log.address.toLowerCase() === aggregatorAddress.toLowerCase())) {
214
- _context2.next = 65;
219
+ _context2.next = 62;
215
220
  break;
216
221
  }
217
- _context2.prev = 56;
222
+ _context2.prev = 53;
218
223
  parsed = iface.parseLog(log);
219
224
  if (!(parsed && parsed.name === 'Swapped' && parsed.args && parsed.args.amountOut !== undefined)) {
220
- _context2.next = 61;
225
+ _context2.next = 58;
221
226
  break;
222
227
  }
223
228
  amountOut = parsed.args.amountOut;
224
- return _context2.abrupt("break", 67);
225
- case 61:
226
- _context2.next = 65;
229
+ return _context2.abrupt("break", 64);
230
+ case 58:
231
+ _context2.next = 62;
227
232
  break;
228
- case 63:
229
- _context2.prev = 63;
230
- _context2.t2 = _context2["catch"](56);
231
- case 65:
232
- _context2.next = 53;
233
+ case 60:
234
+ _context2.prev = 60;
235
+ _context2.t2 = _context2["catch"](53);
236
+ case 62:
237
+ _context2.next = 50;
233
238
  break;
234
- case 67:
235
- _context2.next = 72;
239
+ case 64:
240
+ _context2.next = 69;
236
241
  break;
242
+ case 66:
243
+ _context2.prev = 66;
244
+ _context2.t3 = _context2["catch"](48);
245
+ _iterator.e(_context2.t3);
237
246
  case 69:
238
247
  _context2.prev = 69;
239
- _context2.t3 = _context2["catch"](51);
240
- _iterator.e(_context2.t3);
241
- case 72:
242
- _context2.prev = 72;
243
248
  _iterator.f();
244
- return _context2.finish(72);
245
- case 75:
249
+ return _context2.finish(69);
250
+ case 72:
246
251
  return _context2.abrupt("return", {
247
252
  fromToken: fromTokenAddress,
248
253
  toToken: toTokenAddress,
@@ -252,11 +257,11 @@ var Hermes = /*#__PURE__*/function () {
252
257
  to: receipt.from,
253
258
  logs: receipt.logs
254
259
  });
255
- case 76:
260
+ case 73:
256
261
  case "end":
257
262
  return _context2.stop();
258
263
  }
259
- }, _callee2, this, [[23, 30], [34, 40], [51, 69, 72, 75], [56, 63]]);
264
+ }, _callee2, this, [[22, 28], [32, 38], [48, 66, 69, 72], [53, 60]]);
260
265
  }));
261
266
  function swap(_x2) {
262
267
  return _swap.apply(this, arguments);
@@ -267,26 +272,104 @@ var Hermes = /*#__PURE__*/function () {
267
272
  key: "bridge",
268
273
  value: function () {
269
274
  var _bridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
270
- var receipt;
275
+ var _params$extra;
276
+ var aggregatorAddress, wallet, provider, nativeBalance, aggregator, bridgeArgs, txOverrides, txResponse, receipt;
271
277
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
272
278
  while (1) switch (_context3.prev = _context3.next) {
273
279
  case 0:
274
280
  this.validateParams(params);
281
+
282
+ // set up
283
+ aggregatorAddress = this.getAggregatorAddress(params.chain);
284
+ wallet = this.walletMap.get(params.chain);
285
+ if (wallet) {
286
+ _context3.next = 5;
287
+ break;
288
+ }
289
+ throw new Error("Wallet not configured for chain: ".concat(params.chain));
290
+ case 5:
291
+ if (!(params.tokenAddress && params.tokenAddress !== ethers.ZeroAddress)) {
292
+ _context3.next = 8;
293
+ break;
294
+ }
295
+ _context3.next = 8;
296
+ return this.checkIsEnoughToken(params.tokenAddress, params.user, params.amountInWei, aggregatorAddress, wallet);
297
+ case 8:
298
+ if (!(params.bridgeFee > 0n)) {
299
+ _context3.next = 17;
300
+ break;
301
+ }
302
+ provider = this.providerMap.get(params.chain);
303
+ if (provider) {
304
+ _context3.next = 12;
305
+ break;
306
+ }
307
+ throw new Error("Provider not configured for chain: ".concat(params.chain));
308
+ case 12:
309
+ _context3.next = 14;
310
+ return provider.getBalance(params.user);
311
+ case 14:
312
+ nativeBalance = _context3.sent;
313
+ if (!(nativeBalance < params.bridgeFee)) {
314
+ _context3.next = 17;
315
+ break;
316
+ }
317
+ throw new Error('Insufficient native balance for bridge fee');
318
+ case 17:
319
+ aggregator = new Contract(aggregatorAddress, AggregatorAbi, wallet); // simulate
320
+ bridgeArgs = {
321
+ bridge: params.bridgeType,
322
+ token: params.tokenAddress,
323
+ amount: params.amountInWei,
324
+ bridgeAddress: params.bridgeAddress,
325
+ destChain: params.destChain,
326
+ destUser: params.destUser,
327
+ extra: (_params$extra = params.extra) !== null && _params$extra !== void 0 ? _params$extra : '0x'
328
+ };
329
+ txOverrides = {
330
+ from: wallet.address,
331
+ value: params.bridgeFee
332
+ }; // simulate
333
+ _context3.prev = 20;
334
+ _context3.next = 23;
335
+ return aggregator.bridge.estimateGas(params.user, bridgeArgs, txOverrides);
336
+ case 23:
337
+ _context3.next = 29;
338
+ break;
339
+ case 25:
340
+ _context3.prev = 25;
341
+ _context3.t0 = _context3["catch"](20);
342
+ console.error('Bridge gas estimation reverted', _context3.t0);
343
+ throw _context3.t0;
344
+ case 29:
345
+ _context3.prev = 29;
346
+ _context3.next = 32;
347
+ return aggregator.bridge(params.user, bridgeArgs, txOverrides);
348
+ case 32:
349
+ txResponse = _context3.sent;
350
+ _context3.next = 39;
351
+ break;
352
+ case 35:
353
+ _context3.prev = 35;
354
+ _context3.t1 = _context3["catch"](29);
355
+ console.error('Aggregator swap transaction failed', _context3.t1);
356
+ throw _context3.t1;
357
+ case 39:
275
358
  receipt = {
276
359
  fromToken: params.tokenAddress,
277
360
  toToken: params.tokenAddress,
278
361
  amountOut: params.amountInWei,
279
- hash: '',
280
- from: '',
281
- to: '',
282
- logs: []
362
+ hash: txResponse.hash,
363
+ from: txResponse.from,
364
+ to: txResponse.to,
365
+ logs: txResponse.logs
283
366
  };
284
367
  return _context3.abrupt("return", Promise.resolve(receipt));
285
- case 3:
368
+ case 41:
286
369
  case "end":
287
370
  return _context3.stop();
288
371
  }
289
- }, _callee3, this);
372
+ }, _callee3, this, [[20, 25], [29, 35]]);
290
373
  }));
291
374
  function bridge(_x3) {
292
375
  return _bridge.apply(this, arguments);
@@ -294,35 +377,196 @@ var Hermes = /*#__PURE__*/function () {
294
377
  return bridge;
295
378
  }()
296
379
  }, {
297
- key: "swapAndBridge",
380
+ key: "estimateBridgeFee",
298
381
  value: function () {
299
- var _swapAndBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
300
- var receipt;
382
+ var _estimateBridgeFee = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
383
+ var _params$extra2;
384
+ var wallet, address, quoter, bridgeArgs, bridgeFee;
301
385
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
302
386
  while (1) switch (_context4.prev = _context4.next) {
303
387
  case 0:
304
388
  this.validateParams(params);
389
+ wallet = this.walletMap.get(params.chain);
390
+ if (wallet) {
391
+ _context4.next = 4;
392
+ break;
393
+ }
394
+ throw new Error("Wallet not configured for chain: ".concat(params.chain));
395
+ case 4:
396
+ address = this.getQuoterAddress(params.chain);
397
+ if (address) {
398
+ _context4.next = 7;
399
+ break;
400
+ }
401
+ throw new Error("Quoter address not found for chain: ".concat(params.chain));
402
+ case 7:
403
+ quoter = new Contract(address, QuoterAbi, wallet);
404
+ bridgeArgs = {
405
+ bridge: params.bridgeType,
406
+ token: params.tokenAddress,
407
+ amount: params.amountInWei,
408
+ bridgeAddress: params.bridgeAddress,
409
+ destChain: params.destChain,
410
+ destUser: params.destUser,
411
+ extra: (_params$extra2 = params.extra) !== null && _params$extra2 !== void 0 ? _params$extra2 : '0x'
412
+ };
413
+ _context4.next = 11;
414
+ return quoter.quoteBridge.staticCall(bridgeArgs, {
415
+ from: wallet.address
416
+ });
417
+ case 11:
418
+ bridgeFee = _context4.sent;
419
+ return _context4.abrupt("return", bridgeFee);
420
+ case 13:
421
+ case "end":
422
+ return _context4.stop();
423
+ }
424
+ }, _callee4, this);
425
+ }));
426
+ function estimateBridgeFee(_x4) {
427
+ return _estimateBridgeFee.apply(this, arguments);
428
+ }
429
+ return estimateBridgeFee;
430
+ }()
431
+ }, {
432
+ key: "swapAndBridge",
433
+ value: function () {
434
+ var _swapAndBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
435
+ var _params$extra3;
436
+ var aggregatorAddress, wallet, fromCoinAddress, swapParams, bridgeArgs, txOverrides, aggregator, txResponse, receipt;
437
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
438
+ while (1) switch (_context5.prev = _context5.next) {
439
+ case 0:
440
+ this.validateParams(params);
441
+
442
+ // call the aggregator swap and bridge
443
+ aggregatorAddress = this.getAggregatorAddress(params.chain);
444
+ wallet = this.walletMap.get(params.chain);
445
+ if (wallet) {
446
+ _context5.next = 5;
447
+ break;
448
+ }
449
+ throw new Error("Wallet not configured for chain: ".concat(params.chain));
450
+ case 5:
451
+ fromCoinAddress = params.path[0].fromCoinAddress;
452
+ if (!(fromCoinAddress && fromCoinAddress !== ethers.ZeroAddress)) {
453
+ _context5.next = 9;
454
+ break;
455
+ }
456
+ _context5.next = 9;
457
+ return this.checkIsEnoughToken(fromCoinAddress, params.user, params.amountInWei, aggregatorAddress, wallet);
458
+ case 9:
459
+ // 准备合约参数
460
+ swapParams = params.path.map(function (pathItem) {
461
+ var _pathItem$extra2;
462
+ return {
463
+ dexType: pathItem.dexType,
464
+ pool: pathItem.poolAddress,
465
+ fromCoin: pathItem.fromCoinAddress,
466
+ toCoin: pathItem.toCoinAddress,
467
+ extra: (_pathItem$extra2 = pathItem.extra) !== null && _pathItem$extra2 !== void 0 ? _pathItem$extra2 : '0x'
468
+ };
469
+ });
470
+ bridgeArgs = {
471
+ bridge: params.bridgeType,
472
+ token: params.tokenAddress,
473
+ amount: params.amountInWei,
474
+ bridgeAddress: params.bridgeAddress,
475
+ destChain: params.destChain,
476
+ destUser: params.destUser,
477
+ extra: (_params$extra3 = params.extra) !== null && _params$extra3 !== void 0 ? _params$extra3 : '0x'
478
+ };
479
+ txOverrides = {
480
+ from: wallet.address,
481
+ value: params.bridgeFee
482
+ }; // simulate
483
+ aggregator = new Contract(aggregatorAddress, AggregatorAbi, wallet);
484
+ _context5.prev = 13;
485
+ _context5.next = 16;
486
+ return aggregator.swapAndBridge.estimateGas(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
487
+ case 16:
488
+ _context5.next = 22;
489
+ break;
490
+ case 18:
491
+ _context5.prev = 18;
492
+ _context5.t0 = _context5["catch"](13);
493
+ console.error('Bridge gas estimation reverted', _context5.t0);
494
+ throw _context5.t0;
495
+ case 22:
496
+ _context5.prev = 22;
497
+ _context5.next = 25;
498
+ return aggregator.swapAndBridge(params.user, params.amountInWei, swapParams, params.minAmountOutList, bridgeArgs, txOverrides);
499
+ case 25:
500
+ txResponse = _context5.sent;
501
+ _context5.next = 32;
502
+ break;
503
+ case 28:
504
+ _context5.prev = 28;
505
+ _context5.t1 = _context5["catch"](22);
506
+ console.error('Aggregator swap and bridge transaction failed', _context5.t1);
507
+ throw _context5.t1;
508
+ case 32:
305
509
  receipt = {
306
510
  fromToken: params.path[0].fromCoinAddress,
307
511
  toToken: params.path[params.path.length - 1].toCoinAddress,
308
512
  amountOut: params.minAmountOutList[params.minAmountOutList.length - 1],
309
- hash: '',
310
- from: '',
311
- to: '',
312
- logs: []
513
+ hash: txResponse.hash,
514
+ from: txResponse.from,
515
+ to: txResponse.to,
516
+ logs: txResponse.logs
313
517
  };
314
- return _context4.abrupt("return", Promise.resolve(receipt));
315
- case 3:
518
+ return _context5.abrupt("return", Promise.resolve(receipt));
519
+ case 34:
316
520
  case "end":
317
- return _context4.stop();
521
+ return _context5.stop();
318
522
  }
319
- }, _callee4, this);
523
+ }, _callee5, this, [[13, 18], [22, 28]]);
320
524
  }));
321
- function swapAndBridge(_x4) {
525
+ function swapAndBridge(_x5) {
322
526
  return _swapAndBridge.apply(this, arguments);
323
527
  }
324
528
  return swapAndBridge;
325
529
  }()
530
+ }, {
531
+ key: "checkIsEnoughToken",
532
+ value: function () {
533
+ var _checkIsEnoughToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(fromTokenAddress, userAddress, amountInWei, aggregatorAddress, wallet) {
534
+ var erc20, userBalance, currentAllowance;
535
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
536
+ while (1) switch (_context6.prev = _context6.next) {
537
+ case 0:
538
+ erc20 = new Contract(fromTokenAddress, ['function balanceOf(address) view returns (uint256)', 'function allowance(address, address) view returns (uint256)'], wallet);
539
+ _context6.next = 3;
540
+ return erc20.balanceOf(userAddress);
541
+ case 3:
542
+ userBalance = _context6.sent;
543
+ if (!(userBalance < amountInWei)) {
544
+ _context6.next = 6;
545
+ break;
546
+ }
547
+ throw new Error('Insufficient balance token amount');
548
+ case 6:
549
+ _context6.next = 8;
550
+ return erc20.allowance(userAddress, aggregatorAddress);
551
+ case 8:
552
+ currentAllowance = _context6.sent;
553
+ console.log(currentAllowance);
554
+ if (!(currentAllowance < amountInWei)) {
555
+ _context6.next = 12;
556
+ break;
557
+ }
558
+ throw new Error('Insufficient allowance token amount');
559
+ case 12:
560
+ case "end":
561
+ return _context6.stop();
562
+ }
563
+ }, _callee6);
564
+ }));
565
+ function checkIsEnoughToken(_x6, _x7, _x8, _x9, _x10) {
566
+ return _checkIsEnoughToken.apply(this, arguments);
567
+ }
568
+ return checkIsEnoughToken;
569
+ }()
326
570
  }, {
327
571
  key: "validateParams",
328
572
  value: function validateParams(params) {