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