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