@kittycorn-labs/v4-sdk 1.1.16 → 1.1.18
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/v4-sdk.esm.js
CHANGED
|
@@ -78,274 +78,115 @@ function _extends() {
|
|
|
78
78
|
function _inheritsLoose(t, o) {
|
|
79
79
|
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function h(r, e, n, o) {
|
|
109
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
110
|
-
a = Object.create(i.prototype);
|
|
111
|
-
return c(a, "_invoke", function (r, e, n) {
|
|
112
|
-
var o = 1;
|
|
113
|
-
return function (i, a) {
|
|
114
|
-
if (3 === o) throw Error("Generator is already running");
|
|
115
|
-
if (4 === o) {
|
|
116
|
-
if ("throw" === i) throw a;
|
|
117
|
-
return {
|
|
118
|
-
value: t,
|
|
119
|
-
done: !0
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
for (n.method = i, n.arg = a;;) {
|
|
123
|
-
var u = n.delegate;
|
|
124
|
-
if (u) {
|
|
125
|
-
var c = d(u, n);
|
|
126
|
-
if (c) {
|
|
127
|
-
if (c === f) continue;
|
|
128
|
-
return c;
|
|
129
|
-
}
|
|
81
|
+
function _regenerator() {
|
|
82
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
83
|
+
var e,
|
|
84
|
+
t,
|
|
85
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
86
|
+
n = r.iterator || "@@iterator",
|
|
87
|
+
o = r.toStringTag || "@@toStringTag";
|
|
88
|
+
function i(r, n, o, i) {
|
|
89
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
90
|
+
u = Object.create(c.prototype);
|
|
91
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
92
|
+
var i,
|
|
93
|
+
c,
|
|
94
|
+
u,
|
|
95
|
+
f = 0,
|
|
96
|
+
p = o || [],
|
|
97
|
+
y = !1,
|
|
98
|
+
G = {
|
|
99
|
+
p: 0,
|
|
100
|
+
n: 0,
|
|
101
|
+
v: e,
|
|
102
|
+
a: d,
|
|
103
|
+
f: d.bind(e, 4),
|
|
104
|
+
d: function (t, r) {
|
|
105
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
130
106
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
107
|
+
};
|
|
108
|
+
function d(r, n) {
|
|
109
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
110
|
+
var o,
|
|
111
|
+
i = p[t],
|
|
112
|
+
d = G.p,
|
|
113
|
+
l = i[2];
|
|
114
|
+
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));
|
|
115
|
+
}
|
|
116
|
+
if (o || r > 1) return a;
|
|
117
|
+
throw y = !0, n;
|
|
118
|
+
}
|
|
119
|
+
return function (o, p, l) {
|
|
120
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
121
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
122
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
123
|
+
try {
|
|
124
|
+
if (f = 2, i) {
|
|
125
|
+
if (c || (o = "next"), t = i[o]) {
|
|
126
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
127
|
+
if (!t.done) return t;
|
|
128
|
+
u = t.value, c < 2 && (c = 0);
|
|
129
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
130
|
+
i = e;
|
|
131
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
132
|
+
} catch (t) {
|
|
133
|
+
i = e, c = 1, u = t;
|
|
134
|
+
} finally {
|
|
135
|
+
f = 1;
|
|
143
136
|
}
|
|
144
|
-
"throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
|
|
145
137
|
}
|
|
138
|
+
return {
|
|
139
|
+
value: t,
|
|
140
|
+
done: y
|
|
141
|
+
};
|
|
146
142
|
};
|
|
147
|
-
}(r,
|
|
148
|
-
}
|
|
149
|
-
function s(t, r, e) {
|
|
150
|
-
try {
|
|
151
|
-
return {
|
|
152
|
-
type: "normal",
|
|
153
|
-
arg: t.call(r, e)
|
|
154
|
-
};
|
|
155
|
-
} catch (t) {
|
|
156
|
-
return {
|
|
157
|
-
type: "throw",
|
|
158
|
-
arg: t
|
|
159
|
-
};
|
|
160
|
-
}
|
|
143
|
+
}(r, o, i), !0), u;
|
|
161
144
|
}
|
|
162
|
-
|
|
163
|
-
var f = {};
|
|
145
|
+
var a = {};
|
|
164
146
|
function Generator() {}
|
|
165
147
|
function GeneratorFunction() {}
|
|
166
148
|
function GeneratorFunctionPrototype() {}
|
|
167
|
-
|
|
168
|
-
c(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
|
|
175
|
-
function g(t) {
|
|
176
|
-
["next", "throw", "return"].forEach(function (r) {
|
|
177
|
-
c(t, r, function (t) {
|
|
178
|
-
return this._invoke(r, t);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
function AsyncIterator(t, r) {
|
|
183
|
-
function e(o, i, a, u) {
|
|
184
|
-
var c = s(t[o], t, i);
|
|
185
|
-
if ("throw" !== c.type) {
|
|
186
|
-
var h = c.arg,
|
|
187
|
-
f = h.value;
|
|
188
|
-
return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
|
|
189
|
-
e("next", t, a, u);
|
|
190
|
-
}, function (t) {
|
|
191
|
-
e("throw", t, a, u);
|
|
192
|
-
}) : r.resolve(f).then(function (t) {
|
|
193
|
-
h.value = t, a(h);
|
|
194
|
-
}, function (t) {
|
|
195
|
-
return e("throw", t, a, u);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
u(c.arg);
|
|
199
|
-
}
|
|
200
|
-
var o;
|
|
201
|
-
c(this, "_invoke", function (t, n) {
|
|
202
|
-
function i() {
|
|
203
|
-
return new r(function (r, o) {
|
|
204
|
-
e(t, n, r, o);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
return o = o ? o.then(i, i) : i();
|
|
208
|
-
}, !0);
|
|
209
|
-
}
|
|
210
|
-
function d(r, e) {
|
|
211
|
-
var n = e.method,
|
|
212
|
-
o = r.i[n];
|
|
213
|
-
if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f;
|
|
214
|
-
var i = s(o, r.i, e.arg);
|
|
215
|
-
if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
|
|
216
|
-
var a = i.arg;
|
|
217
|
-
return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f);
|
|
218
|
-
}
|
|
219
|
-
function w(t) {
|
|
220
|
-
this.tryEntries.push(t);
|
|
221
|
-
}
|
|
222
|
-
function m(r) {
|
|
223
|
-
var e = r[4] || {};
|
|
224
|
-
e.type = "normal", e.arg = t, r[4] = e;
|
|
225
|
-
}
|
|
226
|
-
function Context(t) {
|
|
227
|
-
this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0);
|
|
149
|
+
t = Object.getPrototypeOf;
|
|
150
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
151
|
+
return this;
|
|
152
|
+
}), t),
|
|
153
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
154
|
+
function f(e) {
|
|
155
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
228
156
|
}
|
|
229
|
-
function
|
|
230
|
-
if (null != r) {
|
|
231
|
-
var e = r[i];
|
|
232
|
-
if (e) return e.call(r);
|
|
233
|
-
if ("function" == typeof r.next) return r;
|
|
234
|
-
if (!isNaN(r.length)) {
|
|
235
|
-
var o = -1,
|
|
236
|
-
a = function e() {
|
|
237
|
-
for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e;
|
|
238
|
-
return e.value = t, e.done = !0, e;
|
|
239
|
-
};
|
|
240
|
-
return a.next = a;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
throw new TypeError(typeof r + " is not iterable");
|
|
244
|
-
}
|
|
245
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) {
|
|
246
|
-
var r = "function" == typeof t && t.constructor;
|
|
247
|
-
return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
|
|
248
|
-
}, r.mark = function (t) {
|
|
249
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
|
|
250
|
-
}, r.awrap = function (t) {
|
|
251
|
-
return {
|
|
252
|
-
__await: t
|
|
253
|
-
};
|
|
254
|
-
}, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
|
|
157
|
+
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 () {
|
|
255
158
|
return this;
|
|
256
|
-
}),
|
|
257
|
-
void 0 === i && (i = Promise);
|
|
258
|
-
var a = new AsyncIterator(h(t, e, n, o), i);
|
|
259
|
-
return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
|
|
260
|
-
return t.done ? t.value : a.next();
|
|
261
|
-
});
|
|
262
|
-
}, g(v), c(v, u, "Generator"), c(v, i, function () {
|
|
263
|
-
return this;
|
|
264
|
-
}), c(v, "toString", function () {
|
|
159
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
265
160
|
return "[object Generator]";
|
|
266
|
-
}),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return function t() {
|
|
271
|
-
for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t;
|
|
272
|
-
return t.done = !0, t;
|
|
161
|
+
}), (_regenerator = function () {
|
|
162
|
+
return {
|
|
163
|
+
w: i,
|
|
164
|
+
m: f
|
|
273
165
|
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
u = this.prev,
|
|
295
|
-
c = i[1],
|
|
296
|
-
h = i[2];
|
|
297
|
-
if (-1 === i[0]) return n("end"), !1;
|
|
298
|
-
if (!c && !h) throw Error("try statement without catch or finally");
|
|
299
|
-
if (null != i[0] && i[0] <= u) {
|
|
300
|
-
if (u < c) return this.method = "next", this.arg = t, n(c), !0;
|
|
301
|
-
if (u < h) return n(h), !1;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
abrupt: function (t, r) {
|
|
306
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
307
|
-
var n = this.tryEntries[e];
|
|
308
|
-
if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
|
|
309
|
-
var o = n;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
|
|
314
|
-
var i = o ? o[4] : {};
|
|
315
|
-
return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
|
|
316
|
-
},
|
|
317
|
-
complete: function (t, r) {
|
|
318
|
-
if ("throw" === t.type) throw t.arg;
|
|
319
|
-
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 && r && (this.next = r), f;
|
|
320
|
-
},
|
|
321
|
-
finish: function (t) {
|
|
322
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
323
|
-
var e = this.tryEntries[r];
|
|
324
|
-
if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
catch: function (t) {
|
|
328
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
329
|
-
var e = this.tryEntries[r];
|
|
330
|
-
if (e[0] === t) {
|
|
331
|
-
var n = e[4];
|
|
332
|
-
if ("throw" === n.type) {
|
|
333
|
-
var o = n.arg;
|
|
334
|
-
m(e);
|
|
335
|
-
}
|
|
336
|
-
return o;
|
|
337
|
-
}
|
|
166
|
+
})();
|
|
167
|
+
}
|
|
168
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
169
|
+
var i = Object.defineProperty;
|
|
170
|
+
try {
|
|
171
|
+
i({}, "", {});
|
|
172
|
+
} catch (e) {
|
|
173
|
+
i = 0;
|
|
174
|
+
}
|
|
175
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
176
|
+
if (r) i ? i(e, r, {
|
|
177
|
+
value: n,
|
|
178
|
+
enumerable: !t,
|
|
179
|
+
configurable: !t,
|
|
180
|
+
writable: !t
|
|
181
|
+
}) : e[r] = n;else {
|
|
182
|
+
function o(r, n) {
|
|
183
|
+
_regeneratorDefine(e, r, function (e) {
|
|
184
|
+
return this._invoke(r, n, e);
|
|
185
|
+
});
|
|
338
186
|
}
|
|
339
|
-
|
|
340
|
-
},
|
|
341
|
-
delegateYield: function (r, e, n) {
|
|
342
|
-
return this.delegate = {
|
|
343
|
-
i: x(r),
|
|
344
|
-
r: e,
|
|
345
|
-
n: n
|
|
346
|
-
}, "next" === this.method && (this.arg = t), f;
|
|
187
|
+
o("next", 0), o("throw", 1), o("return", 2);
|
|
347
188
|
}
|
|
348
|
-
}, r;
|
|
189
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
349
190
|
}
|
|
350
191
|
function _setPrototypeOf(t, e) {
|
|
351
192
|
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
@@ -600,26 +441,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
600
441
|
_proto.getOutputAmount =
|
|
601
442
|
/*#__PURE__*/
|
|
602
443
|
function () {
|
|
603
|
-
var _getOutputAmount = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
444
|
+
var _getOutputAmount = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(inputAmount, sqrtPriceLimitX96) {
|
|
604
445
|
var zeroForOne, _yield$this$swap, outputAmount, sqrtRatioX96, liquidity, tickCurrent, outputCurrency;
|
|
605
|
-
return
|
|
606
|
-
while (1) switch (_context.
|
|
446
|
+
return _regenerator().w(function (_context) {
|
|
447
|
+
while (1) switch (_context.n) {
|
|
607
448
|
case 0:
|
|
608
449
|
!this.involvesCurrency(inputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CURRENCY') : invariant(false) : void 0;
|
|
609
450
|
zeroForOne = inputAmount.currency.equals(this.currency0);
|
|
610
|
-
_context.
|
|
451
|
+
_context.n = 1;
|
|
611
452
|
return this.swap(zeroForOne, inputAmount.quotient, sqrtPriceLimitX96);
|
|
612
|
-
case
|
|
613
|
-
_yield$this$swap = _context.
|
|
453
|
+
case 1:
|
|
454
|
+
_yield$this$swap = _context.v;
|
|
614
455
|
outputAmount = _yield$this$swap.amountCalculated;
|
|
615
456
|
sqrtRatioX96 = _yield$this$swap.sqrtRatioX96;
|
|
616
457
|
liquidity = _yield$this$swap.liquidity;
|
|
617
458
|
tickCurrent = _yield$this$swap.tickCurrent;
|
|
618
459
|
outputCurrency = zeroForOne ? this.currency1 : this.currency0;
|
|
619
|
-
return _context.
|
|
620
|
-
case 11:
|
|
621
|
-
case "end":
|
|
622
|
-
return _context.stop();
|
|
460
|
+
return _context.a(2, [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)]);
|
|
623
461
|
}
|
|
624
462
|
}, _callee, this);
|
|
625
463
|
}));
|
|
@@ -639,26 +477,23 @@ var Pool = /*#__PURE__*/function () {
|
|
|
639
477
|
_proto.getInputAmount =
|
|
640
478
|
/*#__PURE__*/
|
|
641
479
|
function () {
|
|
642
|
-
var _getInputAmount = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
480
|
+
var _getInputAmount = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(outputAmount, sqrtPriceLimitX96) {
|
|
643
481
|
var zeroForOne, _yield$this$swap2, inputAmount, sqrtRatioX96, liquidity, tickCurrent, inputCurrency;
|
|
644
|
-
return
|
|
645
|
-
while (1) switch (_context2.
|
|
482
|
+
return _regenerator().w(function (_context2) {
|
|
483
|
+
while (1) switch (_context2.n) {
|
|
646
484
|
case 0:
|
|
647
485
|
!this.involvesCurrency(outputAmount.currency) ? process.env.NODE_ENV !== "production" ? invariant(false, 'CURRENCY') : invariant(false) : void 0;
|
|
648
486
|
zeroForOne = outputAmount.currency.equals(this.currency1);
|
|
649
|
-
_context2.
|
|
487
|
+
_context2.n = 1;
|
|
650
488
|
return this.swap(zeroForOne, JSBI.multiply(outputAmount.quotient, NEGATIVE_ONE), sqrtPriceLimitX96);
|
|
651
|
-
case
|
|
652
|
-
_yield$this$swap2 = _context2.
|
|
489
|
+
case 1:
|
|
490
|
+
_yield$this$swap2 = _context2.v;
|
|
653
491
|
inputAmount = _yield$this$swap2.amountCalculated;
|
|
654
492
|
sqrtRatioX96 = _yield$this$swap2.sqrtRatioX96;
|
|
655
493
|
liquidity = _yield$this$swap2.liquidity;
|
|
656
494
|
tickCurrent = _yield$this$swap2.tickCurrent;
|
|
657
495
|
inputCurrency = zeroForOne ? this.currency0 : this.currency1;
|
|
658
|
-
return _context2.
|
|
659
|
-
case 11:
|
|
660
|
-
case "end":
|
|
661
|
-
return _context2.stop();
|
|
496
|
+
return _context2.a(2, [CurrencyAmount.fromRawAmount(inputCurrency, inputAmount), new Pool(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider)]);
|
|
662
497
|
}
|
|
663
498
|
}, _callee2, this);
|
|
664
499
|
}));
|
|
@@ -681,20 +516,19 @@ var Pool = /*#__PURE__*/function () {
|
|
|
681
516
|
_proto.swap =
|
|
682
517
|
/*#__PURE__*/
|
|
683
518
|
function () {
|
|
684
|
-
var _swap = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
685
|
-
return
|
|
686
|
-
while (1) switch (_context3.
|
|
519
|
+
var _swap = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(zeroForOne, amountSpecified, sqrtPriceLimitX96) {
|
|
520
|
+
return _regenerator().w(function (_context3) {
|
|
521
|
+
while (1) switch (_context3.n) {
|
|
687
522
|
case 0:
|
|
688
523
|
if (this.hookImpactsSwap()) {
|
|
689
|
-
_context3.
|
|
524
|
+
_context3.n = 1;
|
|
690
525
|
break;
|
|
691
526
|
}
|
|
692
|
-
return _context3.
|
|
693
|
-
case
|
|
527
|
+
return _context3.a(2, v3Swap(JSBI.BigInt(this.fee), this.sqrtRatioX96, this.tickCurrent, this.liquidity, this.tickSpacing, this.tickDataProvider, zeroForOne, amountSpecified, sqrtPriceLimitX96));
|
|
528
|
+
case 1:
|
|
694
529
|
throw new Error('Unsupported hook');
|
|
695
|
-
case
|
|
696
|
-
|
|
697
|
-
return _context3.stop();
|
|
530
|
+
case 2:
|
|
531
|
+
return _context3.a(2);
|
|
698
532
|
}
|
|
699
533
|
}, _callee3, this);
|
|
700
534
|
}));
|
|
@@ -764,10 +598,10 @@ var TWBTC_MAINNET = /*#__PURE__*/new Token(ChainId.MAINNET, '0x137a906E06EC20808
|
|
|
764
598
|
// Sepolia
|
|
765
599
|
var TUSDC_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '0x1E271DB8D8B446A0DEe8e9D774f4213e9Bc1C6ba', 6, 'Kittycorn Tokenize USDC', 'tUSDC');
|
|
766
600
|
var TUSDT_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '0x137a906E06EC20808c8F156F9024196427429220', 6, 'Kittycorn Tokenize USDT', 'tUSDT');
|
|
767
|
-
var TWETH_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '
|
|
768
|
-
var TWBTC_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '
|
|
769
|
-
var TLINK_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '
|
|
770
|
-
var TAAVE_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '
|
|
601
|
+
var TWETH_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '0x54f4d76DaB01190A32FB0a5da441Be85e3Cef937', 18, 'Kittycorn Tokenize WETH', 'tWETH');
|
|
602
|
+
var TWBTC_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '0x67332E6e2fbB793B822f3c2d7ff8BE9F07F1eAd9', 8, 'Kittycorn Tokenize WBTC', 'tWBTC');
|
|
603
|
+
var TLINK_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '0x7ddE6BD33B4E6eB1d6F0519f4CF65deEB162dd86', 18, 'Kittycorn Tokenize LINK', 'tLINK');
|
|
604
|
+
var TAAVE_SEPOLIA = /*#__PURE__*/new Token(ChainId.SEPOLIA, '0x1289c2dC45a0eA5E67F6ffa2B601D23d66547d3E', 18, 'Kittycorn Tokenize AAVE', 'tAAVE');
|
|
771
605
|
var BASE_TOKENIZE_UNDERLYING = (_BASE_TOKENIZE_UNDERL = {}, _BASE_TOKENIZE_UNDERL[ChainId.MAINNET] = [{
|
|
772
606
|
tokenize: TUSDC_MAINNET,
|
|
773
607
|
underlying: /*#__PURE__*/new Token(ChainId.MAINNET, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6, 'USDC', 'USD//C')
|
|
@@ -1023,14 +857,11 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1023
857
|
Trade.exactIn =
|
|
1024
858
|
/*#__PURE__*/
|
|
1025
859
|
function () {
|
|
1026
|
-
var _exactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
1027
|
-
return
|
|
1028
|
-
while (1) switch (_context.
|
|
860
|
+
var _exactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(route, amountIn) {
|
|
861
|
+
return _regenerator().w(function (_context) {
|
|
862
|
+
while (1) switch (_context.n) {
|
|
1029
863
|
case 0:
|
|
1030
|
-
return _context.
|
|
1031
|
-
case 1:
|
|
1032
|
-
case "end":
|
|
1033
|
-
return _context.stop();
|
|
864
|
+
return _context.a(2, Trade.fromRoute(route, amountIn, TradeType.EXACT_INPUT));
|
|
1034
865
|
}
|
|
1035
866
|
}, _callee);
|
|
1036
867
|
}));
|
|
@@ -1051,14 +882,11 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1051
882
|
Trade.exactOut =
|
|
1052
883
|
/*#__PURE__*/
|
|
1053
884
|
function () {
|
|
1054
|
-
var _exactOut = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
1055
|
-
return
|
|
1056
|
-
while (1) switch (_context2.
|
|
885
|
+
var _exactOut = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(route, amountOut) {
|
|
886
|
+
return _regenerator().w(function (_context2) {
|
|
887
|
+
while (1) switch (_context2.n) {
|
|
1057
888
|
case 0:
|
|
1058
|
-
return _context2.
|
|
1059
|
-
case 1:
|
|
1060
|
-
case "end":
|
|
1061
|
-
return _context2.stop();
|
|
889
|
+
return _context2.a(2, Trade.fromRoute(route, amountOut, TradeType.EXACT_OUTPUT));
|
|
1062
890
|
}
|
|
1063
891
|
}, _callee2);
|
|
1064
892
|
}));
|
|
@@ -1081,64 +909,64 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1081
909
|
Trade.fromRoute =
|
|
1082
910
|
/*#__PURE__*/
|
|
1083
911
|
function () {
|
|
1084
|
-
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
912
|
+
var _fromRoute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(route, amount, tradeType) {
|
|
1085
913
|
var inputAmount, outputAmount, tokenAmount, i, pool, _yield$pool$getOutput, _tokenAmount, _i, _pool, _yield$_pool$getInput;
|
|
1086
|
-
return
|
|
1087
|
-
while (1) switch (_context3.
|
|
914
|
+
return _regenerator().w(function (_context3) {
|
|
915
|
+
while (1) switch (_context3.n) {
|
|
1088
916
|
case 0:
|
|
1089
917
|
if (!(tradeType === TradeType.EXACT_INPUT)) {
|
|
1090
|
-
_context3.
|
|
918
|
+
_context3.n = 5;
|
|
1091
919
|
break;
|
|
1092
920
|
}
|
|
1093
921
|
!amount.currency.equals(route.input) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INPUT') : invariant(false) : void 0;
|
|
1094
922
|
// Account for trades that wrap/unwrap as a first step
|
|
1095
923
|
tokenAmount = amountWithPathCurrency(amount, route.pools[0]);
|
|
1096
924
|
i = 0;
|
|
1097
|
-
case
|
|
925
|
+
case 1:
|
|
1098
926
|
if (!(i < route.pools.length)) {
|
|
1099
|
-
_context3.
|
|
927
|
+
_context3.n = 4;
|
|
1100
928
|
break;
|
|
1101
929
|
}
|
|
1102
930
|
pool = route.pools[i];
|
|
1103
|
-
_context3.
|
|
931
|
+
_context3.n = 2;
|
|
1104
932
|
return pool.getOutputAmount(tokenAmount);
|
|
1105
|
-
case
|
|
1106
|
-
_yield$pool$getOutput = _context3.
|
|
933
|
+
case 2:
|
|
934
|
+
_yield$pool$getOutput = _context3.v;
|
|
1107
935
|
tokenAmount = _yield$pool$getOutput[0];
|
|
1108
|
-
case
|
|
936
|
+
case 3:
|
|
1109
937
|
i++;
|
|
1110
|
-
_context3.
|
|
938
|
+
_context3.n = 1;
|
|
1111
939
|
break;
|
|
1112
|
-
case
|
|
940
|
+
case 4:
|
|
1113
941
|
inputAmount = CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
|
|
1114
942
|
outputAmount = CurrencyAmount.fromFractionalAmount(route.output, tokenAmount.numerator, tokenAmount.denominator);
|
|
1115
|
-
_context3.
|
|
943
|
+
_context3.n = 10;
|
|
1116
944
|
break;
|
|
1117
|
-
case
|
|
945
|
+
case 5:
|
|
1118
946
|
!amount.currency.equals(route.output) ? process.env.NODE_ENV !== "production" ? invariant(false, 'OUTPUT') : invariant(false) : void 0;
|
|
1119
947
|
// Account for trades that wrap/unwrap as a last step
|
|
1120
948
|
_tokenAmount = amountWithPathCurrency(amount, route.pools[route.pools.length - 1]);
|
|
1121
949
|
_i = route.pools.length - 1;
|
|
1122
|
-
case
|
|
950
|
+
case 6:
|
|
1123
951
|
if (!(_i >= 0)) {
|
|
1124
|
-
_context3.
|
|
952
|
+
_context3.n = 9;
|
|
1125
953
|
break;
|
|
1126
954
|
}
|
|
1127
955
|
_pool = route.pools[_i];
|
|
1128
|
-
_context3.
|
|
956
|
+
_context3.n = 7;
|
|
1129
957
|
return _pool.getInputAmount(_tokenAmount);
|
|
1130
|
-
case
|
|
1131
|
-
_yield$_pool$getInput = _context3.
|
|
958
|
+
case 7:
|
|
959
|
+
_yield$_pool$getInput = _context3.v;
|
|
1132
960
|
_tokenAmount = _yield$_pool$getInput[0];
|
|
1133
|
-
case
|
|
961
|
+
case 8:
|
|
1134
962
|
_i--;
|
|
1135
|
-
_context3.
|
|
963
|
+
_context3.n = 6;
|
|
1136
964
|
break;
|
|
1137
|
-
case
|
|
965
|
+
case 9:
|
|
1138
966
|
inputAmount = CurrencyAmount.fromFractionalAmount(route.input, _tokenAmount.numerator, _tokenAmount.denominator);
|
|
1139
967
|
outputAmount = CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
|
|
1140
|
-
case
|
|
1141
|
-
return _context3.
|
|
968
|
+
case 10:
|
|
969
|
+
return _context3.a(2, new Trade({
|
|
1142
970
|
routes: [{
|
|
1143
971
|
inputAmount: inputAmount,
|
|
1144
972
|
outputAmount: outputAmount,
|
|
@@ -1146,9 +974,6 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1146
974
|
}],
|
|
1147
975
|
tradeType: tradeType
|
|
1148
976
|
}));
|
|
1149
|
-
case 32:
|
|
1150
|
-
case "end":
|
|
1151
|
-
return _context3.stop();
|
|
1152
977
|
}
|
|
1153
978
|
}, _callee3);
|
|
1154
979
|
}));
|
|
@@ -1171,27 +996,24 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1171
996
|
Trade.fromRoutes =
|
|
1172
997
|
/*#__PURE__*/
|
|
1173
998
|
function () {
|
|
1174
|
-
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
999
|
+
var _fromRoutes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(routes, tradeType) {
|
|
1175
1000
|
var swaps;
|
|
1176
|
-
return
|
|
1177
|
-
while (1) switch (_context5.
|
|
1001
|
+
return _regenerator().w(function (_context5) {
|
|
1002
|
+
while (1) switch (_context5.n) {
|
|
1178
1003
|
case 0:
|
|
1179
|
-
_context5.
|
|
1004
|
+
_context5.n = 1;
|
|
1180
1005
|
return Promise.all(routes.map(/*#__PURE__*/function () {
|
|
1181
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/
|
|
1006
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref5) {
|
|
1182
1007
|
var amount, route, trade;
|
|
1183
|
-
return
|
|
1184
|
-
while (1) switch (_context4.
|
|
1008
|
+
return _regenerator().w(function (_context4) {
|
|
1009
|
+
while (1) switch (_context4.n) {
|
|
1185
1010
|
case 0:
|
|
1186
1011
|
amount = _ref5.amount, route = _ref5.route;
|
|
1187
|
-
_context4.
|
|
1012
|
+
_context4.n = 1;
|
|
1188
1013
|
return Trade.fromRoute(route, amount, tradeType);
|
|
1189
|
-
case
|
|
1190
|
-
trade = _context4.
|
|
1191
|
-
return _context4.
|
|
1192
|
-
case 5:
|
|
1193
|
-
case "end":
|
|
1194
|
-
return _context4.stop();
|
|
1014
|
+
case 1:
|
|
1015
|
+
trade = _context4.v;
|
|
1016
|
+
return _context4.a(2, trade.swaps[0]);
|
|
1195
1017
|
}
|
|
1196
1018
|
}, _callee4);
|
|
1197
1019
|
}));
|
|
@@ -1199,15 +1021,12 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1199
1021
|
return _ref6.apply(this, arguments);
|
|
1200
1022
|
};
|
|
1201
1023
|
}()));
|
|
1202
|
-
case
|
|
1203
|
-
swaps = _context5.
|
|
1204
|
-
return _context5.
|
|
1024
|
+
case 1:
|
|
1025
|
+
swaps = _context5.v;
|
|
1026
|
+
return _context5.a(2, new Trade({
|
|
1205
1027
|
routes: swaps,
|
|
1206
1028
|
tradeType: tradeType
|
|
1207
1029
|
}));
|
|
1208
|
-
case 4:
|
|
1209
|
-
case "end":
|
|
1210
|
-
return _context5.stop();
|
|
1211
1030
|
}
|
|
1212
1031
|
}, _callee5);
|
|
1213
1032
|
}));
|
|
@@ -1308,12 +1127,12 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1308
1127
|
Trade.bestTradeExactIn =
|
|
1309
1128
|
/*#__PURE__*/
|
|
1310
1129
|
function () {
|
|
1311
|
-
var _bestTradeExactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
1130
|
+
var _bestTradeExactIn = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(pools, currencyAmountIn, currencyOut, _temp,
|
|
1312
1131
|
// used in recursion.
|
|
1313
1132
|
currentPools, nextAmountIn, bestTrades) {
|
|
1314
|
-
var _ref7, _ref7$maxNumResults, maxNumResults, _ref7$maxHops, maxHops, amountIn, i, pool, amountOut, _yield$pool$getOutput2, poolsExcludingThisPool;
|
|
1315
|
-
return
|
|
1316
|
-
while (1) switch (_context6.
|
|
1133
|
+
var _ref7, _ref7$maxNumResults, maxNumResults, _ref7$maxHops, maxHops, amountIn, i, pool, amountOut, _yield$pool$getOutput2, poolsExcludingThisPool, _t, _t2, _t3, _t4, _t5, _t6;
|
|
1134
|
+
return _regenerator().w(function (_context6) {
|
|
1135
|
+
while (1) switch (_context6.n) {
|
|
1317
1136
|
case 0:
|
|
1318
1137
|
_ref7 = _temp === void 0 ? {} : _temp, _ref7$maxNumResults = _ref7.maxNumResults, maxNumResults = _ref7$maxNumResults === void 0 ? 3 : _ref7$maxNumResults, _ref7$maxHops = _ref7.maxHops, maxHops = _ref7$maxHops === void 0 ? 3 : _ref7$maxHops;
|
|
1319
1138
|
if (currentPools === void 0) {
|
|
@@ -1330,75 +1149,72 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1330
1149
|
!(currencyAmountIn === nextAmountIn || currentPools.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INVALID_RECURSION') : invariant(false) : void 0;
|
|
1331
1150
|
amountIn = nextAmountIn;
|
|
1332
1151
|
i = 0;
|
|
1333
|
-
case
|
|
1152
|
+
case 1:
|
|
1334
1153
|
if (!(i < pools.length)) {
|
|
1335
|
-
_context6.
|
|
1154
|
+
_context6.n = 11;
|
|
1336
1155
|
break;
|
|
1337
1156
|
}
|
|
1338
1157
|
pool = pools[i]; // pool irrelevant
|
|
1339
1158
|
if (!(!pool.currency0.equals(amountIn.currency) && !pool.currency1.equals(amountIn.currency))) {
|
|
1340
|
-
_context6.
|
|
1159
|
+
_context6.n = 2;
|
|
1341
1160
|
break;
|
|
1342
1161
|
}
|
|
1343
|
-
return _context6.
|
|
1344
|
-
case
|
|
1162
|
+
return _context6.a(3, 10);
|
|
1163
|
+
case 2:
|
|
1345
1164
|
amountOut = void 0;
|
|
1346
|
-
_context6.
|
|
1347
|
-
_context6.
|
|
1165
|
+
_context6.p = 3;
|
|
1166
|
+
_context6.n = 4;
|
|
1348
1167
|
return pool.getOutputAmount(amountIn);
|
|
1349
|
-
case
|
|
1350
|
-
_yield$pool$getOutput2 = _context6.
|
|
1168
|
+
case 4:
|
|
1169
|
+
_yield$pool$getOutput2 = _context6.v;
|
|
1351
1170
|
amountOut = _yield$pool$getOutput2[0];
|
|
1352
|
-
_context6.
|
|
1171
|
+
_context6.n = 7;
|
|
1353
1172
|
break;
|
|
1354
|
-
case
|
|
1355
|
-
_context6.
|
|
1356
|
-
|
|
1357
|
-
if (!
|
|
1358
|
-
_context6.
|
|
1173
|
+
case 5:
|
|
1174
|
+
_context6.p = 5;
|
|
1175
|
+
_t = _context6.v;
|
|
1176
|
+
if (!_t.isInsufficientInputAmountError) {
|
|
1177
|
+
_context6.n = 6;
|
|
1359
1178
|
break;
|
|
1360
1179
|
}
|
|
1361
|
-
return _context6.
|
|
1362
|
-
case
|
|
1363
|
-
throw
|
|
1364
|
-
case
|
|
1180
|
+
return _context6.a(3, 10);
|
|
1181
|
+
case 6:
|
|
1182
|
+
throw _t;
|
|
1183
|
+
case 7:
|
|
1365
1184
|
if (!amountOut.currency.equals(currencyOut)) {
|
|
1366
|
-
_context6.
|
|
1185
|
+
_context6.n = 9;
|
|
1367
1186
|
break;
|
|
1368
1187
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
_context6.
|
|
1188
|
+
_t2 = sortedInsert;
|
|
1189
|
+
_t3 = bestTrades;
|
|
1190
|
+
_context6.n = 8;
|
|
1372
1191
|
return Trade.fromRoute(new Route([].concat(currentPools, [pool]), currencyAmountIn.currency, currencyOut), currencyAmountIn, TradeType.EXACT_INPUT);
|
|
1373
|
-
case
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
(
|
|
1378
|
-
_context6.
|
|
1192
|
+
case 8:
|
|
1193
|
+
_t4 = _context6.v;
|
|
1194
|
+
_t5 = maxNumResults;
|
|
1195
|
+
_t6 = tradeComparator;
|
|
1196
|
+
_t2(_t3, _t4, _t5, _t6);
|
|
1197
|
+
_context6.n = 10;
|
|
1379
1198
|
break;
|
|
1380
|
-
case
|
|
1199
|
+
case 9:
|
|
1381
1200
|
if (!(maxHops > 1 && pools.length > 1)) {
|
|
1382
|
-
_context6.
|
|
1201
|
+
_context6.n = 10;
|
|
1383
1202
|
break;
|
|
1384
1203
|
}
|
|
1385
1204
|
poolsExcludingThisPool = pools.slice(0, i).concat(pools.slice(i + 1, pools.length)); // otherwise, consider all the other paths that lead from this currency as long as we have not exceeded maxHops
|
|
1386
|
-
_context6.
|
|
1205
|
+
_context6.n = 10;
|
|
1387
1206
|
return Trade.bestTradeExactIn(poolsExcludingThisPool, currencyAmountIn, currencyOut, {
|
|
1388
1207
|
maxNumResults: maxNumResults,
|
|
1389
1208
|
maxHops: maxHops - 1
|
|
1390
1209
|
}, [].concat(currentPools, [pool]), amountOut, bestTrades);
|
|
1391
|
-
case
|
|
1210
|
+
case 10:
|
|
1392
1211
|
i++;
|
|
1393
|
-
_context6.
|
|
1212
|
+
_context6.n = 1;
|
|
1394
1213
|
break;
|
|
1395
|
-
case
|
|
1396
|
-
return _context6.
|
|
1397
|
-
case 46:
|
|
1398
|
-
case "end":
|
|
1399
|
-
return _context6.stop();
|
|
1214
|
+
case 11:
|
|
1215
|
+
return _context6.a(2, bestTrades);
|
|
1400
1216
|
}
|
|
1401
|
-
}, _callee6, null, [[
|
|
1217
|
+
}, _callee6, null, [[3, 5]]);
|
|
1402
1218
|
}));
|
|
1403
1219
|
function bestTradeExactIn(_x1, _x10, _x11, _x12, _x13, _x14, _x15) {
|
|
1404
1220
|
return _bestTradeExactIn.apply(this, arguments);
|
|
@@ -1425,12 +1241,12 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1425
1241
|
Trade.bestTradeExactOut =
|
|
1426
1242
|
/*#__PURE__*/
|
|
1427
1243
|
function () {
|
|
1428
|
-
var _bestTradeExactOut = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
1244
|
+
var _bestTradeExactOut = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(pools, currencyIn, currencyAmountOut, _temp2,
|
|
1429
1245
|
// used in recursion.
|
|
1430
1246
|
currentPools, nextAmountOut, bestTrades) {
|
|
1431
|
-
var _ref8, _ref8$maxNumResults, maxNumResults, _ref8$maxHops, maxHops, amountOut, i, pool, amountIn, _yield$pool$getInputA, poolsExcludingThisPool;
|
|
1432
|
-
return
|
|
1433
|
-
while (1) switch (_context7.
|
|
1247
|
+
var _ref8, _ref8$maxNumResults, maxNumResults, _ref8$maxHops, maxHops, amountOut, i, pool, amountIn, _yield$pool$getInputA, poolsExcludingThisPool, _t7, _t8, _t9, _t0, _t1, _t10;
|
|
1248
|
+
return _regenerator().w(function (_context7) {
|
|
1249
|
+
while (1) switch (_context7.n) {
|
|
1434
1250
|
case 0:
|
|
1435
1251
|
_ref8 = _temp2 === void 0 ? {} : _temp2, _ref8$maxNumResults = _ref8.maxNumResults, maxNumResults = _ref8$maxNumResults === void 0 ? 3 : _ref8$maxNumResults, _ref8$maxHops = _ref8.maxHops, maxHops = _ref8$maxHops === void 0 ? 3 : _ref8$maxHops;
|
|
1436
1252
|
if (currentPools === void 0) {
|
|
@@ -1447,75 +1263,72 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1447
1263
|
!(currencyAmountOut === nextAmountOut || currentPools.length > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, 'INVALID_RECURSION') : invariant(false) : void 0;
|
|
1448
1264
|
amountOut = nextAmountOut;
|
|
1449
1265
|
i = 0;
|
|
1450
|
-
case
|
|
1266
|
+
case 1:
|
|
1451
1267
|
if (!(i < pools.length)) {
|
|
1452
|
-
_context7.
|
|
1268
|
+
_context7.n = 11;
|
|
1453
1269
|
break;
|
|
1454
1270
|
}
|
|
1455
1271
|
pool = pools[i]; // pool irrelevant
|
|
1456
1272
|
if (!(!pool.currency0.equals(amountOut.currency) && !pool.currency1.equals(amountOut.currency))) {
|
|
1457
|
-
_context7.
|
|
1273
|
+
_context7.n = 2;
|
|
1458
1274
|
break;
|
|
1459
1275
|
}
|
|
1460
|
-
return _context7.
|
|
1461
|
-
case
|
|
1276
|
+
return _context7.a(3, 10);
|
|
1277
|
+
case 2:
|
|
1462
1278
|
amountIn = void 0;
|
|
1463
|
-
_context7.
|
|
1464
|
-
_context7.
|
|
1279
|
+
_context7.p = 3;
|
|
1280
|
+
_context7.n = 4;
|
|
1465
1281
|
return pool.getInputAmount(amountOut);
|
|
1466
|
-
case
|
|
1467
|
-
_yield$pool$getInputA = _context7.
|
|
1282
|
+
case 4:
|
|
1283
|
+
_yield$pool$getInputA = _context7.v;
|
|
1468
1284
|
amountIn = _yield$pool$getInputA[0];
|
|
1469
|
-
_context7.
|
|
1285
|
+
_context7.n = 7;
|
|
1470
1286
|
break;
|
|
1471
|
-
case
|
|
1472
|
-
_context7.
|
|
1473
|
-
|
|
1474
|
-
if (!
|
|
1475
|
-
_context7.
|
|
1287
|
+
case 5:
|
|
1288
|
+
_context7.p = 5;
|
|
1289
|
+
_t7 = _context7.v;
|
|
1290
|
+
if (!_t7.isInsufficientReservesError) {
|
|
1291
|
+
_context7.n = 6;
|
|
1476
1292
|
break;
|
|
1477
1293
|
}
|
|
1478
|
-
return _context7.
|
|
1479
|
-
case
|
|
1480
|
-
throw
|
|
1481
|
-
case
|
|
1294
|
+
return _context7.a(3, 10);
|
|
1295
|
+
case 6:
|
|
1296
|
+
throw _t7;
|
|
1297
|
+
case 7:
|
|
1482
1298
|
if (!amountIn.currency.equals(currencyIn)) {
|
|
1483
|
-
_context7.
|
|
1299
|
+
_context7.n = 9;
|
|
1484
1300
|
break;
|
|
1485
1301
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
_context7.
|
|
1302
|
+
_t8 = sortedInsert;
|
|
1303
|
+
_t9 = bestTrades;
|
|
1304
|
+
_context7.n = 8;
|
|
1489
1305
|
return Trade.fromRoute(new Route([pool].concat(currentPools), currencyIn, currencyAmountOut.currency), currencyAmountOut, TradeType.EXACT_OUTPUT);
|
|
1490
|
-
case
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
(
|
|
1495
|
-
_context7.
|
|
1306
|
+
case 8:
|
|
1307
|
+
_t0 = _context7.v;
|
|
1308
|
+
_t1 = maxNumResults;
|
|
1309
|
+
_t10 = tradeComparator;
|
|
1310
|
+
_t8(_t9, _t0, _t1, _t10);
|
|
1311
|
+
_context7.n = 10;
|
|
1496
1312
|
break;
|
|
1497
|
-
case
|
|
1313
|
+
case 9:
|
|
1498
1314
|
if (!(maxHops > 1 && pools.length > 1)) {
|
|
1499
|
-
_context7.
|
|
1315
|
+
_context7.n = 10;
|
|
1500
1316
|
break;
|
|
1501
1317
|
}
|
|
1502
1318
|
poolsExcludingThisPool = pools.slice(0, i).concat(pools.slice(i + 1, pools.length)); // otherwise, consider all the other paths that arrive at this currency as long as we have not exceeded maxHops
|
|
1503
|
-
_context7.
|
|
1319
|
+
_context7.n = 10;
|
|
1504
1320
|
return Trade.bestTradeExactOut(poolsExcludingThisPool, currencyIn, currencyAmountOut, {
|
|
1505
1321
|
maxNumResults: maxNumResults,
|
|
1506
1322
|
maxHops: maxHops - 1
|
|
1507
1323
|
}, [pool].concat(currentPools), amountIn, bestTrades);
|
|
1508
|
-
case
|
|
1324
|
+
case 10:
|
|
1509
1325
|
i++;
|
|
1510
|
-
_context7.
|
|
1326
|
+
_context7.n = 1;
|
|
1511
1327
|
break;
|
|
1512
|
-
case
|
|
1513
|
-
return _context7.
|
|
1514
|
-
case 46:
|
|
1515
|
-
case "end":
|
|
1516
|
-
return _context7.stop();
|
|
1328
|
+
case 11:
|
|
1329
|
+
return _context7.a(2, bestTrades);
|
|
1517
1330
|
}
|
|
1518
|
-
}, _callee7, null, [[
|
|
1331
|
+
}, _callee7, null, [[3, 5]]);
|
|
1519
1332
|
}));
|
|
1520
1333
|
function bestTradeExactOut(_x16, _x17, _x18, _x19, _x20, _x21, _x22) {
|
|
1521
1334
|
return _bestTradeExactOut.apply(this, arguments);
|