@uniswap/router-sdk 2.0.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/router-sdk.cjs.development.js +241 -452
- package/dist/router-sdk.cjs.development.js.map +1 -1
- package/dist/router-sdk.cjs.production.min.js +1 -1
- package/dist/router-sdk.cjs.production.min.js.map +1 -1
- package/dist/router-sdk.esm.js +241 -452
- package/dist/router-sdk.esm.js.map +1 -1
- package/package.json +8 -6
package/dist/router-sdk.esm.js
CHANGED
|
@@ -273,306 +273,113 @@ function _extends() {
|
|
|
273
273
|
function _inheritsLoose(t, o) {
|
|
274
274
|
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return o(a, "_invoke", {
|
|
311
|
-
value: makeInvokeMethod(t, r, c)
|
|
312
|
-
}), a;
|
|
313
|
-
}
|
|
314
|
-
function tryCatch(t, e, r) {
|
|
315
|
-
try {
|
|
316
|
-
return {
|
|
317
|
-
type: "normal",
|
|
318
|
-
arg: t.call(e, r)
|
|
319
|
-
};
|
|
320
|
-
} catch (t) {
|
|
321
|
-
return {
|
|
322
|
-
type: "throw",
|
|
323
|
-
arg: t
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
e.wrap = wrap;
|
|
328
|
-
var h = "suspendedStart",
|
|
329
|
-
l = "suspendedYield",
|
|
330
|
-
f = "executing",
|
|
331
|
-
s = "completed",
|
|
332
|
-
y = {};
|
|
333
|
-
function Generator() {}
|
|
334
|
-
function GeneratorFunction() {}
|
|
335
|
-
function GeneratorFunctionPrototype() {}
|
|
336
|
-
var p = {};
|
|
337
|
-
define(p, a, function () {
|
|
338
|
-
return this;
|
|
339
|
-
});
|
|
340
|
-
var d = Object.getPrototypeOf,
|
|
341
|
-
v = d && d(d(values([])));
|
|
342
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
343
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
344
|
-
function defineIteratorMethods(t) {
|
|
345
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
346
|
-
define(t, e, function (t) {
|
|
347
|
-
return this._invoke(e, t);
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
function AsyncIterator(t, e) {
|
|
352
|
-
function invoke(r, o, i, a) {
|
|
353
|
-
var c = tryCatch(t[r], t, o);
|
|
354
|
-
if ("throw" !== c.type) {
|
|
355
|
-
var u = c.arg,
|
|
356
|
-
h = u.value;
|
|
357
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
358
|
-
invoke("next", t, i, a);
|
|
359
|
-
}, function (t) {
|
|
360
|
-
invoke("throw", t, i, a);
|
|
361
|
-
}) : e.resolve(h).then(function (t) {
|
|
362
|
-
u.value = t, i(u);
|
|
363
|
-
}, function (t) {
|
|
364
|
-
return invoke("throw", t, i, a);
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
a(c.arg);
|
|
368
|
-
}
|
|
369
|
-
var r;
|
|
370
|
-
o(this, "_invoke", {
|
|
371
|
-
value: function (t, n) {
|
|
372
|
-
function callInvokeWithMethodAndArg() {
|
|
373
|
-
return new e(function (e, r) {
|
|
374
|
-
invoke(t, n, e, r);
|
|
375
|
-
});
|
|
276
|
+
function _regenerator() {
|
|
277
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
278
|
+
var e,
|
|
279
|
+
t,
|
|
280
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
281
|
+
n = r.iterator || "@@iterator",
|
|
282
|
+
o = r.toStringTag || "@@toStringTag";
|
|
283
|
+
function i(r, n, o, i) {
|
|
284
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
285
|
+
u = Object.create(c.prototype);
|
|
286
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
287
|
+
var i,
|
|
288
|
+
c,
|
|
289
|
+
u,
|
|
290
|
+
f = 0,
|
|
291
|
+
p = o || [],
|
|
292
|
+
y = !1,
|
|
293
|
+
G = {
|
|
294
|
+
p: 0,
|
|
295
|
+
n: 0,
|
|
296
|
+
v: e,
|
|
297
|
+
a: d,
|
|
298
|
+
f: d.bind(e, 4),
|
|
299
|
+
d: function (t, r) {
|
|
300
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
function d(r, n) {
|
|
304
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
305
|
+
var o,
|
|
306
|
+
i = p[t],
|
|
307
|
+
d = G.p,
|
|
308
|
+
l = i[2];
|
|
309
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
376
310
|
}
|
|
377
|
-
|
|
311
|
+
if (o || r > 1) return a;
|
|
312
|
+
throw y = !0, n;
|
|
378
313
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
314
|
+
return function (o, p, l) {
|
|
315
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
316
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
317
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
318
|
+
try {
|
|
319
|
+
if (f = 2, i) {
|
|
320
|
+
if (c || (o = "next"), t = i[o]) {
|
|
321
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
322
|
+
if (!t.done) return t;
|
|
323
|
+
u = t.value, c < 2 && (c = 0);
|
|
324
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
325
|
+
i = e;
|
|
326
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
327
|
+
} catch (t) {
|
|
328
|
+
i = e, c = 1, u = t;
|
|
329
|
+
} finally {
|
|
330
|
+
f = 1;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
387
333
|
return {
|
|
388
334
|
value: t,
|
|
389
|
-
done:
|
|
335
|
+
done: y
|
|
390
336
|
};
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var c = n.delegate;
|
|
394
|
-
if (c) {
|
|
395
|
-
var u = maybeInvokeDelegate(c, n);
|
|
396
|
-
if (u) {
|
|
397
|
-
if (u === y) continue;
|
|
398
|
-
return u;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
402
|
-
if (o === h) throw o = s, n.arg;
|
|
403
|
-
n.dispatchException(n.arg);
|
|
404
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
405
|
-
o = f;
|
|
406
|
-
var p = tryCatch(e, r, n);
|
|
407
|
-
if ("normal" === p.type) {
|
|
408
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
409
|
-
return {
|
|
410
|
-
value: p.arg,
|
|
411
|
-
done: n.done
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
function maybeInvokeDelegate(e, r) {
|
|
419
|
-
var n = r.method,
|
|
420
|
-
o = e.iterator[n];
|
|
421
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
422
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
423
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
424
|
-
var a = i.arg;
|
|
425
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
426
|
-
}
|
|
427
|
-
function pushTryEntry(t) {
|
|
428
|
-
var e = {
|
|
429
|
-
tryLoc: t[0]
|
|
430
|
-
};
|
|
431
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
432
|
-
}
|
|
433
|
-
function resetTryEntry(t) {
|
|
434
|
-
var e = t.completion || {};
|
|
435
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
436
|
-
}
|
|
437
|
-
function Context(t) {
|
|
438
|
-
this.tryEntries = [{
|
|
439
|
-
tryLoc: "root"
|
|
440
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
337
|
+
};
|
|
338
|
+
}(r, o, i), !0), u;
|
|
441
339
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
return i.next = i;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
340
|
+
var a = {};
|
|
341
|
+
function Generator() {}
|
|
342
|
+
function GeneratorFunction() {}
|
|
343
|
+
function GeneratorFunctionPrototype() {}
|
|
344
|
+
t = Object.getPrototypeOf;
|
|
345
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
346
|
+
return this;
|
|
347
|
+
}), t),
|
|
348
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
349
|
+
function f(e) {
|
|
350
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
457
351
|
}
|
|
458
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
459
|
-
value: GeneratorFunctionPrototype,
|
|
460
|
-
configurable: !0
|
|
461
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
462
|
-
value: GeneratorFunction,
|
|
463
|
-
configurable: !0
|
|
464
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
465
|
-
var e = "function" == typeof t && t.constructor;
|
|
466
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
467
|
-
}, e.mark = function (t) {
|
|
468
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
469
|
-
}, e.awrap = function (t) {
|
|
470
|
-
return {
|
|
471
|
-
__await: t
|
|
472
|
-
};
|
|
473
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
352
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
474
353
|
return this;
|
|
475
|
-
}),
|
|
476
|
-
void 0 === i && (i = Promise);
|
|
477
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
478
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
479
|
-
return t.done ? t.value : a.next();
|
|
480
|
-
});
|
|
481
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
482
|
-
return this;
|
|
483
|
-
}), define(g, "toString", function () {
|
|
354
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
484
355
|
return "[object Generator]";
|
|
485
|
-
}),
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
return r.reverse(), function next() {
|
|
490
|
-
for (; r.length;) {
|
|
491
|
-
var t = r.pop();
|
|
492
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
493
|
-
}
|
|
494
|
-
return next.done = !0, next;
|
|
356
|
+
}), (_regenerator = function () {
|
|
357
|
+
return {
|
|
358
|
+
w: i,
|
|
359
|
+
m: f
|
|
495
360
|
};
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
var c = n.call(i, "catchLoc"),
|
|
519
|
-
u = n.call(i, "finallyLoc");
|
|
520
|
-
if (c && u) {
|
|
521
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
522
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
523
|
-
} else if (c) {
|
|
524
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
525
|
-
} else {
|
|
526
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
527
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
},
|
|
532
|
-
abrupt: function (t, e) {
|
|
533
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
534
|
-
var o = this.tryEntries[r];
|
|
535
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
536
|
-
var i = o;
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
541
|
-
var a = i ? i.completion : {};
|
|
542
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
543
|
-
},
|
|
544
|
-
complete: function (t, e) {
|
|
545
|
-
if ("throw" === t.type) throw t.arg;
|
|
546
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
547
|
-
},
|
|
548
|
-
finish: function (t) {
|
|
549
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
550
|
-
var r = this.tryEntries[e];
|
|
551
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
catch: function (t) {
|
|
555
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
556
|
-
var r = this.tryEntries[e];
|
|
557
|
-
if (r.tryLoc === t) {
|
|
558
|
-
var n = r.completion;
|
|
559
|
-
if ("throw" === n.type) {
|
|
560
|
-
var o = n.arg;
|
|
561
|
-
resetTryEntry(r);
|
|
562
|
-
}
|
|
563
|
-
return o;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
throw Error("illegal catch attempt");
|
|
567
|
-
},
|
|
568
|
-
delegateYield: function (e, r, n) {
|
|
569
|
-
return this.delegate = {
|
|
570
|
-
iterator: values(e),
|
|
571
|
-
resultName: r,
|
|
572
|
-
nextLoc: n
|
|
573
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
574
|
-
}
|
|
575
|
-
}, e;
|
|
361
|
+
})();
|
|
362
|
+
}
|
|
363
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
364
|
+
var i = Object.defineProperty;
|
|
365
|
+
try {
|
|
366
|
+
i({}, "", {});
|
|
367
|
+
} catch (e) {
|
|
368
|
+
i = 0;
|
|
369
|
+
}
|
|
370
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
371
|
+
function o(r, n) {
|
|
372
|
+
_regeneratorDefine(e, r, function (e) {
|
|
373
|
+
return this._invoke(r, n, e);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
r ? i ? i(e, r, {
|
|
377
|
+
value: n,
|
|
378
|
+
enumerable: !t,
|
|
379
|
+
configurable: !t,
|
|
380
|
+
writable: !t
|
|
381
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
382
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
576
383
|
}
|
|
577
384
|
function _setPrototypeOf(t, e) {
|
|
578
385
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
@@ -857,36 +664,36 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
857
664
|
MixedRouteTrade.fromRoute =
|
|
858
665
|
/*#__PURE__*/
|
|
859
666
|
function () {
|
|
860
|
-
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
667
|
+
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(route, amount, tradeType) {
|
|
861
668
|
var amounts, inputAmount, outputAmount, i, pool, _yield$pool$getOutput, _outputAmount;
|
|
862
|
-
return
|
|
863
|
-
while (1) switch (_context.
|
|
669
|
+
return _regenerator().w(function (_context) {
|
|
670
|
+
while (1) switch (_context.n) {
|
|
864
671
|
case 0:
|
|
865
672
|
amounts = new Array(route.path.length);
|
|
866
673
|
!(tradeType === TradeType.EXACT_INPUT) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TRADE_TYPE') : invariant(false) : void 0;
|
|
867
674
|
!amount.currency.equals(route.input) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0;
|
|
868
675
|
amounts[0] = amountWithPathCurrency(amount, route.pools[0]);
|
|
869
676
|
i = 0;
|
|
870
|
-
case
|
|
677
|
+
case 1:
|
|
871
678
|
if (!(i < route.path.length - 1)) {
|
|
872
|
-
_context.
|
|
679
|
+
_context.n = 4;
|
|
873
680
|
break;
|
|
874
681
|
}
|
|
875
682
|
pool = route.pools[i];
|
|
876
|
-
_context.
|
|
683
|
+
_context.n = 2;
|
|
877
684
|
return pool.getOutputAmount(amountWithPathCurrency(amounts[i], pool));
|
|
878
|
-
case
|
|
879
|
-
_yield$pool$getOutput = _context.
|
|
685
|
+
case 2:
|
|
686
|
+
_yield$pool$getOutput = _context.v;
|
|
880
687
|
_outputAmount = _yield$pool$getOutput[0];
|
|
881
688
|
amounts[i + 1] = _outputAmount;
|
|
882
|
-
case
|
|
689
|
+
case 3:
|
|
883
690
|
i++;
|
|
884
|
-
_context.
|
|
691
|
+
_context.n = 1;
|
|
885
692
|
break;
|
|
886
|
-
case
|
|
693
|
+
case 4:
|
|
887
694
|
inputAmount = CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
|
|
888
695
|
outputAmount = CurrencyAmount.fromFractionalAmount(route.output, amounts[amounts.length - 1].numerator, amounts[amounts.length - 1].denominator);
|
|
889
|
-
return _context.
|
|
696
|
+
return _context.a(2, new MixedRouteTrade({
|
|
890
697
|
routes: [{
|
|
891
698
|
inputAmount: inputAmount,
|
|
892
699
|
outputAmount: outputAmount,
|
|
@@ -894,9 +701,6 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
894
701
|
}],
|
|
895
702
|
tradeType: tradeType
|
|
896
703
|
}));
|
|
897
|
-
case 18:
|
|
898
|
-
case "end":
|
|
899
|
-
return _context.stop();
|
|
900
704
|
}
|
|
901
705
|
}, _callee);
|
|
902
706
|
}));
|
|
@@ -919,17 +723,17 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
919
723
|
MixedRouteTrade.fromRoutes =
|
|
920
724
|
/*#__PURE__*/
|
|
921
725
|
function () {
|
|
922
|
-
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
726
|
+
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(routes, tradeType) {
|
|
923
727
|
var populatedRoutes, _iterator3, _step3, _step3$value, route, amount, amounts, inputAmount, outputAmount, i, pool, _yield$pool$getOutput2, _outputAmount2;
|
|
924
|
-
return
|
|
925
|
-
while (1) switch (_context2.
|
|
728
|
+
return _regenerator().w(function (_context2) {
|
|
729
|
+
while (1) switch (_context2.n) {
|
|
926
730
|
case 0:
|
|
927
731
|
populatedRoutes = [];
|
|
928
732
|
!(tradeType === TradeType.EXACT_INPUT) ? process.env.NODE_ENV !== "production" ? invariant(false, 'TRADE_TYPE') : invariant(false) : void 0;
|
|
929
733
|
_iterator3 = _createForOfIteratorHelperLoose(routes);
|
|
930
|
-
case
|
|
734
|
+
case 1:
|
|
931
735
|
if ((_step3 = _iterator3()).done) {
|
|
932
|
-
_context2.
|
|
736
|
+
_context2.n = 7;
|
|
933
737
|
break;
|
|
934
738
|
}
|
|
935
739
|
_step3$value = _step3.value, route = _step3$value.route, amount = _step3$value.amount;
|
|
@@ -940,40 +744,37 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
940
744
|
inputAmount = CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
|
|
941
745
|
amounts[0] = CurrencyAmount.fromFractionalAmount(route.pathInput, amount.numerator, amount.denominator);
|
|
942
746
|
i = 0;
|
|
943
|
-
case
|
|
747
|
+
case 2:
|
|
944
748
|
if (!(i < route.path.length - 1)) {
|
|
945
|
-
_context2.
|
|
749
|
+
_context2.n = 5;
|
|
946
750
|
break;
|
|
947
751
|
}
|
|
948
752
|
pool = route.pools[i];
|
|
949
|
-
_context2.
|
|
753
|
+
_context2.n = 3;
|
|
950
754
|
return pool.getOutputAmount(amountWithPathCurrency(amounts[i], pool));
|
|
951
|
-
case
|
|
952
|
-
_yield$pool$getOutput2 = _context2.
|
|
755
|
+
case 3:
|
|
756
|
+
_yield$pool$getOutput2 = _context2.v;
|
|
953
757
|
_outputAmount2 = _yield$pool$getOutput2[0];
|
|
954
758
|
amounts[i + 1] = _outputAmount2;
|
|
955
|
-
case
|
|
759
|
+
case 4:
|
|
956
760
|
i++;
|
|
957
|
-
_context2.
|
|
761
|
+
_context2.n = 2;
|
|
958
762
|
break;
|
|
959
|
-
case
|
|
763
|
+
case 5:
|
|
960
764
|
outputAmount = CurrencyAmount.fromFractionalAmount(route.output, amounts[amounts.length - 1].numerator, amounts[amounts.length - 1].denominator);
|
|
961
765
|
populatedRoutes.push({
|
|
962
766
|
route: route,
|
|
963
767
|
inputAmount: inputAmount,
|
|
964
768
|
outputAmount: outputAmount
|
|
965
769
|
});
|
|
966
|
-
case
|
|
967
|
-
_context2.
|
|
770
|
+
case 6:
|
|
771
|
+
_context2.n = 1;
|
|
968
772
|
break;
|
|
969
|
-
case
|
|
970
|
-
return _context2.
|
|
773
|
+
case 7:
|
|
774
|
+
return _context2.a(2, new MixedRouteTrade({
|
|
971
775
|
routes: populatedRoutes,
|
|
972
776
|
tradeType: tradeType
|
|
973
777
|
}));
|
|
974
|
-
case 27:
|
|
975
|
-
case "end":
|
|
976
|
-
return _context2.stop();
|
|
977
778
|
}
|
|
978
779
|
}, _callee2);
|
|
979
780
|
}));
|
|
@@ -1067,12 +868,12 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
1067
868
|
MixedRouteTrade.bestTradeExactIn =
|
|
1068
869
|
/*#__PURE__*/
|
|
1069
870
|
function () {
|
|
1070
|
-
var _bestTradeExactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
871
|
+
var _bestTradeExactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(pools, currencyAmountIn, currencyOut, _temp,
|
|
1071
872
|
// used in recursion.
|
|
1072
873
|
currentPools, nextAmountIn, bestTrades) {
|
|
1073
|
-
var _ref5, _ref5$maxNumResults, maxNumResults, _ref5$maxHops, maxHops, amountIn, i, pool, amountInAdjusted, amountOut, _ref6, poolsExcludingThisPool;
|
|
1074
|
-
return
|
|
1075
|
-
while (1) switch (_context3.
|
|
874
|
+
var _ref5, _ref5$maxNumResults, maxNumResults, _ref5$maxHops, maxHops, amountIn, i, pool, amountInAdjusted, amountOut, _ref6, poolsExcludingThisPool, _t, _t2, _t3, _t4;
|
|
875
|
+
return _regenerator().w(function (_context3) {
|
|
876
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
1076
877
|
case 0:
|
|
1077
878
|
_ref5 = _temp === void 0 ? {} : _temp, _ref5$maxNumResults = _ref5.maxNumResults, maxNumResults = _ref5$maxNumResults === void 0 ? 3 : _ref5$maxNumResults, _ref5$maxHops = _ref5.maxHops, maxHops = _ref5$maxHops === void 0 ? 3 : _ref5$maxHops;
|
|
1078
879
|
if (currentPools === void 0) {
|
|
@@ -1089,101 +890,95 @@ var MixedRouteTrade = /*#__PURE__*/function () {
|
|
|
1089
890
|
!(currencyAmountIn === nextAmountIn || currentPools.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INVALID_RECURSION') : invariant(false) : void 0;
|
|
1090
891
|
amountIn = nextAmountIn;
|
|
1091
892
|
i = 0;
|
|
1092
|
-
case
|
|
893
|
+
case 1:
|
|
1093
894
|
if (!(i < pools.length)) {
|
|
1094
|
-
_context3.
|
|
895
|
+
_context3.n = 15;
|
|
1095
896
|
break;
|
|
1096
897
|
}
|
|
1097
898
|
pool = pools[i];
|
|
1098
899
|
amountInAdjusted = pool instanceof Pool ? amountIn : amountIn.wrapped; // pool irrelevant
|
|
1099
900
|
if (!(!pool.token0.equals(amountInAdjusted.currency) && !pool.token1.equals(amountInAdjusted.currency))) {
|
|
1100
|
-
_context3.
|
|
901
|
+
_context3.n = 2;
|
|
1101
902
|
break;
|
|
1102
903
|
}
|
|
1103
|
-
return _context3.
|
|
1104
|
-
case
|
|
904
|
+
return _context3.a(3, 14);
|
|
905
|
+
case 2:
|
|
1105
906
|
if (!(pool instanceof Pair)) {
|
|
1106
|
-
_context3.
|
|
907
|
+
_context3.n = 3;
|
|
1107
908
|
break;
|
|
1108
909
|
}
|
|
1109
910
|
if (!(pool.reserve0.equalTo(ZERO) || pool.reserve1.equalTo(ZERO))) {
|
|
1110
|
-
_context3.
|
|
911
|
+
_context3.n = 3;
|
|
1111
912
|
break;
|
|
1112
913
|
}
|
|
1113
|
-
return _context3.
|
|
1114
|
-
case
|
|
914
|
+
return _context3.a(3, 14);
|
|
915
|
+
case 3:
|
|
1115
916
|
amountOut = void 0;
|
|
1116
|
-
_context3.
|
|
917
|
+
_context3.p = 4;
|
|
1117
918
|
if (!(pool instanceof Pool)) {
|
|
1118
|
-
_context3.
|
|
919
|
+
_context3.n = 6;
|
|
1119
920
|
break;
|
|
1120
921
|
}
|
|
1121
|
-
_context3.
|
|
922
|
+
_context3.n = 5;
|
|
1122
923
|
return pool.getOutputAmount(amountInAdjusted);
|
|
1123
|
-
case
|
|
1124
|
-
|
|
1125
|
-
_context3.
|
|
924
|
+
case 5:
|
|
925
|
+
_t = _context3.v;
|
|
926
|
+
_context3.n = 8;
|
|
1126
927
|
break;
|
|
1127
|
-
case
|
|
1128
|
-
_context3.
|
|
928
|
+
case 6:
|
|
929
|
+
_context3.n = 7;
|
|
1129
930
|
return pool.getOutputAmount(amountInAdjusted.wrapped);
|
|
1130
|
-
case
|
|
1131
|
-
|
|
1132
|
-
case
|
|
1133
|
-
_ref6 =
|
|
931
|
+
case 7:
|
|
932
|
+
_t = _context3.v;
|
|
933
|
+
case 8:
|
|
934
|
+
_ref6 = _t;
|
|
1134
935
|
amountOut = _ref6[0];
|
|
1135
|
-
_context3.
|
|
936
|
+
_context3.n = 11;
|
|
1136
937
|
break;
|
|
1137
|
-
case
|
|
1138
|
-
_context3.
|
|
1139
|
-
|
|
1140
|
-
if (!
|
|
1141
|
-
_context3.
|
|
938
|
+
case 9:
|
|
939
|
+
_context3.p = 9;
|
|
940
|
+
_t2 = _context3.v;
|
|
941
|
+
if (!_t2.isInsufficientInputAmountError) {
|
|
942
|
+
_context3.n = 10;
|
|
1142
943
|
break;
|
|
1143
944
|
}
|
|
1144
|
-
return _context3.
|
|
1145
|
-
case
|
|
1146
|
-
throw
|
|
1147
|
-
case
|
|
945
|
+
return _context3.a(3, 14);
|
|
946
|
+
case 10:
|
|
947
|
+
throw _t2;
|
|
948
|
+
case 11:
|
|
1148
949
|
if (!amountOut.currency.wrapped.equals(currencyOut.wrapped)) {
|
|
1149
|
-
_context3.
|
|
950
|
+
_context3.n = 13;
|
|
1150
951
|
break;
|
|
1151
952
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
_context3.
|
|
953
|
+
_t3 = sortedInsert;
|
|
954
|
+
_t4 = bestTrades;
|
|
955
|
+
_context3.n = 12;
|
|
1155
956
|
return MixedRouteTrade.fromRoute(new MixedRouteSDK([].concat(currentPools, [pool]), currencyAmountIn.currency, currencyOut), currencyAmountIn, TradeType.EXACT_INPUT);
|
|
1156
|
-
case
|
|
1157
|
-
_context3.
|
|
1158
|
-
_context3.
|
|
1159
|
-
_context3.t6 = tradeComparator;
|
|
1160
|
-
(0, _context3.t2)(_context3.t3, _context3.t4, _context3.t5, _context3.t6);
|
|
1161
|
-
_context3.next = 53;
|
|
957
|
+
case 12:
|
|
958
|
+
_t3(_t4, _context3.v, maxNumResults, tradeComparator);
|
|
959
|
+
_context3.n = 14;
|
|
1162
960
|
break;
|
|
1163
|
-
case
|
|
961
|
+
case 13:
|
|
1164
962
|
if (!(maxHops > 1 && pools.length > 1)) {
|
|
1165
|
-
_context3.
|
|
963
|
+
_context3.n = 14;
|
|
1166
964
|
break;
|
|
1167
965
|
}
|
|
1168
966
|
poolsExcludingThisPool = pools.slice(0, i).concat(pools.slice(i + 1, pools.length)); // otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops
|
|
1169
|
-
_context3.
|
|
967
|
+
_context3.n = 14;
|
|
1170
968
|
return MixedRouteTrade.bestTradeExactIn(poolsExcludingThisPool, currencyAmountIn, currencyOut, {
|
|
1171
969
|
maxNumResults: maxNumResults,
|
|
1172
970
|
maxHops: maxHops - 1
|
|
1173
971
|
}, [].concat(currentPools, [pool]), amountOut, bestTrades);
|
|
1174
|
-
case
|
|
972
|
+
case 14:
|
|
1175
973
|
i++;
|
|
1176
|
-
_context3.
|
|
974
|
+
_context3.n = 1;
|
|
1177
975
|
break;
|
|
1178
|
-
case
|
|
1179
|
-
return _context3.
|
|
1180
|
-
case 57:
|
|
1181
|
-
case "end":
|
|
1182
|
-
return _context3.stop();
|
|
976
|
+
case 15:
|
|
977
|
+
return _context3.a(2, bestTrades);
|
|
1183
978
|
}
|
|
1184
|
-
}, _callee3, null, [[
|
|
979
|
+
}, _callee3, null, [[4, 9]]);
|
|
1185
980
|
}));
|
|
1186
|
-
function bestTradeExactIn(_x6, _x7, _x8, _x9,
|
|
981
|
+
function bestTradeExactIn(_x6, _x7, _x8, _x9, _x0, _x1, _x10) {
|
|
1187
982
|
return _bestTradeExactIn.apply(this, arguments);
|
|
1188
983
|
}
|
|
1189
984
|
return bestTradeExactIn;
|
|
@@ -1499,10 +1294,10 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1499
1294
|
return new Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
|
|
1500
1295
|
};
|
|
1501
1296
|
Trade.fromRoutes = /*#__PURE__*/function () {
|
|
1502
|
-
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
1503
|
-
var populatedV2Routes, populatedV3Routes, populatedV4Routes, populatedMixedRoutes, _iterator7, _step7, _step7$value, routev2, _amount2, v2Trade, _inputAmount5, _outputAmount5, _iterator8, _step8, _step8$value, routev3, _amount3, v3Trade, _inputAmount6, _outputAmount6, _iterator9, _step9, _step9$value, routev4, amount, v4Trade, inputAmount, outputAmount,
|
|
1504
|
-
return
|
|
1505
|
-
while (1) switch (_context.
|
|
1297
|
+
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(v2Routes, v3Routes, tradeType, mixedRoutes, v4Routes) {
|
|
1298
|
+
var populatedV2Routes, populatedV3Routes, populatedV4Routes, populatedMixedRoutes, _iterator7, _step7, _step7$value, routev2, _amount2, v2Trade, _inputAmount5, _outputAmount5, _iterator8, _step8, _step8$value, routev3, _amount3, v3Trade, _inputAmount6, _outputAmount6, _iterator9, _step9, _step9$value, routev4, amount, v4Trade, inputAmount, outputAmount, _iterator0, _step0, _step0$value, mixedRoute, _amount, mixedRouteTrade, _inputAmount4, _outputAmount4;
|
|
1299
|
+
return _regenerator().w(function (_context) {
|
|
1300
|
+
while (1) switch (_context.n) {
|
|
1506
1301
|
case 0:
|
|
1507
1302
|
populatedV2Routes = [];
|
|
1508
1303
|
populatedV3Routes = [];
|
|
@@ -1519,86 +1314,83 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1519
1314
|
});
|
|
1520
1315
|
}
|
|
1521
1316
|
_iterator8 = _createForOfIteratorHelperLoose(v3Routes);
|
|
1522
|
-
case
|
|
1317
|
+
case 1:
|
|
1523
1318
|
if ((_step8 = _iterator8()).done) {
|
|
1524
|
-
_context.
|
|
1319
|
+
_context.n = 4;
|
|
1525
1320
|
break;
|
|
1526
1321
|
}
|
|
1527
1322
|
_step8$value = _step8.value, routev3 = _step8$value.routev3, _amount3 = _step8$value.amount;
|
|
1528
|
-
_context.
|
|
1323
|
+
_context.n = 2;
|
|
1529
1324
|
return Trade$2.fromRoute(routev3, _amount3, tradeType);
|
|
1530
|
-
case
|
|
1531
|
-
v3Trade = _context.
|
|
1325
|
+
case 2:
|
|
1326
|
+
v3Trade = _context.v;
|
|
1532
1327
|
_inputAmount6 = v3Trade.inputAmount, _outputAmount6 = v3Trade.outputAmount;
|
|
1533
1328
|
populatedV3Routes.push({
|
|
1534
1329
|
routev3: routev3,
|
|
1535
1330
|
inputAmount: _inputAmount6,
|
|
1536
1331
|
outputAmount: _outputAmount6
|
|
1537
1332
|
});
|
|
1538
|
-
case
|
|
1539
|
-
_context.
|
|
1333
|
+
case 3:
|
|
1334
|
+
_context.n = 1;
|
|
1540
1335
|
break;
|
|
1541
|
-
case
|
|
1336
|
+
case 4:
|
|
1542
1337
|
if (!v4Routes) {
|
|
1543
|
-
_context.
|
|
1338
|
+
_context.n = 8;
|
|
1544
1339
|
break;
|
|
1545
1340
|
}
|
|
1546
1341
|
_iterator9 = _createForOfIteratorHelperLoose(v4Routes);
|
|
1547
|
-
case
|
|
1342
|
+
case 5:
|
|
1548
1343
|
if ((_step9 = _iterator9()).done) {
|
|
1549
|
-
_context.
|
|
1344
|
+
_context.n = 8;
|
|
1550
1345
|
break;
|
|
1551
1346
|
}
|
|
1552
1347
|
_step9$value = _step9.value, routev4 = _step9$value.routev4, amount = _step9$value.amount;
|
|
1553
|
-
_context.
|
|
1348
|
+
_context.n = 6;
|
|
1554
1349
|
return Trade$1.fromRoute(routev4, amount, tradeType);
|
|
1555
|
-
case
|
|
1556
|
-
v4Trade = _context.
|
|
1350
|
+
case 6:
|
|
1351
|
+
v4Trade = _context.v;
|
|
1557
1352
|
inputAmount = v4Trade.inputAmount, outputAmount = v4Trade.outputAmount;
|
|
1558
1353
|
populatedV4Routes.push({
|
|
1559
1354
|
routev4: routev4,
|
|
1560
1355
|
inputAmount: inputAmount,
|
|
1561
1356
|
outputAmount: outputAmount
|
|
1562
1357
|
});
|
|
1563
|
-
case
|
|
1564
|
-
_context.
|
|
1358
|
+
case 7:
|
|
1359
|
+
_context.n = 5;
|
|
1565
1360
|
break;
|
|
1566
|
-
case
|
|
1361
|
+
case 8:
|
|
1567
1362
|
if (!mixedRoutes) {
|
|
1568
|
-
_context.
|
|
1363
|
+
_context.n = 12;
|
|
1569
1364
|
break;
|
|
1570
1365
|
}
|
|
1571
|
-
|
|
1572
|
-
case
|
|
1573
|
-
if ((
|
|
1574
|
-
_context.
|
|
1366
|
+
_iterator0 = _createForOfIteratorHelperLoose(mixedRoutes);
|
|
1367
|
+
case 9:
|
|
1368
|
+
if ((_step0 = _iterator0()).done) {
|
|
1369
|
+
_context.n = 12;
|
|
1575
1370
|
break;
|
|
1576
1371
|
}
|
|
1577
|
-
|
|
1578
|
-
_context.
|
|
1372
|
+
_step0$value = _step0.value, mixedRoute = _step0$value.mixedRoute, _amount = _step0$value.amount;
|
|
1373
|
+
_context.n = 10;
|
|
1579
1374
|
return MixedRouteTrade.fromRoute(mixedRoute, _amount, tradeType);
|
|
1580
|
-
case
|
|
1581
|
-
mixedRouteTrade = _context.
|
|
1375
|
+
case 10:
|
|
1376
|
+
mixedRouteTrade = _context.v;
|
|
1582
1377
|
_inputAmount4 = mixedRouteTrade.inputAmount, _outputAmount4 = mixedRouteTrade.outputAmount;
|
|
1583
1378
|
populatedMixedRoutes.push({
|
|
1584
1379
|
mixedRoute: mixedRoute,
|
|
1585
1380
|
inputAmount: _inputAmount4,
|
|
1586
1381
|
outputAmount: _outputAmount4
|
|
1587
1382
|
});
|
|
1588
|
-
case
|
|
1589
|
-
_context.
|
|
1383
|
+
case 11:
|
|
1384
|
+
_context.n = 9;
|
|
1590
1385
|
break;
|
|
1591
|
-
case
|
|
1592
|
-
return _context.
|
|
1386
|
+
case 12:
|
|
1387
|
+
return _context.a(2, new Trade({
|
|
1593
1388
|
v2Routes: populatedV2Routes,
|
|
1594
1389
|
v3Routes: populatedV3Routes,
|
|
1595
1390
|
v4Routes: populatedV4Routes,
|
|
1596
1391
|
mixedRoutes: populatedMixedRoutes,
|
|
1597
1392
|
tradeType: tradeType
|
|
1598
1393
|
}));
|
|
1599
|
-
case 38:
|
|
1600
|
-
case "end":
|
|
1601
|
-
return _context.stop();
|
|
1602
1394
|
}
|
|
1603
1395
|
}, _callee);
|
|
1604
1396
|
}));
|
|
@@ -1608,17 +1400,17 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1608
1400
|
return fromRoutes;
|
|
1609
1401
|
}();
|
|
1610
1402
|
Trade.fromRoute = /*#__PURE__*/function () {
|
|
1611
|
-
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
1403
|
+
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(route, amount, tradeType) {
|
|
1612
1404
|
var v2Routes, v3Routes, v4Routes, mixedRoutes, v2Trade, inputAmount, outputAmount, v3Trade, _inputAmount7, _outputAmount7, v4Trade, _inputAmount8, _outputAmount8, mixedRouteTrade, _inputAmount9, _outputAmount9;
|
|
1613
|
-
return
|
|
1614
|
-
while (1) switch (_context2.
|
|
1405
|
+
return _regenerator().w(function (_context2) {
|
|
1406
|
+
while (1) switch (_context2.n) {
|
|
1615
1407
|
case 0:
|
|
1616
1408
|
v2Routes = [];
|
|
1617
1409
|
v3Routes = [];
|
|
1618
1410
|
v4Routes = [];
|
|
1619
1411
|
mixedRoutes = [];
|
|
1620
1412
|
if (!(route instanceof Route)) {
|
|
1621
|
-
_context2.
|
|
1413
|
+
_context2.n = 1;
|
|
1622
1414
|
break;
|
|
1623
1415
|
}
|
|
1624
1416
|
v2Trade = new Trade$3(route, amount, tradeType);
|
|
@@ -1628,72 +1420,69 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1628
1420
|
inputAmount: inputAmount,
|
|
1629
1421
|
outputAmount: outputAmount
|
|
1630
1422
|
}];
|
|
1631
|
-
_context2.
|
|
1423
|
+
_context2.n = 8;
|
|
1632
1424
|
break;
|
|
1633
|
-
case
|
|
1425
|
+
case 1:
|
|
1634
1426
|
if (!(route instanceof Route$1)) {
|
|
1635
|
-
_context2.
|
|
1427
|
+
_context2.n = 3;
|
|
1636
1428
|
break;
|
|
1637
1429
|
}
|
|
1638
|
-
_context2.
|
|
1430
|
+
_context2.n = 2;
|
|
1639
1431
|
return Trade$2.fromRoute(route, amount, tradeType);
|
|
1640
|
-
case
|
|
1641
|
-
v3Trade = _context2.
|
|
1432
|
+
case 2:
|
|
1433
|
+
v3Trade = _context2.v;
|
|
1642
1434
|
_inputAmount7 = v3Trade.inputAmount, _outputAmount7 = v3Trade.outputAmount;
|
|
1643
1435
|
v3Routes = [{
|
|
1644
1436
|
routev3: route,
|
|
1645
1437
|
inputAmount: _inputAmount7,
|
|
1646
1438
|
outputAmount: _outputAmount7
|
|
1647
1439
|
}];
|
|
1648
|
-
_context2.
|
|
1440
|
+
_context2.n = 8;
|
|
1649
1441
|
break;
|
|
1650
|
-
case
|
|
1442
|
+
case 3:
|
|
1651
1443
|
if (!(route instanceof Route$2)) {
|
|
1652
|
-
_context2.
|
|
1444
|
+
_context2.n = 5;
|
|
1653
1445
|
break;
|
|
1654
1446
|
}
|
|
1655
|
-
_context2.
|
|
1447
|
+
_context2.n = 4;
|
|
1656
1448
|
return Trade$1.fromRoute(route, amount, tradeType);
|
|
1657
|
-
case
|
|
1658
|
-
v4Trade = _context2.
|
|
1449
|
+
case 4:
|
|
1450
|
+
v4Trade = _context2.v;
|
|
1659
1451
|
_inputAmount8 = v4Trade.inputAmount, _outputAmount8 = v4Trade.outputAmount;
|
|
1660
1452
|
v4Routes = [{
|
|
1661
1453
|
routev4: route,
|
|
1662
1454
|
inputAmount: _inputAmount8,
|
|
1663
1455
|
outputAmount: _outputAmount8
|
|
1664
1456
|
}];
|
|
1665
|
-
_context2.
|
|
1457
|
+
_context2.n = 8;
|
|
1666
1458
|
break;
|
|
1667
|
-
case
|
|
1459
|
+
case 5:
|
|
1668
1460
|
if (!(route instanceof MixedRouteSDK)) {
|
|
1669
|
-
_context2.
|
|
1461
|
+
_context2.n = 7;
|
|
1670
1462
|
break;
|
|
1671
1463
|
}
|
|
1672
|
-
_context2.
|
|
1464
|
+
_context2.n = 6;
|
|
1673
1465
|
return MixedRouteTrade.fromRoute(route, amount, tradeType);
|
|
1674
|
-
case
|
|
1675
|
-
mixedRouteTrade = _context2.
|
|
1466
|
+
case 6:
|
|
1467
|
+
mixedRouteTrade = _context2.v;
|
|
1676
1468
|
_inputAmount9 = mixedRouteTrade.inputAmount, _outputAmount9 = mixedRouteTrade.outputAmount;
|
|
1677
1469
|
mixedRoutes = [{
|
|
1678
1470
|
mixedRoute: route,
|
|
1679
1471
|
inputAmount: _inputAmount9,
|
|
1680
1472
|
outputAmount: _outputAmount9
|
|
1681
1473
|
}];
|
|
1682
|
-
_context2.
|
|
1474
|
+
_context2.n = 8;
|
|
1683
1475
|
break;
|
|
1684
|
-
case
|
|
1476
|
+
case 7:
|
|
1685
1477
|
throw new Error('Invalid route type');
|
|
1686
|
-
case
|
|
1687
|
-
return _context2.
|
|
1478
|
+
case 8:
|
|
1479
|
+
return _context2.a(2, new Trade({
|
|
1688
1480
|
v2Routes: v2Routes,
|
|
1689
1481
|
v3Routes: v3Routes,
|
|
1690
1482
|
v4Routes: v4Routes,
|
|
1691
1483
|
mixedRoutes: mixedRoutes,
|
|
1692
1484
|
tradeType: tradeType
|
|
1693
1485
|
}));
|
|
1694
|
-
case 36:
|
|
1695
|
-
case "end":
|
|
1696
|
-
return _context2.stop();
|
|
1697
1486
|
}
|
|
1698
1487
|
}, _callee2);
|
|
1699
1488
|
}));
|
|
@@ -1848,10 +1637,10 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1848
1637
|
// because we're unable to derive the pre-buy-tax amount, use 0% as a placeholder.
|
|
1849
1638
|
if (this.outputTax.equalTo(ONE_HUNDRED_PERCENT)) return ZERO_PERCENT;
|
|
1850
1639
|
var spotOutputAmount = CurrencyAmount.fromRawAmount(this.outputAmount.currency, 0);
|
|
1851
|
-
for (var
|
|
1852
|
-
var
|
|
1853
|
-
route =
|
|
1854
|
-
inputAmount =
|
|
1640
|
+
for (var _iterator1 = _createForOfIteratorHelperLoose(this.swaps), _step1; !(_step1 = _iterator1()).done;) {
|
|
1641
|
+
var _step1$value = _step1.value,
|
|
1642
|
+
route = _step1$value.route,
|
|
1643
|
+
inputAmount = _step1$value.inputAmount;
|
|
1855
1644
|
var midPrice = route.midPrice;
|
|
1856
1645
|
var postTaxInputAmount = inputAmount.multiply(new Fraction(ONE).subtract(this.inputTax));
|
|
1857
1646
|
spotOutputAmount = spotOutputAmount.add(midPrice.quote(postTaxInputAmount));
|