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