@orbs-network/spot-ui 2.1.1 → 2.1.3
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/README.md +7 -9
- package/dist/spot-ui.js +852 -860
- package/dist/spot-ui.umd.cjs +8 -8
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/client.d.ts +0 -3
- package/dist/src/lib/client.d.ts.map +1 -1
- package/dist/src/lib/partners.d.ts.map +1 -1
- package/dist/src/lib/types.d.ts +2 -1
- package/dist/src/lib/types.d.ts.map +1 -1
- 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.Orvex = "orvex", 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, Me = Math.ceil, ne = Math.floor, Z = "[BigNumber Error] ", Qe = Z + "Number primitive has more than 15 significant digits: ", ae = 1e14, k = 14, Ne = 9007199254740991, Le = [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 =
|
|
6
|
+
var t, n, i, a = D.prototype = { constructor: D, toString: null, valueOf: null }, d = new D(1), b = 20, m = 4, F = -7, C = 21, O = -1e7, T = 1e7, g = !1, B = 1, P = 0, V = {
|
|
7
7
|
prefix: "",
|
|
8
8
|
groupSize: 3,
|
|
9
9
|
secondaryGroupSize: 0,
|
|
@@ -13,19 +13,19 @@ function ut(e) {
|
|
|
13
13
|
fractionGroupSeparator: " ",
|
|
14
14
|
// non-breaking space
|
|
15
15
|
suffix: ""
|
|
16
|
-
},
|
|
17
|
-
function
|
|
16
|
+
}, U = "0123456789abcdefghijklmnopqrstuvwxyz", j = !0;
|
|
17
|
+
function D(r, s) {
|
|
18
18
|
var o, A, u, f, E, c, l, y, p = this;
|
|
19
|
-
if (!(p instanceof
|
|
19
|
+
if (!(p instanceof D)) return new D(r, s);
|
|
20
20
|
if (s == null) {
|
|
21
21
|
if (r && r._isBigNumber === !0) {
|
|
22
|
-
p.s = r.s, !r.c || r.e >
|
|
22
|
+
p.s = r.s, !r.c || r.e > T ? p.c = p.e = null : r.e < O ? p.c = [p.e = 0] : (p.e = r.e, p.c = r.c.slice());
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
if ((c = typeof r == "number") && r * 0 == 0) {
|
|
26
26
|
if (p.s = 1 / r < 0 ? (r = -r, -1) : 1, r === ~~r) {
|
|
27
27
|
for (f = 0, E = r; E >= 10; E /= 10, f++) ;
|
|
28
|
-
f >
|
|
28
|
+
f > T ? p.c = p.e = null : (p.e = f, p.c = [r]);
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
y = String(r);
|
|
@@ -35,15 +35,15 @@ function ut(e) {
|
|
|
35
35
|
}
|
|
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
|
-
if (L(s, 2,
|
|
39
|
-
return p = new
|
|
38
|
+
if (L(s, 2, U.length, "Base"), s == 10 && j)
|
|
39
|
+
return p = new D(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
|
-
if (p.s = 1 / r < 0 ? (y = y.slice(1), -1) : 1,
|
|
42
|
+
if (p.s = 1 / r < 0 ? (y = y.slice(1), -1) : 1, D.DEBUG && y.replace(/^0\.0*|\./, "").length > 15)
|
|
43
43
|
throw Error(Qe + r);
|
|
44
44
|
} else
|
|
45
45
|
p.s = y.charCodeAt(0) === 45 ? (y = y.slice(1), -1) : 1;
|
|
46
|
-
for (o =
|
|
46
|
+
for (o = U.slice(0, s), f = E = 0, l = y.length; E < l; E++)
|
|
47
47
|
if (o.indexOf(A = y.charAt(E)) < 0) {
|
|
48
48
|
if (A == ".") {
|
|
49
49
|
if (E > f) {
|
|
@@ -61,9 +61,9 @@ function ut(e) {
|
|
|
61
61
|
for (E = 0; y.charCodeAt(E) === 48; E++) ;
|
|
62
62
|
for (l = y.length; y.charCodeAt(--l) === 48; ) ;
|
|
63
63
|
if (y = y.slice(E, ++l)) {
|
|
64
|
-
if (l -= E, c &&
|
|
64
|
+
if (l -= E, c && D.DEBUG && l > 15 && (r > Ne || r !== ne(r)))
|
|
65
65
|
throw Error(Qe + p.s * r);
|
|
66
|
-
if ((f = f - E - 1) >
|
|
66
|
+
if ((f = f - E - 1) > T)
|
|
67
67
|
p.c = p.e = null;
|
|
68
68
|
else if (f < O)
|
|
69
69
|
p.c = [p.e = 0];
|
|
@@ -80,52 +80,52 @@ function ut(e) {
|
|
|
80
80
|
} else
|
|
81
81
|
p.c = [p.e = 0];
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
D.clone = ut, D.ROUND_UP = 0, D.ROUND_DOWN = 1, D.ROUND_CEIL = 2, D.ROUND_FLOOR = 3, D.ROUND_HALF_UP = 4, D.ROUND_HALF_DOWN = 5, D.ROUND_HALF_EVEN = 6, D.ROUND_HALF_CEIL = 7, D.ROUND_HALF_FLOOR = 8, D.EUCLID = 9, D.config = D.set = function(r) {
|
|
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), F = o[0], C = o[1]) : (L(o, -q, q, s), F = -(C = o < 0 ? -o : o))), r.hasOwnProperty(s = "RANGE"))
|
|
88
88
|
if (o = r[s], o && o.pop)
|
|
89
|
-
L(o[0], -q, -1, s), L(o[1], 1, q, s), O = o[0],
|
|
89
|
+
L(o[0], -q, -1, s), L(o[1], 1, q, s), O = o[0], T = o[1];
|
|
90
90
|
else if (L(o, -q, q, s), o)
|
|
91
|
-
O = -(
|
|
91
|
+
O = -(T = o < 0 ? -o : o);
|
|
92
92
|
else
|
|
93
93
|
throw Error(Z + s + " cannot be zero: " + o);
|
|
94
94
|
if (r.hasOwnProperty(s = "CRYPTO"))
|
|
95
95
|
if (o = r[s], o === !!o)
|
|
96
96
|
if (o)
|
|
97
97
|
if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
|
|
98
|
-
|
|
98
|
+
g = o;
|
|
99
99
|
else
|
|
100
|
-
throw
|
|
100
|
+
throw g = !o, Error(Z + "crypto unavailable");
|
|
101
101
|
else
|
|
102
|
-
|
|
102
|
+
g = o;
|
|
103
103
|
else
|
|
104
104
|
throw Error(Z + s + " not true or false: " + o);
|
|
105
|
-
if (r.hasOwnProperty(s = "MODULO_MODE") && (o = r[s], L(o, 0, 9, s),
|
|
105
|
+
if (r.hasOwnProperty(s = "MODULO_MODE") && (o = r[s], L(o, 0, 9, s), B = o), r.hasOwnProperty(s = "POW_PRECISION") && (o = r[s], L(o, 0, q, s), P = o), r.hasOwnProperty(s = "FORMAT"))
|
|
106
106
|
if (o = r[s], typeof o == "object") V = o;
|
|
107
107
|
else throw Error(Z + s + " not an object: " + o);
|
|
108
108
|
if (r.hasOwnProperty(s = "ALPHABET"))
|
|
109
109
|
if (o = r[s], typeof o == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(o))
|
|
110
|
-
|
|
110
|
+
j = o.slice(0, 10) == "0123456789", U = o;
|
|
111
111
|
else
|
|
112
112
|
throw Error(Z + s + " invalid: " + o);
|
|
113
113
|
} else
|
|
114
114
|
throw Error(Z + "Object expected: " + r);
|
|
115
115
|
return {
|
|
116
|
-
DECIMAL_PLACES:
|
|
117
|
-
ROUNDING_MODE:
|
|
118
|
-
EXPONENTIAL_AT: [
|
|
119
|
-
RANGE: [O,
|
|
120
|
-
CRYPTO:
|
|
121
|
-
MODULO_MODE:
|
|
122
|
-
POW_PRECISION:
|
|
116
|
+
DECIMAL_PLACES: b,
|
|
117
|
+
ROUNDING_MODE: m,
|
|
118
|
+
EXPONENTIAL_AT: [F, C],
|
|
119
|
+
RANGE: [O, T],
|
|
120
|
+
CRYPTO: g,
|
|
121
|
+
MODULO_MODE: B,
|
|
122
|
+
POW_PRECISION: P,
|
|
123
123
|
FORMAT: V,
|
|
124
|
-
ALPHABET:
|
|
124
|
+
ALPHABET: U
|
|
125
125
|
};
|
|
126
|
-
},
|
|
126
|
+
}, D.isBigNumber = function(r) {
|
|
127
127
|
if (!r || r._isBigNumber !== !0) return !1;
|
|
128
|
-
if (!
|
|
128
|
+
if (!D.DEBUG) return !0;
|
|
129
129
|
var s, o, A = r.c, u = r.e, f = r.s;
|
|
130
130
|
e: if ({}.toString.call(A) == "[object Array]") {
|
|
131
131
|
if ((f === 1 || f === -1) && u >= -q && u <= q && u === ne(u)) {
|
|
@@ -142,19 +142,19 @@ function ut(e) {
|
|
|
142
142
|
} else if (A === null && u === null && (f === null || f === 1 || f === -1))
|
|
143
143
|
return !0;
|
|
144
144
|
throw Error(Z + "Invalid BigNumber: " + r);
|
|
145
|
-
},
|
|
146
|
-
return
|
|
147
|
-
},
|
|
148
|
-
return
|
|
149
|
-
},
|
|
145
|
+
}, D.maximum = D.max = function() {
|
|
146
|
+
return ge(arguments, -1);
|
|
147
|
+
}, D.minimum = D.min = function() {
|
|
148
|
+
return ge(arguments, 1);
|
|
149
|
+
}, D.random = (function() {
|
|
150
150
|
var r = 9007199254740992, s = Math.random() * r & 2097151 ? function() {
|
|
151
151
|
return ne(Math.random() * r);
|
|
152
152
|
} : function() {
|
|
153
153
|
return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
|
|
154
154
|
};
|
|
155
155
|
return function(o) {
|
|
156
|
-
var A, u, f, E, c, l = 0, y = [], p = new
|
|
157
|
-
if (o == null ? o =
|
|
156
|
+
var A, u, f, E, c, l = 0, y = [], p = new D(d);
|
|
157
|
+
if (o == null ? o = b : L(o, 0, q), E = Me(o / k), g)
|
|
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);
|
|
@@ -164,11 +164,11 @@ function ut(e) {
|
|
|
164
164
|
c = (A[l] & 31) * 281474976710656 + A[l + 1] * 1099511627776 + A[l + 2] * 4294967296 + A[l + 3] * 16777216 + (A[l + 4] << 16) + (A[l + 5] << 8) + A[l + 6], c >= 9e15 ? crypto.randomBytes(7).copy(A, l) : (y.push(c % 1e14), l += 7);
|
|
165
165
|
l = E / 7;
|
|
166
166
|
} else
|
|
167
|
-
throw
|
|
168
|
-
if (!
|
|
167
|
+
throw g = !1, Error(Z + "crypto unavailable");
|
|
168
|
+
if (!g)
|
|
169
169
|
for (; l < E; )
|
|
170
170
|
c = s(), c < 9e15 && (y[l++] = c % 1e14);
|
|
171
|
-
for (E = y[--l], o %= k, E && o && (c =
|
|
171
|
+
for (E = y[--l], o %= k, E && o && (c = Le[k - o], y[l] = ne(E / c) * c); y[l] === 0; y.pop(), l--) ;
|
|
172
172
|
if (l < 0)
|
|
173
173
|
y = [f = 0];
|
|
174
174
|
else {
|
|
@@ -178,8 +178,8 @@ function ut(e) {
|
|
|
178
178
|
}
|
|
179
179
|
return p.e = f, p.c = y, p;
|
|
180
180
|
};
|
|
181
|
-
})(),
|
|
182
|
-
for (var r = 1, s = arguments, o = new
|
|
181
|
+
})(), D.sum = function() {
|
|
182
|
+
for (var r = 1, s = arguments, o = new D(s[0]); r < s.length; ) o = o.plus(s[r++]);
|
|
183
183
|
return o;
|
|
184
184
|
}, n = /* @__PURE__ */ (function() {
|
|
185
185
|
var r = "0123456789";
|
|
@@ -192,31 +192,31 @@ 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,
|
|
196
|
-
for (
|
|
197
|
-
le(te(
|
|
195
|
+
var c, l, y, p, h, w, S, R, $ = o.indexOf("."), G = b, I = m;
|
|
196
|
+
for ($ >= 0 && (p = P, P = 0, o = o.replace(".", ""), R = new D(A), w = R.pow(o.length - $), P = p, R.c = s(
|
|
197
|
+
le(te(w.c), w.e, "0"),
|
|
198
198
|
10,
|
|
199
199
|
u,
|
|
200
200
|
r
|
|
201
|
-
), R.e = R.c.length),
|
|
202
|
-
if (!
|
|
203
|
-
if (
|
|
204
|
-
o =
|
|
201
|
+
), R.e = R.c.length), S = s(o, A, u, E ? (c = U, r) : (c = r, U)), y = p = S.length; S[--p] == 0; S.pop()) ;
|
|
202
|
+
if (!S[0]) return c.charAt(0);
|
|
203
|
+
if ($ < 0 ? --y : (w.c = S, w.e = y, w.s = f, w = t(w, R, G, I, u), S = w.c, h = w.r, y = w.e), l = y + G + 1, $ = S[l], p = u / 2, h = h || l < 0 || S[l + 1] != null, h = I < 4 ? ($ != null || h) && (I == 0 || I == (w.s < 0 ? 3 : 2)) : $ > p || $ == p && (I == 4 || h || I == 6 && S[l - 1] & 1 || I == (w.s < 0 ? 8 : 7)), l < 1 || !S[0])
|
|
204
|
+
o = h ? le(c.charAt(1), -G, c.charAt(0)) : c.charAt(0);
|
|
205
205
|
else {
|
|
206
|
-
if (
|
|
207
|
-
for (--u; ++
|
|
208
|
-
|
|
209
|
-
for (p =
|
|
210
|
-
for (
|
|
206
|
+
if (S.length = l, h)
|
|
207
|
+
for (--u; ++S[--l] > u; )
|
|
208
|
+
S[l] = 0, l || (++y, S = [1].concat(S));
|
|
209
|
+
for (p = S.length; !S[--p]; ) ;
|
|
210
|
+
for ($ = 0, o = ""; $ <= p; o += c.charAt(S[$++])) ;
|
|
211
211
|
o = le(o, y, c.charAt(0));
|
|
212
212
|
}
|
|
213
213
|
return o;
|
|
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, h = A.length, w = u % pe, S = u / pe | 0;
|
|
218
|
+
for (A = A.slice(); h--; )
|
|
219
|
+
l = A[h] % pe, y = A[h] / pe | 0, E = S * l + y * w, c = w * l + E % pe * pe + p, p = (c / f | 0) + (E / pe | 0) + S * y, A[h] = c % f;
|
|
220
220
|
return p && (A = [p].concat(A)), A;
|
|
221
221
|
}
|
|
222
222
|
function s(A, u, f, E) {
|
|
@@ -237,67 +237,67 @@ 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,
|
|
241
|
-
if (!X || !X[0] ||
|
|
242
|
-
return new
|
|
240
|
+
var l, y, p, h, w, S, R, $, G, I, M, z, De, Ie, Re, oe, Te, ee = A.s == u.s ? 1 : -1, X = A.c, K = u.c;
|
|
241
|
+
if (!X || !X[0] || !K || !K[0])
|
|
242
|
+
return new D(
|
|
243
243
|
// Return NaN if either NaN, or both Infinity or 0.
|
|
244
|
-
!A.s || !u.s || (X ?
|
|
244
|
+
!A.s || !u.s || (X ? K && X[0] == K[0] : !K) ? NaN : (
|
|
245
245
|
// Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
|
|
246
|
-
X && X[0] == 0 ||
|
|
246
|
+
X && X[0] == 0 || !K ? ee * 0 : ee / 0
|
|
247
247
|
)
|
|
248
248
|
);
|
|
249
|
-
for (
|
|
250
|
-
if (
|
|
251
|
-
G.push(1),
|
|
249
|
+
for ($ = new D(ee), G = $.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; K[p] == (X[p] || 0); p++) ;
|
|
250
|
+
if (K[p] > (X[p] || 0) && y--, ee < 0)
|
|
251
|
+
G.push(1), h = !0;
|
|
252
252
|
else {
|
|
253
|
-
for (
|
|
254
|
-
|
|
253
|
+
for (Ie = X.length, oe = K.length, p = 0, ee += 2, w = ne(c / (K[0] + 1)), w > 1 && (K = r(K, w, c), X = r(X, w, c), oe = K.length, Ie = X.length), De = oe, I = X.slice(0, oe), M = I.length; M < oe; I[M++] = 0) ;
|
|
254
|
+
Te = K.slice(), Te = [0].concat(Te), Re = K[0], K[1] >= c / 2 && Re++;
|
|
255
255
|
do {
|
|
256
|
-
if (
|
|
257
|
-
if (
|
|
258
|
-
for (
|
|
259
|
-
|
|
256
|
+
if (w = 0, l = s(K, I, oe, M), l < 0) {
|
|
257
|
+
if (z = I[0], oe != M && (z = z * c + (I[1] || 0)), w = ne(z / Re), w > 1)
|
|
258
|
+
for (w >= c && (w = c - 1), S = r(K, w, c), R = S.length, M = I.length; s(S, I, R, M) == 1; )
|
|
259
|
+
w--, o(S, oe < R ? Te : K, R, c), R = S.length, l = 1;
|
|
260
260
|
else
|
|
261
|
-
|
|
262
|
-
if (R < M && (
|
|
263
|
-
for (; s(
|
|
264
|
-
|
|
265
|
-
} else l === 0 && (
|
|
266
|
-
G[p++] =
|
|
267
|
-
} while ((
|
|
268
|
-
|
|
261
|
+
w == 0 && (l = w = 1), S = K.slice(), R = S.length;
|
|
262
|
+
if (R < M && (S = [0].concat(S)), o(I, S, M, c), M = I.length, l == -1)
|
|
263
|
+
for (; s(K, I, oe, M) < 1; )
|
|
264
|
+
w++, o(I, oe < M ? Te : K, M, c), M = I.length;
|
|
265
|
+
} else l === 0 && (w++, I = [0]);
|
|
266
|
+
G[p++] = w, I[0] ? I[M++] = X[De] || 0 : (I = [X[De]], M = 1);
|
|
267
|
+
} while ((De++ < Ie || I[0] != null) && ee--);
|
|
268
|
+
h = 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(
|
|
272
|
+
Y($, f + ($.e = p + y * k - 1) + 1, E, h);
|
|
273
273
|
} else
|
|
274
|
-
|
|
275
|
-
return
|
|
274
|
+
$.e = y, $.r = +h;
|
|
275
|
+
return $;
|
|
276
276
|
};
|
|
277
277
|
})();
|
|
278
|
-
function
|
|
278
|
+
function he(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
|
-
l = te(r.c), l = A == 1 || A == 2 && (E <=
|
|
283
|
-
else if (r = Y(new
|
|
282
|
+
l = te(r.c), l = A == 1 || A == 2 && (E <= F || E >= C) ? Ce(l, E) : le(l, E, "0");
|
|
283
|
+
else if (r = Y(new D(r), s, o), f = r.e, l = te(r.c), c = l.length, A == 1 || A == 2 && (s <= f || f <= F)) {
|
|
284
284
|
for (; c < s; l += "0", c++) ;
|
|
285
|
-
l =
|
|
285
|
+
l = Ce(l, f);
|
|
286
286
|
} else if (s -= E + (A === 2 && f > E), l = le(l, f, "0"), f + 1 > c) {
|
|
287
287
|
if (--s > 0) for (l += "."; s--; l += "0") ;
|
|
288
288
|
} else if (s += f - c, s > 0)
|
|
289
289
|
for (f + 1 == c && (l += "."); s--; l += "0") ;
|
|
290
290
|
return r.s < 0 && u ? "-" + l : l;
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
for (var o, A, u = 1, f = new
|
|
294
|
-
A = new
|
|
292
|
+
function ge(r, s) {
|
|
293
|
+
for (var o, A, u = 1, f = new D(r[0]); u < r.length; u++)
|
|
294
|
+
A = new D(r[u]), (!A.s || (o = ye(f, A)) === s || o === 0 && f.s === s) && (f = A);
|
|
295
295
|
return f;
|
|
296
296
|
}
|
|
297
297
|
function xe(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
|
-
return (o = A + o * k - 1) >
|
|
300
|
+
return (o = A + o * k - 1) > T ? r.c = r.e = null : o < O ? r.c = [r.e = 0] : (r.e = o, r.c = s), r;
|
|
301
301
|
}
|
|
302
302
|
i = /* @__PURE__ */ (function() {
|
|
303
303
|
var r = /^(-?)0([xbo])(?=\w[\w.]*$)/i, s = /^([^.]+)\.$/, o = /^\.([^.]+)$/, A = /^-?(Infinity|NaN)$/, u = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
@@ -306,11 +306,11 @@ 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 = (
|
|
309
|
+
if (!c && (p = p.replace(r, function(h, w, S) {
|
|
310
|
+
return y = (S = S.toLowerCase()) == "x" ? 16 : S == "b" ? 2 : 8, !l || l == y ? w : h;
|
|
311
311
|
}), l && (y = l, p = p.replace(s, "$1").replace(o, "0.$1")), E != p))
|
|
312
|
-
return new
|
|
313
|
-
if (
|
|
312
|
+
return new D(p, y);
|
|
313
|
+
if (D.DEBUG)
|
|
314
314
|
throw Error(Z + "Not a" + (l ? " base " + l : "") + " number: " + E);
|
|
315
315
|
f.s = null;
|
|
316
316
|
}
|
|
@@ -318,113 +318,113 @@ 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, h = r.c, w = Le;
|
|
322
|
+
if (h) {
|
|
323
323
|
e: {
|
|
324
|
-
for (u = 1, c =
|
|
324
|
+
for (u = 1, c = h[0]; c >= 10; c /= 10, u++) ;
|
|
325
325
|
if (f = s - u, f < 0)
|
|
326
|
-
f += k, E = s, l =
|
|
327
|
-
else if (y =
|
|
326
|
+
f += k, E = s, l = h[y = 0], p = ne(l / w[u - E - 1] % 10);
|
|
327
|
+
else if (y = Me((f + 1) / k), y >= h.length)
|
|
328
328
|
if (A) {
|
|
329
|
-
for (;
|
|
329
|
+
for (; h.length <= y; h.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 =
|
|
335
|
-
f %= k, E = f - k + u, p = E < 0 ? 0 : ne(l /
|
|
334
|
+
for (l = c = h[y], u = 1; c >= 10; c /= 10, u++) ;
|
|
335
|
+
f %= k, E = f - k + u, p = E < 0 ? 0 : ne(l / w[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 /
|
|
342
|
-
return
|
|
343
|
-
if (f == 0 ? (
|
|
340
|
+
h[y + 1] != null || (E < 0 ? l : l % w[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 / w[u - E] : 0 : h[y - 1]) % 10 & 1 || o == (r.s < 0 ? 8 : 7)), s < 1 || !h[0])
|
|
342
|
+
return h.length = 0, A ? (s -= r.e + 1, h[0] = w[(k - s % k) % k], r.e = -s || 0) : h[0] = r.e = 0, r;
|
|
343
|
+
if (f == 0 ? (h.length = y, c = 1, y--) : (h.length = y + 1, c = w[k - f], h[y] = E > 0 ? ne(l / w[u - E] % w[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 = h[0]; E >= 10; E /= 10, f++) ;
|
|
347
|
+
for (E = h[0] += c, c = 1; E >= 10; E /= 10, c++) ;
|
|
348
|
+
f != c && (r.e++, h[0] == ae && (h[0] = 1));
|
|
349
349
|
break;
|
|
350
350
|
} else {
|
|
351
|
-
if (
|
|
352
|
-
|
|
351
|
+
if (h[y] += c, h[y] != ae) break;
|
|
352
|
+
h[y--] = 0, c = 1;
|
|
353
353
|
}
|
|
354
|
-
for (f =
|
|
354
|
+
for (f = h.length; h[--f] === 0; h.pop()) ;
|
|
355
355
|
}
|
|
356
|
-
r.e >
|
|
356
|
+
r.e > T ? r.c = r.e = null : r.e < O && (r.c = [r.e = 0]);
|
|
357
357
|
}
|
|
358
358
|
return r;
|
|
359
359
|
}
|
|
360
360
|
function ue(r) {
|
|
361
361
|
var s, o = r.e;
|
|
362
|
-
return o === null ? r.toString() : (s = te(r.c), s = o <=
|
|
362
|
+
return o === null ? r.toString() : (s = te(r.c), s = o <= F || o >= C ? Ce(s, o) : le(s, o, "0"), r.s < 0 ? "-" + s : s);
|
|
363
363
|
}
|
|
364
364
|
return a.absoluteValue = a.abs = function() {
|
|
365
|
-
var r = new
|
|
365
|
+
var r = new D(this);
|
|
366
366
|
return r.s < 0 && (r.s = 1), r;
|
|
367
367
|
}, a.comparedTo = function(r, s) {
|
|
368
|
-
return ye(this, new
|
|
368
|
+
return ye(this, new D(r, s));
|
|
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 D(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
|
|
377
|
+
return t(this, new D(r, s), b, m);
|
|
378
378
|
}, a.dividedToIntegerBy = a.idiv = function(r, s) {
|
|
379
|
-
return t(this, new
|
|
379
|
+
return t(this, new D(r, s), 0, 1);
|
|
380
380
|
}, a.exponentiatedBy = a.pow = function(r, s) {
|
|
381
|
-
var o, A, u, f, E, c, l, y, p,
|
|
382
|
-
if (r = new
|
|
381
|
+
var o, A, u, f, E, c, l, y, p, h = this;
|
|
382
|
+
if (r = new D(r), r.c && !r.isInteger())
|
|
383
383
|
throw Error(Z + "Exponent not an integer: " + ue(r));
|
|
384
|
-
if (s != null && (s = new
|
|
385
|
-
return p = new
|
|
384
|
+
if (s != null && (s = new D(s)), c = r.e > 14, !h.c || !h.c[0] || h.c[0] == 1 && !h.e && h.c.length == 1 || !r.c || !r.c[0])
|
|
385
|
+
return p = new D(Math.pow(+ue(h), c ? r.s * (2 - Fe(r)) : +ue(r))), s ? p.mod(s) : p;
|
|
386
386
|
if (l = r.s < 0, s) {
|
|
387
|
-
if (s.c ? !s.c[0] : !s.s) return new
|
|
388
|
-
A = !l &&
|
|
387
|
+
if (s.c ? !s.c[0] : !s.s) return new D(NaN);
|
|
388
|
+
A = !l && h.isInteger() && s.isInteger(), A && (h = h.mod(s));
|
|
389
389
|
} else {
|
|
390
|
-
if (r.e > 9 && (
|
|
391
|
-
return f =
|
|
392
|
-
|
|
390
|
+
if (r.e > 9 && (h.e > 0 || h.e < -1 || (h.e == 0 ? h.c[0] > 1 || c && h.c[1] >= 24e7 : h.c[0] < 8e13 || c && h.c[0] <= 9999975e7)))
|
|
391
|
+
return f = h.s < 0 && Fe(r) ? -0 : 0, h.e > -1 && (f = 1 / f), new D(l ? 1 / f : f);
|
|
392
|
+
P && (f = Me(P / k + 2));
|
|
393
393
|
}
|
|
394
|
-
for (c ? (o = new
|
|
394
|
+
for (c ? (o = new D(0.5), l && (r.s = 1), y = Fe(r)) : (u = Math.abs(+ue(r)), y = u % 2), p = new D(d); ; ) {
|
|
395
395
|
if (y) {
|
|
396
|
-
if (p = p.times(
|
|
396
|
+
if (p = p.times(h), !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) {
|
|
400
400
|
if (u = ne(u / 2), u === 0) break;
|
|
401
401
|
y = u % 2;
|
|
402
402
|
} else if (r = r.times(o), Y(r, r.e + 1, 1), r.e > 14)
|
|
403
|
-
y =
|
|
403
|
+
y = Fe(r);
|
|
404
404
|
else {
|
|
405
405
|
if (u = +ue(r), u === 0) break;
|
|
406
406
|
y = u % 2;
|
|
407
407
|
}
|
|
408
|
-
|
|
408
|
+
h = h.times(h), f ? h.c && h.c.length > f && (h.c.length = f) : A && (h = h.mod(s));
|
|
409
409
|
}
|
|
410
|
-
return A ? p : (l && (p = d.div(p)), s ? p.mod(s) : f ? Y(p,
|
|
410
|
+
return A ? p : (l && (p = d.div(p)), s ? p.mod(s) : f ? Y(p, P, m, E) : p);
|
|
411
411
|
}, a.integerValue = function(r) {
|
|
412
|
-
var s = new
|
|
413
|
-
return r == null ? r =
|
|
412
|
+
var s = new D(this);
|
|
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
|
-
return ye(this, new
|
|
415
|
+
return ye(this, new D(r, s)) === 0;
|
|
416
416
|
}, a.isFinite = function() {
|
|
417
417
|
return !!this.c;
|
|
418
418
|
}, a.isGreaterThan = a.gt = function(r, s) {
|
|
419
|
-
return ye(this, new
|
|
419
|
+
return ye(this, new D(r, s)) > 0;
|
|
420
420
|
}, a.isGreaterThanOrEqualTo = a.gte = function(r, s) {
|
|
421
|
-
return (s = ye(this, new
|
|
421
|
+
return (s = ye(this, new D(r, s))) === 1 || s === 0;
|
|
422
422
|
}, a.isInteger = function() {
|
|
423
423
|
return !!this.c && re(this.e / k) > this.c.length - 2;
|
|
424
424
|
}, a.isLessThan = a.lt = function(r, s) {
|
|
425
|
-
return ye(this, new
|
|
425
|
+
return ye(this, new D(r, s)) < 0;
|
|
426
426
|
}, a.isLessThanOrEqualTo = a.lte = function(r, s) {
|
|
427
|
-
return (s = ye(this, new
|
|
427
|
+
return (s = ye(this, new D(r, s))) === -1 || s === 0;
|
|
428
428
|
}, a.isNaN = function() {
|
|
429
429
|
return !this.s;
|
|
430
430
|
}, a.isNegative = function() {
|
|
@@ -435,63 +435,63 @@ function ut(e) {
|
|
|
435
435
|
return !!this.c && this.c[0] == 0;
|
|
436
436
|
}, a.minus = function(r, s) {
|
|
437
437
|
var o, A, u, f, E = this, c = E.s;
|
|
438
|
-
if (r = new
|
|
438
|
+
if (r = new D(r, s), s = r.s, !c || !s) return new D(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, h = r.c;
|
|
442
442
|
if (!l || !y) {
|
|
443
|
-
if (!p || !
|
|
444
|
-
if (!p[0] || !
|
|
445
|
-
return
|
|
443
|
+
if (!p || !h) return p ? (r.s = -s, r) : new D(h ? E : NaN);
|
|
444
|
+
if (!p[0] || !h[0])
|
|
445
|
+
return h[0] ? (r.s = -s, r) : new D(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 = h), 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 = h.length)) ? c : s, c = s = 0; s < A; s++)
|
|
455
|
+
if (p[s] != h[s]) {
|
|
456
|
+
f = p[s] < h[s];
|
|
457
457
|
break;
|
|
458
458
|
}
|
|
459
|
-
if (f && (u = p, p =
|
|
459
|
+
if (f && (u = p, p = h, h = u, r.s = -r.s), s = (A = h.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] < h[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] -= h[A];
|
|
466
466
|
}
|
|
467
467
|
for (; p[0] == 0; p.splice(0, 1), --y) ;
|
|
468
|
-
return p[0] ? xe(r, p, y) : (r.s =
|
|
468
|
+
return p[0] ? xe(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
|
-
return r = new
|
|
471
|
+
return r = new D(r, s), !u.c || !r.s || r.c && !r.c[0] ? new D(NaN) : !r.c || u.c && !u.c[0] ? new D(u) : (B == 9 ? (A = r.s, r.s = 1, o = t(u, r, 0, 3), r.s = A, o.s *= A) : o = t(u, r, 0, B), r = u.minus(o.times(r)), !r.c[0] && B == 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,
|
|
474
|
-
if (!M || !
|
|
475
|
-
return !I.s || !r.s || M && !M[0] && !
|
|
476
|
-
for (A = re(I.e / k) + re(r.e / k), r.s *= I.s, l = M.length,
|
|
477
|
-
for (
|
|
478
|
-
for (o = 0,
|
|
479
|
-
y = M[--E] % G, p = M[E] / G | 0, c =
|
|
473
|
+
var o, A, u, f, E, c, l, y, p, h, w, S, R, $, G, I = this, M = I.c, z = (r = new D(r, s)).c;
|
|
474
|
+
if (!M || !z || !M[0] || !z[0])
|
|
475
|
+
return !I.s || !r.s || M && !M[0] && !z || z && !z[0] && !M ? r.c = r.e = r.s = null : (r.s *= I.s, !M || !z ? 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, h = z.length, l < h && (R = M, M = z, z = R, u = l, l = h, h = u), u = l + h, R = []; u--; R.push(0)) ;
|
|
477
|
+
for ($ = ae, G = pe, u = h; --u >= 0; ) {
|
|
478
|
+
for (o = 0, w = z[u] % G, S = z[u] / G | 0, E = l, f = u + E; f > u; )
|
|
479
|
+
y = M[--E] % G, p = M[E] / G | 0, c = S * y + p * w, y = w * y + c % G * G + R[f] + o, o = (y / $ | 0) + (c / G | 0) + S * p, R[f--] = y % $;
|
|
480
480
|
R[f] = o;
|
|
481
481
|
}
|
|
482
482
|
return o ? ++A : R.splice(0, 1), xe(r, R, A);
|
|
483
483
|
}, a.negated = function() {
|
|
484
|
-
var r = new
|
|
484
|
+
var r = new D(this);
|
|
485
485
|
return r.s = -r.s || null, r;
|
|
486
486
|
}, a.plus = function(r, s) {
|
|
487
487
|
var o, A = this, u = A.s;
|
|
488
|
-
if (r = new
|
|
488
|
+
if (r = new D(r, s), s = r.s, !u || !s) return new D(NaN);
|
|
489
489
|
if (u != s)
|
|
490
490
|
return r.s = -s, A.minus(r);
|
|
491
491
|
var f = A.e / k, E = r.e / k, c = A.c, l = r.c;
|
|
492
492
|
if (!f || !E) {
|
|
493
|
-
if (!c || !l) return new
|
|
494
|
-
if (!c[0] || !l[0]) return l[0] ? r : new
|
|
493
|
+
if (!c || !l) return new D(u / 0);
|
|
494
|
+
if (!c[0] || !l[0]) return l[0] ? r : new D(c[0] ? A : u * 0);
|
|
495
495
|
}
|
|
496
496
|
if (f = re(f), E = re(E), c = c.slice(), u = f - E) {
|
|
497
497
|
for (u > 0 ? (E = f, o = l) : (u = -u, o = c), o.reverse(); u--; o.push(0)) ;
|
|
@@ -503,7 +503,7 @@ function ut(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 D(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--) ;
|
|
@@ -511,30 +511,30 @@ function ut(e) {
|
|
|
511
511
|
}
|
|
512
512
|
return r && f.e + 1 > A && (A = f.e + 1), A;
|
|
513
513
|
}, a.shiftedBy = function(r) {
|
|
514
|
-
return L(r, -
|
|
514
|
+
return L(r, -Ne, Ne), 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 D("0.5");
|
|
517
517
|
if (c !== 1 || !E || !E[0])
|
|
518
|
-
return new
|
|
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
|
|
518
|
+
return new D(!c || c < 0 && (!E || E[0]) ? NaN : E ? f : 1 / 0);
|
|
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 D(s)) : o = new D(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++), he(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), he(this, r, s);
|
|
538
538
|
}, a.toFormat = function(r, s, o) {
|
|
539
539
|
var A, u = this;
|
|
540
540
|
if (o == null)
|
|
@@ -542,37 +542,37 @@ 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], h = E[1], w = u.s < 0, S = w ? p.slice(1) : p, R = S.length;
|
|
546
546
|
if (l && (f = c, c = l, l = f, R -= f), c > 0 && R > 0) {
|
|
547
|
-
for (f = R % c || c, p =
|
|
548
|
-
l > 0 && (p += y +
|
|
547
|
+
for (f = R % c || c, p = S.substr(0, f); f < R; f += c) p += y + S.substr(f, c);
|
|
548
|
+
l > 0 && (p += y + S.slice(f)), w && (p = "-" + p);
|
|
549
549
|
}
|
|
550
|
-
A =
|
|
550
|
+
A = h ? p + (o.decimalSeparator || "") + ((l = +o.fractionGroupSize) ? h.replace(
|
|
551
551
|
new RegExp("\\d{" + l + "}\\B", "g"),
|
|
552
552
|
"$&" + (o.fractionGroupSeparator || "")
|
|
553
|
-
) :
|
|
553
|
+
) : h) : 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,
|
|
558
|
-
if (r != null && (c = new
|
|
557
|
+
var s, o, A, u, f, E, c, l, y, p, h, w, S = this, R = S.c;
|
|
558
|
+
if (r != null && (c = new D(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
|
-
if (!R) return new
|
|
561
|
-
for (s = new
|
|
560
|
+
if (!R) return new D(S);
|
|
561
|
+
for (s = new D(d), y = o = new D(d), A = l = new D(d), w = te(R), f = s.e = w.length - S.e - 1, s.c[0] = Le[(E = f % k) < 0 ? k + E : E], r = !r || c.comparedTo(s) > 0 ? f > 0 ? s : y : c, E = T, T = 1 / 0, c = new D(w), 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 =
|
|
564
|
-
t(l, o, f,
|
|
565
|
-
) < 1 ? [y, A] : [l, o],
|
|
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 = S.s, f = f * 2, h = t(y, A, f, m).minus(S).abs().comparedTo(
|
|
564
|
+
t(l, o, f, m).minus(S).abs()
|
|
565
|
+
) < 1 ? [y, A] : [l, o], T = E, h;
|
|
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), he(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 <=
|
|
572
|
+
return u === null ? A ? (s = "Infinity", A < 0 && (s = "-" + s)) : s = "NaN" : (r == null ? s = u <= F || u >= C ? Ce(te(o.c), u) : le(te(o.c), u, "0") : r === 10 && j ? (o = Y(new D(o), b + u + 1, m), s = le(te(o.c), o.e, "0")) : (L(r, 2, U.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
|
-
}, a._isBigNumber = !0, a[Symbol.toStringTag] = "BigNumber", a[Symbol.for("nodejs.util.inspect.custom")] = a.valueOf, e != null &&
|
|
575
|
+
}, a._isBigNumber = !0, a[Symbol.toStringTag] = "BigNumber", a[Symbol.for("nodejs.util.inspect.custom")] = a.valueOf, e != null && D.set(e), D;
|
|
576
576
|
}
|
|
577
577
|
function re(e) {
|
|
578
578
|
var t = e | 0;
|
|
@@ -587,24 +587,24 @@ 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 =
|
|
595
|
-
if (!i) return
|
|
596
|
-
for (
|
|
597
|
-
return
|
|
590
|
+
var n, i, a = e.c, d = t.c, b = e.s, m = t.s, F = 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 = F == C, !a || !d) return i ? 0 : !a ^ n ? 1 : -1;
|
|
595
|
+
if (!i) return F > C ^ n ? 1 : -1;
|
|
596
|
+
for (m = (F = a.length) < (C = d.length) ? F : C, b = 0; b < m; b++) if (a[b] != d[b]) return a[b] > d[b] ^ n ? 1 : -1;
|
|
597
|
+
return F == C ? 0 : F > C ^ n ? 1 : -1;
|
|
598
598
|
}
|
|
599
599
|
function L(e, t, n, i) {
|
|
600
600
|
if (e < t || e > n || e !== ne(e))
|
|
601
601
|
throw Error(Z + (i || "Argument") + (typeof e == "number" ? e < t || e > n ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(e));
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function Fe(e) {
|
|
604
604
|
var t = e.c.length - 1;
|
|
605
605
|
return re(e.e / k) == t && e.c[t] % 2 != 0;
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function Ce(e, t) {
|
|
608
608
|
return (e.length > 1 ? e.charAt(0) + "." + e.slice(1) : e) + (t < 0 ? "e" : "e+") + t;
|
|
609
609
|
}
|
|
610
610
|
function le(e, t, n) {
|
|
@@ -648,21 +648,21 @@ 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 && x(d).gt(0) ? x(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
|
-
}, Ke = 300 * 1e3,
|
|
657
|
+
}, Ke = 300 * 1e3, Pe = 1440 * 60 * 60 * 1e3, Je = 300 * 1e3, Ve = {
|
|
658
658
|
unit: se.Minutes,
|
|
659
659
|
value: Ke / 6e4
|
|
660
660
|
}, Ft = "-5", Ct = "10", Bt = "-10", wt = "5", lt = (e) => {
|
|
661
661
|
const t = H(e.initialPrice);
|
|
662
662
|
let n = "";
|
|
663
663
|
if (e.typedValue !== void 0) {
|
|
664
|
-
const d = x(e.typedValue),
|
|
665
|
-
n = We(
|
|
664
|
+
const d = x(e.typedValue), b = e.isInverted ? d.isZero() ? x(0) : x(1).dividedBy(d) : d;
|
|
665
|
+
n = We(b.toFixed(), e.tokenDecimals);
|
|
666
666
|
} else if (e.percentage !== void 0 && t && x(t).gt(0)) {
|
|
667
667
|
const d = x(e.percentage || 0).dividedBy(100);
|
|
668
668
|
n = x(t).plus(x(t).multipliedBy(d)).decimalPlaces(0).toFixed();
|
|
@@ -686,8 +686,8 @@ const H = (e) => {
|
|
|
686
686
|
}, ft = (e) => {
|
|
687
687
|
const t = (d) => {
|
|
688
688
|
if (!d) return "";
|
|
689
|
-
const
|
|
690
|
-
return
|
|
689
|
+
const b = x(d);
|
|
690
|
+
return b.isFinite() && !b.isNaN() ? d : "";
|
|
691
691
|
};
|
|
692
692
|
let n = "";
|
|
693
693
|
if (e.typedValue !== void 0)
|
|
@@ -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" } } },
|
|
@@ -854,9 +855,9 @@ const Nt = {
|
|
|
854
855
|
747474: { adapter: { Nordstern: "0xd16A1849E86431872a87f476fa0DfB30eEb96cb3", Sushi: "0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c" }, dex: { katana: { type: "universal", adapter: "0xe7505d43AdF7d44AB11d7eEAF353a85F8169bE6a", fee: "0x7a76704765D366ac2A559e1A1fc1273b834B2cA8" }, sushiswap: { type: "default", solver: "Sushi", router: "0xAC4c6e212A361c968F1725b4d055b47E63F80b75", adapter: "0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df", fee: "0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc" } } },
|
|
855
856
|
"*": { wm: "0x0005d5cE0dB57e5BE3b2b8b6FeB75f0ccd015000", repermit: "0x00002a9C4D9497df5Bd31768eC5d30eEf5405000", cosigner: "0x000ECFa392ecDEfEE6e2a5C095d39B7A32f1E000", reactor: "0x000000b33fE4fB9d999Dd684F79b110731c3d000", executor: "0x000642A0966d9bd49870D9519f76b5cf823f3000", refinery: "0x000E474c0D7084EAA35A501035E73269f4b009A5", salt: { wm: "0xc9b46eae42dfeba3222a0315bf682f33cd5cc9d60c9625642e88406f8415f152", repermit: "0x4871dc9008e605821ea9677b65ea2a60ffb774afb31e0dcaea2e192880096be7", cosigner: "0x1117fe6f4e25c9380d10b2b3314a1e9b33e5f65ba0e55e0c63d0640db0dd60a2", reactor: "0xec73677f3a465a9755d4c9eab9509b59a24613fdb8b78719682930373e9876f5", executor: "0x9abc67d936f79e493f1f14050c2f6adb87ec208ff7aaae2e7ae788a7cb4796d7", refinery: "0x9746de29f1dd31b2c8460d71e92a7aefa34911130e61f274f37776e598c48bec", agentAdapter: "0xf6d54cf6a0619f1fb8e1ded91d4c23e7bb9f498c56735fb0c7669423c766219f", agentFee: "0x151234279af18acc113f70463977058efa2e598b5bfc0c106c75fd638d344c0a", unknownAdapter: "0x1aa43154c4be61f2790f139ef440a68806cfbbb86d0dc5e2704937cd93cbafc4", unknownFee: "0x429599ae7495b3e6a93b88d653ac97772fb130b0b74e755d9d215912a252cb7e", utilaAdapter: "0x7671291910b559d7a05ab73ee31dd714d9c6e7b065c9496338bf427182ae5145", utilaFee: "0x46f797cddb221ecf6279b56f52e2f6360cd721ef95bd5a17dd0ffceffaaf7fd6", efAdapter: "0xa5425e0f84a7cf12c4213f57396810d808d88e43a65210786bd0d9a98a314728", efFee: "0x14387b821c54f18e2a9351887a92cc79164a5ea0b88cfc3f36741eae6d4fd815", htAdapter: "0x2ec50a8a136049da76c16f3dd12a8ed1b23f2bc91aca73c6a20cc8344e34f998", htFee: "0x2f902a86a7f6abeedc073e76cd33d4737f25189e18c8f450f16d2ffe14405242" }, dex: { agent: { type: "universal", adapter: "0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa", fee: "0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE" }, unknown: { type: "universal", adapter: "0xada00982E8a888a6aa9BFb270591cb54cE7190d0", fee: "0xfEe00C84894160d582860D76cd7e896d96DBD3d5" }, utila: { type: "universal", adapter: "0x000ADa14B2ECF45Da6Cf1B33dE34e05231E9C76f", fee: "0x000FEee351263c82501a4dF5f699a8b630ac7f36" }, ef: { type: "universal", adapter: "0xeF1B796D708BD776F6b377E93eAd8Ca5fA0C3117", fee: "0xeF1D677d7aE1a066beb26cC1C74E31C082B75FEf" }, ht: { type: "universal", adapter: "0xA560a960C3b7784f5c335C33028D31596b91650b", fee: "0xE7a926C0cb01aCCE74e5d4FCeB7CA1699e200608" }, ginco: { type: "universal", adapter: "0x96604C3E846BBa75c43B5518bd076851e5484197", fee: "0xCf2eB80A89A69aB17e295aeF033Ffe9564736155" } } }
|
|
856
857
|
};
|
|
857
|
-
var
|
|
858
|
+
var Ue, et;
|
|
858
859
|
function Lt() {
|
|
859
|
-
if (et) return
|
|
860
|
+
if (et) return Ue;
|
|
860
861
|
et = 1;
|
|
861
862
|
const e = Nt, t = (d) => Mt(`./out/${d}.sol/${d}.abi.json`), n = () => ({
|
|
862
863
|
wm: t("WM"),
|
|
@@ -868,23 +869,23 @@ 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: F, ...C } = e["*"] ?? {}, O = e[d];
|
|
880
881
|
if (!O) return;
|
|
881
|
-
const { dex:
|
|
882
|
-
if (!V) return
|
|
883
|
-
const
|
|
884
|
-
if (!(!
|
|
885
|
-
return { ...
|
|
882
|
+
const { dex: T, salt: g, ...B } = O, P = { ...C, ...B }, V = b == null ? void 0 : b.trim();
|
|
883
|
+
if (!V) return P;
|
|
884
|
+
const U = m == null ? void 0 : m[V], j = T == null ? void 0 : T[V];
|
|
885
|
+
if (!(!U && !j))
|
|
886
|
+
return { ...P, ...U, ...j };
|
|
886
887
|
}
|
|
887
|
-
return
|
|
888
|
+
return Ue = { config: a, adapters: i, abis: n, raw: e }, Ue;
|
|
888
889
|
}
|
|
889
890
|
var Ge = Lt();
|
|
890
891
|
const Ut = new Set(Object.values(Q)), $t = (e) => Ut.has(e), At = () => {
|
|
@@ -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
|
);
|
|
@@ -1023,11 +1024,11 @@ const Ut = new Set(Object.values(Q)), $t = (e) => Ut.has(e), At = () => {
|
|
|
1023
1024
|
const n = x(10).pow(e);
|
|
1024
1025
|
return x(t).times(n).idiv(n).div(n).toFixed();
|
|
1025
1026
|
};
|
|
1026
|
-
function
|
|
1027
|
+
function Oe(e, t) {
|
|
1027
1028
|
return e == t || e.toLowerCase() == t.toLowerCase();
|
|
1028
1029
|
}
|
|
1029
1030
|
const pn = (e) => Rt.some(
|
|
1030
|
-
(t) =>
|
|
1031
|
+
(t) => Oe(t, e || "")
|
|
1031
1032
|
);
|
|
1032
1033
|
function An(e) {
|
|
1033
1034
|
return [
|
|
@@ -1039,7 +1040,7 @@ function An(e) {
|
|
|
1039
1040
|
se.Minutes
|
|
1040
1041
|
].find((n) => n <= e) || se.Minutes;
|
|
1041
1042
|
}
|
|
1042
|
-
const
|
|
1043
|
+
const me = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0" : x(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)
|
|
@@ -1075,32 +1076,32 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1075
1076
|
if (e.type === N.TWAP_MARKET) return "";
|
|
1076
1077
|
const i = be(t, e.srcAmountPerTrade), a = be(n, e.triggerPricePerTrade);
|
|
1077
1078
|
return x(a).div(i).toFixed();
|
|
1078
|
-
},
|
|
1079
|
-
const a =
|
|
1079
|
+
}, bn = (e, t, n, i) => {
|
|
1080
|
+
const a = me(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
1086
|
return { unit: d, value: Number(x(a / d).toFixed(2)) };
|
|
1086
|
-
},
|
|
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
1089
|
const a = x(t).times(e).div(n).integerValue(x.ROUND_FLOOR).toNumber();
|
|
1089
1090
|
return Math.max(1, a);
|
|
1090
|
-
},
|
|
1091
|
-
isError: !(e.unit === Ve.unit && e.value === Ve.value) &&
|
|
1092
|
-
value: Math.floor(
|
|
1093
|
-
}),
|
|
1094
|
-
isError:
|
|
1091
|
+
}, xn = (e, t) => ({
|
|
1092
|
+
isError: !(e.unit === Ve.unit && e.value === Ve.value) && me(e) * t > Pe,
|
|
1093
|
+
value: Math.floor(Pe / t)
|
|
1094
|
+
}), Tn = (e, t) => e === v.STOP_LOSS || e === v.TAKE_PROFIT ? {
|
|
1095
|
+
isError: me(t) > 5184e6,
|
|
1095
1096
|
value: 5184e6
|
|
1096
1097
|
} : {
|
|
1097
|
-
isError:
|
|
1098
|
-
value:
|
|
1098
|
+
isError: me(t) > Pe,
|
|
1099
|
+
value: Pe
|
|
1099
1100
|
}, gn = (e) => ({
|
|
1100
|
-
isError:
|
|
1101
|
+
isError: me(e) < Je,
|
|
1101
1102
|
value: Je
|
|
1102
1103
|
}), Dn = (e) => ({
|
|
1103
|
-
isError:
|
|
1104
|
+
isError: me(e) < Ke,
|
|
1104
1105
|
value: Ke
|
|
1105
1106
|
}), Fn = (e, t, n) => ({
|
|
1106
1107
|
isError: n === v.TWAP && x(e).isGreaterThan(t),
|
|
@@ -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,
|
|
@@ -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
|
);
|
|
@@ -1171,7 +1172,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1171
1172
|
};
|
|
1172
1173
|
}, Pn = (e, t, n, i) => {
|
|
1173
1174
|
if (x(t || "0").isZero() || !n) return;
|
|
1174
|
-
const a =
|
|
1175
|
+
const a = Tn(e, i.duration);
|
|
1175
1176
|
if (a.isError)
|
|
1176
1177
|
return {
|
|
1177
1178
|
type: J.MAX_ORDER_DURATION,
|
|
@@ -1197,32 +1198,32 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
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 && x(t.raw).gt(e.inputBalanceRaw) ? {
|
|
1204
1205
|
type: J.INSUFFICIENT_BALANCE,
|
|
1205
1206
|
value: e.inputBalanceRaw
|
|
1206
|
-
} : void 0,
|
|
1207
|
-
|
|
1207
|
+
} : void 0, F = [
|
|
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((
|
|
1214
|
+
m
|
|
1215
|
+
].filter((T) => !!T), C = x(n || 0).gt(0) && x(t.raw || 0).gt(0) && x(e.inputTokenUsdPrice || 0).gt(0), O = C ? F[0] : void 0;
|
|
1215
1216
|
return {
|
|
1216
1217
|
errors: {
|
|
1217
1218
|
primary: O,
|
|
1218
|
-
all:
|
|
1219
|
-
minTradeSize:
|
|
1219
|
+
all: F,
|
|
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
|
|
@@ -1248,31 +1249,31 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1248
1249
|
limitPrice: i,
|
|
1249
1250
|
triggerPrice: a
|
|
1250
1251
|
}) => e === v.LIMIT || !t ? H(i) : e === v.STOP_LOSS || e === v.TAKE_PROFIT ? H(a) : H(n), Ln = (e, t) => !e || !t ? "" : x(e).multipliedBy(t).decimalPlaces(0).toFixed(), Un = (e) => {
|
|
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),
|
|
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), F = 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
|
|
1260
1261
|
), O = H(
|
|
1261
|
-
_n(a,
|
|
1262
|
-
),
|
|
1262
|
+
_n(a, F, e.inputTokenDecimals)
|
|
1263
|
+
), T = vn(
|
|
1263
1264
|
C,
|
|
1264
|
-
|
|
1265
|
+
b,
|
|
1265
1266
|
e.isMarketOrder,
|
|
1266
1267
|
e.inputTokenDecimals
|
|
1267
|
-
),
|
|
1268
|
-
|
|
1268
|
+
), g = Ln(
|
|
1269
|
+
T,
|
|
1269
1270
|
t.totalTrades
|
|
1270
|
-
),
|
|
1271
|
+
), B = In(
|
|
1271
1272
|
e.module,
|
|
1272
1273
|
C,
|
|
1273
|
-
|
|
1274
|
+
m,
|
|
1274
1275
|
e.inputTokenDecimals
|
|
1275
|
-
) || "0",
|
|
1276
|
+
) || "0", P = i && O ? x(O).multipliedBy(i).dividedBy(100).toFixed(0) : "";
|
|
1276
1277
|
return {
|
|
1277
1278
|
...t,
|
|
1278
1279
|
orderType: Mn(e.module, e.isMarketOrder),
|
|
@@ -1282,14 +1283,14 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
1282
1283
|
inputAmount: a,
|
|
1283
1284
|
outputAmount: O,
|
|
1284
1285
|
inputAmountPerTrade: C,
|
|
1285
|
-
minOutputAmountPerTrade:
|
|
1286
|
-
minOutputAmountTotal:
|
|
1287
|
-
triggerOutputAmountPerTrade:
|
|
1288
|
-
tradePrice:
|
|
1286
|
+
minOutputAmountPerTrade: T,
|
|
1287
|
+
minOutputAmountTotal: g,
|
|
1288
|
+
triggerOutputAmountPerTrade: B,
|
|
1289
|
+
tradePrice: F,
|
|
1289
1290
|
marketPrice: d,
|
|
1290
|
-
limitPrice:
|
|
1291
|
-
triggerPrice:
|
|
1292
|
-
displayFeeAmount:
|
|
1291
|
+
limitPrice: b,
|
|
1292
|
+
triggerPrice: m,
|
|
1293
|
+
displayFeeAmount: P,
|
|
1293
1294
|
displayFeePercent: i
|
|
1294
1295
|
};
|
|
1295
1296
|
}, $n = (e) => {
|
|
@@ -1310,7 +1311,7 @@ const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0"
|
|
|
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
|
+
}), F = 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
|
-
|
|
1399
|
+
F,
|
|
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
|
-
schedule:
|
|
1413
|
-
triggerPrice:
|
|
1414
|
-
limitPrice:
|
|
1413
|
+
schedule: F,
|
|
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,308 +1746,29 @@ 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", _e = {
|
|
1749
1750
|
version: Xn
|
|
1750
|
-
},
|
|
1751
|
-
let Pe = "unknown";
|
|
1752
|
-
function Xr(e) {
|
|
1753
|
-
Pe = e;
|
|
1754
|
-
}
|
|
1755
|
-
function we() {
|
|
1756
|
-
const e = Math.random().toString(36).substring(2, 16), t = Math.random().toString(36).substring(2, 16), n = Date.now().toString(36);
|
|
1757
|
-
return `id_${e + t + n}`;
|
|
1758
|
-
}
|
|
1759
|
-
const Zn = (e, t, n) => ({
|
|
1760
|
-
spotVersion: ve.version,
|
|
1761
|
-
partner: e,
|
|
1762
|
-
chainId: n || 0,
|
|
1763
|
-
minChunkSizeUsd: t
|
|
1764
|
-
}), Qn = (e, t, n, i) => {
|
|
1765
|
-
const { witness: a } = e.order, d = Ge.config(
|
|
1766
|
-
e.domain.chainId,
|
|
1767
|
-
t
|
|
1768
|
-
);
|
|
1769
|
-
return {
|
|
1770
|
-
spotVersion: ve.version,
|
|
1771
|
-
partner: t,
|
|
1772
|
-
cosigner: d == null ? void 0 : d.cosigner,
|
|
1773
|
-
fee: d == null ? void 0 : d.fee,
|
|
1774
|
-
refinery: d == null ? void 0 : d.refinery,
|
|
1775
|
-
router: d == null ? void 0 : d.router,
|
|
1776
|
-
type: d == null ? void 0 : d.type,
|
|
1777
|
-
wm: d == null ? void 0 : d.wm,
|
|
1778
|
-
adapter: a.exchange.adapter,
|
|
1779
|
-
executor: a.executor,
|
|
1780
|
-
reactor: a.reactor,
|
|
1781
|
-
repermit: e.domain.verifyingContract,
|
|
1782
|
-
chainId: e.domain.chainId,
|
|
1783
|
-
chainName: (n == null ? void 0 : n.chainName) || "",
|
|
1784
|
-
twapVersion: (n == null ? void 0 : n.twapVersion) || 0,
|
|
1785
|
-
twapAddress: (n == null ? void 0 : n.twapAddress) || "",
|
|
1786
|
-
lensAddress: (n == null ? void 0 : n.lensAddress) || "",
|
|
1787
|
-
bidDelaySeconds: (n == null ? void 0 : n.bidDelaySeconds) || 0,
|
|
1788
|
-
minChunkSizeUsd: i || 0,
|
|
1789
|
-
name: (n == null ? void 0 : n.name) || "",
|
|
1790
|
-
exchangeAddress: (n == null ? void 0 : n.exchangeAddress) || "",
|
|
1791
|
-
exchangeType: (n == null ? void 0 : n.exchangeType) || "",
|
|
1792
|
-
pathfinderKey: (n == null ? void 0 : n.pathfinderKey) || ""
|
|
1793
|
-
};
|
|
1794
|
-
}, Se = async (e) => {
|
|
1795
|
-
try {
|
|
1796
|
-
await fetch(Yn, {
|
|
1797
|
-
method: "POST",
|
|
1798
|
-
headers: {
|
|
1799
|
-
Accept: "application/json",
|
|
1800
|
-
"Content-Type": "application/json"
|
|
1801
|
-
},
|
|
1802
|
-
body: JSON.stringify(e)
|
|
1803
|
-
}).then();
|
|
1804
|
-
} catch (t) {
|
|
1805
|
-
console.error("Failed to send BI", t);
|
|
1806
|
-
}
|
|
1807
|
-
}, it = (e) => {
|
|
1808
|
-
try {
|
|
1809
|
-
if (typeof e == "string" && e.trim())
|
|
1810
|
-
return e.toLowerCase();
|
|
1811
|
-
if (typeof e == "object" && e !== null) {
|
|
1812
|
-
const t = Reflect.get(e, "message");
|
|
1813
|
-
if (typeof t == "string" && t.trim())
|
|
1814
|
-
return t.toLowerCase();
|
|
1815
|
-
const n = Reflect.get(e, "code");
|
|
1816
|
-
if (typeof n == "string" || typeof n == "number")
|
|
1817
|
-
return String(n).toLowerCase();
|
|
1818
|
-
}
|
|
1819
|
-
} catch {
|
|
1820
|
-
}
|
|
1821
|
-
return "unknown error";
|
|
1822
|
-
};
|
|
1823
|
-
class Jn {
|
|
1824
|
-
constructor() {
|
|
1825
|
-
Ee(this, "timeout");
|
|
1826
|
-
Ee(this, "configDetails", {});
|
|
1827
|
-
Ee(this, "configUpdateKey", "");
|
|
1828
|
-
Ee(this, "moduleImportKey", "");
|
|
1829
|
-
Ee(this, "data", {
|
|
1830
|
-
_id: we()
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
|
-
async updateAndSend(t = {}, n = !1, i) {
|
|
1834
|
-
try {
|
|
1835
|
-
this.data = {
|
|
1836
|
-
...this.data,
|
|
1837
|
-
...t
|
|
1838
|
-
}, n ? (await Se(this.data), i == null || i()) : (clearTimeout(this.timeout), this.timeout = setTimeout(() => {
|
|
1839
|
-
Se(this.data), i == null || i();
|
|
1840
|
-
}, 1e3));
|
|
1841
|
-
} catch (a) {
|
|
1842
|
-
console.error("Failed to update and send BI", a);
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
onCancelOrderRequest(t, n) {
|
|
1846
|
-
this.updateAndSend({
|
|
1847
|
-
cancelOrderIdsV1: n === 1 ? t : void 0,
|
|
1848
|
-
cancelOrderIdsV2: n === 2 ? t : void 0,
|
|
1849
|
-
action: "cancel order",
|
|
1850
|
-
cancelOrderSuccess: !1,
|
|
1851
|
-
cancelOrderTxHash: void 0,
|
|
1852
|
-
actionError: void 0
|
|
1853
|
-
});
|
|
1854
|
-
}
|
|
1855
|
-
onCancelOrderSuccess(t) {
|
|
1856
|
-
this.updateAndSend({
|
|
1857
|
-
cancelOrderTxHash: t,
|
|
1858
|
-
cancelOrderSuccess: !0
|
|
1859
|
-
});
|
|
1860
|
-
}
|
|
1861
|
-
onCancelOrderError(t) {
|
|
1862
|
-
this.onTxError(t);
|
|
1863
|
-
}
|
|
1864
|
-
onWrapSuccess(t) {
|
|
1865
|
-
this.updateAndSend({
|
|
1866
|
-
wrapTxHash: t
|
|
1867
|
-
});
|
|
1868
|
-
}
|
|
1869
|
-
onWrapRequest() {
|
|
1870
|
-
this.updateAndSend({
|
|
1871
|
-
action: "wrap"
|
|
1872
|
-
});
|
|
1873
|
-
}
|
|
1874
|
-
onWrapError(t) {
|
|
1875
|
-
this.onTxError(t);
|
|
1876
|
-
}
|
|
1877
|
-
onApproveRequest() {
|
|
1878
|
-
this.updateAndSend({
|
|
1879
|
-
action: "approve"
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
onApproveSuccess(t) {
|
|
1883
|
-
this.updateAndSend({
|
|
1884
|
-
approvalTxHash: t
|
|
1885
|
-
});
|
|
1886
|
-
}
|
|
1887
|
-
onApproveError(t) {
|
|
1888
|
-
this.onTxError(t);
|
|
1889
|
-
}
|
|
1890
|
-
onCrash(t) {
|
|
1891
|
-
this.updateAndSend({
|
|
1892
|
-
action: "crash",
|
|
1893
|
-
actionError: it(t)
|
|
1894
|
-
});
|
|
1895
|
-
}
|
|
1896
|
-
onTxError(t) {
|
|
1897
|
-
this.updateAndSend({ actionError: it(t) });
|
|
1898
|
-
}
|
|
1899
|
-
onRequestOrder({
|
|
1900
|
-
account: t,
|
|
1901
|
-
chainId: n,
|
|
1902
|
-
module: i,
|
|
1903
|
-
srcToken: a,
|
|
1904
|
-
dstToken: d,
|
|
1905
|
-
fromTokenAmount: m,
|
|
1906
|
-
srcChunkAmount: b,
|
|
1907
|
-
minDstAmountOutPerTrade: D = "",
|
|
1908
|
-
triggerPricePerTrade: C = "",
|
|
1909
|
-
deadline: O,
|
|
1910
|
-
fillDelay: F,
|
|
1911
|
-
slippage: h,
|
|
1912
|
-
isMarketOrder: w,
|
|
1913
|
-
chunksAmount: B
|
|
1914
|
-
}) {
|
|
1915
|
-
this.updateAndSend({
|
|
1916
|
-
toTokenAddress: d.address,
|
|
1917
|
-
toTokenSymbol: d.symbol,
|
|
1918
|
-
fromTokenAddress: a.address,
|
|
1919
|
-
fromTokenSymbol: a.symbol,
|
|
1920
|
-
fromTokenAmount: m,
|
|
1921
|
-
chunksAmount: B,
|
|
1922
|
-
srcChunkAmount: b,
|
|
1923
|
-
minDstAmountOutPerTrade: D,
|
|
1924
|
-
triggerPricePerTrade: C,
|
|
1925
|
-
deadline: O,
|
|
1926
|
-
fillDelay: F,
|
|
1927
|
-
slippage: h,
|
|
1928
|
-
chainId: n,
|
|
1929
|
-
walletAddress: t,
|
|
1930
|
-
module: i,
|
|
1931
|
-
orderType: w ? "market" : "limit",
|
|
1932
|
-
actionError: void 0
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
|
-
onSignOrderRequest(t) {
|
|
1936
|
-
this.updateAndSend({
|
|
1937
|
-
action: "sign order"
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
onSignOrderError(t) {
|
|
1941
|
-
this.onTxError(t);
|
|
1942
|
-
}
|
|
1943
|
-
onSignOrderSuccess(t) {
|
|
1944
|
-
this.updateAndSend({
|
|
1945
|
-
action: "sign order"
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
init(t, n, i, a) {
|
|
1949
|
-
const d = `${t}:${i || 0}:${a || ""}`;
|
|
1950
|
-
if (d !== this.moduleImportKey) {
|
|
1951
|
-
this.moduleImportKey = d;
|
|
1952
|
-
const m = {
|
|
1953
|
-
_id: we(),
|
|
1954
|
-
action: "module-import",
|
|
1955
|
-
uiVersion: Pe,
|
|
1956
|
-
appId: a,
|
|
1957
|
-
...Zn(t, n, i),
|
|
1958
|
-
origin: window.location.origin
|
|
1959
|
-
};
|
|
1960
|
-
this.configDetails.partner === t && this.configDetails.chainId === (i || 0) || (this.configDetails = {}), this.data = { ...m, ...this.configDetails }, Se(m);
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
onFetchedConfig(t, n, i, a) {
|
|
1964
|
-
const d = Qn(
|
|
1965
|
-
t,
|
|
1966
|
-
n,
|
|
1967
|
-
i,
|
|
1968
|
-
a
|
|
1969
|
-
), m = `${n}:${d.chainId}:${d.repermit}:${d.adapter}:${d.executor}:${d.reactor}`;
|
|
1970
|
-
m !== this.configUpdateKey && (this.configUpdateKey = m, this.configDetails = d, this.data = { ...this.data, ...d }, Se({
|
|
1971
|
-
_id: we(),
|
|
1972
|
-
action: "config-update",
|
|
1973
|
-
uiVersion: Pe,
|
|
1974
|
-
appId: this.data.appId,
|
|
1975
|
-
origin: typeof window > "u" ? void 0 : window.location.origin,
|
|
1976
|
-
...d
|
|
1977
|
-
}));
|
|
1978
|
-
}
|
|
1979
|
-
onCreateOrderError(t) {
|
|
1980
|
-
this.onTxError(t);
|
|
1981
|
-
}
|
|
1982
|
-
onCreateOrderRequest() {
|
|
1983
|
-
this.updateAndSend({
|
|
1984
|
-
action: "create order"
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
async onCreateOrderSuccess(t) {
|
|
1988
|
-
this.updateAndSend(
|
|
1989
|
-
{
|
|
1990
|
-
orderHash: t,
|
|
1991
|
-
orderSuccess: !0
|
|
1992
|
-
},
|
|
1993
|
-
void 0,
|
|
1994
|
-
() => {
|
|
1995
|
-
this.data = {
|
|
1996
|
-
_id: we(),
|
|
1997
|
-
action: "reset",
|
|
1998
|
-
uiVersion: Pe,
|
|
1999
|
-
appId: this.data.appId,
|
|
2000
|
-
origin: this.data.origin,
|
|
2001
|
-
spotVersion: ve.version,
|
|
2002
|
-
partner: this.data.partner,
|
|
2003
|
-
adapter: this.data.adapter,
|
|
2004
|
-
cosigner: this.data.cosigner,
|
|
2005
|
-
executor: this.data.executor,
|
|
2006
|
-
fee: this.data.fee,
|
|
2007
|
-
reactor: this.data.reactor,
|
|
2008
|
-
refinery: this.data.refinery,
|
|
2009
|
-
repermit: this.data.repermit,
|
|
2010
|
-
router: this.data.router,
|
|
2011
|
-
type: this.data.type,
|
|
2012
|
-
wm: this.data.wm,
|
|
2013
|
-
chainName: this.data.chainName || "",
|
|
2014
|
-
chainId: this.data.chainId || 0,
|
|
2015
|
-
twapVersion: this.data.twapVersion || 0,
|
|
2016
|
-
twapAddress: this.data.twapAddress || "",
|
|
2017
|
-
lensAddress: this.data.lensAddress || "",
|
|
2018
|
-
bidDelaySeconds: this.data.bidDelaySeconds || 0,
|
|
2019
|
-
minChunkSizeUsd: this.data.minChunkSizeUsd || 0,
|
|
2020
|
-
name: this.data.name || "",
|
|
2021
|
-
exchangeAddress: this.data.exchangeAddress || "",
|
|
2022
|
-
exchangeType: this.data.exchangeType || "",
|
|
2023
|
-
pathfinderKey: this.data.pathfinderKey || ""
|
|
2024
|
-
};
|
|
2025
|
-
}
|
|
2026
|
-
);
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
const me = 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 = {
|
|
1751
|
+
}, ke = "https://order-sink.orbs.network", ve = "https://order-sink-v2.orbs.network", Xe = _e.version.split(".")[0], Hn = () => Number(Xe) >= 2 ? ve : ke, Yn = () => `${ve}/config`, Zn = () => Number(Xe) >= 2 ? [ve, ke] : [ke], Qn = {
|
|
2030
1752
|
[Q.Thena]: ["0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"],
|
|
2031
1753
|
[Q.Katana]: ["0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df"]
|
|
2032
|
-
},
|
|
1754
|
+
}, Jn = ({
|
|
2033
1755
|
endpoint: e,
|
|
2034
1756
|
exchange: t,
|
|
2035
1757
|
partner: n
|
|
2036
1758
|
}) => {
|
|
2037
|
-
const a = [
|
|
1759
|
+
const a = [ke, ve].includes(
|
|
2038
1760
|
e
|
|
2039
|
-
) && n ?
|
|
1761
|
+
) && n ? Qn[n] || [] : [], d = t ? [t, ...a] : a;
|
|
2040
1762
|
return d.filter(
|
|
2041
|
-
(
|
|
2042
|
-
(
|
|
2043
|
-
) ===
|
|
1763
|
+
(b, m) => d.findIndex(
|
|
1764
|
+
(F) => F.toLowerCase() === b.toLowerCase()
|
|
1765
|
+
) === m
|
|
2044
1766
|
);
|
|
2045
|
-
},
|
|
1767
|
+
}, er = async (e, t) => {
|
|
2046
1768
|
const n = new URLSearchParams({
|
|
2047
1769
|
partner: e,
|
|
2048
1770
|
chain: t.toString()
|
|
2049
|
-
}), i = await fetch(`${
|
|
1771
|
+
}), i = await fetch(`${Yn()}?${n}`);
|
|
2050
1772
|
if (!i.ok) {
|
|
2051
1773
|
const a = await i.text();
|
|
2052
1774
|
throw new Error(
|
|
@@ -2054,66 +1776,66 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2054
1776
|
);
|
|
2055
1777
|
}
|
|
2056
1778
|
return i.json();
|
|
2057
|
-
},
|
|
1779
|
+
}, tr = ({
|
|
2058
1780
|
inputTokenAddress: e,
|
|
2059
1781
|
outputTokenAddress: t,
|
|
2060
1782
|
totalInputAmount: n,
|
|
2061
1783
|
nonce: i,
|
|
2062
1784
|
currentTimeMillis: a,
|
|
2063
1785
|
deadlineMillis: d,
|
|
2064
|
-
fillDelayMillis:
|
|
2065
|
-
totalTrades:
|
|
2066
|
-
slippageBps:
|
|
1786
|
+
fillDelayMillis: b,
|
|
1787
|
+
totalTrades: m,
|
|
1788
|
+
slippageBps: F,
|
|
2067
1789
|
swapperAddress: C,
|
|
2068
1790
|
inputAmountPerTrade: O,
|
|
2069
|
-
minOutputAmountPerTrade:
|
|
2070
|
-
triggerOutputAmountPerTrade:
|
|
2071
|
-
permitData:
|
|
2072
|
-
module:
|
|
1791
|
+
minOutputAmountPerTrade: T = "0",
|
|
1792
|
+
triggerOutputAmountPerTrade: g = "0",
|
|
1793
|
+
permitData: B,
|
|
1794
|
+
module: P
|
|
2073
1795
|
}) => {
|
|
2074
|
-
const V = !
|
|
2075
|
-
|
|
1796
|
+
const V = !m || m === 1 ? 0 : parseInt((b / 1e3).toFixed(0)), U = yn(d / 1e3), j = 60, D = Math.floor(a / 1e3).toString(), he = x(T || 0).toFixed(), ge = x(
|
|
1797
|
+
P === v.STOP_LOSS && g || 0
|
|
2076
1798
|
).toFixed(), xe = x(
|
|
2077
|
-
|
|
1799
|
+
P === v.TAKE_PROFIT && g || 0
|
|
2078
1800
|
).toFixed(), Y = {
|
|
2079
|
-
...
|
|
1801
|
+
...B.order,
|
|
2080
1802
|
permitted: {
|
|
2081
|
-
...
|
|
1803
|
+
...B.order.permitted,
|
|
2082
1804
|
token: e,
|
|
2083
1805
|
amount: n
|
|
2084
1806
|
},
|
|
2085
1807
|
nonce: i,
|
|
2086
|
-
deadline:
|
|
1808
|
+
deadline: U,
|
|
2087
1809
|
witness: {
|
|
2088
|
-
...
|
|
1810
|
+
...B.order.witness,
|
|
2089
1811
|
swapper: C,
|
|
2090
1812
|
nonce: i,
|
|
2091
|
-
start:
|
|
2092
|
-
deadline:
|
|
1813
|
+
start: D,
|
|
1814
|
+
deadline: U,
|
|
2093
1815
|
epoch: V,
|
|
2094
|
-
slippage:
|
|
2095
|
-
freshness:
|
|
1816
|
+
slippage: F,
|
|
1817
|
+
freshness: j,
|
|
2096
1818
|
input: {
|
|
2097
|
-
...
|
|
1819
|
+
...B.order.witness.input,
|
|
2098
1820
|
token: e,
|
|
2099
1821
|
amount: O,
|
|
2100
1822
|
maxAmount: n
|
|
2101
1823
|
},
|
|
2102
1824
|
output: {
|
|
2103
|
-
...
|
|
1825
|
+
...B.order.witness.output,
|
|
2104
1826
|
token: t,
|
|
2105
|
-
limit:
|
|
2106
|
-
triggerLower:
|
|
1827
|
+
limit: he,
|
|
1828
|
+
triggerLower: ge,
|
|
2107
1829
|
triggerUpper: xe,
|
|
2108
1830
|
recipient: C
|
|
2109
1831
|
}
|
|
2110
1832
|
}
|
|
2111
1833
|
};
|
|
2112
1834
|
return {
|
|
2113
|
-
...
|
|
1835
|
+
...B,
|
|
2114
1836
|
order: Y
|
|
2115
1837
|
};
|
|
2116
|
-
}, fe = (e, t) => e && e.length ? e.map(t || ((n) => `${n}`)) : void 0,
|
|
1838
|
+
}, fe = (e, t) => e && e.length ? e.map(t || ((n) => `${n}`)) : void 0, nr = (e) => {
|
|
2117
1839
|
if (e)
|
|
2118
1840
|
return on[e];
|
|
2119
1841
|
}, He = (e, t) => {
|
|
@@ -2133,44 +1855,44 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2133
1855
|
signal: i,
|
|
2134
1856
|
retries: a = 1,
|
|
2135
1857
|
limit: d = 1e3,
|
|
2136
|
-
page:
|
|
1858
|
+
page: b
|
|
2137
1859
|
}) => {
|
|
2138
|
-
const
|
|
2139
|
-
if (!
|
|
2140
|
-
const
|
|
2141
|
-
let
|
|
2142
|
-
for (;
|
|
1860
|
+
const m = nr(e);
|
|
1861
|
+
if (!m) throw new Et();
|
|
1862
|
+
const F = async (T) => {
|
|
1863
|
+
let g = 0;
|
|
1864
|
+
for (; g <= a; )
|
|
2143
1865
|
try {
|
|
2144
|
-
const
|
|
1866
|
+
const B = await fetch(m, {
|
|
2145
1867
|
method: "POST",
|
|
2146
|
-
body: JSON.stringify({ query:
|
|
1868
|
+
body: JSON.stringify({ query: T }),
|
|
2147
1869
|
signal: i,
|
|
2148
1870
|
headers: { "Content-Type": "application/json" }
|
|
2149
1871
|
});
|
|
2150
|
-
if (!
|
|
2151
|
-
const
|
|
1872
|
+
if (!B.ok) throw new Error(`HTTP error: ${B.status}`);
|
|
1873
|
+
const P = await B.json(), V = P && typeof P == "object" ? P.errors : void 0;
|
|
2152
1874
|
if (Array.isArray(V) && V.length) {
|
|
2153
|
-
const
|
|
1875
|
+
const U = V[0], j = U && typeof U == "object" ? U.message : void 0;
|
|
2154
1876
|
throw new Error(
|
|
2155
|
-
typeof
|
|
1877
|
+
typeof j == "string" ? j : "Subgraph request failed"
|
|
2156
1878
|
);
|
|
2157
1879
|
}
|
|
2158
|
-
return n(
|
|
2159
|
-
} catch (
|
|
2160
|
-
if (i != null && i.aborted ||
|
|
2161
|
-
await new Promise((
|
|
1880
|
+
return n(P);
|
|
1881
|
+
} catch (B) {
|
|
1882
|
+
if (i != null && i.aborted || B instanceof Error && B.name === "AbortError" || g === a) throw B;
|
|
1883
|
+
await new Promise((P) => setTimeout(P, 500 * 2 ** g)), g++;
|
|
2162
1884
|
}
|
|
2163
1885
|
return [];
|
|
2164
1886
|
};
|
|
2165
1887
|
let C = 0;
|
|
2166
1888
|
const O = [];
|
|
2167
|
-
if (
|
|
2168
|
-
const
|
|
2169
|
-
return
|
|
1889
|
+
if (b !== void 0) {
|
|
1890
|
+
const T = t(b, d);
|
|
1891
|
+
return F(T);
|
|
2170
1892
|
}
|
|
2171
1893
|
for (; ; ) {
|
|
2172
|
-
const
|
|
2173
|
-
if (O.push(...
|
|
1894
|
+
const T = t(C, d), g = await F(T);
|
|
1895
|
+
if (O.push(...g), g.length < d) break;
|
|
2174
1896
|
C++;
|
|
2175
1897
|
}
|
|
2176
1898
|
return O;
|
|
@@ -2179,17 +1901,17 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2179
1901
|
outAmount: t.dstAmountOut,
|
|
2180
1902
|
timestamp: t.timestamp,
|
|
2181
1903
|
txHash: t.transactionHash
|
|
2182
|
-
})),
|
|
1904
|
+
})), it = (e, t) => {
|
|
2183
1905
|
const n = x(e || 0).gt(1);
|
|
2184
1906
|
return !n && t === 1 ? N.TWAP_MARKET : t > 1 && n ? N.TWAP_LIMIT : n ? N.LIMIT : N.TWAP_MARKET;
|
|
2185
|
-
},
|
|
2186
|
-
const a = yt(n || []), d = new x(e.ask_srcBidAmount || 0),
|
|
1907
|
+
}, rr = (e, t, n, i) => {
|
|
1908
|
+
const a = yt(n || []), d = new x(e.ask_srcBidAmount || 0), b = d.gt(0) ? Math.max(
|
|
2187
1909
|
1,
|
|
2188
1910
|
new x(e.ask_srcAmount || 0).div(d).integerValue(x.ROUND_CEIL).toNumber()
|
|
2189
|
-
) : 1,
|
|
2190
|
-
(
|
|
1911
|
+
) : 1, F = (n == null ? void 0 : n.length) >= b ? a.reduce(
|
|
1912
|
+
(B, P) => Math.max(B, P.timestamp),
|
|
2191
1913
|
0
|
|
2192
|
-
) : void 0, C = a.reduce((
|
|
1914
|
+
) : void 0, C = a.reduce((B, P) => B.plus(P.inAmount), new x(0)).toFixed(), O = a.reduce((B, P) => B.plus(P.outAmount), new x(0)).toFixed(), T = bt(e.ask_srcAmount, C), g = it(e.ask_dstMinAmount, b);
|
|
2193
1915
|
return {
|
|
2194
1916
|
repermitDigest: "",
|
|
2195
1917
|
version: 1,
|
|
@@ -2197,18 +1919,18 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2197
1919
|
isTriggerPrice: !1,
|
|
2198
1920
|
id: e.Contract_id.toString(),
|
|
2199
1921
|
hash: "",
|
|
2200
|
-
type:
|
|
1922
|
+
type: it(e.ask_dstMinAmount, b),
|
|
2201
1923
|
srcTokenAddress: e.ask_srcToken,
|
|
2202
1924
|
dstTokenAddress: e.ask_dstToken,
|
|
2203
1925
|
exchangeAddress: e.exchange,
|
|
2204
1926
|
twapAddress: e.twapAddress,
|
|
2205
1927
|
maker: e.maker,
|
|
2206
|
-
progress:
|
|
1928
|
+
progress: T,
|
|
2207
1929
|
dstAmountFilled: O,
|
|
2208
1930
|
srcAmountFilled: C,
|
|
2209
1931
|
orderDollarValueIn: x(e.dollarValueIn || 0).toFixed(6),
|
|
2210
1932
|
srcAmount: e.ask_srcAmount,
|
|
2211
|
-
dstMinAmountTotal: x(e.ask_dstMinAmount).multipliedBy(
|
|
1933
|
+
dstMinAmountTotal: x(e.ask_dstMinAmount).multipliedBy(b).toString(),
|
|
2212
1934
|
fills: a,
|
|
2213
1935
|
fillDelay: e.ask_fillDelay,
|
|
2214
1936
|
deadline: e.ask_deadline * 1e3,
|
|
@@ -2217,77 +1939,77 @@ const me = new Jn(), _e = "https://order-sink.orbs.network", Ie = "https://order
|
|
|
2217
1939
|
triggerPricePerTrade: "",
|
|
2218
1940
|
srcAmountPerTrade: e.ask_srcBidAmount,
|
|
2219
1941
|
txHash: e.transactionHash,
|
|
2220
|
-
totalTradesAmount:
|
|
2221
|
-
isMarketPrice: [N.TWAP_MARKET].includes(
|
|
1942
|
+
totalTradesAmount: b,
|
|
1943
|
+
isMarketPrice: [N.TWAP_MARKET].includes(g),
|
|
2222
1944
|
chainId: t,
|
|
2223
|
-
filledOrderTimestamp:
|
|
1945
|
+
filledOrderTimestamp: F || 0,
|
|
2224
1946
|
status: i,
|
|
2225
1947
|
rawOrder: e
|
|
2226
1948
|
};
|
|
2227
|
-
},
|
|
2228
|
-
var
|
|
1949
|
+
}, ar = (e) => {
|
|
1950
|
+
var T;
|
|
2229
1951
|
if (!e) return "";
|
|
2230
1952
|
const t = fe(
|
|
2231
1953
|
e.accounts,
|
|
2232
|
-
(
|
|
1954
|
+
(g) => `"${g.toLowerCase()}"`
|
|
2233
1955
|
), n = fe(
|
|
2234
1956
|
En(e.configs),
|
|
2235
|
-
(
|
|
1957
|
+
(g) => `"${g.toLowerCase()}"`
|
|
2236
1958
|
), i = fe(
|
|
2237
1959
|
e.inTokenSymbols,
|
|
2238
|
-
(
|
|
1960
|
+
(g) => `"${g.toUpperCase()}"`
|
|
2239
1961
|
), a = fe(
|
|
2240
1962
|
e.outTokenSymbols,
|
|
2241
|
-
(
|
|
1963
|
+
(g) => `"${g.toUpperCase()}"`
|
|
2242
1964
|
), d = fe(
|
|
2243
1965
|
e.inTokenAddresses,
|
|
2244
|
-
(
|
|
2245
|
-
), m = fe(
|
|
2246
|
-
e.outTokenAddresses,
|
|
2247
|
-
(h) => `"${h.toLowerCase()}"`
|
|
1966
|
+
(g) => `"${g.toLowerCase()}"`
|
|
2248
1967
|
), b = fe(
|
|
1968
|
+
e.outTokenAddresses,
|
|
1969
|
+
(g) => `"${g.toLowerCase()}"`
|
|
1970
|
+
), m = fe(
|
|
2249
1971
|
e.transactionHashes,
|
|
2250
|
-
(
|
|
2251
|
-
),
|
|
2252
|
-
(
|
|
2253
|
-
(
|
|
1972
|
+
(g) => `"${g.toLowerCase()}"`
|
|
1973
|
+
), F = fe(e.orderIds, (g) => `"${g}"`), C = n != null && n.length ? "" : fe(
|
|
1974
|
+
(T = e.configs) == null ? void 0 : T.map((g) => g.twapAddress),
|
|
1975
|
+
(g) => `"${g.toLowerCase()}"`
|
|
2254
1976
|
), O = e.minDollarValueIn;
|
|
2255
1977
|
return [
|
|
2256
1978
|
n ? `exchange_in: [${n.join(", ")}]` : "",
|
|
2257
1979
|
C ? `twapAddress_in: [${C.join(", ")}]` : "",
|
|
2258
1980
|
t ? `maker_in: [${t.join(", ")}]` : "",
|
|
2259
|
-
|
|
2260
|
-
|
|
1981
|
+
m ? `transactionHash_in: [${m.join(", ")}]` : "",
|
|
1982
|
+
F ? `Contract_id_in: [${F.join(", ")}]` : "",
|
|
2261
1983
|
O ? `dollarValueIn_gte: ${O}` : "",
|
|
2262
1984
|
i ? `srcTokenSymbol_in: [${i.join(", ")}]` : "",
|
|
2263
1985
|
a ? `dstTokenSymbol_in: [${a.join(", ")}]` : "",
|
|
2264
1986
|
d ? `srcTokenAddress_in: [${d.join(", ")}]` : "",
|
|
2265
|
-
|
|
1987
|
+
b ? `dstTokenAddress_in: [${b.join(", ")}]` : "",
|
|
2266
1988
|
e != null && e.startDate ? `blockTimestamp_gte: ${e.startDate}` : "",
|
|
2267
1989
|
e != null && e.endDate ? `blockTimestamp_lte: ${e.endDate}` : "",
|
|
2268
1990
|
(e == null ? void 0 : e.orderType) === "limit" ? "ask_dstMinAmount_gt: 1" : "",
|
|
2269
1991
|
(e == null ? void 0 : e.orderType) === "market" ? "ask_dstMinAmount_lte: 1" : ""
|
|
2270
1992
|
].filter(Boolean).join(", ");
|
|
2271
1993
|
};
|
|
2272
|
-
async function
|
|
1994
|
+
async function ir({
|
|
2273
1995
|
chainId: e,
|
|
2274
1996
|
signal: t,
|
|
2275
1997
|
page: n,
|
|
2276
1998
|
limit: i,
|
|
2277
1999
|
filters: a
|
|
2278
2000
|
}) {
|
|
2279
|
-
const d = i || 1e3,
|
|
2001
|
+
const d = i || 1e3, b = ar(a);
|
|
2280
2002
|
return await Ye({
|
|
2281
2003
|
chainId: e,
|
|
2282
2004
|
signal: t,
|
|
2283
2005
|
limit: d,
|
|
2284
2006
|
page: n,
|
|
2285
|
-
buildQuery: (
|
|
2007
|
+
buildQuery: (F, C) => `
|
|
2286
2008
|
{
|
|
2287
2009
|
orderCreateds(
|
|
2288
|
-
${
|
|
2010
|
+
${b ? `where: { ${b} },` : ""}
|
|
2289
2011
|
first: ${C},
|
|
2290
|
-
skip: ${
|
|
2012
|
+
skip: ${F * C},
|
|
2291
2013
|
orderBy: timestamp,
|
|
2292
2014
|
orderDirection: desc,
|
|
2293
2015
|
) {
|
|
@@ -2317,27 +2039,27 @@ async function ur({
|
|
|
2317
2039
|
}
|
|
2318
2040
|
}
|
|
2319
2041
|
`,
|
|
2320
|
-
extractResults: (
|
|
2042
|
+
extractResults: (F) => He(F, "orderCreateds")
|
|
2321
2043
|
});
|
|
2322
2044
|
}
|
|
2323
|
-
const
|
|
2045
|
+
const sr = async ({
|
|
2324
2046
|
chainId: e,
|
|
2325
2047
|
orders: t,
|
|
2326
2048
|
signal: n
|
|
2327
2049
|
}) => {
|
|
2328
2050
|
if (t.length === 0) return [];
|
|
2329
|
-
const i = qe(t.map((
|
|
2051
|
+
const i = qe(t.map((m) => m.Contract_id.toString()));
|
|
2330
2052
|
if (!i.length) return [];
|
|
2331
|
-
const d = `where: { twapId_in: [${i.map((
|
|
2053
|
+
const d = `where: { twapId_in: [${i.map((m) => `"${m}"`).join(", ")}]}`;
|
|
2332
2054
|
return await Ye({
|
|
2333
2055
|
chainId: e,
|
|
2334
2056
|
signal: n,
|
|
2335
2057
|
limit: 1e3,
|
|
2336
|
-
buildQuery: (
|
|
2058
|
+
buildQuery: (m, F) => `
|
|
2337
2059
|
{
|
|
2338
2060
|
statusNews(
|
|
2339
|
-
first: ${
|
|
2340
|
-
skip: ${
|
|
2061
|
+
first: ${F},
|
|
2062
|
+
skip: ${m * F},
|
|
2341
2063
|
${d}
|
|
2342
2064
|
) {
|
|
2343
2065
|
twapId
|
|
@@ -2346,30 +2068,30 @@ const lr = async ({
|
|
|
2346
2068
|
}
|
|
2347
2069
|
}
|
|
2348
2070
|
`,
|
|
2349
|
-
extractResults: (
|
|
2071
|
+
extractResults: (m) => He(m, "statusNews")
|
|
2350
2072
|
});
|
|
2351
2073
|
};
|
|
2352
2074
|
function qe(e) {
|
|
2353
2075
|
return Array.from(new Set(e));
|
|
2354
2076
|
}
|
|
2355
|
-
const
|
|
2077
|
+
const or = async ({
|
|
2356
2078
|
chainId: e,
|
|
2357
2079
|
orders: t,
|
|
2358
2080
|
signal: n
|
|
2359
2081
|
}) => {
|
|
2360
|
-
const i = qe(t.map((
|
|
2082
|
+
const i = qe(t.map((T) => T.Contract_id)), a = qe(t.map((T) => T.twapAddress)).filter(Boolean);
|
|
2361
2083
|
if (i.length === 0) return [];
|
|
2362
|
-
const d = i.join(", "),
|
|
2084
|
+
const d = i.join(", "), b = a.map((T) => `"${T}"`).join(", "), m = a.length ? `twapAddress_in: [${b}]` : "", C = `where: { ${[
|
|
2363
2085
|
`TWAP_id_in: [${d}]`,
|
|
2364
|
-
|
|
2086
|
+
m
|
|
2365
2087
|
].filter(Boolean).join(", ")} }`;
|
|
2366
2088
|
return await Ye({
|
|
2367
2089
|
chainId: e,
|
|
2368
2090
|
signal: n,
|
|
2369
2091
|
limit: 1e3,
|
|
2370
|
-
buildQuery: (
|
|
2092
|
+
buildQuery: (T, g) => `
|
|
2371
2093
|
{
|
|
2372
|
-
orderFilleds(first: ${
|
|
2094
|
+
orderFilleds(first: ${g}, orderBy: timestamp, skip: ${T * g}, ${C}) {
|
|
2373
2095
|
id
|
|
2374
2096
|
dstAmountOut
|
|
2375
2097
|
dstFee
|
|
@@ -2385,9 +2107,9 @@ const fr = async ({
|
|
|
2385
2107
|
}
|
|
2386
2108
|
}
|
|
2387
2109
|
`,
|
|
2388
|
-
extractResults: (
|
|
2389
|
-
...
|
|
2390
|
-
timestamp: new Date(
|
|
2110
|
+
extractResults: (T) => He(T, "orderFilleds").map((g) => ({
|
|
2111
|
+
...g,
|
|
2112
|
+
timestamp: new Date(g.timestamp).getTime()
|
|
2391
2113
|
}))
|
|
2392
2114
|
});
|
|
2393
2115
|
};
|
|
@@ -2396,7 +2118,7 @@ class Et extends Error {
|
|
|
2396
2118
|
super("No graph endpoint found"), this.name = "NoGraphEndpointError";
|
|
2397
2119
|
}
|
|
2398
2120
|
}
|
|
2399
|
-
const
|
|
2121
|
+
const dr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "number" && Number.isFinite(e.Contract_id)) && typeof e.twapAddress == "string" && e.twapAddress.length > 0 && typeof e.exchange == "string", cr = async ({
|
|
2400
2122
|
chainId: e,
|
|
2401
2123
|
signal: t,
|
|
2402
2124
|
page: n,
|
|
@@ -2404,71 +2126,71 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2404
2126
|
filters: a
|
|
2405
2127
|
}) => {
|
|
2406
2128
|
try {
|
|
2407
|
-
const d = await
|
|
2129
|
+
const d = await ir({
|
|
2408
2130
|
chainId: e,
|
|
2409
2131
|
signal: t,
|
|
2410
2132
|
page: n,
|
|
2411
2133
|
limit: i,
|
|
2412
2134
|
filters: a
|
|
2413
2135
|
});
|
|
2414
|
-
let
|
|
2415
|
-
const
|
|
2416
|
-
const
|
|
2417
|
-
return
|
|
2418
|
-
}), [
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
]), O =
|
|
2422
|
-
const
|
|
2423
|
-
(
|
|
2136
|
+
let b = 0;
|
|
2137
|
+
const m = d.filter((g) => {
|
|
2138
|
+
const B = dr(g);
|
|
2139
|
+
return B || b++, B;
|
|
2140
|
+
}), [F, C] = await Promise.all([
|
|
2141
|
+
or({ chainId: e, orders: m, signal: t }),
|
|
2142
|
+
sr({ chainId: e, orders: m, signal: t })
|
|
2143
|
+
]), O = m.flatMap((g) => {
|
|
2144
|
+
const B = F == null ? void 0 : F.filter(
|
|
2145
|
+
(P) => String(P.TWAP_id) === String(g.Contract_id) && Oe(P.exchange, g.exchange) && Oe(P.twapAddress, g.twapAddress)
|
|
2424
2146
|
);
|
|
2425
2147
|
try {
|
|
2426
2148
|
return [
|
|
2427
|
-
|
|
2428
|
-
|
|
2149
|
+
rr(
|
|
2150
|
+
g,
|
|
2429
2151
|
e,
|
|
2430
|
-
|
|
2431
|
-
|
|
2152
|
+
B,
|
|
2153
|
+
ur(g, B || [], C)
|
|
2432
2154
|
)
|
|
2433
2155
|
];
|
|
2434
2156
|
} catch {
|
|
2435
|
-
return
|
|
2157
|
+
return b++, [];
|
|
2436
2158
|
}
|
|
2437
|
-
}).sort((
|
|
2438
|
-
|
|
2439
|
-
`Skipped ${
|
|
2159
|
+
}).sort((g, B) => B.createdAt - g.createdAt);
|
|
2160
|
+
b > 0 && console.warn(
|
|
2161
|
+
`Skipped ${b} invalid legacy order history ${b === 1 ? "item" : "items"} on chain ${e}`
|
|
2440
2162
|
);
|
|
2441
|
-
const
|
|
2442
|
-
return O.filter((
|
|
2163
|
+
const T = /* @__PURE__ */ new Set();
|
|
2164
|
+
return O.filter((g) => T.has(g.historyKey) ? !1 : (T.add(g.historyKey), !0));
|
|
2443
2165
|
} catch (d) {
|
|
2444
2166
|
if (d instanceof Et) return [];
|
|
2445
2167
|
throw d;
|
|
2446
2168
|
}
|
|
2447
|
-
},
|
|
2448
|
-
var
|
|
2449
|
-
const i = (
|
|
2450
|
-
(
|
|
2451
|
-
)) == null ? void 0 :
|
|
2452
|
-
return
|
|
2453
|
-
},
|
|
2169
|
+
}, ur = (e, t, n) => {
|
|
2170
|
+
var m;
|
|
2171
|
+
const i = (m = n == null ? void 0 : n.find(
|
|
2172
|
+
(F) => F.twapId === e.Contract_id.toString() && Oe(F.twapAddress, e.twapAddress)
|
|
2173
|
+
)) == null ? void 0 : m.status, d = yt(t).reduce((F, C) => F.plus(C.inAmount), new x(0)).toFixed(), b = bt(e.ask_srcAmount, d);
|
|
2174
|
+
return lr(b, e.ask_deadline * 1e3, i);
|
|
2175
|
+
}, bt = (e, t) => {
|
|
2454
2176
|
const n = x(e || 0), i = x(t || 0);
|
|
2455
2177
|
if (!n.isFinite() || !i.isFinite() || n.lte(0)) return 0;
|
|
2456
2178
|
const a = i.dividedBy(n).toNumber();
|
|
2457
2179
|
return a >= 1 ? 100 : a <= 0 ? 0 : Number((a * 100).toFixed(2));
|
|
2458
|
-
},
|
|
2459
|
-
const t = x(e.order.witness.output.limit || 0).gt(1), { stop: n, triggerLower: i, triggerUpper: a } = e.order.witness.output, d = x(n || 0).eq(pt),
|
|
2460
|
-
return
|
|
2461
|
-
},
|
|
2180
|
+
}, lr = (e, t, n) => e === 100 ? ce.Completed : n === "CANCELLED" ? ce.Cancelled : n === "COMPLETED" ? ce.Completed : t > Date.now() ? ce.Open : ce.Expired, fr = (e) => {
|
|
2181
|
+
const t = x(e.order.witness.output.limit || 0).gt(1), { stop: n, triggerLower: i, triggerUpper: a } = e.order.witness.output, d = x(n || 0).eq(pt), b = d || x(a || 0).gt(0), m = !d && x(n || 0).gt(0) || x(i || 0).gt(0), F = x(e.order.witness.input.amount), C = e.metadata.expectedChunks || (F.gt(0) ? x(e.order.witness.input.maxAmount).div(F).toNumber() : 1);
|
|
2182
|
+
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;
|
|
2183
|
+
}, pr = (e) => {
|
|
2462
2184
|
var a;
|
|
2463
2185
|
const t = ((a = e.metadata.chunks) == null ? void 0 : a.filter((d) => d.status === "success").length) || 0, n = e.metadata.expectedChunks || 0;
|
|
2464
2186
|
if (!n) return 0;
|
|
2465
2187
|
const i = x(t).dividedBy(n).toNumber();
|
|
2466
2188
|
return t >= n ? 100 : i <= 0 ? 0 : Number((i * 100).toFixed(2));
|
|
2467
|
-
},
|
|
2189
|
+
}, Ar = (e, t) => {
|
|
2468
2190
|
var a;
|
|
2469
2191
|
const n = (e.metadata.status || "").toLowerCase(), i = (a = e.metadata.description) == null ? void 0 : a.toLowerCase();
|
|
2470
2192
|
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
|
-
},
|
|
2193
|
+
}, yr = (e) => {
|
|
2472
2194
|
var n;
|
|
2473
2195
|
return (((n = e.metadata.chunks) == null ? void 0 : n.filter((i) => i.status === "success")) || []).map((i) => ({
|
|
2474
2196
|
inAmount: i.inAmount,
|
|
@@ -2476,28 +2198,28 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2476
2198
|
timestamp: new Date(i.timestamp).getTime(),
|
|
2477
2199
|
txHash: i.txHash
|
|
2478
2200
|
})).sort((i, a) => i.timestamp - a.timestamp);
|
|
2479
|
-
},
|
|
2201
|
+
}, Er = (e, t) => e.length >= t ? e.reduce(
|
|
2480
2202
|
(i, a) => Math.max(i, a.timestamp),
|
|
2481
2203
|
0
|
|
2482
|
-
) : 0,
|
|
2204
|
+
) : 0, br = (e) => {
|
|
2483
2205
|
const t = x(e.metadata.displayOnlyInputTokenPriceUSD || 0);
|
|
2484
2206
|
return t.isFinite() ? t.dividedBy(1e18).toFixed() : "0";
|
|
2485
|
-
}, Ze = (e) => x(e.order.witness.output.limit || 0).eq(1) ? "" : e.order.witness.output.limit,
|
|
2207
|
+
}, Ze = (e) => x(e.order.witness.output.limit || 0).eq(1) ? "" : e.order.witness.output.limit, mr = (e) => {
|
|
2486
2208
|
const { triggerLower: t = "0", triggerUpper: n = "0" } = e.order.witness.output, i = Ze(e), a = e.metadata.expectedChunks || 1, d = x(n || 0).gt(0);
|
|
2487
2209
|
return {
|
|
2488
2210
|
dstMinAmountPerTrade: i,
|
|
2489
2211
|
triggerPricePerTrade: d ? n : t,
|
|
2490
2212
|
dstMinAmountTotal: i ? x(i).multipliedBy(a).toFixed() : ""
|
|
2491
2213
|
};
|
|
2492
|
-
},
|
|
2214
|
+
}, hr = (e) => {
|
|
2493
2215
|
const t = Ze(e), n = x(e.order.witness.output.stop || 0).eq(pt), i = e.metadata.expectedChunks || 1;
|
|
2494
2216
|
return {
|
|
2495
2217
|
dstMinAmountPerTrade: n ? "" : t,
|
|
2496
2218
|
triggerPricePerTrade: n ? t : x(e.order.witness.output.stop || 0).toFixed(),
|
|
2497
2219
|
dstMinAmountTotal: n || !t ? "" : x(t).multipliedBy(i).toFixed()
|
|
2498
2220
|
};
|
|
2499
|
-
},
|
|
2500
|
-
const t =
|
|
2221
|
+
}, xr = (e) => Number(Xe) >= 2 ? mr(e) : hr(e), mt = (e) => {
|
|
2222
|
+
const t = pr(e), n = Ze(e), i = e.metadata.expectedChunks || 1, a = yr(e), d = fr(e);
|
|
2501
2223
|
return {
|
|
2502
2224
|
id: e.hash,
|
|
2503
2225
|
hash: e.hash,
|
|
@@ -2506,12 +2228,12 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2506
2228
|
type: d,
|
|
2507
2229
|
maker: e.order.witness.swapper,
|
|
2508
2230
|
progress: t,
|
|
2509
|
-
srcAmountFilled: a.reduce((
|
|
2510
|
-
dstAmountFilled: a.reduce((
|
|
2231
|
+
srcAmountFilled: a.reduce((b, m) => b.plus(m.inAmount), new x(0)).toFixed() || "",
|
|
2232
|
+
dstAmountFilled: a.reduce((b, m) => b.plus(m.outAmount), new x(0)).toFixed() || "",
|
|
2511
2233
|
fills: a,
|
|
2512
2234
|
srcTokenAddress: e.order.witness.input.token,
|
|
2513
2235
|
dstTokenAddress: e.order.witness.output.token,
|
|
2514
|
-
orderDollarValueIn:
|
|
2236
|
+
orderDollarValueIn: br(e),
|
|
2515
2237
|
fillDelay: e.order.witness.epoch * 1e3,
|
|
2516
2238
|
deadline: Number(e.order.deadline) * 1e3,
|
|
2517
2239
|
createdAt: new Date(e.timestamp).getTime(),
|
|
@@ -2520,18 +2242,18 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2520
2242
|
totalTradesAmount: i,
|
|
2521
2243
|
isMarketPrice: x(n || 0).lte(1),
|
|
2522
2244
|
chainId: e.order.witness.chainid,
|
|
2523
|
-
filledOrderTimestamp:
|
|
2524
|
-
status:
|
|
2245
|
+
filledOrderTimestamp: Er(a, i),
|
|
2246
|
+
status: Ar(e, t),
|
|
2525
2247
|
repermitDigest: e.metadata.repermitDigest,
|
|
2526
2248
|
isTriggerPrice: d === N.TAKE_PROFIT_MARKET || d === N.TAKE_PROFIT_LIMIT || d === N.STOP_LOSS_LIMIT || d === N.STOP_LOSS_MARKET,
|
|
2527
2249
|
rawOrder: e,
|
|
2528
|
-
...
|
|
2250
|
+
...xr(e)
|
|
2529
2251
|
};
|
|
2530
|
-
},
|
|
2252
|
+
}, Tr = (e, t) => {
|
|
2531
2253
|
e !== 0 && console.warn(
|
|
2532
2254
|
`Skipped ${e} invalid order history ${e === 1 ? "item" : "items"} from ${t}`
|
|
2533
2255
|
);
|
|
2534
|
-
},
|
|
2256
|
+
}, gr = (e, t) => {
|
|
2535
2257
|
if (!e || typeof e != "object" || !Array.isArray(e.orders))
|
|
2536
2258
|
throw new Error("Invalid order history response: missing orders array");
|
|
2537
2259
|
const n = Number(
|
|
@@ -2541,195 +2263,474 @@ const pr = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
2541
2263
|
orders: e.orders,
|
|
2542
2264
|
totalPages: i
|
|
2543
2265
|
};
|
|
2544
|
-
},
|
|
2266
|
+
}, st = async ({
|
|
2545
2267
|
endpoint: e,
|
|
2546
2268
|
chainId: t,
|
|
2547
2269
|
signal: n,
|
|
2548
2270
|
account: i,
|
|
2549
2271
|
exchange: a,
|
|
2550
2272
|
page: d,
|
|
2551
|
-
limit:
|
|
2273
|
+
limit: b
|
|
2552
2274
|
}) => {
|
|
2553
|
-
const
|
|
2275
|
+
const m = new URLSearchParams({
|
|
2554
2276
|
swapper: i,
|
|
2555
2277
|
chainId: t.toString(),
|
|
2556
2278
|
page: d.toString()
|
|
2557
2279
|
});
|
|
2558
|
-
a &&
|
|
2559
|
-
const
|
|
2560
|
-
if (!
|
|
2280
|
+
a && m.set("exchange", a), b !== void 0 && m.set("limit", b.toString());
|
|
2281
|
+
const F = await fetch(`${e}/orders?${m}`, { signal: n });
|
|
2282
|
+
if (!F.ok)
|
|
2561
2283
|
throw new Error(
|
|
2562
|
-
`Failed to fetch order history from ${e}: ${
|
|
2284
|
+
`Failed to fetch order history from ${e}: ${F.status}`
|
|
2563
2285
|
);
|
|
2564
|
-
const C =
|
|
2286
|
+
const C = gr(await F.json(), d);
|
|
2565
2287
|
let O = 0;
|
|
2566
|
-
const
|
|
2288
|
+
const T = C.orders.flatMap((g) => {
|
|
2567
2289
|
try {
|
|
2568
|
-
return [
|
|
2290
|
+
return [mt(g)];
|
|
2569
2291
|
} catch {
|
|
2570
2292
|
return O++, [];
|
|
2571
2293
|
}
|
|
2572
2294
|
});
|
|
2573
|
-
return
|
|
2574
|
-
},
|
|
2295
|
+
return Tr(O, e), { orders: T, totalPages: C.totalPages ?? d };
|
|
2296
|
+
}, Dr = async ({
|
|
2575
2297
|
endpoint: e,
|
|
2576
2298
|
chainId: t,
|
|
2577
2299
|
signal: n,
|
|
2578
2300
|
account: i,
|
|
2579
2301
|
exchange: a,
|
|
2580
2302
|
page: d,
|
|
2581
|
-
limit:
|
|
2303
|
+
limit: b
|
|
2582
2304
|
}) => {
|
|
2583
|
-
const
|
|
2305
|
+
const m = d === void 0 ? 1 : d + 1, F = await st({
|
|
2584
2306
|
endpoint: e,
|
|
2585
2307
|
chainId: t,
|
|
2586
2308
|
signal: n,
|
|
2587
2309
|
account: i,
|
|
2588
2310
|
exchange: a,
|
|
2589
|
-
page:
|
|
2590
|
-
limit:
|
|
2311
|
+
page: m,
|
|
2312
|
+
limit: b
|
|
2591
2313
|
});
|
|
2592
|
-
if (d !== void 0 ||
|
|
2593
|
-
return
|
|
2314
|
+
if (d !== void 0 || m >= F.totalPages)
|
|
2315
|
+
return F.orders;
|
|
2594
2316
|
const C = Array.from(
|
|
2595
|
-
{ length:
|
|
2596
|
-
(
|
|
2317
|
+
{ length: F.totalPages - m },
|
|
2318
|
+
(T, g) => m + g + 1
|
|
2597
2319
|
), O = await Promise.all(
|
|
2598
2320
|
C.map(
|
|
2599
|
-
(
|
|
2321
|
+
(T) => st({
|
|
2600
2322
|
endpoint: e,
|
|
2601
2323
|
chainId: t,
|
|
2602
2324
|
signal: n,
|
|
2603
2325
|
account: i,
|
|
2604
2326
|
exchange: a,
|
|
2605
|
-
page:
|
|
2606
|
-
limit:
|
|
2327
|
+
page: T,
|
|
2328
|
+
limit: b
|
|
2607
2329
|
})
|
|
2608
2330
|
)
|
|
2609
2331
|
);
|
|
2610
2332
|
return [
|
|
2611
|
-
...
|
|
2612
|
-
...O.flatMap((
|
|
2333
|
+
...F.orders,
|
|
2334
|
+
...O.flatMap((T) => T.orders)
|
|
2613
2335
|
];
|
|
2614
|
-
},
|
|
2336
|
+
}, Fr = (e, t, n) => {
|
|
2615
2337
|
const i = /* @__PURE__ */ new Map();
|
|
2616
2338
|
for (const a of e) {
|
|
2617
|
-
const d =
|
|
2618
|
-
for (const
|
|
2619
|
-
const
|
|
2620
|
-
exchange:
|
|
2339
|
+
const d = Jn({ endpoint: a, exchange: t, partner: n }), b = d.length ? d : [void 0];
|
|
2340
|
+
for (const m of b) {
|
|
2341
|
+
const F = (m == null ? void 0 : m.toLowerCase()) ?? "all", C = i.get(F) ?? {
|
|
2342
|
+
exchange: m,
|
|
2621
2343
|
endpoints: []
|
|
2622
2344
|
};
|
|
2623
|
-
C.endpoints.push(a), i.set(
|
|
2345
|
+
C.endpoints.push(a), i.set(F, C);
|
|
2624
2346
|
}
|
|
2625
2347
|
}
|
|
2626
2348
|
return Array.from(i.values());
|
|
2627
|
-
},
|
|
2349
|
+
}, ot = () => {
|
|
2628
2350
|
const e = new Error("Order history request aborted");
|
|
2629
2351
|
throw e.name = "AbortError", e;
|
|
2630
|
-
},
|
|
2352
|
+
}, Cr = async ({
|
|
2631
2353
|
chainId: e,
|
|
2632
2354
|
signal: t,
|
|
2633
2355
|
account: n,
|
|
2634
2356
|
exchange: i,
|
|
2635
2357
|
partner: a,
|
|
2636
2358
|
page: d,
|
|
2637
|
-
limit:
|
|
2359
|
+
limit: b
|
|
2638
2360
|
}) => {
|
|
2639
2361
|
if (!n) return [];
|
|
2640
|
-
const
|
|
2641
|
-
|
|
2362
|
+
const m = Fr(
|
|
2363
|
+
Zn(),
|
|
2642
2364
|
i,
|
|
2643
2365
|
a
|
|
2644
|
-
),
|
|
2645
|
-
|
|
2646
|
-
const
|
|
2647
|
-
|
|
2648
|
-
(
|
|
2649
|
-
endpoint:
|
|
2366
|
+
), F = await Promise.allSettled(
|
|
2367
|
+
m.map(async (T) => {
|
|
2368
|
+
const g = await Promise.allSettled(
|
|
2369
|
+
T.endpoints.map(
|
|
2370
|
+
(P) => Dr({
|
|
2371
|
+
endpoint: P,
|
|
2650
2372
|
chainId: e,
|
|
2651
2373
|
signal: t,
|
|
2652
2374
|
account: n,
|
|
2653
|
-
exchange:
|
|
2375
|
+
exchange: T.exchange,
|
|
2654
2376
|
page: d,
|
|
2655
|
-
limit:
|
|
2377
|
+
limit: b
|
|
2656
2378
|
})
|
|
2657
2379
|
)
|
|
2658
2380
|
);
|
|
2659
|
-
t != null && t.aborted &&
|
|
2660
|
-
const
|
|
2661
|
-
(
|
|
2381
|
+
t != null && t.aborted && ot();
|
|
2382
|
+
const B = g.filter(
|
|
2383
|
+
(P) => P.status === "fulfilled"
|
|
2662
2384
|
);
|
|
2663
|
-
if (!
|
|
2664
|
-
const
|
|
2385
|
+
if (!B.length) {
|
|
2386
|
+
const P = g.find(
|
|
2665
2387
|
(V) => V.status === "rejected"
|
|
2666
2388
|
);
|
|
2667
|
-
throw (
|
|
2389
|
+
throw (P == null ? void 0 : P.reason) instanceof Error ? P.reason : new Error("Failed to fetch order history");
|
|
2668
2390
|
}
|
|
2669
|
-
return
|
|
2391
|
+
return B.flatMap((P) => P.value);
|
|
2670
2392
|
})
|
|
2671
2393
|
);
|
|
2672
|
-
t != null && t.aborted &&
|
|
2673
|
-
const C =
|
|
2674
|
-
(
|
|
2394
|
+
t != null && t.aborted && ot();
|
|
2395
|
+
const C = F.filter(
|
|
2396
|
+
(T) => T.status === "fulfilled"
|
|
2675
2397
|
);
|
|
2676
2398
|
if (!C.length) {
|
|
2677
|
-
const
|
|
2678
|
-
(
|
|
2399
|
+
const T = F.find(
|
|
2400
|
+
(g) => g.status === "rejected"
|
|
2679
2401
|
);
|
|
2680
|
-
throw (
|
|
2402
|
+
throw (T == null ? void 0 : T.reason) instanceof Error ? T.reason : new Error("Failed to fetch order history");
|
|
2681
2403
|
}
|
|
2682
2404
|
const O = /* @__PURE__ */ new Map();
|
|
2683
|
-
for (const
|
|
2684
|
-
O.has(
|
|
2405
|
+
for (const T of C.flatMap((g) => g.value))
|
|
2406
|
+
O.has(T.historyKey) || O.set(T.historyKey, T);
|
|
2685
2407
|
return Array.from(O.values());
|
|
2686
|
-
},
|
|
2408
|
+
}, Br = (e, t) => {
|
|
2687
2409
|
if (e !== void 0 && (!Number.isInteger(e) || e < 0))
|
|
2688
2410
|
throw new Error("Order history page must be a non-negative integer");
|
|
2689
2411
|
if (t !== void 0 && (!Number.isInteger(t) || t <= 0))
|
|
2690
2412
|
throw new Error("Order history limit must be a positive integer");
|
|
2691
|
-
},
|
|
2413
|
+
}, wr = async ({
|
|
2692
2414
|
signal: e,
|
|
2693
2415
|
page: t,
|
|
2694
2416
|
chainId: n,
|
|
2695
2417
|
limit: i,
|
|
2696
2418
|
exchange: a,
|
|
2697
2419
|
partner: d,
|
|
2698
|
-
account:
|
|
2699
|
-
legacyOrders:
|
|
2420
|
+
account: b,
|
|
2421
|
+
legacyOrders: m = !0
|
|
2700
2422
|
}) => {
|
|
2701
|
-
|
|
2702
|
-
const
|
|
2423
|
+
Br(t, i);
|
|
2424
|
+
const F = ln(d, n);
|
|
2703
2425
|
return (await Promise.all([
|
|
2704
|
-
!
|
|
2426
|
+
!F || !m ? Promise.resolve([]) : cr({
|
|
2705
2427
|
chainId: n,
|
|
2706
2428
|
signal: e,
|
|
2707
2429
|
page: t,
|
|
2708
2430
|
limit: i,
|
|
2709
2431
|
filters: {
|
|
2710
|
-
accounts: [
|
|
2711
|
-
configs: [
|
|
2432
|
+
accounts: [b],
|
|
2433
|
+
configs: [F]
|
|
2712
2434
|
}
|
|
2713
2435
|
}),
|
|
2714
|
-
|
|
2436
|
+
Cr({
|
|
2715
2437
|
chainId: n,
|
|
2716
2438
|
signal: e,
|
|
2717
|
-
account:
|
|
2439
|
+
account: b,
|
|
2718
2440
|
exchange: a,
|
|
2719
2441
|
partner: d,
|
|
2720
2442
|
page: t,
|
|
2721
2443
|
limit: i
|
|
2722
2444
|
})
|
|
2723
|
-
]).then(([
|
|
2724
|
-
},
|
|
2445
|
+
]).then(([T, g]) => [...T, ...g])).sort((T, g) => g.createdAt - T.createdAt);
|
|
2446
|
+
}, Sr = 0.7, Pr = `https://bi.orbs.network/putes/twap-ui-${Sr}`;
|
|
2447
|
+
let Se = "unknown";
|
|
2448
|
+
function Xr(e) {
|
|
2449
|
+
Se = e;
|
|
2450
|
+
}
|
|
2451
|
+
function Be() {
|
|
2452
|
+
const e = Math.random().toString(36).substring(2, 16), t = Math.random().toString(36).substring(2, 16), n = Date.now().toString(36);
|
|
2453
|
+
return `id_${e + t + n}`;
|
|
2454
|
+
}
|
|
2455
|
+
const Or = (e, t, n) => ({
|
|
2456
|
+
spotVersion: _e.version,
|
|
2457
|
+
partner: e,
|
|
2458
|
+
chainId: n || 0,
|
|
2459
|
+
minChunkSizeUsd: t
|
|
2460
|
+
}), kr = (e, t, n, i) => {
|
|
2461
|
+
const { witness: a } = e.order, d = Ge.config(
|
|
2462
|
+
e.domain.chainId,
|
|
2463
|
+
t
|
|
2464
|
+
);
|
|
2465
|
+
return {
|
|
2466
|
+
spotVersion: _e.version,
|
|
2467
|
+
partner: t,
|
|
2468
|
+
cosigner: d == null ? void 0 : d.cosigner,
|
|
2469
|
+
fee: d == null ? void 0 : d.fee,
|
|
2470
|
+
refinery: d == null ? void 0 : d.refinery,
|
|
2471
|
+
router: d == null ? void 0 : d.router,
|
|
2472
|
+
type: d == null ? void 0 : d.type,
|
|
2473
|
+
wm: d == null ? void 0 : d.wm,
|
|
2474
|
+
adapter: a.exchange.adapter,
|
|
2475
|
+
executor: a.executor,
|
|
2476
|
+
reactor: a.reactor,
|
|
2477
|
+
repermit: e.domain.verifyingContract,
|
|
2478
|
+
chainId: e.domain.chainId,
|
|
2479
|
+
chainName: (n == null ? void 0 : n.chainName) || "",
|
|
2480
|
+
twapVersion: (n == null ? void 0 : n.twapVersion) || 0,
|
|
2481
|
+
twapAddress: (n == null ? void 0 : n.twapAddress) || "",
|
|
2482
|
+
lensAddress: (n == null ? void 0 : n.lensAddress) || "",
|
|
2483
|
+
bidDelaySeconds: (n == null ? void 0 : n.bidDelaySeconds) || 0,
|
|
2484
|
+
minChunkSizeUsd: i || 0,
|
|
2485
|
+
name: (n == null ? void 0 : n.name) || "",
|
|
2486
|
+
exchangeAddress: (n == null ? void 0 : n.exchangeAddress) || "",
|
|
2487
|
+
exchangeType: (n == null ? void 0 : n.exchangeType) || "",
|
|
2488
|
+
pathfinderKey: (n == null ? void 0 : n.pathfinderKey) || ""
|
|
2489
|
+
};
|
|
2490
|
+
}, we = async (e) => {
|
|
2491
|
+
try {
|
|
2492
|
+
await fetch(Pr, {
|
|
2493
|
+
method: "POST",
|
|
2494
|
+
headers: {
|
|
2495
|
+
Accept: "application/json",
|
|
2496
|
+
"Content-Type": "application/json"
|
|
2497
|
+
},
|
|
2498
|
+
body: JSON.stringify(e)
|
|
2499
|
+
}).then();
|
|
2500
|
+
} catch (t) {
|
|
2501
|
+
console.error("Failed to send BI", t);
|
|
2502
|
+
}
|
|
2503
|
+
}, dt = (e) => {
|
|
2504
|
+
try {
|
|
2505
|
+
if (typeof e == "string" && e.trim())
|
|
2506
|
+
return e.toLowerCase();
|
|
2507
|
+
if (typeof e == "object" && e !== null) {
|
|
2508
|
+
const t = Reflect.get(e, "message");
|
|
2509
|
+
if (typeof t == "string" && t.trim())
|
|
2510
|
+
return t.toLowerCase();
|
|
2511
|
+
const n = Reflect.get(e, "code");
|
|
2512
|
+
if (typeof n == "string" || typeof n == "number")
|
|
2513
|
+
return String(n).toLowerCase();
|
|
2514
|
+
}
|
|
2515
|
+
} catch {
|
|
2516
|
+
}
|
|
2517
|
+
return "unknown error";
|
|
2518
|
+
};
|
|
2519
|
+
class _r {
|
|
2520
|
+
constructor() {
|
|
2521
|
+
Ee(this, "timeout");
|
|
2522
|
+
Ee(this, "configDetails", {});
|
|
2523
|
+
Ee(this, "configUpdateKey", "");
|
|
2524
|
+
Ee(this, "moduleImportKey", "");
|
|
2525
|
+
Ee(this, "data", {
|
|
2526
|
+
_id: Be()
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
async updateAndSend(t = {}, n = !1, i) {
|
|
2530
|
+
try {
|
|
2531
|
+
this.data = {
|
|
2532
|
+
...this.data,
|
|
2533
|
+
...t
|
|
2534
|
+
}, n ? (await we(this.data), i == null || i()) : (clearTimeout(this.timeout), this.timeout = setTimeout(() => {
|
|
2535
|
+
we(this.data), i == null || i();
|
|
2536
|
+
}, 1e3));
|
|
2537
|
+
} catch (a) {
|
|
2538
|
+
console.error("Failed to update and send BI", a);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
onCancelOrderRequest(t, n) {
|
|
2542
|
+
this.updateAndSend({
|
|
2543
|
+
cancelOrderIdsV1: n === 1 ? t : void 0,
|
|
2544
|
+
cancelOrderIdsV2: n === 2 ? t : void 0,
|
|
2545
|
+
action: "cancel order",
|
|
2546
|
+
cancelOrderSuccess: !1,
|
|
2547
|
+
cancelOrderTxHash: void 0,
|
|
2548
|
+
actionError: void 0
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
onCancelOrderSuccess(t) {
|
|
2552
|
+
this.updateAndSend({
|
|
2553
|
+
cancelOrderTxHash: t,
|
|
2554
|
+
cancelOrderSuccess: !0
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
onCancelOrderError(t) {
|
|
2558
|
+
this.onTxError(t);
|
|
2559
|
+
}
|
|
2560
|
+
onWrapSuccess(t) {
|
|
2561
|
+
this.updateAndSend({
|
|
2562
|
+
wrapTxHash: t
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
onWrapRequest() {
|
|
2566
|
+
this.updateAndSend({
|
|
2567
|
+
action: "wrap"
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
onWrapError(t) {
|
|
2571
|
+
this.onTxError(t);
|
|
2572
|
+
}
|
|
2573
|
+
onApproveRequest() {
|
|
2574
|
+
this.updateAndSend({
|
|
2575
|
+
action: "approve"
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
onApproveSuccess(t) {
|
|
2579
|
+
this.updateAndSend({
|
|
2580
|
+
approvalTxHash: t
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
onApproveError(t) {
|
|
2584
|
+
this.onTxError(t);
|
|
2585
|
+
}
|
|
2586
|
+
onCrash(t) {
|
|
2587
|
+
this.updateAndSend({
|
|
2588
|
+
action: "crash",
|
|
2589
|
+
actionError: dt(t)
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
onTxError(t) {
|
|
2593
|
+
this.updateAndSend({ actionError: dt(t) });
|
|
2594
|
+
}
|
|
2595
|
+
onRequestOrder({
|
|
2596
|
+
account: t,
|
|
2597
|
+
chainId: n,
|
|
2598
|
+
module: i,
|
|
2599
|
+
srcToken: a,
|
|
2600
|
+
dstToken: d,
|
|
2601
|
+
fromTokenAmount: b,
|
|
2602
|
+
srcChunkAmount: m,
|
|
2603
|
+
minDstAmountOutPerTrade: F = "",
|
|
2604
|
+
triggerPricePerTrade: C = "",
|
|
2605
|
+
deadline: O,
|
|
2606
|
+
fillDelay: T,
|
|
2607
|
+
slippage: g,
|
|
2608
|
+
isMarketOrder: B,
|
|
2609
|
+
chunksAmount: P
|
|
2610
|
+
}) {
|
|
2611
|
+
this.updateAndSend({
|
|
2612
|
+
toTokenAddress: d.address,
|
|
2613
|
+
toTokenSymbol: d.symbol,
|
|
2614
|
+
fromTokenAddress: a.address,
|
|
2615
|
+
fromTokenSymbol: a.symbol,
|
|
2616
|
+
fromTokenAmount: b,
|
|
2617
|
+
chunksAmount: P,
|
|
2618
|
+
srcChunkAmount: m,
|
|
2619
|
+
minDstAmountOutPerTrade: F,
|
|
2620
|
+
triggerPricePerTrade: C,
|
|
2621
|
+
deadline: O,
|
|
2622
|
+
fillDelay: T,
|
|
2623
|
+
slippage: g,
|
|
2624
|
+
chainId: n,
|
|
2625
|
+
walletAddress: t,
|
|
2626
|
+
module: i,
|
|
2627
|
+
orderType: B ? "market" : "limit",
|
|
2628
|
+
actionError: void 0
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
onSignOrderRequest(t) {
|
|
2632
|
+
this.updateAndSend({
|
|
2633
|
+
action: "sign order"
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
onSignOrderError(t) {
|
|
2637
|
+
this.onTxError(t);
|
|
2638
|
+
}
|
|
2639
|
+
onSignOrderSuccess(t) {
|
|
2640
|
+
this.updateAndSend({
|
|
2641
|
+
action: "sign order"
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
init(t, n, i, a) {
|
|
2645
|
+
const d = `${t}:${i || 0}:${a || ""}`;
|
|
2646
|
+
if (d !== this.moduleImportKey) {
|
|
2647
|
+
this.moduleImportKey = d;
|
|
2648
|
+
const b = {
|
|
2649
|
+
_id: Be(),
|
|
2650
|
+
action: "module-import",
|
|
2651
|
+
uiVersion: Se,
|
|
2652
|
+
appId: a,
|
|
2653
|
+
...Or(t, n, i),
|
|
2654
|
+
origin: window.location.origin
|
|
2655
|
+
};
|
|
2656
|
+
this.configDetails.partner === t && this.configDetails.chainId === (i || 0) || (this.configDetails = {}), this.data = { ...b, ...this.configDetails }, we(b);
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
onFetchedConfig(t, n, i, a) {
|
|
2660
|
+
const d = kr(
|
|
2661
|
+
t,
|
|
2662
|
+
n,
|
|
2663
|
+
i,
|
|
2664
|
+
a
|
|
2665
|
+
), b = `${n}:${d.chainId}:${d.repermit}:${d.adapter}:${d.executor}:${d.reactor}`;
|
|
2666
|
+
b !== this.configUpdateKey && (this.configUpdateKey = b, this.configDetails = d, this.data = { ...this.data, ...d }, we({
|
|
2667
|
+
_id: Be(),
|
|
2668
|
+
action: "config-update",
|
|
2669
|
+
uiVersion: Se,
|
|
2670
|
+
appId: this.data.appId,
|
|
2671
|
+
origin: typeof window > "u" ? void 0 : window.location.origin,
|
|
2672
|
+
...d
|
|
2673
|
+
}));
|
|
2674
|
+
}
|
|
2675
|
+
onCreateOrderError(t) {
|
|
2676
|
+
this.onTxError(t);
|
|
2677
|
+
}
|
|
2678
|
+
onCreateOrderRequest() {
|
|
2679
|
+
this.updateAndSend({
|
|
2680
|
+
action: "create order"
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2683
|
+
async onCreateOrderSuccess(t) {
|
|
2684
|
+
this.updateAndSend(
|
|
2685
|
+
{
|
|
2686
|
+
orderHash: t,
|
|
2687
|
+
orderSuccess: !0
|
|
2688
|
+
},
|
|
2689
|
+
void 0,
|
|
2690
|
+
() => {
|
|
2691
|
+
this.data = {
|
|
2692
|
+
_id: Be(),
|
|
2693
|
+
action: "reset",
|
|
2694
|
+
uiVersion: Se,
|
|
2695
|
+
appId: this.data.appId,
|
|
2696
|
+
origin: this.data.origin,
|
|
2697
|
+
spotVersion: _e.version,
|
|
2698
|
+
partner: this.data.partner,
|
|
2699
|
+
adapter: this.data.adapter,
|
|
2700
|
+
cosigner: this.data.cosigner,
|
|
2701
|
+
executor: this.data.executor,
|
|
2702
|
+
fee: this.data.fee,
|
|
2703
|
+
reactor: this.data.reactor,
|
|
2704
|
+
refinery: this.data.refinery,
|
|
2705
|
+
repermit: this.data.repermit,
|
|
2706
|
+
router: this.data.router,
|
|
2707
|
+
type: this.data.type,
|
|
2708
|
+
wm: this.data.wm,
|
|
2709
|
+
chainName: this.data.chainName || "",
|
|
2710
|
+
chainId: this.data.chainId || 0,
|
|
2711
|
+
twapVersion: this.data.twapVersion || 0,
|
|
2712
|
+
twapAddress: this.data.twapAddress || "",
|
|
2713
|
+
lensAddress: this.data.lensAddress || "",
|
|
2714
|
+
bidDelaySeconds: this.data.bidDelaySeconds || 0,
|
|
2715
|
+
minChunkSizeUsd: this.data.minChunkSizeUsd || 0,
|
|
2716
|
+
name: this.data.name || "",
|
|
2717
|
+
exchangeAddress: this.data.exchangeAddress || "",
|
|
2718
|
+
exchangeType: this.data.exchangeType || "",
|
|
2719
|
+
pathfinderKey: this.data.pathfinderKey || ""
|
|
2720
|
+
};
|
|
2721
|
+
}
|
|
2722
|
+
);
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
const $e = new _r(), vr = async (e, t) => {
|
|
2725
2726
|
try {
|
|
2726
2727
|
const n = {
|
|
2727
2728
|
signature: t,
|
|
2728
2729
|
order: e,
|
|
2729
2730
|
status: "pending"
|
|
2730
2731
|
};
|
|
2731
|
-
|
|
2732
|
-
const i = await fetch(`${
|
|
2732
|
+
$e.onCreateOrderRequest();
|
|
2733
|
+
const i = await fetch(`${Hn()}/orders/new`, {
|
|
2733
2734
|
method: "POST",
|
|
2734
2735
|
headers: {
|
|
2735
2736
|
"Content-Type": "application/json",
|
|
@@ -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 $e.onCreateOrderSuccess(d.id), d;
|
|
2748
2749
|
} catch (n) {
|
|
2749
|
-
throw
|
|
2750
|
+
throw $e.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,94 +2776,85 @@ 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) => {
|
|
2782
2783
|
Rr(e, t);
|
|
2783
|
-
const n = await
|
|
2784
|
+
const n = await er(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 = (T) => (d = Math.max(T, d + 1), d.toString());
|
|
2788
2789
|
return Object.freeze({
|
|
2789
2790
|
partner: e,
|
|
2790
2791
|
chainId: t,
|
|
2791
2792
|
rePermitData: n,
|
|
2792
2793
|
spenderAddress: i,
|
|
2793
2794
|
exchangeAddress: a,
|
|
2794
|
-
prepareOrder: (
|
|
2795
|
-
const { form:
|
|
2796
|
-
if (!
|
|
2795
|
+
prepareOrder: (T) => {
|
|
2796
|
+
const { form: g } = T;
|
|
2797
|
+
if (!g.canSubmit)
|
|
2797
2798
|
throw new Error("Order form is not submittable");
|
|
2798
|
-
if (pn(
|
|
2799
|
+
if (pn(T.inputTokenAddress))
|
|
2799
2800
|
throw new Error(
|
|
2800
2801
|
"prepareOrder inputTokenAddress must be an ERC-20 address; pass the host-provided wrapped native token for native input"
|
|
2801
2802
|
);
|
|
2802
|
-
const B =
|
|
2803
|
+
const B = g.values, P = Date.now(), V = {
|
|
2803
2804
|
...B,
|
|
2804
|
-
currentTimeMillis:
|
|
2805
|
-
deadlineMillis: Ir(
|
|
2806
|
-
},
|
|
2807
|
-
inputTokenAddress:
|
|
2808
|
-
outputTokenAddress:
|
|
2805
|
+
currentTimeMillis: P,
|
|
2806
|
+
deadlineMillis: Ir(P, B.duration)
|
|
2807
|
+
}, U = tr({
|
|
2808
|
+
inputTokenAddress: T.inputTokenAddress,
|
|
2809
|
+
outputTokenAddress: T.outputTokenAddress,
|
|
2809
2810
|
totalInputAmount: B.inputAmount,
|
|
2810
|
-
nonce:
|
|
2811
|
-
currentTimeMillis:
|
|
2812
|
-
deadlineMillis:
|
|
2811
|
+
nonce: b(P),
|
|
2812
|
+
currentTimeMillis: V.currentTimeMillis,
|
|
2813
|
+
deadlineMillis: V.deadlineMillis,
|
|
2813
2814
|
fillDelayMillis: B.fillDelayMillis,
|
|
2814
2815
|
totalTrades: B.totalTrades,
|
|
2815
2816
|
slippageBps: B.slippageBps,
|
|
2816
|
-
swapperAddress:
|
|
2817
|
+
swapperAddress: T.swapperAddress,
|
|
2817
2818
|
inputAmountPerTrade: B.inputAmountPerTrade,
|
|
2818
2819
|
minOutputAmountPerTrade: B.minOutputAmountPerTrade,
|
|
2819
2820
|
triggerOutputAmountPerTrade: B.triggerOutputAmountPerTrade,
|
|
2820
2821
|
permitData: n,
|
|
2821
|
-
module:
|
|
2822
|
-
}),
|
|
2822
|
+
module: g.module
|
|
2823
|
+
}), j = U.order;
|
|
2823
2824
|
return {
|
|
2824
|
-
order:
|
|
2825
|
+
order: j,
|
|
2825
2826
|
signingRequest: {
|
|
2826
|
-
signerAddress:
|
|
2827
|
+
signerAddress: T.swapperAddress,
|
|
2827
2828
|
typedData: {
|
|
2828
|
-
domain:
|
|
2829
|
-
types:
|
|
2830
|
-
primaryType:
|
|
2831
|
-
message:
|
|
2829
|
+
domain: U.domain,
|
|
2830
|
+
types: U.types,
|
|
2831
|
+
primaryType: U.primaryType,
|
|
2832
|
+
message: j
|
|
2832
2833
|
}
|
|
2833
2834
|
},
|
|
2834
2835
|
approvalRequest: {
|
|
2835
|
-
tokenAddress:
|
|
2836
|
+
tokenAddress: j.permitted.token,
|
|
2836
2837
|
amount: B.inputAmount,
|
|
2837
2838
|
spenderAddress: i
|
|
2838
2839
|
},
|
|
2839
|
-
form:
|
|
2840
|
-
values:
|
|
2840
|
+
form: g,
|
|
2841
|
+
values: V
|
|
2841
2842
|
};
|
|
2842
2843
|
},
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
return me.onSignOrderSuccess(B), B;
|
|
2848
|
-
} catch (B) {
|
|
2849
|
-
throw me.onSignOrderError(B), B;
|
|
2850
|
-
}
|
|
2851
|
-
},
|
|
2852
|
-
submitOrder: (h, w) => vr(h.order, w),
|
|
2853
|
-
getCancelOrderRequest: (h) => {
|
|
2854
|
-
const w = h.version === 1 ? h.twapAddress : i;
|
|
2855
|
-
if (!w)
|
|
2844
|
+
submitOrder: (T, g) => vr(T.order, g),
|
|
2845
|
+
getCancelOrderRequest: (T) => {
|
|
2846
|
+
const g = T.version === 1 ? T.twapAddress : i;
|
|
2847
|
+
if (!g)
|
|
2856
2848
|
throw new Error("Cancellation contract address is unavailable");
|
|
2857
2849
|
return {
|
|
2858
|
-
order:
|
|
2859
|
-
contractAddress:
|
|
2860
|
-
args:
|
|
2861
|
-
abi:
|
|
2850
|
+
order: T,
|
|
2851
|
+
contractAddress: g,
|
|
2852
|
+
args: T.version === 1 ? [T.id] : [[T.repermitDigest]],
|
|
2853
|
+
abi: T.version === 1 ? jn : zn
|
|
2862
2854
|
};
|
|
2863
2855
|
},
|
|
2864
|
-
getAccountOrders: (
|
|
2865
|
-
...
|
|
2856
|
+
getAccountOrders: (T) => wr({
|
|
2857
|
+
...T,
|
|
2866
2858
|
chainId: t,
|
|
2867
2859
|
exchange: a,
|
|
2868
2860
|
partner: e
|
|
@@ -2877,16 +2869,16 @@ export {
|
|
|
2877
2869
|
Zr as ORBS_SLTP_FAQ_URL,
|
|
2878
2870
|
Yr as ORBS_TWAP_FAQ_URL,
|
|
2879
2871
|
Jr as ORBS_WEBSITE_URL,
|
|
2880
|
-
|
|
2872
|
+
Tt as OrderFilter,
|
|
2881
2873
|
ce as OrderStatus,
|
|
2882
2874
|
N as OrderType,
|
|
2883
2875
|
Q as Partners,
|
|
2884
2876
|
Xe as SPOT_VERSION,
|
|
2885
2877
|
se as TimeUnit,
|
|
2886
|
-
|
|
2878
|
+
$e as analytics,
|
|
2887
2879
|
jr as calculateOrderForm,
|
|
2888
2880
|
Hr as createClient,
|
|
2889
|
-
|
|
2881
|
+
Oe as eqIgnoreCase,
|
|
2890
2882
|
qr as getOrderExecutionRate,
|
|
2891
2883
|
Vr as getOrderFillDelayMillis,
|
|
2892
2884
|
Wr as getOrderLimitPriceRate,
|