@latchprotocol/widgets 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/chunks/{SwapWidget-DgyHAVc8.js → SwapWidget-CwkRtOfn.js} +58 -66
- package/dist/chunks/SwapWidget-CwkRtOfn.js.map +1 -0
- package/dist/chunks/{useLocker-D1c_NTk-.js → useLocker-CGpgCh75.js} +641 -641
- package/dist/chunks/{useLocker-D1c_NTk-.js.map → useLocker-CGpgCh75.js.map} +1 -1
- package/dist/components/LaunchWidget.d.ts.map +1 -1
- package/dist/embed.js +12 -12
- package/dist/embed.js.map +1 -1
- package/dist/headless.js +1 -1
- package/dist/index.js +87 -87
- package/dist/index.js.map +1 -1
- package/dist/latch-embed.js +1 -1
- package/dist/latch-embed.js.map +1 -1
- package/dist/latch-embed.mjs +4 -5
- package/dist/latch-embed.mjs.map +1 -1
- package/dist/trust/model.d.ts +4 -3
- package/dist/trust/model.d.ts.map +1 -1
- package/package.json +1 -5
- package/dist/chunks/SwapWidget-DgyHAVc8.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://latches.fun">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Latch-Protocol-Team/latch-sdk/main/assets/og.png"
|
|
4
|
+
alt="Latch Protocol — hooks for a bigger ecosystem" width="640">
|
|
5
|
+
</a>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://latches.fun">Website</a> ·
|
|
10
|
+
<a href="https://www.npmjs.com/package/@latchprotocol/widgets">npm</a> ·
|
|
11
|
+
<a href="https://github.com/Latch-Protocol-Team">GitHub</a> ·
|
|
12
|
+
<a href="https://x.com/Latchesdotfun">X</a> ·
|
|
13
|
+
<a href="https://x.com/Ox_Forged">Developer on X</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<b>Building on Latch with a coding agent?</b> Start with a prompt, not the docs:<br>
|
|
18
|
+
<a href="https://github.com/Latch-Protocol-Team/latch-sdk/blob/main/prompts/dex-integration.md">🔁 Ship a DEX</a> ·
|
|
19
|
+
<a href="https://github.com/Latch-Protocol-Team/latch-sdk/blob/main/prompts/launchpad-integration.md">🚀 Run a Launchpad</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
1
22
|
# @latchprotocol/widgets
|
|
2
23
|
|
|
3
24
|
Embeddable swap, liquidity and launch widgets for **Latch Protocol** — a hooks platform on its own Infinity-architecture core (a singleton Vault with CL and Bin pool managers), deployed and verified per chain.
|
|
4
25
|
|
|
5
|
-
These widgets are built to live in **your** app. Not Latch's. If you run a DEX, an aggregator, a
|
|
26
|
+
These widgets are built to live in **your** app. Not Latch's. If you run a DEX, an aggregator, a Launchpad, a wallet or a portfolio tracker, you can drop one in, keep your own look, and **earn a share of every swap it routes**.
|
|
6
27
|
|
|
7
28
|
MIT licensed. The protocol's Solidity is GPL-2.0; this package is independently authored against the ABIs, so embedding it puts no licence obligation on your app.
|
|
8
29
|
|
|
@@ -642,6 +663,17 @@ The multi-hop case is the exception: Sepolia has one pool over two tokens, so th
|
|
|
642
663
|
|
|
643
664
|
---
|
|
644
665
|
|
|
666
|
+
## Other Latch packages
|
|
667
|
+
|
|
668
|
+
- [`@latchprotocol/sdk`](https://www.npmjs.com/package/@latchprotocol/sdk) — TypeScript SDK: pool keys and ids, the hook permission bitmap, typed events, the address book, market reads and the Launchpad builders
|
|
669
|
+
- [`@latchprotocol/connect`](https://www.npmjs.com/package/@latchprotocol/connect) — the wallet layer: a Latch-themed wrapper over RainbowKit and wagmi, with the Latch chain list
|
|
670
|
+
- [`@latchprotocol/cli`](https://www.npmjs.com/package/@latchprotocol/cli) — the `latch` command: launches, hosted Launchpad and DEX sites, airdrops, splits, locks and `latch doctor`
|
|
671
|
+
- [`@latchprotocol/create-app`](https://www.npmjs.com/package/@latchprotocol/create-app) — the Latch app template: a DEX, a Launchpad or both, on the shared core
|
|
672
|
+
- [`@latchprotocol/create-hook`](https://www.npmjs.com/package/@latchprotocol/create-hook) — the hook starter: `npx @latchprotocol/create-hook my-latch --template dynamic-fee`
|
|
673
|
+
|
|
674
|
+
Website: [latches.fun](https://latches.fun) · X: [@Latchesdotfun](https://x.com/Latchesdotfun)
|
|
675
|
+
|
|
676
|
+
|
|
645
677
|
## Licence
|
|
646
678
|
|
|
647
679
|
MIT. See [LICENSE](LICENSE).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as l, Fragment as X } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as ht, useContext as ut, useId as ge, useMemo as
|
|
3
|
-
import { at as q, aj as Je, bX as le, aS as bt, aA as Q, br as H, bK as ft, bl as Se, bJ as vt, bH as xt, bC as xe, b4 as se, bU as Le, bI as kt, a2 as wt, aB as Pe, az as W, au as $e, bN as yt, a7 as _t, bM as Nt, ah as Ct, ab as Tt, b3 as zt, bE as St, bD as Lt, ak as qe, bO as Pt, b_ as $t, bh as qt, bQ as It, bu as ze, z as Ve, _ as
|
|
2
|
+
import { createContext as ht, useContext as ut, useId as ge, useMemo as R, useState as L, useEffect as I, useCallback as V, forwardRef as pt, useReducer as mt, useRef as oe, useImperativeHandle as gt } from "react";
|
|
3
|
+
import { at as q, aj as Je, bX as le, aS as bt, aA as Q, br as H, bK as ft, bl as Se, bJ as vt, bH as xt, bC as xe, b4 as se, bU as Le, bI as kt, a2 as wt, aB as Pe, az as W, au as $e, bN as yt, a7 as _t, bM as Nt, ah as Ct, ab as Tt, b3 as zt, bE as St, bD as Lt, ak as qe, bO as Pt, b_ as $t, bh as qt, bQ as It, bu as ze, z as Ve, _ as At, j as Rt, aK as Bt, bm as Ft, bV as Mt, bW as Ot, ad as Et, a_ as Qe, bt as jt, aM as Dt, b0 as Ut, bT as Wt, bS as Vt, bb as Qt, a6 as Ht, bo as Yt, an as Gt, bc as Kt, b2 as Xt, aZ as Jt, bn as He, a$ as Zt } from "./scan-Dhu7f4Nl.js";
|
|
4
4
|
import { humanDuration as ea, isDynamicLPFee as ta } from "@latchprotocol/sdk";
|
|
5
5
|
import { formatUnits as Ze } from "viem";
|
|
6
6
|
import * as me from "@radix-ui/react-popover";
|
|
@@ -1096,7 +1096,7 @@ function ca(t) {
|
|
|
1096
1096
|
] });
|
|
1097
1097
|
}
|
|
1098
1098
|
function Pa(t) {
|
|
1099
|
-
const a =
|
|
1099
|
+
const a = R(
|
|
1100
1100
|
() => t.tokens.flatMap((n, r) => {
|
|
1101
1101
|
const s = /* @__PURE__ */ e("span", { className: "latch-route-token", children: n }, `token-${n}-${r}`);
|
|
1102
1102
|
return r === 0 ? [s] : [
|
|
@@ -1125,12 +1125,12 @@ function sa(t) {
|
|
|
1125
1125
|
launch: i,
|
|
1126
1126
|
amountIn: c,
|
|
1127
1127
|
...t.onPurchaseConfirmed ? { onSuccess: t.onPurchaseConfirmed } : {}
|
|
1128
|
-
}), P =
|
|
1128
|
+
}), P = R(
|
|
1129
1129
|
() => i === null ? null : wt(i),
|
|
1130
1130
|
[i]
|
|
1131
1131
|
), M = V(
|
|
1132
|
-
(
|
|
1133
|
-
if (
|
|
1132
|
+
(A) => {
|
|
1133
|
+
if (A.preventDefault(), o.execution.needsApproval) {
|
|
1134
1134
|
o.execution.approve();
|
|
1135
1135
|
return;
|
|
1136
1136
|
}
|
|
@@ -1231,7 +1231,7 @@ function sa(t) {
|
|
|
1231
1231
|
function lt(t) {
|
|
1232
1232
|
switch (t.state) {
|
|
1233
1233
|
case "loading":
|
|
1234
|
-
return /* @__PURE__ */ e(F, { message: "
|
|
1234
|
+
return /* @__PURE__ */ e(F, { message: "Loading the launch schedule…", tone: "neutral" });
|
|
1235
1235
|
case "not-configured":
|
|
1236
1236
|
return /* @__PURE__ */ e("div", { className: "latch-summary", children: /* @__PURE__ */ e(
|
|
1237
1237
|
F,
|
|
@@ -1254,7 +1254,7 @@ function lt(t) {
|
|
|
1254
1254
|
/* @__PURE__ */ e(
|
|
1255
1255
|
F,
|
|
1256
1256
|
{
|
|
1257
|
-
message: t.error?.message ?? "
|
|
1257
|
+
message: t.error?.message ?? "Couldn't load this launch. Try again.",
|
|
1258
1258
|
tone: "error",
|
|
1259
1259
|
assertive: !0
|
|
1260
1260
|
}
|
|
@@ -1275,7 +1275,7 @@ function da(t) {
|
|
|
1275
1275
|
{
|
|
1276
1276
|
label: "Fee right now",
|
|
1277
1277
|
value: Q(a.currentFeePips),
|
|
1278
|
-
title: "
|
|
1278
|
+
title: "Live from the chain."
|
|
1279
1279
|
}
|
|
1280
1280
|
),
|
|
1281
1281
|
/* @__PURE__ */ e(
|
|
@@ -1290,7 +1290,7 @@ function da(t) {
|
|
|
1290
1290
|
{
|
|
1291
1291
|
label: "Opens at",
|
|
1292
1292
|
value: n.start === null ? "unknown" : ia(n.durationClock, n.start),
|
|
1293
|
-
title:
|
|
1293
|
+
title: "Trading opens at this time; swaps before it are refused."
|
|
1294
1294
|
}
|
|
1295
1295
|
),
|
|
1296
1296
|
/* @__PURE__ */ e(
|
|
@@ -1305,30 +1305,22 @@ function da(t) {
|
|
|
1305
1305
|
{
|
|
1306
1306
|
label: "Launch owner",
|
|
1307
1307
|
value: H(a.guard.owner),
|
|
1308
|
-
title: "
|
|
1308
|
+
title: "Set when the launch was configured. It cannot change anything once trading opens."
|
|
1309
1309
|
}
|
|
1310
1310
|
)
|
|
1311
1311
|
] }),
|
|
1312
1312
|
r !== null ? /* @__PURE__ */ l("div", { className: "latch-field", children: [
|
|
1313
1313
|
/* @__PURE__ */ e("span", { className: "latch-label", children: "Fee decay" }),
|
|
1314
1314
|
/* @__PURE__ */ e(ra, { label: "Fee decay progress", percent: r / 100 }),
|
|
1315
|
-
/* @__PURE__ */
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
] }),
|
|
1320
|
-
/* @__PURE__ */ l("span", { className: "latch-meta-value", children: [
|
|
1321
|
-
"read at ",
|
|
1322
|
-
a.guard.durationClock === "timestamp" ? "block.timestamp" : "hook block",
|
|
1323
|
-
" ",
|
|
1324
|
-
a.readAt.toLocaleString()
|
|
1325
|
-
] })
|
|
1326
|
-
] })
|
|
1315
|
+
/* @__PURE__ */ e("div", { className: "latch-meta", children: /* @__PURE__ */ l("span", { children: [
|
|
1316
|
+
(r / 100).toFixed(1),
|
|
1317
|
+
"% of the way to the final fee"
|
|
1318
|
+
] }) })
|
|
1327
1319
|
] }) : null,
|
|
1328
1320
|
s !== null && s !== 0 ? /* @__PURE__ */ e(
|
|
1329
1321
|
F,
|
|
1330
1322
|
{
|
|
1331
|
-
message: `The
|
|
1323
|
+
message: `The chain reports ${Q(a.currentFeePips)} but this page projects ${Q(a.currentFeePips - s)}. The figure above is the chain's; the curve below may be off.`,
|
|
1332
1324
|
tone: "error"
|
|
1333
1325
|
}
|
|
1334
1326
|
) : null
|
|
@@ -1372,7 +1364,7 @@ function ua(t) {
|
|
|
1372
1364
|
] });
|
|
1373
1365
|
}
|
|
1374
1366
|
function pa(t) {
|
|
1375
|
-
const { guard: a, schedule: n } = t, r = 320, s = 72, g = 48, d =
|
|
1367
|
+
const { guard: a, schedule: n } = t, r = 320, s = 72, g = 48, d = R(() => {
|
|
1376
1368
|
if (a.window <= 0) return [];
|
|
1377
1369
|
const _ = [];
|
|
1378
1370
|
for (let T = 0; T <= g; T += 1) {
|
|
@@ -1437,7 +1429,7 @@ function $a(t) {
|
|
|
1437
1429
|
)) });
|
|
1438
1430
|
}
|
|
1439
1431
|
function qa(t) {
|
|
1440
|
-
const { chain: a, onConnectRequest: n } = le(), r = t.onConnectRequest ?? n, s = yt(), g = xe(), [d, u] = L(t.defaultMode ?? "add"), [i, m] = L(null), [b, v] = L(0), w = t.onLiquidityChanged, k =
|
|
1432
|
+
const { chain: a, onConnectRequest: n } = le(), r = t.onConnectRequest ?? n, s = yt(), g = xe(), [d, u] = L(t.defaultMode ?? "add"), [i, m] = L(null), [b, v] = L(0), w = t.onLiquidityChanged, k = R(
|
|
1441
1433
|
() => _t(() => v((_) => _ + 1), w),
|
|
1442
1434
|
[w]
|
|
1443
1435
|
);
|
|
@@ -1518,18 +1510,18 @@ function ga(t) {
|
|
|
1518
1510
|
}, [a, r.data, g]), I(() => {
|
|
1519
1511
|
i({ side: 0, text: "" }), b({ t0: "", t1: "" });
|
|
1520
1512
|
}, [a.id]);
|
|
1521
|
-
const v = r.data?.sqrtPriceX96 ?? null, w = g !== null && g.type === "CL" && v !== null ? g : null, k = w === null || v === null ? null : Tt(v, w.tickLower, w.tickUpper), { amount0Text: _, amount1Text: T } =
|
|
1513
|
+
const v = r.data?.sqrtPriceX96 ?? null, w = g !== null && g.type === "CL" && v !== null ? g : null, k = w === null || v === null ? null : Tt(v, w.tickLower, w.tickUpper), { amount0Text: _, amount1Text: T } = R(() => {
|
|
1522
1514
|
if (w === null || v === null || k === null) return { amount0Text: m.t0, amount1Text: m.t1 };
|
|
1523
|
-
const z = u.side === 0 ? a.token0.decimals : a.token1.decimals, j = u.side === 0 ? a.token1.decimals : a.token0.decimals,
|
|
1515
|
+
const z = u.side === 0 ? a.token0.decimals : a.token1.decimals, j = u.side === 0 ? a.token1.decimals : a.token0.decimals, A = u.text;
|
|
1524
1516
|
let Y = "";
|
|
1525
1517
|
if (k === "both") {
|
|
1526
|
-
const ee =
|
|
1518
|
+
const ee = A.trim() === "" ? null : se(A, z);
|
|
1527
1519
|
if (ee !== null && ee.ok) {
|
|
1528
|
-
const
|
|
1529
|
-
Y =
|
|
1520
|
+
const G = zt(v, w.tickLower, w.tickUpper, u.side === 0 ? "token0" : "token1", ee.value);
|
|
1521
|
+
Y = G === null ? "" : Ze(G, j);
|
|
1530
1522
|
}
|
|
1531
1523
|
}
|
|
1532
|
-
return k === "token0-only" ? { amount0Text: u.side === 0 ?
|
|
1524
|
+
return k === "token0-only" ? { amount0Text: u.side === 0 ? A : "", amount1Text: "0" } : k === "token1-only" ? { amount0Text: "0", amount1Text: u.side === 1 ? A : "" } : u.side === 0 ? { amount0Text: A, amount1Text: Y } : { amount0Text: Y, amount1Text: A };
|
|
1533
1525
|
}, [w, v, k, u, m, a.token0.decimals, a.token1.decimals]), y = V((z) => {
|
|
1534
1526
|
i({ side: 0, text: z }), b((j) => ({ ...j, t0: z }));
|
|
1535
1527
|
}, []), c = V((z) => {
|
|
@@ -1703,7 +1695,7 @@ function ba(t) {
|
|
|
1703
1695
|
return /* @__PURE__ */ l("fieldset", { className: "latch-field", style: { margin: 0 }, children: [
|
|
1704
1696
|
/* @__PURE__ */ l("legend", { className: "latch-label", style: { padding: "0 4px" }, children: [
|
|
1705
1697
|
"Bin range (step ",
|
|
1706
|
-
|
|
1698
|
+
At(a),
|
|
1707
1699
|
")"
|
|
1708
1700
|
] }),
|
|
1709
1701
|
/* @__PURE__ */ l("label", { className: "latch-label", htmlFor: "latch-bin-width", children: [
|
|
@@ -1738,7 +1730,7 @@ function ba(t) {
|
|
|
1738
1730
|
] });
|
|
1739
1731
|
}
|
|
1740
1732
|
function fa(t) {
|
|
1741
|
-
const a = Pt(t.account, t.pool, t.refreshKey), [n, r] = L(null), [s, g] = L(5e3), d =
|
|
1733
|
+
const a = Pt(t.account, t.pool, t.refreshKey), [n, r] = L(null), [s, g] = L(5e3), d = R(() => $t(a.data ?? []), [a.data]);
|
|
1742
1734
|
I(() => {
|
|
1743
1735
|
r((m) => qt(m, d));
|
|
1744
1736
|
}, [d]);
|
|
@@ -1836,7 +1828,7 @@ function xa(t) {
|
|
|
1836
1828
|
const m = Number.parseFloat(i);
|
|
1837
1829
|
if (!Number.isFinite(m) || m < 0) return;
|
|
1838
1830
|
const b = Math.round(m * 100);
|
|
1839
|
-
b >
|
|
1831
|
+
b > Rt || t.onSlippageChange(b);
|
|
1840
1832
|
}, d = t.slippageBps > 100, u = t.slippageBps < 5;
|
|
1841
1833
|
return /* @__PURE__ */ l(me.Root, { children: [
|
|
1842
1834
|
/* @__PURE__ */ e(me.Trigger, { asChild: !0, children: /* @__PURE__ */ l("button", { type: "button", className: "latch-icon-button latch-settings-trigger", "aria-label": "Swap settings", children: [
|
|
@@ -1919,15 +1911,15 @@ function ya() {
|
|
|
1919
1911
|
}
|
|
1920
1912
|
function _a(t) {
|
|
1921
1913
|
const a = t.token, n = [];
|
|
1922
|
-
return a.stock !== void 0 && (n.push({ key: "stock", label: `${a.stock.issuer} · ${a.stock.ticker}`, tone: "info", title: `Tokenised stock issued by ${a.stock.issuer} (underlying ${a.stock.ticker}). The issuer can pause transfers and upgrade the token.` }), a.stock.rebasing && n.push({ key: "rebasing", label: "rebasing", tone: "warn", title: "The issuer rescales balances. Not usable as a Latch pool currency." })), a.tags?.includes("test") && n.push({ key: "test", label: "test token", tone: "muted", title: "A throwaway token with no economic meaning." }), a.tags?.includes("launch") && n.push({ key: "launch", label: "launch", tone: "muted", title: "
|
|
1914
|
+
return a.stock !== void 0 && (n.push({ key: "stock", label: `${a.stock.issuer} · ${a.stock.ticker}`, tone: "info", title: `Tokenised stock issued by ${a.stock.issuer} (underlying ${a.stock.ticker}). The issuer can pause transfers and upgrade the token.` }), a.stock.rebasing && n.push({ key: "rebasing", label: "rebasing", tone: "warn", title: "The issuer rescales balances. Not usable as a Latch pool currency." })), a.tags?.includes("test") && n.push({ key: "test", label: "test token", tone: "muted", title: "A throwaway token with no economic meaning." }), a.tags?.includes("launch") && n.push({ key: "launch", label: "launch", tone: "muted", title: "Launched on Latch; its launch pools are locked forever." }), n.length === 0 ? null : /* @__PURE__ */ e("span", { className: "latch-token-row__badges", children: n.map((r) => /* @__PURE__ */ e("span", { className: "latch-badge", "data-latch-tone": r.tone, title: r.title, children: r.label }, r.key)) });
|
|
1923
1915
|
}
|
|
1924
|
-
function
|
|
1916
|
+
function Ge(t) {
|
|
1925
1917
|
return /* @__PURE__ */ l("span", { className: "latch-token-button latch-token-button--locked", role: "img", "aria-label": `${t.label}: ${t.value?.symbol ?? "loading"} (fixed)`, title: "This pair is fixed on this page", children: [
|
|
1926
1918
|
/* @__PURE__ */ e(ie, { token: t.value }),
|
|
1927
1919
|
/* @__PURE__ */ e("span", { className: "latch-token-button__symbol", children: t.value?.symbol ?? "…" })
|
|
1928
1920
|
] });
|
|
1929
1921
|
}
|
|
1930
|
-
function
|
|
1922
|
+
function Ke(t) {
|
|
1931
1923
|
const { adapter: a } = le(), n = tt(), r = xe(), [s, g] = L(!1), [d, u] = L(""), [i, m] = L({}), [b, v] = L("none");
|
|
1932
1924
|
I(() => {
|
|
1933
1925
|
if (!s || r.data === null || r.data === void 0) return;
|
|
@@ -1964,7 +1956,7 @@ function Ge(t) {
|
|
|
1964
1956
|
h = !0;
|
|
1965
1957
|
};
|
|
1966
1958
|
}, [d, t.tokens, a]);
|
|
1967
|
-
const w =
|
|
1959
|
+
const w = R(() => {
|
|
1968
1960
|
const c = d.trim().toLowerCase();
|
|
1969
1961
|
return [...c === "" ? t.tokens : t.tokens.filter(
|
|
1970
1962
|
(o) => o.symbol.toLowerCase().includes(c) || o.name.toLowerCase().includes(c) || o.address.toLowerCase() === c || o.stock !== void 0 && (o.stock.ticker.toLowerCase().includes(c) || o.stock.issuer.toLowerCase().includes(c))
|
|
@@ -1972,7 +1964,7 @@ function Ge(t) {
|
|
|
1972
1964
|
const M = i[o.address.toLowerCase()] ?? 0n, E = i[P.address.toLowerCase()] ?? 0n;
|
|
1973
1965
|
return M === E ? 0 : M > E ? -1 : 1;
|
|
1974
1966
|
});
|
|
1975
|
-
}, [t.tokens, d, i]), k =
|
|
1967
|
+
}, [t.tokens, d, i]), k = R(() => w.some((c) => c.listSource !== void 0) ? Bt(w) : null, [w]), _ = t.tokens.slice(0, 5), T = (c) => {
|
|
1976
1968
|
t.onChange(c), g(!1), u("");
|
|
1977
1969
|
}, y = (c) => {
|
|
1978
1970
|
const h = i[c.address.toLowerCase()], o = t.exclude?.address.toLowerCase() === c.address.toLowerCase(), P = c.listSource?.alsoIn ?? [];
|
|
@@ -2036,7 +2028,7 @@ function Ge(t) {
|
|
|
2036
2028
|
c.symbol
|
|
2037
2029
|
] }, c.address)) }) : null,
|
|
2038
2030
|
/* @__PURE__ */ l("ul", { className: "latch-token-list", role: "listbox", "aria-label": "Tokens", children: [
|
|
2039
|
-
b === "loading" ? /* @__PURE__ */ e("li", { className: "latch-token-row latch-token-row--note", children: "
|
|
2031
|
+
b === "loading" ? /* @__PURE__ */ e("li", { className: "latch-token-row latch-token-row--note", children: "Loading the token…" }) : null,
|
|
2040
2032
|
b === null ? /* @__PURE__ */ e("li", { className: "latch-token-row latch-token-row--note", children: "That address does not answer as an ERC-20." }) : null,
|
|
2041
2033
|
b !== "none" && b !== "loading" && b !== null ? /* @__PURE__ */ e("li", { children: /* @__PURE__ */ l("button", { type: "button", className: "latch-token-row latch-token-row--unlisted", onClick: () => T(b), children: [
|
|
2042
2034
|
/* @__PURE__ */ e(ie, { token: b, size: 32 }),
|
|
@@ -2086,11 +2078,11 @@ function Ge(t) {
|
|
|
2086
2078
|
}
|
|
2087
2079
|
const Xe = 1500;
|
|
2088
2080
|
function Na(t, a) {
|
|
2089
|
-
const { adapter: n } = le(), r = Xt(t), s =
|
|
2081
|
+
const { adapter: n } = le(), r = Xt(t), s = R(() => t === void 0 ? null : Jt(t), [r]), [g, d] = L({}), u = oe({ adapter: n, addresses: /* @__PURE__ */ new Set() }), i = oe(!0);
|
|
2090
2082
|
I(() => (i.current = !0, () => {
|
|
2091
2083
|
i.current = !1;
|
|
2092
2084
|
}), []);
|
|
2093
|
-
const m =
|
|
2085
|
+
const m = R(() => s === null ? null : { token: He(s.token, a), quote: He(s.quote, a) }, [s, a]);
|
|
2094
2086
|
return I(() => {
|
|
2095
2087
|
if (!(s === null || m === null)) {
|
|
2096
2088
|
u.current.adapter !== n && (u.current = { adapter: n, addresses: /* @__PURE__ */ new Set() });
|
|
@@ -2101,14 +2093,14 @@ function Na(t, a) {
|
|
|
2101
2093
|
u.current.addresses.has(w) || (u.current.addresses.add(w), n.getToken(w).then((k) => i.current && d((_) => ({ ..._, [w]: k }))).catch(() => i.current && d((k) => ({ ...k, [w]: null }))));
|
|
2102
2094
|
}
|
|
2103
2095
|
}
|
|
2104
|
-
}, [n, s, m]),
|
|
2096
|
+
}, [n, s, m]), R(() => {
|
|
2105
2097
|
if (s === null || m === null) return null;
|
|
2106
2098
|
const b = (v) => m[v] ?? (typeof s[v] == "string" ? g[s[v].toLowerCase()] ?? null : null);
|
|
2107
2099
|
return { token: b("token"), quote: b("quote") };
|
|
2108
2100
|
}, [s, m, g]);
|
|
2109
2101
|
}
|
|
2110
2102
|
const Ia = pt(function(a, n) {
|
|
2111
|
-
const { integrator: r, defaultSlippageBps: s, chain: g, onConnectRequest: d } = le(), u = a.onConnectRequest ?? d, i = Mt(), m = Ot(a.tokenLists), b = xe(), v =
|
|
2103
|
+
const { integrator: r, defaultSlippageBps: s, chain: g, onConnectRequest: d } = le(), u = a.onConnectRequest ?? d, i = Mt(), m = Ot(a.tokenLists), b = xe(), v = R(() => Et(i.data ?? [], m.tokens), [i.data, m.tokens]), w = Qe(a.portions), k = a.pair !== void 0 && a.lockPair === !0, _ = a.variant === "compact", [T, y] = mt(jt, { ...a.pair === void 0 ? {} : { pair: a.pair }, ...a.side === void 0 ? {} : { side: a.side } }, Dt), c = a.side ?? T.side, { tokenIn: h, tokenOut: o } = Ut(T.anchor, c), { amountText: P, impactAck: M } = T, [E, $] = L(s), [N, U] = L(!1), [ce, J] = L(!1);
|
|
2112
2104
|
I(() => {
|
|
2113
2105
|
if (a.side === void 0) return;
|
|
2114
2106
|
const p = ye.current;
|
|
@@ -2126,11 +2118,11 @@ const Ia = pt(function(a, n) {
|
|
|
2126
2118
|
...a.defaultTokenOut === void 0 ? {} : { defaultTokenOut: a.defaultTokenOut }
|
|
2127
2119
|
});
|
|
2128
2120
|
}, [v, a.pair, a.defaultTokenIn, a.defaultTokenOut, c]);
|
|
2129
|
-
const z = V((p) => y({ type: "amount", text: p }), []), j = V((p) => y({ type: "ack", value: p }), []),
|
|
2121
|
+
const z = V((p) => y({ type: "amount", text: p }), []), j = V((p) => y({ type: "ack", value: p }), []), A = R(() => h === null || P.trim() === "" ? null : se(P, h.decimals), [P, h]), Y = A !== null && A.ok ? A.value : null, ee = A !== null && !A.ok ? A.message : null, G = Le(h, b.data), Ie = Le(o, b.data), f = Wt({ tokenIn: h, tokenOut: o, amountIn: Y, slippageBps: E }), Ae = f.status !== "idle", x = Ae ? f.breakdown : null, K = Ae ? f.quote : null, C = Vt({
|
|
2130
2122
|
tokenIn: h,
|
|
2131
2123
|
tokenOut: o,
|
|
2132
2124
|
amountIn: Y,
|
|
2133
|
-
quote:
|
|
2125
|
+
quote: K,
|
|
2134
2126
|
breakdown: x,
|
|
2135
2127
|
...a.onSwapConfirmed ? { onSuccess: a.onSwapConfirmed } : {}
|
|
2136
2128
|
}), we = oe(a.onSideChange);
|
|
@@ -2138,7 +2130,7 @@ const Ia = pt(function(a, n) {
|
|
|
2138
2130
|
const he = a.side !== void 0, ye = oe(null), _e = V(() => {
|
|
2139
2131
|
const p = Zt(c), D = x !== null && o !== null && x.netAmountOut > 0n ? Ze(x.netAmountOut, o.decimals) : "";
|
|
2140
2132
|
he ? ye.current = { side: p, text: D } : y({ type: "set-side", side: p, amountText: D }), J(!1), we.current?.(p);
|
|
2141
|
-
}, [c, he, x, o]),
|
|
2133
|
+
}, [c, he, x, o]), Re = V(
|
|
2142
2134
|
(p) => {
|
|
2143
2135
|
p !== c && (he || y({ type: "set-side", side: p }), J(!1), we.current?.(p));
|
|
2144
2136
|
},
|
|
@@ -2147,10 +2139,10 @@ const Ia = pt(function(a, n) {
|
|
|
2147
2139
|
Be.current = a.onNeedsWallet;
|
|
2148
2140
|
const Ne = V(
|
|
2149
2141
|
(p) => {
|
|
2150
|
-
const D = Qt(h,
|
|
2142
|
+
const D = Qt(h, G.data, p);
|
|
2151
2143
|
return D === null ? (Be.current?.(), !1) : (z(D), !0);
|
|
2152
2144
|
},
|
|
2153
|
-
[h,
|
|
2145
|
+
[h, G.data, z]
|
|
2154
2146
|
);
|
|
2155
2147
|
gt(
|
|
2156
2148
|
n,
|
|
@@ -2162,11 +2154,11 @@ const Ia = pt(function(a, n) {
|
|
|
2162
2154
|
}),
|
|
2163
2155
|
[z, Ne, _e, f.refetch]
|
|
2164
2156
|
);
|
|
2165
|
-
const Fe =
|
|
2157
|
+
const Fe = R(
|
|
2166
2158
|
() => Ht({
|
|
2167
2159
|
tokenIn: h,
|
|
2168
2160
|
tokenOut: o,
|
|
2169
|
-
quote:
|
|
2161
|
+
quote: K,
|
|
2170
2162
|
breakdown: x,
|
|
2171
2163
|
rate: f.rate,
|
|
2172
2164
|
status: f.status,
|
|
@@ -2174,7 +2166,7 @@ const Ia = pt(function(a, n) {
|
|
|
2174
2166
|
isMock: f.isMock,
|
|
2175
2167
|
updatedAt: f.updatedAt
|
|
2176
2168
|
}),
|
|
2177
|
-
[h, o,
|
|
2169
|
+
[h, o, K, x, f.rate, f.status, f.isRefreshing, f.isMock, f.updatedAt]
|
|
2178
2170
|
), Ce = oe(a.onQuote);
|
|
2179
2171
|
Ce.current = a.onQuote, I(() => {
|
|
2180
2172
|
Ce.current?.(Fe);
|
|
@@ -2184,7 +2176,7 @@ const Ia = pt(function(a, n) {
|
|
|
2184
2176
|
},
|
|
2185
2177
|
[]
|
|
2186
2178
|
);
|
|
2187
|
-
const nt = Y !== null &&
|
|
2179
|
+
const nt = Y !== null && G.data !== null && Y > G.data, te = x?.priceImpactBps ?? null, Me = te !== null && te >= Xe && !M, ot = V(
|
|
2188
2180
|
(p) => {
|
|
2189
2181
|
if (p.preventDefault(), C.needsApproval) {
|
|
2190
2182
|
C.approve();
|
|
@@ -2193,15 +2185,15 @@ const Ia = pt(function(a, n) {
|
|
|
2193
2185
|
C.execute();
|
|
2194
2186
|
},
|
|
2195
2187
|
[C]
|
|
2196
|
-
), ue = x === null || o === null ? "" : q(x.netAmountOut, o.decimals), Oe =
|
|
2188
|
+
), ue = x === null || o === null ? "" : q(x.netAmountOut, o.decimals), Oe = R(() => K === null ? [] : Yt(K.route), [K]), rt = C.statusMessage !== "" ? C.statusMessage : f.status === "error" ? f.error === null ? "No route for this pair." : Je(f.error, "quote") : "", ct = C.step === "error" || f.status === "error" ? "error" : C.step === "success" ? "success" : "neutral", pe = C.step === "approving" || C.step === "building" || C.step === "awaiting-signature" || C.step === "pending";
|
|
2197
2189
|
let O, Te = !1;
|
|
2198
2190
|
const Ee = b.data === null || b.data === void 0;
|
|
2199
2191
|
Ee ? O = "Connect wallet" : h === null || o === null ? O = "Select a token" : Y === null || Y === 0n ? O = "Enter an amount" : ee !== null ? O = ee : nt ? O = `Insufficient ${h.symbol}` : (f.status === "loading" || f.status === "idle" && f.isRefreshing) && x === null ? O = "Fetching quote…" : f.status === "error" ? O = "Cannot quote this trade" : C.needsApproval ? (O = `Approve ${C.approvals[0]?.token.symbol ?? h.symbol}`, Te = !pe) : pe ? O = C.step === "pending" ? "Confirming on chain…" : C.step === "awaiting-signature" ? "Confirm in your wallet…" : "Preparing…" : Me ? O = "Acknowledge the price impact" : (O = "Swap", Te = C.canExecute && f.status === "success");
|
|
2200
|
-
const it = f.rate === null || h === null || o === null || f.rate === 0 ? null : ce ? Pe(1 / f.rate, o.symbol, h.symbol) : Pe(f.rate, h.symbol, o.symbol), je = C.txHash === null ? null :
|
|
2201
|
-
/* @__PURE__ */ e("button", { type: "button", className: "latch-sides__btn", "data-latch-side": "buy", "aria-pressed": c === "buy", onClick: () =>
|
|
2202
|
-
/* @__PURE__ */ e("button", { type: "button", className: "latch-sides__btn", "data-latch-side": "sell", "aria-pressed": c === "sell", onClick: () =>
|
|
2203
|
-
] }) : void 0, dt = w.length > 0 &&
|
|
2204
|
-
const D =
|
|
2192
|
+
const it = f.rate === null || h === null || o === null || f.rate === 0 ? null : ce ? Pe(1 / f.rate, o.symbol, h.symbol) : Pe(f.rate, h.symbol, o.symbol), je = C.txHash === null ? null : Gt(g, C.txHash), ne = a.creatorTax === void 0 ? void 0 : a.creatorTax === null ? null : c === "buy" ? a.creatorTax.buyBps : a.creatorTax.sellBps, De = ne === void 0 ? "" : ne === null || ne === 0 ? "none" : W(ne), Ue = "Taken by the launch pool's hook on this swap, for the creator and the protocol. The quoted output already includes it.", st = a.showSlippageControl !== !1 ? /* @__PURE__ */ e(xa, { slippageBps: E, defaultSlippageBps: s, onSlippageChange: $ }) : void 0, We = _ ? /* @__PURE__ */ l("div", { className: "latch-sides", role: "group", "aria-label": "Buy or sell", children: [
|
|
2193
|
+
/* @__PURE__ */ e("button", { type: "button", className: "latch-sides__btn", "data-latch-side": "buy", "aria-pressed": c === "buy", onClick: () => Re("buy"), children: "Buy" }),
|
|
2194
|
+
/* @__PURE__ */ e("button", { type: "button", className: "latch-sides__btn", "data-latch-side": "sell", "aria-pressed": c === "sell", onClick: () => Re("sell"), children: "Sell" })
|
|
2195
|
+
] }) : void 0, dt = w.length > 0 && G.data !== null && h !== null ? /* @__PURE__ */ e("div", { className: "latch-portions", role: "group", "aria-label": "Quick amounts", children: w.map((p) => {
|
|
2196
|
+
const D = Kt(p);
|
|
2205
2197
|
return /* @__PURE__ */ e("button", { type: "button", className: "latch-portion", "aria-label": `${D} of your ${h.symbol} balance`, onClick: () => Ne(p), children: D }, p);
|
|
2206
2198
|
}) }) : null;
|
|
2207
2199
|
return /* @__PURE__ */ l(
|
|
@@ -2217,9 +2209,9 @@ const Ia = pt(function(a, n) {
|
|
|
2217
2209
|
/* @__PURE__ */ l("div", { className: "latch-panel", "data-latch-side": "sell", children: [
|
|
2218
2210
|
/* @__PURE__ */ l("div", { className: "latch-panel__top", children: [
|
|
2219
2211
|
/* @__PURE__ */ e("span", { className: "latch-label", children: "You pay" }),
|
|
2220
|
-
|
|
2212
|
+
G.data !== null && h !== null ? /* @__PURE__ */ l("span", { className: "latch-panel__balance", children: [
|
|
2221
2213
|
"Balance ",
|
|
2222
|
-
q(
|
|
2214
|
+
q(G.data, h.decimals)
|
|
2223
2215
|
] }) : null
|
|
2224
2216
|
] }),
|
|
2225
2217
|
/* @__PURE__ */ l("div", { className: "latch-panel__main", children: [
|
|
@@ -2237,7 +2229,7 @@ const Ia = pt(function(a, n) {
|
|
|
2237
2229
|
onChange: (p) => z(p.target.value.replace(/,/g, "."))
|
|
2238
2230
|
}
|
|
2239
2231
|
),
|
|
2240
|
-
k ? /* @__PURE__ */ e(
|
|
2232
|
+
k ? /* @__PURE__ */ e(Ge, { label: "Sell", value: h }) : /* @__PURE__ */ e(Ke, { label: "Sell", value: h, tokens: v, exclude: o, listFailures: m.failures, listsLoading: m.status === "loading", onChange: (p) => y({ type: "select-in", token: p, side: c }) })
|
|
2241
2233
|
] }),
|
|
2242
2234
|
dt,
|
|
2243
2235
|
ee !== null ? /* @__PURE__ */ e("p", { className: "latch-panel__error", children: ee }) : null
|
|
@@ -2277,7 +2269,7 @@ const Ia = pt(function(a, n) {
|
|
|
2277
2269
|
] }),
|
|
2278
2270
|
/* @__PURE__ */ l("div", { className: "latch-panel__main", children: [
|
|
2279
2271
|
/* @__PURE__ */ e("output", { className: `latch-big-input latch-big-input--out${f.isRefreshing ? " is-refreshing" : ""}`, "aria-live": "polite", "aria-label": `Amount of ${o?.symbol ?? "the output token"} you receive`, children: ue === "" ? /* @__PURE__ */ e("span", { className: "latch-big-input__placeholder", children: "0" }) : ue }),
|
|
2280
|
-
k ? /* @__PURE__ */ e(
|
|
2272
|
+
k ? /* @__PURE__ */ e(Ge, { label: "Buy", value: o }) : /* @__PURE__ */ e(Ke, { label: "Buy", value: o, tokens: v, exclude: h, listFailures: m.failures, listsLoading: m.status === "loading", onChange: (p) => y({ type: "select-out", token: p, side: c }) })
|
|
2281
2273
|
] }),
|
|
2282
2274
|
f.isMock ? /* @__PURE__ */ e("p", { className: "latch-panel__note", children: "Simulated by the mock adapter" }) : null
|
|
2283
2275
|
] })
|
|
@@ -2347,7 +2339,7 @@ const Ia = pt(function(a, n) {
|
|
|
2347
2339
|
] }) : null,
|
|
2348
2340
|
Oe.length > 1 ? /* @__PURE__ */ l(B, { label: "Route", hint: "The pools this swap goes through, in order.", children: [
|
|
2349
2341
|
Oe.join(" → "),
|
|
2350
|
-
|
|
2342
|
+
K !== null ? ` · ${K.route.length} hop${K.route.length > 1 ? "s" : ""} · ${K.route.map((p) => p.poolType).join(", ")}` : ""
|
|
2351
2343
|
] }) : null,
|
|
2352
2344
|
f.updatedAt !== null ? /* @__PURE__ */ e(B, { label: "Quote", hint: "Quotes refresh on an interval; the chain recomputes the output at execution.", children: f.isRefreshing ? "refreshing…" : `read ${Math.max(0, Math.round((Date.now() - f.updatedAt) / 1e3))}s ago` }) : null
|
|
2353
2345
|
] }) : null
|
|
@@ -2401,4 +2393,4 @@ export {
|
|
|
2401
2393
|
de as l,
|
|
2402
2394
|
at as m
|
|
2403
2395
|
};
|
|
2404
|
-
//# sourceMappingURL=SwapWidget-
|
|
2396
|
+
//# sourceMappingURL=SwapWidget-CwkRtOfn.js.map
|