@orbs-network/spot-ui 2.1.1 → 2.1.2
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/spot-ui.js +326 -325
- package/dist/spot-ui.umd.cjs +2 -2
- package/package.json +2 -2
package/dist/spot-ui.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var ht = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var Ee = (e, t, n) =>
|
|
4
|
-
var v = /* @__PURE__ */ ((e) => (e.TWAP = "TWAP", e.LIMIT = "LIMIT", e.STOP_LOSS = "STOP_LOSS", e.TAKE_PROFIT = "TAKE_PROFIT", e))(v || {}), ce = /* @__PURE__ */ ((e) => (e.Open = "OPEN", e.Cancelled = "CANCELLED", e.Completed = "COMPLETED", e.Expired = "EXPIRED", e))(ce || {}),
|
|
2
|
+
var xt = (e, t, n) => t in e ? ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var Ee = (e, t, n) => xt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var v = /* @__PURE__ */ ((e) => (e.TWAP = "TWAP", e.LIMIT = "LIMIT", e.STOP_LOSS = "STOP_LOSS", e.TAKE_PROFIT = "TAKE_PROFIT", e))(v || {}), ce = /* @__PURE__ */ ((e) => (e.Open = "OPEN", e.Cancelled = "CANCELLED", e.Completed = "COMPLETED", e.Expired = "EXPIRED", e))(ce || {}), Tt = /* @__PURE__ */ ((e) => (e.All = "ALL", e.Open = "OPEN", e.Cancelled = "CANCELLED", e.Completed = "COMPLETED", e.Expired = "EXPIRED", e))(Tt || {}), se = /* @__PURE__ */ ((e) => (e[e.Minutes = 6e4] = "Minutes", e[e.Hours = 36e5] = "Hours", e[e.Weeks = 6048e5] = "Weeks", e[e.Days = 864e5] = "Days", e[e.Months = 2592e6] = "Months", e[e.Years = 31536e6] = "Years", e))(se || {}), N = /* @__PURE__ */ ((e) => (e.LIMIT = "limit", e.TWAP_LIMIT = "twap-limit", e.TWAP_MARKET = "twap-market", e.TAKE_PROFIT_MARKET = "take-profit-market", e.TAKE_PROFIT_LIMIT = "take-profit-limit", e.STOP_LOSS_LIMIT = "stop-loss-limit", e.STOP_LOSS_MARKET = "stop-loss-market", e))(N || {}), Q = /* @__PURE__ */ ((e) => (e.Arbidex = "arbidex", e.Blackhole = "blackhole", e.Chronos = "chronos", e.Dragon = "dragon", e.Kodiak = "kodiak", e.Lynex = "lynex", e.Nami = "nami", e.Newera = "newera", e.Omni = "omni", e.Pancake = "pancake", e.Quick = "quick", e.Ramses = "ramses", e.Shadow = "shadow", e.Spark = "spark", e.Spooky = "spooky", e.Swapx = "swapx", e.Teafi = "teafi", e.Thena = "thena", e.Yowie = "yowie", e.Pangolin = "pangolin", e.Sushiswap = "sushiswap", e.Agent = "agent", e.Utila = "utila", e.Ring = "ring", e.EfficientFrontier = "ef", e.HtDigital = "ht", e.Ginco = "ginco", e.Katana = "katana", e.Unknown = "unknown", e))(Q || {}), J = /* @__PURE__ */ ((e) => (e.MAX_TRADES = "maxTradesError", e.MIN_TRADES = "minTradesError", e.MIN_TRADE_SIZE = "minTradeSizeError", e.MAX_FILL_DELAY = "maxFillDelayError", e.MIN_FILL_DELAY = "minFillDelayError", e.MAX_ORDER_DURATION = "maxDurationError", e.MIN_ORDER_DURATION = "minDurationError", e.MISSING_LIMIT_PRICE = "missingLimitPrice", e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE = "StopLossTriggerPriceError", e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE = "triggerLimitPriceError", e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE = "TakeProfitTriggerPriceError", e.EMPTY_TRIGGER_PRICE = "emptyTriggerPrice", e.INSUFFICIENT_BALANCE = "insufficientFunds", e.MAX_ORDER_SIZE = "maxOrderSize", e))(J || {}), gt = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, Ne = Math.ceil, ne = Math.floor, Z = "[BigNumber Error] ", Qe = Z + "Number primitive has more than 15 significant digits: ", ae = 1e14, k = 14, Le = 9007199254740991, Ue = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], pe = 1e7, q = 1e9;
|
|
5
5
|
function ut(e) {
|
|
6
|
-
var t, n, i, a = g.prototype = { constructor: g, toString: null, valueOf: null }, d = new g(1),
|
|
6
|
+
var t, n, i, a = g.prototype = { constructor: g, toString: null, valueOf: null }, d = new g(1), b = 20, m = 4, D = -7, C = 21, O = -1e7, F = 1e7, h = !1, w = 1, B = 0, V = {
|
|
7
7
|
prefix: "",
|
|
8
8
|
groupSize: 3,
|
|
9
9
|
secondaryGroupSize: 0,
|
|
@@ -36,7 +36,7 @@ function ut(e) {
|
|
|
36
36
|
(f = y.indexOf(".")) > -1 && (y = y.replace(".", "")), (E = y.search(/e/i)) > 0 ? (f < 0 && (f = E), f += +y.slice(E + 1), y = y.substring(0, E)) : f < 0 && (f = y.length);
|
|
37
37
|
} else {
|
|
38
38
|
if (L(s, 2, K.length, "Base"), s == 10 && z)
|
|
39
|
-
return p = new g(r), Y(p,
|
|
39
|
+
return p = new g(r), Y(p, b + p.e + 1, m);
|
|
40
40
|
if (y = String(r), c = typeof r == "number") {
|
|
41
41
|
if (r * 0 != 0) return i(p, y, c, s);
|
|
42
42
|
if (p.s = 1 / r < 0 ? (y = y.slice(1), -1) : 1, g.DEBUG && y.replace(/^0\.0*|\./, "").length > 15)
|
|
@@ -84,7 +84,7 @@ function ut(e) {
|
|
|
84
84
|
var s, o;
|
|
85
85
|
if (r != null)
|
|
86
86
|
if (typeof r == "object") {
|
|
87
|
-
if (r.hasOwnProperty(s = "DECIMAL_PLACES") && (o = r[s], L(o, 0, q, s),
|
|
87
|
+
if (r.hasOwnProperty(s = "DECIMAL_PLACES") && (o = r[s], L(o, 0, q, s), b = o), r.hasOwnProperty(s = "ROUNDING_MODE") && (o = r[s], L(o, 0, 8, s), m = o), r.hasOwnProperty(s = "EXPONENTIAL_AT") && (o = r[s], o && o.pop ? (L(o[0], -q, 0, s), L(o[1], 0, q, s), D = o[0], C = o[1]) : (L(o, -q, q, s), D = -(C = o < 0 ? -o : o))), r.hasOwnProperty(s = "RANGE"))
|
|
88
88
|
if (o = r[s], o && o.pop)
|
|
89
89
|
L(o[0], -q, -1, s), L(o[1], 1, q, s), O = o[0], F = o[1];
|
|
90
90
|
else if (L(o, -q, q, s), o)
|
|
@@ -113,8 +113,8 @@ function ut(e) {
|
|
|
113
113
|
} else
|
|
114
114
|
throw Error(Z + "Object expected: " + r);
|
|
115
115
|
return {
|
|
116
|
-
DECIMAL_PLACES:
|
|
117
|
-
ROUNDING_MODE:
|
|
116
|
+
DECIMAL_PLACES: b,
|
|
117
|
+
ROUNDING_MODE: m,
|
|
118
118
|
EXPONENTIAL_AT: [D, C],
|
|
119
119
|
RANGE: [O, F],
|
|
120
120
|
CRYPTO: h,
|
|
@@ -154,7 +154,7 @@ function ut(e) {
|
|
|
154
154
|
};
|
|
155
155
|
return function(o) {
|
|
156
156
|
var A, u, f, E, c, l = 0, y = [], p = new g(d);
|
|
157
|
-
if (o == null ? o =
|
|
157
|
+
if (o == null ? o = b : L(o, 0, q), E = Ne(o / k), h)
|
|
158
158
|
if (crypto.getRandomValues) {
|
|
159
159
|
for (A = crypto.getRandomValues(new Uint32Array(E *= 2)); l < E; )
|
|
160
160
|
c = A[l] * 131072 + (A[l + 1] >>> 11), c >= 9e15 ? (u = crypto.getRandomValues(new Uint32Array(2)), A[l] = u[0], A[l + 1] = u[1]) : (y.push(c % 1e14), l += 2);
|
|
@@ -192,7 +192,7 @@ function ut(e) {
|
|
|
192
192
|
return c.reverse();
|
|
193
193
|
}
|
|
194
194
|
return function(o, A, u, f, E) {
|
|
195
|
-
var c, l, y, p,
|
|
195
|
+
var c, l, y, p, x, S, P, R, U = o.indexOf("."), G = b, I = m;
|
|
196
196
|
for (U >= 0 && (p = B, B = 0, o = o.replace(".", ""), R = new g(A), S = R.pow(o.length - U), B = p, R.c = s(
|
|
197
197
|
le(te(S.c), S.e, "0"),
|
|
198
198
|
10,
|
|
@@ -200,10 +200,10 @@ function ut(e) {
|
|
|
200
200
|
r
|
|
201
201
|
), R.e = R.c.length), P = s(o, A, u, E ? (c = K, r) : (c = r, K)), y = p = P.length; P[--p] == 0; P.pop()) ;
|
|
202
202
|
if (!P[0]) return c.charAt(0);
|
|
203
|
-
if (U < 0 ? --y : (S.c = P, S.e = y, S.s = f, S = t(S, R, G, I, u), P = S.c,
|
|
204
|
-
o =
|
|
203
|
+
if (U < 0 ? --y : (S.c = P, S.e = y, S.s = f, S = t(S, R, G, I, u), P = S.c, x = S.r, y = S.e), l = y + G + 1, U = P[l], p = u / 2, x = x || l < 0 || P[l + 1] != null, x = I < 4 ? (U != null || x) && (I == 0 || I == (S.s < 0 ? 3 : 2)) : U > p || U == p && (I == 4 || x || I == 6 && P[l - 1] & 1 || I == (S.s < 0 ? 8 : 7)), l < 1 || !P[0])
|
|
204
|
+
o = x ? le(c.charAt(1), -G, c.charAt(0)) : c.charAt(0);
|
|
205
205
|
else {
|
|
206
|
-
if (P.length = l,
|
|
206
|
+
if (P.length = l, x)
|
|
207
207
|
for (--u; ++P[--l] > u; )
|
|
208
208
|
P[l] = 0, l || (++y, P = [1].concat(P));
|
|
209
209
|
for (p = P.length; !P[--p]; ) ;
|
|
@@ -214,9 +214,9 @@ function ut(e) {
|
|
|
214
214
|
};
|
|
215
215
|
})(), t = /* @__PURE__ */ (function() {
|
|
216
216
|
function r(A, u, f) {
|
|
217
|
-
var E, c, l, y, p = 0,
|
|
218
|
-
for (A = A.slice();
|
|
219
|
-
l = A[
|
|
217
|
+
var E, c, l, y, p = 0, x = A.length, S = u % pe, P = u / pe | 0;
|
|
218
|
+
for (A = A.slice(); x--; )
|
|
219
|
+
l = A[x] % pe, y = A[x] / pe | 0, E = P * l + y * S, c = S * l + E % pe * pe + p, p = (c / f | 0) + (E / pe | 0) + P * y, A[x] = c % f;
|
|
220
220
|
return p && (A = [p].concat(A)), A;
|
|
221
221
|
}
|
|
222
222
|
function s(A, u, f, E) {
|
|
@@ -237,7 +237,7 @@ function ut(e) {
|
|
|
237
237
|
for (; !A[0] && A.length > 1; A.splice(0, 1)) ;
|
|
238
238
|
}
|
|
239
239
|
return function(A, u, f, E, c) {
|
|
240
|
-
var l, y, p,
|
|
240
|
+
var l, y, p, x, S, P, R, U, G, I, M, j, Fe, Re, Me, oe, ge, ee = A.s == u.s ? 1 : -1, X = A.c, $ = u.c;
|
|
241
241
|
if (!X || !X[0] || !$ || !$[0])
|
|
242
242
|
return new g(
|
|
243
243
|
// Return NaN if either NaN, or both Infinity or 0.
|
|
@@ -248,7 +248,7 @@ function ut(e) {
|
|
|
248
248
|
);
|
|
249
249
|
for (U = new g(ee), G = U.c = [], y = A.e - u.e, ee = f + y + 1, c || (c = ae, y = re(A.e / k) - re(u.e / k), ee = ee / k | 0), p = 0; $[p] == (X[p] || 0); p++) ;
|
|
250
250
|
if ($[p] > (X[p] || 0) && y--, ee < 0)
|
|
251
|
-
G.push(1),
|
|
251
|
+
G.push(1), x = !0;
|
|
252
252
|
else {
|
|
253
253
|
for (Re = X.length, oe = $.length, p = 0, ee += 2, S = ne(c / ($[0] + 1)), S > 1 && ($ = r($, S, c), X = r(X, S, c), oe = $.length, Re = X.length), Fe = oe, I = X.slice(0, oe), M = I.length; M < oe; I[M++] = 0) ;
|
|
254
254
|
ge = $.slice(), ge = [0].concat(ge), Me = $[0], $[1] >= c / 2 && Me++;
|
|
@@ -265,19 +265,19 @@ function ut(e) {
|
|
|
265
265
|
} else l === 0 && (S++, I = [0]);
|
|
266
266
|
G[p++] = S, I[0] ? I[M++] = X[Fe] || 0 : (I = [X[Fe]], M = 1);
|
|
267
267
|
} while ((Fe++ < Re || I[0] != null) && ee--);
|
|
268
|
-
|
|
268
|
+
x = I[0] != null, G[0] || G.splice(0, 1);
|
|
269
269
|
}
|
|
270
270
|
if (c == ae) {
|
|
271
271
|
for (p = 1, ee = G[0]; ee >= 10; ee /= 10, p++) ;
|
|
272
|
-
Y(U, f + (U.e = p + y * k - 1) + 1, E,
|
|
272
|
+
Y(U, f + (U.e = p + y * k - 1) + 1, E, x);
|
|
273
273
|
} else
|
|
274
|
-
U.e = y, U.r = +
|
|
274
|
+
U.e = y, U.r = +x;
|
|
275
275
|
return U;
|
|
276
276
|
};
|
|
277
277
|
})();
|
|
278
|
-
function
|
|
278
|
+
function xe(r, s, o, A) {
|
|
279
279
|
var u, f, E, c, l;
|
|
280
|
-
if (o == null ? o =
|
|
280
|
+
if (o == null ? o = m : L(o, 0, 8), !r.c) return r.toString();
|
|
281
281
|
if (u = r.c[0], E = r.e, s == null)
|
|
282
282
|
l = te(r.c), l = A == 1 || A == 2 && (E <= D || E >= C) ? Be(l, E) : le(l, E, "0");
|
|
283
283
|
else if (r = Y(new g(r), s, o), f = r.e, l = te(r.c), c = l.length, A == 1 || A == 2 && (s <= f || f <= D)) {
|
|
@@ -294,7 +294,7 @@ function ut(e) {
|
|
|
294
294
|
A = new g(r[u]), (!A.s || (o = ye(f, A)) === s || o === 0 && f.s === s) && (f = A);
|
|
295
295
|
return f;
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function Te(r, s, o) {
|
|
298
298
|
for (var A = 1, u = s.length; !s[--u]; s.pop()) ;
|
|
299
299
|
for (u = s[0]; u >= 10; u /= 10, A++) ;
|
|
300
300
|
return (o = A + o * k - 1) > F ? r.c = r.e = null : o < O ? r.c = [r.e = 0] : (r.e = o, r.c = s), r;
|
|
@@ -306,8 +306,8 @@ function ut(e) {
|
|
|
306
306
|
if (A.test(p))
|
|
307
307
|
f.s = isNaN(p) ? null : p < 0 ? -1 : 1;
|
|
308
308
|
else {
|
|
309
|
-
if (!c && (p = p.replace(r, function(
|
|
310
|
-
return y = (P = P.toLowerCase()) == "x" ? 16 : P == "b" ? 2 : 8, !l || l == y ? S :
|
|
309
|
+
if (!c && (p = p.replace(r, function(x, S, P) {
|
|
310
|
+
return y = (P = P.toLowerCase()) == "x" ? 16 : P == "b" ? 2 : 8, !l || l == y ? S : x;
|
|
311
311
|
}), l && (y = l, p = p.replace(s, "$1").replace(o, "0.$1")), E != p))
|
|
312
312
|
return new g(p, y);
|
|
313
313
|
if (g.DEBUG)
|
|
@@ -318,40 +318,40 @@ function ut(e) {
|
|
|
318
318
|
};
|
|
319
319
|
})();
|
|
320
320
|
function Y(r, s, o, A) {
|
|
321
|
-
var u, f, E, c, l, y, p,
|
|
322
|
-
if (
|
|
321
|
+
var u, f, E, c, l, y, p, x = r.c, S = Ue;
|
|
322
|
+
if (x) {
|
|
323
323
|
e: {
|
|
324
|
-
for (u = 1, c =
|
|
324
|
+
for (u = 1, c = x[0]; c >= 10; c /= 10, u++) ;
|
|
325
325
|
if (f = s - u, f < 0)
|
|
326
|
-
f += k, E = s, l =
|
|
327
|
-
else if (y = Ne((f + 1) / k), y >=
|
|
326
|
+
f += k, E = s, l = x[y = 0], p = ne(l / S[u - E - 1] % 10);
|
|
327
|
+
else if (y = Ne((f + 1) / k), y >= x.length)
|
|
328
328
|
if (A) {
|
|
329
|
-
for (;
|
|
329
|
+
for (; x.length <= y; x.push(0)) ;
|
|
330
330
|
l = p = 0, u = 1, f %= k, E = f - k + 1;
|
|
331
331
|
} else
|
|
332
332
|
break e;
|
|
333
333
|
else {
|
|
334
|
-
for (l = c =
|
|
334
|
+
for (l = c = x[y], u = 1; c >= 10; c /= 10, u++) ;
|
|
335
335
|
f %= k, E = f - k + u, p = E < 0 ? 0 : ne(l / S[u - E - 1] % 10);
|
|
336
336
|
}
|
|
337
337
|
if (A = A || s < 0 || // Are there any non-zero digits after the rounding digit?
|
|
338
338
|
// The expression n % pows10[d - j - 1] returns all digits of n to the right
|
|
339
339
|
// of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
|
|
340
|
-
|
|
341
|
-
(f > 0 ? E > 0 ? l / S[u - E] : 0 :
|
|
342
|
-
return
|
|
343
|
-
if (f == 0 ? (
|
|
340
|
+
x[y + 1] != null || (E < 0 ? l : l % S[u - E - 1]), A = o < 4 ? (p || A) && (o == 0 || o == (r.s < 0 ? 3 : 2)) : p > 5 || p == 5 && (o == 4 || A || o == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
341
|
+
(f > 0 ? E > 0 ? l / S[u - E] : 0 : x[y - 1]) % 10 & 1 || o == (r.s < 0 ? 8 : 7)), s < 1 || !x[0])
|
|
342
|
+
return x.length = 0, A ? (s -= r.e + 1, x[0] = S[(k - s % k) % k], r.e = -s || 0) : x[0] = r.e = 0, r;
|
|
343
|
+
if (f == 0 ? (x.length = y, c = 1, y--) : (x.length = y + 1, c = S[k - f], x[y] = E > 0 ? ne(l / S[u - E] % S[E]) * c : 0), A)
|
|
344
344
|
for (; ; )
|
|
345
345
|
if (y == 0) {
|
|
346
|
-
for (f = 1, E =
|
|
347
|
-
for (E =
|
|
348
|
-
f != c && (r.e++,
|
|
346
|
+
for (f = 1, E = x[0]; E >= 10; E /= 10, f++) ;
|
|
347
|
+
for (E = x[0] += c, c = 1; E >= 10; E /= 10, c++) ;
|
|
348
|
+
f != c && (r.e++, x[0] == ae && (x[0] = 1));
|
|
349
349
|
break;
|
|
350
350
|
} else {
|
|
351
|
-
if (
|
|
352
|
-
|
|
351
|
+
if (x[y] += c, x[y] != ae) break;
|
|
352
|
+
x[y--] = 0, c = 1;
|
|
353
353
|
}
|
|
354
|
-
for (f =
|
|
354
|
+
for (f = x.length; x[--f] === 0; x.pop()) ;
|
|
355
355
|
}
|
|
356
356
|
r.e > F ? r.c = r.e = null : r.e < O && (r.c = [r.e = 0]);
|
|
357
357
|
}
|
|
@@ -369,31 +369,31 @@ function ut(e) {
|
|
|
369
369
|
}, a.decimalPlaces = a.dp = function(r, s) {
|
|
370
370
|
var o, A, u, f = this;
|
|
371
371
|
if (r != null)
|
|
372
|
-
return L(r, 0, q), s == null ? s =
|
|
372
|
+
return L(r, 0, q), s == null ? s = m : L(s, 0, 8), Y(new g(f), r + f.e + 1, s);
|
|
373
373
|
if (!(o = f.c)) return null;
|
|
374
374
|
if (A = ((u = o.length - 1) - re(this.e / k)) * k, u = o[u]) for (; u % 10 == 0; u /= 10, A--) ;
|
|
375
375
|
return A < 0 && (A = 0), A;
|
|
376
376
|
}, a.dividedBy = a.div = function(r, s) {
|
|
377
|
-
return t(this, new g(r, s),
|
|
377
|
+
return t(this, new g(r, s), b, m);
|
|
378
378
|
}, a.dividedToIntegerBy = a.idiv = function(r, s) {
|
|
379
379
|
return t(this, new g(r, s), 0, 1);
|
|
380
380
|
}, a.exponentiatedBy = a.pow = function(r, s) {
|
|
381
|
-
var o, A, u, f, E, c, l, y, p,
|
|
381
|
+
var o, A, u, f, E, c, l, y, p, x = this;
|
|
382
382
|
if (r = new g(r), r.c && !r.isInteger())
|
|
383
383
|
throw Error(Z + "Exponent not an integer: " + ue(r));
|
|
384
|
-
if (s != null && (s = new g(s)), c = r.e > 14, !
|
|
385
|
-
return p = new g(Math.pow(+ue(
|
|
384
|
+
if (s != null && (s = new g(s)), c = r.e > 14, !x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !r.c || !r.c[0])
|
|
385
|
+
return p = new g(Math.pow(+ue(x), c ? r.s * (2 - Ce(r)) : +ue(r))), s ? p.mod(s) : p;
|
|
386
386
|
if (l = r.s < 0, s) {
|
|
387
387
|
if (s.c ? !s.c[0] : !s.s) return new g(NaN);
|
|
388
|
-
A = !l &&
|
|
388
|
+
A = !l && x.isInteger() && s.isInteger(), A && (x = x.mod(s));
|
|
389
389
|
} else {
|
|
390
|
-
if (r.e > 9 && (
|
|
391
|
-
return f =
|
|
390
|
+
if (r.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || c && x.c[1] >= 24e7 : x.c[0] < 8e13 || c && x.c[0] <= 9999975e7)))
|
|
391
|
+
return f = x.s < 0 && Ce(r) ? -0 : 0, x.e > -1 && (f = 1 / f), new g(l ? 1 / f : f);
|
|
392
392
|
B && (f = Ne(B / k + 2));
|
|
393
393
|
}
|
|
394
394
|
for (c ? (o = new g(0.5), l && (r.s = 1), y = Ce(r)) : (u = Math.abs(+ue(r)), y = u % 2), p = new g(d); ; ) {
|
|
395
395
|
if (y) {
|
|
396
|
-
if (p = p.times(
|
|
396
|
+
if (p = p.times(x), !p.c) break;
|
|
397
397
|
f ? p.c.length > f && (p.c.length = f) : A && (p = p.mod(s));
|
|
398
398
|
}
|
|
399
399
|
if (u) {
|
|
@@ -405,12 +405,12 @@ function ut(e) {
|
|
|
405
405
|
if (u = +ue(r), u === 0) break;
|
|
406
406
|
y = u % 2;
|
|
407
407
|
}
|
|
408
|
-
|
|
408
|
+
x = x.times(x), f ? x.c && x.c.length > f && (x.c.length = f) : A && (x = x.mod(s));
|
|
409
409
|
}
|
|
410
|
-
return A ? p : (l && (p = d.div(p)), s ? p.mod(s) : f ? Y(p, B,
|
|
410
|
+
return A ? p : (l && (p = d.div(p)), s ? p.mod(s) : f ? Y(p, B, m, E) : p);
|
|
411
411
|
}, a.integerValue = function(r) {
|
|
412
412
|
var s = new g(this);
|
|
413
|
-
return r == null ? r =
|
|
413
|
+
return r == null ? r = m : L(r, 0, 8), Y(s, s.e + 1, r);
|
|
414
414
|
}, a.isEqualTo = a.eq = function(r, s) {
|
|
415
415
|
return ye(this, new g(r, s)) === 0;
|
|
416
416
|
}, a.isFinite = function() {
|
|
@@ -438,48 +438,48 @@ function ut(e) {
|
|
|
438
438
|
if (r = new g(r, s), s = r.s, !c || !s) return new g(NaN);
|
|
439
439
|
if (c != s)
|
|
440
440
|
return r.s = -s, E.plus(r);
|
|
441
|
-
var l = E.e / k, y = r.e / k, p = E.c,
|
|
441
|
+
var l = E.e / k, y = r.e / k, p = E.c, x = r.c;
|
|
442
442
|
if (!l || !y) {
|
|
443
|
-
if (!p || !
|
|
444
|
-
if (!p[0] || !
|
|
445
|
-
return
|
|
443
|
+
if (!p || !x) return p ? (r.s = -s, r) : new g(x ? E : NaN);
|
|
444
|
+
if (!p[0] || !x[0])
|
|
445
|
+
return x[0] ? (r.s = -s, r) : new g(p[0] ? E : (
|
|
446
446
|
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
|
|
447
|
-
|
|
447
|
+
m == 3 ? -0 : 0
|
|
448
448
|
));
|
|
449
449
|
}
|
|
450
450
|
if (l = re(l), y = re(y), p = p.slice(), c = l - y) {
|
|
451
|
-
for ((f = c < 0) ? (c = -c, u = p) : (y = l, u =
|
|
451
|
+
for ((f = c < 0) ? (c = -c, u = p) : (y = l, u = x), u.reverse(), s = c; s--; u.push(0)) ;
|
|
452
452
|
u.reverse();
|
|
453
453
|
} else
|
|
454
|
-
for (A = (f = (c = p.length) < (s =
|
|
455
|
-
if (p[s] !=
|
|
456
|
-
f = p[s] <
|
|
454
|
+
for (A = (f = (c = p.length) < (s = x.length)) ? c : s, c = s = 0; s < A; s++)
|
|
455
|
+
if (p[s] != x[s]) {
|
|
456
|
+
f = p[s] < x[s];
|
|
457
457
|
break;
|
|
458
458
|
}
|
|
459
|
-
if (f && (u = p, p =
|
|
459
|
+
if (f && (u = p, p = x, x = u, r.s = -r.s), s = (A = x.length) - (o = p.length), s > 0) for (; s--; p[o++] = 0) ;
|
|
460
460
|
for (s = ae - 1; A > c; ) {
|
|
461
|
-
if (p[--A] <
|
|
461
|
+
if (p[--A] < x[A]) {
|
|
462
462
|
for (o = A; o && !p[--o]; p[o] = s) ;
|
|
463
463
|
--p[o], p[A] += ae;
|
|
464
464
|
}
|
|
465
|
-
p[A] -=
|
|
465
|
+
p[A] -= x[A];
|
|
466
466
|
}
|
|
467
467
|
for (; p[0] == 0; p.splice(0, 1), --y) ;
|
|
468
|
-
return p[0] ?
|
|
468
|
+
return p[0] ? Te(r, p, y) : (r.s = m == 3 ? -1 : 1, r.c = [r.e = 0], r);
|
|
469
469
|
}, a.modulo = a.mod = function(r, s) {
|
|
470
470
|
var o, A, u = this;
|
|
471
471
|
return r = new g(r, s), !u.c || !r.s || r.c && !r.c[0] ? new g(NaN) : !r.c || u.c && !u.c[0] ? new g(u) : (w == 9 ? (A = r.s, r.s = 1, o = t(u, r, 0, 3), r.s = A, o.s *= A) : o = t(u, r, 0, w), r = u.minus(o.times(r)), !r.c[0] && w == 1 && (r.s = u.s), r);
|
|
472
472
|
}, a.multipliedBy = a.times = function(r, s) {
|
|
473
|
-
var o, A, u, f, E, c, l, y, p,
|
|
473
|
+
var o, A, u, f, E, c, l, y, p, x, S, P, R, U, G, I = this, M = I.c, j = (r = new g(r, s)).c;
|
|
474
474
|
if (!M || !j || !M[0] || !j[0])
|
|
475
475
|
return !I.s || !r.s || M && !M[0] && !j || j && !j[0] && !M ? r.c = r.e = r.s = null : (r.s *= I.s, !M || !j ? r.c = r.e = null : (r.c = [0], r.e = 0)), r;
|
|
476
|
-
for (A = re(I.e / k) + re(r.e / k), r.s *= I.s, l = M.length,
|
|
477
|
-
for (U = ae, G = pe, u =
|
|
476
|
+
for (A = re(I.e / k) + re(r.e / k), r.s *= I.s, l = M.length, x = j.length, l < x && (R = M, M = j, j = R, u = l, l = x, x = u), u = l + x, R = []; u--; R.push(0)) ;
|
|
477
|
+
for (U = ae, G = pe, u = x; --u >= 0; ) {
|
|
478
478
|
for (o = 0, S = j[u] % G, P = j[u] / G | 0, E = l, f = u + E; f > u; )
|
|
479
479
|
y = M[--E] % G, p = M[E] / G | 0, c = P * y + p * S, y = S * y + c % G * G + R[f] + o, o = (y / U | 0) + (c / G | 0) + P * p, R[f--] = y % U;
|
|
480
480
|
R[f] = o;
|
|
481
481
|
}
|
|
482
|
-
return o ? ++A : R.splice(0, 1),
|
|
482
|
+
return o ? ++A : R.splice(0, 1), Te(r, R, A);
|
|
483
483
|
}, a.negated = function() {
|
|
484
484
|
var r = new g(this);
|
|
485
485
|
return r.s = -r.s || null, r;
|
|
@@ -499,11 +499,11 @@ function ut(e) {
|
|
|
499
499
|
}
|
|
500
500
|
for (u = c.length, s = l.length, u - s < 0 && (o = l, l = c, c = o, s = u), u = 0; s; )
|
|
501
501
|
u = (c[--s] = c[s] + l[s] + u) / ae | 0, c[s] = ae === c[s] ? 0 : c[s] % ae;
|
|
502
|
-
return u && (c = [u].concat(c), ++E),
|
|
502
|
+
return u && (c = [u].concat(c), ++E), Te(r, c, E);
|
|
503
503
|
}, a.precision = a.sd = function(r, s) {
|
|
504
504
|
var o, A, u, f = this;
|
|
505
505
|
if (r != null && r !== !!r)
|
|
506
|
-
return L(r, 1, q), s == null ? s =
|
|
506
|
+
return L(r, 1, q), s == null ? s = m : L(s, 0, 8), Y(new g(f), r, s);
|
|
507
507
|
if (!(o = f.c)) return null;
|
|
508
508
|
if (u = o.length - 1, A = u * k + 1, u = o[u]) {
|
|
509
509
|
for (; u % 10 == 0; u /= 10, A--) ;
|
|
@@ -513,28 +513,28 @@ function ut(e) {
|
|
|
513
513
|
}, a.shiftedBy = function(r) {
|
|
514
514
|
return L(r, -Le, Le), this.times("1e" + r);
|
|
515
515
|
}, a.squareRoot = a.sqrt = function() {
|
|
516
|
-
var r, s, o, A, u, f = this, E = f.c, c = f.s, l = f.e, y =
|
|
516
|
+
var r, s, o, A, u, f = this, E = f.c, c = f.s, l = f.e, y = b + 4, p = new g("0.5");
|
|
517
517
|
if (c !== 1 || !E || !E[0])
|
|
518
518
|
return new g(!c || c < 0 && (!E || E[0]) ? NaN : E ? f : 1 / 0);
|
|
519
519
|
if (c = Math.sqrt(+ue(f)), c == 0 || c == 1 / 0 ? (s = te(E), (s.length + l) % 2 == 0 && (s += "0"), c = Math.sqrt(+s), l = re((l + 1) / 2) - (l < 0 || l % 2), c == 1 / 0 ? s = "5e" + l : (s = c.toExponential(), s = s.slice(0, s.indexOf("e") + 1) + l), o = new g(s)) : o = new g(c + ""), o.c[0]) {
|
|
520
520
|
for (l = o.e, c = l + y, c < 3 && (c = 0); ; )
|
|
521
521
|
if (u = o, o = p.times(u.plus(t(f, u, y, 1))), te(u.c).slice(0, c) === (s = te(o.c)).slice(0, c))
|
|
522
522
|
if (o.e < l && --c, s = s.slice(c - 3, c + 1), s == "9999" || !A && s == "4999") {
|
|
523
|
-
if (!A && (Y(u, u.e +
|
|
523
|
+
if (!A && (Y(u, u.e + b + 2, 0), u.times(u).eq(f))) {
|
|
524
524
|
o = u;
|
|
525
525
|
break;
|
|
526
526
|
}
|
|
527
527
|
y += 4, c += 4, A = 1;
|
|
528
528
|
} else {
|
|
529
|
-
(!+s || !+s.slice(1) && s.charAt(0) == "5") && (Y(o, o.e +
|
|
529
|
+
(!+s || !+s.slice(1) && s.charAt(0) == "5") && (Y(o, o.e + b + 2, 1), r = !o.times(o).eq(f));
|
|
530
530
|
break;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
return Y(o, o.e +
|
|
533
|
+
return Y(o, o.e + b + 1, m, r);
|
|
534
534
|
}, a.toExponential = function(r, s) {
|
|
535
|
-
return r != null && (L(r, 0, q), r++),
|
|
535
|
+
return r != null && (L(r, 0, q), r++), xe(this, r, s, 1);
|
|
536
536
|
}, a.toFixed = function(r, s) {
|
|
537
|
-
return r != null && (L(r, 0, q), r = r + this.e + 1),
|
|
537
|
+
return r != null && (L(r, 0, q), r = r + this.e + 1), xe(this, r, s);
|
|
538
538
|
}, a.toFormat = function(r, s, o) {
|
|
539
539
|
var A, u = this;
|
|
540
540
|
if (o == null)
|
|
@@ -542,34 +542,34 @@ function ut(e) {
|
|
|
542
542
|
else if (typeof o != "object")
|
|
543
543
|
throw Error(Z + "Argument not an object: " + o);
|
|
544
544
|
if (A = u.toFixed(r, s), u.c) {
|
|
545
|
-
var f, E = A.split("."), c = +o.groupSize, l = +o.secondaryGroupSize, y = o.groupSeparator || "", p = E[0],
|
|
545
|
+
var f, E = A.split("."), c = +o.groupSize, l = +o.secondaryGroupSize, y = o.groupSeparator || "", p = E[0], x = E[1], S = u.s < 0, P = S ? p.slice(1) : p, R = P.length;
|
|
546
546
|
if (l && (f = c, c = l, l = f, R -= f), c > 0 && R > 0) {
|
|
547
547
|
for (f = R % c || c, p = P.substr(0, f); f < R; f += c) p += y + P.substr(f, c);
|
|
548
548
|
l > 0 && (p += y + P.slice(f)), S && (p = "-" + p);
|
|
549
549
|
}
|
|
550
|
-
A =
|
|
550
|
+
A = x ? p + (o.decimalSeparator || "") + ((l = +o.fractionGroupSize) ? x.replace(
|
|
551
551
|
new RegExp("\\d{" + l + "}\\B", "g"),
|
|
552
552
|
"$&" + (o.fractionGroupSeparator || "")
|
|
553
|
-
) :
|
|
553
|
+
) : x) : p;
|
|
554
554
|
}
|
|
555
555
|
return (o.prefix || "") + A + (o.suffix || "");
|
|
556
556
|
}, a.toFraction = function(r) {
|
|
557
|
-
var s, o, A, u, f, E, c, l, y, p,
|
|
557
|
+
var s, o, A, u, f, E, c, l, y, p, x, S, P = this, R = P.c;
|
|
558
558
|
if (r != null && (c = new g(r), !c.isInteger() && (c.c || c.s !== 1) || c.lt(d)))
|
|
559
559
|
throw Error(Z + "Argument " + (c.isInteger() ? "out of range: " : "not an integer: ") + ue(c));
|
|
560
560
|
if (!R) return new g(P);
|
|
561
561
|
for (s = new g(d), y = o = new g(d), A = l = new g(d), S = te(R), f = s.e = S.length - P.e - 1, s.c[0] = Ue[(E = f % k) < 0 ? k + E : E], r = !r || c.comparedTo(s) > 0 ? f > 0 ? s : y : c, E = F, F = 1 / 0, c = new g(S), l.c[0] = 0; p = t(c, s, 0, 1), u = o.plus(p.times(A)), u.comparedTo(r) != 1; )
|
|
562
562
|
o = A, A = u, y = l.plus(p.times(u = y)), l = u, s = c.minus(p.times(u = s)), c = u;
|
|
563
|
-
return u = t(r.minus(o), A, 0, 1), l = l.plus(u.times(y)), o = o.plus(u.times(A)), l.s = y.s = P.s, f = f * 2,
|
|
564
|
-
t(l, o, f,
|
|
565
|
-
) < 1 ? [y, A] : [l, o], F = E,
|
|
563
|
+
return u = t(r.minus(o), A, 0, 1), l = l.plus(u.times(y)), o = o.plus(u.times(A)), l.s = y.s = P.s, f = f * 2, x = t(y, A, f, m).minus(P).abs().comparedTo(
|
|
564
|
+
t(l, o, f, m).minus(P).abs()
|
|
565
|
+
) < 1 ? [y, A] : [l, o], F = E, x;
|
|
566
566
|
}, a.toNumber = function() {
|
|
567
567
|
return +ue(this);
|
|
568
568
|
}, a.toPrecision = function(r, s) {
|
|
569
|
-
return r != null && L(r, 1, q),
|
|
569
|
+
return r != null && L(r, 1, q), xe(this, r, s, 2);
|
|
570
570
|
}, a.toString = function(r) {
|
|
571
571
|
var s, o = this, A = o.s, u = o.e;
|
|
572
|
-
return u === null ? A ? (s = "Infinity", A < 0 && (s = "-" + s)) : s = "NaN" : (r == null ? s = u <= D || u >= C ? Be(te(o.c), u) : le(te(o.c), u, "0") : r === 10 && z ? (o = Y(new g(o),
|
|
572
|
+
return u === null ? A ? (s = "Infinity", A < 0 && (s = "-" + s)) : s = "NaN" : (r == null ? s = u <= D || u >= C ? Be(te(o.c), u) : le(te(o.c), u, "0") : r === 10 && z ? (o = Y(new g(o), b + u + 1, m), s = le(te(o.c), o.e, "0")) : (L(r, 2, K.length, "Base"), s = n(le(te(o.c), u, "0"), 10, r, A, !0)), A < 0 && o.c[0] && (s = "-" + s)), s;
|
|
573
573
|
}, a.valueOf = a.toJSON = function() {
|
|
574
574
|
return ue(this);
|
|
575
575
|
}, a._isBigNumber = !0, a[Symbol.toStringTag] = "BigNumber", a[Symbol.for("nodejs.util.inspect.custom")] = a.valueOf, e != null && g.set(e), g;
|
|
@@ -587,13 +587,13 @@ function te(e) {
|
|
|
587
587
|
return d.slice(0, a + 1 || 1);
|
|
588
588
|
}
|
|
589
589
|
function ye(e, t) {
|
|
590
|
-
var n, i, a = e.c, d = t.c,
|
|
591
|
-
if (!
|
|
592
|
-
if (n = a && !a[0], i = d && !d[0], n || i) return n ? i ? 0 : -
|
|
593
|
-
if (
|
|
594
|
-
if (n =
|
|
590
|
+
var n, i, a = e.c, d = t.c, b = e.s, m = t.s, D = e.e, C = t.e;
|
|
591
|
+
if (!b || !m) return null;
|
|
592
|
+
if (n = a && !a[0], i = d && !d[0], n || i) return n ? i ? 0 : -m : b;
|
|
593
|
+
if (b != m) return b;
|
|
594
|
+
if (n = b < 0, i = D == C, !a || !d) return i ? 0 : !a ^ n ? 1 : -1;
|
|
595
595
|
if (!i) return D > C ^ n ? 1 : -1;
|
|
596
|
-
for (
|
|
596
|
+
for (m = (D = a.length) < (C = d.length) ? D : C, b = 0; b < m; b++) if (a[b] != d[b]) return a[b] > d[b] ^ n ? 1 : -1;
|
|
597
597
|
return D == C ? 0 : D > C ^ n ? 1 : -1;
|
|
598
598
|
}
|
|
599
599
|
function L(e, t, n, i) {
|
|
@@ -618,22 +618,22 @@ function le(e, t, n) {
|
|
|
618
618
|
} else t < i && (e = e.slice(0, t) + "." + e.slice(t));
|
|
619
619
|
return e;
|
|
620
620
|
}
|
|
621
|
-
var
|
|
621
|
+
var T = ut();
|
|
622
622
|
const H = (e) => {
|
|
623
623
|
if (!e) return "";
|
|
624
|
-
const t =
|
|
624
|
+
const t = T(e);
|
|
625
625
|
return t.isFinite() && !t.isNaN() ? e : "";
|
|
626
626
|
}, We = (e, t) => {
|
|
627
627
|
if (t == null || !e) return "";
|
|
628
|
-
const n =
|
|
629
|
-
return !n.isFinite() || n.isNaN() ? "" : n.multipliedBy(
|
|
628
|
+
const n = T(e);
|
|
629
|
+
return !n.isFinite() || n.isNaN() ? "" : n.multipliedBy(T(10).pow(t)).toFixed(0);
|
|
630
630
|
}, ze = (e, t) => {
|
|
631
631
|
if (t == null || !e) return "";
|
|
632
|
-
const n =
|
|
633
|
-
return !n.isFinite() || n.isNaN() ? "" : n.dividedBy(
|
|
632
|
+
const n = T(e);
|
|
633
|
+
return !n.isFinite() || n.isNaN() ? "" : n.dividedBy(T(10).pow(t)).toFixed();
|
|
634
634
|
}, je = (e, t) => {
|
|
635
635
|
if (!e || !t) return "";
|
|
636
|
-
const n =
|
|
636
|
+
const n = T(e), i = T(t);
|
|
637
637
|
return !n.isFinite() || n.isNaN() || n.isZero() || !i.isFinite() || i.isNaN() || i.isZero() ? "" : n.multipliedBy(i).toFixed();
|
|
638
638
|
}, Ae = (e, t, n) => {
|
|
639
639
|
const i = H(e), a = ze(i, t);
|
|
@@ -648,11 +648,11 @@ const H = (e) => {
|
|
|
648
648
|
outputTokenDecimals: n,
|
|
649
649
|
outputUsdPrice: i
|
|
650
650
|
}) => {
|
|
651
|
-
const a = H(e), d = H(t),
|
|
651
|
+
const a = H(e), d = H(t), b = a && d && T(d).gt(0) ? T(a).dividedBy(d).toFixed() : "", m = ze(b, n);
|
|
652
652
|
return {
|
|
653
|
-
raw:
|
|
654
|
-
ui:
|
|
655
|
-
usd: je(
|
|
653
|
+
raw: b,
|
|
654
|
+
ui: m,
|
|
655
|
+
usd: je(m, i)
|
|
656
656
|
};
|
|
657
657
|
}, Ke = 300 * 1e3, Oe = 1440 * 60 * 60 * 1e3, Je = 300 * 1e3, Ve = {
|
|
658
658
|
unit: se.Minutes,
|
|
@@ -661,20 +661,20 @@ const H = (e) => {
|
|
|
661
661
|
const t = H(e.initialPrice);
|
|
662
662
|
let n = "";
|
|
663
663
|
if (e.typedValue !== void 0) {
|
|
664
|
-
const d =
|
|
665
|
-
n = We(
|
|
666
|
-
} else if (e.percentage !== void 0 && t &&
|
|
667
|
-
const d =
|
|
668
|
-
n =
|
|
669
|
-
} else t &&
|
|
664
|
+
const d = T(e.typedValue), b = e.isInverted ? d.isZero() ? T(0) : T(1).dividedBy(d) : d;
|
|
665
|
+
n = We(b.toFixed(), e.tokenDecimals);
|
|
666
|
+
} else if (e.percentage !== void 0 && t && T(t).gt(0)) {
|
|
667
|
+
const d = T(e.percentage || 0).dividedBy(100);
|
|
668
|
+
n = T(t).plus(T(t).multipliedBy(d)).decimalPlaces(0).toFixed();
|
|
669
|
+
} else t && T(t).gt(0) && (n = T(t).decimalPlaces(0).toFixed());
|
|
670
670
|
const i = H(n);
|
|
671
671
|
let a = "";
|
|
672
|
-
if (t && !
|
|
672
|
+
if (t && !T(t).isZero()) {
|
|
673
673
|
if (e.percentage !== void 0 && e.percentage !== null)
|
|
674
674
|
a = e.percentage;
|
|
675
675
|
else if (i) {
|
|
676
|
-
const d =
|
|
677
|
-
a =
|
|
676
|
+
const d = T(i).minus(t).dividedBy(t).multipliedBy(100).decimalPlaces(2).toString();
|
|
677
|
+
a = T(d).isZero() ? "" : d;
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
return {
|
|
@@ -686,15 +686,15 @@ const H = (e) => {
|
|
|
686
686
|
}, ft = (e) => {
|
|
687
687
|
const t = (d) => {
|
|
688
688
|
if (!d) return "";
|
|
689
|
-
const
|
|
690
|
-
return
|
|
689
|
+
const b = T(d);
|
|
690
|
+
return b.isFinite() && !b.isNaN() ? d : "";
|
|
691
691
|
};
|
|
692
692
|
let n = "";
|
|
693
693
|
if (e.typedValue !== void 0)
|
|
694
694
|
n = t(e.typedValue);
|
|
695
695
|
else {
|
|
696
696
|
const d = ze(e.raw, e.amountDecimals ?? 18);
|
|
697
|
-
d && !
|
|
697
|
+
d && !T(d).isZero() && (n = e.isInverted ? T(1).dividedBy(d).toFixed() : d);
|
|
698
698
|
}
|
|
699
699
|
const i = n ? e.isInverted ? t(We(n, e.invertedAmountDecimals ?? 18)) : t(e.raw) : "", a = e.isInverted ? e.invertedAmountUsdPrice : e.amountUsdPrice;
|
|
700
700
|
return {
|
|
@@ -704,8 +704,8 @@ const H = (e) => {
|
|
|
704
704
|
};
|
|
705
705
|
}, $r = (e) => {
|
|
706
706
|
if (e === void 0 || e === "") return e;
|
|
707
|
-
const t =
|
|
708
|
-
return !t.isFinite() || t.isNaN() || t.isZero() ? "0" :
|
|
707
|
+
const t = T(e);
|
|
708
|
+
return !t.isFinite() || t.isNaN() || t.isZero() ? "0" : T(1).dividedBy(t).toFixed();
|
|
709
709
|
}, St = (e) => {
|
|
710
710
|
if (e === v.STOP_LOSS) return Ft;
|
|
711
711
|
if (e === v.TAKE_PROFIT) return Ct;
|
|
@@ -717,18 +717,18 @@ const H = (e) => {
|
|
|
717
717
|
return wt;
|
|
718
718
|
}
|
|
719
719
|
}, Ot = (e, t, n, i) => {
|
|
720
|
-
if (!(
|
|
721
|
-
if (e === v.STOP_LOSS &&
|
|
720
|
+
if (!(T(t || "0").isZero() || !n || e !== v.STOP_LOSS && e !== v.TAKE_PROFIT)) {
|
|
721
|
+
if (e === v.STOP_LOSS && T(i || 0).gte(n))
|
|
722
722
|
return {
|
|
723
723
|
type: J.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,
|
|
724
724
|
value: n
|
|
725
725
|
};
|
|
726
|
-
if (e === v.TAKE_PROFIT &&
|
|
726
|
+
if (e === v.TAKE_PROFIT && T(i || 0).lte(n))
|
|
727
727
|
return {
|
|
728
728
|
type: J.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,
|
|
729
729
|
value: n
|
|
730
730
|
};
|
|
731
|
-
if (!i ||
|
|
731
|
+
if (!i || T(i).isZero())
|
|
732
732
|
return {
|
|
733
733
|
type: J.EMPTY_TRIGGER_PRICE,
|
|
734
734
|
value: i
|
|
@@ -762,13 +762,13 @@ const H = (e) => {
|
|
|
762
762
|
)
|
|
763
763
|
};
|
|
764
764
|
}, _t = (e, t, n) => {
|
|
765
|
-
if (!(
|
|
766
|
-
if ((e.module === v.STOP_LOSS || e.module === v.TAKE_PROFIT) && e.triggerPrice &&
|
|
765
|
+
if (!(T(e.inputAmountRaw || "0").isZero() || !t || e.isMarketOrder)) {
|
|
766
|
+
if ((e.module === v.STOP_LOSS || e.module === v.TAKE_PROFIT) && e.triggerPrice && T(n || 0).gte(e.triggerPrice))
|
|
767
767
|
return {
|
|
768
768
|
type: J.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,
|
|
769
769
|
value: e.triggerPrice
|
|
770
770
|
};
|
|
771
|
-
if (!n ||
|
|
771
|
+
if (!n || T(n).isZero())
|
|
772
772
|
return {
|
|
773
773
|
type: J.MISSING_LIMIT_PRICE,
|
|
774
774
|
value: n
|
|
@@ -846,6 +846,7 @@ const Nt = {
|
|
|
846
846
|
999: { adapter: { Nordstern: "0xA9c6c1F14c1d0eF2ab6ec79E5dcF0ff3a3680F05", Ring: "0x47e27973dA3e16dB13F8b713877b3A31623E0E5B", Kyber: "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", Sushi: "0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba" }, dex: { ring: { type: "dynamicp2", solver: "Ring", permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3", adapter: "0x028fa69049aB68EC42064Eb18896D587dD41Af2a", fee: "0xA04329696aAd1417c75Cf6d91342815001999B21" } } },
|
|
847
847
|
1329: { adapter: { Nordstern: "0xd16A1849E86431872a87f476fa0DfB30eEb96cb3", DragonSwap: "0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502", OpenOcean: "0xc7f07C830e22FCA94bF52F38C6707F9D396c6172" }, dex: { dragon: { type: "default", solver: "DragonSwap", router: "0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428", adapter: "0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502", fee: "0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334" }, nami: { type: "default", solver: "OpenOcean", router: "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64", adapter: "0xba56F9A7865d430c8293851D576b5728Ca711ff5", fee: "0xeB58450e23632003f013568703F54446070E2E80" } } },
|
|
848
848
|
4326: { adapter: { Ring: "0x47e27973dA3e16dB13F8b713877b3A31623E0E5B", Kyber: "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", Sushi: "0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba" }, dex: { ring: { type: "dynamicp2", solver: "Ring", permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3", adapter: "0x028fa69049aB68EC42064Eb18896D587dD41Af2a", fee: "0xA04329696aAd1417c75Cf6d91342815001999B21" } } },
|
|
849
|
+
4663: { adapter: { Kyber: "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA", Magpie: "0xe757b37EDbE768f487a8Fc66BB48bbdb85412570", OpenOcean: "0xF4087df1F43De3B8e84171c1434da5aE0355796C", LiFi: "0xA75eA4C3570Ec0ebCbe79176B8D6E06839C36c84" }, dex: { orvex: { type: "universal", adapter: "0xbdf2A1565f0fa68974d703e3F0505e26DBeB604f", fee: "0xA31F236b8f9cb321258824d33472D7b06d98D648" } } },
|
|
849
850
|
8453: { adapter: { Nordstern: "0xd16A1849E86431872a87f476fa0DfB30eEb96cb3", Orbs: "0x917b492557957f5dD3e69c04c8E1Ac3d6948c022", Kyber: "0x6f4e5b8d7F6b037c62277992c39E7834D7C04596", TrebleSwap: "0x6f4938535879c668A797F2a6e9B912c54f9D43Cf", Sushi: "0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c", Ring: "0x47e27973dA3e16dB13F8b713877b3A31623E0E5B", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d", Paraswap: "0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f" }, dex: { pancake: { type: "p2", solver: "Orbs", router: "0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912", permit2: "0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768", adapter: "0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75", fee: "0x37A957f10F458e0d7fDECBE2917971b57F15c927" }, quick: { type: "default", solver: "Kyber", router: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", adapter: "0x0438644898F69bfF1018Cb01a81877D14d3e6493", fee: "0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f" }, trebleswap: { type: "default", solver: "TrebleSwap", router: "0x347539D82A14C0A3a89769f1024774A545a151ac", adapter: "0x6f4938535879c668A797F2a6e9B912c54f9D43Cf", fee: "0x15fc883d7DF4e681Ddb9E43e7B1D8c61d4fC162C" }, sushiswap: { type: "default", solver: "Sushi", router: "0xAC4c6e212A361c968F1725b4d055b47E63F80b75", adapter: "0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df", fee: "0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc" }, ring: { type: "dynamicp2", solver: "Ring", permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3", adapter: "0x028fa69049aB68EC42064Eb18896D587dD41Af2a", fee: "0xA04329696aAd1417c75Cf6d91342815001999B21" } } },
|
|
850
851
|
42161: { adapter: { Nordstern: "0x52756370A08F63ADE4900A9c3046cf93ac0397e5", Paraswap: "0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D", Orbs: "0x917b492557957f5dD3e69c04c8E1Ac3d6948c022", Sushi: "0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c", Ring: "0x47e27973dA3e16dB13F8b713877b3A31623E0E5B", Kyber: "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d" }, dex: { ramses: { type: "paraswap", solver: "Paraswap", router: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57", adapter: "0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8", fee: "0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af" }, omni: { type: "paraswap", solver: "Paraswap", router: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57", adapter: "0x41c925E8E4fC65136BDf5322824E0D8c20c4824e", fee: "0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa" }, pancake: { type: "p2", solver: "Orbs", router: "0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912", permit2: "0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768", adapter: "0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75", fee: "0x37A957f10F458e0d7fDECBE2917971b57F15c927" }, sushiswap: { type: "default", solver: "Sushi", router: "0xAC4c6e212A361c968F1725b4d055b47E63F80b75", adapter: "0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df", fee: "0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc" }, ring: { type: "dynamicp2", solver: "Ring", permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3", adapter: "0x028fa69049aB68EC42064Eb18896D587dD41Af2a", fee: "0xA04329696aAd1417c75Cf6d91342815001999B21" } } },
|
|
851
852
|
43114: { adapter: { Nordstern: "0x1D06d98D523F8B51AD693D4A22fb97fCf0838d83", Kyber: "0x6f4e5b8d7F6b037c62277992c39E7834D7C04596", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d", Paraswap: "0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f", Sushi: "0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba" }, dex: { blackhole: { type: "default", solver: "Kyber", router: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", adapter: "0xccdF1D6ce95FeC0F842197470CE8969A678B0A04", fee: "0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928" }, pangolin: { type: "default", solver: "Kyber", router: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", adapter: "0xf42106eBf985bF49b39eba0114F57FA05e7B52eD", fee: "0xde92da99D188Ceb54A11ec711EF52D808A6260B5" } } },
|
|
@@ -868,19 +869,19 @@ function Lt() {
|
|
|
868
869
|
adapter: t("DefaultDexAdapter")
|
|
869
870
|
});
|
|
870
871
|
function i(d) {
|
|
871
|
-
var
|
|
872
|
+
var m;
|
|
872
873
|
if (!d) return;
|
|
873
|
-
const
|
|
874
|
-
if (
|
|
875
|
-
return { ...((
|
|
874
|
+
const b = e[d];
|
|
875
|
+
if (b)
|
|
876
|
+
return { ...((m = e["*"]) == null ? void 0 : m.adapter) ?? {}, ...b.adapter ?? {} };
|
|
876
877
|
}
|
|
877
|
-
function a(d,
|
|
878
|
+
function a(d, b) {
|
|
878
879
|
if (!d) return;
|
|
879
|
-
const { dex:
|
|
880
|
+
const { dex: m, salt: D, ...C } = e["*"] ?? {}, O = e[d];
|
|
880
881
|
if (!O) return;
|
|
881
|
-
const { dex: F, salt: h, ...w } = O, B = { ...C, ...w }, V =
|
|
882
|
+
const { dex: F, salt: h, ...w } = O, B = { ...C, ...w }, V = b == null ? void 0 : b.trim();
|
|
882
883
|
if (!V) return B;
|
|
883
|
-
const K =
|
|
884
|
+
const K = m == null ? void 0 : m[V], z = F == null ? void 0 : F[V];
|
|
884
885
|
if (!(!K && !z))
|
|
885
886
|
return { ...B, ...K, ...z };
|
|
886
887
|
}
|
|
@@ -894,8 +895,8 @@ const Ut = new Set(Object.values(Q)), $t = (e) => Ut.has(e), At = () => {
|
|
|
894
895
|
if (i === "*") return [];
|
|
895
896
|
const d = Number(i);
|
|
896
897
|
if (!Number.isSafeInteger(d)) return [];
|
|
897
|
-
const
|
|
898
|
-
return Object.keys(
|
|
898
|
+
const b = { ...t, ...(a == null ? void 0 : a.dex) ?? {} };
|
|
899
|
+
return Object.keys(b).filter($t).filter((m) => !!Ge.config(d, m)).map((m) => ({ chainId: d, name: m }));
|
|
899
900
|
}).sort(
|
|
900
901
|
(i, a) => i.name.localeCompare(a.name) || i.chainId - a.chainId
|
|
901
902
|
);
|
|
@@ -1018,10 +1019,10 @@ const Ut = new Set(Object.values(Q)), $t = (e) => Ut.has(e), At = () => {
|
|
|
1018
1019
|
}, ln = (e, t) => {
|
|
1019
1020
|
var n;
|
|
1020
1021
|
return (n = un[e]) == null ? void 0 : n.get(t);
|
|
1021
|
-
}, fn = (e) => e.bidDelaySeconds * 1e3 * 2,
|
|
1022
|
+
}, fn = (e) => e.bidDelaySeconds * 1e3 * 2, me = (e, t) => {
|
|
1022
1023
|
if (e == null || !t) return "";
|
|
1023
|
-
const n =
|
|
1024
|
-
return
|
|
1024
|
+
const n = T(10).pow(e);
|
|
1025
|
+
return T(t).times(n).idiv(n).div(n).toFixed();
|
|
1025
1026
|
};
|
|
1026
1027
|
function ke(e, t) {
|
|
1027
1028
|
return e == t || e.toLowerCase() == t.toLowerCase();
|
|
@@ -1039,7 +1040,7 @@ function An(e) {
|
|
|
1039
1040
|
se.Minutes
|
|
1040
1041
|
].find((n) => n <= e) || se.Minutes;
|
|
1041
1042
|
}
|
|
1042
|
-
const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0" :
|
|
1043
|
+
const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0" : T(e).decimalPlaces(0).toFixed(), Kr = (e) => {
|
|
1043
1044
|
const t = [e];
|
|
1044
1045
|
return typeof e == "object" && e !== null && t.push(Reflect.get(e, "error"), Reflect.get(e, "cause")), t.some((n) => {
|
|
1045
1046
|
if (typeof n != "object" || n === null)
|
|
@@ -1063,34 +1064,34 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1063
1064
|
);
|
|
1064
1065
|
return Array.from(i);
|
|
1065
1066
|
}, Vr = (e, t) => e.version === 1 ? (e.fillDelay || 0) * 1e3 + (t ? fn(t) : 0) : e.fillDelay || 0, Gr = (e) => At().filter((t) => t.name === e).map((t) => t.chainId), qr = (e = "", t = "", n = 18, i = 18) => {
|
|
1066
|
-
if (!
|
|
1067
|
+
if (!T(e || 0).gt(0) || !T(t || 0).gt(0))
|
|
1067
1068
|
return "";
|
|
1068
|
-
const a =
|
|
1069
|
-
return
|
|
1069
|
+
const a = me(n, e), d = me(i, t);
|
|
1070
|
+
return T(d).div(a).toFixed();
|
|
1070
1071
|
}, Wr = (e, t, n) => {
|
|
1071
1072
|
if (e.type === N.TWAP_MARKET) return "";
|
|
1072
|
-
const i =
|
|
1073
|
-
return
|
|
1073
|
+
const i = me(t, e.srcAmountPerTrade), a = me(n, e.dstMinAmountPerTrade);
|
|
1074
|
+
return T(a).div(i).toFixed();
|
|
1074
1075
|
}, zr = (e, t, n) => {
|
|
1075
1076
|
if (e.type === N.TWAP_MARKET) return "";
|
|
1076
|
-
const i =
|
|
1077
|
-
return
|
|
1078
|
-
},
|
|
1077
|
+
const i = me(t, e.srcAmountPerTrade), a = me(n, e.triggerPricePerTrade);
|
|
1078
|
+
return T(a).div(i).toFixed();
|
|
1079
|
+
}, bn = (e, t, n, i) => {
|
|
1079
1080
|
const a = he(n) * 2 * t;
|
|
1080
1081
|
if (i) return i;
|
|
1081
1082
|
if (e === v.LIMIT) return { unit: se.Days, value: 7 };
|
|
1082
1083
|
if (e === v.STOP_LOSS || e === v.TAKE_PROFIT)
|
|
1083
1084
|
return { unit: se.Days, value: 1 };
|
|
1084
1085
|
const d = An(a);
|
|
1085
|
-
return { unit: d, value: Number(
|
|
1086
|
-
},
|
|
1086
|
+
return { unit: d, value: Number(T(a / d).toFixed(2)) };
|
|
1087
|
+
}, mn = (e, t, n) => t !== v.TWAP ? 1 : n !== void 0 ? n : Math.max(1, Math.ceil(e / 2)), hn = (e, t, n) => {
|
|
1087
1088
|
if (!e || !t || !n) return 1;
|
|
1088
|
-
const a =
|
|
1089
|
+
const a = T(t).times(e).div(n).integerValue(T.ROUND_FLOOR).toNumber();
|
|
1089
1090
|
return Math.max(1, a);
|
|
1090
|
-
},
|
|
1091
|
+
}, xn = (e, t) => ({
|
|
1091
1092
|
isError: !(e.unit === Ve.unit && e.value === Ve.value) && he(e) * t > Oe,
|
|
1092
1093
|
value: Math.floor(Oe / t)
|
|
1093
|
-
}),
|
|
1094
|
+
}), Tn = (e, t) => e === v.STOP_LOSS || e === v.TAKE_PROFIT ? {
|
|
1094
1095
|
isError: he(t) > 5184e6,
|
|
1095
1096
|
value: 5184e6
|
|
1096
1097
|
} : {
|
|
@@ -1103,7 +1104,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1103
1104
|
isError: he(e) < Ke,
|
|
1104
1105
|
value: Ke
|
|
1105
1106
|
}), Fn = (e, t, n) => ({
|
|
1106
|
-
isError: n === v.TWAP &&
|
|
1107
|
+
isError: n === v.TWAP && T(e).isGreaterThan(t),
|
|
1107
1108
|
value: t
|
|
1108
1109
|
}), Cn = (e, t) => {
|
|
1109
1110
|
const n = Number.isFinite(t) ? Math.floor(t) : 1;
|
|
@@ -1112,7 +1113,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1112
1113
|
const t = e.unit * e.value;
|
|
1113
1114
|
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
1114
1115
|
}, Bn = (e) => {
|
|
1115
|
-
const t = Cn(e.module, e.totalTrades), n = e.fillDelay ?? { ...Ve }, i =
|
|
1116
|
+
const t = Cn(e.module, e.totalTrades), n = e.fillDelay ?? { ...Ve }, i = bn(
|
|
1116
1117
|
e.module,
|
|
1117
1118
|
t,
|
|
1118
1119
|
n,
|
|
@@ -1132,7 +1133,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1132
1133
|
const i = t / 60;
|
|
1133
1134
|
return i >= 1 ? `${i.toFixed(i % 1 ? 1 : 0)} ${i === 1 ? "hour" : "hours"}` : `${t.toFixed(t % 1 ? 1 : 0)} ${t === 1 ? "minute" : "minutes"}`;
|
|
1134
1135
|
}, wn = (e, t, n, i, a) => {
|
|
1135
|
-
if (
|
|
1136
|
+
if (T(n.raw || "0").isZero() || !t || T(e.inputTokenUsdPrice || "0").isZero())
|
|
1136
1137
|
return;
|
|
1137
1138
|
if (!i)
|
|
1138
1139
|
return {
|
|
@@ -1151,7 +1152,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1151
1152
|
args: { maxTrades: `${a}` }
|
|
1152
1153
|
};
|
|
1153
1154
|
}, Sn = (e, t, n) => {
|
|
1154
|
-
if (
|
|
1155
|
+
if (T(e || "0").isZero() || !t) return;
|
|
1155
1156
|
const i = Dn(n.fillDelay);
|
|
1156
1157
|
if (i.isError)
|
|
1157
1158
|
return {
|
|
@@ -1159,7 +1160,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1159
1160
|
value: i.value,
|
|
1160
1161
|
args: { fillDelay: at(i.value) }
|
|
1161
1162
|
};
|
|
1162
|
-
const a =
|
|
1163
|
+
const a = xn(
|
|
1163
1164
|
n.fillDelay,
|
|
1164
1165
|
n.totalTrades
|
|
1165
1166
|
);
|
|
@@ -1170,8 +1171,8 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1170
1171
|
args: { fillDelay: at(a.value) }
|
|
1171
1172
|
};
|
|
1172
1173
|
}, Pn = (e, t, n, i) => {
|
|
1173
|
-
if (
|
|
1174
|
-
const a =
|
|
1174
|
+
if (T(t || "0").isZero() || !n) return;
|
|
1175
|
+
const a = Tn(e, i.duration);
|
|
1175
1176
|
if (a.isError)
|
|
1176
1177
|
return {
|
|
1177
1178
|
type: J.MAX_ORDER_DURATION,
|
|
@@ -1190,70 +1191,70 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1190
1191
|
}
|
|
1191
1192
|
};
|
|
1192
1193
|
}, On = (e, t) => {
|
|
1193
|
-
if (!(!
|
|
1194
|
+
if (!(!T(e.raw || 0).gt(0) || !e.usd) && T(t).gt(e.usd))
|
|
1194
1195
|
return {
|
|
1195
1196
|
type: J.MIN_TRADE_SIZE,
|
|
1196
1197
|
value: t,
|
|
1197
1198
|
args: { minTradeSize: `${t}` }
|
|
1198
1199
|
};
|
|
1199
1200
|
}, kn = (e, t, n, i, a, d) => {
|
|
1200
|
-
const
|
|
1201
|
+
const b = On(
|
|
1201
1202
|
t,
|
|
1202
1203
|
e.minTradeSizeUsd
|
|
1203
|
-
),
|
|
1204
|
+
), m = e.inputBalanceRaw && T(t.raw).gt(e.inputBalanceRaw) ? {
|
|
1204
1205
|
type: J.INSUFFICIENT_BALANCE,
|
|
1205
1206
|
value: e.inputBalanceRaw
|
|
1206
1207
|
} : void 0, D = [
|
|
1207
|
-
|
|
1208
|
+
b,
|
|
1208
1209
|
d.triggerPrice.error,
|
|
1209
1210
|
d.limitPrice.error,
|
|
1210
1211
|
i.error,
|
|
1211
1212
|
a.fillDelayError,
|
|
1212
1213
|
a.durationError,
|
|
1213
|
-
|
|
1214
|
-
].filter((F) => !!F), C =
|
|
1214
|
+
m
|
|
1215
|
+
].filter((F) => !!F), C = T(n || 0).gt(0) && T(t.raw || 0).gt(0) && T(e.inputTokenUsdPrice || 0).gt(0), O = C ? D[0] : void 0;
|
|
1215
1216
|
return {
|
|
1216
1217
|
errors: {
|
|
1217
1218
|
primary: O,
|
|
1218
1219
|
all: D,
|
|
1219
|
-
minTradeSize:
|
|
1220
|
+
minTradeSize: b,
|
|
1220
1221
|
triggerPrice: d.triggerPrice.error,
|
|
1221
1222
|
limitPrice: d.limitPrice.error,
|
|
1222
1223
|
trades: i.error,
|
|
1223
1224
|
fillDelay: a.fillDelayError,
|
|
1224
1225
|
duration: a.durationError,
|
|
1225
|
-
balance:
|
|
1226
|
+
balance: m
|
|
1226
1227
|
},
|
|
1227
1228
|
isReady: C,
|
|
1228
1229
|
canSubmit: C && !O
|
|
1229
1230
|
};
|
|
1230
1231
|
}, _n = (e, t, n) => {
|
|
1231
1232
|
if (!(!e || !t || n == null))
|
|
1232
|
-
return
|
|
1233
|
+
return T(e).times(t).div(T(10).pow(n)).toFixed(0);
|
|
1233
1234
|
}, vn = (e, t, n, i) => {
|
|
1234
1235
|
if (n || i == null || !e || !t)
|
|
1235
1236
|
return "0";
|
|
1236
|
-
const a =
|
|
1237
|
-
return
|
|
1237
|
+
const a = T(e).times(t).div(T(10).pow(i));
|
|
1238
|
+
return T.max(1, a).integerValue(T.ROUND_FLOOR).toFixed(0);
|
|
1238
1239
|
}, In = (e, t, n, i) => {
|
|
1239
1240
|
if (e === v.TWAP || e === v.LIMIT) return "0";
|
|
1240
1241
|
if (i == null || !t || !n)
|
|
1241
1242
|
return;
|
|
1242
|
-
const a =
|
|
1243
|
-
return
|
|
1244
|
-
}, Rn = (e = "", t = 0) => !e || !t ? "0" :
|
|
1243
|
+
const a = T(t).times(n).div(T(10).pow(i));
|
|
1244
|
+
return T.max(1, a).integerValue(T.ROUND_FLOOR).toFixed(0);
|
|
1245
|
+
}, Rn = (e = "", t = 0) => !e || !t ? "0" : T(e).div(t).integerValue(T.ROUND_FLOOR).toFixed(0), Mn = (e, t) => e === v.LIMIT ? N.LIMIT : e === v.STOP_LOSS ? t ? N.STOP_LOSS_MARKET : N.STOP_LOSS_LIMIT : e === v.TAKE_PROFIT ? t ? N.TAKE_PROFIT_MARKET : N.TAKE_PROFIT_LIMIT : t ? N.TWAP_MARKET : N.TWAP_LIMIT, Nn = ({
|
|
1245
1246
|
module: e,
|
|
1246
1247
|
isMarketOrder: t,
|
|
1247
1248
|
marketPrice: n,
|
|
1248
1249
|
limitPrice: i,
|
|
1249
1250
|
triggerPrice: a
|
|
1250
|
-
}) => e === v.LIMIT || !t ? H(i) : e === v.STOP_LOSS || e === v.TAKE_PROFIT ? H(a) : H(n), Ln = (e, t) => !e || !t ? "" :
|
|
1251
|
-
const t = Bn(e), n = Number.isFinite(e.priceProtectionPercent) ? e.priceProtectionPercent * 100 : 0, i = typeof e.displayFeePercent == "number" && Number.isFinite(e.displayFeePercent) ? e.displayFeePercent : 0, a = H(e.totalInputAmount), d = H(e.marketPrice),
|
|
1251
|
+
}) => e === v.LIMIT || !t ? H(i) : e === v.STOP_LOSS || e === v.TAKE_PROFIT ? H(a) : H(n), Ln = (e, t) => !e || !t ? "" : T(e).multipliedBy(t).decimalPlaces(0).toFixed(), Un = (e) => {
|
|
1252
|
+
const t = Bn(e), n = Number.isFinite(e.priceProtectionPercent) ? e.priceProtectionPercent * 100 : 0, i = typeof e.displayFeePercent == "number" && Number.isFinite(e.displayFeePercent) ? e.displayFeePercent : 0, a = H(e.totalInputAmount), d = H(e.marketPrice), b = H(e.limitPrice), m = H(e.triggerPrice), D = Nn({
|
|
1252
1253
|
module: e.module,
|
|
1253
1254
|
isMarketOrder: e.isMarketOrder,
|
|
1254
1255
|
marketPrice: d,
|
|
1255
|
-
limitPrice:
|
|
1256
|
-
triggerPrice:
|
|
1256
|
+
limitPrice: b,
|
|
1257
|
+
triggerPrice: m
|
|
1257
1258
|
}), C = Rn(
|
|
1258
1259
|
a,
|
|
1259
1260
|
t.totalTrades
|
|
@@ -1261,7 +1262,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1261
1262
|
_n(a, D, e.inputTokenDecimals)
|
|
1262
1263
|
), F = vn(
|
|
1263
1264
|
C,
|
|
1264
|
-
|
|
1265
|
+
b,
|
|
1265
1266
|
e.isMarketOrder,
|
|
1266
1267
|
e.inputTokenDecimals
|
|
1267
1268
|
), h = Ln(
|
|
@@ -1270,9 +1271,9 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1270
1271
|
), w = In(
|
|
1271
1272
|
e.module,
|
|
1272
1273
|
C,
|
|
1273
|
-
|
|
1274
|
+
m,
|
|
1274
1275
|
e.inputTokenDecimals
|
|
1275
|
-
) || "0", B = i && O ?
|
|
1276
|
+
) || "0", B = i && O ? T(O).multipliedBy(i).dividedBy(100).toFixed(0) : "";
|
|
1276
1277
|
return {
|
|
1277
1278
|
...t,
|
|
1278
1279
|
orderType: Mn(e.module, e.isMarketOrder),
|
|
@@ -1287,8 +1288,8 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1287
1288
|
triggerOutputAmountPerTrade: w,
|
|
1288
1289
|
tradePrice: D,
|
|
1289
1290
|
marketPrice: d,
|
|
1290
|
-
limitPrice:
|
|
1291
|
-
triggerPrice:
|
|
1291
|
+
limitPrice: b,
|
|
1292
|
+
triggerPrice: m,
|
|
1292
1293
|
displayFeeAmount: B,
|
|
1293
1294
|
displayFeePercent: i
|
|
1294
1295
|
};
|
|
@@ -1303,14 +1304,14 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1303
1304
|
);
|
|
1304
1305
|
return {
|
|
1305
1306
|
...n,
|
|
1306
|
-
isEmpty: !
|
|
1307
|
+
isEmpty: !T(n.raw || 0).gt(0)
|
|
1307
1308
|
};
|
|
1308
1309
|
}, Kn = (e, t, n) => {
|
|
1309
1310
|
const i = hn(
|
|
1310
1311
|
t.ui,
|
|
1311
1312
|
e.inputTokenUsdPrice,
|
|
1312
1313
|
e.minTradeSizeUsd
|
|
1313
|
-
), a =
|
|
1314
|
+
), a = mn(
|
|
1314
1315
|
i,
|
|
1315
1316
|
e.module,
|
|
1316
1317
|
e.userInput.tradeCount
|
|
@@ -1372,7 +1373,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1372
1373
|
e,
|
|
1373
1374
|
t,
|
|
1374
1375
|
a
|
|
1375
|
-
),
|
|
1376
|
+
), b = It(e, n, a), m = Un({
|
|
1376
1377
|
module: e.module,
|
|
1377
1378
|
inputTokenDecimals: e.inputTokenDecimals,
|
|
1378
1379
|
totalInputAmount: n,
|
|
@@ -1380,57 +1381,57 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1380
1381
|
duration: e.userInput.orderDuration,
|
|
1381
1382
|
totalTrades: d.totalTrades,
|
|
1382
1383
|
priceProtectionPercent: e.priceProtectionPercent,
|
|
1383
|
-
isMarketOrder:
|
|
1384
|
+
isMarketOrder: b.isMarketOrder,
|
|
1384
1385
|
marketPrice: a,
|
|
1385
|
-
limitPrice:
|
|
1386
|
-
triggerPrice:
|
|
1386
|
+
limitPrice: b.limitPrice.raw,
|
|
1387
|
+
triggerPrice: b.triggerPrice.raw,
|
|
1387
1388
|
displayFeePercent: e.displayFeePercent
|
|
1388
1389
|
}), D = Gn(
|
|
1389
1390
|
e,
|
|
1390
1391
|
n,
|
|
1391
1392
|
a,
|
|
1392
|
-
|
|
1393
|
-
), C = Vn(e, d,
|
|
1393
|
+
m
|
|
1394
|
+
), C = Vn(e, d, m), O = kn(
|
|
1394
1395
|
e,
|
|
1395
1396
|
t,
|
|
1396
1397
|
a,
|
|
1397
1398
|
d,
|
|
1398
1399
|
D,
|
|
1399
|
-
|
|
1400
|
+
b
|
|
1400
1401
|
);
|
|
1401
1402
|
return {
|
|
1402
1403
|
module: e.module,
|
|
1403
1404
|
isInverted: !!e.userInput.isPriceInverted,
|
|
1404
1405
|
inputAmount: t,
|
|
1405
1406
|
outputAmount: Ae(
|
|
1406
|
-
|
|
1407
|
+
m.outputAmount,
|
|
1407
1408
|
e.outputTokenDecimals,
|
|
1408
1409
|
e.outputTokenUsdPrice
|
|
1409
1410
|
),
|
|
1410
1411
|
marketPrice: i,
|
|
1411
1412
|
trades: C,
|
|
1412
1413
|
schedule: D,
|
|
1413
|
-
triggerPrice:
|
|
1414
|
-
limitPrice:
|
|
1414
|
+
triggerPrice: b.triggerPrice,
|
|
1415
|
+
limitPrice: b.limitPrice,
|
|
1415
1416
|
minOutputAmountTotal: Ae(
|
|
1416
|
-
|
|
1417
|
+
m.minOutputAmountTotal,
|
|
1417
1418
|
e.outputTokenDecimals,
|
|
1418
1419
|
e.outputTokenUsdPrice
|
|
1419
1420
|
),
|
|
1420
1421
|
tradePrice: Ae(
|
|
1421
|
-
|
|
1422
|
+
m.tradePrice,
|
|
1422
1423
|
e.outputTokenDecimals,
|
|
1423
1424
|
e.outputTokenUsdPrice
|
|
1424
1425
|
),
|
|
1425
1426
|
fees: {
|
|
1426
1427
|
...Ae(
|
|
1427
|
-
|
|
1428
|
+
m.displayFeeAmount,
|
|
1428
1429
|
e.outputTokenDecimals,
|
|
1429
1430
|
e.outputTokenUsdPrice
|
|
1430
1431
|
),
|
|
1431
|
-
percentage:
|
|
1432
|
+
percentage: m.displayFeePercent
|
|
1432
1433
|
},
|
|
1433
|
-
values:
|
|
1434
|
+
values: m,
|
|
1434
1435
|
...O
|
|
1435
1436
|
};
|
|
1436
1437
|
}, qn = /* @__PURE__ */ JSON.parse('[{"inputs":[{"internalType":"address","name":"_iweth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"name":"OrderBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"OrderCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"}],"name":"OrderCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"}],"name":"OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"srcFilledAmount","type":"uint256"}],"name":"OrderFilled","type":"event"},{"inputs":[],"name":"MIN_BID_DELAY_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_OUTBID_PERCENT","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERCENT_BASE","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STALE_BID_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_CANCELED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_COMPLETED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"_ask","type":"tuple"}],"name":"ask","outputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"book","outputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"fill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"iweth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"length","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"makerOrders","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"order","outputs":[{"components":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"internalType":"struct OrderLib.Order","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"maker","type":"address"}],"name":"orderIdsByMaker","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"prune","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"status","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]'), Wn = [
|
|
@@ -1745,7 +1746,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1745
1746
|
}
|
|
1746
1747
|
]
|
|
1747
1748
|
}
|
|
1748
|
-
], zn = Wn, jn = qn, Xn = "2.
|
|
1749
|
+
], zn = Wn, jn = qn, Xn = "2.9.0", ve = {
|
|
1749
1750
|
version: Xn
|
|
1750
1751
|
}, Hn = 0.7, Yn = `https://bi.orbs.network/putes/twap-ui-${Hn}`;
|
|
1751
1752
|
let Pe = "unknown";
|
|
@@ -1902,8 +1903,8 @@ class Jn {
|
|
|
1902
1903
|
module: i,
|
|
1903
1904
|
srcToken: a,
|
|
1904
1905
|
dstToken: d,
|
|
1905
|
-
fromTokenAmount:
|
|
1906
|
-
srcChunkAmount:
|
|
1906
|
+
fromTokenAmount: b,
|
|
1907
|
+
srcChunkAmount: m,
|
|
1907
1908
|
minDstAmountOutPerTrade: D = "",
|
|
1908
1909
|
triggerPricePerTrade: C = "",
|
|
1909
1910
|
deadline: O,
|
|
@@ -1917,9 +1918,9 @@ class Jn {
|
|
|
1917
1918
|
toTokenSymbol: d.symbol,
|
|
1918
1919
|
fromTokenAddress: a.address,
|
|
1919
1920
|
fromTokenSymbol: a.symbol,
|
|
1920
|
-
fromTokenAmount:
|
|
1921
|
+
fromTokenAmount: b,
|
|
1921
1922
|
chunksAmount: B,
|
|
1922
|
-
srcChunkAmount:
|
|
1923
|
+
srcChunkAmount: m,
|
|
1923
1924
|
minDstAmountOutPerTrade: D,
|
|
1924
1925
|
triggerPricePerTrade: C,
|
|
1925
1926
|
deadline: O,
|
|
@@ -1949,7 +1950,7 @@ class Jn {
|
|
|
1949
1950
|
const d = `${t}:${i || 0}:${a || ""}`;
|
|
1950
1951
|
if (d !== this.moduleImportKey) {
|
|
1951
1952
|
this.moduleImportKey = d;
|
|
1952
|
-
const
|
|
1953
|
+
const b = {
|
|
1953
1954
|
_id: we(),
|
|
1954
1955
|
action: "module-import",
|
|
1955
1956
|
uiVersion: Pe,
|
|
@@ -1957,7 +1958,7 @@ class Jn {
|
|
|
1957
1958
|
...Zn(t, n, i),
|
|
1958
1959
|
origin: window.location.origin
|
|
1959
1960
|
};
|
|
1960
|
-
this.configDetails.partner === t && this.configDetails.chainId === (i || 0) || (this.configDetails = {}), this.data = { ...
|
|
1961
|
+
this.configDetails.partner === t && this.configDetails.chainId === (i || 0) || (this.configDetails = {}), this.data = { ...b, ...this.configDetails }, Se(b);
|
|
1961
1962
|
}
|
|
1962
1963
|
}
|
|
1963
1964
|
onFetchedConfig(t, n, i, a) {
|
|
@@ -1966,8 +1967,8 @@ class Jn {
|
|
|
1966
1967
|
n,
|
|
1967
1968
|
i,
|
|
1968
1969
|
a
|
|
1969
|
-
),
|
|
1970
|
-
|
|
1970
|
+
), b = `${n}:${d.chainId}:${d.repermit}:${d.adapter}:${d.executor}:${d.reactor}`;
|
|
1971
|
+
b !== this.configUpdateKey && (this.configUpdateKey = b, this.configDetails = d, this.data = { ...this.data, ...d }, Se({
|
|
1971
1972
|
_id: we(),
|
|
1972
1973
|
action: "config-update",
|
|
1973
1974
|
uiVersion: Pe,
|
|
@@ -2026,7 +2027,7 @@ class Jn {
|
|
|
2026
2027
|
);
|
|
2027
2028
|
}
|
|
2028
2029
|
}
|
|
2029
|
-
const
|
|
2030
|
+
const be = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order-sink-v2.orbs.network", Xe = ve.version.split(".")[0], er = () => Number(Xe) >= 2 ? Ie : _e, tr = () => `${Ie}/config`, nr = () => Number(Xe) >= 2 ? [Ie, _e] : [_e], rr = {
|
|
2030
2031
|
[Q.Thena]: ["0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"],
|
|
2031
2032
|
[Q.Katana]: ["0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df"]
|
|
2032
2033
|
}, ar = ({
|
|
@@ -2038,9 +2039,9 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2038
2039
|
e
|
|
2039
2040
|
) && n ? rr[n] || [] : [], d = t ? [t, ...a] : a;
|
|
2040
2041
|
return d.filter(
|
|
2041
|
-
(
|
|
2042
|
-
(D) => D.toLowerCase() ===
|
|
2043
|
-
) ===
|
|
2042
|
+
(b, m) => d.findIndex(
|
|
2043
|
+
(D) => D.toLowerCase() === b.toLowerCase()
|
|
2044
|
+
) === m
|
|
2044
2045
|
);
|
|
2045
2046
|
}, ir = async (e, t) => {
|
|
2046
2047
|
const n = new URLSearchParams({
|
|
@@ -2061,8 +2062,8 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2061
2062
|
nonce: i,
|
|
2062
2063
|
currentTimeMillis: a,
|
|
2063
2064
|
deadlineMillis: d,
|
|
2064
|
-
fillDelayMillis:
|
|
2065
|
-
totalTrades:
|
|
2065
|
+
fillDelayMillis: b,
|
|
2066
|
+
totalTrades: m,
|
|
2066
2067
|
slippageBps: D,
|
|
2067
2068
|
swapperAddress: C,
|
|
2068
2069
|
inputAmountPerTrade: O,
|
|
@@ -2071,9 +2072,9 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2071
2072
|
permitData: w,
|
|
2072
2073
|
module: B
|
|
2073
2074
|
}) => {
|
|
2074
|
-
const V = !
|
|
2075
|
+
const V = !m || m === 1 ? 0 : parseInt((b / 1e3).toFixed(0)), K = yn(d / 1e3), z = 60, g = Math.floor(a / 1e3).toString(), xe = T(F || 0).toFixed(), De = T(
|
|
2075
2076
|
B === v.STOP_LOSS && h || 0
|
|
2076
|
-
).toFixed(),
|
|
2077
|
+
).toFixed(), Te = T(
|
|
2077
2078
|
B === v.TAKE_PROFIT && h || 0
|
|
2078
2079
|
).toFixed(), Y = {
|
|
2079
2080
|
...w.order,
|
|
@@ -2102,9 +2103,9 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2102
2103
|
output: {
|
|
2103
2104
|
...w.order.witness.output,
|
|
2104
2105
|
token: t,
|
|
2105
|
-
limit:
|
|
2106
|
+
limit: xe,
|
|
2106
2107
|
triggerLower: De,
|
|
2107
|
-
triggerUpper:
|
|
2108
|
+
triggerUpper: Te,
|
|
2108
2109
|
recipient: C
|
|
2109
2110
|
}
|
|
2110
2111
|
}
|
|
@@ -2133,15 +2134,15 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2133
2134
|
signal: i,
|
|
2134
2135
|
retries: a = 1,
|
|
2135
2136
|
limit: d = 1e3,
|
|
2136
|
-
page:
|
|
2137
|
+
page: b
|
|
2137
2138
|
}) => {
|
|
2138
|
-
const
|
|
2139
|
-
if (!
|
|
2139
|
+
const m = or(e);
|
|
2140
|
+
if (!m) throw new Et();
|
|
2140
2141
|
const D = async (F) => {
|
|
2141
2142
|
let h = 0;
|
|
2142
2143
|
for (; h <= a; )
|
|
2143
2144
|
try {
|
|
2144
|
-
const w = await fetch(
|
|
2145
|
+
const w = await fetch(m, {
|
|
2145
2146
|
method: "POST",
|
|
2146
2147
|
body: JSON.stringify({ query: F }),
|
|
2147
2148
|
signal: i,
|
|
@@ -2164,8 +2165,8 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2164
2165
|
};
|
|
2165
2166
|
let C = 0;
|
|
2166
2167
|
const O = [];
|
|
2167
|
-
if (
|
|
2168
|
-
const F = t(
|
|
2168
|
+
if (b !== void 0) {
|
|
2169
|
+
const F = t(b, d);
|
|
2169
2170
|
return D(F);
|
|
2170
2171
|
}
|
|
2171
2172
|
for (; ; ) {
|
|
@@ -2180,16 +2181,16 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2180
2181
|
timestamp: t.timestamp,
|
|
2181
2182
|
txHash: t.transactionHash
|
|
2182
2183
|
})), st = (e, t) => {
|
|
2183
|
-
const n =
|
|
2184
|
+
const n = T(e || 0).gt(1);
|
|
2184
2185
|
return !n && t === 1 ? N.TWAP_MARKET : t > 1 && n ? N.TWAP_LIMIT : n ? N.LIMIT : N.TWAP_MARKET;
|
|
2185
2186
|
}, dr = (e, t, n, i) => {
|
|
2186
|
-
const a = yt(n || []), d = new
|
|
2187
|
+
const a = yt(n || []), d = new T(e.ask_srcBidAmount || 0), b = d.gt(0) ? Math.max(
|
|
2187
2188
|
1,
|
|
2188
|
-
new
|
|
2189
|
-
) : 1, D = (n == null ? void 0 : n.length) >=
|
|
2189
|
+
new T(e.ask_srcAmount || 0).div(d).integerValue(T.ROUND_CEIL).toNumber()
|
|
2190
|
+
) : 1, D = (n == null ? void 0 : n.length) >= b ? a.reduce(
|
|
2190
2191
|
(w, B) => Math.max(w, B.timestamp),
|
|
2191
2192
|
0
|
|
2192
|
-
) : void 0, C = a.reduce((w, B) => w.plus(B.inAmount), new
|
|
2193
|
+
) : void 0, C = a.reduce((w, B) => w.plus(B.inAmount), new T(0)).toFixed(), O = a.reduce((w, B) => w.plus(B.outAmount), new T(0)).toFixed(), F = bt(e.ask_srcAmount, C), h = st(e.ask_dstMinAmount, b);
|
|
2193
2194
|
return {
|
|
2194
2195
|
repermitDigest: "",
|
|
2195
2196
|
version: 1,
|
|
@@ -2197,7 +2198,7 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2197
2198
|
isTriggerPrice: !1,
|
|
2198
2199
|
id: e.Contract_id.toString(),
|
|
2199
2200
|
hash: "",
|
|
2200
|
-
type: st(e.ask_dstMinAmount,
|
|
2201
|
+
type: st(e.ask_dstMinAmount, b),
|
|
2201
2202
|
srcTokenAddress: e.ask_srcToken,
|
|
2202
2203
|
dstTokenAddress: e.ask_dstToken,
|
|
2203
2204
|
exchangeAddress: e.exchange,
|
|
@@ -2206,18 +2207,18 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2206
2207
|
progress: F,
|
|
2207
2208
|
dstAmountFilled: O,
|
|
2208
2209
|
srcAmountFilled: C,
|
|
2209
|
-
orderDollarValueIn:
|
|
2210
|
+
orderDollarValueIn: T(e.dollarValueIn || 0).toFixed(6),
|
|
2210
2211
|
srcAmount: e.ask_srcAmount,
|
|
2211
|
-
dstMinAmountTotal:
|
|
2212
|
+
dstMinAmountTotal: T(e.ask_dstMinAmount).multipliedBy(b).toString(),
|
|
2212
2213
|
fills: a,
|
|
2213
2214
|
fillDelay: e.ask_fillDelay,
|
|
2214
2215
|
deadline: e.ask_deadline * 1e3,
|
|
2215
2216
|
createdAt: new Date(e.timestamp).getTime(),
|
|
2216
|
-
dstMinAmountPerTrade:
|
|
2217
|
+
dstMinAmountPerTrade: T(e.ask_dstMinAmount).eq(1) ? "" : e.ask_dstMinAmount,
|
|
2217
2218
|
triggerPricePerTrade: "",
|
|
2218
2219
|
srcAmountPerTrade: e.ask_srcBidAmount,
|
|
2219
2220
|
txHash: e.transactionHash,
|
|
2220
|
-
totalTradesAmount:
|
|
2221
|
+
totalTradesAmount: b,
|
|
2221
2222
|
isMarketPrice: [N.TWAP_MARKET].includes(h),
|
|
2222
2223
|
chainId: t,
|
|
2223
2224
|
filledOrderTimestamp: D || 0,
|
|
@@ -2242,10 +2243,10 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2242
2243
|
), d = fe(
|
|
2243
2244
|
e.inTokenAddresses,
|
|
2244
2245
|
(h) => `"${h.toLowerCase()}"`
|
|
2245
|
-
),
|
|
2246
|
+
), b = fe(
|
|
2246
2247
|
e.outTokenAddresses,
|
|
2247
2248
|
(h) => `"${h.toLowerCase()}"`
|
|
2248
|
-
),
|
|
2249
|
+
), m = fe(
|
|
2249
2250
|
e.transactionHashes,
|
|
2250
2251
|
(h) => `"${h.toLowerCase()}"`
|
|
2251
2252
|
), D = fe(e.orderIds, (h) => `"${h}"`), C = n != null && n.length ? "" : fe(
|
|
@@ -2256,13 +2257,13 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2256
2257
|
n ? `exchange_in: [${n.join(", ")}]` : "",
|
|
2257
2258
|
C ? `twapAddress_in: [${C.join(", ")}]` : "",
|
|
2258
2259
|
t ? `maker_in: [${t.join(", ")}]` : "",
|
|
2259
|
-
|
|
2260
|
+
m ? `transactionHash_in: [${m.join(", ")}]` : "",
|
|
2260
2261
|
D ? `Contract_id_in: [${D.join(", ")}]` : "",
|
|
2261
2262
|
O ? `dollarValueIn_gte: ${O}` : "",
|
|
2262
2263
|
i ? `srcTokenSymbol_in: [${i.join(", ")}]` : "",
|
|
2263
2264
|
a ? `dstTokenSymbol_in: [${a.join(", ")}]` : "",
|
|
2264
2265
|
d ? `srcTokenAddress_in: [${d.join(", ")}]` : "",
|
|
2265
|
-
|
|
2266
|
+
b ? `dstTokenAddress_in: [${b.join(", ")}]` : "",
|
|
2266
2267
|
e != null && e.startDate ? `blockTimestamp_gte: ${e.startDate}` : "",
|
|
2267
2268
|
e != null && e.endDate ? `blockTimestamp_lte: ${e.endDate}` : "",
|
|
2268
2269
|
(e == null ? void 0 : e.orderType) === "limit" ? "ask_dstMinAmount_gt: 1" : "",
|
|
@@ -2276,7 +2277,7 @@ async function ur({
|
|
|
2276
2277
|
limit: i,
|
|
2277
2278
|
filters: a
|
|
2278
2279
|
}) {
|
|
2279
|
-
const d = i || 1e3,
|
|
2280
|
+
const d = i || 1e3, b = cr(a);
|
|
2280
2281
|
return await Ye({
|
|
2281
2282
|
chainId: e,
|
|
2282
2283
|
signal: t,
|
|
@@ -2285,7 +2286,7 @@ async function ur({
|
|
|
2285
2286
|
buildQuery: (D, C) => `
|
|
2286
2287
|
{
|
|
2287
2288
|
orderCreateds(
|
|
2288
|
-
${
|
|
2289
|
+
${b ? `where: { ${b} },` : ""}
|
|
2289
2290
|
first: ${C},
|
|
2290
2291
|
skip: ${D * C},
|
|
2291
2292
|
orderBy: timestamp,
|
|
@@ -2326,18 +2327,18 @@ const lr = async ({
|
|
|
2326
2327
|
signal: n
|
|
2327
2328
|
}) => {
|
|
2328
2329
|
if (t.length === 0) return [];
|
|
2329
|
-
const i = qe(t.map((
|
|
2330
|
+
const i = qe(t.map((m) => m.Contract_id.toString()));
|
|
2330
2331
|
if (!i.length) return [];
|
|
2331
|
-
const d = `where: { twapId_in: [${i.map((
|
|
2332
|
+
const d = `where: { twapId_in: [${i.map((m) => `"${m}"`).join(", ")}]}`;
|
|
2332
2333
|
return await Ye({
|
|
2333
2334
|
chainId: e,
|
|
2334
2335
|
signal: n,
|
|
2335
2336
|
limit: 1e3,
|
|
2336
|
-
buildQuery: (
|
|
2337
|
+
buildQuery: (m, D) => `
|
|
2337
2338
|
{
|
|
2338
2339
|
statusNews(
|
|
2339
2340
|
first: ${D},
|
|
2340
|
-
skip: ${
|
|
2341
|
+
skip: ${m * D},
|
|
2341
2342
|
${d}
|
|
2342
2343
|
) {
|
|
2343
2344
|
twapId
|
|
@@ -2346,7 +2347,7 @@ const lr = async ({
|
|
|
2346
2347
|
}
|
|
2347
2348
|
}
|
|
2348
2349
|
`,
|
|
2349
|
-
extractResults: (
|
|
2350
|
+
extractResults: (m) => He(m, "statusNews")
|
|
2350
2351
|
});
|
|
2351
2352
|
};
|
|
2352
2353
|
function qe(e) {
|
|
@@ -2359,9 +2360,9 @@ const fr = async ({
|
|
|
2359
2360
|
}) => {
|
|
2360
2361
|
const i = qe(t.map((F) => F.Contract_id)), a = qe(t.map((F) => F.twapAddress)).filter(Boolean);
|
|
2361
2362
|
if (i.length === 0) return [];
|
|
2362
|
-
const d = i.join(", "),
|
|
2363
|
+
const d = i.join(", "), b = a.map((F) => `"${F}"`).join(", "), m = a.length ? `twapAddress_in: [${b}]` : "", C = `where: { ${[
|
|
2363
2364
|
`TWAP_id_in: [${d}]`,
|
|
2364
|
-
|
|
2365
|
+
m
|
|
2365
2366
|
].filter(Boolean).join(", ")} }`;
|
|
2366
2367
|
return await Ye({
|
|
2367
2368
|
chainId: e,
|
|
@@ -2411,14 +2412,14 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2411
2412
|
limit: i,
|
|
2412
2413
|
filters: a
|
|
2413
2414
|
});
|
|
2414
|
-
let
|
|
2415
|
-
const
|
|
2415
|
+
let b = 0;
|
|
2416
|
+
const m = d.filter((h) => {
|
|
2416
2417
|
const w = pr(h);
|
|
2417
|
-
return w ||
|
|
2418
|
+
return w || b++, w;
|
|
2418
2419
|
}), [D, C] = await Promise.all([
|
|
2419
|
-
fr({ chainId: e, orders:
|
|
2420
|
-
lr({ chainId: e, orders:
|
|
2421
|
-
]), O =
|
|
2420
|
+
fr({ chainId: e, orders: m, signal: t }),
|
|
2421
|
+
lr({ chainId: e, orders: m, signal: t })
|
|
2422
|
+
]), O = m.flatMap((h) => {
|
|
2422
2423
|
const w = D == null ? void 0 : D.filter(
|
|
2423
2424
|
(B) => String(B.TWAP_id) === String(h.Contract_id) && ke(B.exchange, h.exchange) && ke(B.twapAddress, h.twapAddress)
|
|
2424
2425
|
);
|
|
@@ -2432,11 +2433,11 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2432
2433
|
)
|
|
2433
2434
|
];
|
|
2434
2435
|
} catch {
|
|
2435
|
-
return
|
|
2436
|
+
return b++, [];
|
|
2436
2437
|
}
|
|
2437
2438
|
}).sort((h, w) => w.createdAt - h.createdAt);
|
|
2438
|
-
|
|
2439
|
-
`Skipped ${
|
|
2439
|
+
b > 0 && console.warn(
|
|
2440
|
+
`Skipped ${b} invalid legacy order history ${b === 1 ? "item" : "items"} on chain ${e}`
|
|
2440
2441
|
);
|
|
2441
2442
|
const F = /* @__PURE__ */ new Set();
|
|
2442
2443
|
return O.filter((h) => F.has(h.historyKey) ? !1 : (F.add(h.historyKey), !0));
|
|
@@ -2445,30 +2446,30 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2445
2446
|
throw d;
|
|
2446
2447
|
}
|
|
2447
2448
|
}, yr = (e, t, n) => {
|
|
2448
|
-
var
|
|
2449
|
-
const i = (
|
|
2449
|
+
var m;
|
|
2450
|
+
const i = (m = n == null ? void 0 : n.find(
|
|
2450
2451
|
(D) => D.twapId === e.Contract_id.toString() && ke(D.twapAddress, e.twapAddress)
|
|
2451
|
-
)) == null ? void 0 :
|
|
2452
|
-
return Er(
|
|
2453
|
-
},
|
|
2454
|
-
const n =
|
|
2452
|
+
)) == null ? void 0 : m.status, d = yt(t).reduce((D, C) => D.plus(C.inAmount), new T(0)).toFixed(), b = bt(e.ask_srcAmount, d);
|
|
2453
|
+
return Er(b, e.ask_deadline * 1e3, i);
|
|
2454
|
+
}, bt = (e, t) => {
|
|
2455
|
+
const n = T(e || 0), i = T(t || 0);
|
|
2455
2456
|
if (!n.isFinite() || !i.isFinite() || n.lte(0)) return 0;
|
|
2456
2457
|
const a = i.dividedBy(n).toNumber();
|
|
2457
2458
|
return a >= 1 ? 100 : a <= 0 ? 0 : Number((a * 100).toFixed(2));
|
|
2458
|
-
}, Er = (e, t, n) => e === 100 ? ce.Completed : n === "CANCELLED" ? ce.Cancelled : n === "COMPLETED" ? ce.Completed : t > Date.now() ? ce.Open : ce.Expired,
|
|
2459
|
-
const t =
|
|
2460
|
-
return
|
|
2461
|
-
},
|
|
2459
|
+
}, Er = (e, t, n) => e === 100 ? ce.Completed : n === "CANCELLED" ? ce.Cancelled : n === "COMPLETED" ? ce.Completed : t > Date.now() ? ce.Open : ce.Expired, br = (e) => {
|
|
2460
|
+
const t = T(e.order.witness.output.limit || 0).gt(1), { stop: n, triggerLower: i, triggerUpper: a } = e.order.witness.output, d = T(n || 0).eq(pt), b = d || T(a || 0).gt(0), m = !d && T(n || 0).gt(0) || T(i || 0).gt(0), D = T(e.order.witness.input.amount), C = e.metadata.expectedChunks || (D.gt(0) ? T(e.order.witness.input.maxAmount).div(D).toNumber() : 1);
|
|
2461
|
+
return b ? t ? N.TAKE_PROFIT_LIMIT : N.TAKE_PROFIT_MARKET : m ? t ? N.STOP_LOSS_LIMIT : N.STOP_LOSS_MARKET : t ? C > 1 && t ? N.TWAP_LIMIT : t ? N.LIMIT : N.TWAP_MARKET : N.TWAP_MARKET;
|
|
2462
|
+
}, mr = (e) => {
|
|
2462
2463
|
var a;
|
|
2463
2464
|
const t = ((a = e.metadata.chunks) == null ? void 0 : a.filter((d) => d.status === "success").length) || 0, n = e.metadata.expectedChunks || 0;
|
|
2464
2465
|
if (!n) return 0;
|
|
2465
|
-
const i =
|
|
2466
|
+
const i = T(t).dividedBy(n).toNumber();
|
|
2466
2467
|
return t >= n ? 100 : i <= 0 ? 0 : Number((i * 100).toFixed(2));
|
|
2467
2468
|
}, hr = (e, t) => {
|
|
2468
2469
|
var a;
|
|
2469
2470
|
const n = (e.metadata.status || "").toLowerCase(), i = (a = e.metadata.description) == null ? void 0 : a.toLowerCase();
|
|
2470
2471
|
return n === "completed" || t === 100 ? ce.Completed : ["pending", "eligible"].includes(n) ? ce.Open : ["cancelled", "canceled"].includes(n) || i === "cancelled by contract" || i === "canceled by contract" ? ce.Cancelled : ce.Expired;
|
|
2471
|
-
},
|
|
2472
|
+
}, xr = (e) => {
|
|
2472
2473
|
var n;
|
|
2473
2474
|
return (((n = e.metadata.chunks) == null ? void 0 : n.filter((i) => i.status === "success")) || []).map((i) => ({
|
|
2474
2475
|
inAmount: i.inAmount,
|
|
@@ -2476,28 +2477,28 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2476
2477
|
timestamp: new Date(i.timestamp).getTime(),
|
|
2477
2478
|
txHash: i.txHash
|
|
2478
2479
|
})).sort((i, a) => i.timestamp - a.timestamp);
|
|
2479
|
-
},
|
|
2480
|
+
}, Tr = (e, t) => e.length >= t ? e.reduce(
|
|
2480
2481
|
(i, a) => Math.max(i, a.timestamp),
|
|
2481
2482
|
0
|
|
2482
2483
|
) : 0, gr = (e) => {
|
|
2483
|
-
const t =
|
|
2484
|
+
const t = T(e.metadata.displayOnlyInputTokenPriceUSD || 0);
|
|
2484
2485
|
return t.isFinite() ? t.dividedBy(1e18).toFixed() : "0";
|
|
2485
|
-
}, Ze = (e) =>
|
|
2486
|
-
const { triggerLower: t = "0", triggerUpper: n = "0" } = e.order.witness.output, i = Ze(e), a = e.metadata.expectedChunks || 1, d =
|
|
2486
|
+
}, Ze = (e) => T(e.order.witness.output.limit || 0).eq(1) ? "" : e.order.witness.output.limit, Dr = (e) => {
|
|
2487
|
+
const { triggerLower: t = "0", triggerUpper: n = "0" } = e.order.witness.output, i = Ze(e), a = e.metadata.expectedChunks || 1, d = T(n || 0).gt(0);
|
|
2487
2488
|
return {
|
|
2488
2489
|
dstMinAmountPerTrade: i,
|
|
2489
2490
|
triggerPricePerTrade: d ? n : t,
|
|
2490
|
-
dstMinAmountTotal: i ?
|
|
2491
|
+
dstMinAmountTotal: i ? T(i).multipliedBy(a).toFixed() : ""
|
|
2491
2492
|
};
|
|
2492
2493
|
}, Fr = (e) => {
|
|
2493
|
-
const t = Ze(e), n =
|
|
2494
|
+
const t = Ze(e), n = T(e.order.witness.output.stop || 0).eq(pt), i = e.metadata.expectedChunks || 1;
|
|
2494
2495
|
return {
|
|
2495
2496
|
dstMinAmountPerTrade: n ? "" : t,
|
|
2496
|
-
triggerPricePerTrade: n ? t :
|
|
2497
|
-
dstMinAmountTotal: n || !t ? "" :
|
|
2497
|
+
triggerPricePerTrade: n ? t : T(e.order.witness.output.stop || 0).toFixed(),
|
|
2498
|
+
dstMinAmountTotal: n || !t ? "" : T(t).multipliedBy(i).toFixed()
|
|
2498
2499
|
};
|
|
2499
|
-
}, Cr = (e) => Number(Xe) >= 2 ? Dr(e) : Fr(e),
|
|
2500
|
-
const t =
|
|
2500
|
+
}, Cr = (e) => Number(Xe) >= 2 ? Dr(e) : Fr(e), mt = (e) => {
|
|
2501
|
+
const t = mr(e), n = Ze(e), i = e.metadata.expectedChunks || 1, a = xr(e), d = br(e);
|
|
2501
2502
|
return {
|
|
2502
2503
|
id: e.hash,
|
|
2503
2504
|
hash: e.hash,
|
|
@@ -2506,8 +2507,8 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2506
2507
|
type: d,
|
|
2507
2508
|
maker: e.order.witness.swapper,
|
|
2508
2509
|
progress: t,
|
|
2509
|
-
srcAmountFilled: a.reduce((
|
|
2510
|
-
dstAmountFilled: a.reduce((
|
|
2510
|
+
srcAmountFilled: a.reduce((b, m) => b.plus(m.inAmount), new T(0)).toFixed() || "",
|
|
2511
|
+
dstAmountFilled: a.reduce((b, m) => b.plus(m.outAmount), new T(0)).toFixed() || "",
|
|
2511
2512
|
fills: a,
|
|
2512
2513
|
srcTokenAddress: e.order.witness.input.token,
|
|
2513
2514
|
dstTokenAddress: e.order.witness.output.token,
|
|
@@ -2518,9 +2519,9 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2518
2519
|
srcAmount: e.order.witness.input.maxAmount,
|
|
2519
2520
|
srcAmountPerTrade: e.order.witness.input.amount,
|
|
2520
2521
|
totalTradesAmount: i,
|
|
2521
|
-
isMarketPrice:
|
|
2522
|
+
isMarketPrice: T(n || 0).lte(1),
|
|
2522
2523
|
chainId: e.order.witness.chainid,
|
|
2523
|
-
filledOrderTimestamp:
|
|
2524
|
+
filledOrderTimestamp: Tr(a, i),
|
|
2524
2525
|
status: hr(e, t),
|
|
2525
2526
|
repermitDigest: e.metadata.repermitDigest,
|
|
2526
2527
|
isTriggerPrice: d === N.TAKE_PROFIT_MARKET || d === N.TAKE_PROFIT_LIMIT || d === N.STOP_LOSS_LIMIT || d === N.STOP_LOSS_MARKET,
|
|
@@ -2548,15 +2549,15 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2548
2549
|
account: i,
|
|
2549
2550
|
exchange: a,
|
|
2550
2551
|
page: d,
|
|
2551
|
-
limit:
|
|
2552
|
+
limit: b
|
|
2552
2553
|
}) => {
|
|
2553
|
-
const
|
|
2554
|
+
const m = new URLSearchParams({
|
|
2554
2555
|
swapper: i,
|
|
2555
2556
|
chainId: t.toString(),
|
|
2556
2557
|
page: d.toString()
|
|
2557
2558
|
});
|
|
2558
|
-
a &&
|
|
2559
|
-
const D = await fetch(`${e}/orders?${
|
|
2559
|
+
a && m.set("exchange", a), b !== void 0 && m.set("limit", b.toString());
|
|
2560
|
+
const D = await fetch(`${e}/orders?${m}`, { signal: n });
|
|
2560
2561
|
if (!D.ok)
|
|
2561
2562
|
throw new Error(
|
|
2562
2563
|
`Failed to fetch order history from ${e}: ${D.status}`
|
|
@@ -2565,7 +2566,7 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2565
2566
|
let O = 0;
|
|
2566
2567
|
const F = C.orders.flatMap((h) => {
|
|
2567
2568
|
try {
|
|
2568
|
-
return [
|
|
2569
|
+
return [mt(h)];
|
|
2569
2570
|
} catch {
|
|
2570
2571
|
return O++, [];
|
|
2571
2572
|
}
|
|
@@ -2578,22 +2579,22 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2578
2579
|
account: i,
|
|
2579
2580
|
exchange: a,
|
|
2580
2581
|
page: d,
|
|
2581
|
-
limit:
|
|
2582
|
+
limit: b
|
|
2582
2583
|
}) => {
|
|
2583
|
-
const
|
|
2584
|
+
const m = d === void 0 ? 1 : d + 1, D = await ot({
|
|
2584
2585
|
endpoint: e,
|
|
2585
2586
|
chainId: t,
|
|
2586
2587
|
signal: n,
|
|
2587
2588
|
account: i,
|
|
2588
2589
|
exchange: a,
|
|
2589
|
-
page:
|
|
2590
|
-
limit:
|
|
2590
|
+
page: m,
|
|
2591
|
+
limit: b
|
|
2591
2592
|
});
|
|
2592
|
-
if (d !== void 0 ||
|
|
2593
|
+
if (d !== void 0 || m >= D.totalPages)
|
|
2593
2594
|
return D.orders;
|
|
2594
2595
|
const C = Array.from(
|
|
2595
|
-
{ length: D.totalPages -
|
|
2596
|
-
(F, h) =>
|
|
2596
|
+
{ length: D.totalPages - m },
|
|
2597
|
+
(F, h) => m + h + 1
|
|
2597
2598
|
), O = await Promise.all(
|
|
2598
2599
|
C.map(
|
|
2599
2600
|
(F) => ot({
|
|
@@ -2603,7 +2604,7 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2603
2604
|
account: i,
|
|
2604
2605
|
exchange: a,
|
|
2605
2606
|
page: F,
|
|
2606
|
-
limit:
|
|
2607
|
+
limit: b
|
|
2607
2608
|
})
|
|
2608
2609
|
)
|
|
2609
2610
|
);
|
|
@@ -2614,10 +2615,10 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2614
2615
|
}, Pr = (e, t, n) => {
|
|
2615
2616
|
const i = /* @__PURE__ */ new Map();
|
|
2616
2617
|
for (const a of e) {
|
|
2617
|
-
const d = ar({ endpoint: a, exchange: t, partner: n }),
|
|
2618
|
-
for (const
|
|
2619
|
-
const D = (
|
|
2620
|
-
exchange:
|
|
2618
|
+
const d = ar({ endpoint: a, exchange: t, partner: n }), b = d.length ? d : [void 0];
|
|
2619
|
+
for (const m of b) {
|
|
2620
|
+
const D = (m == null ? void 0 : m.toLowerCase()) ?? "all", C = i.get(D) ?? {
|
|
2621
|
+
exchange: m,
|
|
2621
2622
|
endpoints: []
|
|
2622
2623
|
};
|
|
2623
2624
|
C.endpoints.push(a), i.set(D, C);
|
|
@@ -2634,15 +2635,15 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2634
2635
|
exchange: i,
|
|
2635
2636
|
partner: a,
|
|
2636
2637
|
page: d,
|
|
2637
|
-
limit:
|
|
2638
|
+
limit: b
|
|
2638
2639
|
}) => {
|
|
2639
2640
|
if (!n) return [];
|
|
2640
|
-
const
|
|
2641
|
+
const m = Pr(
|
|
2641
2642
|
nr(),
|
|
2642
2643
|
i,
|
|
2643
2644
|
a
|
|
2644
2645
|
), D = await Promise.allSettled(
|
|
2645
|
-
|
|
2646
|
+
m.map(async (F) => {
|
|
2646
2647
|
const h = await Promise.allSettled(
|
|
2647
2648
|
F.endpoints.map(
|
|
2648
2649
|
(B) => Sr({
|
|
@@ -2652,7 +2653,7 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2652
2653
|
account: n,
|
|
2653
2654
|
exchange: F.exchange,
|
|
2654
2655
|
page: d,
|
|
2655
|
-
limit:
|
|
2656
|
+
limit: b
|
|
2656
2657
|
})
|
|
2657
2658
|
)
|
|
2658
2659
|
);
|
|
@@ -2695,26 +2696,26 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2695
2696
|
limit: i,
|
|
2696
2697
|
exchange: a,
|
|
2697
2698
|
partner: d,
|
|
2698
|
-
account:
|
|
2699
|
-
legacyOrders:
|
|
2699
|
+
account: b,
|
|
2700
|
+
legacyOrders: m = !0
|
|
2700
2701
|
}) => {
|
|
2701
2702
|
kr(t, i);
|
|
2702
2703
|
const D = ln(d, n);
|
|
2703
2704
|
return (await Promise.all([
|
|
2704
|
-
!D || !
|
|
2705
|
+
!D || !m ? Promise.resolve([]) : Ar({
|
|
2705
2706
|
chainId: n,
|
|
2706
2707
|
signal: e,
|
|
2707
2708
|
page: t,
|
|
2708
2709
|
limit: i,
|
|
2709
2710
|
filters: {
|
|
2710
|
-
accounts: [
|
|
2711
|
+
accounts: [b],
|
|
2711
2712
|
configs: [D]
|
|
2712
2713
|
}
|
|
2713
2714
|
}),
|
|
2714
2715
|
Or({
|
|
2715
2716
|
chainId: n,
|
|
2716
2717
|
signal: e,
|
|
2717
|
-
account:
|
|
2718
|
+
account: b,
|
|
2718
2719
|
exchange: a,
|
|
2719
2720
|
partner: d,
|
|
2720
2721
|
page: t,
|
|
@@ -2728,7 +2729,7 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2728
2729
|
order: e,
|
|
2729
2730
|
status: "pending"
|
|
2730
2731
|
};
|
|
2731
|
-
|
|
2732
|
+
be.onCreateOrderRequest();
|
|
2732
2733
|
const i = await fetch(`${er()}/orders/new`, {
|
|
2733
2734
|
method: "POST",
|
|
2734
2735
|
headers: {
|
|
@@ -2738,15 +2739,15 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2738
2739
|
body: JSON.stringify(n)
|
|
2739
2740
|
}), a = await i.json().catch(() => ({}));
|
|
2740
2741
|
if (!i.ok || !(a != null && a.success)) {
|
|
2741
|
-
const
|
|
2742
|
-
throw new Error(`error:${
|
|
2742
|
+
const b = (a == null ? void 0 : a.message) ?? i.statusText ?? "Request failed", m = (a == null ? void 0 : a.code) ?? i.status;
|
|
2743
|
+
throw new Error(`error:${b}, code:${m}`);
|
|
2743
2744
|
}
|
|
2744
2745
|
if (!a.signedOrder || typeof a.signedOrder != "object")
|
|
2745
2746
|
throw new Error("Invalid API response: missing signedOrder");
|
|
2746
|
-
const d =
|
|
2747
|
-
return
|
|
2747
|
+
const d = mt(a.signedOrder);
|
|
2748
|
+
return be.onCreateOrderSuccess(d.id), d;
|
|
2748
2749
|
} catch (n) {
|
|
2749
|
-
throw
|
|
2750
|
+
throw be.onCreateOrderError(n), console.error(n), n;
|
|
2750
2751
|
}
|
|
2751
2752
|
}, Ir = (e, t) => e + t.unit * t.value + 6e4, Rr = (e, t) => {
|
|
2752
2753
|
if (!At().some(
|
|
@@ -2761,7 +2762,7 @@ function ct(e, t) {
|
|
|
2761
2762
|
);
|
|
2762
2763
|
}
|
|
2763
2764
|
const Lr = (e, t) => {
|
|
2764
|
-
var
|
|
2765
|
+
var b;
|
|
2765
2766
|
const n = e, i = n.domain, a = n.order, d = a == null ? void 0 : a.witness;
|
|
2766
2767
|
if (Number(i == null ? void 0 : i.chainId) !== t)
|
|
2767
2768
|
throw new Error(
|
|
@@ -2775,7 +2776,7 @@ const Lr = (e, t) => {
|
|
|
2775
2776
|
i == null ? void 0 : i.verifyingContract,
|
|
2776
2777
|
"domain.verifyingContract"
|
|
2777
2778
|
), ct(
|
|
2778
|
-
(
|
|
2779
|
+
(b = d == null ? void 0 : d.exchange) == null ? void 0 : b.adapter,
|
|
2779
2780
|
"order.witness.exchange.adapter"
|
|
2780
2781
|
);
|
|
2781
2782
|
}, Hr = async (e, t) => {
|
|
@@ -2784,7 +2785,7 @@ const Lr = (e, t) => {
|
|
|
2784
2785
|
Lr(n, t);
|
|
2785
2786
|
const i = n.domain.verifyingContract, a = n.order.witness.exchange.adapter;
|
|
2786
2787
|
let d = 0;
|
|
2787
|
-
const
|
|
2788
|
+
const b = (h) => (d = Math.max(h, d + 1), d.toString());
|
|
2788
2789
|
return Object.freeze({
|
|
2789
2790
|
partner: e,
|
|
2790
2791
|
chainId: t,
|
|
@@ -2807,7 +2808,7 @@ const Lr = (e, t) => {
|
|
|
2807
2808
|
inputTokenAddress: h.inputTokenAddress,
|
|
2808
2809
|
outputTokenAddress: h.outputTokenAddress,
|
|
2809
2810
|
totalInputAmount: B.inputAmount,
|
|
2810
|
-
nonce:
|
|
2811
|
+
nonce: b(V),
|
|
2811
2812
|
currentTimeMillis: K.currentTimeMillis,
|
|
2812
2813
|
deadlineMillis: K.deadlineMillis,
|
|
2813
2814
|
fillDelayMillis: B.fillDelayMillis,
|
|
@@ -2841,12 +2842,12 @@ const Lr = (e, t) => {
|
|
|
2841
2842
|
};
|
|
2842
2843
|
},
|
|
2843
2844
|
signOrder: async (h, w) => {
|
|
2844
|
-
|
|
2845
|
+
be.onSignOrderRequest(h.order);
|
|
2845
2846
|
try {
|
|
2846
2847
|
const B = await w(h.signingRequest);
|
|
2847
|
-
return
|
|
2848
|
+
return be.onSignOrderSuccess(B), B;
|
|
2848
2849
|
} catch (B) {
|
|
2849
|
-
throw
|
|
2850
|
+
throw be.onSignOrderError(B), B;
|
|
2850
2851
|
}
|
|
2851
2852
|
},
|
|
2852
2853
|
submitOrder: (h, w) => vr(h.order, w),
|
|
@@ -2877,13 +2878,13 @@ export {
|
|
|
2877
2878
|
Zr as ORBS_SLTP_FAQ_URL,
|
|
2878
2879
|
Yr as ORBS_TWAP_FAQ_URL,
|
|
2879
2880
|
Jr as ORBS_WEBSITE_URL,
|
|
2880
|
-
|
|
2881
|
+
Tt as OrderFilter,
|
|
2881
2882
|
ce as OrderStatus,
|
|
2882
2883
|
N as OrderType,
|
|
2883
2884
|
Q as Partners,
|
|
2884
2885
|
Xe as SPOT_VERSION,
|
|
2885
2886
|
se as TimeUnit,
|
|
2886
|
-
|
|
2887
|
+
be as analytics,
|
|
2887
2888
|
jr as calculateOrderForm,
|
|
2888
2889
|
Hr as createClient,
|
|
2889
2890
|
ke as eqIgnoreCase,
|