lotus-v4-sdk
Version:
⚒️ An SDK for building applications on top of Lotus V4
1,182 lines (1,171 loc) • 132 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var invariant = _interopDefault(require('tiny-invariant'));
var solidity = require('@ethersproject/solidity');
var sdkCore = require('@uniswap/sdk-core');
var v3Sdk = require('@uniswap/v3-sdk');
var utils = require('ethers/lib/utils');
var JSBI = _interopDefault(require('jsbi'));
var ethers = require('ethers');
var abi = require('@ethersproject/abi');
var IMulticall = _interopDefault(require('@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json'));
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function asyncGeneratorStep(n, t, e, r, o, a, c) {
try {
var i = n[a](c),
u = i.value;
} catch (n) {
return void e(n);
}
i.done ? t(u) : Promise.resolve(u).then(r, o);
}
function _asyncToGenerator(n) {
return function () {
var t = this,
e = arguments;
return new Promise(function (r, o) {
var a = n.apply(t, e);
function _next(n) {
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
}
function _throw(n) {
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
}
_next(void 0);
});
};
}
function _defineProperties(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
}
}
function _createClass(e, r, t) {
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
writable: !1
}), e;
}
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var o = 0;
return function () {
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _inheritsLoose(t, o) {
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
}
function _regeneratorRuntime() {
_regeneratorRuntime = function () {
return e;
};
var t,
e = {},
r = Object.prototype,
n = r.hasOwnProperty,
o = Object.defineProperty || function (t, e, r) {
t[e] = r.value;
},
i = "function" == typeof Symbol ? Symbol : {},
a = i.iterator || "@@iterator",
c = i.asyncIterator || "@@asyncIterator",
u = i.toStringTag || "@@toStringTag";
function define(t, e, r) {
return Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}), t[e];
}
try {
define({}, "");
} catch (t) {
define = function (t, e, r) {
return t[e] = r;
};
}
function wrap(t, e, r, n) {
var i = e && e.prototype instanceof Generator ? e : Generator,
a = Object.create(i.prototype),
c = new Context(n || []);
return o(a, "_invoke", {
value: makeInvokeMethod(t, r, c)
}), a;
}
function tryCatch(t, e, r) {
try {
return {
type: "normal",
arg: t.call(e, r)
};
} catch (t) {
return {
type: "throw",
arg: t
};
}
}
e.wrap = wrap;
var h = "suspendedStart",
l = "suspendedYield",
f = "executing",
s = "completed",
y = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var p = {};
define(p, a, function () {
return this;
});
var d = Object.getPrototypeOf,
v = d && d(d(values([])));
v && v !== r && n.call(v, a) && (p = v);
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
function defineIteratorMethods(t) {
["next", "throw", "return"].forEach(function (e) {
define(t, e, function (t) {
return this._invoke(e, t);
});
});
}
function AsyncIterator(t, e) {
function invoke(r, o, i, a) {
var c = tryCatch(t[r], t, o);
if ("throw" !== c.type) {
var u = c.arg,
h = u.value;
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
invoke("next", t, i, a);
}, function (t) {
invoke("throw", t, i, a);
}) : e.resolve(h).then(function (t) {
u.value = t, i(u);
}, function (t) {
return invoke("throw", t, i, a);
});
}
a(c.arg);
}
var r;
o(this, "_invoke", {
value: function (t, n) {
function callInvokeWithMethodAndArg() {
return new e(function (e, r) {
invoke(t, n, e, r);
});
}
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(e, r, n) {
var o = h;
return function (i, a) {
if (o === f) throw Error("Generator is already running");
if (o === s) {
if ("throw" === i) throw a;
return {
value: t,
done: !0
};
}
for (n.method = i, n.arg = a;;) {
var c = n.delegate;
if (c) {
var u = maybeInvokeDelegate(c, n);
if (u) {
if (u === y) continue;
return u;
}
}
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
if (o === h) throw o = s, n.arg;
n.dispatchException(n.arg);
} else "return" === n.method && n.abrupt("return", n.arg);
o = f;
var p = tryCatch(e, r, n);
if ("normal" === p.type) {
if (o = n.done ? s : l, p.arg === y) continue;
return {
value: p.arg,
done: n.done
};
}
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
}
};
}
function maybeInvokeDelegate(e, r) {
var n = r.method,
o = e.iterator[n];
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;
var i = tryCatch(o, e.iterator, r.arg);
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
var a = i.arg;
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);
}
function pushTryEntry(t) {
var e = {
tryLoc: t[0]
};
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
}
function resetTryEntry(t) {
var e = t.completion || {};
e.type = "normal", delete e.arg, t.completion = e;
}
function Context(t) {
this.tryEntries = [{
tryLoc: "root"
}], t.forEach(pushTryEntry, this), this.reset(!0);
}
function values(e) {
if (e || "" === e) {
var r = e[a];
if (r) return r.call(e);
if ("function" == typeof e.next) return e;
if (!isNaN(e.length)) {
var o = -1,
i = function next() {
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
return next.value = t, next.done = !0, next;
};
return i.next = i;
}
}
throw new TypeError(typeof e + " is not iterable");
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), o(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
var e = "function" == typeof t && t.constructor;
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
}, e.mark = function (t) {
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
}, e.awrap = function (t) {
return {
__await: t
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
return this;
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
void 0 === i && (i = Promise);
var a = new AsyncIterator(wrap(t, r, n, o), i);
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
return t.done ? t.value : a.next();
});
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
return this;
}), define(g, "toString", function () {
return "[object Generator]";
}), e.keys = function (t) {
var e = Object(t),
r = [];
for (var n in e) r.push(n);
return r.reverse(), function next() {
for (; r.length;) {
var t = r.pop();
if (t in e) return next.value = t, next.done = !1, next;
}
return next.done = !0, next;
};
}, e.values = values, Context.prototype = {
constructor: Context,
reset: function (e) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
},
stop: function () {
this.done = !0;
var t = this.tryEntries[0].completion;
if ("throw" === t.type) throw t.arg;
return this.rval;
},
dispatchException: function (e) {
if (this.done) throw e;
var r = this;
function handle(n, o) {
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
}
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
var i = this.tryEntries[o],
a = i.completion;
if ("root" === i.tryLoc) return handle("end");
if (i.tryLoc <= this.prev) {
var c = n.call(i, "catchLoc"),
u = n.call(i, "finallyLoc");
if (c && u) {
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
} else if (c) {
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
} else {
if (!u) throw Error("try statement without catch or finally");
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
}
}
}
},
abrupt: function (t, e) {
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
var o = this.tryEntries[r];
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
var i = o;
break;
}
}
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
var a = i ? i.completion : {};
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
},
complete: function (t, e) {
if ("throw" === t.type) throw t.arg;
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;
},
finish: function (t) {
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
var r = this.tryEntries[e];
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
}
},
catch: function (t) {
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
var r = this.tryEntries[e];
if (r.tryLoc === t) {
var n = r.completion;
if ("throw" === n.type) {
var o = n.arg;
resetTryEntry(r);
}
return o;
}
}
throw Error("illegal catch attempt");
},
delegateYield: function (e, r, n) {
return this.delegate = {
iterator: values(e),
resultName: r,
nextLoc: n
}, "next" === this.method && (this.arg = t), y;
}
}, e;
}
function _setPrototypeOf(t, e) {
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
return t.__proto__ = e, t;
}, _setPrototypeOf(t, e);
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function sortsBefore(currencyA, currencyB) {
if (currencyA.isNative) return true;
if (currencyB.isNative) return false;
return currencyA.wrapped.sortsBefore(currencyB.wrapped);
}
var _hookFlagIndex;
(function (HookOptions) {
HookOptions["AfterRemoveLiquidityReturnsDelta"] = "afterRemoveLiquidityReturnsDelta";
HookOptions["AfterAddLiquidityReturnsDelta"] = "afterAddLiquidityReturnsDelta";
HookOptions["AfterSwapReturnsDelta"] = "afterSwapReturnsDelta";
HookOptions["BeforeSwapReturnsDelta"] = "beforeSwapReturnsDelta";
HookOptions["AfterDonate"] = "afterDonate";
HookOptions["BeforeDonate"] = "beforeDonate";
HookOptions["AfterSwap"] = "afterSwap";
HookOptions["BeforeSwap"] = "beforeSwap";
HookOptions["AfterRemoveLiquidity"] = "afterRemoveLiquidity";
HookOptions["BeforeRemoveLiquidity"] = "beforeRemoveLiquidity";
HookOptions["AfterAddLiquidity"] = "afterAddLiquidity";
HookOptions["BeforeAddLiquidity"] = "beforeAddLiquidity";
HookOptions["AfterInitialize"] = "afterInitialize";
HookOptions["BeforeInitialize"] = "beforeInitialize";
})(exports.HookOptions || (exports.HookOptions = {}));
var hookFlagIndex = (_hookFlagIndex = {}, _hookFlagIndex[exports.HookOptions.AfterRemoveLiquidityReturnsDelta] = 0, _hookFlagIndex[exports.HookOptions.AfterAddLiquidityReturnsDelta] = 1, _hookFlagIndex[exports.HookOptions.AfterSwapReturnsDelta] = 2, _hookFlagIndex[exports.HookOptions.BeforeSwapReturnsDelta] = 3, _hookFlagIndex[exports.HookOptions.AfterDonate] = 4, _hookFlagIndex[exports.HookOptions.BeforeDonate] = 5, _hookFlagIndex[exports.HookOptions.AfterSwap] = 6, _hookFlagIndex[exports.HookOptions.BeforeSwap] = 7, _hookFlagIndex[exports.HookOptions.AfterRemoveLiquidity] = 8, _hookFlagIndex[exports.HookOptions.BeforeRemoveLiquidity] = 9, _hookFlagIndex[exports.HookOptions.AfterAddLiquidity] = 10, _hookFlagIndex[exports.HookOptions.BeforeAddLiquidity] = 11, _hookFlagIndex[exports.HookOptions.AfterInitialize] = 12, _hookFlagIndex[exports.HookOptions.BeforeInitialize] = 13, _hookFlagIndex);
var Hook = /*#__PURE__*/function () {
function Hook() {}
Hook.permissions = function permissions(address) {
this._checkAddress(address);
return {
beforeInitialize: this._hasPermission(address, exports.HookOptions.BeforeInitialize),
afterInitialize: this._hasPermission(address, exports.HookOptions.AfterInitialize),
beforeAddLiquidity: this._hasPermission(address, exports.HookOptions.BeforeAddLiquidity),
afterAddLiquidity: this._hasPermission(address, exports.HookOptions.AfterAddLiquidity),
beforeRemoveLiquidity: this._hasPermission(address, exports.HookOptions.BeforeRemoveLiquidity),
afterRemoveLiquidity: this._hasPermission(address, exports.HookOptions.AfterRemoveLiquidity),
beforeSwap: this._hasPermission(address, exports.HookOptions.BeforeSwap),
afterSwap: this._hasPermission(address, exports.HookOptions.AfterSwap),
beforeDonate: this._hasPermission(address, exports.HookOptions.BeforeDonate),
afterDonate: this._hasPermission(address, exports.HookOptions.AfterDonate),
beforeSwapReturnsDelta: this._hasPermission(address, exports.HookOptions.BeforeSwapReturnsDelta),
afterSwapReturnsDelta: this._hasPermission(address, exports.HookOptions.AfterSwapReturnsDelta),
afterAddLiquidityReturnsDelta: this._hasPermission(address, exports.HookOptions.AfterAddLiquidityReturnsDelta),
afterRemoveLiquidityReturnsDelta: this._hasPermission(address, exports.HookOptions.AfterRemoveLiquidityReturnsDelta)
};
};
Hook.hasPermission = function hasPermission(address, hookOption) {
this._checkAddress(address);
return this._hasPermission(address, hookOption);
};
Hook.hasInitializePermissions = function hasInitializePermissions(address) {
this._checkAddress(address);
return this._hasPermission(address, exports.HookOptions.BeforeInitialize) || Hook._hasPermission(address, exports.HookOptions.AfterInitialize);
};
Hook.hasLiquidityPermissions = function hasLiquidityPermissions(address) {
this._checkAddress(address);
// this implicitly encapsulates liquidity delta permissions
return this._hasPermission(address, exports.HookOptions.BeforeAddLiquidity) || Hook._hasPermission(address, exports.HookOptions.AfterAddLiquidity) || Hook._hasPermission(address, exports.HookOptions.BeforeRemoveLiquidity) || Hook._hasPermission(address, exports.HookOptions.AfterRemoveLiquidity);
};
Hook.hasSwapPermissions = function hasSwapPermissions(address) {
this._checkAddress(address);
// this implicitly encapsulates swap delta permissions
return this._hasPermission(address, exports.HookOptions.BeforeSwap) || Hook._hasPermission(address, exports.HookOptions.AfterSwap);
};
Hook.hasDonatePermissions = function hasDonatePermissions(address) {
this._checkAddress(address);
return this._hasPermission(address, exports.HookOptions.BeforeDonate) || Hook._hasPermission(address, exports.HookOptions.AfterDonate);
};
Hook._hasPermission = function _hasPermission(address, hookOption) {
return !!(parseInt(address, 16) & 1 << hookFlagIndex[hookOption]);
};
Hook._checkAddress = function _checkAddress(address) {
!utils.isAddress(address) ? invariant(false, 'invalid address') : void 0;
};
return Hook;
}();
var _TICK_SPACINGS;
// constants used internally but not expected to be used externally
var ADDRESS_ZERO = ethers.constants.AddressZero;
var NEGATIVE_ONE = /*#__PURE__*/JSBI.BigInt(-1);
var ZERO = /*#__PURE__*/JSBI.BigInt(0);
var ONE = /*#__PURE__*/JSBI.BigInt(1);
var EMPTY_BYTES = '0x';
// used in liquidity amount math
var Q96 = /*#__PURE__*/JSBI.exponentiate(/*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(96));
var Q192 = /*#__PURE__*/JSBI.exponentiate(Q96, /*#__PURE__*/JSBI.BigInt(2));
// used when unwrapping weth in positon manager
var OPEN_DELTA = ethers.constants.Zero;
// error constants
var NATIVE_NOT_SET = 'NATIVE_NOT_SET';
var ZERO_LIQUIDITY = 'ZERO_LIQUIDITY';
var NO_SQRT_PRICE = 'NO_SQRT_PRICE';
var CANNOT_BURN = 'CANNOT_BURN';
/**
* Function fragments that exist on the PositionManager contract.
*/
var PositionFunctions;
(function (PositionFunctions) {
PositionFunctions["INITIALIZE_POOL"] = "initializePool";
PositionFunctions["MODIFY_LIQUIDITIES"] = "modifyLiquidities";
// Inherited from PermitForwarder
PositionFunctions["PERMIT_BATCH"] = "0x002a3e3a";
// Inherited from ERC721Permit
PositionFunctions["ERC721PERMIT_PERMIT"] = "0x0f5730f1";
})(PositionFunctions || (PositionFunctions = {}));
/**
* The default factory enabled fee amounts, denominated in hundredths of bips.
*/
var FeeAmount;
(function (FeeAmount) {
FeeAmount[FeeAmount["LOWEST"] = 100] = "LOWEST";
FeeAmount[FeeAmount["LOW"] = 500] = "LOW";
FeeAmount[FeeAmount["MEDIUM"] = 3000] = "MEDIUM";
FeeAmount[FeeAmount["HIGH"] = 10000] = "HIGH";
})(FeeAmount || (FeeAmount = {}));
/**
* The default factory tick spacings by fee amount.
*/
var TICK_SPACINGS = (_TICK_SPACINGS = {}, _TICK_SPACINGS[FeeAmount.LOWEST] = 1, _TICK_SPACINGS[FeeAmount.LOW] = 10, _TICK_SPACINGS[FeeAmount.MEDIUM] = 60, _TICK_SPACINGS[FeeAmount.HIGH] = 200, _TICK_SPACINGS);
var DYNAMIC_FEE_FLAG = 0x800000;
var NO_TICK_DATA_PROVIDER_DEFAULT = /*#__PURE__*/new v3Sdk.NoTickDataProvider();
/**
* Represents a V4 pool
*/
var Pool = /*#__PURE__*/function () {
/**
* Construct a pool
* @param currencyA One of the currencys in the pool
* @param currencyB The other currency in the pool
* @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
* @param tickSpacing The tickSpacing of the pool
* @param hooks The address of the hook contract
* @param sqrtRatioX96 The sqrt of the current ratio of amounts of currency1 to currency0
* @param liquidity The current value of in range liquidity
* @param tickCurrent The current tick of the pool
*/
function Pool(currencyA, currencyB, fee, tickSpacing, hooks, sqrtRatioX96, liquidity, tickCurrent, ticks) {
if (ticks === void 0) {
ticks = NO_TICK_DATA_PROVIDER_DEFAULT;
}
!utils.isAddress(hooks) ? invariant(false, 'Invalid hook address') : void 0;
!(Number.isInteger(fee) && (fee === DYNAMIC_FEE_FLAG || fee < 1000000)) ? invariant(false, 'FEE') : void 0;
if (fee === DYNAMIC_FEE_FLAG) {
!(Number(hooks) > 0) ? invariant(false, 'Dynamic fee pool requires a hook') : void 0;
}
var tickCurrentSqrtRatioX96 = v3Sdk.TickMath.getSqrtRatioAtTick(tickCurrent);
var nextTickSqrtRatioX96 = v3Sdk.TickMath.getSqrtRatioAtTick(tickCurrent + 1);
!(JSBI.greaterThanOrEqual(JSBI.BigInt(sqrtRatioX96), tickCurrentSqrtRatioX96) && JSBI.lessThanOrEqual(JSBI.BigInt(sqrtRatioX96), nextTickSqrtRatioX96)) ? invariant(false, 'PRICE_BOUNDS') : void 0;
var _ref = sortsBefore(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA];
this.currency0 = _ref[0];
this.currency1 = _ref[1];
this.fee = fee;
this.sqrtRatioX96 = JSBI.BigInt(sqrtRatioX96);
this.tickSpacing = tickSpacing;
this.hooks = hooks;
this.liquidity = JSBI.BigInt(liquidity);
this.tickCurrent = tickCurrent;
this.tickDataProvider = Array.isArray(ticks) ? new v3Sdk.TickListDataProvider(ticks, tickSpacing) : ticks;
this.poolKey = Pool.getPoolKey(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks);
this.poolId = Pool.getPoolId(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks);
}
Pool.getPoolKey = function getPoolKey(currencyA, currencyB, fee, tickSpacing, hooks) {
!utils.isAddress(hooks) ? invariant(false, 'Invalid hook address') : void 0;
var _ref2 = sortsBefore(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA],
currency0 = _ref2[0],
currency1 = _ref2[1];
var currency0Addr = currency0.isNative ? ADDRESS_ZERO : currency0.wrapped.address;
var currency1Addr = currency1.isNative ? ADDRESS_ZERO : currency1.wrapped.address;
return {
currency0: currency0Addr,
currency1: currency1Addr,
fee: fee,
tickSpacing: tickSpacing,
hooks: hooks
};
};
Pool.getPoolId = function getPoolId(currencyA, currencyB, fee, tickSpacing, hooks) {
var _ref3 = sortsBefore(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA],
currency0 = _ref3[0],
currency1 = _ref3[1];
var currency0Addr = currency0.isNative ? ADDRESS_ZERO : currency0.wrapped.address;
var currency1Addr = currency1.isNative ? ADDRESS_ZERO : currency1.wrapped.address;
return solidity.keccak256(['bytes'], [utils.defaultAbiCoder.encode(['address', 'address', 'uint24', 'int24', 'address'], [currency0Addr, currency1Addr, fee, tickSpacing, hooks])]);
}
/** backwards compatibility with v2/3 sdks */;
var _proto = Pool.prototype;
/**
* Returns true if the currency is either currency0 or currency1
* @param currency The currency to check
* @returns True if currency is either currency0 or currency1
*/
_proto.involvesCurrency = function involvesCurrency(currency) {
return currency.equals(this.currency0) || currency.equals(this.currency1);
}
/** backwards compatibility with v2/3 sdks */;
_proto.involvesToken = function involvesToken(currency) {
return this.involvesCurrency(currency);
}
/**
* v4-only involvesToken convenience method, used for mixed route ETH <-> WETH connection only
* @param currency
*/;
_proto.v4InvolvesToken = function v4InvolvesToken(currency) {
return this.involvesCurrency(currency) || currency.wrapped.equals(this.currency0) || currency.wrapped.equals(this.currency1) || currency.wrapped.equals(this.currency0.wrapped) || currency.wrapped.equals(this.currency1.wrapped);
}
/**
* Returns the current mid price of the pool in terms of currency0, i.e. the ratio of currency1 over currency0
*/;
/**
* Return the price of the given currency in terms of the other currency in the pool.
* @param currency The currency to return price of
* @returns The price of the given currency, in terms of the other.
*/
_proto.priceOf = function priceOf(currency) {
!this.involvesCurrency(currency) ? invariant(false, 'CURRENCY') : void 0;
return currency.equals(this.currency0) ? this.currency0Price : this.currency1Price;
}
/**
* Returns the chain ID of the currencies in the pool.
*/;
/** Works only for vanilla hookless v3 pools, otherwise throws an error */
_proto.getOutputAmount =
/*#__PURE__*/
function () {
var _getOutputAmount = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(inputAmount, sqrtPriceLimitX96) {
var zeroForOne, _yield$this$swap, outputAmount, sqrtRatioX96, liquidity, tickCurrent, outputCurrency;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
!this.involvesCurrency(inputAmount.currency) ? invariant(false, 'CURRENCY') : void 0;
zeroForOne = inputAmount.currency.equals(this.currency0);
_context.next = 4;
return this.swap(zeroForOne, inputAmount.quotient, sqrtPriceLimitX96);
case 4:
_yield$this$swap = _context.sent;
outputAmount = _yield$this$swap.amountCalculated;
sqrtRatioX96 = _yield$this$swap.sqrtRatioX96;
liquidity = _yield$this$swap.liquidity;
tickCurrent = _yield$this$swap.tickCurrent;
outputCurrency = zeroForOne ? this.currency1 : this.currency0;
return _context.abrupt("return", [sdkCore.CurrencyAmount.fromRawAmount(outputCurrency, JSBI.multiply(outputAmount, NEGATIVE_ONE)), new Pool(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider)]);
case 11:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function getOutputAmount(_x, _x2) {
return _getOutputAmount.apply(this, arguments);
}
return getOutputAmount;
}()
/**
* Given a desired output amount of a currency, return the computed input amount and a pool with state updated after the trade
* Works only for vanilla hookless v3 pools, otherwise throws an error
* @param outputAmount the output amount for which to quote the input amount
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
* @returns The input amount and the pool with updated state
*/
;
_proto.getInputAmount =
/*#__PURE__*/
function () {
var _getInputAmount = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(outputAmount, sqrtPriceLimitX96) {
var zeroForOne, _yield$this$swap2, inputAmount, sqrtRatioX96, liquidity, tickCurrent, inputCurrency;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
!this.involvesCurrency(outputAmount.currency) ? invariant(false, 'CURRENCY') : void 0;
zeroForOne = outputAmount.currency.equals(this.currency1);
_context2.next = 4;
return this.swap(zeroForOne, JSBI.multiply(outputAmount.quotient, NEGATIVE_ONE), sqrtPriceLimitX96);
case 4:
_yield$this$swap2 = _context2.sent;
inputAmount = _yield$this$swap2.amountCalculated;
sqrtRatioX96 = _yield$this$swap2.sqrtRatioX96;
liquidity = _yield$this$swap2.liquidity;
tickCurrent = _yield$this$swap2.tickCurrent;
inputCurrency = zeroForOne ? this.currency0 : this.currency1;
return _context2.abrupt("return", [sdkCore.CurrencyAmount.fromRawAmount(inputCurrency, inputAmount), new Pool(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider)]);
case 11:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function getInputAmount(_x3, _x4) {
return _getInputAmount.apply(this, arguments);
}
return getInputAmount;
}()
/**
* Executes a swap
* @param zeroForOne Whether the amount in is token0 or token1
* @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
* @returns amountCalculated
* @returns sqrtRatioX96
* @returns liquidity
* @returns tickCurrent
*/
;
_proto.swap =
/*#__PURE__*/
function () {
var _swap = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(zeroForOne, amountSpecified, sqrtPriceLimitX96) {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
if (this.hookImpactsSwap()) {
_context3.next = 4;
break;
}
return _context3.abrupt("return", v3Sdk.v3Swap(JSBI.BigInt(this.fee), this.sqrtRatioX96, this.tickCurrent, this.liquidity, this.tickSpacing, this.tickDataProvider, zeroForOne, amountSpecified, sqrtPriceLimitX96));
case 4:
throw new Error('Unsupported hook');
case 5:
case "end":
return _context3.stop();
}
}, _callee3, this);
}));
function swap(_x5, _x6, _x7) {
return _swap.apply(this, arguments);
}
return swap;
}();
_proto.hookImpactsSwap = function hookImpactsSwap() {
// could use this function to clear certain hooks that may have swap Permissions, but we know they don't interfere
// in the swap outcome
return Hook.hasSwapPermissions(this.hooks);
};
return _createClass(Pool, [{
key: "token0",
get: function get() {
return this.currency0;
}
}, {
key: "token1",
get: function get() {
return this.currency1;
}
}, {
key: "currency0Price",
get: function get() {
var _this$_currency0Price;
return (_this$_currency0Price = this._currency0Price) != null ? _this$_currency0Price : this._currency0Price = new sdkCore.Price(this.currency0, this.currency1, Q192, JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96));
}
/** backwards compatibility with v2/3 sdks */
}, {
key: "token0Price",
get: function get() {
return this.currency0Price;
}
/**
* Returns the current mid price of the pool in terms of currency1, i.e. the ratio of currency0 over currency1
*/
}, {
key: "currency1Price",
get: function get() {
var _this$_currency1Price;
return (_this$_currency1Price = this._currency1Price) != null ? _this$_currency1Price : this._currency1Price = new sdkCore.Price(this.currency1, this.currency0, JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96), Q192);
}
/** backwards compatibility with v2/3 sdks */
}, {
key: "token1Price",
get: function get() {
return this.currency1Price;
}
}, {
key: "chainId",
get: function get() {
return this.currency0.chainId;
}
}]);
}();
function amountWithPathCurrency(amount, pool) {
return sdkCore.CurrencyAmount.fromFractionalAmount(getPathCurrency(amount.currency, pool), amount.numerator, amount.denominator);
}
function getPathCurrency(currency, pool) {
if (pool.involvesCurrency(currency)) {
return currency;
} else if (pool.involvesCurrency(currency.wrapped)) {
return currency.wrapped;
} else if (pool.currency0.wrapped.equals(currency)) {
return pool.currency0;
} else if (pool.currency1.wrapped.equals(currency)) {
return pool.currency1;
} else {
throw new Error("Expected currency " + currency.symbol + " to be either " + pool.currency0.symbol + " or " + pool.currency1.symbol);
}
}
/**
* Represents a list of pools through which a swap can occur
* @template TInput The input currency
* @template TOutput The output currency
*/
var Route = /*#__PURE__*/function () {
/**
* Creates an instance of route.
* @param pools An array of `Pool` objects, ordered by the route the swap will take
* @param input The input currency
* @param output The output currency
*/
function Route(pools, input, output) {
this._midPrice = null;
!(pools.length > 0) ? invariant(false, 'POOLS') : void 0;
var chainId = pools[0].chainId;
var allOnSameChain = pools.every(function (pool) {
return pool.chainId === chainId;
});
!allOnSameChain ? invariant(false, 'CHAIN_IDS') : void 0;
/**
* function throws if pools do not involve the input and output currency or the native/wrapped equivalent
**/
this.pathInput = getPathCurrency(input, pools[0]);
this.pathOutput = getPathCurrency(output, pools[pools.length - 1]);
/**
* Normalizes currency0-currency1 order and selects the next currency/fee step to add to the path
* */
var currencyPath = [this.pathInput];
for (var _iterator = _createForOfIteratorHelperLoose(pools.entries()), _step; !(_step = _iterator()).done;) {
var _step$value = _step.value,
i = _step$value[0],
pool = _step$value[1];
var currentInputCurrency = currencyPath[i];
!(currentInputCurrency.equals(pool.currency0) || currentInputCurrency.equals(pool.currency1)) ? invariant(false, 'PATH') : void 0;
var nextCurrency = currentInputCurrency.equals(pool.currency0) ? pool.currency1 : pool.currency0;
currencyPath.push(nextCurrency);
}
this.pools = pools;
this.currencyPath = currencyPath;
this.input = input;
this.output = output != null ? output : currencyPath[currencyPath.length - 1];
}
return _createClass(Route, [{
key: "chainId",
get: function get() {
return this.pools[0].chainId;
}
/**
* Returns the mid price of the route
*/
}, {
key: "midPrice",
get: function get() {
if (this._midPrice !== null) return this._midPrice;
var price = this.pools.slice(1).reduce(function (_ref, pool) {
var nextInput = _ref.nextInput,
price = _ref.price;
return nextInput.equals(pool.currency0) ? {
nextInput: pool.currency1,
price: price.multiply(pool.currency0Price)
} : {
nextInput: pool.currency0,
price: price.multiply(pool.currency1Price)
};
}, this.pools[0].currency0.equals(this.input) ? {
nextInput: this.pools[0].currency1,
price: this.pools[0].currency0Price
} : {
nextInput: this.pools[0].currency0,
price: this.pools[0].currency1Price
}).price;
return this._midPrice = new sdkCore.Price(this.input, this.output, price.denominator, price.numerator);
}
}]);
}();
/**
* Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
* @template TInput The input currency, either Ether or an ERC-20
* @template TOutput The output currency, either Ether or an ERC-20
* @template TTradeType The trade type, either exact input or exact output
* @param a The first trade to compare
* @param b The second trade to compare
* @returns A sorted ordering for two neighboring elements in a trade array
*/
function tradeComparator(a, b) {
// must have same input and output currency for comparison
!a.inputAmount.currency.equals(b.inputAmount.currency) ? invariant(false, 'INPUT_CURRENCY') : void 0;
!a.outputAmount.currency.equals(b.outputAmount.currency) ? invariant(false, 'OUTPUT_CURRENCY') : void 0;
if (a.outputAmount.equalTo(b.outputAmount)) {
if (a.inputAmount.equalTo(b.inputAmount)) {
// consider the number of hops since each hop costs gas
var aHops = a.swaps.reduce(function (total, cur) {
return total + cur.route.currencyPath.length;
}, 0);
var bHops = b.swaps.reduce(function (total, cur) {
return total + cur.route.currencyPath.length;
}, 0);
return aHops - bHops;
}
// trade A requires less input than trade B, so A should come first
if (a.inputAmount.lessThan(b.inputAmount)) {
return -1;
} else {
return 1;
}
} else {
// tradeA has less output than trade B, so should come second
if (a.outputAmount.lessThan(b.outputAmount)) {
return 1;
} else {
return -1;
}
}
}
/**
* Represents a trade executed against a set of routes where some percentage of the input is
* split across each route.
*
* Each route has its own set of pools. Pools can not be re-used across routes.
*
* Does not account for slippage, i.e., changes in price environment that can occur between
* the time the trade is submitted and when it is executed.
* @template TInput The input currency, either Ether or an ERC-20
* @template TOutput The output currency, either Ether or an ERC-20
* @template TTradeType The trade type, either exact input or exact output
*/
var Trade = /*#__PURE__*/function () {
/**
* Construct a trade by passing in the pre-computed property values
* @param routes The routes through which the trade occurs
* @param tradeType The type of trade, exact input or exact output
*/
function Trade(_ref) {
var routes = _ref.routes,
tradeType = _ref.tradeType;
var inputCurrency = routes[0].inputAmount.currency;
var outputCurrency = routes[0].outputAmount.currency;
!routes.every(function (_ref2) {
var route = _ref2.route;
return inputCurrency.equals(route.input);
}) ? invariant(false, 'INPUT_CURRENCY_MATCH') : void 0;
!routes.every(function (_ref3) {
var route = _ref3.route;
return outputCurrency.equals(route.output);
}) ? invariant(false, 'OUTPUT_CURRENCY_MATCH') : void 0;
// const numPools = routes.map(({ route }) => route.pools.length).reduce((total, cur) => total + cur, 0)
var poolIDSet = new Set();
for (var _iterator = _createForOfIteratorHelperLoose(routes), _step; !(_step = _iterator()).done;) {
var route = _step.value.route;
for (var _iterator2 = _createForOfIteratorHelperLoose(route.pools), _step2; !(_step2 = _iterator2()).done;) {
var pool = _step2.value;
poolIDSet.add(Pool.getPoolId(pool.currency0, pool.currency1, pool.fee, pool.tickSpacing, pool.hooks));
}
}
// invariant(numPools === poolIDSet.size, 'POOLS_DUPLICATED')
this.swaps = routes;
this.tradeType = tradeType;
}
/**
* @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
* this will return an error.
*
* When the trade consists of just a single route, this returns the route of the trade,
* i.e. which pools the trade goes through.
*/
/**
* Constructs an exact in trade with the given amount in and route
* @template TInput The input currency, either Ether or an ERC-20
* @template TOutput The output currency, either Ether or an ERC-20
* @param route The route of the exact in trade
* @param amountIn The amount being passed in
* @returns The exact in trade
*/
Trade.exactIn =
/*#__PURE__*/
function () {
var _exactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(route, amountIn) {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", Trade.fromRoute(route, amountIn, sdkCore.TradeType.EXACT_INPUT));
case 1:
case "end":
return _context.stop();
}
}, _callee);
}));
function exactIn(_x, _x2) {
return _exactIn.apply(this, arguments);
}
return exactIn;
}()
/**
* Constructs an exact out trade with the given amount out and route
* @template TInput The input currency, either Ether or an ERC-20
* @template TOutput The output currency, either Ether or an ERC-20
* @param route The route of the exact out trade
* @param amountOut The amount returned by the trade
* @returns The exact out trade
*/
;
Trade.exactOut =
/*#__PURE__*/
function () {
var _exactOut = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(route, amountOut) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
return _context2.abrupt("return", Trade.fromRoute(route, amountOut, sdkCore.TradeType.EXACT_OUTPUT));
case 1:
case "end":
return _context2.stop();
}
}, _callee2);
}));
function exactOut(_x3, _x4) {
return _exactOut.apply(this, arguments);
}
return exactOut;
}()
/**
* Constructs a trade by simulating swaps through the given route
* @template TInput The input currency, either Ether or an ERC-20.
* @template TOutput The output currency, either Ether or an ERC-20.
* @template TTradeType The type of the trade, either exact in or exact out.
* @param route route to swap through
* @param amount the amount specified, either input or output, depending on tradeType
* @param tradeType whether the trade is an exact input or exact output swap
* @returns The route
*/
;
Trade.fromRoute =
/*#__PURE__*/
function () {
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(route, amount, tradeType) {
var inputAmount, outputAmount, tokenAmount, i, pool, _yield$pool$getOutput, _tokenAmount, _i, _pool, _yield$_pool$getInput;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
if (!(tradeType === sdkCore.TradeType.EXACT_INPUT)) {
_context3.next = 17;
break;
}
!amount.currency.equals(route.input) ? invariant(false, 'INPUT') : void 0;
// Account for trades that wrap/unwrap as a first step
tokenAmount = amountWithPathCurrency(amount, route.pools[0]);
i = 0;
case 4:
if (!(i < route.pools.length)) {
_context3.next = 13;
break;
}
pool = route.pools[i];
_context3.next = 8;
return pool.getOutputAmount(tokenAmount);
case 8:
_yield$pool$getOutput = _context3.sent;
tokenAmount = _yield$pool$getOutput[0];
case 10:
i++;
_context3.next = 4;
break;
case 13:
inputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
outputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.output, tokenAmount.numerator, tokenAmount.denominator);
_context3.next = 31;
break;
case 17:
!amount.currency.equals(route.output) ? invariant(false, 'OUTPUT') : void 0;
// Account for trades that wrap/unwrap as a last step
_tokenAmount = amountWithPathCurrency(amount, route.pools[route.pools.length - 1]);
_i = route.pools.length - 1;
case 20:
if (!(_i >= 0)) {
_context3.next = 29;
break;
}
_pool = route.pools[_i];
_context3.next = 24;
return _pool.getInputAmount(_tokenAmount);
case 24:
_yield$_pool$getInput = _context3.sent;
_tokenAmount = _yield$_pool$getInput[0];
case 26:
_i--;
_context3.next = 20;
break;
case 29:
inputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.input, _tokenAmount.numerator, _tokenAmount.denominator);
outputAmount = sdkCore.CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
case 31:
return _context3.abrupt("return", new Trade({
routes: [{
inputAmount: inputAmount,
outputAmount: outputAmount,
route: route
}],
tradeType: tradeType
}));
case 32:
case "end":
return _context3.stop();
}
}, _callee3);
}));
function fromRoute(_x5, _x6, _x7) {
return _fromRoute.apply(this, arguments);
}
return fromRoute;
}()
/**
* Constructs a trade from routes by simulating swaps
*
* @template TInput The input currency, either Ether or an ERC-20.
* @template TOutput The output currency, either Ether or an ERC-20.
* @template TTradeType The type of the trade, either exact in or exact out.
* @param routes the routes to swap through and how much of the amount should be routed through each
* @param tradeType whether the trade is an exact input or exact output swap
* @returns The trade
*/
;
Trade.fromRoutes =
/*#__PURE__*/
function () {
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(routes, tradeType) {
var swaps;
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
while (1) switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return Promise.all(routes.map(/*#__PURE__*/function () {
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref4) {
var amount, route, trade;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
amount = _ref4.amount, route = _ref4.route;
_context4.next = 3;
return Trade.fromRoute(route, amount, tradeType);
case 3:
trade = _context4.sent;
return _context4.abrupt("return", trade.swaps[0]);
case 5:
case "end":
return _context4.stop();
}
}, _callee4);
}));
return function (_x10) {
return _ref5.apply(this, arguments);
};
}()));
case 2:
swaps = _context5.sent;
return _context5.abrupt("return", new Trade({
routes: swaps,
tradeType: tradeType
}));
case 4:
case "end":
return _context5.stop();
}
}, _callee5);
}));
function fromRoutes(_x8, _x9) {
return _fromRoutes.apply(this, arguments);
}
return fromRoutes;
}()
/**
* Creates a trade without computing the result of swapping through the route. Us