@swapkit/helpers 1.0.0-rc.2 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +69 -47
- package/dist/index.es.js +822 -422
- package/package.json +9 -6
- package/src/helpers/asset.ts +24 -14
- package/src/helpers/liquidity.ts +12 -10
- package/src/helpers/others.ts +0 -39
- package/src/helpers/request.ts +15 -0
- package/src/index.ts +5 -4
- package/src/modules/__tests__/assetValue.test.ts +44 -9
- package/src/modules/__tests__/swapKitNumber.test.ts +204 -78
- package/src/modules/assetValue.ts +87 -80
- package/src/modules/bigIntArithmetics.ts +226 -101
- package/src/modules/swapKitNumber.ts +6 -3
- package/src/helpers/number.ts +0 -40
package/dist/index.es.js
CHANGED
|
@@ -1,317 +1,661 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
if (!t.has(
|
|
1
|
+
var gt = Object.defineProperty;
|
|
2
|
+
var bt = (s, t, e) => t in s ? gt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var f = (s, t, e) => (bt(s, typeof t != "symbol" ? t + "" : t, e), e), yt = (s, t, e) => {
|
|
4
|
+
if (!t.has(s))
|
|
5
5
|
throw TypeError("Cannot " + e);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (t.has(
|
|
7
|
+
var y = (s, t, e) => {
|
|
8
|
+
if (t.has(s))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
t instanceof WeakSet ? t.add(
|
|
10
|
+
t instanceof WeakSet ? t.add(s) : t.set(s, e);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
import { FeeOption as
|
|
14
|
-
const
|
|
15
|
-
if (n < 0)
|
|
16
|
-
throw new Error("Invalid number of year");
|
|
17
|
-
return 10 + n;
|
|
18
|
-
}, Ct = (n) => {
|
|
19
|
-
if (n.length > 30)
|
|
20
|
-
return !1;
|
|
21
|
-
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
22
|
-
return !!n.match(t);
|
|
23
|
-
}, Tt = ([n, t, e, r, s]) => `${n}'/${t}'/${e}'/${r}${typeof s != "number" ? "" : `/${s}`}`, Bt = async (n, t) => {
|
|
24
|
-
const e = Object.entries(t || {}).reduce(
|
|
25
|
-
(s, [a, c]) => (c && (s[a] = c), s),
|
|
26
|
-
{}
|
|
27
|
-
);
|
|
28
|
-
return (await fetch(
|
|
29
|
-
`${n}${t ? `?${new URLSearchParams(e).toString()}` : ""}`,
|
|
30
|
-
{ method: "GET", mode: "cors", credentials: "omit", referrer: "https://sk.thorswap.net" }
|
|
31
|
-
)).json();
|
|
32
|
-
}, ct = async (n, t, e, r = !1) => {
|
|
33
|
-
const s = await fetch(`${n}`, {
|
|
34
|
-
body: t,
|
|
35
|
-
headers: e,
|
|
36
|
-
method: "POST",
|
|
37
|
-
referrer: "https://sk.thorswap.net"
|
|
38
|
-
});
|
|
39
|
-
return r ? s.text() : s.json();
|
|
40
|
-
}, ot = "0x313ce567", K = async ({ chain: n, to: t }) => {
|
|
12
|
+
var m = (s, t, e) => (yt(s, t, "access private method"), e);
|
|
13
|
+
import { FeeOption as L, BaseDecimal as d, Chain as o, ChainToRPC as wt, MemoType as g } from "@swapkit/types";
|
|
14
|
+
const At = "0x313ce567", nt = async ({ chain: s, to: t }) => {
|
|
41
15
|
try {
|
|
42
|
-
const e = await
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
const { result: e } = await Qt.post(wt[s], {
|
|
17
|
+
headers: {
|
|
18
|
+
accept: "*/*",
|
|
19
|
+
"content-type": "application/json",
|
|
20
|
+
"cache-control": "no-cache"
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify({
|
|
47
23
|
id: 44,
|
|
48
|
-
jsonrpc: "2.0"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return parseInt(BigInt(
|
|
24
|
+
jsonrpc: "2.0",
|
|
25
|
+
method: "eth_call",
|
|
26
|
+
params: [{ to: t.toLowerCase(), data: At }, "latest"]
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
return parseInt(BigInt(e).toString());
|
|
54
30
|
} catch (e) {
|
|
55
|
-
return console.error(e),
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
60
|
-
const [, t] =
|
|
61
|
-
return t != null && t.startsWith("0x") ?
|
|
62
|
-
},
|
|
63
|
-
const [, t] =
|
|
64
|
-
return t != null && t.startsWith("0x") ?
|
|
65
|
-
},
|
|
66
|
-
switch (
|
|
67
|
-
case
|
|
68
|
-
return
|
|
69
|
-
case
|
|
70
|
-
return
|
|
71
|
-
case
|
|
72
|
-
return
|
|
31
|
+
return console.error(e), d[s];
|
|
32
|
+
}
|
|
33
|
+
}, Tt = async (s) => {
|
|
34
|
+
if (s === o.Ethereum)
|
|
35
|
+
return d.ETH;
|
|
36
|
+
const [, t] = s.split("-");
|
|
37
|
+
return t != null && t.startsWith("0x") ? nt({ chain: o.Ethereum, to: t }) : d.ETH;
|
|
38
|
+
}, vt = async (s) => {
|
|
39
|
+
const [, t] = s.split("-");
|
|
40
|
+
return t != null && t.startsWith("0x") ? nt({ chain: o.Avalanche, to: t.toLowerCase() }) : d.AVAX;
|
|
41
|
+
}, St = async (s) => s === o.BinanceSmartChain ? d.BSC : d.BSC, Rt = async ({ chain: s, symbol: t }) => {
|
|
42
|
+
switch (s) {
|
|
43
|
+
case o.Ethereum:
|
|
44
|
+
return Tt(t);
|
|
45
|
+
case o.Avalanche:
|
|
46
|
+
return vt(t);
|
|
47
|
+
case o.BinanceSmartChain:
|
|
48
|
+
return St(t);
|
|
73
49
|
default:
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
},
|
|
81
|
-
switch (
|
|
82
|
-
case
|
|
83
|
-
case
|
|
84
|
-
case
|
|
85
|
-
case
|
|
86
|
-
case
|
|
87
|
-
case
|
|
88
|
-
case
|
|
89
|
-
return t ===
|
|
90
|
-
case
|
|
91
|
-
case
|
|
50
|
+
return d[s];
|
|
51
|
+
}
|
|
52
|
+
}, re = {
|
|
53
|
+
[L.Average]: 1.2,
|
|
54
|
+
[L.Fast]: 1.5,
|
|
55
|
+
[L.Fastest]: 2
|
|
56
|
+
}, $t = ({ chain: s, symbol: t }) => {
|
|
57
|
+
switch (s) {
|
|
58
|
+
case o.Bitcoin:
|
|
59
|
+
case o.BitcoinCash:
|
|
60
|
+
case o.Litecoin:
|
|
61
|
+
case o.Dogecoin:
|
|
62
|
+
case o.Binance:
|
|
63
|
+
case o.Ethereum:
|
|
64
|
+
case o.Avalanche:
|
|
65
|
+
return t === s;
|
|
66
|
+
case o.Arbitrum:
|
|
67
|
+
case o.Optimism:
|
|
92
68
|
return t === "ETH";
|
|
93
|
-
case
|
|
69
|
+
case o.Maya:
|
|
94
70
|
return t === "CACAO";
|
|
95
|
-
case
|
|
71
|
+
case o.Kujira:
|
|
96
72
|
return t === "KUJI";
|
|
97
|
-
case
|
|
73
|
+
case o.Cosmos:
|
|
98
74
|
return t === "ATOM";
|
|
99
|
-
case
|
|
75
|
+
case o.Polygon:
|
|
100
76
|
return t === "MATIC";
|
|
101
|
-
case
|
|
77
|
+
case o.BinanceSmartChain:
|
|
102
78
|
return t === "BNB";
|
|
103
|
-
case
|
|
79
|
+
case o.THORChain:
|
|
104
80
|
return t === "RUNE";
|
|
105
81
|
}
|
|
106
|
-
},
|
|
107
|
-
switch (
|
|
82
|
+
}, Ct = (s) => {
|
|
83
|
+
switch (s) {
|
|
108
84
|
case "ETH.THOR":
|
|
109
85
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
110
86
|
case "ETH.vTHOR":
|
|
111
87
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
112
|
-
case
|
|
113
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
114
|
-
case
|
|
115
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
116
|
-
case
|
|
117
|
-
return { identifier: "BSC.BNB", decimal:
|
|
118
|
-
case
|
|
119
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
88
|
+
case o.Cosmos:
|
|
89
|
+
return { identifier: "GAIA.ATOM", decimal: d[s] };
|
|
90
|
+
case o.THORChain:
|
|
91
|
+
return { identifier: "THOR.RUNE", decimal: d[s] };
|
|
92
|
+
case o.BinanceSmartChain:
|
|
93
|
+
return { identifier: "BSC.BNB", decimal: d[s] };
|
|
94
|
+
case o.Maya:
|
|
95
|
+
return { identifier: "MAYA.CACAO", decimal: d.MAYA };
|
|
120
96
|
case "MAYA.MAYA":
|
|
121
97
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
122
|
-
case
|
|
123
|
-
case
|
|
124
|
-
case
|
|
125
|
-
case
|
|
126
|
-
case
|
|
127
|
-
case
|
|
128
|
-
case
|
|
129
|
-
case
|
|
130
|
-
case
|
|
131
|
-
case
|
|
132
|
-
case
|
|
133
|
-
return { identifier: `${
|
|
134
|
-
}
|
|
135
|
-
},
|
|
98
|
+
case o.Kujira:
|
|
99
|
+
case o.Arbitrum:
|
|
100
|
+
case o.Optimism:
|
|
101
|
+
case o.BitcoinCash:
|
|
102
|
+
case o.Litecoin:
|
|
103
|
+
case o.Dogecoin:
|
|
104
|
+
case o.Binance:
|
|
105
|
+
case o.Avalanche:
|
|
106
|
+
case o.Polygon:
|
|
107
|
+
case o.Bitcoin:
|
|
108
|
+
case o.Ethereum:
|
|
109
|
+
return { identifier: `${s}.${s}`, decimal: d[s] };
|
|
110
|
+
}
|
|
111
|
+
}, It = ({ chain: s, symbol: t }) => {
|
|
136
112
|
if (t.includes("/"))
|
|
137
113
|
return "Synth";
|
|
138
|
-
switch (
|
|
139
|
-
case
|
|
140
|
-
case
|
|
141
|
-
case
|
|
142
|
-
case
|
|
143
|
-
case
|
|
144
|
-
case
|
|
114
|
+
switch (s) {
|
|
115
|
+
case o.Bitcoin:
|
|
116
|
+
case o.BitcoinCash:
|
|
117
|
+
case o.Dogecoin:
|
|
118
|
+
case o.Litecoin:
|
|
119
|
+
case o.Maya:
|
|
120
|
+
case o.THORChain:
|
|
145
121
|
return "Native";
|
|
146
|
-
case
|
|
147
|
-
return t === "ATOM" ? "Native" :
|
|
148
|
-
case
|
|
149
|
-
return t ===
|
|
150
|
-
case
|
|
151
|
-
return t ===
|
|
152
|
-
case
|
|
153
|
-
return t ===
|
|
154
|
-
case
|
|
155
|
-
return t ===
|
|
156
|
-
case
|
|
157
|
-
return t ===
|
|
158
|
-
case
|
|
159
|
-
return t ===
|
|
160
|
-
case
|
|
161
|
-
return [
|
|
162
|
-
case
|
|
163
|
-
return [
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
var
|
|
167
|
-
const [t, ...e] =
|
|
168
|
-
return { chain: t, symbol:
|
|
169
|
-
},
|
|
170
|
-
|
|
122
|
+
case o.Cosmos:
|
|
123
|
+
return t === "ATOM" ? "Native" : o.Cosmos;
|
|
124
|
+
case o.Kujira:
|
|
125
|
+
return t === o.Kujira ? "Native" : o.Kujira;
|
|
126
|
+
case o.Binance:
|
|
127
|
+
return t === o.Binance ? "Native" : "BEP2";
|
|
128
|
+
case o.BinanceSmartChain:
|
|
129
|
+
return t === o.Binance ? "Native" : "BEP20";
|
|
130
|
+
case o.Ethereum:
|
|
131
|
+
return t === o.Ethereum ? "Native" : "ERC20";
|
|
132
|
+
case o.Avalanche:
|
|
133
|
+
return t === o.Avalanche ? "Native" : o.Avalanche;
|
|
134
|
+
case o.Polygon:
|
|
135
|
+
return t === o.Polygon ? "Native" : "POLYGON";
|
|
136
|
+
case o.Arbitrum:
|
|
137
|
+
return [o.Ethereum, o.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
|
|
138
|
+
case o.Optimism:
|
|
139
|
+
return [o.Ethereum, o.Optimism].includes(t) ? "Native" : "OPTIMISM";
|
|
140
|
+
}
|
|
141
|
+
}, se = (s) => {
|
|
142
|
+
var a;
|
|
143
|
+
const [t, ...e] = s.split("."), r = s.includes("/"), n = e.join("."), i = (a = n == null ? void 0 : n.split("-")) == null ? void 0 : a[0];
|
|
144
|
+
return { chain: t, symbol: n, ticker: i, synth: r };
|
|
145
|
+
}, Et = new RegExp(
|
|
146
|
+
/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
|
|
147
|
+
"gmi"
|
|
148
|
+
), ne = (s) => s.filter(
|
|
149
|
+
(t) => !Et.test(t.toString()) && !t.toString().includes("undefined")
|
|
150
|
+
), Bt = ({
|
|
151
|
+
liquidityUnits: s,
|
|
171
152
|
poolUnits: t,
|
|
172
153
|
runeDepth: e
|
|
173
154
|
}) => {
|
|
174
|
-
const r =
|
|
175
|
-
return
|
|
176
|
-
},
|
|
177
|
-
liquidityUnits:
|
|
155
|
+
const r = p(s), n = p(t), i = p(e), a = r.mul(i), c = n.mul(n).mul(2), u = n.mul(r).mul(2), l = r.mul(r), h = n.mul(n).mul(n);
|
|
156
|
+
return a.mul(c.sub(u).add(l)).div(h);
|
|
157
|
+
}, Ot = ({
|
|
158
|
+
liquidityUnits: s,
|
|
178
159
|
poolUnits: t,
|
|
179
160
|
assetDepth: e
|
|
180
161
|
}) => {
|
|
181
|
-
const r =
|
|
182
|
-
return
|
|
183
|
-
},
|
|
184
|
-
percent:
|
|
162
|
+
const r = p(s), n = p(t), i = p(e), a = r.mul(i), c = n.mul(n).mul(2), u = n.mul(r).mul(2), l = r.mul(r), h = a.mul(c.sub(u).add(l)), _ = n.mul(n).mul(n);
|
|
163
|
+
return h.div(_);
|
|
164
|
+
}, ie = ({
|
|
165
|
+
percent: s,
|
|
185
166
|
runeDepth: t,
|
|
186
167
|
liquidityUnits: e,
|
|
187
168
|
poolUnits: r
|
|
188
|
-
}) =>
|
|
189
|
-
percent:
|
|
169
|
+
}) => Bt({ runeDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), oe = ({
|
|
170
|
+
percent: s,
|
|
190
171
|
assetDepth: t,
|
|
191
172
|
liquidityUnits: e,
|
|
192
173
|
poolUnits: r
|
|
193
|
-
}) =>
|
|
194
|
-
liquidityUnits:
|
|
174
|
+
}) => Ot({ assetDepth: t, liquidityUnits: e, poolUnits: r }).mul(s), p = (s) => b.fromBigInt(BigInt(s), d.THOR), Vt = ({
|
|
175
|
+
liquidityUnits: s,
|
|
195
176
|
poolUnits: t,
|
|
196
177
|
runeDepth: e,
|
|
197
178
|
assetDepth: r
|
|
198
179
|
}) => ({
|
|
199
|
-
assetAmount:
|
|
200
|
-
runeAmount:
|
|
201
|
-
}),
|
|
202
|
-
liquidityUnits:
|
|
180
|
+
assetAmount: p(r).mul(s).div(t),
|
|
181
|
+
runeAmount: p(e).mul(s).div(t)
|
|
182
|
+
}), ae = ({
|
|
183
|
+
liquidityUnits: s,
|
|
203
184
|
poolUnits: t,
|
|
204
185
|
runeDepth: e,
|
|
205
186
|
assetDepth: r,
|
|
206
|
-
percent:
|
|
187
|
+
percent: n
|
|
207
188
|
}) => Object.fromEntries(
|
|
208
|
-
Object.entries(
|
|
209
|
-
([
|
|
189
|
+
Object.entries(Vt({ liquidityUnits: s, poolUnits: t, runeDepth: e, assetDepth: r })).map(
|
|
190
|
+
([i, a]) => [i, a.mul(n)]
|
|
210
191
|
)
|
|
211
|
-
),
|
|
212
|
-
runeDepth:
|
|
192
|
+
), ce = ({
|
|
193
|
+
runeDepth: s,
|
|
213
194
|
poolUnits: t,
|
|
214
195
|
assetDepth: e,
|
|
215
196
|
liquidityUnits: r,
|
|
216
|
-
runeAmount: s,
|
|
217
|
-
assetAmount: a
|
|
218
|
-
}) => {
|
|
219
|
-
const c = m(n), o = m(e), l = m(t), u = m(s), g = m(a), $ = u.mul(o), v = g.mul(c), D = u.mul(g), Z = c.mul(o), tt = l.mul($.add(v.add(D.mul(2)))), et = $.add(v.add(Z.mul(2))), U = tt.div(et), H = m(r).add(U);
|
|
220
|
-
if (U.baseValueNumber === 0)
|
|
221
|
-
return H.div(l).baseValueNumber;
|
|
222
|
-
const nt = l.add(H);
|
|
223
|
-
return H.div(nt).baseValueNumber;
|
|
224
|
-
}, Rt = ({
|
|
225
197
|
runeAmount: n,
|
|
198
|
+
assetAmount: i
|
|
199
|
+
}) => {
|
|
200
|
+
const a = new b({ value: s, decimal: 8 }), c = new b({ value: e, decimal: 8 }), u = new b({ value: t, decimal: 8 }), l = new b({ value: n, decimal: 8 }), h = new b({ value: i, decimal: 8 }), _ = l.mul(c), v = h.mul(a), j = l.mul(h), mt = a.mul(c), pt = u.mul(_.add(v.add(j.mul(2)))), ft = _.add(v.add(mt.mul(2))), Q = pt.div(ft), H = p(r).add(Q);
|
|
201
|
+
if (Q.getBaseValue("number") === 0)
|
|
202
|
+
return H.div(u).getBaseValue("number");
|
|
203
|
+
const _t = u.add(H);
|
|
204
|
+
return H.div(_t).getBaseValue("number");
|
|
205
|
+
}, ue = ({
|
|
206
|
+
runeAmount: s,
|
|
226
207
|
assetAmount: t,
|
|
227
208
|
runeDepth: e,
|
|
228
209
|
assetDepth: r
|
|
229
210
|
}) => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
211
|
+
if (s === "0" || t === "0" || e === "0" || r === "0")
|
|
212
|
+
return 0;
|
|
213
|
+
const n = p(e), i = p(r), a = p(t), c = p(s), u = a.mul(n).sub(i.mul(c)), l = i.mul(c).add(n.mul(i));
|
|
214
|
+
return Math.abs(u.div(l).getBaseValue("number"));
|
|
215
|
+
}, Mt = ({
|
|
216
|
+
symbol: s,
|
|
234
217
|
ticker: t,
|
|
235
218
|
chain: e
|
|
236
|
-
}) => e === "ETH" && t !== "ETH" ? `${t}-${
|
|
237
|
-
switch (
|
|
238
|
-
case
|
|
239
|
-
case
|
|
219
|
+
}) => e === "ETH" && t !== "ETH" ? `${t}-${s.slice(-3)}` : s, le = (s, t) => {
|
|
220
|
+
switch (s) {
|
|
221
|
+
case g.LEAVE:
|
|
222
|
+
case g.BOND: {
|
|
240
223
|
const { address: e } = t;
|
|
241
|
-
return `${
|
|
224
|
+
return `${s}:${e}`;
|
|
242
225
|
}
|
|
243
|
-
case
|
|
226
|
+
case g.UNBOND: {
|
|
244
227
|
const { address: e, unbondAmount: r } = t;
|
|
245
|
-
return `${
|
|
228
|
+
return `${s}:${e}:${r * 10 ** 8}`;
|
|
246
229
|
}
|
|
247
|
-
case
|
|
248
|
-
const { name: e, chain: r, address:
|
|
249
|
-
return `${
|
|
230
|
+
case g.THORNAME_REGISTER: {
|
|
231
|
+
const { name: e, chain: r, address: n, owner: i } = t;
|
|
232
|
+
return `${s}:${e}:${r}:${n}${i ? `:${i}` : ""}`;
|
|
250
233
|
}
|
|
251
|
-
case
|
|
252
|
-
const { chain: e, symbol: r, address:
|
|
253
|
-
return
|
|
234
|
+
case g.DEPOSIT: {
|
|
235
|
+
const { chain: e, symbol: r, address: n, singleSide: i } = t;
|
|
236
|
+
return i ? `${s}:${e}/${r}::t:0` : `${s}:${e}.${r}:${n || ""}:t:0`;
|
|
254
237
|
}
|
|
255
|
-
case
|
|
256
|
-
const { chain: e, ticker: r, symbol:
|
|
257
|
-
return `${
|
|
238
|
+
case g.WITHDRAW: {
|
|
239
|
+
const { chain: e, ticker: r, symbol: n, basisPoints: i, targetAssetString: a, singleSide: c } = t, u = !c && a ? `:${a}` : "", l = Mt({ chain: e, symbol: n, ticker: r });
|
|
240
|
+
return `${s}:${e}${c ? "/" : "."}${l}:${i}${u}`;
|
|
258
241
|
}
|
|
259
|
-
case
|
|
260
|
-
case
|
|
242
|
+
case g.OPEN_LOAN:
|
|
243
|
+
case g.CLOSE_LOAN: {
|
|
261
244
|
const { asset: e, address: r } = t;
|
|
262
|
-
return `${
|
|
245
|
+
return `${s}:${e}:${r}`;
|
|
263
246
|
}
|
|
264
247
|
default:
|
|
265
248
|
return "";
|
|
266
249
|
}
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
""
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
250
|
+
}, he = (s) => {
|
|
251
|
+
if (s < 0)
|
|
252
|
+
throw new Error("Invalid number of year");
|
|
253
|
+
return 10 + s;
|
|
254
|
+
}, de = (s) => {
|
|
255
|
+
if (s.length > 30)
|
|
256
|
+
return !1;
|
|
257
|
+
const t = /^[a-zA-Z0-9+_-]+$/g;
|
|
258
|
+
return !!s.match(t);
|
|
259
|
+
}, me = ([s, t, e, r, n]) => `${s}'/${t}'/${e}'/${r}${typeof n != "number" ? "" : `/${n}`}`;
|
|
260
|
+
class X extends Error {
|
|
261
|
+
constructor(t, e, r) {
|
|
262
|
+
const n = t.status || t.status === 0 ? t.status : "", i = t.statusText || "", a = `${n} ${i}`.trim(), c = a ? `status code ${a}` : "an unknown error";
|
|
263
|
+
super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
|
|
264
|
+
enumerable: !0,
|
|
265
|
+
configurable: !0,
|
|
266
|
+
writable: !0,
|
|
267
|
+
value: void 0
|
|
268
|
+
}), Object.defineProperty(this, "request", {
|
|
269
|
+
enumerable: !0,
|
|
270
|
+
configurable: !0,
|
|
271
|
+
writable: !0,
|
|
272
|
+
value: void 0
|
|
273
|
+
}), Object.defineProperty(this, "options", {
|
|
274
|
+
enumerable: !0,
|
|
275
|
+
configurable: !0,
|
|
276
|
+
writable: !0,
|
|
277
|
+
value: void 0
|
|
278
|
+
}), this.name = "HTTPError", this.response = t, this.request = e, this.options = r;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
class it extends Error {
|
|
282
|
+
constructor(t) {
|
|
283
|
+
super("Request timed out"), Object.defineProperty(this, "request", {
|
|
284
|
+
enumerable: !0,
|
|
285
|
+
configurable: !0,
|
|
286
|
+
writable: !0,
|
|
287
|
+
value: void 0
|
|
288
|
+
}), this.name = "TimeoutError", this.request = t;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const M = (s) => s !== null && typeof s == "object", V = (...s) => {
|
|
292
|
+
for (const t of s)
|
|
293
|
+
if ((!M(t) || Array.isArray(t)) && t !== void 0)
|
|
294
|
+
throw new TypeError("The `options` argument must be an object");
|
|
295
|
+
return J({}, ...s);
|
|
296
|
+
}, ot = (s = {}, t = {}) => {
|
|
297
|
+
const e = new globalThis.Headers(s), r = t instanceof globalThis.Headers, n = new globalThis.Headers(t);
|
|
298
|
+
for (const [i, a] of n.entries())
|
|
299
|
+
r && a === "undefined" || a === void 0 ? e.delete(i) : e.set(i, a);
|
|
300
|
+
return e;
|
|
301
|
+
}, J = (...s) => {
|
|
302
|
+
let t = {}, e = {};
|
|
303
|
+
for (const r of s)
|
|
304
|
+
if (Array.isArray(r))
|
|
305
|
+
Array.isArray(t) || (t = []), t = [...t, ...r];
|
|
306
|
+
else if (M(r)) {
|
|
307
|
+
for (let [n, i] of Object.entries(r))
|
|
308
|
+
M(i) && n in t && (i = J(t[n], i)), t = { ...t, [n]: i };
|
|
309
|
+
M(r.headers) && (e = ot(e, r.headers), t.headers = e);
|
|
310
|
+
}
|
|
311
|
+
return t;
|
|
312
|
+
}, kt = (() => {
|
|
313
|
+
let s = !1, t = !1;
|
|
314
|
+
const e = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
|
|
315
|
+
return e && r && (t = new globalThis.Request("https://empty.invalid", {
|
|
316
|
+
body: new globalThis.ReadableStream(),
|
|
317
|
+
method: "POST",
|
|
318
|
+
// @ts-expect-error - Types are outdated.
|
|
319
|
+
get duplex() {
|
|
320
|
+
return s = !0, "half";
|
|
321
|
+
}
|
|
322
|
+
}).headers.has("Content-Type")), s && !t;
|
|
323
|
+
})(), qt = typeof globalThis.AbortController == "function", xt = typeof globalThis.ReadableStream == "function", Pt = typeof globalThis.FormData == "function", at = ["get", "post", "put", "patch", "head", "delete"], Nt = {
|
|
324
|
+
json: "application/json",
|
|
325
|
+
text: "text/*",
|
|
326
|
+
formData: "multipart/form-data",
|
|
327
|
+
arrayBuffer: "*/*",
|
|
328
|
+
blob: "*/*"
|
|
329
|
+
}, D = 2147483647, ct = Symbol("stop"), jt = {
|
|
330
|
+
json: !0,
|
|
331
|
+
parseJson: !0,
|
|
332
|
+
searchParams: !0,
|
|
333
|
+
prefixUrl: !0,
|
|
334
|
+
retry: !0,
|
|
335
|
+
timeout: !0,
|
|
336
|
+
hooks: !0,
|
|
337
|
+
throwHttpErrors: !0,
|
|
338
|
+
onDownloadProgress: !0,
|
|
339
|
+
fetch: !0
|
|
340
|
+
}, Ht = {
|
|
341
|
+
method: !0,
|
|
342
|
+
headers: !0,
|
|
343
|
+
body: !0,
|
|
344
|
+
mode: !0,
|
|
345
|
+
credentials: !0,
|
|
346
|
+
cache: !0,
|
|
347
|
+
redirect: !0,
|
|
348
|
+
referrer: !0,
|
|
349
|
+
referrerPolicy: !0,
|
|
350
|
+
integrity: !0,
|
|
351
|
+
keepalive: !0,
|
|
352
|
+
signal: !0,
|
|
353
|
+
window: !0,
|
|
354
|
+
dispatcher: !0,
|
|
355
|
+
duplex: !0
|
|
356
|
+
}, Lt = (s) => at.includes(s) ? s.toUpperCase() : s, Dt = ["get", "put", "head", "delete", "options", "trace"], Ut = [408, 413, 429, 500, 502, 503, 504], ut = [413, 429, 503], Z = {
|
|
357
|
+
limit: 2,
|
|
358
|
+
methods: Dt,
|
|
359
|
+
statusCodes: Ut,
|
|
360
|
+
afterStatusCodes: ut,
|
|
361
|
+
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
362
|
+
backoffLimit: Number.POSITIVE_INFINITY,
|
|
363
|
+
delay: (s) => 0.3 * 2 ** (s - 1) * 1e3
|
|
364
|
+
}, Ft = (s = {}) => {
|
|
365
|
+
if (typeof s == "number")
|
|
366
|
+
return {
|
|
367
|
+
...Z,
|
|
368
|
+
limit: s
|
|
369
|
+
};
|
|
370
|
+
if (s.methods && !Array.isArray(s.methods))
|
|
371
|
+
throw new Error("retry.methods must be an array");
|
|
372
|
+
if (s.statusCodes && !Array.isArray(s.statusCodes))
|
|
373
|
+
throw new Error("retry.statusCodes must be an array");
|
|
374
|
+
return {
|
|
375
|
+
...Z,
|
|
376
|
+
...s,
|
|
377
|
+
afterStatusCodes: ut
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
async function Wt(s, t, e, r) {
|
|
381
|
+
return new Promise((n, i) => {
|
|
382
|
+
const a = setTimeout(() => {
|
|
383
|
+
e && e.abort(), i(new it(s));
|
|
384
|
+
}, r.timeout);
|
|
385
|
+
r.fetch(s, t).then(n).catch(i).then(() => {
|
|
386
|
+
clearTimeout(a);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
async function Gt(s, { signal: t }) {
|
|
391
|
+
return new Promise((e, r) => {
|
|
392
|
+
t && (t.throwIfAborted(), t.addEventListener("abort", n, { once: !0 }));
|
|
393
|
+
function n() {
|
|
394
|
+
clearTimeout(i), r(t.reason);
|
|
395
|
+
}
|
|
396
|
+
const i = setTimeout(() => {
|
|
397
|
+
t == null || t.removeEventListener("abort", n), e();
|
|
398
|
+
}, s);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
const Yt = (s, t) => {
|
|
402
|
+
const e = {};
|
|
403
|
+
for (const r in t)
|
|
404
|
+
!(r in Ht) && !(r in jt) && !(r in s) && (e[r] = t[r]);
|
|
405
|
+
return e;
|
|
406
|
+
};
|
|
407
|
+
class q {
|
|
408
|
+
static create(t, e) {
|
|
409
|
+
const r = new q(t, e), n = async () => {
|
|
410
|
+
if (typeof r._options.timeout == "number" && r._options.timeout > D)
|
|
411
|
+
throw new RangeError(`The \`timeout\` option cannot be greater than ${D}`);
|
|
412
|
+
await Promise.resolve();
|
|
413
|
+
let c = await r._fetch();
|
|
414
|
+
for (const u of r._options.hooks.afterResponse) {
|
|
415
|
+
const l = await u(r.request, r._options, r._decorateResponse(c.clone()));
|
|
416
|
+
l instanceof globalThis.Response && (c = l);
|
|
417
|
+
}
|
|
418
|
+
if (r._decorateResponse(c), !c.ok && r._options.throwHttpErrors) {
|
|
419
|
+
let u = new X(c, r.request, r._options);
|
|
420
|
+
for (const l of r._options.hooks.beforeError)
|
|
421
|
+
u = await l(u);
|
|
422
|
+
throw u;
|
|
423
|
+
}
|
|
424
|
+
if (r._options.onDownloadProgress) {
|
|
425
|
+
if (typeof r._options.onDownloadProgress != "function")
|
|
426
|
+
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
427
|
+
if (!xt)
|
|
428
|
+
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
429
|
+
return r._stream(c.clone(), r._options.onDownloadProgress);
|
|
430
|
+
}
|
|
431
|
+
return c;
|
|
432
|
+
}, a = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(n) : n();
|
|
433
|
+
for (const [c, u] of Object.entries(Nt))
|
|
434
|
+
a[c] = async () => {
|
|
435
|
+
r.request.headers.set("accept", r.request.headers.get("accept") || u);
|
|
436
|
+
const h = (await a).clone();
|
|
437
|
+
if (c === "json") {
|
|
438
|
+
if (h.status === 204 || (await h.clone().arrayBuffer()).byteLength === 0)
|
|
439
|
+
return "";
|
|
440
|
+
if (e.parseJson)
|
|
441
|
+
return e.parseJson(await h.text());
|
|
442
|
+
}
|
|
443
|
+
return h[c]();
|
|
444
|
+
};
|
|
445
|
+
return a;
|
|
446
|
+
}
|
|
447
|
+
// eslint-disable-next-line complexity
|
|
448
|
+
constructor(t, e = {}) {
|
|
449
|
+
if (Object.defineProperty(this, "request", {
|
|
450
|
+
enumerable: !0,
|
|
451
|
+
configurable: !0,
|
|
452
|
+
writable: !0,
|
|
453
|
+
value: void 0
|
|
454
|
+
}), Object.defineProperty(this, "abortController", {
|
|
455
|
+
enumerable: !0,
|
|
456
|
+
configurable: !0,
|
|
457
|
+
writable: !0,
|
|
458
|
+
value: void 0
|
|
459
|
+
}), Object.defineProperty(this, "_retryCount", {
|
|
460
|
+
enumerable: !0,
|
|
461
|
+
configurable: !0,
|
|
462
|
+
writable: !0,
|
|
463
|
+
value: 0
|
|
464
|
+
}), Object.defineProperty(this, "_input", {
|
|
465
|
+
enumerable: !0,
|
|
466
|
+
configurable: !0,
|
|
467
|
+
writable: !0,
|
|
468
|
+
value: void 0
|
|
469
|
+
}), Object.defineProperty(this, "_options", {
|
|
470
|
+
enumerable: !0,
|
|
471
|
+
configurable: !0,
|
|
472
|
+
writable: !0,
|
|
473
|
+
value: void 0
|
|
474
|
+
}), this._input = t, this._options = {
|
|
475
|
+
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
|
|
476
|
+
credentials: this._input.credentials || "same-origin",
|
|
477
|
+
...e,
|
|
478
|
+
headers: ot(this._input.headers, e.headers),
|
|
479
|
+
hooks: J({
|
|
480
|
+
beforeRequest: [],
|
|
481
|
+
beforeRetry: [],
|
|
482
|
+
beforeError: [],
|
|
483
|
+
afterResponse: []
|
|
484
|
+
}, e.hooks),
|
|
485
|
+
method: Lt(e.method ?? this._input.method),
|
|
486
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
487
|
+
prefixUrl: String(e.prefixUrl || ""),
|
|
488
|
+
retry: Ft(e.retry),
|
|
489
|
+
throwHttpErrors: e.throwHttpErrors !== !1,
|
|
490
|
+
timeout: e.timeout ?? 1e4,
|
|
491
|
+
fetch: e.fetch ?? globalThis.fetch.bind(globalThis)
|
|
492
|
+
}, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
|
|
493
|
+
throw new TypeError("`input` must be a string, URL, or Request");
|
|
494
|
+
if (this._options.prefixUrl && typeof this._input == "string") {
|
|
495
|
+
if (this._input.startsWith("/"))
|
|
496
|
+
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
497
|
+
this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
|
|
498
|
+
}
|
|
499
|
+
if (qt) {
|
|
500
|
+
if (this.abortController = new globalThis.AbortController(), this._options.signal) {
|
|
501
|
+
const r = this._options.signal;
|
|
502
|
+
this._options.signal.addEventListener("abort", () => {
|
|
503
|
+
this.abortController.abort(r.reason);
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
this._options.signal = this.abortController.signal;
|
|
507
|
+
}
|
|
508
|
+
if (kt && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
|
|
509
|
+
const n = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, n);
|
|
510
|
+
(Pt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(i, { ...this.request }), this._options);
|
|
511
|
+
}
|
|
512
|
+
this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
|
|
513
|
+
}
|
|
514
|
+
_calculateRetryDelay(t) {
|
|
515
|
+
if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof it)) {
|
|
516
|
+
if (t instanceof X) {
|
|
517
|
+
if (!this._options.retry.statusCodes.includes(t.response.status))
|
|
518
|
+
return 0;
|
|
519
|
+
const r = t.response.headers.get("Retry-After");
|
|
520
|
+
if (r && this._options.retry.afterStatusCodes.includes(t.response.status)) {
|
|
521
|
+
let n = Number(r);
|
|
522
|
+
return Number.isNaN(n) ? n = Date.parse(r) - Date.now() : n *= 1e3, this._options.retry.maxRetryAfter !== void 0 && n > this._options.retry.maxRetryAfter ? 0 : n;
|
|
523
|
+
}
|
|
524
|
+
if (t.response.status === 413)
|
|
525
|
+
return 0;
|
|
526
|
+
}
|
|
527
|
+
const e = this._options.retry.delay(this._retryCount);
|
|
528
|
+
return Math.min(this._options.retry.backoffLimit, e);
|
|
529
|
+
}
|
|
530
|
+
return 0;
|
|
531
|
+
}
|
|
532
|
+
_decorateResponse(t) {
|
|
533
|
+
return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
|
|
534
|
+
}
|
|
535
|
+
async _retry(t) {
|
|
536
|
+
try {
|
|
537
|
+
return await t();
|
|
538
|
+
} catch (e) {
|
|
539
|
+
const r = Math.min(this._calculateRetryDelay(e), D);
|
|
540
|
+
if (r !== 0 && this._retryCount > 0) {
|
|
541
|
+
await Gt(r, { signal: this._options.signal });
|
|
542
|
+
for (const n of this._options.hooks.beforeRetry)
|
|
543
|
+
if (await n({
|
|
544
|
+
request: this.request,
|
|
545
|
+
options: this._options,
|
|
546
|
+
error: e,
|
|
547
|
+
retryCount: this._retryCount
|
|
548
|
+
}) === ct)
|
|
549
|
+
return;
|
|
550
|
+
return this._retry(t);
|
|
551
|
+
}
|
|
552
|
+
throw e;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
async _fetch() {
|
|
556
|
+
for (const e of this._options.hooks.beforeRequest) {
|
|
557
|
+
const r = await e(this.request, this._options);
|
|
558
|
+
if (r instanceof Request) {
|
|
559
|
+
this.request = r;
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
if (r instanceof Response)
|
|
563
|
+
return r;
|
|
564
|
+
}
|
|
565
|
+
const t = Yt(this.request, this._options);
|
|
566
|
+
return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : Wt(this.request.clone(), t, this.abortController, this._options);
|
|
567
|
+
}
|
|
568
|
+
/* istanbul ignore next */
|
|
569
|
+
_stream(t, e) {
|
|
570
|
+
const r = Number(t.headers.get("content-length")) || 0;
|
|
571
|
+
let n = 0;
|
|
572
|
+
return t.status === 204 ? (e && e({ percent: 1, totalBytes: r, transferredBytes: n }, new Uint8Array()), new globalThis.Response(null, {
|
|
573
|
+
status: t.status,
|
|
574
|
+
statusText: t.statusText,
|
|
575
|
+
headers: t.headers
|
|
576
|
+
})) : new globalThis.Response(new globalThis.ReadableStream({
|
|
577
|
+
async start(i) {
|
|
578
|
+
const a = t.body.getReader();
|
|
579
|
+
e && e({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
|
|
580
|
+
async function c() {
|
|
581
|
+
const { done: u, value: l } = await a.read();
|
|
582
|
+
if (u) {
|
|
583
|
+
i.close();
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (e) {
|
|
587
|
+
n += l.byteLength;
|
|
588
|
+
const h = r === 0 ? 0 : n / r;
|
|
589
|
+
e({ percent: h, transferredBytes: n, totalBytes: r }, l);
|
|
590
|
+
}
|
|
591
|
+
i.enqueue(l), await c();
|
|
592
|
+
}
|
|
593
|
+
await c();
|
|
594
|
+
}
|
|
595
|
+
}), {
|
|
596
|
+
status: t.status,
|
|
597
|
+
statusText: t.statusText,
|
|
598
|
+
headers: t.headers
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
/*! MIT License © Sindre Sorhus */
|
|
603
|
+
const F = (s) => {
|
|
604
|
+
const t = (e, r) => q.create(e, V(s, r));
|
|
605
|
+
for (const e of at)
|
|
606
|
+
t[e] = (r, n) => q.create(r, V(s, n, { method: e }));
|
|
607
|
+
return t.create = (e) => F(V(e)), t.extend = (e) => F(V(s, e)), t.stop = ct, t;
|
|
608
|
+
}, zt = F(), Jt = zt, Kt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, tt = Jt.create({ headers: Kt }), Qt = {
|
|
609
|
+
get: (s, t) => tt.get(s, t).json(),
|
|
610
|
+
post: (s, t) => tt.post(s, t).json()
|
|
611
|
+
}, et = Object.values(o), Xt = (s = "") => {
|
|
612
|
+
const t = s.toUpperCase(), [e] = t.split(".");
|
|
613
|
+
if (et.includes(e))
|
|
285
614
|
return !0;
|
|
286
615
|
const [r] = t.split("/");
|
|
287
|
-
if (
|
|
616
|
+
if (et.includes(r))
|
|
288
617
|
return !0;
|
|
289
618
|
throw new Error(
|
|
290
|
-
`Invalid identifier: ${
|
|
619
|
+
`Invalid identifier: ${s}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
|
|
620
|
+
);
|
|
621
|
+
}, I = 8, S = (s) => 10n ** BigInt(s), R = (s) => Math.log10(parseFloat(s.toString()));
|
|
622
|
+
function x({
|
|
623
|
+
value: s,
|
|
624
|
+
bigIntDecimal: t = I,
|
|
625
|
+
decimal: e = I
|
|
626
|
+
}) {
|
|
627
|
+
const r = s < 0n;
|
|
628
|
+
let n = s.toString().substring(r ? 1 : 0);
|
|
629
|
+
const i = e - (n.length - 1);
|
|
630
|
+
i > 0 && (n = "0".repeat(i) + n);
|
|
631
|
+
const a = n.length - e;
|
|
632
|
+
let c = n.slice(-e);
|
|
633
|
+
return parseInt(c[t]) >= 5 ? c = `${c.substring(0, t - 1)}${(parseInt(c[t - 1]) + 1).toString()}` : c = c.substring(0, t), `${r ? "-" : ""}${n.slice(0, a)}.${c}`.replace(
|
|
634
|
+
/\.?0*$/,
|
|
635
|
+
""
|
|
291
636
|
);
|
|
292
|
-
}
|
|
293
|
-
var
|
|
294
|
-
const
|
|
637
|
+
}
|
|
638
|
+
var A, $, P, lt, N, ht, B, W, T, C, O, G;
|
|
639
|
+
const K = class K {
|
|
295
640
|
constructor(t) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
), d(this, R, z).call(this, r);
|
|
641
|
+
y(this, A);
|
|
642
|
+
y(this, P);
|
|
643
|
+
y(this, N);
|
|
644
|
+
y(this, B);
|
|
645
|
+
y(this, T);
|
|
646
|
+
y(this, O);
|
|
647
|
+
f(this, "decimalMultiplier", 10n ** 8n);
|
|
648
|
+
f(this, "bigIntValue", 0n);
|
|
649
|
+
f(this, "decimal");
|
|
650
|
+
const e = U(t);
|
|
651
|
+
this.decimal = typeof t == "object" ? t.decimal : void 0, this.decimalMultiplier = S(
|
|
652
|
+
Math.max(m(this, O, G).call(this, m(this, T, C).call(this, e)), this.decimal || 0)
|
|
653
|
+
), m(this, P, lt).call(this, e);
|
|
310
654
|
}
|
|
311
655
|
static fromBigInt(t, e) {
|
|
312
|
-
return new
|
|
656
|
+
return new K({
|
|
313
657
|
decimal: e,
|
|
314
|
-
value:
|
|
658
|
+
value: x({ value: t, bigIntDecimal: e, decimal: e })
|
|
315
659
|
});
|
|
316
660
|
}
|
|
317
661
|
static shiftDecimals({
|
|
@@ -319,40 +663,43 @@ const M = class M {
|
|
|
319
663
|
from: e,
|
|
320
664
|
to: r
|
|
321
665
|
}) {
|
|
322
|
-
return
|
|
323
|
-
|
|
666
|
+
return this.fromBigInt(
|
|
667
|
+
t.getBaseValue("bigint") * S(r) / S(e),
|
|
324
668
|
r
|
|
325
669
|
);
|
|
326
670
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
671
|
+
/**
|
|
672
|
+
* @deprecated Use `getBaseValue('string')` instead
|
|
673
|
+
*/
|
|
330
674
|
get baseValue() {
|
|
331
|
-
return
|
|
675
|
+
return this.getBaseValue("string");
|
|
332
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* @deprecated Use `getBaseValue('number')` instead
|
|
679
|
+
*/
|
|
333
680
|
get baseValueNumber() {
|
|
334
|
-
return
|
|
681
|
+
return this.getBaseValue("number");
|
|
335
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* @deprecated Use `getBaseValue('bigint')` instead
|
|
685
|
+
*/
|
|
336
686
|
get baseValueBigInt() {
|
|
337
|
-
return
|
|
687
|
+
return this.getBaseValue("bigint");
|
|
338
688
|
}
|
|
339
|
-
|
|
340
|
-
return this.
|
|
341
|
-
this.bigIntValue,
|
|
342
|
-
this.decimal || C(this.decimalMultiplier)
|
|
343
|
-
);
|
|
689
|
+
set(t) {
|
|
690
|
+
return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
|
|
344
691
|
}
|
|
345
692
|
add(...t) {
|
|
346
|
-
return
|
|
693
|
+
return m(this, A, $).call(this, "add", ...t);
|
|
347
694
|
}
|
|
348
695
|
sub(...t) {
|
|
349
|
-
return
|
|
696
|
+
return m(this, A, $).call(this, "sub", ...t);
|
|
350
697
|
}
|
|
351
698
|
mul(...t) {
|
|
352
|
-
return
|
|
699
|
+
return m(this, A, $).call(this, "mul", ...t);
|
|
353
700
|
}
|
|
354
701
|
div(...t) {
|
|
355
|
-
return
|
|
702
|
+
return m(this, A, $).call(this, "div", ...t);
|
|
356
703
|
}
|
|
357
704
|
gt(t) {
|
|
358
705
|
return this.bigIntValue > this.getBigIntValue(t);
|
|
@@ -369,136 +716,195 @@ const M = class M {
|
|
|
369
716
|
eqValue(t) {
|
|
370
717
|
return this.bigIntValue === this.getBigIntValue(t);
|
|
371
718
|
}
|
|
719
|
+
getValue(t) {
|
|
720
|
+
const e = this.formatBigIntToSafeValue(
|
|
721
|
+
this.bigIntValue,
|
|
722
|
+
this.decimal || R(this.decimalMultiplier)
|
|
723
|
+
);
|
|
724
|
+
switch (t) {
|
|
725
|
+
case "number":
|
|
726
|
+
return Number(e);
|
|
727
|
+
case "string":
|
|
728
|
+
return e;
|
|
729
|
+
default:
|
|
730
|
+
return this.bigIntValue * BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
getBaseValue(t) {
|
|
734
|
+
const e = this.decimalMultiplier / S(this.decimal || d.THOR), r = this.bigIntValue / e;
|
|
735
|
+
switch (t) {
|
|
736
|
+
case "number":
|
|
737
|
+
return Number(r);
|
|
738
|
+
case "string":
|
|
739
|
+
return r.toString();
|
|
740
|
+
default:
|
|
741
|
+
return r;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
372
744
|
getBigIntValue(t, e) {
|
|
373
|
-
|
|
745
|
+
if (!e && typeof t == "object")
|
|
746
|
+
return t.bigIntValue;
|
|
747
|
+
const r = U(t), n = m(this, T, C).call(this, r);
|
|
748
|
+
return n === "0" || n === "undefined" ? 0n : m(this, B, W).call(this, n, e);
|
|
374
749
|
}
|
|
375
750
|
formatBigIntToSafeValue(t, e) {
|
|
376
|
-
const r = e || this.decimal ||
|
|
751
|
+
const r = e || this.decimal || I, n = Math.max(
|
|
377
752
|
r,
|
|
378
|
-
|
|
379
|
-
),
|
|
380
|
-
let
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
)
|
|
753
|
+
R(this.decimalMultiplier)
|
|
754
|
+
), i = t < 0n, a = t.toString().substring(i ? 1 : 0), c = n - (a.length - 1), u = c > 0 ? "0".repeat(c) + a : a, l = u.length - n;
|
|
755
|
+
let h = u.slice(-n);
|
|
756
|
+
return parseInt(h[r]) >= 5 ? h = `${h.substring(0, r - 1)}${(parseInt(h[r - 1]) + 1).toString()}` : h = h.substring(0, r), `${i ? "-" : ""}${u.slice(
|
|
757
|
+
0,
|
|
758
|
+
l
|
|
759
|
+
)}.${h}`.replace(/\.?0*$/, "");
|
|
760
|
+
}
|
|
761
|
+
toSignificant(t = 6) {
|
|
762
|
+
const [e, r] = this.getValue("string").split("."), n = e || "", i = r || "";
|
|
763
|
+
if ((parseInt(n) ? n.length + i.length : i.length) <= t)
|
|
764
|
+
return this.getValue("string");
|
|
765
|
+
if (n.length >= t)
|
|
766
|
+
return n.slice(0, t).padEnd(n.length, "0");
|
|
767
|
+
if (parseInt(n))
|
|
768
|
+
return `${n}.${i.slice(0, t - n.length)}`.padEnd(
|
|
769
|
+
t - n.length,
|
|
770
|
+
"0"
|
|
771
|
+
);
|
|
772
|
+
const c = parseInt(i), u = `${c}`.slice(0, t);
|
|
773
|
+
return `0.${u.padStart(
|
|
774
|
+
i.length - `${c}`.length + u.length,
|
|
775
|
+
"0"
|
|
776
|
+
)}`;
|
|
389
777
|
}
|
|
390
|
-
|
|
391
|
-
const e = this.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
778
|
+
toFixed(t = 6) {
|
|
779
|
+
const [e, r] = this.getValue("string").split("."), n = e || "", i = r || "";
|
|
780
|
+
if (parseInt(n))
|
|
781
|
+
return `${n}.${i.slice(0, t)}`.padEnd(t, "0");
|
|
782
|
+
const a = parseInt(i), c = `${a}`.slice(0, t);
|
|
783
|
+
return `0.${c.padStart(
|
|
784
|
+
i.length - `${a}`.length + c.length,
|
|
785
|
+
"0"
|
|
786
|
+
)}`;
|
|
787
|
+
}
|
|
788
|
+
toAbbreviation(t = 2) {
|
|
789
|
+
const e = this.getValue("number"), r = ["", "K", "M", "B", "T", "Q", "Qi", "S"], n = Math.floor(Math.log10(Math.abs(e)) / 3), i = r[n];
|
|
790
|
+
if (!i)
|
|
791
|
+
return this.getValue("string");
|
|
792
|
+
const a = 10 ** (n * 3);
|
|
793
|
+
return `${(e / a).toFixed(t)}${i}`;
|
|
396
794
|
}
|
|
397
795
|
};
|
|
398
|
-
|
|
399
|
-
const r =
|
|
400
|
-
(
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
796
|
+
A = new WeakSet(), $ = function(t, ...e) {
|
|
797
|
+
const r = m(this, N, ht).call(this, this, ...e), n = S(r), i = e.reduce(
|
|
798
|
+
(c, u) => {
|
|
799
|
+
const l = this.getBigIntValue(u, r);
|
|
800
|
+
switch (t) {
|
|
801
|
+
case "add":
|
|
802
|
+
return c + l;
|
|
803
|
+
case "sub":
|
|
804
|
+
return c - l;
|
|
805
|
+
case "mul":
|
|
806
|
+
return c * l / n;
|
|
807
|
+
case "div": {
|
|
808
|
+
if (l === 0n)
|
|
809
|
+
throw new RangeError("Division by zero");
|
|
810
|
+
return c * n / l;
|
|
811
|
+
}
|
|
812
|
+
default:
|
|
813
|
+
return c;
|
|
814
|
+
}
|
|
405
815
|
},
|
|
406
816
|
//normalize is to precision multiplier base
|
|
407
|
-
this.bigIntValue *
|
|
408
|
-
),
|
|
817
|
+
this.bigIntValue * n / this.decimalMultiplier
|
|
818
|
+
), a = x({
|
|
409
819
|
bigIntDecimal: r,
|
|
410
|
-
decimal: Math.max(r,
|
|
411
|
-
value:
|
|
820
|
+
decimal: Math.max(r, R(this.decimalMultiplier)),
|
|
821
|
+
value: i
|
|
412
822
|
});
|
|
413
|
-
return new this.constructor({ decimal: this.decimal, value:
|
|
414
|
-
},
|
|
415
|
-
const
|
|
416
|
-
this.bigIntValue =
|
|
417
|
-
},
|
|
823
|
+
return new this.constructor({ decimal: this.decimal, value: a, identifier: this.toString() });
|
|
824
|
+
}, P = new WeakSet(), lt = function(t) {
|
|
825
|
+
const e = m(this, T, C).call(this, t) || "0";
|
|
826
|
+
this.bigIntValue = m(this, B, W).call(this, e);
|
|
827
|
+
}, N = new WeakSet(), ht = function(...t) {
|
|
418
828
|
const e = t.map(
|
|
419
|
-
(r) => typeof r == "object" ? r.decimal ||
|
|
829
|
+
(r) => typeof r == "object" ? r.decimal || R(r.decimalMultiplier) : m(this, O, G).call(this, m(this, T, C).call(this, r))
|
|
420
830
|
).filter(Boolean);
|
|
421
|
-
return Math.max(...e,
|
|
422
|
-
},
|
|
423
|
-
const r = e ?
|
|
424
|
-
return BigInt(`${
|
|
425
|
-
},
|
|
831
|
+
return Math.max(...e, I);
|
|
832
|
+
}, B = new WeakSet(), W = function(t, e) {
|
|
833
|
+
const r = e ? S(e) : this.decimalMultiplier, n = R(r), [i = "", a = ""] = t.split(".");
|
|
834
|
+
return BigInt(`${i}${a.padEnd(n, "0")}`);
|
|
835
|
+
}, T = new WeakSet(), C = function(t) {
|
|
426
836
|
const r = `${typeof t == "number" ? Number(t).toLocaleString("fullwide", {
|
|
427
837
|
useGrouping: !1,
|
|
428
838
|
maximumFractionDigits: 20
|
|
429
|
-
}) : t}`.replaceAll(",", ".").split(".");
|
|
839
|
+
}) : U(t)}`.replaceAll(",", ".").split(".");
|
|
430
840
|
return r.length > 1 ? `${r.slice(0, -1).join("")}.${r.at(-1)}` : r[0];
|
|
431
|
-
},
|
|
841
|
+
}, O = new WeakSet(), G = function(t) {
|
|
432
842
|
var r;
|
|
433
843
|
const e = ((r = t.split(".")[1]) == null ? void 0 : r.length) || 0;
|
|
434
|
-
return Math.max(e,
|
|
435
|
-
}, S = new WeakSet(), N = function(t) {
|
|
436
|
-
const e = this.decimalMultiplier / I(this.decimal || 0), r = this.bigIntValue / e;
|
|
437
|
-
switch (t) {
|
|
438
|
-
case "number":
|
|
439
|
-
return Number(r);
|
|
440
|
-
case "string":
|
|
441
|
-
return r.toString();
|
|
442
|
-
default:
|
|
443
|
-
return r;
|
|
444
|
-
}
|
|
844
|
+
return Math.max(e, I);
|
|
445
845
|
};
|
|
446
|
-
let E =
|
|
447
|
-
|
|
448
|
-
|
|
846
|
+
let E = K;
|
|
847
|
+
function U(s) {
|
|
848
|
+
return typeof s == "object" ? "getValue" in s ? s.getValue("string") : s.value : s;
|
|
849
|
+
}
|
|
850
|
+
const k = (s, t) => typeof s == "bigint" ? x({ value: s, bigIntDecimal: t, decimal: t }) : s;
|
|
851
|
+
let Y;
|
|
852
|
+
const rt = (s) => {
|
|
853
|
+
if (!Y)
|
|
449
854
|
throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
|
|
450
|
-
return
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
const e = await
|
|
454
|
-
return new
|
|
855
|
+
return Y.get(s.toUpperCase()) || { decimal: d.THOR, identifier: "" };
|
|
856
|
+
}, st = async (s, t = 0) => {
|
|
857
|
+
Xt(s);
|
|
858
|
+
const e = await Rt(z(s)), r = k(t, e);
|
|
859
|
+
return new w({ decimal: e, value: r, identifier: s });
|
|
455
860
|
};
|
|
456
|
-
class
|
|
861
|
+
class w extends E {
|
|
457
862
|
constructor(e) {
|
|
458
863
|
super(
|
|
459
864
|
e.value instanceof E ? e.value : { decimal: e.decimal, value: e.value }
|
|
460
865
|
);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const r = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`,
|
|
469
|
-
this.type =
|
|
866
|
+
f(this, "address");
|
|
867
|
+
f(this, "chain");
|
|
868
|
+
f(this, "isSynthetic", !1);
|
|
869
|
+
f(this, "isGasAsset", !1);
|
|
870
|
+
f(this, "symbol");
|
|
871
|
+
f(this, "ticker");
|
|
872
|
+
f(this, "type");
|
|
873
|
+
const r = "identifier" in e ? e.identifier : `${e.chain}.${e.symbol}`, n = z(r);
|
|
874
|
+
this.type = It(n), this.chain = n.chain, this.ticker = n.ticker, this.symbol = n.symbol, this.address = n.address, this.isSynthetic = n.isSynthetic, this.isGasAsset = n.isGasAsset;
|
|
875
|
+
}
|
|
876
|
+
get assetValue() {
|
|
877
|
+
return `${this.getValue("string")} ${this.ticker}`;
|
|
878
|
+
}
|
|
879
|
+
toString(e = !1) {
|
|
880
|
+
const r = this.isSynthetic ? this.symbol.split("-")[0] : `${this.chain}.${this.ticker}`;
|
|
881
|
+
return e ? r : (
|
|
882
|
+
// THOR.ETH/ETH | ETH.USDT-0x1234567890
|
|
883
|
+
`${this.chain}.${this.symbol}`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
eq({ chain: e, symbol: r }) {
|
|
887
|
+
return this.chain === e && this.symbol === r;
|
|
470
888
|
}
|
|
471
889
|
static async fromString(e, r = 0) {
|
|
472
|
-
return
|
|
890
|
+
return st(e, r);
|
|
473
891
|
}
|
|
474
892
|
static fromStringSync(e, r = 0) {
|
|
475
|
-
const { decimal:
|
|
893
|
+
const { isSynthetic: n } = z(e), { decimal: i, identifier: a } = rt(
|
|
476
894
|
e
|
|
477
|
-
);
|
|
478
|
-
return a ? new
|
|
895
|
+
), c = k(r, i);
|
|
896
|
+
return a ? new w({ decimal: i, identifier: a, value: c }) : n ? new w({ decimal: 8, identifier: e, value: c }) : void 0;
|
|
479
897
|
}
|
|
480
898
|
static async fromIdentifier(e, r = 0) {
|
|
481
|
-
return
|
|
899
|
+
return st(e, r);
|
|
482
900
|
}
|
|
483
901
|
static fromIdentifierSync(e, r = 0) {
|
|
484
|
-
const { decimal:
|
|
485
|
-
return new
|
|
902
|
+
const { decimal: n, identifier: i } = rt(e), a = k(r, n);
|
|
903
|
+
return new w({ decimal: n, identifier: i, value: a });
|
|
486
904
|
}
|
|
487
905
|
static fromChainOrSignature(e, r = 0) {
|
|
488
|
-
const { decimal:
|
|
489
|
-
return new
|
|
490
|
-
}
|
|
491
|
-
static async fromTCQuote(e, r = 0) {
|
|
492
|
-
const s = await J(F(e)), a = this.shiftDecimals({ value: r, from: h.THOR, to: s });
|
|
493
|
-
return new A({ value: a, identifier: e, decimal: s });
|
|
494
|
-
}
|
|
495
|
-
static fromTCQuoteStatic(e, r = 0) {
|
|
496
|
-
const s = P(e), a = this.shiftDecimals({
|
|
497
|
-
value: r,
|
|
498
|
-
from: h.THOR,
|
|
499
|
-
to: s.decimal
|
|
500
|
-
});
|
|
501
|
-
return new A({ ...s, value: a });
|
|
906
|
+
const { decimal: n, identifier: i } = Ct(e), a = k(r, n);
|
|
907
|
+
return new w({ value: a, decimal: n, identifier: i });
|
|
502
908
|
}
|
|
503
909
|
static async loadStaticAssets() {
|
|
504
910
|
return new Promise(
|
|
@@ -507,66 +913,57 @@ class A extends E {
|
|
|
507
913
|
const {
|
|
508
914
|
// Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
|
|
509
915
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
510
|
-
ThorchainList:
|
|
511
|
-
NativeList:
|
|
512
|
-
...
|
|
916
|
+
ThorchainList: n,
|
|
917
|
+
NativeList: i,
|
|
918
|
+
...a
|
|
513
919
|
} = await import("@swapkit/tokens");
|
|
514
|
-
|
|
515
|
-
(
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
}),
|
|
920
|
+
Y = [i, ...Object.values(a)].reduce(
|
|
921
|
+
(u, { tokens: l }) => (l.forEach(({ identifier: h, chain: _, ...v }) => {
|
|
922
|
+
const j = "decimals" in v ? v.decimals : d[_];
|
|
923
|
+
u.set(h, { identifier: h, decimal: j });
|
|
924
|
+
}), u),
|
|
519
925
|
/* @__PURE__ */ new Map()
|
|
520
926
|
), e({ ok: !0 });
|
|
521
|
-
} catch (
|
|
522
|
-
console.error(
|
|
927
|
+
} catch (n) {
|
|
928
|
+
console.error(n), r({
|
|
523
929
|
ok: !1,
|
|
524
|
-
error:
|
|
930
|
+
error: n,
|
|
525
931
|
message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
|
|
526
932
|
});
|
|
527
933
|
}
|
|
528
934
|
}
|
|
529
935
|
);
|
|
530
936
|
}
|
|
531
|
-
get assetValue() {
|
|
532
|
-
return `${this.value} ${this.ticker}`;
|
|
533
|
-
}
|
|
534
|
-
toString() {
|
|
535
|
-
return `${this.chain}.${this.symbol}`;
|
|
536
|
-
}
|
|
537
|
-
eq({ chain: e, symbol: r }) {
|
|
538
|
-
return this.chain === e && this.symbol === r;
|
|
539
|
-
}
|
|
540
937
|
}
|
|
541
|
-
const
|
|
542
|
-
const t =
|
|
543
|
-
switch (
|
|
544
|
-
case
|
|
545
|
-
case
|
|
546
|
-
case
|
|
547
|
-
return t.
|
|
548
|
-
case
|
|
549
|
-
return t.
|
|
550
|
-
case
|
|
551
|
-
case
|
|
552
|
-
return t.
|
|
553
|
-
case
|
|
554
|
-
case
|
|
555
|
-
return t.
|
|
938
|
+
const pe = (s) => {
|
|
939
|
+
const t = w.fromChainOrSignature(s);
|
|
940
|
+
switch (s) {
|
|
941
|
+
case o.Bitcoin:
|
|
942
|
+
case o.Litecoin:
|
|
943
|
+
case o.BitcoinCash:
|
|
944
|
+
return t.set(10001e-8);
|
|
945
|
+
case o.Dogecoin:
|
|
946
|
+
return t.set(1.00000001);
|
|
947
|
+
case o.Avalanche:
|
|
948
|
+
case o.Ethereum:
|
|
949
|
+
return t.set(1e-8);
|
|
950
|
+
case o.THORChain:
|
|
951
|
+
case o.Maya:
|
|
952
|
+
return t.set(0);
|
|
556
953
|
default:
|
|
557
|
-
return t.
|
|
954
|
+
return t.set(1e-8);
|
|
558
955
|
}
|
|
559
|
-
},
|
|
560
|
-
const t =
|
|
956
|
+
}, z = (s) => {
|
|
957
|
+
const t = s.slice(0, 14).includes("/"), [e, r] = s.split(".").pop().split("/"), n = s.includes(".") && !t ? s : `${o.THORChain}.${r}`, [i, a] = n.split("."), [c, u] = (t ? r : a).split("-");
|
|
561
958
|
return {
|
|
562
|
-
address:
|
|
563
|
-
chain:
|
|
564
|
-
isGasAsset:
|
|
959
|
+
address: u == null ? void 0 : u.toLowerCase(),
|
|
960
|
+
chain: i,
|
|
961
|
+
isGasAsset: $t({ chain: i, symbol: a }),
|
|
565
962
|
isSynthetic: t,
|
|
566
|
-
symbol:
|
|
567
|
-
ticker:
|
|
963
|
+
symbol: (t ? `${e}/` : "") + (u ? `${c}-${(u == null ? void 0 : u.toLowerCase()) ?? ""}` : a),
|
|
964
|
+
ticker: c
|
|
568
965
|
};
|
|
569
|
-
},
|
|
966
|
+
}, Zt = {
|
|
570
967
|
/**
|
|
571
968
|
* Core
|
|
572
969
|
*/
|
|
@@ -623,44 +1020,47 @@ const Dt = (n) => {
|
|
|
623
1020
|
*/
|
|
624
1021
|
helpers_number_different_decimals: 99101
|
|
625
1022
|
};
|
|
626
|
-
class
|
|
1023
|
+
class dt extends Error {
|
|
627
1024
|
constructor(t, e) {
|
|
628
|
-
console.error(e), super(t, { cause: { code:
|
|
1025
|
+
console.error(e), super(t, { cause: { code: Zt[t], message: t } }), Object.setPrototypeOf(this, dt.prototype);
|
|
629
1026
|
}
|
|
630
1027
|
}
|
|
631
|
-
class
|
|
1028
|
+
class b extends E {
|
|
632
1029
|
eq(t) {
|
|
633
1030
|
return this.eqValue(t);
|
|
634
1031
|
}
|
|
635
|
-
|
|
636
|
-
return
|
|
1032
|
+
static fromBigInt(t, e) {
|
|
1033
|
+
return new b({
|
|
1034
|
+
decimal: e,
|
|
1035
|
+
value: x({ value: t, bigIntDecimal: e, decimal: e })
|
|
1036
|
+
});
|
|
637
1037
|
}
|
|
638
1038
|
}
|
|
639
1039
|
export {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
Rt as
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
Vt as
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
1040
|
+
w as AssetValue,
|
|
1041
|
+
E as BigIntArithmetics,
|
|
1042
|
+
Qt as RequestClient,
|
|
1043
|
+
dt as SwapKitError,
|
|
1044
|
+
b as SwapKitNumber,
|
|
1045
|
+
se as assetFromString,
|
|
1046
|
+
me as derivationPathToString,
|
|
1047
|
+
ne as filterAssets,
|
|
1048
|
+
x as formatBigIntToSafeValue,
|
|
1049
|
+
re as gasFeeMultiplier,
|
|
1050
|
+
It as getAssetType,
|
|
1051
|
+
Ot as getAsymmetricAssetShare,
|
|
1052
|
+
oe as getAsymmetricAssetWithdrawAmount,
|
|
1053
|
+
Bt as getAsymmetricRuneShare,
|
|
1054
|
+
ie as getAsymmetricRuneWithdrawAmount,
|
|
1055
|
+
Ct as getCommonAssetInfo,
|
|
1056
|
+
Rt as getDecimal,
|
|
1057
|
+
ce as getEstimatedPoolShare,
|
|
1058
|
+
ue as getLiquiditySlippage,
|
|
1059
|
+
le as getMemoFor,
|
|
1060
|
+
pe as getMinAmountByChain,
|
|
1061
|
+
Vt as getSymmetricPoolShare,
|
|
1062
|
+
ae as getSymmetricWithdraw,
|
|
1063
|
+
he as getTHORNameCost,
|
|
1064
|
+
$t as isGasAsset,
|
|
1065
|
+
de as validateTHORName
|
|
666
1066
|
};
|