@swapkit/core 1.0.0-rc.84 → 1.0.0-rc.86
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +59 -53
- package/dist/index.es.js.map +1 -1
- package/package.json +9 -9
- package/src/client/index.ts +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ export declare class SwapKitCore<T = ''> {
|
|
|
165
165
|
connectXDEFI: (_chains: Chain[]) => Promise<void>;
|
|
166
166
|
connectEVMWallet: (_chains: Chain[] | Chain, _wallet: EVMWalletOptions) => Promise<void>;
|
|
167
167
|
connectWalletconnect: (_chains: Chain[], _options?: any) => Promise<void>;
|
|
168
|
+
connectKeepkey: (_chains: Chain[], _derivationPath: number[][]) => Promise<string>;
|
|
168
169
|
connectKeystore: (_chains: Chain[], _phrase: string) => Promise<void>;
|
|
169
170
|
connectLedger: (_chains: Chain, _derivationPath: number[]) => Promise<void>;
|
|
170
171
|
connectTrezor: (_chains: Chain, _derivationPath: number[]) => Promise<void>;
|
package/dist/index.es.js
CHANGED
|
@@ -745,7 +745,7 @@ const Cn = {
|
|
|
745
745
|
OP: [44, 60, 0, 0, 0],
|
|
746
746
|
THOR: [44, 931, 0, 0, 0]
|
|
747
747
|
};
|
|
748
|
-
var
|
|
748
|
+
var _ = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(_ || {});
|
|
749
749
|
const ot = [
|
|
750
750
|
"ETH",
|
|
751
751
|
"AVAX",
|
|
@@ -839,7 +839,7 @@ const se = Object.values(s), dt = Object.keys(s), he = se.reduce(
|
|
|
839
839
|
MATIC: "https://polygonscan.com",
|
|
840
840
|
THOR: "https://runescan.io"
|
|
841
841
|
};
|
|
842
|
-
var mt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(mt || {}), b = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(b || {}), q = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(q || {}), Tt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(Tt || {}), ct = Object.defineProperty, bt = (e, t, n) => t in e ? ct(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (bt(e, typeof t != "symbol" ? t + "" : t, n), n), ft = (e, t, n) => {
|
|
842
|
+
var mt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(mt || {}), b = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(b || {}), q = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(q || {}), Tt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.KEEPKEY = "KEEPKEY", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.OKX_MOBILE = "OKX_MOBILE", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(Tt || {}), ct = Object.defineProperty, bt = (e, t, n) => t in e ? ct(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t, n) => (bt(e, typeof t != "symbol" ? t + "" : t, n), n), ft = (e, t, n) => {
|
|
843
843
|
if (!t.has(e))
|
|
844
844
|
throw TypeError("Cannot " + n);
|
|
845
845
|
}, F = (e, t, n) => {
|
|
@@ -849,7 +849,7 @@ var mt = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(mt || {}
|
|
|
849
849
|
}, E = (e, t, n) => (ft(e, t, "access private method"), n);
|
|
850
850
|
const ht = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
851
851
|
try {
|
|
852
|
-
const { result: n } = await
|
|
852
|
+
const { result: n } = await Ae.post(lt[e], {
|
|
853
853
|
headers: {
|
|
854
854
|
accept: "*/*",
|
|
855
855
|
"content-type": "application/json",
|
|
@@ -864,26 +864,26 @@ const ht = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
864
864
|
});
|
|
865
865
|
return parseInt(BigInt(n).toString());
|
|
866
866
|
} catch (n) {
|
|
867
|
-
return console.error(n),
|
|
867
|
+
return console.error(n), _[e];
|
|
868
868
|
}
|
|
869
|
-
},
|
|
869
|
+
}, _t = async (e) => {
|
|
870
870
|
if (e === s.Ethereum)
|
|
871
|
-
return
|
|
871
|
+
return _.ETH;
|
|
872
872
|
const [, t] = e.split("-");
|
|
873
|
-
return t != null && t.startsWith("0x") ? Ne({ chain: s.Ethereum, to: t }) :
|
|
874
|
-
},
|
|
873
|
+
return t != null && t.startsWith("0x") ? Ne({ chain: s.Ethereum, to: t }) : _.ETH;
|
|
874
|
+
}, At = async (e) => {
|
|
875
875
|
const [, t] = e.split("-");
|
|
876
|
-
return t != null && t.startsWith("0x") ? Ne({ chain: s.Avalanche, to: t.toLowerCase() }) :
|
|
877
|
-
}, wt = async (e) => (e === s.BinanceSmartChain,
|
|
876
|
+
return t != null && t.startsWith("0x") ? Ne({ chain: s.Avalanche, to: t.toLowerCase() }) : _.AVAX;
|
|
877
|
+
}, wt = async (e) => (e === s.BinanceSmartChain, _.BSC), Mt = async ({ chain: e, symbol: t }) => {
|
|
878
878
|
switch (e) {
|
|
879
879
|
case s.Ethereum:
|
|
880
|
-
return At(t);
|
|
881
|
-
case s.Avalanche:
|
|
882
880
|
return _t(t);
|
|
881
|
+
case s.Avalanche:
|
|
882
|
+
return At(t);
|
|
883
883
|
case s.BinanceSmartChain:
|
|
884
884
|
return wt(t);
|
|
885
885
|
default:
|
|
886
|
-
return
|
|
886
|
+
return _[e];
|
|
887
887
|
}
|
|
888
888
|
}, Et = {
|
|
889
889
|
[q.Average]: 1.2,
|
|
@@ -917,20 +917,22 @@ const ht = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
917
917
|
}
|
|
918
918
|
}, gt = (e) => {
|
|
919
919
|
switch (e) {
|
|
920
|
-
case
|
|
920
|
+
case `${s.Ethereum}.THOR`:
|
|
921
921
|
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
922
|
-
case
|
|
922
|
+
case `${s.Ethereum}.vTHOR`:
|
|
923
923
|
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
924
924
|
case s.Cosmos:
|
|
925
|
-
return { identifier: "GAIA.ATOM", decimal:
|
|
925
|
+
return { identifier: "GAIA.ATOM", decimal: _[e] };
|
|
926
926
|
case s.THORChain:
|
|
927
|
-
return { identifier: "THOR.RUNE", decimal:
|
|
927
|
+
return { identifier: "THOR.RUNE", decimal: _[e] };
|
|
928
928
|
case s.BinanceSmartChain:
|
|
929
|
-
return { identifier: "BSC.BNB", decimal:
|
|
929
|
+
return { identifier: "BSC.BNB", decimal: _[e] };
|
|
930
930
|
case s.Maya:
|
|
931
|
-
return { identifier: "MAYA.CACAO", decimal:
|
|
932
|
-
case
|
|
931
|
+
return { identifier: "MAYA.CACAO", decimal: _.MAYA };
|
|
932
|
+
case `${s.Maya}.MAYA`:
|
|
933
933
|
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
934
|
+
case `${s.Kujira}.USK`:
|
|
935
|
+
return { identifier: `${s.Kujira}.USK`, decimal: 6 };
|
|
934
936
|
case s.Kujira:
|
|
935
937
|
case s.Arbitrum:
|
|
936
938
|
case s.Optimism:
|
|
@@ -942,7 +944,7 @@ const ht = "0x313ce567", Ne = async ({ chain: e, to: t }) => {
|
|
|
942
944
|
case s.Polygon:
|
|
943
945
|
case s.Bitcoin:
|
|
944
946
|
case s.Ethereum:
|
|
945
|
-
return { identifier: `${e}.${e}`, decimal:
|
|
947
|
+
return { identifier: `${e}.${e}`, decimal: _[e] };
|
|
946
948
|
}
|
|
947
949
|
}, Rt = ({ chain: e, symbol: t }) => {
|
|
948
950
|
if (t.includes("/"))
|
|
@@ -1024,7 +1026,7 @@ function Vn({
|
|
|
1024
1026
|
return St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e);
|
|
1025
1027
|
}
|
|
1026
1028
|
function g(e) {
|
|
1027
|
-
return k.fromBigInt(BigInt(e),
|
|
1029
|
+
return k.fromBigInt(BigInt(e), _.THOR);
|
|
1028
1030
|
}
|
|
1029
1031
|
function Ct({
|
|
1030
1032
|
liquidityUnits: e,
|
|
@@ -1058,7 +1060,7 @@ function Un({
|
|
|
1058
1060
|
runeAmount: i,
|
|
1059
1061
|
assetAmount: r
|
|
1060
1062
|
}) {
|
|
1061
|
-
const p = new k({ value: e, decimal: 8 }), u = new k({ value: n, decimal: 8 }), y = new k({ value: t, decimal: 8 }), d = new k({ value: i, decimal: 8 }), o = new k({ value: r, decimal: 8 }), T = d.mul(u), f = o.mul(p),
|
|
1063
|
+
const p = new k({ value: e, decimal: 8 }), u = new k({ value: n, decimal: 8 }), y = new k({ value: t, decimal: 8 }), d = new k({ value: i, decimal: 8 }), o = new k({ value: r, decimal: 8 }), T = d.mul(u), f = o.mul(p), A = d.mul(o), w = p.mul(u), M = y.mul(T.add(f.add(A.mul(2)))), R = T.add(f.add(w.mul(2))), O = M.div(R), D = g(a).add(O);
|
|
1062
1064
|
if (O.getBaseValue("number") === 0)
|
|
1063
1065
|
return D.div(y).getBaseValue("number");
|
|
1064
1066
|
const pe = y.add(D);
|
|
@@ -1167,20 +1169,20 @@ const Z = (e) => e !== null && typeof e == "object", J = (...e) => {
|
|
|
1167
1169
|
for (const t of e)
|
|
1168
1170
|
if ((!Z(t) || Array.isArray(t)) && t !== void 0)
|
|
1169
1171
|
throw new TypeError("The `options` argument must be an object");
|
|
1170
|
-
return
|
|
1172
|
+
return _e({}, ...e);
|
|
1171
1173
|
}, He = (e = {}, t = {}) => {
|
|
1172
1174
|
const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, i = new globalThis.Headers(t);
|
|
1173
1175
|
for (const [r, p] of i.entries())
|
|
1174
1176
|
a && p === "undefined" || p === void 0 ? n.delete(r) : n.set(r, p);
|
|
1175
1177
|
return n;
|
|
1176
|
-
},
|
|
1178
|
+
}, _e = (...e) => {
|
|
1177
1179
|
let t = {}, n = {};
|
|
1178
1180
|
for (const a of e)
|
|
1179
1181
|
if (Array.isArray(a))
|
|
1180
1182
|
Array.isArray(t) || (t = []), t = [...t, ...a];
|
|
1181
1183
|
else if (Z(a)) {
|
|
1182
1184
|
for (let [i, r] of Object.entries(a))
|
|
1183
|
-
Z(r) && i in t && (r =
|
|
1185
|
+
Z(r) && i in t && (r = _e(t[i], r)), t = { ...t, [i]: r };
|
|
1184
1186
|
Z(a.headers) && (n = He(n, a.headers), t.headers = n);
|
|
1185
1187
|
}
|
|
1186
1188
|
return t;
|
|
@@ -1351,7 +1353,7 @@ class te {
|
|
|
1351
1353
|
credentials: this._input.credentials || "same-origin",
|
|
1352
1354
|
...n,
|
|
1353
1355
|
headers: He(this._input.headers, n.headers),
|
|
1354
|
-
hooks:
|
|
1356
|
+
hooks: _e({
|
|
1355
1357
|
beforeRequest: [],
|
|
1356
1358
|
beforeRetry: [],
|
|
1357
1359
|
beforeError: [],
|
|
@@ -1480,7 +1482,7 @@ const me = (e) => {
|
|
|
1480
1482
|
for (const n of Ve)
|
|
1481
1483
|
t[n] = (a, i) => te.create(a, J(e, i, { method: n }));
|
|
1482
1484
|
return t.create = (n) => me(J(n)), t.extend = (n) => me(J(e, n)), t.stop = Fe, t;
|
|
1483
|
-
}, Gt = me(), Xt = Gt, jt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ee = Xt.create({ headers: jt }),
|
|
1485
|
+
}, Gt = me(), Xt = Gt, jt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Ee = Xt.create({ headers: jt }), Ae = {
|
|
1484
1486
|
get: (e, t) => Ee.get(e, t).json(),
|
|
1485
1487
|
post: (e, t) => Ee.post(e, t).json()
|
|
1486
1488
|
}, ge = [...Object.values(s), "TERRA"];
|
|
@@ -1584,7 +1586,7 @@ const Yt = class $e {
|
|
|
1584
1586
|
}
|
|
1585
1587
|
// @ts-expect-error
|
|
1586
1588
|
getBaseValue(t) {
|
|
1587
|
-
const n = this.decimalMultiplier / P(this.decimal ||
|
|
1589
|
+
const n = this.decimalMultiplier / P(this.decimal || _.THOR), a = this.bigIntValue / n;
|
|
1588
1590
|
switch (t) {
|
|
1589
1591
|
case "number":
|
|
1590
1592
|
return Number(a);
|
|
@@ -1776,7 +1778,7 @@ class x extends We {
|
|
|
1776
1778
|
if (i)
|
|
1777
1779
|
return Re(t, n);
|
|
1778
1780
|
const { tax: p, decimal: u, identifier: y } = r || {
|
|
1779
|
-
decimal:
|
|
1781
|
+
decimal: _[a],
|
|
1780
1782
|
identifier: t
|
|
1781
1783
|
};
|
|
1782
1784
|
return new x({
|
|
@@ -1791,7 +1793,7 @@ class x extends We {
|
|
|
1791
1793
|
if (i)
|
|
1792
1794
|
return Re(t, n);
|
|
1793
1795
|
const { tax: p, decimal: u, identifier: y } = r || {
|
|
1794
|
-
decimal:
|
|
1796
|
+
decimal: _[a],
|
|
1795
1797
|
identifier: t
|
|
1796
1798
|
};
|
|
1797
1799
|
return new x({ tax: p, decimal: u, identifier: y, value: G(n, u) });
|
|
@@ -1810,7 +1812,7 @@ class x extends We {
|
|
|
1810
1812
|
(r = i == null ? void 0 : i.tokens) == null || r.forEach(({ identifier: p, chain: u, ...y }) => {
|
|
1811
1813
|
W.set(p.toUpperCase(), {
|
|
1812
1814
|
identifier: p,
|
|
1813
|
-
decimal: "decimals" in y ? y.decimals :
|
|
1815
|
+
decimal: "decimals" in y ? y.decimals : _[u]
|
|
1814
1816
|
});
|
|
1815
1817
|
});
|
|
1816
1818
|
}), t({ ok: !0 });
|
|
@@ -1899,6 +1901,7 @@ const Jt = {
|
|
|
1899
1901
|
core_wallet_trezor_not_installed: 10106,
|
|
1900
1902
|
core_wallet_keplr_not_installed: 10107,
|
|
1901
1903
|
core_wallet_okx_not_installed: 10108,
|
|
1904
|
+
core_wallet_keepkey_not_installed: 10109,
|
|
1902
1905
|
/**
|
|
1903
1906
|
* Core - Swap
|
|
1904
1907
|
*/
|
|
@@ -8233,7 +8236,7 @@ const Zt = [
|
|
|
8233
8236
|
type: "function"
|
|
8234
8237
|
},
|
|
8235
8238
|
{ stateMutability: "payable", type: "receive" }
|
|
8236
|
-
],
|
|
8239
|
+
], _n = [
|
|
8237
8240
|
{
|
|
8238
8241
|
inputs: [
|
|
8239
8242
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -8364,7 +8367,7 @@ const Zt = [
|
|
|
8364
8367
|
["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Zt,
|
|
8365
8368
|
["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: en,
|
|
8366
8369
|
["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: tn
|
|
8367
|
-
},
|
|
8370
|
+
}, An = {
|
|
8368
8371
|
...dn,
|
|
8369
8372
|
...Xe,
|
|
8370
8373
|
// AVAX
|
|
@@ -8380,7 +8383,7 @@ const Zt = [
|
|
|
8380
8383
|
["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: bn,
|
|
8381
8384
|
["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: fn,
|
|
8382
8385
|
["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: hn,
|
|
8383
|
-
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]:
|
|
8386
|
+
["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: _n
|
|
8384
8387
|
}, wn = ({
|
|
8385
8388
|
streamSwap: e,
|
|
8386
8389
|
contractAddress: t,
|
|
@@ -8396,7 +8399,7 @@ const Zt = [
|
|
|
8396
8399
|
memoStreamingSwap: o,
|
|
8397
8400
|
tcMemo: T,
|
|
8398
8401
|
tcRouter: f,
|
|
8399
|
-
tcVault:
|
|
8402
|
+
tcVault: A,
|
|
8400
8403
|
vault: w,
|
|
8401
8404
|
token: M
|
|
8402
8405
|
}
|
|
@@ -8405,7 +8408,7 @@ const Zt = [
|
|
|
8405
8408
|
if (R && !d)
|
|
8406
8409
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
8407
8410
|
const O = T || y, D = e && o || O;
|
|
8408
|
-
if (!
|
|
8411
|
+
if (!A && !w)
|
|
8409
8412
|
throw new Error("TC Vault is required on calldata");
|
|
8410
8413
|
if (!f && !d)
|
|
8411
8414
|
throw new Error("TC Router is required on calldata");
|
|
@@ -8416,7 +8419,7 @@ const Zt = [
|
|
|
8416
8419
|
const pe = [
|
|
8417
8420
|
// v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
|
|
8418
8421
|
a(f || d),
|
|
8419
|
-
a(
|
|
8422
|
+
a(A || w),
|
|
8420
8423
|
D.replace("{recipientAddress}", n),
|
|
8421
8424
|
a(M),
|
|
8422
8425
|
i
|
|
@@ -8472,10 +8475,10 @@ const Zt = [
|
|
|
8472
8475
|
}
|
|
8473
8476
|
}, gn = (e) => {
|
|
8474
8477
|
const t = e ? X.ThornodeStagenet : X.ThornodeMainnet;
|
|
8475
|
-
return
|
|
8478
|
+
return Ae.get(`${t}/thorchain/inbound_addresses`);
|
|
8476
8479
|
}, Rn = (e) => {
|
|
8477
8480
|
const t = e ? X.ThornodeStagenet : X.ThornodeMainnet;
|
|
8478
|
-
return
|
|
8481
|
+
return Ae.get(`${t}/thorchain/mimir`);
|
|
8479
8482
|
}, Se = () => Object.values(s).reduce(
|
|
8480
8483
|
(e, t) => (e[t] = null, e),
|
|
8481
8484
|
{}
|
|
@@ -8521,10 +8524,10 @@ class Xn {
|
|
|
8521
8524
|
throw new m("core_wallet_connection_not_found");
|
|
8522
8525
|
if (!(t ? (u = a == null ? void 0 : a.streamingSwap) == null ? void 0 : u.transaction : a == null ? void 0 : a.transaction))
|
|
8523
8526
|
throw new m("core_swap_route_transaction_not_found");
|
|
8524
|
-
const { data: T, from: f, to:
|
|
8527
|
+
const { data: T, from: f, to: A, value: w } = a.transaction, M = {
|
|
8525
8528
|
data: T,
|
|
8526
8529
|
from: f,
|
|
8527
|
-
to:
|
|
8530
|
+
to: A.toLowerCase(),
|
|
8528
8531
|
chainId: BigInt(De[p]),
|
|
8529
8532
|
value: w ? BigInt(w) : 0n
|
|
8530
8533
|
};
|
|
@@ -8538,8 +8541,8 @@ class Xn {
|
|
|
8538
8541
|
throw new m("core_swap_asset_not_recognized");
|
|
8539
8542
|
const { address: o } = await h(this, L).call(this, d.chain), {
|
|
8540
8543
|
contract: T,
|
|
8541
|
-
calldata: { expiration: f, amountIn:
|
|
8542
|
-
} = a, R = d.add(k.fromBigInt(BigInt(
|
|
8544
|
+
calldata: { expiration: f, amountIn: A, memo: w, memoStreamingSwap: M }
|
|
8545
|
+
} = a, R = d.add(k.fromBigInt(BigInt(A), d.decimal)), O = t && M || w;
|
|
8543
8546
|
return this.deposit({
|
|
8544
8547
|
expiration: f,
|
|
8545
8548
|
assetValue: R,
|
|
@@ -8556,7 +8559,7 @@ class Xn {
|
|
|
8556
8559
|
const T = this.connectedWallets[p], f = this.getAddress(p);
|
|
8557
8560
|
if (!(T != null && T.sendTransaction) || !f)
|
|
8558
8561
|
throw new m("core_wallet_connection_not_found");
|
|
8559
|
-
const { getProvider:
|
|
8562
|
+
const { getProvider: A, toChecksumAddress: w } = await import("@swapkit/toolbox-evm"), M = A(p), R = An[o.toLowerCase()];
|
|
8560
8563
|
if (!R)
|
|
8561
8564
|
throw new m("core_swap_contract_not_supported", { contractAddress: o });
|
|
8562
8565
|
const D = await (await ((y = T.createContract) == null ? void 0 : y.call(T, o, R, M))).getFunction("swapIn").populateTransaction(
|
|
@@ -8652,7 +8655,7 @@ class Xn {
|
|
|
8652
8655
|
return await y.transfer(d);
|
|
8653
8656
|
}
|
|
8654
8657
|
} catch (o) {
|
|
8655
|
-
const T = ((o == null ? void 0 : o.message) || (o == null ? void 0 : o.toString())).toLowerCase(), f = T == null ? void 0 : T.includes("insufficient funds"),
|
|
8658
|
+
const T = ((o == null ? void 0 : o.message) || (o == null ? void 0 : o.toString())).toLowerCase(), f = T == null ? void 0 : T.includes("insufficient funds"), A = T == null ? void 0 : T.includes("gas"), w = T == null ? void 0 : T.includes("server"), M = f ? "core_transaction_deposit_insufficient_funds_error" : A ? "core_transaction_deposit_gas_error" : w ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
|
|
8656
8659
|
throw new m(M, o);
|
|
8657
8660
|
}
|
|
8658
8661
|
});
|
|
@@ -8698,10 +8701,10 @@ class Xn {
|
|
|
8698
8701
|
isPendingSymmAsset: r,
|
|
8699
8702
|
mode: p = "sym"
|
|
8700
8703
|
}) => {
|
|
8701
|
-
const { chain: u, symbol: y } = n, d = p === "sym", o = (t == null ? void 0 : t.gt(0)) && (d || p === "rune"), T = (n == null ? void 0 : n.gt(0)) && (d || p === "asset"), f = r || o,
|
|
8704
|
+
const { chain: u, symbol: y } = n, d = p === "sym", o = (t == null ? void 0 : t.gt(0)) && (d || p === "rune"), T = (n == null ? void 0 : n.gt(0)) && (d || p === "asset"), f = r || o, A = f ? a || this.getAddress(s.THORChain) : "", w = d || p === "asset" ? i || this.getAddress(u) : "";
|
|
8702
8705
|
if (!o && !T)
|
|
8703
8706
|
throw new m("core_transaction_add_liquidity_invalid_params");
|
|
8704
|
-
if (f && !
|
|
8707
|
+
if (f && !A)
|
|
8705
8708
|
throw new m("core_transaction_add_liquidity_no_rune_address");
|
|
8706
8709
|
let M, R;
|
|
8707
8710
|
if (o && t)
|
|
@@ -8717,7 +8720,7 @@ class Xn {
|
|
|
8717
8720
|
try {
|
|
8718
8721
|
R = await h(this, I).call(this, {
|
|
8719
8722
|
assetValue: n,
|
|
8720
|
-
memo: C(b.DEPOSIT, { chain: u, symbol: y, address:
|
|
8723
|
+
memo: C(b.DEPOSIT, { chain: u, symbol: y, address: A })
|
|
8721
8724
|
});
|
|
8722
8725
|
} catch (O) {
|
|
8723
8726
|
throw new m("core_transaction_add_liquidity_asset_error", O);
|
|
@@ -8864,6 +8867,9 @@ class Xn {
|
|
|
8864
8867
|
c(this, "connectWalletconnect", async (t, n) => {
|
|
8865
8868
|
throw new m("core_wallet_walletconnect_not_installed");
|
|
8866
8869
|
});
|
|
8870
|
+
c(this, "connectKeepkey", async (t, n) => {
|
|
8871
|
+
throw new m("core_wallet_keepkey_not_installed");
|
|
8872
|
+
});
|
|
8867
8873
|
c(this, "connectKeystore", async (t, n) => {
|
|
8868
8874
|
throw new m("core_wallet_keystore_not_installed");
|
|
8869
8875
|
});
|
|
@@ -8915,12 +8921,12 @@ class Xn {
|
|
|
8915
8921
|
const f = this.getAddress(r);
|
|
8916
8922
|
if (!i || !f)
|
|
8917
8923
|
throw new m("core_approve_asset_address_or_from_not_found");
|
|
8918
|
-
const
|
|
8924
|
+
const A = a || (await h(this, L).call(this, r)).router;
|
|
8919
8925
|
return T({
|
|
8920
8926
|
amount: t.getBaseValue("bigint"),
|
|
8921
8927
|
assetAddress: i,
|
|
8922
8928
|
from: f,
|
|
8923
|
-
spenderAddress:
|
|
8929
|
+
spenderAddress: A
|
|
8924
8930
|
});
|
|
8925
8931
|
});
|
|
8926
8932
|
B(this, I, async ({
|
|
@@ -8962,7 +8968,7 @@ export {
|
|
|
8962
8968
|
Sn as ApiError,
|
|
8963
8969
|
X as ApiUrl,
|
|
8964
8970
|
x as AssetValue,
|
|
8965
|
-
|
|
8971
|
+
_ as BaseDecimal,
|
|
8966
8972
|
We as BigIntArithmetics,
|
|
8967
8973
|
s as Chain,
|
|
8968
8974
|
fe as ChainId,
|
|
@@ -8984,7 +8990,7 @@ export {
|
|
|
8984
8990
|
Cn as NetworkDerivationPath,
|
|
8985
8991
|
nt as QuoteMode,
|
|
8986
8992
|
ke as RPCUrl,
|
|
8987
|
-
|
|
8993
|
+
Ae as RequestClient,
|
|
8988
8994
|
it as SWAP_IN,
|
|
8989
8995
|
st as SWAP_OUT,
|
|
8990
8996
|
Xn as SwapKitCore,
|