@orbs-network/spot-ui 2.1.0 → 2.1.1
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 +68 -69
- package/dist/spot-ui.js +1612 -2260
- package/dist/spot-ui.umd.cjs +8 -8
- package/dist/src/index.d.ts +11 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/analytics.d.ts +10 -12
- package/dist/src/lib/analytics.d.ts.map +1 -1
- package/dist/src/lib/api-config.d.ts +11 -0
- package/dist/src/lib/api-config.d.ts.map +1 -0
- package/dist/src/lib/build-repermit-order-data.d.ts +1 -2
- package/dist/src/lib/build-repermit-order-data.d.ts.map +1 -1
- package/dist/src/lib/client.d.ts +2 -2
- package/dist/src/lib/client.d.ts.map +1 -1
- package/dist/src/lib/evm-constants.d.ts +3 -0
- package/dist/src/lib/evm-constants.d.ts.map +1 -0
- package/dist/src/lib/order-form/amounts.d.ts +13 -0
- package/dist/src/lib/order-form/amounts.d.ts.map +1 -0
- package/dist/src/lib/order-form/calculate-order-form.d.ts +3 -0
- package/dist/src/lib/order-form/calculate-order-form.d.ts.map +1 -0
- package/dist/src/lib/order-form/constants.d.ts +10 -0
- package/dist/src/lib/order-form/constants.d.ts.map +1 -0
- package/dist/src/lib/order-form/prices.d.ts +8 -0
- package/dist/src/lib/order-form/prices.d.ts.map +1 -0
- package/dist/src/lib/order-form/schedule.d.ts +27 -0
- package/dist/src/lib/order-form/schedule.d.ts.map +1 -0
- package/dist/src/lib/order-form/types.d.ts +209 -0
- package/dist/src/lib/order-form/types.d.ts.map +1 -0
- package/dist/src/lib/order-form/validation.d.ts +7 -0
- package/dist/src/lib/order-form/validation.d.ts.map +1 -0
- package/dist/src/lib/order-form/values.d.ts +3 -0
- package/dist/src/lib/order-form/values.d.ts.map +1 -0
- package/dist/src/lib/orders/legacy-twap-config.d.ts +22 -0
- package/dist/src/lib/orders/legacy-twap-config.d.ts.map +1 -0
- package/dist/src/lib/partners.d.ts +3 -0
- package/dist/src/lib/partners.d.ts.map +1 -0
- package/dist/src/lib/public-links.d.ts +6 -0
- package/dist/src/lib/public-links.d.ts.map +1 -0
- package/dist/src/lib/types.d.ts +3 -13
- package/dist/src/lib/types.d.ts.map +1 -1
- package/dist/src/lib/utils.d.ts +1 -28
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/lib/calculations.d.ts +0 -123
- package/dist/src/lib/calculations.d.ts.map +0 -1
- package/dist/src/lib/consts.d.ts +0 -92
- package/dist/src/lib/consts.d.ts.map +0 -1
- package/dist/src/lib/lib.d.ts +0 -66
- package/dist/src/lib/lib.d.ts.map +0 -1
- package/dist/src/lib/networks.d.ts +0 -571
- package/dist/src/lib/networks.d.ts.map +0 -1
- package/dist/src/lib/order-form.d.ts +0 -95
- package/dist/src/lib/order-form.d.ts.map +0 -1
package/dist/spot-ui.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
1
|
+
var ht = Object.defineProperty;
|
|
2
|
+
var Tt = (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) => Tt(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 || {}), xt = /* @__PURE__ */ ((e) => (e.All = "ALL", e.Open = "OPEN", e.Cancelled = "CANCELLED", e.Completed = "COMPLETED", e.Expired = "EXPIRED", e))(xt || {}), se = /* @__PURE__ */ ((e) => (e[e.Minutes = 6e4] = "Minutes", e[e.Hours = 36e5] = "Hours", e[e.Weeks = 6048e5] = "Weeks", e[e.Days = 864e5] = "Days", e[e.Months = 2592e6] = "Months", e[e.Years = 31536e6] = "Years", e))(se || {}), N = /* @__PURE__ */ ((e) => (e.LIMIT = "limit", e.TWAP_LIMIT = "twap-limit", e.TWAP_MARKET = "twap-market", e.TAKE_PROFIT_MARKET = "take-profit-market", e.TAKE_PROFIT_LIMIT = "take-profit-limit", e.STOP_LOSS_LIMIT = "stop-loss-limit", e.STOP_LOSS_MARKET = "stop-loss-market", e))(N || {}), Q = /* @__PURE__ */ ((e) => (e.Arbidex = "arbidex", e.Blackhole = "blackhole", e.Chronos = "chronos", e.Dragon = "dragon", e.Kodiak = "kodiak", e.Lynex = "lynex", e.Nami = "nami", e.Newera = "newera", e.Omni = "omni", e.Pancake = "pancake", e.Quick = "quick", e.Ramses = "ramses", e.Shadow = "shadow", e.Spark = "spark", e.Spooky = "spooky", e.Swapx = "swapx", e.Teafi = "teafi", e.Thena = "thena", e.Yowie = "yowie", e.Pangolin = "pangolin", e.Sushiswap = "sushiswap", e.Agent = "agent", e.Utila = "utila", e.Ring = "ring", e.EfficientFrontier = "ef", e.HtDigital = "ht", e.Ginco = "ginco", e.Katana = "katana", e.Unknown = "unknown", e))(Q || {}), J = /* @__PURE__ */ ((e) => (e.MAX_TRADES = "maxTradesError", e.MIN_TRADES = "minTradesError", e.MIN_TRADE_SIZE = "minTradeSizeError", e.MAX_FILL_DELAY = "maxFillDelayError", e.MIN_FILL_DELAY = "minFillDelayError", e.MAX_ORDER_DURATION = "maxDurationError", e.MIN_ORDER_DURATION = "minDurationError", e.MISSING_LIMIT_PRICE = "missingLimitPrice", e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE = "StopLossTriggerPriceError", e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE = "triggerLimitPriceError", e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE = "TakeProfitTriggerPriceError", e.EMPTY_TRIGGER_PRICE = "emptyTriggerPrice", e.INSUFFICIENT_BALANCE = "insufficientFunds", e.MAX_ORDER_SIZE = "maxOrderSize", e))(J || {}), gt = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, Ne = Math.ceil, ne = Math.floor, Z = "[BigNumber Error] ", Qe = Z + "Number primitive has more than 15 significant digits: ", ae = 1e14, k = 14, Le = 9007199254740991, Ue = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], pe = 1e7, q = 1e9;
|
|
5
5
|
function ut(e) {
|
|
6
|
-
var t, n,
|
|
6
|
+
var t, n, i, a = g.prototype = { constructor: g, toString: null, valueOf: null }, d = new g(1), m = 20, b = 4, D = -7, C = 21, O = -1e7, F = 1e7, h = !1, w = 1, B = 0, V = {
|
|
7
7
|
prefix: "",
|
|
8
8
|
groupSize: 3,
|
|
9
9
|
secondaryGroupSize: 0,
|
|
@@ -13,616 +13,827 @@ function ut(e) {
|
|
|
13
13
|
fractionGroupSeparator: " ",
|
|
14
14
|
// non-breaking space
|
|
15
15
|
suffix: ""
|
|
16
|
-
}, K = "0123456789abcdefghijklmnopqrstuvwxyz",
|
|
17
|
-
function
|
|
18
|
-
var o,
|
|
19
|
-
if (!(
|
|
20
|
-
if (
|
|
16
|
+
}, K = "0123456789abcdefghijklmnopqrstuvwxyz", z = !0;
|
|
17
|
+
function g(r, s) {
|
|
18
|
+
var o, A, u, f, E, c, l, y, p = this;
|
|
19
|
+
if (!(p instanceof g)) return new g(r, s);
|
|
20
|
+
if (s == null) {
|
|
21
21
|
if (r && r._isBigNumber === !0) {
|
|
22
|
-
|
|
22
|
+
p.s = r.s, !r.c || r.e > F ? 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
|
-
if ((
|
|
26
|
-
if (
|
|
27
|
-
for (
|
|
28
|
-
|
|
25
|
+
if ((c = typeof r == "number") && r * 0 == 0) {
|
|
26
|
+
if (p.s = 1 / r < 0 ? (r = -r, -1) : 1, r === ~~r) {
|
|
27
|
+
for (f = 0, E = r; E >= 10; E /= 10, f++) ;
|
|
28
|
+
f > F ? p.c = p.e = null : (p.e = f, p.c = [r]);
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
y = String(r);
|
|
32
32
|
} else {
|
|
33
|
-
if (!
|
|
34
|
-
|
|
33
|
+
if (!gt.test(y = String(r))) return i(p, y, c);
|
|
34
|
+
p.s = y.charCodeAt(0) == 45 ? (y = y.slice(1), -1) : 1;
|
|
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(
|
|
39
|
-
return
|
|
40
|
-
if (
|
|
41
|
-
if (r * 0 != 0) return
|
|
42
|
-
if (
|
|
43
|
-
throw Error(
|
|
38
|
+
if (L(s, 2, K.length, "Base"), s == 10 && z)
|
|
39
|
+
return p = new g(r), Y(p, m + p.e + 1, b);
|
|
40
|
+
if (y = String(r), c = typeof r == "number") {
|
|
41
|
+
if (r * 0 != 0) return i(p, y, c, s);
|
|
42
|
+
if (p.s = 1 / r < 0 ? (y = y.slice(1), -1) : 1, g.DEBUG && y.replace(/^0\.0*|\./, "").length > 15)
|
|
43
|
+
throw Error(Qe + r);
|
|
44
44
|
} else
|
|
45
|
-
|
|
46
|
-
for (o = K.slice(0,
|
|
47
|
-
if (o.indexOf(
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
50
|
-
|
|
45
|
+
p.s = y.charCodeAt(0) === 45 ? (y = y.slice(1), -1) : 1;
|
|
46
|
+
for (o = K.slice(0, s), f = E = 0, l = y.length; E < l; E++)
|
|
47
|
+
if (o.indexOf(A = y.charAt(E)) < 0) {
|
|
48
|
+
if (A == ".") {
|
|
49
|
+
if (E > f) {
|
|
50
|
+
f = l;
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
-
} else if (!
|
|
54
|
-
|
|
53
|
+
} else if (!u && (y == y.toUpperCase() && (y = y.toLowerCase()) || y == y.toLowerCase() && (y = y.toUpperCase()))) {
|
|
54
|
+
u = !0, E = -1, f = 0;
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return i(p, String(r), c, s);
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
c = !1, y = n(y, s, 10, p.s), (f = y.indexOf(".")) > -1 ? y = y.replace(".", "") : f = y.length;
|
|
60
60
|
}
|
|
61
|
-
for (
|
|
62
|
-
for (
|
|
63
|
-
if (
|
|
64
|
-
if (
|
|
65
|
-
throw Error(
|
|
66
|
-
if ((
|
|
67
|
-
|
|
68
|
-
else if (
|
|
69
|
-
|
|
61
|
+
for (E = 0; y.charCodeAt(E) === 48; E++) ;
|
|
62
|
+
for (l = y.length; y.charCodeAt(--l) === 48; ) ;
|
|
63
|
+
if (y = y.slice(E, ++l)) {
|
|
64
|
+
if (l -= E, c && g.DEBUG && l > 15 && (r > Le || r !== ne(r)))
|
|
65
|
+
throw Error(Qe + p.s * r);
|
|
66
|
+
if ((f = f - E - 1) > F)
|
|
67
|
+
p.c = p.e = null;
|
|
68
|
+
else if (f < O)
|
|
69
|
+
p.c = [p.e = 0];
|
|
70
70
|
else {
|
|
71
|
-
if (
|
|
72
|
-
for (
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
if (p.e = f, p.c = [], E = (f + 1) % k, f < 0 && (E += k), E < l) {
|
|
72
|
+
for (E && p.c.push(+y.slice(0, E)), l -= k; E < l; )
|
|
73
|
+
p.c.push(+y.slice(E, E += k));
|
|
74
|
+
E = k - (y = y.slice(E)).length;
|
|
75
75
|
} else
|
|
76
|
-
|
|
77
|
-
for (;
|
|
78
|
-
|
|
76
|
+
E -= l;
|
|
77
|
+
for (; E--; y += "0") ;
|
|
78
|
+
p.c.push(+y);
|
|
79
79
|
}
|
|
80
80
|
} else
|
|
81
|
-
|
|
81
|
+
p.c = [p.e = 0];
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
var
|
|
83
|
+
g.clone = ut, g.ROUND_UP = 0, g.ROUND_DOWN = 1, g.ROUND_CEIL = 2, g.ROUND_FLOOR = 3, g.ROUND_HALF_UP = 4, g.ROUND_HALF_DOWN = 5, g.ROUND_HALF_EVEN = 6, g.ROUND_HALF_CEIL = 7, g.ROUND_HALF_FLOOR = 8, g.EUCLID = 9, g.config = g.set = function(r) {
|
|
84
|
+
var s, o;
|
|
85
85
|
if (r != null)
|
|
86
86
|
if (typeof r == "object") {
|
|
87
|
-
if (r.hasOwnProperty(
|
|
88
|
-
if (o = r[
|
|
89
|
-
L(o[0], -
|
|
90
|
-
else if (L(o, -
|
|
91
|
-
|
|
87
|
+
if (r.hasOwnProperty(s = "DECIMAL_PLACES") && (o = r[s], L(o, 0, q, s), m = o), r.hasOwnProperty(s = "ROUNDING_MODE") && (o = r[s], L(o, 0, 8, s), b = o), r.hasOwnProperty(s = "EXPONENTIAL_AT") && (o = r[s], o && o.pop ? (L(o[0], -q, 0, s), L(o[1], 0, q, s), D = o[0], C = o[1]) : (L(o, -q, q, s), D = -(C = o < 0 ? -o : o))), r.hasOwnProperty(s = "RANGE"))
|
|
88
|
+
if (o = r[s], o && o.pop)
|
|
89
|
+
L(o[0], -q, -1, s), L(o[1], 1, q, s), O = o[0], F = o[1];
|
|
90
|
+
else if (L(o, -q, q, s), o)
|
|
91
|
+
O = -(F = o < 0 ? -o : o);
|
|
92
92
|
else
|
|
93
|
-
throw Error(
|
|
94
|
-
if (r.hasOwnProperty(
|
|
95
|
-
if (o = r[
|
|
93
|
+
throw Error(Z + s + " cannot be zero: " + o);
|
|
94
|
+
if (r.hasOwnProperty(s = "CRYPTO"))
|
|
95
|
+
if (o = r[s], o === !!o)
|
|
96
96
|
if (o)
|
|
97
97
|
if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
|
|
98
|
-
|
|
98
|
+
h = o;
|
|
99
99
|
else
|
|
100
|
-
throw
|
|
100
|
+
throw h = !o, Error(Z + "crypto unavailable");
|
|
101
101
|
else
|
|
102
|
-
|
|
102
|
+
h = o;
|
|
103
103
|
else
|
|
104
|
-
throw Error(
|
|
105
|
-
if (r.hasOwnProperty(
|
|
106
|
-
if (o = r[
|
|
107
|
-
else throw Error(
|
|
108
|
-
if (r.hasOwnProperty(
|
|
109
|
-
if (o = r[
|
|
110
|
-
|
|
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), w = o), r.hasOwnProperty(s = "POW_PRECISION") && (o = r[s], L(o, 0, q, s), B = o), r.hasOwnProperty(s = "FORMAT"))
|
|
106
|
+
if (o = r[s], typeof o == "object") V = o;
|
|
107
|
+
else throw Error(Z + s + " not an object: " + o);
|
|
108
|
+
if (r.hasOwnProperty(s = "ALPHABET"))
|
|
109
|
+
if (o = r[s], typeof o == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(o))
|
|
110
|
+
z = o.slice(0, 10) == "0123456789", K = o;
|
|
111
111
|
else
|
|
112
|
-
throw Error(
|
|
112
|
+
throw Error(Z + s + " invalid: " + o);
|
|
113
113
|
} else
|
|
114
|
-
throw Error(
|
|
114
|
+
throw Error(Z + "Object expected: " + r);
|
|
115
115
|
return {
|
|
116
|
-
DECIMAL_PLACES:
|
|
117
|
-
ROUNDING_MODE:
|
|
116
|
+
DECIMAL_PLACES: m,
|
|
117
|
+
ROUNDING_MODE: b,
|
|
118
118
|
EXPONENTIAL_AT: [D, C],
|
|
119
|
-
RANGE: [
|
|
120
|
-
CRYPTO:
|
|
121
|
-
MODULO_MODE:
|
|
122
|
-
POW_PRECISION:
|
|
123
|
-
FORMAT:
|
|
119
|
+
RANGE: [O, F],
|
|
120
|
+
CRYPTO: h,
|
|
121
|
+
MODULO_MODE: w,
|
|
122
|
+
POW_PRECISION: B,
|
|
123
|
+
FORMAT: V,
|
|
124
124
|
ALPHABET: K
|
|
125
125
|
};
|
|
126
|
-
},
|
|
126
|
+
}, g.isBigNumber = function(r) {
|
|
127
127
|
if (!r || r._isBigNumber !== !0) return !1;
|
|
128
|
-
if (!
|
|
129
|
-
var
|
|
130
|
-
e: if ({}.toString.call(
|
|
131
|
-
if ((
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
128
|
+
if (!g.DEBUG) return !0;
|
|
129
|
+
var s, o, A = r.c, u = r.e, f = r.s;
|
|
130
|
+
e: if ({}.toString.call(A) == "[object Array]") {
|
|
131
|
+
if ((f === 1 || f === -1) && u >= -q && u <= q && u === ne(u)) {
|
|
132
|
+
if (A[0] === 0) {
|
|
133
|
+
if (u === 0 && A.length === 1) return !0;
|
|
134
134
|
break e;
|
|
135
135
|
}
|
|
136
|
-
if (
|
|
137
|
-
for (
|
|
138
|
-
if (o =
|
|
136
|
+
if (s = (u + 1) % k, s < 1 && (s += k), String(A[0]).length == s) {
|
|
137
|
+
for (s = 0; s < A.length; s++)
|
|
138
|
+
if (o = A[s], o < 0 || o >= ae || o !== ne(o)) break e;
|
|
139
139
|
if (o !== 0) return !0;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
} else if (
|
|
142
|
+
} else if (A === null && u === null && (f === null || f === 1 || f === -1))
|
|
143
143
|
return !0;
|
|
144
|
-
throw Error(
|
|
145
|
-
},
|
|
144
|
+
throw Error(Z + "Invalid BigNumber: " + r);
|
|
145
|
+
}, g.maximum = g.max = function() {
|
|
146
146
|
return De(arguments, -1);
|
|
147
|
-
},
|
|
147
|
+
}, g.minimum = g.min = function() {
|
|
148
148
|
return De(arguments, 1);
|
|
149
|
-
},
|
|
150
|
-
var r = 9007199254740992,
|
|
151
|
-
return
|
|
149
|
+
}, g.random = (function() {
|
|
150
|
+
var r = 9007199254740992, s = Math.random() * r & 2097151 ? function() {
|
|
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
|
|
157
|
-
if (o == null ? o =
|
|
156
|
+
var A, u, f, E, c, l = 0, y = [], p = new g(d);
|
|
157
|
+
if (o == null ? o = m : L(o, 0, q), E = Ne(o / k), h)
|
|
158
158
|
if (crypto.getRandomValues) {
|
|
159
|
-
for (
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
for (A = crypto.getRandomValues(new Uint32Array(E *= 2)); l < E; )
|
|
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);
|
|
161
|
+
l = E / 2;
|
|
162
162
|
} else if (crypto.randomBytes) {
|
|
163
|
-
for (
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
for (A = crypto.randomBytes(E *= 7); l < E; )
|
|
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
|
+
l = E / 7;
|
|
166
166
|
} else
|
|
167
|
-
throw
|
|
168
|
-
if (!
|
|
169
|
-
for (;
|
|
170
|
-
|
|
171
|
-
for (
|
|
172
|
-
if (
|
|
173
|
-
|
|
167
|
+
throw h = !1, Error(Z + "crypto unavailable");
|
|
168
|
+
if (!h)
|
|
169
|
+
for (; l < E; )
|
|
170
|
+
c = s(), c < 9e15 && (y[l++] = c % 1e14);
|
|
171
|
+
for (E = y[--l], o %= k, E && o && (c = Ue[k - o], y[l] = ne(E / c) * c); y[l] === 0; y.pop(), l--) ;
|
|
172
|
+
if (l < 0)
|
|
173
|
+
y = [f = 0];
|
|
174
174
|
else {
|
|
175
|
-
for (
|
|
176
|
-
for (
|
|
177
|
-
|
|
175
|
+
for (f = -1; y[0] === 0; y.splice(0, 1), f -= k) ;
|
|
176
|
+
for (l = 1, c = y[0]; c >= 10; c /= 10, l++) ;
|
|
177
|
+
l < k && (f -= k - l);
|
|
178
178
|
}
|
|
179
|
-
return
|
|
179
|
+
return p.e = f, p.c = y, p;
|
|
180
180
|
};
|
|
181
|
-
})(),
|
|
182
|
-
for (var r = 1,
|
|
181
|
+
})(), g.sum = function() {
|
|
182
|
+
for (var r = 1, s = arguments, o = new g(s[0]); r < s.length; ) o = o.plus(s[r++]);
|
|
183
183
|
return o;
|
|
184
184
|
}, n = /* @__PURE__ */ (function() {
|
|
185
185
|
var r = "0123456789";
|
|
186
|
-
function
|
|
187
|
-
for (var
|
|
188
|
-
for (
|
|
189
|
-
for (
|
|
190
|
-
|
|
186
|
+
function s(o, A, u, f) {
|
|
187
|
+
for (var E, c = [0], l, y = 0, p = o.length; y < p; ) {
|
|
188
|
+
for (l = c.length; l--; c[l] *= A) ;
|
|
189
|
+
for (c[0] += f.indexOf(o.charAt(y++)), E = 0; E < c.length; E++)
|
|
190
|
+
c[E] > u - 1 && (c[E + 1] == null && (c[E + 1] = 0), c[E + 1] += c[E] / u | 0, c[E] %= u);
|
|
191
191
|
}
|
|
192
|
-
return
|
|
192
|
+
return c.reverse();
|
|
193
193
|
}
|
|
194
|
-
return function(o,
|
|
195
|
-
var
|
|
196
|
-
for (
|
|
197
|
-
|
|
194
|
+
return function(o, A, u, f, E) {
|
|
195
|
+
var c, l, y, p, T, S, P, R, U = o.indexOf("."), G = m, I = b;
|
|
196
|
+
for (U >= 0 && (p = B, B = 0, o = o.replace(".", ""), R = new g(A), S = R.pow(o.length - U), B = p, R.c = s(
|
|
197
|
+
le(te(S.c), S.e, "0"),
|
|
198
198
|
10,
|
|
199
|
-
|
|
199
|
+
u,
|
|
200
200
|
r
|
|
201
|
-
),
|
|
202
|
-
if (!
|
|
203
|
-
if (
|
|
204
|
-
o =
|
|
201
|
+
), R.e = R.c.length), P = s(o, A, u, E ? (c = K, r) : (c = r, K)), y = p = P.length; P[--p] == 0; P.pop()) ;
|
|
202
|
+
if (!P[0]) return c.charAt(0);
|
|
203
|
+
if (U < 0 ? --y : (S.c = P, S.e = y, S.s = f, S = t(S, R, G, I, u), P = S.c, T = S.r, y = S.e), l = y + G + 1, U = P[l], p = u / 2, T = T || l < 0 || P[l + 1] != null, T = I < 4 ? (U != null || T) && (I == 0 || I == (S.s < 0 ? 3 : 2)) : U > p || U == p && (I == 4 || T || I == 6 && P[l - 1] & 1 || I == (S.s < 0 ? 8 : 7)), l < 1 || !P[0])
|
|
204
|
+
o = T ? le(c.charAt(1), -G, c.charAt(0)) : c.charAt(0);
|
|
205
205
|
else {
|
|
206
|
-
if (
|
|
207
|
-
for (--
|
|
208
|
-
|
|
209
|
-
for (
|
|
210
|
-
for (
|
|
211
|
-
o =
|
|
206
|
+
if (P.length = l, T)
|
|
207
|
+
for (--u; ++P[--l] > u; )
|
|
208
|
+
P[l] = 0, l || (++y, P = [1].concat(P));
|
|
209
|
+
for (p = P.length; !P[--p]; ) ;
|
|
210
|
+
for (U = 0, o = ""; U <= p; o += c.charAt(P[U++])) ;
|
|
211
|
+
o = le(o, y, c.charAt(0));
|
|
212
212
|
}
|
|
213
213
|
return o;
|
|
214
214
|
};
|
|
215
215
|
})(), t = /* @__PURE__ */ (function() {
|
|
216
|
-
function r(
|
|
217
|
-
var
|
|
218
|
-
for (
|
|
219
|
-
|
|
220
|
-
return
|
|
216
|
+
function r(A, u, f) {
|
|
217
|
+
var E, c, l, y, p = 0, T = A.length, S = u % pe, P = u / pe | 0;
|
|
218
|
+
for (A = A.slice(); T--; )
|
|
219
|
+
l = A[T] % pe, y = A[T] / pe | 0, E = P * l + y * S, c = S * l + E % pe * pe + p, p = (c / f | 0) + (E / pe | 0) + P * y, A[T] = c % f;
|
|
220
|
+
return p && (A = [p].concat(A)), A;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
var
|
|
224
|
-
if (
|
|
225
|
-
|
|
222
|
+
function s(A, u, f, E) {
|
|
223
|
+
var c, l;
|
|
224
|
+
if (f != E)
|
|
225
|
+
l = f > E ? 1 : -1;
|
|
226
226
|
else
|
|
227
|
-
for (
|
|
228
|
-
if (
|
|
229
|
-
|
|
227
|
+
for (c = l = 0; c < f; c++)
|
|
228
|
+
if (A[c] != u[c]) {
|
|
229
|
+
l = A[c] > u[c] ? 1 : -1;
|
|
230
230
|
break;
|
|
231
231
|
}
|
|
232
|
-
return
|
|
232
|
+
return l;
|
|
233
233
|
}
|
|
234
|
-
function o(
|
|
235
|
-
for (var
|
|
236
|
-
|
|
237
|
-
for (; !
|
|
234
|
+
function o(A, u, f, E) {
|
|
235
|
+
for (var c = 0; f--; )
|
|
236
|
+
A[f] -= c, c = A[f] < u[f] ? 1 : 0, A[f] = c * E + A[f] - u[f];
|
|
237
|
+
for (; !A[0] && A.length > 1; A.splice(0, 1)) ;
|
|
238
238
|
}
|
|
239
|
-
return function(
|
|
240
|
-
var
|
|
241
|
-
if (!X || !X[0] ||
|
|
242
|
-
return new
|
|
239
|
+
return function(A, u, f, E, c) {
|
|
240
|
+
var l, y, p, T, S, P, R, U, G, I, M, j, Fe, Re, Me, oe, ge, ee = A.s == u.s ? 1 : -1, X = A.c, $ = u.c;
|
|
241
|
+
if (!X || !X[0] || !$ || !$[0])
|
|
242
|
+
return new g(
|
|
243
243
|
// Return NaN if either NaN, or both Infinity or 0.
|
|
244
|
-
!
|
|
244
|
+
!A.s || !u.s || (X ? $ && X[0] == $[0] : !$) ? 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 || !$ ? ee * 0 : ee / 0
|
|
247
247
|
)
|
|
248
248
|
);
|
|
249
|
-
for (
|
|
250
|
-
if (
|
|
251
|
-
|
|
249
|
+
for (U = new g(ee), G = U.c = [], y = A.e - u.e, ee = f + y + 1, c || (c = ae, y = re(A.e / k) - re(u.e / k), ee = ee / k | 0), p = 0; $[p] == (X[p] || 0); p++) ;
|
|
250
|
+
if ($[p] > (X[p] || 0) && y--, ee < 0)
|
|
251
|
+
G.push(1), T = !0;
|
|
252
252
|
else {
|
|
253
|
-
for (
|
|
254
|
-
|
|
253
|
+
for (Re = X.length, oe = $.length, p = 0, ee += 2, S = ne(c / ($[0] + 1)), S > 1 && ($ = r($, S, c), X = r(X, S, c), oe = $.length, Re = X.length), Fe = oe, I = X.slice(0, oe), M = I.length; M < oe; I[M++] = 0) ;
|
|
254
|
+
ge = $.slice(), ge = [0].concat(ge), Me = $[0], $[1] >= c / 2 && Me++;
|
|
255
255
|
do {
|
|
256
|
-
if (
|
|
257
|
-
if (j =
|
|
258
|
-
for (
|
|
259
|
-
|
|
256
|
+
if (S = 0, l = s($, I, oe, M), l < 0) {
|
|
257
|
+
if (j = I[0], oe != M && (j = j * c + (I[1] || 0)), S = ne(j / Me), S > 1)
|
|
258
|
+
for (S >= c && (S = c - 1), P = r($, S, c), R = P.length, M = I.length; s(P, I, R, M) == 1; )
|
|
259
|
+
S--, o(P, oe < R ? ge : $, R, c), R = P.length, l = 1;
|
|
260
260
|
else
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
for (;
|
|
264
|
-
|
|
265
|
-
} else
|
|
266
|
-
|
|
267
|
-
} while ((
|
|
268
|
-
|
|
261
|
+
S == 0 && (l = S = 1), P = $.slice(), R = P.length;
|
|
262
|
+
if (R < M && (P = [0].concat(P)), o(I, P, M, c), M = I.length, l == -1)
|
|
263
|
+
for (; s($, I, oe, M) < 1; )
|
|
264
|
+
S++, o(I, oe < M ? ge : $, M, c), M = I.length;
|
|
265
|
+
} else l === 0 && (S++, I = [0]);
|
|
266
|
+
G[p++] = S, I[0] ? I[M++] = X[Fe] || 0 : (I = [X[Fe]], M = 1);
|
|
267
|
+
} while ((Fe++ < Re || I[0] != null) && ee--);
|
|
268
|
+
T = I[0] != null, G[0] || G.splice(0, 1);
|
|
269
269
|
}
|
|
270
|
-
if (
|
|
271
|
-
for (
|
|
272
|
-
Y(
|
|
270
|
+
if (c == ae) {
|
|
271
|
+
for (p = 1, ee = G[0]; ee >= 10; ee /= 10, p++) ;
|
|
272
|
+
Y(U, f + (U.e = p + y * k - 1) + 1, E, T);
|
|
273
273
|
} else
|
|
274
|
-
|
|
275
|
-
return
|
|
274
|
+
U.e = y, U.r = +T;
|
|
275
|
+
return U;
|
|
276
276
|
};
|
|
277
277
|
})();
|
|
278
|
-
function Te(r,
|
|
279
|
-
var
|
|
280
|
-
if (o == null ? o =
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
else if (r = Y(new
|
|
284
|
-
for (;
|
|
285
|
-
|
|
286
|
-
} else if (
|
|
287
|
-
if (--
|
|
288
|
-
} else if (
|
|
289
|
-
for (
|
|
290
|
-
return r.s < 0 &&
|
|
278
|
+
function Te(r, s, o, A) {
|
|
279
|
+
var u, f, E, c, l;
|
|
280
|
+
if (o == null ? o = b : L(o, 0, 8), !r.c) return r.toString();
|
|
281
|
+
if (u = r.c[0], E = r.e, s == null)
|
|
282
|
+
l = te(r.c), l = A == 1 || A == 2 && (E <= D || E >= C) ? Be(l, E) : le(l, E, "0");
|
|
283
|
+
else if (r = Y(new g(r), s, o), f = r.e, l = te(r.c), c = l.length, A == 1 || A == 2 && (s <= f || f <= D)) {
|
|
284
|
+
for (; c < s; l += "0", c++) ;
|
|
285
|
+
l = Be(l, f);
|
|
286
|
+
} else if (s -= E + (A === 2 && f > E), l = le(l, f, "0"), f + 1 > c) {
|
|
287
|
+
if (--s > 0) for (l += "."; s--; l += "0") ;
|
|
288
|
+
} else if (s += f - c, s > 0)
|
|
289
|
+
for (f + 1 == c && (l += "."); s--; l += "0") ;
|
|
290
|
+
return r.s < 0 && u ? "-" + l : l;
|
|
291
291
|
}
|
|
292
|
-
function De(r,
|
|
293
|
-
for (var o,
|
|
294
|
-
|
|
295
|
-
return
|
|
292
|
+
function De(r, s) {
|
|
293
|
+
for (var o, A, u = 1, f = new g(r[0]); u < r.length; u++)
|
|
294
|
+
A = new g(r[u]), (!A.s || (o = ye(f, A)) === s || o === 0 && f.s === s) && (f = A);
|
|
295
|
+
return f;
|
|
296
296
|
}
|
|
297
|
-
function
|
|
298
|
-
for (var
|
|
299
|
-
for (
|
|
300
|
-
return (o =
|
|
297
|
+
function xe(r, s, o) {
|
|
298
|
+
for (var A = 1, u = s.length; !s[--u]; s.pop()) ;
|
|
299
|
+
for (u = s[0]; u >= 10; u /= 10, A++) ;
|
|
300
|
+
return (o = A + o * k - 1) > F ? r.c = r.e = null : o < O ? r.c = [r.e = 0] : (r.e = o, r.c = s), r;
|
|
301
301
|
}
|
|
302
|
-
|
|
303
|
-
var r = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
|
|
304
|
-
return function(
|
|
305
|
-
var
|
|
306
|
-
if (
|
|
307
|
-
|
|
302
|
+
i = /* @__PURE__ */ (function() {
|
|
303
|
+
var r = /^(-?)0([xbo])(?=\w[\w.]*$)/i, s = /^([^.]+)\.$/, o = /^\.([^.]+)$/, A = /^-?(Infinity|NaN)$/, u = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
304
|
+
return function(f, E, c, l) {
|
|
305
|
+
var y, p = c ? E : E.replace(u, "");
|
|
306
|
+
if (A.test(p))
|
|
307
|
+
f.s = isNaN(p) ? null : p < 0 ? -1 : 1;
|
|
308
308
|
else {
|
|
309
|
-
if (!
|
|
310
|
-
return
|
|
311
|
-
}),
|
|
312
|
-
return new
|
|
313
|
-
if (
|
|
314
|
-
throw Error(
|
|
315
|
-
|
|
309
|
+
if (!c && (p = p.replace(r, function(T, S, P) {
|
|
310
|
+
return y = (P = P.toLowerCase()) == "x" ? 16 : P == "b" ? 2 : 8, !l || l == y ? S : T;
|
|
311
|
+
}), l && (y = l, p = p.replace(s, "$1").replace(o, "0.$1")), E != p))
|
|
312
|
+
return new g(p, y);
|
|
313
|
+
if (g.DEBUG)
|
|
314
|
+
throw Error(Z + "Not a" + (l ? " base " + l : "") + " number: " + E);
|
|
315
|
+
f.s = null;
|
|
316
316
|
}
|
|
317
|
-
|
|
317
|
+
f.c = f.e = null;
|
|
318
318
|
};
|
|
319
319
|
})();
|
|
320
|
-
function Y(r,
|
|
321
|
-
var
|
|
322
|
-
if (
|
|
320
|
+
function Y(r, s, o, A) {
|
|
321
|
+
var u, f, E, c, l, y, p, T = r.c, S = Ue;
|
|
322
|
+
if (T) {
|
|
323
323
|
e: {
|
|
324
|
-
for (
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
else if (
|
|
328
|
-
if (
|
|
329
|
-
for (;
|
|
330
|
-
|
|
324
|
+
for (u = 1, c = T[0]; c >= 10; c /= 10, u++) ;
|
|
325
|
+
if (f = s - u, f < 0)
|
|
326
|
+
f += k, E = s, l = T[y = 0], p = ne(l / S[u - E - 1] % 10);
|
|
327
|
+
else if (y = Ne((f + 1) / k), y >= T.length)
|
|
328
|
+
if (A) {
|
|
329
|
+
for (; T.length <= y; T.push(0)) ;
|
|
330
|
+
l = p = 0, u = 1, f %= k, E = f - k + 1;
|
|
331
331
|
} else
|
|
332
332
|
break e;
|
|
333
333
|
else {
|
|
334
|
-
for (
|
|
335
|
-
|
|
334
|
+
for (l = c = T[y], u = 1; c >= 10; c /= 10, u++) ;
|
|
335
|
+
f %= k, E = f - k + u, p = E < 0 ? 0 : ne(l / S[u - E - 1] % 10);
|
|
336
336
|
}
|
|
337
|
-
if (
|
|
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
|
-
(
|
|
342
|
-
return
|
|
343
|
-
if (
|
|
340
|
+
T[y + 1] != null || (E < 0 ? l : l % S[u - E - 1]), A = o < 4 ? (p || A) && (o == 0 || o == (r.s < 0 ? 3 : 2)) : p > 5 || p == 5 && (o == 4 || A || o == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
341
|
+
(f > 0 ? E > 0 ? l / S[u - E] : 0 : T[y - 1]) % 10 & 1 || o == (r.s < 0 ? 8 : 7)), s < 1 || !T[0])
|
|
342
|
+
return T.length = 0, A ? (s -= r.e + 1, T[0] = S[(k - s % k) % k], r.e = -s || 0) : T[0] = r.e = 0, r;
|
|
343
|
+
if (f == 0 ? (T.length = y, c = 1, y--) : (T.length = y + 1, c = S[k - f], T[y] = E > 0 ? ne(l / S[u - E] % S[E]) * c : 0), A)
|
|
344
344
|
for (; ; )
|
|
345
|
-
if (
|
|
346
|
-
for (
|
|
347
|
-
for (
|
|
348
|
-
|
|
345
|
+
if (y == 0) {
|
|
346
|
+
for (f = 1, E = T[0]; E >= 10; E /= 10, f++) ;
|
|
347
|
+
for (E = T[0] += c, c = 1; E >= 10; E /= 10, c++) ;
|
|
348
|
+
f != c && (r.e++, T[0] == ae && (T[0] = 1));
|
|
349
349
|
break;
|
|
350
350
|
} else {
|
|
351
|
-
if (
|
|
352
|
-
|
|
351
|
+
if (T[y] += c, T[y] != ae) break;
|
|
352
|
+
T[y--] = 0, c = 1;
|
|
353
353
|
}
|
|
354
|
-
for (
|
|
354
|
+
for (f = T.length; T[--f] === 0; T.pop()) ;
|
|
355
355
|
}
|
|
356
|
-
r.e > F ? r.c = r.e = null : r.e <
|
|
356
|
+
r.e > F ? r.c = r.e = null : r.e < O && (r.c = [r.e = 0]);
|
|
357
357
|
}
|
|
358
358
|
return r;
|
|
359
359
|
}
|
|
360
|
-
function
|
|
361
|
-
var
|
|
362
|
-
return o === null ? r.toString() : (
|
|
360
|
+
function ue(r) {
|
|
361
|
+
var s, o = r.e;
|
|
362
|
+
return o === null ? r.toString() : (s = te(r.c), s = o <= D || o >= C ? Be(s, o) : le(s, o, "0"), r.s < 0 ? "-" + s : s);
|
|
363
363
|
}
|
|
364
|
-
return
|
|
365
|
-
var r = new
|
|
364
|
+
return a.absoluteValue = a.abs = function() {
|
|
365
|
+
var r = new g(this);
|
|
366
366
|
return r.s < 0 && (r.s = 1), r;
|
|
367
|
-
},
|
|
368
|
-
return
|
|
369
|
-
},
|
|
370
|
-
var o,
|
|
367
|
+
}, a.comparedTo = function(r, s) {
|
|
368
|
+
return ye(this, new g(r, s));
|
|
369
|
+
}, a.decimalPlaces = a.dp = function(r, s) {
|
|
370
|
+
var o, A, u, f = this;
|
|
371
371
|
if (r != null)
|
|
372
|
-
return L(r, 0,
|
|
373
|
-
if (!(o =
|
|
374
|
-
if (
|
|
375
|
-
return
|
|
376
|
-
},
|
|
377
|
-
return t(this, new
|
|
378
|
-
},
|
|
379
|
-
return t(this, new
|
|
380
|
-
},
|
|
381
|
-
var o,
|
|
382
|
-
if (r = new
|
|
383
|
-
throw Error(
|
|
384
|
-
if (
|
|
385
|
-
return
|
|
386
|
-
if (
|
|
387
|
-
if (
|
|
388
|
-
|
|
372
|
+
return L(r, 0, q), s == null ? s = b : L(s, 0, 8), Y(new g(f), r + f.e + 1, s);
|
|
373
|
+
if (!(o = f.c)) return null;
|
|
374
|
+
if (A = ((u = o.length - 1) - re(this.e / k)) * k, u = o[u]) for (; u % 10 == 0; u /= 10, A--) ;
|
|
375
|
+
return A < 0 && (A = 0), A;
|
|
376
|
+
}, a.dividedBy = a.div = function(r, s) {
|
|
377
|
+
return t(this, new g(r, s), m, b);
|
|
378
|
+
}, a.dividedToIntegerBy = a.idiv = function(r, s) {
|
|
379
|
+
return t(this, new g(r, s), 0, 1);
|
|
380
|
+
}, a.exponentiatedBy = a.pow = function(r, s) {
|
|
381
|
+
var o, A, u, f, E, c, l, y, p, T = this;
|
|
382
|
+
if (r = new g(r), r.c && !r.isInteger())
|
|
383
|
+
throw Error(Z + "Exponent not an integer: " + ue(r));
|
|
384
|
+
if (s != null && (s = new g(s)), c = r.e > 14, !T.c || !T.c[0] || T.c[0] == 1 && !T.e && T.c.length == 1 || !r.c || !r.c[0])
|
|
385
|
+
return p = new g(Math.pow(+ue(T), c ? r.s * (2 - Ce(r)) : +ue(r))), s ? p.mod(s) : p;
|
|
386
|
+
if (l = r.s < 0, s) {
|
|
387
|
+
if (s.c ? !s.c[0] : !s.s) return new g(NaN);
|
|
388
|
+
A = !l && T.isInteger() && s.isInteger(), A && (T = T.mod(s));
|
|
389
389
|
} else {
|
|
390
|
-
if (r.e > 9 && (
|
|
391
|
-
return
|
|
392
|
-
|
|
390
|
+
if (r.e > 9 && (T.e > 0 || T.e < -1 || (T.e == 0 ? T.c[0] > 1 || c && T.c[1] >= 24e7 : T.c[0] < 8e13 || c && T.c[0] <= 9999975e7)))
|
|
391
|
+
return f = T.s < 0 && Ce(r) ? -0 : 0, T.e > -1 && (f = 1 / f), new g(l ? 1 / f : f);
|
|
392
|
+
B && (f = Ne(B / k + 2));
|
|
393
393
|
}
|
|
394
|
-
for (
|
|
395
|
-
if (
|
|
396
|
-
if (
|
|
397
|
-
|
|
394
|
+
for (c ? (o = new g(0.5), l && (r.s = 1), y = Ce(r)) : (u = Math.abs(+ue(r)), y = u % 2), p = new g(d); ; ) {
|
|
395
|
+
if (y) {
|
|
396
|
+
if (p = p.times(T), !p.c) break;
|
|
397
|
+
f ? p.c.length > f && (p.c.length = f) : A && (p = p.mod(s));
|
|
398
398
|
}
|
|
399
|
-
if (
|
|
400
|
-
if (
|
|
401
|
-
|
|
399
|
+
if (u) {
|
|
400
|
+
if (u = ne(u / 2), u === 0) break;
|
|
401
|
+
y = u % 2;
|
|
402
402
|
} else if (r = r.times(o), Y(r, r.e + 1, 1), r.e > 14)
|
|
403
|
-
|
|
403
|
+
y = Ce(r);
|
|
404
404
|
else {
|
|
405
|
-
if (
|
|
406
|
-
|
|
405
|
+
if (u = +ue(r), u === 0) break;
|
|
406
|
+
y = u % 2;
|
|
407
407
|
}
|
|
408
|
-
|
|
408
|
+
T = T.times(T), f ? T.c && T.c.length > f && (T.c.length = f) : A && (T = T.mod(s));
|
|
409
409
|
}
|
|
410
|
-
return
|
|
411
|
-
},
|
|
412
|
-
var
|
|
413
|
-
return r == null ? r =
|
|
414
|
-
},
|
|
415
|
-
return
|
|
416
|
-
},
|
|
410
|
+
return A ? p : (l && (p = d.div(p)), s ? p.mod(s) : f ? Y(p, B, b, E) : p);
|
|
411
|
+
}, a.integerValue = function(r) {
|
|
412
|
+
var s = new g(this);
|
|
413
|
+
return r == null ? r = b : L(r, 0, 8), Y(s, s.e + 1, r);
|
|
414
|
+
}, a.isEqualTo = a.eq = function(r, s) {
|
|
415
|
+
return ye(this, new g(r, s)) === 0;
|
|
416
|
+
}, a.isFinite = function() {
|
|
417
417
|
return !!this.c;
|
|
418
|
-
},
|
|
419
|
-
return
|
|
420
|
-
},
|
|
421
|
-
return (
|
|
422
|
-
},
|
|
423
|
-
return !!this.c &&
|
|
424
|
-
},
|
|
425
|
-
return
|
|
426
|
-
},
|
|
427
|
-
return (
|
|
428
|
-
},
|
|
418
|
+
}, a.isGreaterThan = a.gt = function(r, s) {
|
|
419
|
+
return ye(this, new g(r, s)) > 0;
|
|
420
|
+
}, a.isGreaterThanOrEqualTo = a.gte = function(r, s) {
|
|
421
|
+
return (s = ye(this, new g(r, s))) === 1 || s === 0;
|
|
422
|
+
}, a.isInteger = function() {
|
|
423
|
+
return !!this.c && re(this.e / k) > this.c.length - 2;
|
|
424
|
+
}, a.isLessThan = a.lt = function(r, s) {
|
|
425
|
+
return ye(this, new g(r, s)) < 0;
|
|
426
|
+
}, a.isLessThanOrEqualTo = a.lte = function(r, s) {
|
|
427
|
+
return (s = ye(this, new g(r, s))) === -1 || s === 0;
|
|
428
|
+
}, a.isNaN = function() {
|
|
429
429
|
return !this.s;
|
|
430
|
-
},
|
|
430
|
+
}, a.isNegative = function() {
|
|
431
431
|
return this.s < 0;
|
|
432
|
-
},
|
|
432
|
+
}, a.isPositive = function() {
|
|
433
433
|
return this.s > 0;
|
|
434
|
-
},
|
|
434
|
+
}, a.isZero = function() {
|
|
435
435
|
return !!this.c && this.c[0] == 0;
|
|
436
|
-
},
|
|
437
|
-
var o,
|
|
438
|
-
if (r = new
|
|
439
|
-
if (
|
|
440
|
-
return r.s = -
|
|
441
|
-
var
|
|
442
|
-
if (!
|
|
443
|
-
if (!
|
|
444
|
-
if (!
|
|
445
|
-
return
|
|
436
|
+
}, a.minus = function(r, s) {
|
|
437
|
+
var o, A, u, f, E = this, c = E.s;
|
|
438
|
+
if (r = new g(r, s), s = r.s, !c || !s) return new g(NaN);
|
|
439
|
+
if (c != s)
|
|
440
|
+
return r.s = -s, E.plus(r);
|
|
441
|
+
var l = E.e / k, y = r.e / k, p = E.c, T = r.c;
|
|
442
|
+
if (!l || !y) {
|
|
443
|
+
if (!p || !T) return p ? (r.s = -s, r) : new g(T ? E : NaN);
|
|
444
|
+
if (!p[0] || !T[0])
|
|
445
|
+
return T[0] ? (r.s = -s, r) : new g(p[0] ? E : (
|
|
446
446
|
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
|
|
447
|
-
|
|
447
|
+
b == 3 ? -0 : 0
|
|
448
448
|
));
|
|
449
449
|
}
|
|
450
|
-
if (
|
|
451
|
-
for ((
|
|
452
|
-
|
|
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 = T), u.reverse(), s = c; s--; u.push(0)) ;
|
|
452
|
+
u.reverse();
|
|
453
453
|
} else
|
|
454
|
-
for (
|
|
455
|
-
if (
|
|
456
|
-
|
|
454
|
+
for (A = (f = (c = p.length) < (s = T.length)) ? c : s, c = s = 0; s < A; s++)
|
|
455
|
+
if (p[s] != T[s]) {
|
|
456
|
+
f = p[s] < T[s];
|
|
457
457
|
break;
|
|
458
458
|
}
|
|
459
|
-
if (
|
|
460
|
-
for (
|
|
461
|
-
if (
|
|
462
|
-
for (o =
|
|
463
|
-
--
|
|
459
|
+
if (f && (u = p, p = T, T = u, r.s = -r.s), s = (A = T.length) - (o = p.length), s > 0) for (; s--; p[o++] = 0) ;
|
|
460
|
+
for (s = ae - 1; A > c; ) {
|
|
461
|
+
if (p[--A] < T[A]) {
|
|
462
|
+
for (o = A; o && !p[--o]; p[o] = s) ;
|
|
463
|
+
--p[o], p[A] += ae;
|
|
464
464
|
}
|
|
465
|
-
|
|
465
|
+
p[A] -= T[A];
|
|
466
466
|
}
|
|
467
|
-
for (;
|
|
468
|
-
return
|
|
469
|
-
},
|
|
470
|
-
var o,
|
|
471
|
-
return r = new
|
|
472
|
-
},
|
|
473
|
-
var o,
|
|
467
|
+
for (; p[0] == 0; p.splice(0, 1), --y) ;
|
|
468
|
+
return p[0] ? xe(r, p, y) : (r.s = b == 3 ? -1 : 1, r.c = [r.e = 0], r);
|
|
469
|
+
}, a.modulo = a.mod = function(r, s) {
|
|
470
|
+
var o, A, u = this;
|
|
471
|
+
return r = new g(r, s), !u.c || !r.s || r.c && !r.c[0] ? new g(NaN) : !r.c || u.c && !u.c[0] ? new g(u) : (w == 9 ? (A = r.s, r.s = 1, o = t(u, r, 0, 3), r.s = A, o.s *= A) : o = t(u, r, 0, w), r = u.minus(o.times(r)), !r.c[0] && w == 1 && (r.s = u.s), r);
|
|
472
|
+
}, a.multipliedBy = a.times = function(r, s) {
|
|
473
|
+
var o, A, u, f, E, c, l, y, p, T, S, P, R, U, G, I = this, M = I.c, j = (r = new g(r, s)).c;
|
|
474
474
|
if (!M || !j || !M[0] || !j[0])
|
|
475
|
-
return !
|
|
476
|
-
for (
|
|
477
|
-
for (
|
|
478
|
-
for (o = 0,
|
|
479
|
-
|
|
480
|
-
|
|
475
|
+
return !I.s || !r.s || M && !M[0] && !j || j && !j[0] && !M ? r.c = r.e = r.s = null : (r.s *= I.s, !M || !j ? r.c = r.e = null : (r.c = [0], r.e = 0)), r;
|
|
476
|
+
for (A = re(I.e / k) + re(r.e / k), r.s *= I.s, l = M.length, T = j.length, l < T && (R = M, M = j, j = R, u = l, l = T, T = u), u = l + T, R = []; u--; R.push(0)) ;
|
|
477
|
+
for (U = ae, G = pe, u = T; --u >= 0; ) {
|
|
478
|
+
for (o = 0, S = j[u] % G, P = j[u] / G | 0, E = l, f = u + E; f > u; )
|
|
479
|
+
y = M[--E] % G, p = M[E] / G | 0, c = P * y + p * S, y = S * y + c % G * G + R[f] + o, o = (y / U | 0) + (c / G | 0) + P * p, R[f--] = y % U;
|
|
480
|
+
R[f] = o;
|
|
481
481
|
}
|
|
482
|
-
return o ? ++
|
|
483
|
-
},
|
|
484
|
-
var r = new
|
|
482
|
+
return o ? ++A : R.splice(0, 1), xe(r, R, A);
|
|
483
|
+
}, a.negated = function() {
|
|
484
|
+
var r = new g(this);
|
|
485
485
|
return r.s = -r.s || null, r;
|
|
486
|
-
},
|
|
487
|
-
var o,
|
|
488
|
-
if (r = new
|
|
489
|
-
if (
|
|
490
|
-
return r.s = -
|
|
491
|
-
var
|
|
492
|
-
if (!
|
|
493
|
-
if (!
|
|
494
|
-
if (!
|
|
486
|
+
}, a.plus = function(r, s) {
|
|
487
|
+
var o, A = this, u = A.s;
|
|
488
|
+
if (r = new g(r, s), s = r.s, !u || !s) return new g(NaN);
|
|
489
|
+
if (u != s)
|
|
490
|
+
return r.s = -s, A.minus(r);
|
|
491
|
+
var f = A.e / k, E = r.e / k, c = A.c, l = r.c;
|
|
492
|
+
if (!f || !E) {
|
|
493
|
+
if (!c || !l) return new g(u / 0);
|
|
494
|
+
if (!c[0] || !l[0]) return l[0] ? r : new g(c[0] ? A : u * 0);
|
|
495
495
|
}
|
|
496
|
-
if (
|
|
497
|
-
for (
|
|
496
|
+
if (f = re(f), E = re(E), c = c.slice(), u = f - E) {
|
|
497
|
+
for (u > 0 ? (E = f, o = l) : (u = -u, o = c), o.reverse(); u--; o.push(0)) ;
|
|
498
498
|
o.reverse();
|
|
499
499
|
}
|
|
500
|
-
for (
|
|
501
|
-
|
|
502
|
-
return
|
|
503
|
-
},
|
|
504
|
-
var o,
|
|
500
|
+
for (u = c.length, s = l.length, u - s < 0 && (o = l, l = c, c = o, s = u), u = 0; s; )
|
|
501
|
+
u = (c[--s] = c[s] + l[s] + u) / ae | 0, c[s] = ae === c[s] ? 0 : c[s] % ae;
|
|
502
|
+
return u && (c = [u].concat(c), ++E), xe(r, c, E);
|
|
503
|
+
}, a.precision = a.sd = function(r, s) {
|
|
504
|
+
var o, A, u, f = this;
|
|
505
505
|
if (r != null && r !== !!r)
|
|
506
|
-
return L(r, 1,
|
|
507
|
-
if (!(o =
|
|
508
|
-
if (
|
|
509
|
-
for (;
|
|
510
|
-
for (
|
|
506
|
+
return L(r, 1, q), s == null ? s = b : L(s, 0, 8), Y(new g(f), r, s);
|
|
507
|
+
if (!(o = f.c)) return null;
|
|
508
|
+
if (u = o.length - 1, A = u * k + 1, u = o[u]) {
|
|
509
|
+
for (; u % 10 == 0; u /= 10, A--) ;
|
|
510
|
+
for (u = o[0]; u >= 10; u /= 10, A++) ;
|
|
511
511
|
}
|
|
512
|
-
return r &&
|
|
513
|
-
},
|
|
514
|
-
return L(r, -
|
|
515
|
-
},
|
|
516
|
-
var r,
|
|
517
|
-
if (
|
|
518
|
-
return new
|
|
519
|
-
if (
|
|
520
|
-
for (
|
|
521
|
-
if (
|
|
522
|
-
if (o.e <
|
|
523
|
-
if (!
|
|
524
|
-
o =
|
|
512
|
+
return r && f.e + 1 > A && (A = f.e + 1), A;
|
|
513
|
+
}, a.shiftedBy = function(r) {
|
|
514
|
+
return L(r, -Le, Le), this.times("1e" + r);
|
|
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 = m + 4, p = new g("0.5");
|
|
517
|
+
if (c !== 1 || !E || !E[0])
|
|
518
|
+
return new g(!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 g(s)) : o = new g(c + ""), o.c[0]) {
|
|
520
|
+
for (l = o.e, c = l + y, c < 3 && (c = 0); ; )
|
|
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
|
+
if (o.e < l && --c, s = s.slice(c - 3, c + 1), s == "9999" || !A && s == "4999") {
|
|
523
|
+
if (!A && (Y(u, u.e + m + 2, 0), u.times(u).eq(f))) {
|
|
524
|
+
o = u;
|
|
525
525
|
break;
|
|
526
526
|
}
|
|
527
|
-
|
|
527
|
+
y += 4, c += 4, A = 1;
|
|
528
528
|
} else {
|
|
529
|
-
(!+
|
|
529
|
+
(!+s || !+s.slice(1) && s.charAt(0) == "5") && (Y(o, o.e + m + 2, 1), r = !o.times(o).eq(f));
|
|
530
530
|
break;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
return Y(o, o.e +
|
|
534
|
-
},
|
|
535
|
-
return r != null && (L(r, 0,
|
|
536
|
-
},
|
|
537
|
-
return r != null && (L(r, 0,
|
|
538
|
-
},
|
|
539
|
-
var
|
|
533
|
+
return Y(o, o.e + m + 1, b, r);
|
|
534
|
+
}, a.toExponential = function(r, s) {
|
|
535
|
+
return r != null && (L(r, 0, q), r++), Te(this, r, s, 1);
|
|
536
|
+
}, a.toFixed = function(r, s) {
|
|
537
|
+
return r != null && (L(r, 0, q), r = r + this.e + 1), Te(this, r, s);
|
|
538
|
+
}, a.toFormat = function(r, s, o) {
|
|
539
|
+
var A, u = this;
|
|
540
540
|
if (o == null)
|
|
541
|
-
r != null &&
|
|
541
|
+
r != null && s && typeof s == "object" ? (o = s, s = null) : r && typeof r == "object" ? (o = r, r = s = null) : o = V;
|
|
542
542
|
else if (typeof o != "object")
|
|
543
|
-
throw Error(
|
|
544
|
-
if (
|
|
545
|
-
var
|
|
546
|
-
if (
|
|
547
|
-
for (
|
|
548
|
-
|
|
543
|
+
throw Error(Z + "Argument not an object: " + o);
|
|
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], T = E[1], S = u.s < 0, P = S ? p.slice(1) : p, R = P.length;
|
|
546
|
+
if (l && (f = c, c = l, l = f, R -= f), c > 0 && R > 0) {
|
|
547
|
+
for (f = R % c || c, p = P.substr(0, f); f < R; f += c) p += y + P.substr(f, c);
|
|
548
|
+
l > 0 && (p += y + P.slice(f)), S && (p = "-" + p);
|
|
549
549
|
}
|
|
550
|
-
|
|
551
|
-
new RegExp("\\d{" +
|
|
550
|
+
A = T ? p + (o.decimalSeparator || "") + ((l = +o.fractionGroupSize) ? T.replace(
|
|
551
|
+
new RegExp("\\d{" + l + "}\\B", "g"),
|
|
552
552
|
"$&" + (o.fractionGroupSeparator || "")
|
|
553
|
-
) :
|
|
553
|
+
) : T) : p;
|
|
554
554
|
}
|
|
555
|
-
return (o.prefix || "") +
|
|
556
|
-
},
|
|
557
|
-
var
|
|
558
|
-
if (r != null && (
|
|
559
|
-
throw Error(
|
|
560
|
-
if (!
|
|
561
|
-
for (
|
|
562
|
-
o =
|
|
563
|
-
return
|
|
564
|
-
t(
|
|
565
|
-
) < 1 ? [
|
|
566
|
-
},
|
|
567
|
-
return +
|
|
568
|
-
},
|
|
569
|
-
return r != null && L(r, 1,
|
|
570
|
-
},
|
|
571
|
-
var
|
|
572
|
-
return
|
|
573
|
-
},
|
|
574
|
-
return
|
|
575
|
-
},
|
|
555
|
+
return (o.prefix || "") + A + (o.suffix || "");
|
|
556
|
+
}, a.toFraction = function(r) {
|
|
557
|
+
var s, o, A, u, f, E, c, l, y, p, T, S, P = this, R = P.c;
|
|
558
|
+
if (r != null && (c = new g(r), !c.isInteger() && (c.c || c.s !== 1) || c.lt(d)))
|
|
559
|
+
throw Error(Z + "Argument " + (c.isInteger() ? "out of range: " : "not an integer: ") + ue(c));
|
|
560
|
+
if (!R) return new g(P);
|
|
561
|
+
for (s = new g(d), y = o = new g(d), A = l = new g(d), S = te(R), f = s.e = S.length - P.e - 1, s.c[0] = Ue[(E = f % k) < 0 ? k + E : E], r = !r || c.comparedTo(s) > 0 ? f > 0 ? s : y : c, E = F, F = 1 / 0, c = new g(S), l.c[0] = 0; p = t(c, s, 0, 1), u = o.plus(p.times(A)), u.comparedTo(r) != 1; )
|
|
562
|
+
o = A, A = u, y = l.plus(p.times(u = y)), l = u, s = c.minus(p.times(u = s)), c = u;
|
|
563
|
+
return u = t(r.minus(o), A, 0, 1), l = l.plus(u.times(y)), o = o.plus(u.times(A)), l.s = y.s = P.s, f = f * 2, T = t(y, A, f, b).minus(P).abs().comparedTo(
|
|
564
|
+
t(l, o, f, b).minus(P).abs()
|
|
565
|
+
) < 1 ? [y, A] : [l, o], F = E, T;
|
|
566
|
+
}, a.toNumber = function() {
|
|
567
|
+
return +ue(this);
|
|
568
|
+
}, a.toPrecision = function(r, s) {
|
|
569
|
+
return r != null && L(r, 1, q), Te(this, r, s, 2);
|
|
570
|
+
}, a.toString = function(r) {
|
|
571
|
+
var s, o = this, A = o.s, u = o.e;
|
|
572
|
+
return u === null ? A ? (s = "Infinity", A < 0 && (s = "-" + s)) : s = "NaN" : (r == null ? s = u <= D || u >= C ? Be(te(o.c), u) : le(te(o.c), u, "0") : r === 10 && z ? (o = Y(new g(o), m + u + 1, b), s = le(te(o.c), o.e, "0")) : (L(r, 2, K.length, "Base"), s = n(le(te(o.c), u, "0"), 10, r, A, !0)), A < 0 && o.c[0] && (s = "-" + s)), s;
|
|
573
|
+
}, a.valueOf = a.toJSON = function() {
|
|
574
|
+
return ue(this);
|
|
575
|
+
}, a._isBigNumber = !0, a[Symbol.toStringTag] = "BigNumber", a[Symbol.for("nodejs.util.inspect.custom")] = a.valueOf, e != null && g.set(e), g;
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function re(e) {
|
|
578
578
|
var t = e | 0;
|
|
579
579
|
return e > 0 || e === t ? t : t - 1;
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
for (var t, n,
|
|
583
|
-
for (t = e[
|
|
584
|
-
|
|
581
|
+
function te(e) {
|
|
582
|
+
for (var t, n, i = 1, a = e.length, d = e[0] + ""; i < a; ) {
|
|
583
|
+
for (t = e[i++] + "", n = k - t.length; n--; t = "0" + t) ;
|
|
584
|
+
d += t;
|
|
585
585
|
}
|
|
586
|
-
for (
|
|
587
|
-
return
|
|
586
|
+
for (a = d.length; d.charCodeAt(--a) === 48; ) ;
|
|
587
|
+
return d.slice(0, a + 1 || 1);
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
var n,
|
|
591
|
-
if (!
|
|
592
|
-
if (n =
|
|
593
|
-
if (
|
|
594
|
-
if (n =
|
|
595
|
-
if (!
|
|
596
|
-
for (
|
|
589
|
+
function ye(e, t) {
|
|
590
|
+
var n, i, a = e.c, d = t.c, m = e.s, b = t.s, D = e.e, C = t.e;
|
|
591
|
+
if (!m || !b) return null;
|
|
592
|
+
if (n = a && !a[0], i = d && !d[0], n || i) return n ? i ? 0 : -b : m;
|
|
593
|
+
if (m != b) return m;
|
|
594
|
+
if (n = m < 0, i = D == C, !a || !d) return i ? 0 : !a ^ n ? 1 : -1;
|
|
595
|
+
if (!i) return D > C ^ n ? 1 : -1;
|
|
596
|
+
for (b = (D = a.length) < (C = d.length) ? D : C, m = 0; m < b; m++) if (a[m] != d[m]) return a[m] > d[m] ^ n ? 1 : -1;
|
|
597
597
|
return D == C ? 0 : D > C ^ n ? 1 : -1;
|
|
598
598
|
}
|
|
599
|
-
function L(e, t, n,
|
|
600
|
-
if (e < t || e > n || e !==
|
|
601
|
-
throw Error(
|
|
599
|
+
function L(e, t, n, i) {
|
|
600
|
+
if (e < t || e > n || e !== ne(e))
|
|
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 Ce(e) {
|
|
604
604
|
var t = e.c.length - 1;
|
|
605
|
-
return
|
|
605
|
+
return re(e.e / k) == t && e.c[t] % 2 != 0;
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function Be(e, t) {
|
|
608
608
|
return (e.length > 1 ? e.charAt(0) + "." + e.slice(1) : e) + (t < 0 ? "e" : "e+") + t;
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
var
|
|
610
|
+
function le(e, t, n) {
|
|
611
|
+
var i, a;
|
|
612
612
|
if (t < 0) {
|
|
613
|
-
for (
|
|
614
|
-
e =
|
|
615
|
-
} else if (
|
|
616
|
-
for (
|
|
617
|
-
e +=
|
|
618
|
-
} else t <
|
|
613
|
+
for (a = n + "."; ++t; a += n) ;
|
|
614
|
+
e = a + e;
|
|
615
|
+
} else if (i = e.length, ++t > i) {
|
|
616
|
+
for (a = n, t -= i; --t; a += n) ;
|
|
617
|
+
e += a;
|
|
618
|
+
} else t < i && (e = e.slice(0, t) + "." + e.slice(t));
|
|
619
619
|
return e;
|
|
620
620
|
}
|
|
621
|
-
var
|
|
622
|
-
|
|
621
|
+
var x = ut();
|
|
622
|
+
const H = (e) => {
|
|
623
|
+
if (!e) return "";
|
|
624
|
+
const t = x(e);
|
|
625
|
+
return t.isFinite() && !t.isNaN() ? e : "";
|
|
626
|
+
}, We = (e, t) => {
|
|
627
|
+
if (t == null || !e) return "";
|
|
628
|
+
const n = x(e);
|
|
629
|
+
return !n.isFinite() || n.isNaN() ? "" : n.multipliedBy(x(10).pow(t)).toFixed(0);
|
|
630
|
+
}, ze = (e, t) => {
|
|
631
|
+
if (t == null || !e) return "";
|
|
632
|
+
const n = x(e);
|
|
633
|
+
return !n.isFinite() || n.isNaN() ? "" : n.dividedBy(x(10).pow(t)).toFixed();
|
|
634
|
+
}, je = (e, t) => {
|
|
635
|
+
if (!e || !t) return "";
|
|
636
|
+
const n = x(e), i = x(t);
|
|
637
|
+
return !n.isFinite() || n.isNaN() || n.isZero() || !i.isFinite() || i.isNaN() || i.isZero() ? "" : n.multipliedBy(i).toFixed();
|
|
638
|
+
}, Ae = (e, t, n) => {
|
|
639
|
+
const i = H(e), a = ze(i, t);
|
|
640
|
+
return {
|
|
641
|
+
raw: i,
|
|
642
|
+
ui: a,
|
|
643
|
+
usd: je(a, n)
|
|
644
|
+
};
|
|
645
|
+
}, Dt = ({
|
|
646
|
+
quotedOutputAmountRaw: e,
|
|
647
|
+
inputAmountUi: t,
|
|
648
|
+
outputTokenDecimals: n,
|
|
649
|
+
outputUsdPrice: i
|
|
650
|
+
}) => {
|
|
651
|
+
const a = H(e), d = H(t), m = a && d && x(d).gt(0) ? x(a).dividedBy(d).toFixed() : "", b = ze(m, n);
|
|
652
|
+
return {
|
|
653
|
+
raw: m,
|
|
654
|
+
ui: b,
|
|
655
|
+
usd: je(b, i)
|
|
656
|
+
};
|
|
657
|
+
}, Ke = 300 * 1e3, Oe = 1440 * 60 * 60 * 1e3, Je = 300 * 1e3, Ve = {
|
|
658
|
+
unit: se.Minutes,
|
|
659
|
+
value: Ke / 6e4
|
|
660
|
+
}, Ft = "-5", Ct = "10", Bt = "-10", wt = "5", lt = (e) => {
|
|
661
|
+
const t = H(e.initialPrice);
|
|
662
|
+
let n = "";
|
|
663
|
+
if (e.typedValue !== void 0) {
|
|
664
|
+
const d = x(e.typedValue), m = e.isInverted ? d.isZero() ? x(0) : x(1).dividedBy(d) : d;
|
|
665
|
+
n = We(m.toFixed(), e.tokenDecimals);
|
|
666
|
+
} else if (e.percentage !== void 0 && t && x(t).gt(0)) {
|
|
667
|
+
const d = x(e.percentage || 0).dividedBy(100);
|
|
668
|
+
n = x(t).plus(x(t).multipliedBy(d)).decimalPlaces(0).toFixed();
|
|
669
|
+
} else t && x(t).gt(0) && (n = x(t).decimalPlaces(0).toFixed());
|
|
670
|
+
const i = H(n);
|
|
671
|
+
let a = "";
|
|
672
|
+
if (t && !x(t).isZero()) {
|
|
673
|
+
if (e.percentage !== void 0 && e.percentage !== null)
|
|
674
|
+
a = e.percentage;
|
|
675
|
+
else if (i) {
|
|
676
|
+
const d = x(i).minus(t).dividedBy(t).multipliedBy(100).decimalPlaces(2).toString();
|
|
677
|
+
a = x(d).isZero() ? "" : d;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return {
|
|
681
|
+
raw: i,
|
|
682
|
+
typedValue: e.typedValue,
|
|
683
|
+
percentage: a,
|
|
684
|
+
isTypedValue: e.typedValue !== void 0
|
|
685
|
+
};
|
|
686
|
+
}, ft = (e) => {
|
|
687
|
+
const t = (d) => {
|
|
688
|
+
if (!d) return "";
|
|
689
|
+
const m = x(d);
|
|
690
|
+
return m.isFinite() && !m.isNaN() ? d : "";
|
|
691
|
+
};
|
|
692
|
+
let n = "";
|
|
693
|
+
if (e.typedValue !== void 0)
|
|
694
|
+
n = t(e.typedValue);
|
|
695
|
+
else {
|
|
696
|
+
const d = ze(e.raw, e.amountDecimals ?? 18);
|
|
697
|
+
d && !x(d).isZero() && (n = e.isInverted ? x(1).dividedBy(d).toFixed() : d);
|
|
698
|
+
}
|
|
699
|
+
const i = n ? e.isInverted ? t(We(n, e.invertedAmountDecimals ?? 18)) : t(e.raw) : "", a = e.isInverted ? e.invertedAmountUsdPrice : e.amountUsdPrice;
|
|
700
|
+
return {
|
|
701
|
+
raw: i,
|
|
702
|
+
ui: n,
|
|
703
|
+
usd: je(n, a)
|
|
704
|
+
};
|
|
705
|
+
}, $r = (e) => {
|
|
706
|
+
if (e === void 0 || e === "") return e;
|
|
707
|
+
const t = x(e);
|
|
708
|
+
return !t.isFinite() || t.isNaN() || t.isZero() ? "0" : x(1).dividedBy(t).toFixed();
|
|
709
|
+
}, St = (e) => {
|
|
710
|
+
if (e === v.STOP_LOSS) return Ft;
|
|
711
|
+
if (e === v.TAKE_PROFIT) return Ct;
|
|
712
|
+
}, Pt = (e, t) => {
|
|
713
|
+
if (!t) {
|
|
714
|
+
if (e === v.STOP_LOSS)
|
|
715
|
+
return Bt;
|
|
716
|
+
if (e === v.TAKE_PROFIT)
|
|
717
|
+
return wt;
|
|
718
|
+
}
|
|
719
|
+
}, Ot = (e, t, n, i) => {
|
|
720
|
+
if (!(x(t || "0").isZero() || !n || e !== v.STOP_LOSS && e !== v.TAKE_PROFIT)) {
|
|
721
|
+
if (e === v.STOP_LOSS && x(i || 0).gte(n))
|
|
722
|
+
return {
|
|
723
|
+
type: J.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,
|
|
724
|
+
value: n
|
|
725
|
+
};
|
|
726
|
+
if (e === v.TAKE_PROFIT && x(i || 0).lte(n))
|
|
727
|
+
return {
|
|
728
|
+
type: J.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,
|
|
729
|
+
value: n
|
|
730
|
+
};
|
|
731
|
+
if (!i || x(i).isZero())
|
|
732
|
+
return {
|
|
733
|
+
type: J.EMPTY_TRIGGER_PRICE,
|
|
734
|
+
value: i
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
}, kt = (e) => {
|
|
738
|
+
const t = e.module === v.STOP_LOSS || e.module === v.TAKE_PROFIT, n = e.triggerPricePercent === void 0 ? St(e.module) : e.triggerPricePercent, i = lt({
|
|
739
|
+
tokenDecimals: e.outputTokenDecimals,
|
|
740
|
+
initialPrice: t ? e.marketPrice : void 0,
|
|
741
|
+
typedValue: e.triggerPrice,
|
|
742
|
+
percentage: n,
|
|
743
|
+
isInverted: e.isInverted
|
|
744
|
+
}), a = ft({
|
|
745
|
+
raw: i.raw,
|
|
746
|
+
typedValue: i.typedValue,
|
|
747
|
+
amountDecimals: e.outputTokenDecimals,
|
|
748
|
+
invertedAmountDecimals: e.inputTokenDecimals,
|
|
749
|
+
amountUsdPrice: e.outputUsdPrice,
|
|
750
|
+
invertedAmountUsdPrice: e.inputUsdPrice,
|
|
751
|
+
isInverted: e.isInverted
|
|
752
|
+
});
|
|
753
|
+
return {
|
|
754
|
+
...i,
|
|
755
|
+
enabled: t,
|
|
756
|
+
display: a,
|
|
757
|
+
error: Ot(
|
|
758
|
+
e.module,
|
|
759
|
+
e.inputAmountRaw,
|
|
760
|
+
H(e.marketPrice),
|
|
761
|
+
i.raw
|
|
762
|
+
)
|
|
763
|
+
};
|
|
764
|
+
}, _t = (e, t, n) => {
|
|
765
|
+
if (!(x(e.inputAmountRaw || "0").isZero() || !t || e.isMarketOrder)) {
|
|
766
|
+
if ((e.module === v.STOP_LOSS || e.module === v.TAKE_PROFIT) && e.triggerPrice && x(n || 0).gte(e.triggerPrice))
|
|
767
|
+
return {
|
|
768
|
+
type: J.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,
|
|
769
|
+
value: e.triggerPrice
|
|
770
|
+
};
|
|
771
|
+
if (!n || x(n).isZero())
|
|
772
|
+
return {
|
|
773
|
+
type: J.MISSING_LIMIT_PRICE,
|
|
774
|
+
value: n
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
}, vt = (e) => {
|
|
778
|
+
const t = e.limitPricePercent === void 0 ? Pt(e.module, e.isMarketOrder) : e.limitPricePercent, n = lt({
|
|
779
|
+
tokenDecimals: e.outputTokenDecimals,
|
|
780
|
+
initialPrice: e.marketPrice,
|
|
781
|
+
typedValue: e.limitPrice,
|
|
782
|
+
percentage: t,
|
|
783
|
+
isInverted: e.isInverted
|
|
784
|
+
}), i = ft({
|
|
785
|
+
raw: n.raw,
|
|
786
|
+
typedValue: n.typedValue,
|
|
787
|
+
amountDecimals: e.outputTokenDecimals,
|
|
788
|
+
invertedAmountDecimals: e.inputTokenDecimals,
|
|
789
|
+
amountUsdPrice: e.outputUsdPrice,
|
|
790
|
+
invertedAmountUsdPrice: e.inputUsdPrice,
|
|
791
|
+
isInverted: e.isInverted
|
|
792
|
+
}), a = H(e.marketPrice);
|
|
793
|
+
return {
|
|
794
|
+
...n,
|
|
795
|
+
display: i,
|
|
796
|
+
error: _t(e, a, n.raw)
|
|
797
|
+
};
|
|
798
|
+
}, It = (e, t, n) => {
|
|
799
|
+
const i = kt({
|
|
800
|
+
module: e.module,
|
|
801
|
+
marketPrice: n,
|
|
802
|
+
inputAmountRaw: t,
|
|
803
|
+
triggerPrice: e.userInput.triggerPriceUi,
|
|
804
|
+
triggerPricePercent: e.userInput.triggerPricePercent,
|
|
805
|
+
isInverted: e.userInput.isPriceInverted,
|
|
806
|
+
inputTokenDecimals: e.inputTokenDecimals,
|
|
807
|
+
outputTokenDecimals: e.outputTokenDecimals,
|
|
808
|
+
inputUsdPrice: e.inputTokenUsdPrice,
|
|
809
|
+
outputUsdPrice: e.outputTokenUsdPrice
|
|
810
|
+
}), a = e.module === v.LIMIT ? !1 : e.userInput.isMarketOrder, d = vt({
|
|
811
|
+
module: e.module,
|
|
812
|
+
isMarketOrder: a,
|
|
813
|
+
marketPrice: n,
|
|
814
|
+
inputAmountRaw: t,
|
|
815
|
+
limitPrice: e.userInput.limitPriceUi,
|
|
816
|
+
limitPricePercent: e.userInput.limitPricePercent,
|
|
817
|
+
triggerPrice: i.raw,
|
|
818
|
+
isInverted: e.userInput.isPriceInverted,
|
|
819
|
+
inputTokenDecimals: e.inputTokenDecimals,
|
|
820
|
+
outputTokenDecimals: e.outputTokenDecimals,
|
|
821
|
+
inputUsdPrice: e.inputTokenUsdPrice,
|
|
822
|
+
outputUsdPrice: e.outputTokenUsdPrice
|
|
823
|
+
});
|
|
824
|
+
return { isMarketOrder: a, triggerPrice: i, limitPrice: d };
|
|
825
|
+
}, Rt = [
|
|
826
|
+
"0x0000000000000000000000000000000000000000",
|
|
827
|
+
"0x0000000000000000000000000000000000001010",
|
|
828
|
+
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
829
|
+
"0x000000000000000000000000000000000000dEaD",
|
|
830
|
+
"0x000000000000000000000000000000000000800A",
|
|
831
|
+
"0x000000000000000000000000000000000000800a"
|
|
832
|
+
], pt = "115792089237316195423570985008687907853269984665640564039457584007913129639935";
|
|
833
|
+
function Mt(e) {
|
|
623
834
|
throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
624
835
|
}
|
|
625
|
-
const
|
|
836
|
+
const Nt = {
|
|
626
837
|
1: { adapter: { Nordstern: "0x6603629C8d4b683fdc51c7F810D1799cfEAcEAe3", Sushi: "0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c", Ring: "0x47e27973dA3e16dB13F8b713877b3A31623E0E5B", Kyber: "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d", Paraswap: "0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f" }, dex: { sushiswap: { type: "default", solver: "Sushi", router: "0xAC4c6e212A361c968F1725b4d055b47E63F80b75", adapter: "0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df", fee: "0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc" }, ring: { type: "dynamicp2", solver: "Ring", permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3", adapter: "0x028fa69049aB68EC42064Eb18896D587dD41Af2a", fee: "0xA04329696aAd1417c75Cf6d91342815001999B21" } } },
|
|
627
838
|
10: { adapter: { Nordstern: "0x1D06d98D523F8B51AD693D4A22fb97fCf0838d83", Sushi: "0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c", Kyber: "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA", Magpie: "0x370AC766279eCD03dc1D8eb0E5A632a24A255EAb", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d", Paraswap: "0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f" }, dex: {} },
|
|
628
839
|
14: { adapter: { Nordstern: "0xd16A1849E86431872a87f476fa0DfB30eEb96cb3", SparkDex: "0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7", OpenOcean: "0x2Be5260d030ff9A6040bA4292326B796ff1a055d" }, dex: { spark: { type: "default", solver: "SparkDex", router: "0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3", adapter: "0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7", fee: "0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b" } } },
|
|
@@ -643,11 +854,11 @@ const Bt = {
|
|
|
643
854
|
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" } } },
|
|
644
855
|
"*": { 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" } } }
|
|
645
856
|
};
|
|
646
|
-
var
|
|
647
|
-
function
|
|
648
|
-
if (
|
|
649
|
-
|
|
650
|
-
const e =
|
|
857
|
+
var $e, et;
|
|
858
|
+
function Lt() {
|
|
859
|
+
if (et) return $e;
|
|
860
|
+
et = 1;
|
|
861
|
+
const e = Nt, t = (d) => Mt(`./out/${d}.sol/${d}.abi.json`), n = () => ({
|
|
651
862
|
wm: t("WM"),
|
|
652
863
|
repermit: t("RePermit"),
|
|
653
864
|
reactor: t("OrderReactor"),
|
|
@@ -656,1107 +867,252 @@ function kt() {
|
|
|
656
867
|
settler: t("Settler"),
|
|
657
868
|
adapter: t("DefaultDexAdapter")
|
|
658
869
|
});
|
|
659
|
-
function
|
|
660
|
-
var
|
|
661
|
-
if (!
|
|
662
|
-
const
|
|
663
|
-
if (
|
|
664
|
-
return { ...((
|
|
870
|
+
function i(d) {
|
|
871
|
+
var b;
|
|
872
|
+
if (!d) return;
|
|
873
|
+
const m = e[d];
|
|
874
|
+
if (m)
|
|
875
|
+
return { ...((b = e["*"]) == null ? void 0 : b.adapter) ?? {}, ...m.adapter ?? {} };
|
|
665
876
|
}
|
|
666
|
-
function
|
|
667
|
-
if (!
|
|
668
|
-
const { dex:
|
|
669
|
-
if (!
|
|
670
|
-
const { dex: F, salt:
|
|
671
|
-
if (
|
|
672
|
-
const K =
|
|
673
|
-
if (!(!K && !
|
|
674
|
-
return { ...
|
|
877
|
+
function a(d, m) {
|
|
878
|
+
if (!d) return;
|
|
879
|
+
const { dex: b, salt: D, ...C } = e["*"] ?? {}, O = e[d];
|
|
880
|
+
if (!O) return;
|
|
881
|
+
const { dex: F, salt: h, ...w } = O, B = { ...C, ...w }, V = m == null ? void 0 : m.trim();
|
|
882
|
+
if (!V) return B;
|
|
883
|
+
const K = b == null ? void 0 : b[V], z = F == null ? void 0 : F[V];
|
|
884
|
+
if (!(!K && !z))
|
|
885
|
+
return { ...B, ...K, ...z };
|
|
675
886
|
}
|
|
676
|
-
return
|
|
887
|
+
return $e = { config: a, adapters: i, abis: n, raw: e }, $e;
|
|
677
888
|
}
|
|
678
|
-
var
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
SushiArb: Lt,
|
|
691
|
-
SushiBase: $t,
|
|
692
|
-
SushiEth: Kt,
|
|
693
|
-
SushiKatana: Vt,
|
|
694
|
-
DragonSwap: Wt,
|
|
695
|
-
SparkDEX: zt,
|
|
696
|
-
SwapX: Ht,
|
|
697
|
-
BlackholeAvax: qt
|
|
698
|
-
}, U = "0x0000000000000000000000000000000000000000", Z = {
|
|
699
|
-
eth: {
|
|
700
|
-
id: 1,
|
|
701
|
-
name: "Ethereum",
|
|
702
|
-
shortname: "eth",
|
|
703
|
-
native: {
|
|
704
|
-
address: U,
|
|
705
|
-
symbol: "ETH",
|
|
706
|
-
decimals: 18,
|
|
707
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
708
|
-
},
|
|
709
|
-
wToken: {
|
|
710
|
-
symbol: "WETH",
|
|
711
|
-
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
712
|
-
decimals: 18,
|
|
713
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
714
|
-
},
|
|
715
|
-
publicRpcUrl: "https://eth.llamarpc.com",
|
|
716
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg",
|
|
717
|
-
explorer: "https://etherscan.io",
|
|
718
|
-
eip1559: !0
|
|
719
|
-
},
|
|
720
|
-
bsc: {
|
|
721
|
-
id: 56,
|
|
722
|
-
name: "BinanceSmartChain",
|
|
723
|
-
shortname: "bsc",
|
|
724
|
-
native: {
|
|
725
|
-
address: U,
|
|
726
|
-
symbol: "BNB",
|
|
727
|
-
decimals: 18,
|
|
728
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"
|
|
729
|
-
},
|
|
730
|
-
wToken: {
|
|
731
|
-
symbol: "WBNB",
|
|
732
|
-
address: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
733
|
-
decimals: 18,
|
|
734
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"
|
|
735
|
-
},
|
|
736
|
-
publicRpcUrl: "https://bsc-dataseed.binance.org",
|
|
737
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/bsc_2.svg",
|
|
738
|
-
explorer: "https://bscscan.com",
|
|
739
|
-
eip1559: !1
|
|
740
|
-
},
|
|
741
|
-
unichain: {
|
|
742
|
-
id: 130,
|
|
743
|
-
name: "Unichain",
|
|
744
|
-
shortname: "unichain",
|
|
745
|
-
native: {
|
|
746
|
-
address: U,
|
|
747
|
-
symbol: "ETH",
|
|
748
|
-
decimals: 18,
|
|
749
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
750
|
-
},
|
|
751
|
-
wToken: {
|
|
752
|
-
symbol: "WETH",
|
|
753
|
-
address: "0x4200000000000000000000000000000000000006",
|
|
754
|
-
decimals: 18,
|
|
755
|
-
logoUrl: "https://tokens-data.1inch.io/images/130/0x4200000000000000000000000000000000000006_0x042e6d078c6cf9e13a618396b0aa40181bcb43921ebdb5fabc8fb1124d516156.webp"
|
|
756
|
-
},
|
|
757
|
-
publicRpcUrl: "https://mainnet.unichain.org",
|
|
758
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_unichain",
|
|
759
|
-
explorer: "https://uniscan.xyz",
|
|
760
|
-
eip1559: !0
|
|
761
|
-
},
|
|
762
|
-
xlayer: {
|
|
763
|
-
id: 196,
|
|
764
|
-
name: "X Layer",
|
|
765
|
-
shortname: "xlayer",
|
|
766
|
-
native: {
|
|
767
|
-
address: U,
|
|
768
|
-
symbol: "OKB",
|
|
769
|
-
decimals: 18,
|
|
770
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png"
|
|
771
|
-
},
|
|
772
|
-
wToken: {
|
|
773
|
-
symbol: "WOKB",
|
|
774
|
-
address: "0xe538905cf8410324e03A5A23C1c177a474D59b2b",
|
|
775
|
-
decimals: 18,
|
|
776
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png"
|
|
777
|
-
},
|
|
778
|
-
publicRpcUrl: "https://rpc.xlayer.tech",
|
|
779
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png",
|
|
780
|
-
explorer: "https://www.oklink.com/xlayer",
|
|
781
|
-
eip1559: !0
|
|
782
|
-
},
|
|
783
|
-
hyperevm: {
|
|
784
|
-
id: 999,
|
|
785
|
-
name: "HyperEVM",
|
|
786
|
-
shortname: "hyperevm",
|
|
787
|
-
native: {
|
|
788
|
-
address: U,
|
|
789
|
-
symbol: "HYPE",
|
|
790
|
-
decimals: 18,
|
|
791
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png"
|
|
792
|
-
},
|
|
793
|
-
wToken: {
|
|
794
|
-
symbol: "WHYPE",
|
|
795
|
-
address: "0x5555555555555555555555555555555555555555",
|
|
796
|
-
decimals: 18,
|
|
797
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png"
|
|
798
|
-
},
|
|
799
|
-
publicRpcUrl: "https://rpc.hyperliquid.xyz/evm",
|
|
800
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_hyperliquid",
|
|
801
|
-
explorer: "https://hyperevmscan.io",
|
|
802
|
-
eip1559: !0
|
|
803
|
-
},
|
|
804
|
-
megaeth: {
|
|
805
|
-
id: 4326,
|
|
806
|
-
name: "MegaETH",
|
|
807
|
-
shortname: "megaeth",
|
|
808
|
-
native: {
|
|
809
|
-
address: U,
|
|
810
|
-
symbol: "ETH",
|
|
811
|
-
decimals: 18,
|
|
812
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
813
|
-
},
|
|
814
|
-
wToken: {
|
|
815
|
-
symbol: "WETH",
|
|
816
|
-
address: "0x4200000000000000000000000000000000000006",
|
|
817
|
-
decimals: 18,
|
|
818
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
819
|
-
},
|
|
820
|
-
publicRpcUrl: "https://mainnet.megaeth.com/rpc",
|
|
821
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_megaeth",
|
|
822
|
-
explorer: "https://mega.etherscan.io",
|
|
823
|
-
eip1559: !0
|
|
824
|
-
},
|
|
825
|
-
poly: {
|
|
826
|
-
id: 137,
|
|
827
|
-
name: "Polygon",
|
|
828
|
-
shortname: "poly",
|
|
829
|
-
native: {
|
|
830
|
-
address: U,
|
|
831
|
-
symbol: "POL",
|
|
832
|
-
decimals: 18,
|
|
833
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png"
|
|
834
|
-
},
|
|
835
|
-
wToken: {
|
|
836
|
-
symbol: "WPOL",
|
|
837
|
-
address: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
838
|
-
decimals: 18,
|
|
839
|
-
logoUrl: "https://tokens-data.1inch.io/images/0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270.png"
|
|
840
|
-
},
|
|
841
|
-
publicRpcUrl: "https://polygon-rpc.com",
|
|
842
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/polygon.svg",
|
|
843
|
-
explorer: "https://polygonscan.com",
|
|
844
|
-
eip1559: !0
|
|
845
|
-
},
|
|
846
|
-
arb: {
|
|
847
|
-
id: 42161,
|
|
848
|
-
name: "Arbitrum",
|
|
849
|
-
shortname: "arb",
|
|
850
|
-
native: {
|
|
851
|
-
address: U,
|
|
852
|
-
symbol: "ETH",
|
|
853
|
-
decimals: 18,
|
|
854
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
855
|
-
},
|
|
856
|
-
wToken: {
|
|
857
|
-
symbol: "WETH",
|
|
858
|
-
address: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
859
|
-
decimals: 18,
|
|
860
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
861
|
-
},
|
|
862
|
-
publicRpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
863
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/arbitrum.svg",
|
|
864
|
-
explorer: "https://arbiscan.io",
|
|
865
|
-
eip1559: !0
|
|
866
|
-
},
|
|
867
|
-
sei: {
|
|
868
|
-
id: 1329,
|
|
869
|
-
name: "Sei",
|
|
870
|
-
shortname: "sei",
|
|
871
|
-
native: {
|
|
872
|
-
address: U,
|
|
873
|
-
symbol: "SEI",
|
|
874
|
-
decimals: 18,
|
|
875
|
-
logoUrl: "https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png"
|
|
876
|
-
},
|
|
877
|
-
wToken: {
|
|
878
|
-
symbol: "WSEI",
|
|
879
|
-
address: "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",
|
|
880
|
-
decimals: 18,
|
|
881
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
882
|
-
},
|
|
883
|
-
publicRpcUrl: "https://evm-rpc.sei-apis.com",
|
|
884
|
-
logoUrl: "https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png",
|
|
885
|
-
explorer: "https://seitrace.com",
|
|
886
|
-
eip1559: !1
|
|
887
|
-
},
|
|
888
|
-
avax: {
|
|
889
|
-
id: 43114,
|
|
890
|
-
name: "Avalanche",
|
|
891
|
-
shortname: "avax",
|
|
892
|
-
native: {
|
|
893
|
-
address: U,
|
|
894
|
-
symbol: "AVAX",
|
|
895
|
-
decimals: 18,
|
|
896
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/avalanche.svg"
|
|
897
|
-
},
|
|
898
|
-
wToken: {
|
|
899
|
-
symbol: "WAVAX",
|
|
900
|
-
address: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
901
|
-
decimals: 18,
|
|
902
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7.png"
|
|
903
|
-
},
|
|
904
|
-
publicRpcUrl: "https://api.avax.network/ext/bc/C/rpc",
|
|
905
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/avalanche.svg",
|
|
906
|
-
explorer: "https://snowtrace.io",
|
|
907
|
-
eip1559: !0
|
|
908
|
-
},
|
|
909
|
-
ftm: {
|
|
910
|
-
id: 250,
|
|
911
|
-
name: "Fantom",
|
|
912
|
-
shortname: "ftm",
|
|
913
|
-
native: {
|
|
914
|
-
address: U,
|
|
915
|
-
symbol: "FTM",
|
|
916
|
-
decimals: 18,
|
|
917
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/fantom.svg"
|
|
918
|
-
},
|
|
919
|
-
wToken: {
|
|
920
|
-
symbol: "WFTM",
|
|
921
|
-
address: "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",
|
|
922
|
-
decimals: 18,
|
|
923
|
-
logoUrl: "https://tokens-data.1inch.io/images/0x4e15361fd6b4bb609fa63c81a2be19d873717870.png"
|
|
924
|
-
},
|
|
925
|
-
publicRpcUrl: "https://rpc.ftm.tools",
|
|
926
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/fantom.svg",
|
|
927
|
-
explorer: "https://ftmscan.com",
|
|
928
|
-
eip1559: !0
|
|
929
|
-
},
|
|
930
|
-
base: {
|
|
931
|
-
id: 8453,
|
|
932
|
-
name: "Base",
|
|
933
|
-
shortname: "base",
|
|
934
|
-
native: {
|
|
935
|
-
address: U,
|
|
936
|
-
symbol: "ETH",
|
|
937
|
-
decimals: 18,
|
|
938
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/1027.png"
|
|
939
|
-
},
|
|
940
|
-
wToken: {
|
|
941
|
-
symbol: "WETH",
|
|
942
|
-
address: "0x4200000000000000000000000000000000000006",
|
|
943
|
-
decimals: 18,
|
|
944
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
945
|
-
},
|
|
946
|
-
publicRpcUrl: "https://mainnet.base.org",
|
|
947
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/base.svg",
|
|
948
|
-
explorer: "https://basescan.org",
|
|
949
|
-
eip1559: !1
|
|
950
|
-
},
|
|
951
|
-
linea: {
|
|
952
|
-
id: 59144,
|
|
953
|
-
name: "Linea",
|
|
954
|
-
shortname: "linea",
|
|
955
|
-
native: {
|
|
956
|
-
address: U,
|
|
957
|
-
symbol: "ETH",
|
|
958
|
-
decimals: 18,
|
|
959
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
960
|
-
},
|
|
961
|
-
wToken: {
|
|
962
|
-
symbol: "WETH",
|
|
963
|
-
address: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
|
|
964
|
-
decimals: 18,
|
|
965
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
966
|
-
},
|
|
967
|
-
publicRpcUrl: "https://rpc.linea.build",
|
|
968
|
-
logoUrl: "https://lineascan.build/images/logo.svg",
|
|
969
|
-
explorer: "https://lineascan.build",
|
|
970
|
-
eip1559: !1
|
|
971
|
-
},
|
|
972
|
-
zksync: {
|
|
973
|
-
id: 324,
|
|
974
|
-
name: "zksync",
|
|
975
|
-
shortname: "zksync",
|
|
976
|
-
native: {
|
|
977
|
-
address: U,
|
|
978
|
-
symbol: "ETH",
|
|
979
|
-
decimals: 18,
|
|
980
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
981
|
-
},
|
|
982
|
-
wToken: {
|
|
983
|
-
symbol: "WETH",
|
|
984
|
-
address: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
|
|
985
|
-
decimals: 18,
|
|
986
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
987
|
-
},
|
|
988
|
-
publicRpcUrl: "https://mainnet.era.zksync.io",
|
|
989
|
-
logoUrl: "https://raw.githubusercontent.com/matter-labs/zksync/0a4ca2145a0c95b5bafa84c2f095c644907a8825/zkSyncLogo.svg",
|
|
990
|
-
explorer: "https://explorer.zksync.io/",
|
|
991
|
-
eip1559: !0
|
|
992
|
-
},
|
|
993
|
-
zkevm: {
|
|
994
|
-
id: 1101,
|
|
995
|
-
name: "zkevm",
|
|
996
|
-
shortname: "zkevm",
|
|
997
|
-
native: {
|
|
998
|
-
address: U,
|
|
999
|
-
symbol: "ETH",
|
|
1000
|
-
decimals: 18,
|
|
1001
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
1002
|
-
},
|
|
1003
|
-
wToken: {
|
|
1004
|
-
symbol: "WETH",
|
|
1005
|
-
address: "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
|
|
1006
|
-
decimals: 18,
|
|
1007
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
1008
|
-
},
|
|
1009
|
-
publicRpcUrl: "https://zkevm-rpc.com",
|
|
1010
|
-
logoUrl: "https://user-images.githubusercontent.com/18598517/235932702-bc47eae5-d672-4dd9-9da2-8ea8f51a93f3.png",
|
|
1011
|
-
explorer: "https://zkevm.polygonscan.com/",
|
|
1012
|
-
eip1559: !0
|
|
1013
|
-
},
|
|
1014
|
-
manta: {
|
|
1015
|
-
id: 169,
|
|
1016
|
-
name: "manta",
|
|
1017
|
-
shortname: "manta",
|
|
1018
|
-
native: {
|
|
1019
|
-
address: U,
|
|
1020
|
-
symbol: "ETH",
|
|
1021
|
-
decimals: 18,
|
|
1022
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_manta.jpg"
|
|
1023
|
-
},
|
|
1024
|
-
wToken: {
|
|
1025
|
-
symbol: "WETH",
|
|
1026
|
-
address: "0x0Dc808adcE2099A9F62AA87D9670745AbA741746",
|
|
1027
|
-
decimals: 18,
|
|
1028
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
1029
|
-
},
|
|
1030
|
-
publicRpcUrl: "https://pacific-rpc.manta.network/http",
|
|
1031
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_manta.jpg",
|
|
1032
|
-
explorer: "https://manta.socialscan.io/",
|
|
1033
|
-
eip1559: !0
|
|
1034
|
-
},
|
|
1035
|
-
blast: {
|
|
1036
|
-
id: 81457,
|
|
1037
|
-
name: "blast",
|
|
1038
|
-
shortname: "blast",
|
|
1039
|
-
native: {
|
|
1040
|
-
address: U,
|
|
1041
|
-
symbol: "ETH",
|
|
1042
|
-
decimals: 18,
|
|
1043
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_blast"
|
|
1044
|
-
},
|
|
1045
|
-
wToken: {
|
|
1046
|
-
symbol: "WETH",
|
|
1047
|
-
address: "0x4300000000000000000000000000000000000004",
|
|
1048
|
-
decimals: 18,
|
|
1049
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
1050
|
-
},
|
|
1051
|
-
publicRpcUrl: "https://rpc.ankr.com/blast",
|
|
1052
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_blast",
|
|
1053
|
-
explorer: "https://blastscan.io/",
|
|
1054
|
-
eip1559: !0
|
|
1055
|
-
},
|
|
1056
|
-
sonic: {
|
|
1057
|
-
id: 146,
|
|
1058
|
-
name: "sonic",
|
|
1059
|
-
shortname: "sonic",
|
|
1060
|
-
native: {
|
|
1061
|
-
address: U,
|
|
1062
|
-
symbol: "S",
|
|
1063
|
-
decimals: 18,
|
|
1064
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_sonic"
|
|
1065
|
-
},
|
|
1066
|
-
wToken: {
|
|
1067
|
-
symbol: "WS",
|
|
1068
|
-
address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
1069
|
-
decimals: 18,
|
|
1070
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_sonic"
|
|
1071
|
-
},
|
|
1072
|
-
publicRpcUrl: "https://rpc.soniclabs.com",
|
|
1073
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_sonic",
|
|
1074
|
-
explorer: "https://www.sonicscan.org/",
|
|
1075
|
-
eip1559: !0
|
|
1076
|
-
},
|
|
1077
|
-
scroll: {
|
|
1078
|
-
id: 534352,
|
|
1079
|
-
name: "scroll",
|
|
1080
|
-
shortname: "scroll",
|
|
1081
|
-
native: {
|
|
1082
|
-
address: U,
|
|
1083
|
-
symbol: "ETH",
|
|
1084
|
-
decimals: 18,
|
|
1085
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_scroll"
|
|
1086
|
-
},
|
|
1087
|
-
wToken: {
|
|
1088
|
-
symbol: "WETH",
|
|
1089
|
-
address: "0x5300000000000000000000000000000000000004",
|
|
1090
|
-
decimals: 18,
|
|
1091
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
1092
|
-
},
|
|
1093
|
-
publicRpcUrl: "https://scroll-rpc.publicnode.com",
|
|
1094
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_scroll",
|
|
1095
|
-
explorer: "https://scrollscan.com/",
|
|
1096
|
-
eip1559: !0
|
|
1097
|
-
},
|
|
1098
|
-
zircuit: {
|
|
1099
|
-
id: 48900,
|
|
1100
|
-
name: "Zircuit",
|
|
1101
|
-
shortname: "zircuit",
|
|
1102
|
-
native: {
|
|
1103
|
-
address: U,
|
|
1104
|
-
symbol: "ETH",
|
|
1105
|
-
decimals: 18,
|
|
1106
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg"
|
|
1107
|
-
},
|
|
1108
|
-
wToken: {
|
|
1109
|
-
symbol: "WETH",
|
|
1110
|
-
address: "0x4200000000000000000000000000000000000006",
|
|
1111
|
-
decimals: 18,
|
|
1112
|
-
logoUrl: "https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"
|
|
1113
|
-
},
|
|
1114
|
-
publicRpcUrl: "https://zircuit-mainnet.drpc.org",
|
|
1115
|
-
logoUrl: "https://app.1inch.io/assets/images/network-logos/ethereum.svg",
|
|
1116
|
-
explorer: "https://explorer.zircuit.com/",
|
|
1117
|
-
eip1559: !0
|
|
1118
|
-
},
|
|
1119
|
-
flare: {
|
|
1120
|
-
id: 14,
|
|
1121
|
-
name: "flare",
|
|
1122
|
-
shortname: "flare",
|
|
1123
|
-
native: {
|
|
1124
|
-
address: U,
|
|
1125
|
-
symbol: "FLR",
|
|
1126
|
-
decimals: 18,
|
|
1127
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48"
|
|
1128
|
-
},
|
|
1129
|
-
wToken: {
|
|
1130
|
-
symbol: "WFLR",
|
|
1131
|
-
address: "0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",
|
|
1132
|
-
decimals: 18,
|
|
1133
|
-
logoUrl: "https://res.cloudinary.com/sparkdex/image/upload/q_100/v1/website-assets/coins/wflr?_a=DATAg1AAZAA0"
|
|
1134
|
-
},
|
|
1135
|
-
publicRpcUrl: "https://flare.network",
|
|
1136
|
-
logoUrl: "https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48",
|
|
1137
|
-
explorer: "https://flarescan.com",
|
|
1138
|
-
eip1559: !0
|
|
1139
|
-
},
|
|
1140
|
-
cronosZkEvm: {
|
|
1141
|
-
id: 388,
|
|
1142
|
-
name: "Cronos zkEVM",
|
|
1143
|
-
shortname: "cronosZkEvm",
|
|
1144
|
-
native: {
|
|
1145
|
-
address: "0x000000000000000000000000000000000000800a",
|
|
1146
|
-
symbol: "zkCRO",
|
|
1147
|
-
decimals: 18,
|
|
1148
|
-
logoUrl: "https://cryptologos.cc/logos/cronos-cro-logo.png"
|
|
1149
|
-
// Replace with the official logo URL if available
|
|
1150
|
-
},
|
|
1151
|
-
wToken: {
|
|
1152
|
-
symbol: "wzkCRO",
|
|
1153
|
-
address: "0xC1bF55EE54E16229d9b369a5502Bfe5fC9F20b6d",
|
|
1154
|
-
decimals: 18,
|
|
1155
|
-
logoUrl: "https://cryptologos.cc/logos/cronos-cro-logo.png"
|
|
1156
|
-
// Replace with the official logo URL if available
|
|
1157
|
-
},
|
|
1158
|
-
publicRpcUrl: "https://rpc.zkevm.cronos.org",
|
|
1159
|
-
logoUrl: "https://cryptologos.cc/logos/cronos-cro-logo.png",
|
|
1160
|
-
// Replace with the official logo URL if available
|
|
1161
|
-
explorer: "https://explorer.zkevm.cronos.org",
|
|
1162
|
-
eip1559: !0
|
|
1163
|
-
},
|
|
1164
|
-
katana: {
|
|
1165
|
-
id: 747474,
|
|
1166
|
-
name: "Katana",
|
|
1167
|
-
shortname: "katana",
|
|
1168
|
-
native: {
|
|
1169
|
-
address: U,
|
|
1170
|
-
symbol: "ETH",
|
|
1171
|
-
decimals: 18,
|
|
1172
|
-
logoUrl: "https://katana.network/assets/katana-logo.svg"
|
|
1173
|
-
},
|
|
1174
|
-
wToken: {
|
|
1175
|
-
symbol: "WETH",
|
|
1176
|
-
address: "0xee7d8bcfb72bc1880d0cf19822eb0a2e6577ab62",
|
|
1177
|
-
// standard L2 WETH address (example, verify if custom)
|
|
1178
|
-
decimals: 18,
|
|
1179
|
-
logoUrl: "https://katana.network/assets/weth-logo.svg"
|
|
1180
|
-
},
|
|
1181
|
-
publicRpcUrl: "https://rpc.katanarpc.com",
|
|
1182
|
-
logoUrl: "https://katana.network/assets/katana-logo.svg",
|
|
1183
|
-
explorer: "https://explorer.katana.garden",
|
|
1184
|
-
// placeholder — replace with actual if known
|
|
1185
|
-
eip1559: !0
|
|
1186
|
-
},
|
|
1187
|
-
bera: {
|
|
1188
|
-
id: 80094,
|
|
1189
|
-
name: "Bera",
|
|
1190
|
-
shortname: "bera",
|
|
1191
|
-
native: {
|
|
1192
|
-
address: U,
|
|
1193
|
-
symbol: "BERA",
|
|
1194
|
-
decimals: 18,
|
|
1195
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/24647.png"
|
|
1196
|
-
},
|
|
1197
|
-
wToken: {
|
|
1198
|
-
symbol: "WBERA",
|
|
1199
|
-
address: "0x6969696969696969696969696969696969696969",
|
|
1200
|
-
// standard L2 WETH address (example, verify if custom)
|
|
1201
|
-
decimals: 18,
|
|
1202
|
-
logoUrl: "https://berascan.com/token/images/wrappedbera_ofc_64.png"
|
|
1203
|
-
},
|
|
1204
|
-
publicRpcUrl: "https://rpc.berachain.com",
|
|
1205
|
-
logoUrl: "https://berascan.com/token/images/wrappedbera_ofc_64.png",
|
|
1206
|
-
explorer: "https://berascan.com",
|
|
1207
|
-
// placeholder — replace with actual if known
|
|
1208
|
-
eip1559: !0
|
|
1209
|
-
},
|
|
1210
|
-
monad: {
|
|
1211
|
-
id: 143,
|
|
1212
|
-
name: "Monad",
|
|
1213
|
-
shortname: "monad",
|
|
1214
|
-
native: {
|
|
1215
|
-
address: U,
|
|
1216
|
-
symbol: "MONAD",
|
|
1217
|
-
decimals: 18,
|
|
1218
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png"
|
|
1219
|
-
},
|
|
1220
|
-
wToken: {
|
|
1221
|
-
symbol: "WMON",
|
|
1222
|
-
address: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a",
|
|
1223
|
-
decimals: 18,
|
|
1224
|
-
logoUrl: "https://assets.coingecko.com/coins/images/70784/standard/wmon.png?1766028904"
|
|
1225
|
-
},
|
|
1226
|
-
publicRpcUrl: "https://monad-mainnet.drpc.org",
|
|
1227
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png",
|
|
1228
|
-
explorer: "https://monad.network",
|
|
1229
|
-
eip1559: !0
|
|
1230
|
-
},
|
|
1231
|
-
optimism: {
|
|
1232
|
-
id: 10,
|
|
1233
|
-
name: "Optimism",
|
|
1234
|
-
shortname: "optimism",
|
|
1235
|
-
native: {
|
|
1236
|
-
address: U,
|
|
1237
|
-
symbol: "ETH",
|
|
1238
|
-
decimals: 18,
|
|
1239
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png"
|
|
1240
|
-
},
|
|
1241
|
-
wToken: {
|
|
1242
|
-
symbol: "WETH",
|
|
1243
|
-
address: "0x4200000000000000000000000000000000000006",
|
|
1244
|
-
decimals: 18,
|
|
1245
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/2396.png"
|
|
1246
|
-
},
|
|
1247
|
-
publicRpcUrl: "https://optimism.blockscout.com",
|
|
1248
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png",
|
|
1249
|
-
explorer: "https://optimistic.etherscan.io",
|
|
1250
|
-
eip1559: !0
|
|
1251
|
-
},
|
|
1252
|
-
mantle: {
|
|
1253
|
-
id: 5e3,
|
|
1254
|
-
name: "Mantle",
|
|
1255
|
-
shortname: "mantle",
|
|
1256
|
-
native: {
|
|
1257
|
-
address: U,
|
|
1258
|
-
symbol: "MNT",
|
|
1259
|
-
decimals: 18,
|
|
1260
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png"
|
|
1261
|
-
},
|
|
1262
|
-
wToken: {
|
|
1263
|
-
symbol: "WMNT",
|
|
1264
|
-
address: "0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8",
|
|
1265
|
-
decimals: 18,
|
|
1266
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/27614.png"
|
|
1267
|
-
},
|
|
1268
|
-
publicRpcUrl: "https://rpc.mantle.xyz",
|
|
1269
|
-
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png",
|
|
1270
|
-
explorer: "https://mantlescan.xyz",
|
|
1271
|
-
eip1559: !0
|
|
1272
|
-
}
|
|
1273
|
-
}, Gt = "2.8.1", Ne = {
|
|
1274
|
-
version: Gt
|
|
1275
|
-
}, Re = "https://order-sink.orbs.network", Ue = "https://order-sink-v2.orbs.network", Xe = Ne.version.split(".")[0], jt = () => Number(Xe) >= 2 ? Ue : Re, Xt = () => `${Ue}/config`, Zt = () => Number(Xe) >= 2 ? [Ue, Re] : [Re], Yt = {
|
|
1276
|
-
[J.Thena]: ["0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"],
|
|
1277
|
-
[J.Katana]: [
|
|
1278
|
-
"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df"
|
|
1279
|
-
]
|
|
1280
|
-
}, Qt = ({
|
|
1281
|
-
endpoint: e,
|
|
1282
|
-
exchange: t,
|
|
1283
|
-
partner: n
|
|
1284
|
-
}) => {
|
|
1285
|
-
const s = [Re, Ue].includes(e) && n ? Yt[n] || [] : [], c = t ? [t, ...s] : s;
|
|
1286
|
-
return c.filter(
|
|
1287
|
-
(y, E) => c.findIndex(
|
|
1288
|
-
(D) => D.toLowerCase() === y.toLowerCase()
|
|
1289
|
-
) === E
|
|
889
|
+
var Ge = Lt();
|
|
890
|
+
const Ut = new Set(Object.values(Q)), $t = (e) => Ut.has(e), At = () => {
|
|
891
|
+
var n;
|
|
892
|
+
const e = Ge.raw, t = ((n = e["*"]) == null ? void 0 : n.dex) ?? {};
|
|
893
|
+
return Object.entries(e).flatMap(([i, a]) => {
|
|
894
|
+
if (i === "*") return [];
|
|
895
|
+
const d = Number(i);
|
|
896
|
+
if (!Number.isSafeInteger(d)) return [];
|
|
897
|
+
const m = { ...t, ...(a == null ? void 0 : a.dex) ?? {} };
|
|
898
|
+
return Object.keys(m).filter($t).filter((b) => !!Ge.config(d, b)).map((b) => ({ chainId: d, name: b }));
|
|
899
|
+
}).sort(
|
|
900
|
+
(i, a) => i.name.localeCompare(a.name) || i.chainId - a.chainId
|
|
1290
901
|
);
|
|
1291
|
-
},
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
nn,
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
902
|
+
}, Kt = { chainName: "ftm", chainId: 250, twapVersion: 4, twapAddress: "0xd3B290FEB04E353d1821bc0a12397FdEa9a846C0", lensAddress: "0x0221EfDF1Fd3212AF87F23cceB7693a65fAF1d7f", takers: ["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913", "0x504f6E10173249dD22491829D98862Cf81DeF79E"], bidDelaySeconds: 60, minChunkSizeUsd: 10, name: "SpookySwap", partner: "Orbs:TWAP:SpookySwap", exchangeAddress: "0xdF7CCd5fc7077E9de5f27a7b7bfDC837c82f8496", exchangeType: "ExchangeV2", pathfinderKey: "" }, Vt = { chainName: "sonic", chainId: 146, twapVersion: 4, twapAddress: "0x8963992816b4EafE5a22b7DB2A99513c18be9afA", lensAddress: "0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D", takers: ["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913", "0x504f6E10173249dD22491829D98862Cf81DeF79E"], bidDelaySeconds: 60, minChunkSizeUsd: 10, name: "SpookySwapSonic", partner: "Orbs:TWAP:SpookySwap", exchangeAddress: "0x6699bE3aF75e5c1B807b1031dBde6dA9A67739F3", exchangeType: "ExchangeV2", pathfinderKey: "" }, Gt = { chainName: "poly", chainId: 137, twapVersion: 4, twapAddress: "0x688C027B0f7FaCeFcBa73e472900d28c12C5bDF4", lensAddress: "0xe0D4E736fc76af7C256ae7652c8c1e850bfb7849", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 10, name: "QuickSwap", partner: "Orbs:TWAP:QuickSwap", exchangeAddress: "0x8FCc245209bE85C49D738D0CE5613F74E5d91E86", exchangeType: "ParaswapExchange", pathfinderKey: "QuickSwap,QuickSwapV3" }, qt = { chainName: "base", chainId: 8453, twapVersion: 4, twapAddress: "0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55", lensAddress: "0x6313188c1909b161074D62E43105faC9B756A23e", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 10, name: "QuickSwap", partner: "Orbs:TWAP:QuickSwap", exchangeAddress: "0xb7a3d74895bfd3aff6780525e36d79fcf26a895f", exchangeType: "ExchangeV2", pathfinderKey: "" }, Wt = { chainName: "bsc", chainId: 56, twapVersion: 4, twapAddress: "0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994", lensAddress: "0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "Thena", partner: "Orbs:TWAP:Thena", exchangeAddress: "0x2B2fABDbfa4a15da0d351F947C14F4520db0bDc1", exchangeType: "ExchangeV2", pathfinderKey: "43,47" }, zt = { chainName: "bsc", chainId: 56, twapVersion: 4, twapAddress: "0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994", lensAddress: "0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "PancakeSwap", partner: "Orbs:TWAP:PancakeSwap", exchangeAddress: "0x1A2bb6B75D58b740d88413ef4840D6fa3F637940", exchangeType: "P2Exchange", pathfinderKey: "" }, jt = { chainName: "arb", chainId: 42161, twapVersion: 4, twapAddress: "0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3", lensAddress: "0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "PancakeSwap", partner: "Orbs:TWAP:PancakeSwap", exchangeAddress: "0xb37cB9A058c03081Ae6EF934313588cD53d408e7", exchangeType: "P2Exchange", pathfinderKey: "" }, Xt = { chainName: "base", chainId: 8453, twapVersion: 4, twapAddress: "0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55", lensAddress: "0x6313188c1909b161074D62E43105faC9B756A23e", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "PancakeSwap", partner: "Orbs:TWAP:PancakeSwap", exchangeAddress: "0xb37cB9A058c03081Ae6EF934313588cD53d408e7", exchangeType: "P2Exchange", pathfinderKey: "" }, Ht = { chainName: "linea", chainId: 59144, twapVersion: 4, twapAddress: "0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78", lensAddress: "0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 100, name: "PancakeSwap", partner: "Orbs:TWAP:PancakeSwap", exchangeAddress: "0xb37cB9A058c03081Ae6EF934313588cD53d408e7", exchangeType: "P2Exchange", pathfinderKey: "" }, Yt = { chainName: "linea", chainId: 59144, twapVersion: 4, twapAddress: "0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78", lensAddress: "0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 100, name: "Lynex", partner: "Orbs:TWAP:Lynex", exchangeAddress: "0x04C06C96d7D19977156016DD408B5992af0570a2", exchangeType: "ExchangeV2", pathfinderKey: "19,18" }, Zt = { chainName: "arb", chainId: 42161, twapVersion: 4, twapAddress: "0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3", lensAddress: "0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "SushiArb", partner: "Orbs:TWAP:Sushi", exchangeAddress: "0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad", exchangeType: "ExchangeV2", pathfinderKey: "" }, Qt = { chainName: "base", chainId: 8453, twapVersion: 4, twapAddress: "0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55", lensAddress: "0x6313188c1909b161074D62E43105faC9B756A23e", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "SushiBase", partner: "Orbs:TWAP:Sushi", exchangeAddress: "0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad", exchangeType: "ExchangeV2", pathfinderKey: "" }, Jt = { chainName: "eth", chainId: 1, twapVersion: 4, twapAddress: "0xb1ed8BCAD1EaC8a1DF0764700472391800D12946", lensAddress: "0x0967f448c4d4dbd14c355E635AE9CbF68cc44A60", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 200, name: "SushiEth", partner: "Orbs:TWAP:Sushi", exchangeAddress: "0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad", exchangeType: "ExchangeV2", pathfinderKey: "" }, en = { chainName: "katana", chainId: 747474, twapVersion: 4, twapAddress: "0xf2d96E7BE676153d202e1453804E2749923C7c5b", lensAddress: "0x1579EED0527781B1A748043AA1f59a3858Ace4a7", takers: ["0xF74437A3Fc45a518640828E5D6A3E8c9A9BbDC3a", "0x07A6C715063e94c0D95e809efefFCbF4EBEdfD55"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "SushiKatana", partner: "Orbs:TWAP:Sushi", exchangeAddress: "0x92209481507e6B2d14C9b5b70Ed287024177220E", exchangeType: "ExchangeV2", pathfinderKey: "" }, tn = { chainId: 1329, name: "DragonSwap" }, nn = { chainName: "flare", chainId: 14, twapVersion: 4, twapAddress: "0x9D70B0b90915Bb8b9bdAC7e6a7e6435bBF1feC4D", lensAddress: "0xf2d96E7BE676153d202e1453804E2749923C7c5b", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 10, name: "SparkDEX", partner: "Orbs:TWAP:SparkDEX", exchangeAddress: "0xe59c53C76bB7EEc01401A18fA8215B94bC65Bf56", exchangeType: "P2Exchange" }, rn = { chainName: "sonic", chainId: 146, twapVersion: 4, twapAddress: "0x8963992816b4EafE5a22b7DB2A99513c18be9afA", lensAddress: "0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D", takers: ["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913", "0x504f6E10173249dD22491829D98862Cf81DeF79E"], bidDelaySeconds: 60, minChunkSizeUsd: 10, name: "SwapX", partner: "Orbs:TWAP:SwapX", exchangeAddress: "0xDA902994b7F7a1ecDd8De02E4a17dbFF2E6F67b7", exchangeType: "ExchangeV2", pathfinderKey: "" }, an = { chainName: "avax", chainId: 43114, twapVersion: 4, twapAddress: "0xf77Ad005aBF7e31f669ce89a6568B2f39Ca92cDe", lensAddress: "0x48466B82Ce1575c5c9eCa168ac1090048dD47fA3", takers: ["0xA05405b6340A7F43dC5835351BFC4f5b1F028359", "0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"], bidDelaySeconds: 60, minChunkSizeUsd: 50, name: "BlackholeAvax", partner: "Orbs:TWAP:BlackholeAvax", exchangeAddress: "0xb7A3d74895bFD3Aff6780525e36D79FCf26a895F", exchangeType: "ExchangeV2" }, _ = {
|
|
903
|
+
SpookySwap: Kt,
|
|
904
|
+
SpookySwapSonic: Vt,
|
|
905
|
+
QuickSwap: Gt,
|
|
906
|
+
QuickSwapBase: qt,
|
|
907
|
+
Thena: Wt,
|
|
908
|
+
PancakeSwap: zt,
|
|
909
|
+
PancakeSwapArbitrum: jt,
|
|
910
|
+
PancakeSwapBase: Xt,
|
|
911
|
+
PancakeSwapLinea: Ht,
|
|
912
|
+
Lynex: Yt,
|
|
913
|
+
SushiArb: Zt,
|
|
914
|
+
SushiBase: Qt,
|
|
915
|
+
SushiEth: Jt,
|
|
916
|
+
SushiKatana: en,
|
|
917
|
+
DragonSwap: tn,
|
|
918
|
+
SparkDEX: nn,
|
|
919
|
+
SwapX: rn,
|
|
920
|
+
BlackholeAvax: an
|
|
921
|
+
}, tt = (e) => `https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`, sn = "https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-flare/prod/gn", ie = "https://hub.orbs.network/api/apikey/subgraphs/id", on = {
|
|
922
|
+
1: `${ie}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,
|
|
923
|
+
14: sn,
|
|
924
|
+
56: `${ie}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,
|
|
925
|
+
137: `${ie}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,
|
|
926
|
+
146: `${ie}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,
|
|
927
|
+
250: `${ie}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,
|
|
928
|
+
388: tt("cronos-zkevm"),
|
|
929
|
+
1329: `${ie}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,
|
|
930
|
+
8453: `${ie}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,
|
|
931
|
+
42161: `${ie}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,
|
|
932
|
+
43114: `${ie}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,
|
|
933
|
+
59144: `${ie}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,
|
|
934
|
+
80094: tt("berachain"),
|
|
935
|
+
747474: `${ie}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`
|
|
936
|
+
}, W = (e) => `${e.name}_${e.chainId}`, dn = {
|
|
937
|
+
[W(_.SushiArb)]: [
|
|
1315
938
|
"0x846F2B29ef314bF3D667981b4ffdADc5B858312a",
|
|
1316
939
|
"0x08c41f5D1C844061f6D952E25827eeAA576c6536"
|
|
1317
940
|
],
|
|
1318
|
-
[
|
|
941
|
+
[W(_.SushiBase)]: [
|
|
1319
942
|
"0x846F2B29ef314bF3D667981b4ffdADc5B858312a",
|
|
1320
943
|
"0x08c41f5D1C844061f6D952E25827eeAA576c6536"
|
|
1321
944
|
],
|
|
1322
|
-
[
|
|
945
|
+
[W(_.SushiEth)]: [
|
|
1323
946
|
"0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA",
|
|
1324
947
|
"0x08c41f5D1C844061f6D952E25827eeAA576c6536"
|
|
1325
948
|
],
|
|
1326
|
-
[
|
|
949
|
+
[W(_.PancakeSwap)]: [
|
|
1327
950
|
"0xb2BAFe188faD927240038cC4FfF2d771d8A58905",
|
|
1328
951
|
"0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"
|
|
1329
952
|
],
|
|
1330
|
-
[
|
|
953
|
+
[W(_.PancakeSwapArbitrum)]: [
|
|
1331
954
|
"0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F",
|
|
1332
955
|
"0x807488ADAD033e95C438F998277bE654152594dc"
|
|
1333
956
|
],
|
|
1334
|
-
[
|
|
957
|
+
[W(_.PancakeSwapBase)]: [
|
|
1335
958
|
"0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c",
|
|
1336
959
|
"0x3A9df3eE209b802D0337383f5abCe3204d623588"
|
|
1337
960
|
],
|
|
1338
|
-
[
|
|
961
|
+
[W(_.PancakeSwapLinea)]: [
|
|
1339
962
|
"0x3A9df3eE209b802D0337383f5abCe3204d623588"
|
|
1340
963
|
],
|
|
1341
|
-
[
|
|
964
|
+
[W(_.QuickSwap)]: [
|
|
1342
965
|
"0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"
|
|
1343
966
|
],
|
|
1344
|
-
[
|
|
967
|
+
[W(_.Thena)]: [
|
|
1345
968
|
"0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"
|
|
1346
969
|
],
|
|
1347
|
-
[
|
|
970
|
+
[W(_.Lynex)]: [
|
|
1348
971
|
"0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"
|
|
1349
972
|
],
|
|
1350
|
-
[
|
|
973
|
+
[W(_.DragonSwap)]: [
|
|
1351
974
|
"0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"
|
|
1352
975
|
],
|
|
1353
|
-
[
|
|
976
|
+
[W(_.SpookySwapSonic)]: [
|
|
1354
977
|
"0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"
|
|
1355
978
|
],
|
|
1356
|
-
[
|
|
979
|
+
[W(_.SpookySwap)]: [
|
|
1357
980
|
"0x3924d62219483015f982b160d48c0fa5Fd436Cba"
|
|
1358
981
|
],
|
|
1359
|
-
[
|
|
982
|
+
[W(_.SwapX)]: [
|
|
1360
983
|
"0xE5012eBDe5e26EE3Ea41992154731a03023CF274"
|
|
1361
984
|
],
|
|
1362
|
-
[
|
|
985
|
+
[W(_.SushiKatana)]: [
|
|
1363
986
|
"0x92209481507e6B2d14C9b5b70Ed287024177220E"
|
|
1364
987
|
],
|
|
1365
|
-
[
|
|
988
|
+
[W(_.SparkDEX)]: [
|
|
1366
989
|
"0xe59c53C76bB7EEc01401A18fA8215B94bC65Bf56"
|
|
1367
990
|
]
|
|
1368
|
-
},
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
991
|
+
}, cn = (e) => dn[W(e)] ?? [], de = (e) => new Map(e.map((t) => [t.chainId, t])), un = {
|
|
992
|
+
[Q.Pancake]: de([
|
|
993
|
+
_.PancakeSwap,
|
|
994
|
+
_.PancakeSwapArbitrum,
|
|
995
|
+
_.PancakeSwapBase,
|
|
996
|
+
_.PancakeSwapLinea
|
|
997
|
+
]),
|
|
998
|
+
[Q.Sushiswap]: de([
|
|
999
|
+
_.SushiEth,
|
|
1000
|
+
_.SushiArb,
|
|
1001
|
+
_.SushiBase,
|
|
1002
|
+
_.SushiKatana
|
|
1003
|
+
]),
|
|
1004
|
+
[Q.Quick]: de([
|
|
1005
|
+
_.QuickSwap,
|
|
1006
|
+
_.QuickSwapBase
|
|
1007
|
+
]),
|
|
1008
|
+
[Q.Thena]: de([_.Thena]),
|
|
1009
|
+
[Q.Spooky]: de([
|
|
1010
|
+
_.SpookySwap,
|
|
1011
|
+
_.SpookySwapSonic
|
|
1012
|
+
]),
|
|
1013
|
+
[Q.Lynex]: de([_.Lynex]),
|
|
1014
|
+
[Q.Swapx]: de([_.SwapX]),
|
|
1015
|
+
[Q.Blackhole]: de([_.BlackholeAvax]),
|
|
1016
|
+
[Q.Spark]: de([_.SparkDEX]),
|
|
1017
|
+
[Q.Katana]: de([_.SushiKatana])
|
|
1018
|
+
}, ln = (e, t) => {
|
|
1019
|
+
var n;
|
|
1020
|
+
return (n = un[e]) == null ? void 0 : n.get(t);
|
|
1021
|
+
}, fn = (e) => e.bidDelaySeconds * 1e3 * 2, be = (e, t) => {
|
|
1372
1022
|
if (e == null || !t) return "";
|
|
1373
|
-
const n =
|
|
1374
|
-
return
|
|
1023
|
+
const n = x(10).pow(e);
|
|
1024
|
+
return x(t).times(n).idiv(n).div(n).toFixed();
|
|
1375
1025
|
};
|
|
1376
|
-
|
|
1377
|
-
h(1);
|
|
1378
|
-
h(10);
|
|
1379
|
-
h(1e18);
|
|
1380
|
-
function xe(e, t) {
|
|
1026
|
+
function ke(e, t) {
|
|
1381
1027
|
return e == t || e.toLowerCase() == t.toLowerCase();
|
|
1382
1028
|
}
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1029
|
+
const pn = (e) => Rt.some(
|
|
1030
|
+
(t) => ke(t, e || "")
|
|
1031
|
+
);
|
|
1032
|
+
function An(e) {
|
|
1385
1033
|
return [
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
].find((n) => n <= e) ||
|
|
1034
|
+
se.Years,
|
|
1035
|
+
se.Months,
|
|
1036
|
+
se.Weeks,
|
|
1037
|
+
se.Days,
|
|
1038
|
+
se.Hours,
|
|
1039
|
+
se.Minutes
|
|
1040
|
+
].find((n) => n <= e) || se.Minutes;
|
|
1393
1041
|
}
|
|
1394
|
-
const
|
|
1395
|
-
const n = Ce(t);
|
|
1396
|
-
return !n || !Le(e.address) ? e : n.wToken;
|
|
1397
|
-
}, jr = (e, t, n) => {
|
|
1398
|
-
var s;
|
|
1399
|
-
const a = (s = Ce(n)) == null ? void 0 : s.wToken.address;
|
|
1400
|
-
return !!(Le(e == null ? void 0 : e.address) && a && xe((t == null ? void 0 : t.address) || "", a));
|
|
1401
|
-
}, Xr = (e, t, n) => {
|
|
1402
|
-
var s;
|
|
1403
|
-
const a = (s = Ce(n)) == null ? void 0 : s.wToken.address;
|
|
1404
|
-
return !!(a && xe((e == null ? void 0 : e.address) || "", a) && Le(t == null ? void 0 : t.address));
|
|
1405
|
-
}, Zr = (e) => {
|
|
1042
|
+
const he = (e) => e ? e.value * e.unit : 0, yn = (e) => !e || e === "NaN" ? "0" : x(e).decimalPlaces(0).toFixed(), Kr = (e) => {
|
|
1406
1043
|
const t = [e];
|
|
1407
1044
|
return typeof e == "object" && e !== null && t.push(Reflect.get(e, "error"), Reflect.get(e, "cause")), t.some((n) => {
|
|
1408
1045
|
if (typeof n != "object" || n === null)
|
|
1409
|
-
return typeof n == "string" &&
|
|
1410
|
-
const
|
|
1411
|
-
if (
|
|
1046
|
+
return typeof n == "string" && nt(n);
|
|
1047
|
+
const i = Reflect.get(n, "code");
|
|
1048
|
+
if (i === 4001 || i === "4001" || i === "ACTION_REJECTED" || i === "USER_REJECTED" || i === "USER_DENIED")
|
|
1412
1049
|
return !0;
|
|
1413
|
-
const
|
|
1414
|
-
return typeof
|
|
1050
|
+
const a = Reflect.get(n, "message");
|
|
1051
|
+
return typeof a == "string" && nt(a);
|
|
1415
1052
|
});
|
|
1416
|
-
},
|
|
1053
|
+
}, nt = (e) => /\buser\b.{0,80}\b(?:rejected|denied|cancelled|canceled)\b/i.test(
|
|
1417
1054
|
e
|
|
1418
1055
|
) || /\brequest\b\s+(?:was\s+)?\b(?:rejected|denied|cancelled|canceled)\b/i.test(
|
|
1419
1056
|
e
|
|
1420
1057
|
) || /\b(?:rejected|denied|cancelled|canceled)\b.{0,80}\bby\s+(?:the\s+)?user\b/i.test(
|
|
1421
1058
|
e
|
|
1422
|
-
),
|
|
1423
|
-
var a;
|
|
1424
|
-
const n = (a = Ce(t)) == null ? void 0 : a.explorer;
|
|
1425
|
-
return n && e ? `${n}/tx/${e}` : "";
|
|
1426
|
-
}, pn = (e) => {
|
|
1059
|
+
), En = (e) => {
|
|
1427
1060
|
if (!e) return;
|
|
1428
|
-
const t = e.
|
|
1429
|
-
[...
|
|
1061
|
+
const t = e.flatMap(cn), n = e.map((a) => a.exchangeAddress), i = new Set(
|
|
1062
|
+
[...n, ...t].map((a) => a.toLowerCase())
|
|
1430
1063
|
);
|
|
1431
|
-
return Array.from(
|
|
1432
|
-
},
|
|
1433
|
-
if (!
|
|
1064
|
+
return Array.from(i);
|
|
1065
|
+
}, Vr = (e, t) => e.version === 1 ? (e.fillDelay || 0) * 1e3 + (t ? fn(t) : 0) : e.fillDelay || 0, Gr = (e) => At().filter((t) => t.name === e).map((t) => t.chainId), qr = (e = "", t = "", n = 18, i = 18) => {
|
|
1066
|
+
if (!x(e || 0).gt(0) || !x(t || 0).gt(0))
|
|
1434
1067
|
return "";
|
|
1435
|
-
const
|
|
1436
|
-
return
|
|
1437
|
-
},
|
|
1068
|
+
const a = be(n, e), d = be(i, t);
|
|
1069
|
+
return x(d).div(a).toFixed();
|
|
1070
|
+
}, Wr = (e, t, n) => {
|
|
1438
1071
|
if (e.type === N.TWAP_MARKET) return "";
|
|
1439
|
-
const
|
|
1440
|
-
return
|
|
1441
|
-
},
|
|
1072
|
+
const i = be(t, e.srcAmountPerTrade), a = be(n, e.dstMinAmountPerTrade);
|
|
1073
|
+
return x(a).div(i).toFixed();
|
|
1074
|
+
}, zr = (e, t, n) => {
|
|
1442
1075
|
if (e.type === N.TWAP_MARKET) return "";
|
|
1443
|
-
const
|
|
1444
|
-
return
|
|
1445
|
-
},
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
}, yn = (e, t, n, a) => {
|
|
1455
|
-
if (e === _.TWAP || e === _.LIMIT)
|
|
1456
|
-
return "0";
|
|
1457
|
-
if (a == null || !t || !n) return;
|
|
1458
|
-
const s = h(t).times(h(n)), c = h(10).pow(a), y = s.div(c);
|
|
1459
|
-
return h.max(1, y).integerValue(h.ROUND_FLOOR).toFixed(0) || "0";
|
|
1460
|
-
}, hn = (e, t, n, a) => {
|
|
1461
|
-
const s = ye(n) * 2 * t;
|
|
1462
|
-
if (a)
|
|
1463
|
-
return a;
|
|
1464
|
-
if (e === _.LIMIT)
|
|
1465
|
-
return { unit: de.Days, value: 7 };
|
|
1466
|
-
if (e === _.STOP_LOSS || e === _.TAKE_PROFIT)
|
|
1467
|
-
return { unit: de.Days, value: 1 };
|
|
1468
|
-
const c = ln(s);
|
|
1469
|
-
return { unit: c, value: Number(h(s / c).toFixed(2)) };
|
|
1470
|
-
}, En = (e, t, n) => t !== _.TWAP ? 1 : n !== void 0 ? n : Math.max(1, Math.ceil(e / 2)), gn = (e, t, n) => {
|
|
1076
|
+
const i = be(t, e.srcAmountPerTrade), a = be(n, e.triggerPricePerTrade);
|
|
1077
|
+
return x(a).div(i).toFixed();
|
|
1078
|
+
}, mn = (e, t, n, i) => {
|
|
1079
|
+
const a = he(n) * 2 * t;
|
|
1080
|
+
if (i) return i;
|
|
1081
|
+
if (e === v.LIMIT) return { unit: se.Days, value: 7 };
|
|
1082
|
+
if (e === v.STOP_LOSS || e === v.TAKE_PROFIT)
|
|
1083
|
+
return { unit: se.Days, value: 1 };
|
|
1084
|
+
const d = An(a);
|
|
1085
|
+
return { unit: d, value: Number(x(a / d).toFixed(2)) };
|
|
1086
|
+
}, bn = (e, t, n) => t !== v.TWAP ? 1 : n !== void 0 ? n : Math.max(1, Math.ceil(e / 2)), hn = (e, t, n) => {
|
|
1471
1087
|
if (!e || !t || !n) return 1;
|
|
1472
|
-
const
|
|
1473
|
-
return Math.max(1,
|
|
1474
|
-
},
|
|
1475
|
-
isError: !(e.unit ===
|
|
1476
|
-
value: Math.floor(
|
|
1477
|
-
}),
|
|
1478
|
-
isError:
|
|
1088
|
+
const a = x(t).times(e).div(n).integerValue(x.ROUND_FLOOR).toNumber();
|
|
1089
|
+
return Math.max(1, a);
|
|
1090
|
+
}, Tn = (e, t) => ({
|
|
1091
|
+
isError: !(e.unit === Ve.unit && e.value === Ve.value) && he(e) * t > Oe,
|
|
1092
|
+
value: Math.floor(Oe / t)
|
|
1093
|
+
}), xn = (e, t) => e === v.STOP_LOSS || e === v.TAKE_PROFIT ? {
|
|
1094
|
+
isError: he(t) > 5184e6,
|
|
1479
1095
|
value: 5184e6
|
|
1480
1096
|
} : {
|
|
1481
|
-
isError:
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
isError: n === _.TWAP && h(e).isGreaterThan(t),
|
|
1097
|
+
isError: he(t) > Oe,
|
|
1098
|
+
value: Oe
|
|
1099
|
+
}, gn = (e) => ({
|
|
1100
|
+
isError: he(e) < Je,
|
|
1101
|
+
value: Je
|
|
1102
|
+
}), Dn = (e) => ({
|
|
1103
|
+
isError: he(e) < Ke,
|
|
1104
|
+
value: Ke
|
|
1105
|
+
}), Fn = (e, t, n) => ({
|
|
1106
|
+
isError: n === v.TWAP && x(e).isGreaterThan(t),
|
|
1492
1107
|
value: t
|
|
1493
|
-
}),
|
|
1494
|
-
if (e === J.Pancake)
|
|
1495
|
-
switch (t) {
|
|
1496
|
-
case 56:
|
|
1497
|
-
return v.PancakeSwap;
|
|
1498
|
-
case 42161:
|
|
1499
|
-
return v.PancakeSwapArbitrum;
|
|
1500
|
-
case 8453:
|
|
1501
|
-
return v.PancakeSwapBase;
|
|
1502
|
-
case 59144:
|
|
1503
|
-
return v.PancakeSwapLinea;
|
|
1504
|
-
default:
|
|
1505
|
-
return v.PancakeSwap;
|
|
1506
|
-
}
|
|
1507
|
-
if (e === J.Sushiswap)
|
|
1508
|
-
switch (t) {
|
|
1509
|
-
case 1:
|
|
1510
|
-
return v.SushiEth;
|
|
1511
|
-
case 42161:
|
|
1512
|
-
return v.SushiArb;
|
|
1513
|
-
case 8453:
|
|
1514
|
-
return v.SushiBase;
|
|
1515
|
-
case 747474:
|
|
1516
|
-
return v.SushiKatana;
|
|
1517
|
-
default:
|
|
1518
|
-
return v.SushiEth;
|
|
1519
|
-
}
|
|
1520
|
-
if (e === J.Quick)
|
|
1521
|
-
switch (t) {
|
|
1522
|
-
case 137:
|
|
1523
|
-
return v.QuickSwap;
|
|
1524
|
-
case 8453:
|
|
1525
|
-
return v.QuickSwapBase;
|
|
1526
|
-
default:
|
|
1527
|
-
return v.QuickSwap;
|
|
1528
|
-
}
|
|
1529
|
-
if (e === J.Thena)
|
|
1530
|
-
switch (t) {
|
|
1531
|
-
case 56:
|
|
1532
|
-
return v.Thena;
|
|
1533
|
-
default:
|
|
1534
|
-
return v.Thena;
|
|
1535
|
-
}
|
|
1536
|
-
if (e === J.Spooky)
|
|
1537
|
-
switch (t) {
|
|
1538
|
-
case 250:
|
|
1539
|
-
return v.SpookySwap;
|
|
1540
|
-
case 146:
|
|
1541
|
-
return v.SpookySwapSonic;
|
|
1542
|
-
default:
|
|
1543
|
-
return v.SpookySwap;
|
|
1544
|
-
}
|
|
1545
|
-
if (e === J.Lynex)
|
|
1546
|
-
switch (t) {
|
|
1547
|
-
case 59144:
|
|
1548
|
-
return v.Lynex;
|
|
1549
|
-
default:
|
|
1550
|
-
return v.Lynex;
|
|
1551
|
-
}
|
|
1552
|
-
if (e === J.Swapx)
|
|
1553
|
-
switch (t) {
|
|
1554
|
-
case 146:
|
|
1555
|
-
return v.SwapX;
|
|
1556
|
-
default:
|
|
1557
|
-
return v.SwapX;
|
|
1558
|
-
}
|
|
1559
|
-
if (e === J.Blackhole)
|
|
1560
|
-
switch (t) {
|
|
1561
|
-
case 43114:
|
|
1562
|
-
return v.BlackholeAvax;
|
|
1563
|
-
default:
|
|
1564
|
-
return v.BlackholeAvax;
|
|
1565
|
-
}
|
|
1566
|
-
if (e === J.Spark)
|
|
1567
|
-
return v.SparkDEX;
|
|
1568
|
-
if (e === J.Katana)
|
|
1569
|
-
switch (t) {
|
|
1570
|
-
case 747474:
|
|
1571
|
-
return v.SushiKatana;
|
|
1572
|
-
default:
|
|
1573
|
-
return v.SushiKatana;
|
|
1574
|
-
}
|
|
1575
|
-
}, mt = () => {
|
|
1576
|
-
var n;
|
|
1577
|
-
const e = pt.raw, t = ((n = e["*"]) == null ? void 0 : n.dex) ?? {};
|
|
1578
|
-
return Object.entries(e).filter(([a]) => a !== "*").flatMap(([a, s]) => {
|
|
1579
|
-
const c = Number(a), y = { ...t, ...(s == null ? void 0 : s.dex) ?? {} };
|
|
1580
|
-
return !y || typeof y != "object" ? [] : Object.entries(y).flatMap(([E]) => mn(E, c) ? [
|
|
1581
|
-
{
|
|
1582
|
-
chainId: c,
|
|
1583
|
-
name: E
|
|
1584
|
-
}
|
|
1585
|
-
] : []);
|
|
1586
|
-
}).sort((a, s) => a.name.localeCompare(s.name));
|
|
1587
|
-
}, se = (e) => {
|
|
1588
|
-
if (!e) return "";
|
|
1589
|
-
const t = h(e);
|
|
1590
|
-
return t.isFinite() && !t.isNaN() ? e : "";
|
|
1591
|
-
}, At = (e, t) => {
|
|
1592
|
-
if (t == null || !e) return "";
|
|
1593
|
-
const n = h(e);
|
|
1594
|
-
return !n.isFinite() || n.isNaN() ? "" : n.multipliedBy(h(10).pow(t)).toFixed(0);
|
|
1595
|
-
}, Me = (e, t) => {
|
|
1596
|
-
if (t == null || !e) return "";
|
|
1597
|
-
const n = h(e);
|
|
1598
|
-
return !n.isFinite() || n.isNaN() ? "" : n.dividedBy(h(10).pow(t)).toFixed();
|
|
1599
|
-
}, Ze = (e, t) => {
|
|
1600
|
-
if (!e || !t) return "";
|
|
1601
|
-
const n = h(e), a = h(t);
|
|
1602
|
-
return !n.isFinite() || n.isNaN() || n.isZero() || !a.isFinite() || a.isNaN() || a.isZero() ? "" : n.multipliedBy(a).toFixed();
|
|
1603
|
-
}, bt = (e) => {
|
|
1604
|
-
const t = se(e.initialPrice);
|
|
1605
|
-
let n = "";
|
|
1606
|
-
if (e.typedValue !== void 0) {
|
|
1607
|
-
const c = h(e.typedValue), y = e.isInverted ? c.isZero() ? h(0) : h(1).dividedBy(c) : c;
|
|
1608
|
-
n = At(y.toFixed(), e.tokenDecimals);
|
|
1609
|
-
} else if (e.percentage !== void 0 && t && h(t).gt(0)) {
|
|
1610
|
-
const c = h(e.percentage || 0).dividedBy(100);
|
|
1611
|
-
n = h(t).plus(h(t).multipliedBy(c)).decimalPlaces(0).toFixed();
|
|
1612
|
-
} else t && h(t).gt(0) && (n = h(t).decimalPlaces(0).toFixed());
|
|
1613
|
-
const a = se(n);
|
|
1614
|
-
let s = "";
|
|
1615
|
-
if (t && !h(t).isZero()) {
|
|
1616
|
-
if (e.percentage !== void 0 && e.percentage !== null)
|
|
1617
|
-
s = e.percentage;
|
|
1618
|
-
else if (a) {
|
|
1619
|
-
const c = h(a).minus(t).dividedBy(t).multipliedBy(100).decimalPlaces(2).toString();
|
|
1620
|
-
s = h(c).isZero() ? "" : c;
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
return {
|
|
1624
|
-
raw: a,
|
|
1625
|
-
typedValue: e.typedValue,
|
|
1626
|
-
percentage: s,
|
|
1627
|
-
isTypedValue: e.typedValue !== void 0
|
|
1628
|
-
};
|
|
1629
|
-
}, yt = (e) => {
|
|
1630
|
-
const t = (c) => {
|
|
1631
|
-
if (!c) return "";
|
|
1632
|
-
const y = h(c);
|
|
1633
|
-
return y.isFinite() && !y.isNaN() ? c : "";
|
|
1634
|
-
};
|
|
1635
|
-
let n = "";
|
|
1636
|
-
if (e.typedValue !== void 0)
|
|
1637
|
-
n = t(e.typedValue);
|
|
1638
|
-
else {
|
|
1639
|
-
const c = Me(
|
|
1640
|
-
e.raw,
|
|
1641
|
-
e.amountDecimals ?? 18
|
|
1642
|
-
);
|
|
1643
|
-
c && !h(c).isZero() && (n = e.isInverted ? h(1).dividedBy(c).toFixed() : c);
|
|
1644
|
-
}
|
|
1645
|
-
const a = n ? e.isInverted ? t(
|
|
1646
|
-
At(n, e.invertedAmountDecimals ?? 18)
|
|
1647
|
-
) : t(e.raw) : "", s = e.isInverted ? e.invertedAmountUsdPrice : e.amountUsdPrice;
|
|
1648
|
-
return {
|
|
1649
|
-
raw: a,
|
|
1650
|
-
ui: n,
|
|
1651
|
-
usd: Ze(n, s)
|
|
1652
|
-
};
|
|
1653
|
-
}, ra = (e) => {
|
|
1654
|
-
if (e === void 0 || e === "") return e;
|
|
1655
|
-
const t = h(e);
|
|
1656
|
-
return !t.isFinite() || t.isNaN() || t.isZero() ? "0" : h(1).dividedBy(t).toFixed();
|
|
1657
|
-
}, Pn = (e) => {
|
|
1658
|
-
if (e === _.STOP_LOSS) return sn;
|
|
1659
|
-
if (e === _.TAKE_PROFIT) return on;
|
|
1660
|
-
}, On = (e, t) => {
|
|
1661
|
-
if (!t) {
|
|
1662
|
-
if (e === _.STOP_LOSS)
|
|
1663
|
-
return cn;
|
|
1664
|
-
if (e === _.TAKE_PROFIT)
|
|
1665
|
-
return dn;
|
|
1666
|
-
}
|
|
1667
|
-
}, vn = (e, t, n, a) => {
|
|
1668
|
-
if (!(h(t || "0").isZero() || !n || e !== _.STOP_LOSS && e !== _.TAKE_PROFIT)) {
|
|
1669
|
-
if (e === _.STOP_LOSS && h(a || 0).gte(n))
|
|
1670
|
-
return {
|
|
1671
|
-
type: ee.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,
|
|
1672
|
-
value: n
|
|
1673
|
-
};
|
|
1674
|
-
if (e === _.TAKE_PROFIT && h(a || 0).lte(n))
|
|
1675
|
-
return {
|
|
1676
|
-
type: ee.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,
|
|
1677
|
-
value: n
|
|
1678
|
-
};
|
|
1679
|
-
if (!a || h(a).isZero())
|
|
1680
|
-
return {
|
|
1681
|
-
type: ee.EMPTY_TRIGGER_PRICE,
|
|
1682
|
-
value: a
|
|
1683
|
-
};
|
|
1684
|
-
}
|
|
1685
|
-
}, _n = (e) => {
|
|
1686
|
-
const t = e.module === _.STOP_LOSS || e.module === _.TAKE_PROFIT, n = e.triggerPricePercent === void 0 ? Pn(e.module) : e.triggerPricePercent, a = bt({
|
|
1687
|
-
tokenDecimals: e.outputTokenDecimals,
|
|
1688
|
-
initialPrice: t ? e.marketPrice : void 0,
|
|
1689
|
-
typedValue: e.triggerPrice,
|
|
1690
|
-
percentage: n,
|
|
1691
|
-
isInverted: e.isInverted
|
|
1692
|
-
}), s = yt({
|
|
1693
|
-
raw: a.raw,
|
|
1694
|
-
typedValue: a.typedValue,
|
|
1695
|
-
amountDecimals: e.outputTokenDecimals,
|
|
1696
|
-
invertedAmountDecimals: e.inputTokenDecimals,
|
|
1697
|
-
amountUsdPrice: e.outputUsdPrice,
|
|
1698
|
-
invertedAmountUsdPrice: e.inputUsdPrice,
|
|
1699
|
-
isInverted: e.isInverted
|
|
1700
|
-
});
|
|
1701
|
-
return {
|
|
1702
|
-
...a,
|
|
1703
|
-
enabled: t,
|
|
1704
|
-
display: s,
|
|
1705
|
-
error: vn(
|
|
1706
|
-
e.module,
|
|
1707
|
-
e.inputAmountWei,
|
|
1708
|
-
se(e.marketPrice),
|
|
1709
|
-
a.raw
|
|
1710
|
-
)
|
|
1711
|
-
};
|
|
1712
|
-
}, Rn = (e, t, n) => {
|
|
1713
|
-
if (!(h(e.inputAmountWei || "0").isZero() || !t || e.isMarketOrder)) {
|
|
1714
|
-
if ((e.module === _.STOP_LOSS || e.module === _.TAKE_PROFIT) && e.triggerPrice && h(n || 0).gte(e.triggerPrice))
|
|
1715
|
-
return {
|
|
1716
|
-
type: ee.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,
|
|
1717
|
-
value: e.triggerPrice
|
|
1718
|
-
};
|
|
1719
|
-
if (!n || h(n).isZero())
|
|
1720
|
-
return {
|
|
1721
|
-
type: ee.MISSING_LIMIT_PRICE,
|
|
1722
|
-
value: n
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
}, In = (e) => {
|
|
1726
|
-
const t = e.limitPricePercent === void 0 ? On(e.module, e.isMarketOrder) : e.limitPricePercent, n = bt({
|
|
1727
|
-
tokenDecimals: e.outputTokenDecimals,
|
|
1728
|
-
initialPrice: e.marketPrice,
|
|
1729
|
-
typedValue: e.limitPrice,
|
|
1730
|
-
percentage: t,
|
|
1731
|
-
isInverted: e.isInverted
|
|
1732
|
-
}), a = yt({
|
|
1733
|
-
raw: n.raw,
|
|
1734
|
-
typedValue: n.typedValue,
|
|
1735
|
-
amountDecimals: e.outputTokenDecimals,
|
|
1736
|
-
invertedAmountDecimals: e.inputTokenDecimals,
|
|
1737
|
-
amountUsdPrice: e.outputUsdPrice,
|
|
1738
|
-
invertedAmountUsdPrice: e.inputUsdPrice,
|
|
1739
|
-
isInverted: e.isInverted
|
|
1740
|
-
}), s = se(e.marketPrice);
|
|
1741
|
-
return {
|
|
1742
|
-
...n,
|
|
1743
|
-
display: a,
|
|
1744
|
-
error: Rn(e, s, n.raw)
|
|
1745
|
-
};
|
|
1746
|
-
}, Mn = (e, t) => e === _.LIMIT ? N.LIMIT : e === _.STOP_LOSS ? t ? N.STOP_LOSS_MARKET : N.STOP_LOSS_LIMIT : e === _.TAKE_PROFIT ? t ? N.TAKE_PROFIT_MARKET : N.TAKE_PROFIT_LIMIT : t ? N.TWAP_MARKET : N.TWAP_LIMIT, Nn = ({
|
|
1747
|
-
module: e,
|
|
1748
|
-
isMarketOrder: t,
|
|
1749
|
-
marketPrice: n,
|
|
1750
|
-
limitPrice: a,
|
|
1751
|
-
triggerPrice: s
|
|
1752
|
-
}) => e === _.LIMIT || !t ? se(a) : e === _.STOP_LOSS || e === _.TAKE_PROFIT ? se(s) : se(n), Un = (e, t) => !e || !t ? "" : h(e).multipliedBy(t).decimalPlaces(0).toFixed(), Ln = (e, t) => {
|
|
1108
|
+
}), Cn = (e, t) => {
|
|
1753
1109
|
const n = Number.isFinite(t) ? Math.floor(t) : 1;
|
|
1754
|
-
return e ===
|
|
1755
|
-
},
|
|
1110
|
+
return e === v.TWAP ? Math.max(1, n) : 1;
|
|
1111
|
+
}, rt = (e) => {
|
|
1756
1112
|
const t = e.unit * e.value;
|
|
1757
1113
|
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
1758
|
-
},
|
|
1759
|
-
const t =
|
|
1114
|
+
}, Bn = (e) => {
|
|
1115
|
+
const t = Cn(e.module, e.totalTrades), n = e.fillDelay ?? { ...Ve }, i = mn(
|
|
1760
1116
|
e.module,
|
|
1761
1117
|
t,
|
|
1762
1118
|
n,
|
|
@@ -1765,349 +1121,319 @@ const ye = (e) => e ? e.value * e.unit : 0, un = (e) => !e || e === "NaN" ? "0"
|
|
|
1765
1121
|
return {
|
|
1766
1122
|
totalTrades: t,
|
|
1767
1123
|
fillDelay: n,
|
|
1768
|
-
fillDelayMillis:
|
|
1769
|
-
duration:
|
|
1770
|
-
durationMillis:
|
|
1771
|
-
};
|
|
1772
|
-
}, Kn = (e) => {
|
|
1773
|
-
const t = $n(e), n = Number.isFinite(e.priceProtection) ? e.priceProtection * 100 : 0;
|
|
1774
|
-
let a = 0;
|
|
1775
|
-
typeof e.displayFeePercent == "number" && Number.isFinite(e.displayFeePercent) && (a = e.displayFeePercent);
|
|
1776
|
-
const s = se(e.totalInputAmount), c = se(e.marketPrice), y = se(e.limitPrice), E = se(e.triggerPrice), D = Nn({
|
|
1777
|
-
module: e.module,
|
|
1778
|
-
isMarketOrder: e.isMarketOrder,
|
|
1779
|
-
marketPrice: c,
|
|
1780
|
-
limitPrice: y,
|
|
1781
|
-
triggerPrice: E
|
|
1782
|
-
}), C = Dn(
|
|
1783
|
-
s,
|
|
1784
|
-
t.totalTrades
|
|
1785
|
-
), P = se(
|
|
1786
|
-
An(s, D, e.inputTokenDecimals)
|
|
1787
|
-
), F = bn(
|
|
1788
|
-
C,
|
|
1789
|
-
y,
|
|
1790
|
-
e.isMarketOrder,
|
|
1791
|
-
e.inputTokenDecimals
|
|
1792
|
-
), g = Un(
|
|
1793
|
-
F,
|
|
1794
|
-
t.totalTrades
|
|
1795
|
-
), S = yn(
|
|
1796
|
-
e.module,
|
|
1797
|
-
C,
|
|
1798
|
-
E,
|
|
1799
|
-
e.inputTokenDecimals
|
|
1800
|
-
) || "0", w = a && P ? h(P).multipliedBy(a).dividedBy(100).toFixed(0) : "", $ = Mn(e.module, e.isMarketOrder), K = e.module === _.STOP_LOSS || e.module === _.TAKE_PROFIT;
|
|
1801
|
-
return {
|
|
1802
|
-
...t,
|
|
1803
|
-
orderType: $,
|
|
1804
|
-
isMarketOrder: e.isMarketOrder,
|
|
1805
|
-
isTriggerPrice: K,
|
|
1806
|
-
slippageBps: n,
|
|
1807
|
-
inputAmount: s,
|
|
1808
|
-
outputAmount: P,
|
|
1809
|
-
inputAmountPerTrade: C,
|
|
1810
|
-
minOutputAmountPerTrade: F,
|
|
1811
|
-
minOutputAmountTotal: g,
|
|
1812
|
-
triggerOutputAmountPerTrade: S,
|
|
1813
|
-
tradePrice: D,
|
|
1814
|
-
marketPrice: c,
|
|
1815
|
-
limitPrice: y,
|
|
1816
|
-
triggerPrice: E,
|
|
1817
|
-
displayFeeAmount: w,
|
|
1818
|
-
displayFeePercent: a
|
|
1819
|
-
};
|
|
1820
|
-
}, ve = (e) => {
|
|
1821
|
-
if (!e) return "";
|
|
1822
|
-
const t = h(e);
|
|
1823
|
-
return t.isFinite() && !t.isNaN() ? e : "";
|
|
1824
|
-
}, Ae = (e, t, n) => {
|
|
1825
|
-
const a = ve(e), s = Me(a, t);
|
|
1826
|
-
return {
|
|
1827
|
-
raw: a,
|
|
1828
|
-
ui: s,
|
|
1829
|
-
usd: Ze(s, n)
|
|
1124
|
+
fillDelayMillis: rt(n),
|
|
1125
|
+
duration: i,
|
|
1126
|
+
durationMillis: rt(i)
|
|
1830
1127
|
};
|
|
1831
|
-
},
|
|
1832
|
-
const t = ve(e.marketPrice), n = ve(e.quotedOutputAmount), a = Me(
|
|
1833
|
-
ve(e.inputAmountWei),
|
|
1834
|
-
e.inputTokenDecimals
|
|
1835
|
-
), s = n && a && h(a).gt(0) ? h(n).dividedBy(a).toFixed() : "", c = t || s, y = Me(c, e.outputTokenDecimals);
|
|
1836
|
-
return {
|
|
1837
|
-
raw: c,
|
|
1838
|
-
ui: y,
|
|
1839
|
-
usd: Ze(y, e.outputUsdPrice)
|
|
1840
|
-
};
|
|
1841
|
-
}, it = (e) => {
|
|
1128
|
+
}, at = (e) => {
|
|
1842
1129
|
const t = e / 6e4, n = t / 60 / 24;
|
|
1843
1130
|
if (n >= 1)
|
|
1844
1131
|
return `${n.toFixed(n % 1 ? 1 : 0)} ${n === 1 ? "day" : "days"}`;
|
|
1845
|
-
const
|
|
1846
|
-
return
|
|
1847
|
-
},
|
|
1848
|
-
if (
|
|
1132
|
+
const i = t / 60;
|
|
1133
|
+
return i >= 1 ? `${i.toFixed(i % 1 ? 1 : 0)} ${i === 1 ? "hour" : "hours"}` : `${t.toFixed(t % 1 ? 1 : 0)} ${t === 1 ? "minute" : "minutes"}`;
|
|
1134
|
+
}, wn = (e, t, n, i, a) => {
|
|
1135
|
+
if (x(n.raw || "0").isZero() || !t || x(e.inputTokenUsdPrice || "0").isZero())
|
|
1849
1136
|
return;
|
|
1850
|
-
if (!
|
|
1137
|
+
if (!i)
|
|
1851
1138
|
return {
|
|
1852
|
-
type:
|
|
1139
|
+
type: J.MIN_TRADES,
|
|
1853
1140
|
value: 1,
|
|
1854
1141
|
args: { minTrades: "1" }
|
|
1855
1142
|
};
|
|
1856
|
-
if (
|
|
1143
|
+
if (Fn(
|
|
1144
|
+
i,
|
|
1857
1145
|
a,
|
|
1858
|
-
s,
|
|
1859
1146
|
e.module
|
|
1860
1147
|
).isError)
|
|
1861
1148
|
return {
|
|
1862
|
-
type:
|
|
1863
|
-
value:
|
|
1864
|
-
args: { maxTrades: `${
|
|
1149
|
+
type: J.MAX_TRADES,
|
|
1150
|
+
value: a,
|
|
1151
|
+
args: { maxTrades: `${a}` }
|
|
1865
1152
|
};
|
|
1866
|
-
},
|
|
1867
|
-
if (
|
|
1868
|
-
const
|
|
1869
|
-
if (
|
|
1153
|
+
}, Sn = (e, t, n) => {
|
|
1154
|
+
if (x(e || "0").isZero() || !t) return;
|
|
1155
|
+
const i = Dn(n.fillDelay);
|
|
1156
|
+
if (i.isError)
|
|
1870
1157
|
return {
|
|
1871
|
-
type:
|
|
1872
|
-
value:
|
|
1873
|
-
args: { fillDelay:
|
|
1158
|
+
type: J.MIN_FILL_DELAY,
|
|
1159
|
+
value: i.value,
|
|
1160
|
+
args: { fillDelay: at(i.value) }
|
|
1874
1161
|
};
|
|
1875
|
-
const
|
|
1162
|
+
const a = Tn(
|
|
1876
1163
|
n.fillDelay,
|
|
1877
1164
|
n.totalTrades
|
|
1878
1165
|
);
|
|
1879
|
-
if (
|
|
1166
|
+
if (a.isError)
|
|
1880
1167
|
return {
|
|
1881
|
-
type:
|
|
1882
|
-
value:
|
|
1883
|
-
args: { fillDelay:
|
|
1168
|
+
type: J.MAX_FILL_DELAY,
|
|
1169
|
+
value: a.value,
|
|
1170
|
+
args: { fillDelay: at(a.value) }
|
|
1884
1171
|
};
|
|
1885
|
-
},
|
|
1886
|
-
if (
|
|
1887
|
-
const
|
|
1888
|
-
if (
|
|
1172
|
+
}, Pn = (e, t, n, i) => {
|
|
1173
|
+
if (x(t || "0").isZero() || !n) return;
|
|
1174
|
+
const a = xn(e, i.duration);
|
|
1175
|
+
if (a.isError)
|
|
1889
1176
|
return {
|
|
1890
|
-
type:
|
|
1891
|
-
value:
|
|
1177
|
+
type: J.MAX_ORDER_DURATION,
|
|
1178
|
+
value: a.value,
|
|
1892
1179
|
args: {
|
|
1893
|
-
duration: `${Math.floor(
|
|
1180
|
+
duration: `${Math.floor(a.value / 864e5).toFixed(0)} days`
|
|
1894
1181
|
}
|
|
1895
1182
|
};
|
|
1896
|
-
const
|
|
1897
|
-
if (
|
|
1183
|
+
const d = gn(i.duration);
|
|
1184
|
+
if (d.isError)
|
|
1898
1185
|
return {
|
|
1899
|
-
type:
|
|
1900
|
-
value:
|
|
1186
|
+
type: J.MIN_ORDER_DURATION,
|
|
1187
|
+
value: d.value,
|
|
1901
1188
|
args: {
|
|
1902
|
-
duration: `${Math.floor(
|
|
1189
|
+
duration: `${Math.floor(d.value / 6e4).toFixed(0)} minutes`
|
|
1903
1190
|
}
|
|
1904
1191
|
};
|
|
1905
|
-
},
|
|
1906
|
-
if (!(!
|
|
1192
|
+
}, On = (e, t) => {
|
|
1193
|
+
if (!(!x(e.raw || 0).gt(0) || !e.usd) && x(t).gt(e.usd))
|
|
1907
1194
|
return {
|
|
1908
|
-
type:
|
|
1195
|
+
type: J.MIN_TRADE_SIZE,
|
|
1909
1196
|
value: t,
|
|
1910
1197
|
args: { minTradeSize: `${t}` }
|
|
1911
1198
|
};
|
|
1912
|
-
},
|
|
1913
|
-
const
|
|
1914
|
-
|
|
1199
|
+
}, kn = (e, t, n, i, a, d) => {
|
|
1200
|
+
const m = On(
|
|
1201
|
+
t,
|
|
1202
|
+
e.minTradeSizeUsd
|
|
1203
|
+
), b = e.inputBalanceRaw && x(t.raw).gt(e.inputBalanceRaw) ? {
|
|
1204
|
+
type: J.INSUFFICIENT_BALANCE,
|
|
1205
|
+
value: e.inputBalanceRaw
|
|
1206
|
+
} : void 0, D = [
|
|
1207
|
+
m,
|
|
1208
|
+
d.triggerPrice.error,
|
|
1209
|
+
d.limitPrice.error,
|
|
1210
|
+
i.error,
|
|
1211
|
+
a.fillDelayError,
|
|
1212
|
+
a.durationError,
|
|
1213
|
+
b
|
|
1214
|
+
].filter((F) => !!F), C = x(n || 0).gt(0) && x(t.raw || 0).gt(0) && x(e.inputTokenUsdPrice || 0).gt(0), O = C ? D[0] : void 0;
|
|
1215
|
+
return {
|
|
1216
|
+
errors: {
|
|
1217
|
+
primary: O,
|
|
1218
|
+
all: D,
|
|
1219
|
+
minTradeSize: m,
|
|
1220
|
+
triggerPrice: d.triggerPrice.error,
|
|
1221
|
+
limitPrice: d.limitPrice.error,
|
|
1222
|
+
trades: i.error,
|
|
1223
|
+
fillDelay: a.fillDelayError,
|
|
1224
|
+
duration: a.durationError,
|
|
1225
|
+
balance: b
|
|
1226
|
+
},
|
|
1227
|
+
isReady: C,
|
|
1228
|
+
canSubmit: C && !O
|
|
1229
|
+
};
|
|
1230
|
+
}, _n = (e, t, n) => {
|
|
1231
|
+
if (!(!e || !t || n == null))
|
|
1232
|
+
return x(e).times(t).div(x(10).pow(n)).toFixed(0);
|
|
1233
|
+
}, vn = (e, t, n, i) => {
|
|
1234
|
+
if (n || i == null || !e || !t)
|
|
1235
|
+
return "0";
|
|
1236
|
+
const a = x(e).times(t).div(x(10).pow(i));
|
|
1237
|
+
return x.max(1, a).integerValue(x.ROUND_FLOOR).toFixed(0);
|
|
1238
|
+
}, In = (e, t, n, i) => {
|
|
1239
|
+
if (e === v.TWAP || e === v.LIMIT) return "0";
|
|
1240
|
+
if (i == null || !t || !n)
|
|
1241
|
+
return;
|
|
1242
|
+
const a = x(t).times(n).div(x(10).pow(i));
|
|
1243
|
+
return x.max(1, a).integerValue(x.ROUND_FLOOR).toFixed(0);
|
|
1244
|
+
}, Rn = (e = "", t = 0) => !e || !t ? "0" : x(e).div(t).integerValue(x.ROUND_FLOOR).toFixed(0), Mn = (e, t) => e === v.LIMIT ? N.LIMIT : e === v.STOP_LOSS ? t ? N.STOP_LOSS_MARKET : N.STOP_LOSS_LIMIT : e === v.TAKE_PROFIT ? t ? N.TAKE_PROFIT_MARKET : N.TAKE_PROFIT_LIMIT : t ? N.TWAP_MARKET : N.TWAP_LIMIT, Nn = ({
|
|
1245
|
+
module: e,
|
|
1246
|
+
isMarketOrder: t,
|
|
1247
|
+
marketPrice: n,
|
|
1248
|
+
limitPrice: i,
|
|
1249
|
+
triggerPrice: a
|
|
1250
|
+
}) => e === v.LIMIT || !t ? H(i) : e === v.STOP_LOSS || e === v.TAKE_PROFIT ? H(a) : H(n), Ln = (e, t) => !e || !t ? "" : 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), m = H(e.limitPrice), b = H(e.triggerPrice), D = Nn({
|
|
1252
|
+
module: e.module,
|
|
1253
|
+
isMarketOrder: e.isMarketOrder,
|
|
1254
|
+
marketPrice: d,
|
|
1255
|
+
limitPrice: m,
|
|
1256
|
+
triggerPrice: b
|
|
1257
|
+
}), C = Rn(
|
|
1258
|
+
a,
|
|
1259
|
+
t.totalTrades
|
|
1260
|
+
), O = H(
|
|
1261
|
+
_n(a, D, e.inputTokenDecimals)
|
|
1262
|
+
), F = vn(
|
|
1263
|
+
C,
|
|
1264
|
+
m,
|
|
1265
|
+
e.isMarketOrder,
|
|
1266
|
+
e.inputTokenDecimals
|
|
1267
|
+
), h = Ln(
|
|
1268
|
+
F,
|
|
1269
|
+
t.totalTrades
|
|
1270
|
+
), w = In(
|
|
1271
|
+
e.module,
|
|
1272
|
+
C,
|
|
1273
|
+
b,
|
|
1274
|
+
e.inputTokenDecimals
|
|
1275
|
+
) || "0", B = i && O ? x(O).multipliedBy(i).dividedBy(100).toFixed(0) : "";
|
|
1276
|
+
return {
|
|
1277
|
+
...t,
|
|
1278
|
+
orderType: Mn(e.module, e.isMarketOrder),
|
|
1279
|
+
isMarketOrder: e.isMarketOrder,
|
|
1280
|
+
isTriggerPrice: e.module === v.STOP_LOSS || e.module === v.TAKE_PROFIT,
|
|
1281
|
+
slippageBps: n,
|
|
1282
|
+
inputAmount: a,
|
|
1283
|
+
outputAmount: O,
|
|
1284
|
+
inputAmountPerTrade: C,
|
|
1285
|
+
minOutputAmountPerTrade: F,
|
|
1286
|
+
minOutputAmountTotal: h,
|
|
1287
|
+
triggerOutputAmountPerTrade: w,
|
|
1288
|
+
tradePrice: D,
|
|
1289
|
+
marketPrice: d,
|
|
1290
|
+
limitPrice: m,
|
|
1291
|
+
triggerPrice: b,
|
|
1292
|
+
displayFeeAmount: B,
|
|
1293
|
+
displayFeePercent: i
|
|
1294
|
+
};
|
|
1295
|
+
}, $n = (e) => {
|
|
1296
|
+
const t = We(
|
|
1297
|
+
e.userInput.inputAmountUi,
|
|
1298
|
+
e.inputTokenDecimals
|
|
1299
|
+
), n = Ae(
|
|
1300
|
+
t,
|
|
1915
1301
|
e.inputTokenDecimals,
|
|
1916
|
-
e.
|
|
1302
|
+
e.inputTokenUsdPrice
|
|
1917
1303
|
);
|
|
1918
1304
|
return {
|
|
1919
|
-
...
|
|
1920
|
-
isEmpty: !
|
|
1305
|
+
...n,
|
|
1306
|
+
isEmpty: !x(n.raw || 0).gt(0)
|
|
1921
1307
|
};
|
|
1922
|
-
},
|
|
1923
|
-
const
|
|
1308
|
+
}, Kn = (e, t, n) => {
|
|
1309
|
+
const i = hn(
|
|
1924
1310
|
t.ui,
|
|
1925
|
-
e.
|
|
1311
|
+
e.inputTokenUsdPrice,
|
|
1926
1312
|
e.minTradeSizeUsd
|
|
1927
|
-
),
|
|
1928
|
-
|
|
1313
|
+
), a = bn(
|
|
1314
|
+
i,
|
|
1929
1315
|
e.module,
|
|
1930
|
-
e.
|
|
1316
|
+
e.userInput.tradeCount
|
|
1931
1317
|
);
|
|
1932
1318
|
return {
|
|
1933
|
-
totalTrades:
|
|
1934
|
-
maxTrades:
|
|
1935
|
-
error:
|
|
1319
|
+
totalTrades: a,
|
|
1320
|
+
maxTrades: i,
|
|
1321
|
+
error: wn(
|
|
1936
1322
|
e,
|
|
1937
1323
|
n,
|
|
1938
1324
|
t,
|
|
1939
|
-
|
|
1940
|
-
|
|
1325
|
+
a,
|
|
1326
|
+
i
|
|
1941
1327
|
)
|
|
1942
1328
|
};
|
|
1943
|
-
},
|
|
1329
|
+
}, Vn = (e, t, n) => ({
|
|
1944
1330
|
totalTrades: t.totalTrades,
|
|
1945
1331
|
maxTrades: t.maxTrades,
|
|
1946
1332
|
inputAmountPerTrade: Ae(
|
|
1947
1333
|
n.inputAmountPerTrade,
|
|
1948
1334
|
e.inputTokenDecimals,
|
|
1949
|
-
e.
|
|
1335
|
+
e.inputTokenUsdPrice
|
|
1950
1336
|
),
|
|
1951
1337
|
minOutputAmountPerTrade: Ae(
|
|
1952
1338
|
n.minOutputAmountPerTrade,
|
|
1953
1339
|
e.outputTokenDecimals,
|
|
1954
|
-
e.
|
|
1340
|
+
e.outputTokenUsdPrice
|
|
1955
1341
|
),
|
|
1956
1342
|
triggerOutputAmountPerTrade: Ae(
|
|
1957
1343
|
n.triggerOutputAmountPerTrade,
|
|
1958
1344
|
e.outputTokenDecimals,
|
|
1959
|
-
e.
|
|
1345
|
+
e.outputTokenUsdPrice
|
|
1960
1346
|
),
|
|
1961
1347
|
error: t.error
|
|
1962
|
-
}),
|
|
1963
|
-
totalTrades:
|
|
1964
|
-
fillDelay:
|
|
1965
|
-
fillDelayMillis:
|
|
1966
|
-
duration:
|
|
1967
|
-
durationMillis:
|
|
1968
|
-
fillDelayError:
|
|
1348
|
+
}), Gn = (e, t, n, i) => ({
|
|
1349
|
+
totalTrades: i.totalTrades,
|
|
1350
|
+
fillDelay: i.fillDelay,
|
|
1351
|
+
fillDelayMillis: i.fillDelayMillis,
|
|
1352
|
+
duration: i.duration,
|
|
1353
|
+
durationMillis: i.durationMillis,
|
|
1354
|
+
fillDelayError: Sn(
|
|
1969
1355
|
t,
|
|
1970
1356
|
n,
|
|
1971
|
-
|
|
1357
|
+
i
|
|
1972
1358
|
),
|
|
1973
|
-
durationError:
|
|
1359
|
+
durationError: Pn(
|
|
1974
1360
|
e.module,
|
|
1975
1361
|
t,
|
|
1976
1362
|
n,
|
|
1977
|
-
|
|
1363
|
+
i
|
|
1978
1364
|
)
|
|
1979
|
-
}),
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
inputAmountWei: t,
|
|
1984
|
-
triggerPrice: e.triggerPrice,
|
|
1985
|
-
triggerPricePercent: e.triggerPricePercent,
|
|
1986
|
-
isInverted: e.isInverted,
|
|
1987
|
-
inputTokenDecimals: e.inputTokenDecimals,
|
|
1988
|
-
outputTokenDecimals: e.outputTokenDecimals,
|
|
1989
|
-
inputUsdPrice: e.inputUsdPrice,
|
|
1990
|
-
outputUsdPrice: e.outputUsdPrice
|
|
1991
|
-
}), s = e.module === _.LIMIT ? !1 : e.isMarketOrder, c = In({
|
|
1992
|
-
module: e.module,
|
|
1993
|
-
isMarketOrder: s,
|
|
1994
|
-
marketPrice: n,
|
|
1995
|
-
inputAmountWei: t,
|
|
1996
|
-
limitPrice: e.limitPrice,
|
|
1997
|
-
limitPricePercent: e.limitPricePercent,
|
|
1998
|
-
triggerPrice: a.raw,
|
|
1999
|
-
isInverted: e.isInverted,
|
|
2000
|
-
inputTokenDecimals: e.inputTokenDecimals,
|
|
1365
|
+
}), jr = (e) => {
|
|
1366
|
+
const t = $n(e), n = t.raw, i = Dt({
|
|
1367
|
+
quotedOutputAmountRaw: e.quotedOutputAmountRaw,
|
|
1368
|
+
inputAmountUi: t.ui,
|
|
2001
1369
|
outputTokenDecimals: e.outputTokenDecimals,
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
});
|
|
2005
|
-
return { isMarketOrder: s, triggerPrice: a, limitPrice: c };
|
|
2006
|
-
}, Qn = (e, t, n, a, s, c) => {
|
|
2007
|
-
const y = qn(
|
|
2008
|
-
t,
|
|
2009
|
-
e.minTradeSizeUsd
|
|
2010
|
-
), E = e.inputBalance && h(t.raw).gt(e.inputBalance) ? {
|
|
2011
|
-
type: ee.INSUFFICIENT_BALANCE,
|
|
2012
|
-
value: e.inputBalance
|
|
2013
|
-
} : void 0, D = [
|
|
2014
|
-
y,
|
|
2015
|
-
c.triggerPrice.error,
|
|
2016
|
-
c.limitPrice.error,
|
|
2017
|
-
a.error,
|
|
2018
|
-
s.fillDelayError,
|
|
2019
|
-
s.durationError,
|
|
2020
|
-
E
|
|
2021
|
-
].filter((g) => !!g), C = h(n || 0).gt(0) && h(t.raw || 0).gt(0) && h(e.inputUsdPrice || 0).gt(0), P = e.ignoreErrors || !C ? void 0 : D[0];
|
|
2022
|
-
return {
|
|
2023
|
-
errors: {
|
|
2024
|
-
primary: P,
|
|
2025
|
-
all: D,
|
|
2026
|
-
minTradeSize: y,
|
|
2027
|
-
triggerPrice: c.triggerPrice.error,
|
|
2028
|
-
limitPrice: c.limitPrice.error,
|
|
2029
|
-
trades: a.error,
|
|
2030
|
-
fillDelay: s.fillDelayError,
|
|
2031
|
-
duration: s.durationError,
|
|
2032
|
-
balance: E
|
|
2033
|
-
},
|
|
2034
|
-
isReady: C,
|
|
2035
|
-
canSubmit: C && !P
|
|
2036
|
-
};
|
|
2037
|
-
}, aa = (e) => {
|
|
2038
|
-
const t = Gn(e), n = t.raw, a = Vn({
|
|
2039
|
-
marketPrice: e.marketPrice,
|
|
2040
|
-
quotedOutputAmount: e.quotedOutputAmount,
|
|
2041
|
-
inputAmountWei: n,
|
|
2042
|
-
inputTokenDecimals: e.inputTokenDecimals,
|
|
2043
|
-
outputTokenDecimals: e.outputTokenDecimals,
|
|
2044
|
-
outputUsdPrice: e.outputUsdPrice
|
|
2045
|
-
}), s = a.raw, c = jn(
|
|
1370
|
+
outputUsdPrice: e.outputTokenUsdPrice
|
|
1371
|
+
}), a = i.raw, d = Kn(
|
|
2046
1372
|
e,
|
|
2047
1373
|
t,
|
|
2048
|
-
|
|
2049
|
-
),
|
|
1374
|
+
a
|
|
1375
|
+
), m = It(e, n, a), b = Un({
|
|
2050
1376
|
module: e.module,
|
|
2051
1377
|
inputTokenDecimals: e.inputTokenDecimals,
|
|
2052
1378
|
totalInputAmount: n,
|
|
2053
|
-
fillDelay: e.
|
|
2054
|
-
duration: e.
|
|
2055
|
-
totalTrades:
|
|
2056
|
-
|
|
2057
|
-
isMarketOrder:
|
|
2058
|
-
marketPrice:
|
|
2059
|
-
limitPrice:
|
|
2060
|
-
triggerPrice:
|
|
1379
|
+
fillDelay: e.userInput.tradeInterval,
|
|
1380
|
+
duration: e.userInput.orderDuration,
|
|
1381
|
+
totalTrades: d.totalTrades,
|
|
1382
|
+
priceProtectionPercent: e.priceProtectionPercent,
|
|
1383
|
+
isMarketOrder: m.isMarketOrder,
|
|
1384
|
+
marketPrice: a,
|
|
1385
|
+
limitPrice: m.limitPrice.raw,
|
|
1386
|
+
triggerPrice: m.triggerPrice.raw,
|
|
2061
1387
|
displayFeePercent: e.displayFeePercent
|
|
2062
|
-
}), D =
|
|
1388
|
+
}), D = Gn(
|
|
2063
1389
|
e,
|
|
2064
1390
|
n,
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
), C =
|
|
1391
|
+
a,
|
|
1392
|
+
b
|
|
1393
|
+
), C = Vn(e, d, b), O = kn(
|
|
2068
1394
|
e,
|
|
2069
1395
|
t,
|
|
2070
|
-
|
|
2071
|
-
|
|
1396
|
+
a,
|
|
1397
|
+
d,
|
|
2072
1398
|
D,
|
|
2073
|
-
|
|
1399
|
+
m
|
|
2074
1400
|
);
|
|
2075
1401
|
return {
|
|
2076
1402
|
module: e.module,
|
|
2077
|
-
isInverted: !!e.
|
|
1403
|
+
isInverted: !!e.userInput.isPriceInverted,
|
|
2078
1404
|
inputAmount: t,
|
|
2079
1405
|
outputAmount: Ae(
|
|
2080
|
-
|
|
1406
|
+
b.outputAmount,
|
|
2081
1407
|
e.outputTokenDecimals,
|
|
2082
|
-
e.
|
|
1408
|
+
e.outputTokenUsdPrice
|
|
2083
1409
|
),
|
|
2084
|
-
marketPrice:
|
|
1410
|
+
marketPrice: i,
|
|
2085
1411
|
trades: C,
|
|
2086
1412
|
schedule: D,
|
|
2087
|
-
triggerPrice:
|
|
2088
|
-
limitPrice:
|
|
1413
|
+
triggerPrice: m.triggerPrice,
|
|
1414
|
+
limitPrice: m.limitPrice,
|
|
2089
1415
|
minOutputAmountTotal: Ae(
|
|
2090
|
-
|
|
1416
|
+
b.minOutputAmountTotal,
|
|
2091
1417
|
e.outputTokenDecimals,
|
|
2092
|
-
e.
|
|
1418
|
+
e.outputTokenUsdPrice
|
|
2093
1419
|
),
|
|
2094
1420
|
tradePrice: Ae(
|
|
2095
|
-
|
|
1421
|
+
b.tradePrice,
|
|
2096
1422
|
e.outputTokenDecimals,
|
|
2097
|
-
e.
|
|
1423
|
+
e.outputTokenUsdPrice
|
|
2098
1424
|
),
|
|
2099
1425
|
fees: {
|
|
2100
1426
|
...Ae(
|
|
2101
|
-
|
|
1427
|
+
b.displayFeeAmount,
|
|
2102
1428
|
e.outputTokenDecimals,
|
|
2103
|
-
e.
|
|
1429
|
+
e.outputTokenUsdPrice
|
|
2104
1430
|
),
|
|
2105
|
-
percentage:
|
|
1431
|
+
percentage: b.displayFeePercent
|
|
2106
1432
|
},
|
|
2107
|
-
values:
|
|
2108
|
-
...
|
|
1433
|
+
values: b,
|
|
1434
|
+
...O
|
|
2109
1435
|
};
|
|
2110
|
-
}, Jn = /* @__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"}]'), er = [
|
|
1436
|
+
}, 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 = [
|
|
2111
1437
|
{
|
|
2112
1438
|
type: "constructor",
|
|
2113
1439
|
inputs: [],
|
|
@@ -2419,37 +1745,39 @@ const ye = (e) => e ? e.value * e.unit : 0, un = (e) => !e || e === "NaN" ? "0"
|
|
|
2419
1745
|
}
|
|
2420
1746
|
]
|
|
2421
1747
|
}
|
|
2422
|
-
],
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
1748
|
+
], zn = Wn, jn = qn, Xn = "2.8.1", ve = {
|
|
1749
|
+
version: Xn
|
|
1750
|
+
}, Hn = 0.7, Yn = `https://bi.orbs.network/putes/twap-ui-${Hn}`;
|
|
1751
|
+
let Pe = "unknown";
|
|
1752
|
+
function Xr(e) {
|
|
1753
|
+
Pe = e;
|
|
2426
1754
|
}
|
|
2427
|
-
function
|
|
1755
|
+
function we() {
|
|
2428
1756
|
const e = Math.random().toString(36).substring(2, 16), t = Math.random().toString(36).substring(2, 16), n = Date.now().toString(36);
|
|
2429
1757
|
return `id_${e + t + n}`;
|
|
2430
1758
|
}
|
|
2431
|
-
const
|
|
2432
|
-
spotVersion:
|
|
1759
|
+
const Zn = (e, t, n) => ({
|
|
1760
|
+
spotVersion: ve.version,
|
|
2433
1761
|
partner: e,
|
|
2434
1762
|
chainId: n || 0,
|
|
2435
1763
|
minChunkSizeUsd: t
|
|
2436
|
-
}),
|
|
2437
|
-
const { witness:
|
|
1764
|
+
}), Qn = (e, t, n, i) => {
|
|
1765
|
+
const { witness: a } = e.order, d = Ge.config(
|
|
2438
1766
|
e.domain.chainId,
|
|
2439
1767
|
t
|
|
2440
1768
|
);
|
|
2441
1769
|
return {
|
|
2442
|
-
spotVersion:
|
|
1770
|
+
spotVersion: ve.version,
|
|
2443
1771
|
partner: t,
|
|
2444
|
-
cosigner:
|
|
2445
|
-
fee:
|
|
2446
|
-
refinery:
|
|
2447
|
-
router:
|
|
2448
|
-
type:
|
|
2449
|
-
wm:
|
|
2450
|
-
adapter:
|
|
2451
|
-
executor:
|
|
2452
|
-
reactor:
|
|
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,
|
|
2453
1781
|
repermit: e.domain.verifyingContract,
|
|
2454
1782
|
chainId: e.domain.chainId,
|
|
2455
1783
|
chainName: (n == null ? void 0 : n.chainName) || "",
|
|
@@ -2457,15 +1785,15 @@ const sr = (e, t, n) => ({
|
|
|
2457
1785
|
twapAddress: (n == null ? void 0 : n.twapAddress) || "",
|
|
2458
1786
|
lensAddress: (n == null ? void 0 : n.lensAddress) || "",
|
|
2459
1787
|
bidDelaySeconds: (n == null ? void 0 : n.bidDelaySeconds) || 0,
|
|
2460
|
-
minChunkSizeUsd:
|
|
1788
|
+
minChunkSizeUsd: i || 0,
|
|
2461
1789
|
name: (n == null ? void 0 : n.name) || "",
|
|
2462
1790
|
exchangeAddress: (n == null ? void 0 : n.exchangeAddress) || "",
|
|
2463
1791
|
exchangeType: (n == null ? void 0 : n.exchangeType) || "",
|
|
2464
1792
|
pathfinderKey: (n == null ? void 0 : n.pathfinderKey) || ""
|
|
2465
1793
|
};
|
|
2466
|
-
},
|
|
1794
|
+
}, Se = async (e) => {
|
|
2467
1795
|
try {
|
|
2468
|
-
await fetch(
|
|
1796
|
+
await fetch(Yn, {
|
|
2469
1797
|
method: "POST",
|
|
2470
1798
|
headers: {
|
|
2471
1799
|
Accept: "application/json",
|
|
@@ -2476,27 +1804,42 @@ const sr = (e, t, n) => ({
|
|
|
2476
1804
|
} catch (t) {
|
|
2477
1805
|
console.error("Failed to send BI", t);
|
|
2478
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";
|
|
2479
1822
|
};
|
|
2480
|
-
class
|
|
1823
|
+
class Jn {
|
|
2481
1824
|
constructor() {
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
_id:
|
|
1825
|
+
Ee(this, "timeout");
|
|
1826
|
+
Ee(this, "configDetails", {});
|
|
1827
|
+
Ee(this, "configUpdateKey", "");
|
|
1828
|
+
Ee(this, "moduleImportKey", "");
|
|
1829
|
+
Ee(this, "data", {
|
|
1830
|
+
_id: we()
|
|
2488
1831
|
});
|
|
2489
1832
|
}
|
|
2490
|
-
async updateAndSend(t = {}, n = !1,
|
|
1833
|
+
async updateAndSend(t = {}, n = !1, i) {
|
|
2491
1834
|
try {
|
|
2492
1835
|
this.data = {
|
|
2493
1836
|
...this.data,
|
|
2494
1837
|
...t
|
|
2495
|
-
}, n ? (await
|
|
2496
|
-
|
|
1838
|
+
}, n ? (await Se(this.data), i == null || i()) : (clearTimeout(this.timeout), this.timeout = setTimeout(() => {
|
|
1839
|
+
Se(this.data), i == null || i();
|
|
2497
1840
|
}, 1e3));
|
|
2498
|
-
} catch (
|
|
2499
|
-
console.error("Failed to update and send BI",
|
|
1841
|
+
} catch (a) {
|
|
1842
|
+
console.error("Failed to update and send BI", a);
|
|
2500
1843
|
}
|
|
2501
1844
|
}
|
|
2502
1845
|
onCancelOrderRequest(t, n) {
|
|
@@ -2545,54 +1888,53 @@ class or {
|
|
|
2545
1888
|
this.onTxError(t);
|
|
2546
1889
|
}
|
|
2547
1890
|
onCrash(t) {
|
|
2548
|
-
|
|
2549
|
-
|
|
1891
|
+
this.updateAndSend({
|
|
1892
|
+
action: "crash",
|
|
1893
|
+
actionError: it(t)
|
|
1894
|
+
});
|
|
2550
1895
|
}
|
|
2551
1896
|
onTxError(t) {
|
|
2552
|
-
|
|
2553
|
-
const n = ((a = t == null ? void 0 : t.message) == null ? void 0 : a.toLowerCase()) || (t == null ? void 0 : t.toLowerCase());
|
|
2554
|
-
this.updateAndSend({ actionError: n });
|
|
1897
|
+
this.updateAndSend({ actionError: it(t) });
|
|
2555
1898
|
}
|
|
2556
1899
|
onRequestOrder({
|
|
2557
1900
|
account: t,
|
|
2558
1901
|
chainId: n,
|
|
2559
|
-
module:
|
|
2560
|
-
srcToken:
|
|
2561
|
-
dstToken:
|
|
2562
|
-
fromTokenAmount:
|
|
2563
|
-
srcChunkAmount:
|
|
1902
|
+
module: i,
|
|
1903
|
+
srcToken: a,
|
|
1904
|
+
dstToken: d,
|
|
1905
|
+
fromTokenAmount: m,
|
|
1906
|
+
srcChunkAmount: b,
|
|
2564
1907
|
minDstAmountOutPerTrade: D = "",
|
|
2565
1908
|
triggerPricePerTrade: C = "",
|
|
2566
|
-
deadline:
|
|
1909
|
+
deadline: O,
|
|
2567
1910
|
fillDelay: F,
|
|
2568
|
-
slippage:
|
|
2569
|
-
isMarketOrder:
|
|
2570
|
-
chunksAmount:
|
|
1911
|
+
slippage: h,
|
|
1912
|
+
isMarketOrder: w,
|
|
1913
|
+
chunksAmount: B
|
|
2571
1914
|
}) {
|
|
2572
1915
|
this.updateAndSend({
|
|
2573
|
-
toTokenAddress:
|
|
2574
|
-
toTokenSymbol:
|
|
2575
|
-
fromTokenAddress:
|
|
2576
|
-
fromTokenSymbol:
|
|
2577
|
-
fromTokenAmount:
|
|
2578
|
-
chunksAmount:
|
|
2579
|
-
srcChunkAmount:
|
|
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,
|
|
2580
1923
|
minDstAmountOutPerTrade: D,
|
|
2581
1924
|
triggerPricePerTrade: C,
|
|
2582
|
-
deadline:
|
|
1925
|
+
deadline: O,
|
|
2583
1926
|
fillDelay: F,
|
|
2584
|
-
slippage:
|
|
1927
|
+
slippage: h,
|
|
2585
1928
|
chainId: n,
|
|
2586
1929
|
walletAddress: t,
|
|
2587
|
-
module:
|
|
2588
|
-
orderType:
|
|
1930
|
+
module: i,
|
|
1931
|
+
orderType: w ? "market" : "limit",
|
|
2589
1932
|
actionError: void 0
|
|
2590
1933
|
});
|
|
2591
1934
|
}
|
|
2592
1935
|
onSignOrderRequest(t) {
|
|
2593
1936
|
this.updateAndSend({
|
|
2594
|
-
action: "sign order"
|
|
2595
|
-
order: t
|
|
1937
|
+
action: "sign order"
|
|
2596
1938
|
});
|
|
2597
1939
|
}
|
|
2598
1940
|
onSignOrderError(t) {
|
|
@@ -2600,39 +1942,38 @@ class or {
|
|
|
2600
1942
|
}
|
|
2601
1943
|
onSignOrderSuccess(t) {
|
|
2602
1944
|
this.updateAndSend({
|
|
2603
|
-
action: "sign order"
|
|
2604
|
-
signature: t
|
|
1945
|
+
action: "sign order"
|
|
2605
1946
|
});
|
|
2606
1947
|
}
|
|
2607
|
-
init(t, n,
|
|
2608
|
-
const
|
|
2609
|
-
if (
|
|
2610
|
-
this.moduleImportKey =
|
|
2611
|
-
const
|
|
2612
|
-
_id:
|
|
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(),
|
|
2613
1954
|
action: "module-import",
|
|
2614
|
-
uiVersion:
|
|
2615
|
-
appId:
|
|
2616
|
-
...
|
|
1955
|
+
uiVersion: Pe,
|
|
1956
|
+
appId: a,
|
|
1957
|
+
...Zn(t, n, i),
|
|
2617
1958
|
origin: window.location.origin
|
|
2618
1959
|
};
|
|
2619
|
-
this.configDetails.partner === t && this.configDetails.chainId === (
|
|
1960
|
+
this.configDetails.partner === t && this.configDetails.chainId === (i || 0) || (this.configDetails = {}), this.data = { ...m, ...this.configDetails }, Se(m);
|
|
2620
1961
|
}
|
|
2621
1962
|
}
|
|
2622
|
-
onFetchedConfig(t, n,
|
|
2623
|
-
const
|
|
1963
|
+
onFetchedConfig(t, n, i, a) {
|
|
1964
|
+
const d = Qn(
|
|
2624
1965
|
t,
|
|
2625
1966
|
n,
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
),
|
|
2629
|
-
|
|
2630
|
-
_id:
|
|
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(),
|
|
2631
1972
|
action: "config-update",
|
|
2632
|
-
uiVersion:
|
|
1973
|
+
uiVersion: Pe,
|
|
2633
1974
|
appId: this.data.appId,
|
|
2634
1975
|
origin: typeof window > "u" ? void 0 : window.location.origin,
|
|
2635
|
-
...
|
|
1976
|
+
...d
|
|
2636
1977
|
}));
|
|
2637
1978
|
}
|
|
2638
1979
|
onCreateOrderError(t) {
|
|
@@ -2652,12 +1993,12 @@ class or {
|
|
|
2652
1993
|
void 0,
|
|
2653
1994
|
() => {
|
|
2654
1995
|
this.data = {
|
|
2655
|
-
_id:
|
|
1996
|
+
_id: we(),
|
|
2656
1997
|
action: "reset",
|
|
2657
|
-
uiVersion:
|
|
1998
|
+
uiVersion: Pe,
|
|
2658
1999
|
appId: this.data.appId,
|
|
2659
2000
|
origin: this.data.origin,
|
|
2660
|
-
spotVersion:
|
|
2001
|
+
spotVersion: ve.version,
|
|
2661
2002
|
partner: this.data.partner,
|
|
2662
2003
|
adapter: this.data.adapter,
|
|
2663
2004
|
cosigner: this.data.cosigner,
|
|
@@ -2685,156 +2026,170 @@ class or {
|
|
|
2685
2026
|
);
|
|
2686
2027
|
}
|
|
2687
2028
|
}
|
|
2688
|
-
const
|
|
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 = {
|
|
2030
|
+
[Q.Thena]: ["0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"],
|
|
2031
|
+
[Q.Katana]: ["0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df"]
|
|
2032
|
+
}, ar = ({
|
|
2033
|
+
endpoint: e,
|
|
2034
|
+
exchange: t,
|
|
2035
|
+
partner: n
|
|
2036
|
+
}) => {
|
|
2037
|
+
const a = [_e, Ie].includes(
|
|
2038
|
+
e
|
|
2039
|
+
) && n ? rr[n] || [] : [], d = t ? [t, ...a] : a;
|
|
2040
|
+
return d.filter(
|
|
2041
|
+
(m, b) => d.findIndex(
|
|
2042
|
+
(D) => D.toLowerCase() === m.toLowerCase()
|
|
2043
|
+
) === b
|
|
2044
|
+
);
|
|
2045
|
+
}, ir = async (e, t) => {
|
|
2689
2046
|
const n = new URLSearchParams({
|
|
2690
2047
|
partner: e,
|
|
2691
2048
|
chain: t.toString()
|
|
2692
|
-
}),
|
|
2693
|
-
if (!
|
|
2694
|
-
const
|
|
2049
|
+
}), i = await fetch(`${tr()}?${n}`);
|
|
2050
|
+
if (!i.ok) {
|
|
2051
|
+
const a = await i.text();
|
|
2695
2052
|
throw new Error(
|
|
2696
|
-
`Failed to fetch RePermit data for partner "${e}" on chain ${t}: ${
|
|
2053
|
+
`Failed to fetch RePermit data for partner "${e}" on chain ${t}: ${i.status}${a ? ` ${a}` : ""}`
|
|
2697
2054
|
);
|
|
2698
2055
|
}
|
|
2699
|
-
return
|
|
2700
|
-
},
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
triggerOutputAmountPerTrade: S = "0",
|
|
2056
|
+
return i.json();
|
|
2057
|
+
}, sr = ({
|
|
2058
|
+
inputTokenAddress: e,
|
|
2059
|
+
outputTokenAddress: t,
|
|
2060
|
+
totalInputAmount: n,
|
|
2061
|
+
nonce: i,
|
|
2062
|
+
currentTimeMillis: a,
|
|
2063
|
+
deadlineMillis: d,
|
|
2064
|
+
fillDelayMillis: m,
|
|
2065
|
+
totalTrades: b,
|
|
2066
|
+
slippageBps: D,
|
|
2067
|
+
swapperAddress: C,
|
|
2068
|
+
inputAmountPerTrade: O,
|
|
2069
|
+
minOutputAmountPerTrade: F = "0",
|
|
2070
|
+
triggerOutputAmountPerTrade: h = "0",
|
|
2715
2071
|
permitData: w,
|
|
2716
|
-
module:
|
|
2072
|
+
module: B
|
|
2717
2073
|
}) => {
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
).toFixed(), r = {
|
|
2074
|
+
const V = !b || b === 1 ? 0 : parseInt((m / 1e3).toFixed(0)), K = yn(d / 1e3), z = 60, g = Math.floor(a / 1e3).toString(), Te = x(F || 0).toFixed(), De = x(
|
|
2075
|
+
B === v.STOP_LOSS && h || 0
|
|
2076
|
+
).toFixed(), xe = x(
|
|
2077
|
+
B === v.TAKE_PROFIT && h || 0
|
|
2078
|
+
).toFixed(), Y = {
|
|
2724
2079
|
...w.order,
|
|
2725
2080
|
permitted: {
|
|
2726
2081
|
...w.order.permitted,
|
|
2727
|
-
token:
|
|
2728
|
-
amount:
|
|
2082
|
+
token: e,
|
|
2083
|
+
amount: n
|
|
2729
2084
|
},
|
|
2730
|
-
nonce:
|
|
2731
|
-
deadline:
|
|
2085
|
+
nonce: i,
|
|
2086
|
+
deadline: K,
|
|
2732
2087
|
witness: {
|
|
2733
2088
|
...w.order.witness,
|
|
2734
|
-
swapper:
|
|
2735
|
-
nonce:
|
|
2736
|
-
start:
|
|
2737
|
-
deadline:
|
|
2738
|
-
epoch:
|
|
2739
|
-
slippage:
|
|
2740
|
-
freshness:
|
|
2089
|
+
swapper: C,
|
|
2090
|
+
nonce: i,
|
|
2091
|
+
start: g,
|
|
2092
|
+
deadline: K,
|
|
2093
|
+
epoch: V,
|
|
2094
|
+
slippage: D,
|
|
2095
|
+
freshness: z,
|
|
2741
2096
|
input: {
|
|
2742
2097
|
...w.order.witness.input,
|
|
2743
|
-
token:
|
|
2744
|
-
amount:
|
|
2745
|
-
maxAmount:
|
|
2098
|
+
token: e,
|
|
2099
|
+
amount: O,
|
|
2100
|
+
maxAmount: n
|
|
2746
2101
|
},
|
|
2747
2102
|
output: {
|
|
2748
2103
|
...w.order.witness.output,
|
|
2749
|
-
token:
|
|
2750
|
-
limit:
|
|
2751
|
-
triggerLower:
|
|
2752
|
-
triggerUpper:
|
|
2753
|
-
recipient:
|
|
2104
|
+
token: t,
|
|
2105
|
+
limit: Te,
|
|
2106
|
+
triggerLower: De,
|
|
2107
|
+
triggerUpper: xe,
|
|
2108
|
+
recipient: C
|
|
2754
2109
|
}
|
|
2755
2110
|
}
|
|
2756
2111
|
};
|
|
2757
2112
|
return {
|
|
2758
2113
|
...w,
|
|
2759
|
-
order:
|
|
2114
|
+
order: Y
|
|
2760
2115
|
};
|
|
2761
|
-
}, fe = (e, t) => e && e.length ? e.map(t || ((n) => `${n}`)) : void 0,
|
|
2116
|
+
}, fe = (e, t) => e && e.length ? e.map(t || ((n) => `${n}`)) : void 0, or = (e) => {
|
|
2762
2117
|
if (e)
|
|
2763
|
-
return
|
|
2764
|
-
},
|
|
2118
|
+
return on[e];
|
|
2119
|
+
}, He = (e, t) => {
|
|
2765
2120
|
if (!e || typeof e != "object")
|
|
2766
2121
|
throw new Error("Invalid subgraph response");
|
|
2767
2122
|
const n = e.data;
|
|
2768
2123
|
if (!n || typeof n != "object")
|
|
2769
2124
|
throw new Error("Invalid subgraph response: missing data");
|
|
2770
|
-
const
|
|
2771
|
-
if (!Array.isArray(
|
|
2125
|
+
const i = n[t];
|
|
2126
|
+
if (!Array.isArray(i))
|
|
2772
2127
|
throw new Error(`Invalid subgraph response: missing ${t}`);
|
|
2773
|
-
return
|
|
2774
|
-
},
|
|
2128
|
+
return i;
|
|
2129
|
+
}, Ye = async ({
|
|
2775
2130
|
chainId: e,
|
|
2776
2131
|
buildQuery: t,
|
|
2777
2132
|
extractResults: n,
|
|
2778
|
-
signal:
|
|
2779
|
-
retries:
|
|
2780
|
-
limit:
|
|
2781
|
-
page:
|
|
2133
|
+
signal: i,
|
|
2134
|
+
retries: a = 1,
|
|
2135
|
+
limit: d = 1e3,
|
|
2136
|
+
page: m
|
|
2782
2137
|
}) => {
|
|
2783
|
-
const
|
|
2784
|
-
if (!
|
|
2138
|
+
const b = or(e);
|
|
2139
|
+
if (!b) throw new Et();
|
|
2785
2140
|
const D = async (F) => {
|
|
2786
|
-
let
|
|
2787
|
-
for (;
|
|
2141
|
+
let h = 0;
|
|
2142
|
+
for (; h <= a; )
|
|
2788
2143
|
try {
|
|
2789
|
-
const
|
|
2144
|
+
const w = await fetch(b, {
|
|
2790
2145
|
method: "POST",
|
|
2791
2146
|
body: JSON.stringify({ query: F }),
|
|
2792
|
-
signal:
|
|
2147
|
+
signal: i,
|
|
2793
2148
|
headers: { "Content-Type": "application/json" }
|
|
2794
2149
|
});
|
|
2795
|
-
if (!
|
|
2796
|
-
const
|
|
2797
|
-
if (Array.isArray(
|
|
2798
|
-
const K =
|
|
2150
|
+
if (!w.ok) throw new Error(`HTTP error: ${w.status}`);
|
|
2151
|
+
const B = await w.json(), V = B && typeof B == "object" ? B.errors : void 0;
|
|
2152
|
+
if (Array.isArray(V) && V.length) {
|
|
2153
|
+
const K = V[0], z = K && typeof K == "object" ? K.message : void 0;
|
|
2799
2154
|
throw new Error(
|
|
2800
|
-
typeof
|
|
2155
|
+
typeof z == "string" ? z : "Subgraph request failed"
|
|
2801
2156
|
);
|
|
2802
2157
|
}
|
|
2803
|
-
return n(
|
|
2804
|
-
} catch (
|
|
2805
|
-
if (
|
|
2806
|
-
await new Promise((
|
|
2158
|
+
return n(B);
|
|
2159
|
+
} catch (w) {
|
|
2160
|
+
if (i != null && i.aborted || w instanceof Error && w.name === "AbortError" || h === a) throw w;
|
|
2161
|
+
await new Promise((B) => setTimeout(B, 500 * 2 ** h)), h++;
|
|
2807
2162
|
}
|
|
2808
2163
|
return [];
|
|
2809
2164
|
};
|
|
2810
2165
|
let C = 0;
|
|
2811
|
-
const
|
|
2812
|
-
if (
|
|
2813
|
-
const F = t(
|
|
2166
|
+
const O = [];
|
|
2167
|
+
if (m !== void 0) {
|
|
2168
|
+
const F = t(m, d);
|
|
2814
2169
|
return D(F);
|
|
2815
2170
|
}
|
|
2816
2171
|
for (; ; ) {
|
|
2817
|
-
const F = t(C,
|
|
2818
|
-
if (
|
|
2172
|
+
const F = t(C, d), h = await D(F);
|
|
2173
|
+
if (O.push(...h), h.length < d) break;
|
|
2819
2174
|
C++;
|
|
2820
2175
|
}
|
|
2821
|
-
return
|
|
2822
|
-
},
|
|
2176
|
+
return O;
|
|
2177
|
+
}, yt = (e) => e.map((t) => ({
|
|
2823
2178
|
inAmount: t.srcAmountIn,
|
|
2824
2179
|
outAmount: t.dstAmountOut,
|
|
2825
2180
|
timestamp: t.timestamp,
|
|
2826
2181
|
txHash: t.transactionHash
|
|
2827
|
-
})),
|
|
2828
|
-
const n =
|
|
2182
|
+
})), st = (e, t) => {
|
|
2183
|
+
const n = x(e || 0).gt(1);
|
|
2829
2184
|
return !n && t === 1 ? N.TWAP_MARKET : t > 1 && n ? N.TWAP_LIMIT : n ? N.LIMIT : N.TWAP_MARKET;
|
|
2830
|
-
},
|
|
2831
|
-
const
|
|
2185
|
+
}, dr = (e, t, n, i) => {
|
|
2186
|
+
const a = yt(n || []), d = new x(e.ask_srcBidAmount || 0), m = d.gt(0) ? Math.max(
|
|
2832
2187
|
1,
|
|
2833
|
-
new
|
|
2834
|
-
) : 1, D = (n == null ? void 0 : n.length) >=
|
|
2835
|
-
(
|
|
2188
|
+
new x(e.ask_srcAmount || 0).div(d).integerValue(x.ROUND_CEIL).toNumber()
|
|
2189
|
+
) : 1, D = (n == null ? void 0 : n.length) >= m ? a.reduce(
|
|
2190
|
+
(w, B) => Math.max(w, B.timestamp),
|
|
2836
2191
|
0
|
|
2837
|
-
) : void 0, C =
|
|
2192
|
+
) : void 0, C = a.reduce((w, B) => w.plus(B.inAmount), new x(0)).toFixed(), O = a.reduce((w, B) => w.plus(B.outAmount), new x(0)).toFixed(), F = mt(e.ask_srcAmount, C), h = st(e.ask_dstMinAmount, m);
|
|
2838
2193
|
return {
|
|
2839
2194
|
repermitDigest: "",
|
|
2840
2195
|
version: 1,
|
|
@@ -2842,95 +2197,95 @@ const Ee = new or(), cr = async (e, t) => {
|
|
|
2842
2197
|
isTriggerPrice: !1,
|
|
2843
2198
|
id: e.Contract_id.toString(),
|
|
2844
2199
|
hash: "",
|
|
2845
|
-
type:
|
|
2200
|
+
type: st(e.ask_dstMinAmount, m),
|
|
2846
2201
|
srcTokenAddress: e.ask_srcToken,
|
|
2847
2202
|
dstTokenAddress: e.ask_dstToken,
|
|
2848
2203
|
exchangeAddress: e.exchange,
|
|
2849
2204
|
twapAddress: e.twapAddress,
|
|
2850
2205
|
maker: e.maker,
|
|
2851
2206
|
progress: F,
|
|
2852
|
-
dstAmountFilled:
|
|
2207
|
+
dstAmountFilled: O,
|
|
2853
2208
|
srcAmountFilled: C,
|
|
2854
|
-
orderDollarValueIn:
|
|
2209
|
+
orderDollarValueIn: x(e.dollarValueIn || 0).toFixed(6),
|
|
2855
2210
|
srcAmount: e.ask_srcAmount,
|
|
2856
|
-
dstMinAmountTotal:
|
|
2857
|
-
fills:
|
|
2211
|
+
dstMinAmountTotal: x(e.ask_dstMinAmount).multipliedBy(m).toString(),
|
|
2212
|
+
fills: a,
|
|
2858
2213
|
fillDelay: e.ask_fillDelay,
|
|
2859
2214
|
deadline: e.ask_deadline * 1e3,
|
|
2860
2215
|
createdAt: new Date(e.timestamp).getTime(),
|
|
2861
|
-
dstMinAmountPerTrade:
|
|
2216
|
+
dstMinAmountPerTrade: x(e.ask_dstMinAmount).eq(1) ? "" : e.ask_dstMinAmount,
|
|
2862
2217
|
triggerPricePerTrade: "",
|
|
2863
2218
|
srcAmountPerTrade: e.ask_srcBidAmount,
|
|
2864
2219
|
txHash: e.transactionHash,
|
|
2865
|
-
totalTradesAmount:
|
|
2866
|
-
isMarketPrice: [N.TWAP_MARKET].includes(
|
|
2220
|
+
totalTradesAmount: m,
|
|
2221
|
+
isMarketPrice: [N.TWAP_MARKET].includes(h),
|
|
2867
2222
|
chainId: t,
|
|
2868
2223
|
filledOrderTimestamp: D || 0,
|
|
2869
|
-
status:
|
|
2224
|
+
status: i,
|
|
2870
2225
|
rawOrder: e
|
|
2871
2226
|
};
|
|
2872
|
-
},
|
|
2227
|
+
}, cr = (e) => {
|
|
2873
2228
|
var F;
|
|
2874
2229
|
if (!e) return "";
|
|
2875
2230
|
const t = fe(
|
|
2876
2231
|
e.accounts,
|
|
2877
|
-
(
|
|
2232
|
+
(h) => `"${h.toLowerCase()}"`
|
|
2878
2233
|
), n = fe(
|
|
2879
|
-
|
|
2880
|
-
(
|
|
2881
|
-
),
|
|
2234
|
+
En(e.configs),
|
|
2235
|
+
(h) => `"${h.toLowerCase()}"`
|
|
2236
|
+
), i = fe(
|
|
2882
2237
|
e.inTokenSymbols,
|
|
2883
|
-
(
|
|
2884
|
-
),
|
|
2238
|
+
(h) => `"${h.toUpperCase()}"`
|
|
2239
|
+
), a = fe(
|
|
2885
2240
|
e.outTokenSymbols,
|
|
2886
|
-
(
|
|
2887
|
-
),
|
|
2241
|
+
(h) => `"${h.toUpperCase()}"`
|
|
2242
|
+
), d = fe(
|
|
2888
2243
|
e.inTokenAddresses,
|
|
2889
|
-
(
|
|
2890
|
-
),
|
|
2244
|
+
(h) => `"${h.toLowerCase()}"`
|
|
2245
|
+
), m = fe(
|
|
2891
2246
|
e.outTokenAddresses,
|
|
2892
|
-
(
|
|
2893
|
-
),
|
|
2247
|
+
(h) => `"${h.toLowerCase()}"`
|
|
2248
|
+
), b = fe(
|
|
2894
2249
|
e.transactionHashes,
|
|
2895
|
-
(
|
|
2896
|
-
), D = fe(e.orderIds, (
|
|
2897
|
-
(F = e.configs) == null ? void 0 : F.map((
|
|
2898
|
-
(
|
|
2899
|
-
),
|
|
2250
|
+
(h) => `"${h.toLowerCase()}"`
|
|
2251
|
+
), D = fe(e.orderIds, (h) => `"${h}"`), C = n != null && n.length ? "" : fe(
|
|
2252
|
+
(F = e.configs) == null ? void 0 : F.map((h) => h.twapAddress),
|
|
2253
|
+
(h) => `"${h.toLowerCase()}"`
|
|
2254
|
+
), O = e.minDollarValueIn;
|
|
2900
2255
|
return [
|
|
2901
2256
|
n ? `exchange_in: [${n.join(", ")}]` : "",
|
|
2902
2257
|
C ? `twapAddress_in: [${C.join(", ")}]` : "",
|
|
2903
2258
|
t ? `maker_in: [${t.join(", ")}]` : "",
|
|
2904
|
-
|
|
2259
|
+
b ? `transactionHash_in: [${b.join(", ")}]` : "",
|
|
2905
2260
|
D ? `Contract_id_in: [${D.join(", ")}]` : "",
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2261
|
+
O ? `dollarValueIn_gte: ${O}` : "",
|
|
2262
|
+
i ? `srcTokenSymbol_in: [${i.join(", ")}]` : "",
|
|
2263
|
+
a ? `dstTokenSymbol_in: [${a.join(", ")}]` : "",
|
|
2264
|
+
d ? `srcTokenAddress_in: [${d.join(", ")}]` : "",
|
|
2265
|
+
m ? `dstTokenAddress_in: [${m.join(", ")}]` : "",
|
|
2911
2266
|
e != null && e.startDate ? `blockTimestamp_gte: ${e.startDate}` : "",
|
|
2912
2267
|
e != null && e.endDate ? `blockTimestamp_lte: ${e.endDate}` : "",
|
|
2913
2268
|
(e == null ? void 0 : e.orderType) === "limit" ? "ask_dstMinAmount_gt: 1" : "",
|
|
2914
2269
|
(e == null ? void 0 : e.orderType) === "market" ? "ask_dstMinAmount_lte: 1" : ""
|
|
2915
2270
|
].filter(Boolean).join(", ");
|
|
2916
2271
|
};
|
|
2917
|
-
async function
|
|
2272
|
+
async function ur({
|
|
2918
2273
|
chainId: e,
|
|
2919
2274
|
signal: t,
|
|
2920
2275
|
page: n,
|
|
2921
|
-
limit:
|
|
2922
|
-
filters:
|
|
2276
|
+
limit: i,
|
|
2277
|
+
filters: a
|
|
2923
2278
|
}) {
|
|
2924
|
-
const
|
|
2925
|
-
return await
|
|
2279
|
+
const d = i || 1e3, m = cr(a);
|
|
2280
|
+
return await Ye({
|
|
2926
2281
|
chainId: e,
|
|
2927
2282
|
signal: t,
|
|
2928
|
-
limit:
|
|
2283
|
+
limit: d,
|
|
2929
2284
|
page: n,
|
|
2930
2285
|
buildQuery: (D, C) => `
|
|
2931
2286
|
{
|
|
2932
2287
|
orderCreateds(
|
|
2933
|
-
${
|
|
2288
|
+
${m ? `where: { ${m} },` : ""}
|
|
2934
2289
|
first: ${C},
|
|
2935
2290
|
skip: ${D * C},
|
|
2936
2291
|
orderBy: timestamp,
|
|
@@ -2962,28 +2317,28 @@ async function fr({
|
|
|
2962
2317
|
}
|
|
2963
2318
|
}
|
|
2964
2319
|
`,
|
|
2965
|
-
extractResults: (D) =>
|
|
2320
|
+
extractResults: (D) => He(D, "orderCreateds")
|
|
2966
2321
|
});
|
|
2967
2322
|
}
|
|
2968
|
-
const
|
|
2323
|
+
const lr = async ({
|
|
2969
2324
|
chainId: e,
|
|
2970
2325
|
orders: t,
|
|
2971
2326
|
signal: n
|
|
2972
2327
|
}) => {
|
|
2973
2328
|
if (t.length === 0) return [];
|
|
2974
|
-
const
|
|
2975
|
-
if (!
|
|
2976
|
-
const
|
|
2977
|
-
return await
|
|
2329
|
+
const i = qe(t.map((b) => b.Contract_id.toString()));
|
|
2330
|
+
if (!i.length) return [];
|
|
2331
|
+
const d = `where: { twapId_in: [${i.map((b) => `"${b}"`).join(", ")}]}`;
|
|
2332
|
+
return await Ye({
|
|
2978
2333
|
chainId: e,
|
|
2979
2334
|
signal: n,
|
|
2980
2335
|
limit: 1e3,
|
|
2981
|
-
buildQuery: (
|
|
2336
|
+
buildQuery: (b, D) => `
|
|
2982
2337
|
{
|
|
2983
2338
|
statusNews(
|
|
2984
2339
|
first: ${D},
|
|
2985
|
-
skip: ${
|
|
2986
|
-
${
|
|
2340
|
+
skip: ${b * D},
|
|
2341
|
+
${d}
|
|
2987
2342
|
) {
|
|
2988
2343
|
twapId
|
|
2989
2344
|
twapAddress
|
|
@@ -2991,30 +2346,30 @@ const mr = async ({
|
|
|
2991
2346
|
}
|
|
2992
2347
|
}
|
|
2993
2348
|
`,
|
|
2994
|
-
extractResults: (
|
|
2349
|
+
extractResults: (b) => He(b, "statusNews")
|
|
2995
2350
|
});
|
|
2996
2351
|
};
|
|
2997
|
-
function
|
|
2352
|
+
function qe(e) {
|
|
2998
2353
|
return Array.from(new Set(e));
|
|
2999
2354
|
}
|
|
3000
|
-
const
|
|
2355
|
+
const fr = async ({
|
|
3001
2356
|
chainId: e,
|
|
3002
2357
|
orders: t,
|
|
3003
2358
|
signal: n
|
|
3004
2359
|
}) => {
|
|
3005
|
-
const
|
|
3006
|
-
if (
|
|
3007
|
-
const
|
|
3008
|
-
`TWAP_id_in: [${
|
|
3009
|
-
|
|
2360
|
+
const i = qe(t.map((F) => F.Contract_id)), a = qe(t.map((F) => F.twapAddress)).filter(Boolean);
|
|
2361
|
+
if (i.length === 0) return [];
|
|
2362
|
+
const d = i.join(", "), m = a.map((F) => `"${F}"`).join(", "), b = a.length ? `twapAddress_in: [${m}]` : "", C = `where: { ${[
|
|
2363
|
+
`TWAP_id_in: [${d}]`,
|
|
2364
|
+
b
|
|
3010
2365
|
].filter(Boolean).join(", ")} }`;
|
|
3011
|
-
return await
|
|
2366
|
+
return await Ye({
|
|
3012
2367
|
chainId: e,
|
|
3013
2368
|
signal: n,
|
|
3014
2369
|
limit: 1e3,
|
|
3015
|
-
buildQuery: (F,
|
|
2370
|
+
buildQuery: (F, h) => `
|
|
3016
2371
|
{
|
|
3017
|
-
orderFilleds(first: ${
|
|
2372
|
+
orderFilleds(first: ${h}, orderBy: timestamp, skip: ${F * h}, ${C}) {
|
|
3018
2373
|
id
|
|
3019
2374
|
dstAmountOut
|
|
3020
2375
|
dstFee
|
|
@@ -3030,9 +2385,9 @@ const Ar = async ({
|
|
|
3030
2385
|
}
|
|
3031
2386
|
}
|
|
3032
2387
|
`,
|
|
3033
|
-
extractResults: (F) =>
|
|
3034
|
-
...
|
|
3035
|
-
timestamp: new Date(
|
|
2388
|
+
extractResults: (F) => He(F, "orderFilleds").map((h) => ({
|
|
2389
|
+
...h,
|
|
2390
|
+
timestamp: new Date(h.timestamp).getTime()
|
|
3036
2391
|
}))
|
|
3037
2392
|
});
|
|
3038
2393
|
};
|
|
@@ -3041,277 +2396,277 @@ class Et extends Error {
|
|
|
3041
2396
|
super("No graph endpoint found"), this.name = "NoGraphEndpointError";
|
|
3042
2397
|
}
|
|
3043
2398
|
}
|
|
3044
|
-
const
|
|
2399
|
+
const pr = (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", Ar = async ({
|
|
3045
2400
|
chainId: e,
|
|
3046
2401
|
signal: t,
|
|
3047
2402
|
page: n,
|
|
3048
|
-
limit:
|
|
3049
|
-
filters:
|
|
2403
|
+
limit: i,
|
|
2404
|
+
filters: a
|
|
3050
2405
|
}) => {
|
|
3051
2406
|
try {
|
|
3052
|
-
const
|
|
2407
|
+
const d = await ur({
|
|
3053
2408
|
chainId: e,
|
|
3054
2409
|
signal: t,
|
|
3055
2410
|
page: n,
|
|
3056
|
-
limit:
|
|
3057
|
-
filters:
|
|
2411
|
+
limit: i,
|
|
2412
|
+
filters: a
|
|
3058
2413
|
});
|
|
3059
|
-
let
|
|
3060
|
-
const
|
|
3061
|
-
const
|
|
3062
|
-
return
|
|
2414
|
+
let m = 0;
|
|
2415
|
+
const b = d.filter((h) => {
|
|
2416
|
+
const w = pr(h);
|
|
2417
|
+
return w || m++, w;
|
|
3063
2418
|
}), [D, C] = await Promise.all([
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
]),
|
|
3067
|
-
const
|
|
3068
|
-
(
|
|
2419
|
+
fr({ chainId: e, orders: b, signal: t }),
|
|
2420
|
+
lr({ chainId: e, orders: b, signal: t })
|
|
2421
|
+
]), O = b.flatMap((h) => {
|
|
2422
|
+
const w = D == null ? void 0 : D.filter(
|
|
2423
|
+
(B) => String(B.TWAP_id) === String(h.Contract_id) && ke(B.exchange, h.exchange) && ke(B.twapAddress, h.twapAddress)
|
|
3069
2424
|
);
|
|
3070
2425
|
try {
|
|
3071
2426
|
return [
|
|
3072
|
-
|
|
3073
|
-
|
|
2427
|
+
dr(
|
|
2428
|
+
h,
|
|
3074
2429
|
e,
|
|
3075
|
-
|
|
3076
|
-
|
|
2430
|
+
w,
|
|
2431
|
+
yr(h, w || [], C)
|
|
3077
2432
|
)
|
|
3078
2433
|
];
|
|
3079
2434
|
} catch {
|
|
3080
|
-
return
|
|
2435
|
+
return m++, [];
|
|
3081
2436
|
}
|
|
3082
|
-
}).sort((
|
|
3083
|
-
|
|
3084
|
-
`Skipped ${
|
|
2437
|
+
}).sort((h, w) => w.createdAt - h.createdAt);
|
|
2438
|
+
m > 0 && console.warn(
|
|
2439
|
+
`Skipped ${m} invalid legacy order history ${m === 1 ? "item" : "items"} on chain ${e}`
|
|
3085
2440
|
);
|
|
3086
2441
|
const F = /* @__PURE__ */ new Set();
|
|
3087
|
-
return
|
|
3088
|
-
} catch (
|
|
3089
|
-
if (
|
|
3090
|
-
throw
|
|
2442
|
+
return O.filter((h) => F.has(h.historyKey) ? !1 : (F.add(h.historyKey), !0));
|
|
2443
|
+
} catch (d) {
|
|
2444
|
+
if (d instanceof Et) return [];
|
|
2445
|
+
throw d;
|
|
3091
2446
|
}
|
|
3092
|
-
},
|
|
3093
|
-
var
|
|
3094
|
-
const
|
|
3095
|
-
(D) => D.twapId === e.Contract_id.toString() &&
|
|
3096
|
-
)) == null ? void 0 :
|
|
3097
|
-
return Er(
|
|
3098
|
-
},
|
|
3099
|
-
const n =
|
|
3100
|
-
if (!n.isFinite() || !
|
|
3101
|
-
const
|
|
3102
|
-
return
|
|
3103
|
-
}, Er = (e, t, n) => e === 100 ?
|
|
3104
|
-
const t =
|
|
3105
|
-
return
|
|
3106
|
-
},
|
|
3107
|
-
var
|
|
3108
|
-
const t = ((
|
|
2447
|
+
}, yr = (e, t, n) => {
|
|
2448
|
+
var b;
|
|
2449
|
+
const i = (b = n == null ? void 0 : n.find(
|
|
2450
|
+
(D) => D.twapId === e.Contract_id.toString() && ke(D.twapAddress, e.twapAddress)
|
|
2451
|
+
)) == null ? void 0 : b.status, d = yt(t).reduce((D, C) => D.plus(C.inAmount), new x(0)).toFixed(), m = mt(e.ask_srcAmount, d);
|
|
2452
|
+
return Er(m, e.ask_deadline * 1e3, i);
|
|
2453
|
+
}, mt = (e, t) => {
|
|
2454
|
+
const n = x(e || 0), i = x(t || 0);
|
|
2455
|
+
if (!n.isFinite() || !i.isFinite() || n.lte(0)) return 0;
|
|
2456
|
+
const a = i.dividedBy(n).toNumber();
|
|
2457
|
+
return a >= 1 ? 100 : a <= 0 ? 0 : Number((a * 100).toFixed(2));
|
|
2458
|
+
}, Er = (e, t, n) => e === 100 ? ce.Completed : n === "CANCELLED" ? ce.Cancelled : n === "COMPLETED" ? ce.Completed : t > Date.now() ? ce.Open : ce.Expired, mr = (e) => {
|
|
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), m = d || x(a || 0).gt(0), b = !d && x(n || 0).gt(0) || x(i || 0).gt(0), D = x(e.order.witness.input.amount), C = e.metadata.expectedChunks || (D.gt(0) ? x(e.order.witness.input.maxAmount).div(D).toNumber() : 1);
|
|
2460
|
+
return m ? t ? N.TAKE_PROFIT_LIMIT : N.TAKE_PROFIT_MARKET : b ? 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;
|
|
2461
|
+
}, br = (e) => {
|
|
2462
|
+
var a;
|
|
2463
|
+
const t = ((a = e.metadata.chunks) == null ? void 0 : a.filter((d) => d.status === "success").length) || 0, n = e.metadata.expectedChunks || 0;
|
|
3109
2464
|
if (!n) return 0;
|
|
3110
|
-
const
|
|
3111
|
-
return t >= n ? 100 :
|
|
3112
|
-
},
|
|
3113
|
-
var
|
|
3114
|
-
const n = (e.metadata.status || "").toLowerCase(),
|
|
3115
|
-
return n === "completed" || t === 100 ?
|
|
3116
|
-
},
|
|
2465
|
+
const i = x(t).dividedBy(n).toNumber();
|
|
2466
|
+
return t >= n ? 100 : i <= 0 ? 0 : Number((i * 100).toFixed(2));
|
|
2467
|
+
}, hr = (e, t) => {
|
|
2468
|
+
var a;
|
|
2469
|
+
const n = (e.metadata.status || "").toLowerCase(), i = (a = e.metadata.description) == null ? void 0 : a.toLowerCase();
|
|
2470
|
+
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
|
+
}, Tr = (e) => {
|
|
3117
2472
|
var n;
|
|
3118
|
-
return (((n = e.metadata.chunks) == null ? void 0 : n.filter((
|
|
3119
|
-
inAmount:
|
|
3120
|
-
outAmount:
|
|
3121
|
-
timestamp: new Date(
|
|
3122
|
-
txHash:
|
|
3123
|
-
})).sort((
|
|
3124
|
-
},
|
|
3125
|
-
(
|
|
2473
|
+
return (((n = e.metadata.chunks) == null ? void 0 : n.filter((i) => i.status === "success")) || []).map((i) => ({
|
|
2474
|
+
inAmount: i.inAmount,
|
|
2475
|
+
outAmount: i.outAmount,
|
|
2476
|
+
timestamp: new Date(i.timestamp).getTime(),
|
|
2477
|
+
txHash: i.txHash
|
|
2478
|
+
})).sort((i, a) => i.timestamp - a.timestamp);
|
|
2479
|
+
}, xr = (e, t) => e.length >= t ? e.reduce(
|
|
2480
|
+
(i, a) => Math.max(i, a.timestamp),
|
|
3126
2481
|
0
|
|
3127
|
-
) : 0,
|
|
3128
|
-
const t =
|
|
2482
|
+
) : 0, gr = (e) => {
|
|
2483
|
+
const t = x(e.metadata.displayOnlyInputTokenPriceUSD || 0);
|
|
3129
2484
|
return t.isFinite() ? t.dividedBy(1e18).toFixed() : "0";
|
|
3130
|
-
},
|
|
3131
|
-
const { triggerLower: t = "0", triggerUpper: n = "0" } = e.order.witness.output,
|
|
2485
|
+
}, Ze = (e) => x(e.order.witness.output.limit || 0).eq(1) ? "" : e.order.witness.output.limit, Dr = (e) => {
|
|
2486
|
+
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);
|
|
3132
2487
|
return {
|
|
3133
|
-
dstMinAmountPerTrade:
|
|
3134
|
-
triggerPricePerTrade:
|
|
3135
|
-
dstMinAmountTotal:
|
|
2488
|
+
dstMinAmountPerTrade: i,
|
|
2489
|
+
triggerPricePerTrade: d ? n : t,
|
|
2490
|
+
dstMinAmountTotal: i ? x(i).multipliedBy(a).toFixed() : ""
|
|
3136
2491
|
};
|
|
3137
|
-
},
|
|
3138
|
-
const t =
|
|
2492
|
+
}, Fr = (e) => {
|
|
2493
|
+
const t = Ze(e), n = x(e.order.witness.output.stop || 0).eq(pt), i = e.metadata.expectedChunks || 1;
|
|
3139
2494
|
return {
|
|
3140
2495
|
dstMinAmountPerTrade: n ? "" : t,
|
|
3141
|
-
triggerPricePerTrade: n ? t :
|
|
3142
|
-
dstMinAmountTotal: n || !t ? "" :
|
|
2496
|
+
triggerPricePerTrade: n ? t : x(e.order.witness.output.stop || 0).toFixed(),
|
|
2497
|
+
dstMinAmountTotal: n || !t ? "" : x(t).multipliedBy(i).toFixed()
|
|
3143
2498
|
};
|
|
3144
|
-
},
|
|
3145
|
-
const t =
|
|
2499
|
+
}, Cr = (e) => Number(Xe) >= 2 ? Dr(e) : Fr(e), bt = (e) => {
|
|
2500
|
+
const t = br(e), n = Ze(e), i = e.metadata.expectedChunks || 1, a = Tr(e), d = mr(e);
|
|
3146
2501
|
return {
|
|
3147
2502
|
id: e.hash,
|
|
3148
2503
|
hash: e.hash,
|
|
3149
2504
|
version: 2,
|
|
3150
2505
|
historyKey: `2:${e.order.witness.chainid}:${e.hash.toLowerCase()}`,
|
|
3151
|
-
type:
|
|
2506
|
+
type: d,
|
|
3152
2507
|
maker: e.order.witness.swapper,
|
|
3153
2508
|
progress: t,
|
|
3154
|
-
srcAmountFilled:
|
|
3155
|
-
dstAmountFilled:
|
|
3156
|
-
fills:
|
|
2509
|
+
srcAmountFilled: a.reduce((m, b) => m.plus(b.inAmount), new x(0)).toFixed() || "",
|
|
2510
|
+
dstAmountFilled: a.reduce((m, b) => m.plus(b.outAmount), new x(0)).toFixed() || "",
|
|
2511
|
+
fills: a,
|
|
3157
2512
|
srcTokenAddress: e.order.witness.input.token,
|
|
3158
2513
|
dstTokenAddress: e.order.witness.output.token,
|
|
3159
|
-
orderDollarValueIn:
|
|
2514
|
+
orderDollarValueIn: gr(e),
|
|
3160
2515
|
fillDelay: e.order.witness.epoch * 1e3,
|
|
3161
2516
|
deadline: Number(e.order.deadline) * 1e3,
|
|
3162
2517
|
createdAt: new Date(e.timestamp).getTime(),
|
|
3163
2518
|
srcAmount: e.order.witness.input.maxAmount,
|
|
3164
2519
|
srcAmountPerTrade: e.order.witness.input.amount,
|
|
3165
|
-
totalTradesAmount:
|
|
3166
|
-
isMarketPrice:
|
|
2520
|
+
totalTradesAmount: i,
|
|
2521
|
+
isMarketPrice: x(n || 0).lte(1),
|
|
3167
2522
|
chainId: e.order.witness.chainid,
|
|
3168
|
-
filledOrderTimestamp:
|
|
3169
|
-
status:
|
|
2523
|
+
filledOrderTimestamp: xr(a, i),
|
|
2524
|
+
status: hr(e, t),
|
|
3170
2525
|
repermitDigest: e.metadata.repermitDigest,
|
|
3171
|
-
isTriggerPrice:
|
|
2526
|
+
isTriggerPrice: d === N.TAKE_PROFIT_MARKET || d === N.TAKE_PROFIT_LIMIT || d === N.STOP_LOSS_LIMIT || d === N.STOP_LOSS_MARKET,
|
|
3172
2527
|
rawOrder: e,
|
|
3173
|
-
...
|
|
2528
|
+
...Cr(e)
|
|
3174
2529
|
};
|
|
3175
|
-
},
|
|
2530
|
+
}, Br = (e, t) => {
|
|
3176
2531
|
e !== 0 && console.warn(
|
|
3177
2532
|
`Skipped ${e} invalid order history ${e === 1 ? "item" : "items"} from ${t}`
|
|
3178
2533
|
);
|
|
3179
|
-
},
|
|
2534
|
+
}, wr = (e, t) => {
|
|
3180
2535
|
if (!e || typeof e != "object" || !Array.isArray(e.orders))
|
|
3181
2536
|
throw new Error("Invalid order history response: missing orders array");
|
|
3182
2537
|
const n = Number(
|
|
3183
2538
|
e.totalPages
|
|
3184
|
-
),
|
|
2539
|
+
), i = Number.isSafeInteger(n) && n > 0 ? Math.max(t, n) : t;
|
|
3185
2540
|
return {
|
|
3186
2541
|
orders: e.orders,
|
|
3187
|
-
totalPages:
|
|
2542
|
+
totalPages: i
|
|
3188
2543
|
};
|
|
3189
|
-
},
|
|
2544
|
+
}, ot = async ({
|
|
3190
2545
|
endpoint: e,
|
|
3191
2546
|
chainId: t,
|
|
3192
2547
|
signal: n,
|
|
3193
|
-
account:
|
|
3194
|
-
exchange:
|
|
3195
|
-
page:
|
|
3196
|
-
limit:
|
|
2548
|
+
account: i,
|
|
2549
|
+
exchange: a,
|
|
2550
|
+
page: d,
|
|
2551
|
+
limit: m
|
|
3197
2552
|
}) => {
|
|
3198
|
-
const
|
|
3199
|
-
swapper:
|
|
2553
|
+
const b = new URLSearchParams({
|
|
2554
|
+
swapper: i,
|
|
3200
2555
|
chainId: t.toString(),
|
|
3201
|
-
page:
|
|
2556
|
+
page: d.toString()
|
|
3202
2557
|
});
|
|
3203
|
-
|
|
3204
|
-
const D = await fetch(`${e}/orders?${
|
|
2558
|
+
a && b.set("exchange", a), m !== void 0 && b.set("limit", m.toString());
|
|
2559
|
+
const D = await fetch(`${e}/orders?${b}`, { signal: n });
|
|
3205
2560
|
if (!D.ok)
|
|
3206
2561
|
throw new Error(
|
|
3207
2562
|
`Failed to fetch order history from ${e}: ${D.status}`
|
|
3208
2563
|
);
|
|
3209
|
-
const C =
|
|
3210
|
-
let
|
|
3211
|
-
const F = C.orders.flatMap((
|
|
2564
|
+
const C = wr(await D.json(), d);
|
|
2565
|
+
let O = 0;
|
|
2566
|
+
const F = C.orders.flatMap((h) => {
|
|
3212
2567
|
try {
|
|
3213
|
-
return [
|
|
2568
|
+
return [bt(h)];
|
|
3214
2569
|
} catch {
|
|
3215
|
-
return
|
|
2570
|
+
return O++, [];
|
|
3216
2571
|
}
|
|
3217
2572
|
});
|
|
3218
|
-
return
|
|
3219
|
-
},
|
|
2573
|
+
return Br(O, e), { orders: F, totalPages: C.totalPages ?? d };
|
|
2574
|
+
}, Sr = async ({
|
|
3220
2575
|
endpoint: e,
|
|
3221
2576
|
chainId: t,
|
|
3222
2577
|
signal: n,
|
|
3223
|
-
account:
|
|
3224
|
-
exchange:
|
|
3225
|
-
page:
|
|
3226
|
-
limit:
|
|
2578
|
+
account: i,
|
|
2579
|
+
exchange: a,
|
|
2580
|
+
page: d,
|
|
2581
|
+
limit: m
|
|
3227
2582
|
}) => {
|
|
3228
|
-
const
|
|
2583
|
+
const b = d === void 0 ? 1 : d + 1, D = await ot({
|
|
3229
2584
|
endpoint: e,
|
|
3230
2585
|
chainId: t,
|
|
3231
2586
|
signal: n,
|
|
3232
|
-
account:
|
|
3233
|
-
exchange:
|
|
3234
|
-
page:
|
|
3235
|
-
limit:
|
|
2587
|
+
account: i,
|
|
2588
|
+
exchange: a,
|
|
2589
|
+
page: b,
|
|
2590
|
+
limit: m
|
|
3236
2591
|
});
|
|
3237
|
-
if (
|
|
2592
|
+
if (d !== void 0 || b >= D.totalPages)
|
|
3238
2593
|
return D.orders;
|
|
3239
2594
|
const C = Array.from(
|
|
3240
|
-
{ length: D.totalPages -
|
|
3241
|
-
(F,
|
|
3242
|
-
),
|
|
2595
|
+
{ length: D.totalPages - b },
|
|
2596
|
+
(F, h) => b + h + 1
|
|
2597
|
+
), O = await Promise.all(
|
|
3243
2598
|
C.map(
|
|
3244
|
-
(F) =>
|
|
2599
|
+
(F) => ot({
|
|
3245
2600
|
endpoint: e,
|
|
3246
2601
|
chainId: t,
|
|
3247
2602
|
signal: n,
|
|
3248
|
-
account:
|
|
3249
|
-
exchange:
|
|
2603
|
+
account: i,
|
|
2604
|
+
exchange: a,
|
|
3250
2605
|
page: F,
|
|
3251
|
-
limit:
|
|
2606
|
+
limit: m
|
|
3252
2607
|
})
|
|
3253
2608
|
)
|
|
3254
2609
|
);
|
|
3255
2610
|
return [
|
|
3256
2611
|
...D.orders,
|
|
3257
|
-
...
|
|
2612
|
+
...O.flatMap((F) => F.orders)
|
|
3258
2613
|
];
|
|
3259
|
-
},
|
|
3260
|
-
const
|
|
3261
|
-
for (const
|
|
3262
|
-
const
|
|
3263
|
-
for (const
|
|
3264
|
-
const D = (
|
|
3265
|
-
exchange:
|
|
2614
|
+
}, Pr = (e, t, n) => {
|
|
2615
|
+
const i = /* @__PURE__ */ new Map();
|
|
2616
|
+
for (const a of e) {
|
|
2617
|
+
const d = ar({ endpoint: a, exchange: t, partner: n }), m = d.length ? d : [void 0];
|
|
2618
|
+
for (const b of m) {
|
|
2619
|
+
const D = (b == null ? void 0 : b.toLowerCase()) ?? "all", C = i.get(D) ?? {
|
|
2620
|
+
exchange: b,
|
|
3266
2621
|
endpoints: []
|
|
3267
2622
|
};
|
|
3268
|
-
C.endpoints.push(
|
|
2623
|
+
C.endpoints.push(a), i.set(D, C);
|
|
3269
2624
|
}
|
|
3270
2625
|
}
|
|
3271
|
-
return Array.from(
|
|
2626
|
+
return Array.from(i.values());
|
|
3272
2627
|
}, dt = () => {
|
|
3273
2628
|
const e = new Error("Order history request aborted");
|
|
3274
2629
|
throw e.name = "AbortError", e;
|
|
3275
|
-
},
|
|
2630
|
+
}, Or = async ({
|
|
3276
2631
|
chainId: e,
|
|
3277
2632
|
signal: t,
|
|
3278
2633
|
account: n,
|
|
3279
|
-
exchange:
|
|
3280
|
-
partner:
|
|
3281
|
-
page:
|
|
3282
|
-
limit:
|
|
2634
|
+
exchange: i,
|
|
2635
|
+
partner: a,
|
|
2636
|
+
page: d,
|
|
2637
|
+
limit: m
|
|
3283
2638
|
}) => {
|
|
3284
2639
|
if (!n) return [];
|
|
3285
|
-
const
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
2640
|
+
const b = Pr(
|
|
2641
|
+
nr(),
|
|
2642
|
+
i,
|
|
2643
|
+
a
|
|
3289
2644
|
), D = await Promise.allSettled(
|
|
3290
|
-
|
|
3291
|
-
const
|
|
2645
|
+
b.map(async (F) => {
|
|
2646
|
+
const h = await Promise.allSettled(
|
|
3292
2647
|
F.endpoints.map(
|
|
3293
|
-
(
|
|
3294
|
-
endpoint:
|
|
2648
|
+
(B) => Sr({
|
|
2649
|
+
endpoint: B,
|
|
3295
2650
|
chainId: e,
|
|
3296
2651
|
signal: t,
|
|
3297
2652
|
account: n,
|
|
3298
2653
|
exchange: F.exchange,
|
|
3299
|
-
page:
|
|
3300
|
-
limit:
|
|
2654
|
+
page: d,
|
|
2655
|
+
limit: m
|
|
3301
2656
|
})
|
|
3302
2657
|
)
|
|
3303
2658
|
);
|
|
3304
2659
|
t != null && t.aborted && dt();
|
|
3305
|
-
const
|
|
3306
|
-
(
|
|
2660
|
+
const w = h.filter(
|
|
2661
|
+
(B) => B.status === "fulfilled"
|
|
3307
2662
|
);
|
|
3308
|
-
if (!
|
|
3309
|
-
const
|
|
3310
|
-
(
|
|
2663
|
+
if (!w.length) {
|
|
2664
|
+
const B = h.find(
|
|
2665
|
+
(V) => V.status === "rejected"
|
|
3311
2666
|
);
|
|
3312
|
-
throw (
|
|
2667
|
+
throw (B == null ? void 0 : B.reason) instanceof Error ? B.reason : new Error("Failed to fetch order history");
|
|
3313
2668
|
}
|
|
3314
|
-
return
|
|
2669
|
+
return w.flatMap((B) => B.value);
|
|
3315
2670
|
})
|
|
3316
2671
|
);
|
|
3317
2672
|
t != null && t.aborted && dt();
|
|
@@ -3320,232 +2675,229 @@ const br = (e) => (typeof e.Contract_id == "string" || typeof e.Contract_id == "
|
|
|
3320
2675
|
);
|
|
3321
2676
|
if (!C.length) {
|
|
3322
2677
|
const F = D.find(
|
|
3323
|
-
(
|
|
2678
|
+
(h) => h.status === "rejected"
|
|
3324
2679
|
);
|
|
3325
2680
|
throw (F == null ? void 0 : F.reason) instanceof Error ? F.reason : new Error("Failed to fetch order history");
|
|
3326
2681
|
}
|
|
3327
|
-
const
|
|
3328
|
-
for (const F of C.flatMap((
|
|
3329
|
-
|
|
3330
|
-
return Array.from(
|
|
3331
|
-
},
|
|
2682
|
+
const O = /* @__PURE__ */ new Map();
|
|
2683
|
+
for (const F of C.flatMap((h) => h.value))
|
|
2684
|
+
O.has(F.historyKey) || O.set(F.historyKey, F);
|
|
2685
|
+
return Array.from(O.values());
|
|
2686
|
+
}, kr = (e, t) => {
|
|
3332
2687
|
if (e !== void 0 && (!Number.isInteger(e) || e < 0))
|
|
3333
2688
|
throw new Error("Order history page must be a non-negative integer");
|
|
3334
2689
|
if (t !== void 0 && (!Number.isInteger(t) || t <= 0))
|
|
3335
2690
|
throw new Error("Order history limit must be a positive integer");
|
|
3336
|
-
},
|
|
2691
|
+
}, _r = async ({
|
|
3337
2692
|
signal: e,
|
|
3338
2693
|
page: t,
|
|
3339
2694
|
chainId: n,
|
|
3340
|
-
limit:
|
|
3341
|
-
exchange:
|
|
3342
|
-
partner:
|
|
3343
|
-
account:
|
|
3344
|
-
legacyOrders:
|
|
2695
|
+
limit: i,
|
|
2696
|
+
exchange: a,
|
|
2697
|
+
partner: d,
|
|
2698
|
+
account: m,
|
|
2699
|
+
legacyOrders: b = !0
|
|
3345
2700
|
}) => {
|
|
3346
|
-
|
|
3347
|
-
const D =
|
|
2701
|
+
kr(t, i);
|
|
2702
|
+
const D = ln(d, n);
|
|
3348
2703
|
return (await Promise.all([
|
|
3349
|
-
!D || !
|
|
2704
|
+
!D || !b ? Promise.resolve([]) : Ar({
|
|
3350
2705
|
chainId: n,
|
|
3351
2706
|
signal: e,
|
|
3352
2707
|
page: t,
|
|
3353
|
-
limit:
|
|
2708
|
+
limit: i,
|
|
3354
2709
|
filters: {
|
|
3355
|
-
accounts: [
|
|
2710
|
+
accounts: [m],
|
|
3356
2711
|
configs: [D]
|
|
3357
2712
|
}
|
|
3358
2713
|
}),
|
|
3359
|
-
|
|
2714
|
+
Or({
|
|
3360
2715
|
chainId: n,
|
|
3361
2716
|
signal: e,
|
|
3362
|
-
account:
|
|
3363
|
-
exchange:
|
|
3364
|
-
partner:
|
|
2717
|
+
account: m,
|
|
2718
|
+
exchange: a,
|
|
2719
|
+
partner: d,
|
|
3365
2720
|
page: t,
|
|
3366
|
-
limit:
|
|
2721
|
+
limit: i
|
|
3367
2722
|
})
|
|
3368
|
-
]).then(([F,
|
|
3369
|
-
},
|
|
2723
|
+
]).then(([F, h]) => [...F, ...h])).sort((F, h) => h.createdAt - F.createdAt);
|
|
2724
|
+
}, vr = async (e, t) => {
|
|
3370
2725
|
try {
|
|
3371
2726
|
const n = {
|
|
3372
2727
|
signature: t,
|
|
3373
2728
|
order: e,
|
|
3374
2729
|
status: "pending"
|
|
3375
2730
|
};
|
|
3376
|
-
|
|
3377
|
-
const
|
|
2731
|
+
me.onCreateOrderRequest();
|
|
2732
|
+
const i = await fetch(`${er()}/orders/new`, {
|
|
3378
2733
|
method: "POST",
|
|
3379
2734
|
headers: {
|
|
3380
2735
|
"Content-Type": "application/json",
|
|
3381
2736
|
Accept: "application/json"
|
|
3382
2737
|
},
|
|
3383
2738
|
body: JSON.stringify(n)
|
|
3384
|
-
}),
|
|
3385
|
-
if (!
|
|
3386
|
-
const
|
|
3387
|
-
throw new Error(`error:${
|
|
2739
|
+
}), a = await i.json().catch(() => ({}));
|
|
2740
|
+
if (!i.ok || !(a != null && a.success)) {
|
|
2741
|
+
const m = (a == null ? void 0 : a.message) ?? i.statusText ?? "Request failed", b = (a == null ? void 0 : a.code) ?? i.status;
|
|
2742
|
+
throw new Error(`error:${m}, code:${b}`);
|
|
3388
2743
|
}
|
|
3389
|
-
if (!
|
|
2744
|
+
if (!a.signedOrder || typeof a.signedOrder != "object")
|
|
3390
2745
|
throw new Error("Invalid API response: missing signedOrder");
|
|
3391
|
-
const
|
|
3392
|
-
return
|
|
2746
|
+
const d = bt(a.signedOrder);
|
|
2747
|
+
return me.onCreateOrderSuccess(d.id), d;
|
|
3393
2748
|
} catch (n) {
|
|
3394
|
-
throw
|
|
2749
|
+
throw me.onCreateOrderError(n), console.error(n), n;
|
|
3395
2750
|
}
|
|
3396
|
-
},
|
|
3397
|
-
if (!
|
|
3398
|
-
(
|
|
2751
|
+
}, Ir = (e, t) => e + t.unit * t.value + 6e4, Rr = (e, t) => {
|
|
2752
|
+
if (!At().some(
|
|
2753
|
+
(i) => i.name === e && i.chainId === t
|
|
3399
2754
|
))
|
|
3400
2755
|
throw new Error(`Partner "${e}" is not supported on chain ${t}`);
|
|
3401
|
-
},
|
|
3402
|
-
function
|
|
3403
|
-
if (typeof e != "string" || !
|
|
2756
|
+
}, Mr = /^0x[0-9a-f]{40}$/i, Nr = /^0x0{40}$/i;
|
|
2757
|
+
function ct(e, t) {
|
|
2758
|
+
if (typeof e != "string" || !Mr.test(e) || Nr.test(e))
|
|
3404
2759
|
throw new Error(
|
|
3405
2760
|
`Invalid RePermit configuration: ${t} must be a non-zero EVM address`
|
|
3406
2761
|
);
|
|
3407
2762
|
}
|
|
3408
|
-
const
|
|
3409
|
-
var
|
|
3410
|
-
const n = e,
|
|
3411
|
-
if (Number(
|
|
2763
|
+
const Lr = (e, t) => {
|
|
2764
|
+
var m;
|
|
2765
|
+
const n = e, i = n.domain, a = n.order, d = a == null ? void 0 : a.witness;
|
|
2766
|
+
if (Number(i == null ? void 0 : i.chainId) !== t)
|
|
3412
2767
|
throw new Error(
|
|
3413
2768
|
`Invalid RePermit configuration: domain.chainId does not match requested chain ${t}`
|
|
3414
2769
|
);
|
|
3415
|
-
if (Number(
|
|
2770
|
+
if (Number(d == null ? void 0 : d.chainid) !== t)
|
|
3416
2771
|
throw new Error(
|
|
3417
2772
|
`Invalid RePermit configuration: order.witness.chainid does not match requested chain ${t}`
|
|
3418
2773
|
);
|
|
3419
|
-
|
|
3420
|
-
|
|
2774
|
+
ct(
|
|
2775
|
+
i == null ? void 0 : i.verifyingContract,
|
|
3421
2776
|
"domain.verifyingContract"
|
|
3422
|
-
),
|
|
3423
|
-
(
|
|
2777
|
+
), ct(
|
|
2778
|
+
(m = d == null ? void 0 : d.exchange) == null ? void 0 : m.adapter,
|
|
3424
2779
|
"order.witness.exchange.adapter"
|
|
3425
2780
|
);
|
|
3426
|
-
},
|
|
3427
|
-
|
|
3428
|
-
const n = await
|
|
3429
|
-
|
|
3430
|
-
const
|
|
3431
|
-
let
|
|
3432
|
-
const
|
|
2781
|
+
}, Hr = async (e, t) => {
|
|
2782
|
+
Rr(e, t);
|
|
2783
|
+
const n = await ir(e, t);
|
|
2784
|
+
Lr(n, t);
|
|
2785
|
+
const i = n.domain.verifyingContract, a = n.order.witness.exchange.adapter;
|
|
2786
|
+
let d = 0;
|
|
2787
|
+
const m = (h) => (d = Math.max(h, d + 1), d.toString());
|
|
3433
2788
|
return Object.freeze({
|
|
3434
2789
|
partner: e,
|
|
3435
2790
|
chainId: t,
|
|
3436
2791
|
rePermitData: n,
|
|
3437
|
-
spenderAddress:
|
|
3438
|
-
exchangeAddress:
|
|
3439
|
-
prepareOrder: (
|
|
3440
|
-
const { form:
|
|
3441
|
-
if (!
|
|
2792
|
+
spenderAddress: i,
|
|
2793
|
+
exchangeAddress: a,
|
|
2794
|
+
prepareOrder: (h) => {
|
|
2795
|
+
const { form: w } = h;
|
|
2796
|
+
if (!w.canSubmit)
|
|
3442
2797
|
throw new Error("Order form is not submittable");
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
2798
|
+
if (pn(h.inputTokenAddress))
|
|
2799
|
+
throw new Error(
|
|
2800
|
+
"prepareOrder inputTokenAddress must be an ERC-20 address; pass the host-provided wrapped native token for native input"
|
|
2801
|
+
);
|
|
2802
|
+
const B = w.values, V = Date.now(), K = {
|
|
2803
|
+
...B,
|
|
2804
|
+
currentTimeMillis: V,
|
|
2805
|
+
deadlineMillis: Ir(V, B.duration)
|
|
2806
|
+
}, z = sr({
|
|
2807
|
+
inputTokenAddress: h.inputTokenAddress,
|
|
2808
|
+
outputTokenAddress: h.outputTokenAddress,
|
|
2809
|
+
totalInputAmount: B.inputAmount,
|
|
2810
|
+
nonce: m(V),
|
|
3453
2811
|
currentTimeMillis: K.currentTimeMillis,
|
|
3454
2812
|
deadlineMillis: K.deadlineMillis,
|
|
3455
|
-
fillDelayMillis:
|
|
3456
|
-
totalTrades:
|
|
3457
|
-
slippageBps:
|
|
3458
|
-
swapperAddress:
|
|
3459
|
-
inputAmountPerTrade:
|
|
3460
|
-
minOutputAmountPerTrade:
|
|
3461
|
-
triggerOutputAmountPerTrade:
|
|
2813
|
+
fillDelayMillis: B.fillDelayMillis,
|
|
2814
|
+
totalTrades: B.totalTrades,
|
|
2815
|
+
slippageBps: B.slippageBps,
|
|
2816
|
+
swapperAddress: h.swapperAddress,
|
|
2817
|
+
inputAmountPerTrade: B.inputAmountPerTrade,
|
|
2818
|
+
minOutputAmountPerTrade: B.minOutputAmountPerTrade,
|
|
2819
|
+
triggerOutputAmountPerTrade: B.triggerOutputAmountPerTrade,
|
|
3462
2820
|
permitData: n,
|
|
3463
|
-
module:
|
|
3464
|
-
}),
|
|
2821
|
+
module: w.module
|
|
2822
|
+
}), g = z.order;
|
|
3465
2823
|
return {
|
|
3466
|
-
order:
|
|
2824
|
+
order: g,
|
|
3467
2825
|
signingRequest: {
|
|
3468
|
-
signerAddress:
|
|
2826
|
+
signerAddress: h.swapperAddress,
|
|
3469
2827
|
typedData: {
|
|
3470
|
-
domain:
|
|
3471
|
-
types:
|
|
3472
|
-
primaryType:
|
|
3473
|
-
message:
|
|
2828
|
+
domain: z.domain,
|
|
2829
|
+
types: z.types,
|
|
2830
|
+
primaryType: z.primaryType,
|
|
2831
|
+
message: g
|
|
3474
2832
|
}
|
|
3475
2833
|
},
|
|
3476
2834
|
approvalRequest: {
|
|
3477
|
-
tokenAddress:
|
|
3478
|
-
amount:
|
|
3479
|
-
spenderAddress:
|
|
2835
|
+
tokenAddress: g.permitted.token,
|
|
2836
|
+
amount: B.inputAmount,
|
|
2837
|
+
spenderAddress: i
|
|
3480
2838
|
},
|
|
3481
|
-
form:
|
|
2839
|
+
form: w,
|
|
3482
2840
|
values: K
|
|
3483
2841
|
};
|
|
3484
2842
|
},
|
|
3485
|
-
signOrder: async (
|
|
3486
|
-
|
|
2843
|
+
signOrder: async (h, w) => {
|
|
2844
|
+
me.onSignOrderRequest(h.order);
|
|
3487
2845
|
try {
|
|
3488
|
-
const
|
|
3489
|
-
return
|
|
3490
|
-
} catch (
|
|
3491
|
-
throw
|
|
2846
|
+
const B = await w(h.signingRequest);
|
|
2847
|
+
return me.onSignOrderSuccess(B), B;
|
|
2848
|
+
} catch (B) {
|
|
2849
|
+
throw me.onSignOrderError(B), B;
|
|
3492
2850
|
}
|
|
3493
2851
|
},
|
|
3494
|
-
submitOrder: (
|
|
3495
|
-
getCancelOrderRequest: (
|
|
3496
|
-
const
|
|
3497
|
-
if (!
|
|
2852
|
+
submitOrder: (h, w) => vr(h.order, w),
|
|
2853
|
+
getCancelOrderRequest: (h) => {
|
|
2854
|
+
const w = h.version === 1 ? h.twapAddress : i;
|
|
2855
|
+
if (!w)
|
|
3498
2856
|
throw new Error("Cancellation contract address is unavailable");
|
|
3499
2857
|
return {
|
|
3500
|
-
order:
|
|
3501
|
-
contractAddress:
|
|
3502
|
-
args:
|
|
3503
|
-
abi:
|
|
2858
|
+
order: h,
|
|
2859
|
+
contractAddress: w,
|
|
2860
|
+
args: h.version === 1 ? [h.id] : [[h.repermitDigest]],
|
|
2861
|
+
abi: h.version === 1 ? jn : zn
|
|
3504
2862
|
};
|
|
3505
2863
|
},
|
|
3506
|
-
getAccountOrders: (
|
|
3507
|
-
...
|
|
2864
|
+
getAccountOrders: (h) => _r({
|
|
2865
|
+
...h,
|
|
3508
2866
|
chainId: t,
|
|
3509
|
-
exchange:
|
|
2867
|
+
exchange: a,
|
|
3510
2868
|
partner: e
|
|
3511
2869
|
})
|
|
3512
2870
|
});
|
|
3513
|
-
};
|
|
2871
|
+
}, Yr = "https://www.orbs.com/dtwap-and-dlimit-faq/", Zr = "https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP", Qr = "https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg", Jr = "https://www.orbs.com/", ea = "https://www.orbs.com/dtwap-dlimit-disclaimer";
|
|
3514
2872
|
export {
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
2873
|
+
ea as DISCLAIMER_URL,
|
|
2874
|
+
J as InputErrors,
|
|
2875
|
+
v as Module,
|
|
2876
|
+
Qr as ORBS_LOGO,
|
|
2877
|
+
Zr as ORBS_SLTP_FAQ_URL,
|
|
2878
|
+
Yr as ORBS_TWAP_FAQ_URL,
|
|
2879
|
+
Jr as ORBS_WEBSITE_URL,
|
|
2880
|
+
xt as OrderFilter,
|
|
2881
|
+
ce as OrderStatus,
|
|
3524
2882
|
N as OrderType,
|
|
3525
|
-
|
|
2883
|
+
Q as Partners,
|
|
3526
2884
|
Xe as SPOT_VERSION,
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
Z as networks,
|
|
3546
|
-
sa as setUIVersion,
|
|
3547
|
-
Xr as shouldUnwrapOnly,
|
|
3548
|
-
jr as shouldWrapOnly,
|
|
3549
|
-
Me as toAmountUI,
|
|
3550
|
-
At as toAmountWei
|
|
2885
|
+
se as TimeUnit,
|
|
2886
|
+
me as analytics,
|
|
2887
|
+
jr as calculateOrderForm,
|
|
2888
|
+
Hr as createClient,
|
|
2889
|
+
ke as eqIgnoreCase,
|
|
2890
|
+
qr as getOrderExecutionRate,
|
|
2891
|
+
Vr as getOrderFillDelayMillis,
|
|
2892
|
+
Wr as getOrderLimitPriceRate,
|
|
2893
|
+
Gr as getPartnerChains,
|
|
2894
|
+
At as getPartners,
|
|
2895
|
+
zr as getTriggerPriceRate,
|
|
2896
|
+
ln as getTwapConfig,
|
|
2897
|
+
$r as invertPriceInput,
|
|
2898
|
+
pn as isNativeAddress,
|
|
2899
|
+
Kr as isTxRejected,
|
|
2900
|
+
Xr as setUIVersion,
|
|
2901
|
+
We as toAmountRaw,
|
|
2902
|
+
ze as toAmountUI
|
|
3551
2903
|
};
|