@logswap/sdk 0.5.45 → 0.5.47

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.d.ts CHANGED
@@ -19,5 +19,5 @@ export * from "./onboard.js";
19
19
  export * from "./indexer.js";
20
20
  export * from "./tokencache.js";
21
21
  export * from "./fpool.js";
22
- export { cPoolManagerAbi, fPoolManagerAbi, logswapLensAbi, logswapRouterAbi } from "./generated.js";
22
+ export { cPoolManagerAbi, fPoolManagerAbi, logswapLensAbi, logswapRouterAbi, padHookAbi, polHookAbi, privateHookAbi, publicHookAbi } from "./generated.js";
23
23
  export * from "./admin.js";
package/dist/index.js CHANGED
@@ -19,5 +19,5 @@ export * from "./onboard.js";
19
19
  export * from "./indexer.js";
20
20
  export * from "./tokencache.js";
21
21
  export * from "./fpool.js";
22
- export { cPoolManagerAbi, fPoolManagerAbi, logswapLensAbi, logswapRouterAbi } from "./generated.js";
22
+ export { cPoolManagerAbi, fPoolManagerAbi, logswapLensAbi, logswapRouterAbi, padHookAbi, polHookAbi, privateHookAbi, publicHookAbi } from "./generated.js";
23
23
  export * from "./admin.js";
@@ -72,6 +72,8 @@ export interface ZapArgs extends WriteOptions {
72
72
  /** Fund entirely from base (true) or entirely from quote (false). */
73
73
  fundWithBase: boolean;
74
74
  amountIn: bigint;
75
+ /** The least the swap leg may return (contracts 7c82eed, decisions 043): the zap's own slippage bound, as `swapExactIn`'s. 0 = unbounded. */
76
+ minSwapOut?: bigint;
75
77
  targetFloor: bigint;
76
78
  cap?: bigint;
77
79
  L: bigint;
package/dist/liquidity.js CHANGED
@@ -94,6 +94,7 @@ export async function zapIn(c, a) {
94
94
  a.key,
95
95
  a.fundWithBase,
96
96
  a.amountIn,
97
+ a.minSwapOut ?? 0n,
97
98
  a.targetFloor,
98
99
  a.cap ?? NO_CAP,
99
100
  a.L,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logswap/sdk",
3
- "version": "0.5.45",
3
+ "version": "0.5.47",
4
4
  "description": "TypeScript SDK for Logswap, the liquidity primitive introducing the logarithmic invariant — typed wrappers over the CPoolManager / FPoolManager / Router / Lens surface.",
5
5
  "license": "GPL-2.0-or-later",
6
6
  "type": "module",
package/src/admin.ts CHANGED
@@ -1,39 +1,89 @@
1
1
  /**
2
- * admin — the protocol's (feeCollector's) writes: the protocol's cuts, the harvest-cut exemption,
3
- * and the two-step collector handover, on both managers. Plain writes to the managers; no router.
2
+ * admin — the protocol's (feeCollector's) writes: the protocol's cut of the mint fee on both
3
+ * managers, the hooks a pool of each kind may be born with, the hooks' own numbers, and the
4
+ * two-step collector handover. Plain writes to the managers and the hooks; no router.
5
+ *
4
6
  * One vocabulary (decisions 040): both managers call the protocol's cut of the mint fee
5
- * `MINT_FEE_PROTOCOL_CUT` and set it through `setFeeParams` — one cut on C (since version 4,
6
- * decisions 042; `setProtocolFeeCut` / `PROTOCOL_FEE_CUT` before), two on F.
7
+ * `MINT_FEE_PROTOCOL_CUT` and set it through `setFeeParams(uint256)` — one cut each since C
8
+ * version 4 / F version 14. The harvest's cut is the hook's answer at every harvest (decisions
9
+ * 044), set on the hook (`setHarvestCut`) and capped by the manager (`HARVEST_CUT_MAX`); the
10
+ * release's protocol share likewise (`POT_CUT_MAX`).
7
11
  */
8
12
 
9
- import type { Address, Hash, Hex } from "viem";
13
+ import type { Address, Hash } from "viem";
10
14
  import type { LogswapClient } from "./client.js";
11
- import { cPoolManagerAbi, fPoolManagerAbi } from "./generated.js";
15
+ import { cPoolManagerAbi, fPoolManagerAbi, padHookAbi, polHookAbi, publicHookAbi } from "./generated.js";
16
+ import { F_KIND, fHookBaseAbi, type FPoolKind } from "./fpool.js";
12
17
 
13
18
  function wallet(c: LogswapClient) {
14
19
  if (!c.wallet) throw new Error("a wallet client is required");
15
20
  return c.wallet;
16
21
  }
17
22
 
23
+ function write(c: LogswapClient, address: Address, abi: readonly unknown[], functionName: string, args: readonly unknown[]): Promise<Hash> {
24
+ return wallet(c).writeContract({ address, abi, functionName, args, chain: c.wallet!.chain, account: c.wallet!.account! } as never);
25
+ }
26
+
18
27
  /** The C manager's `setFeeParams(mintFeeProtocolCut)` — one cut. */
19
28
  export async function setFeeParamsC(c: LogswapClient, mintFeeProtocolCutWad: bigint): Promise<Hash> {
20
- return wallet(c).writeContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "setFeeParams", args: [mintFeeProtocolCutWad], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
29
+ return write(c, c.addresses.cPoolManager, cPoolManagerAbi, "setFeeParams", [mintFeeProtocolCutWad]);
30
+ }
31
+ /** The F manager's `setFeeParams(mintFeeProtocolCut)` — one cut, the C manager's shape (F version 14). */
32
+ export async function setFeeParams(c: LogswapClient, mintFeeProtocolCutWad: bigint): Promise<Hash> {
33
+ return write(c, c.addresses.fPoolManager as Address, fPoolManagerAbi, "setFeeParams", [mintFeeProtocolCutWad]);
34
+ }
35
+
36
+ /**
37
+ * Approve a hook for pools of `kind` to be born with, or withdraw the approval (decisions 041,
38
+ * 044). Read at `initialize` and never again: a live pool keeps its hook.
39
+ */
40
+ export async function setHookApproved(c: LogswapClient, kind: FPoolKind, hook: Address, approved: boolean): Promise<Hash> {
41
+ return write(c, c.addresses.fPoolManager as Address, fPoolManagerAbi, "setHookApproved", [F_KIND[kind], hook, approved]);
21
42
  }
22
- /** The F manager's `setFeeParams(mintFeeProtocolCut, harvestProtocolCut)` — two cuts. */
23
- export async function setFeeParams(c: LogswapClient, mintFeeProtocolCutWad: bigint, harvestProtocolCutWad: bigint): Promise<Hash> {
24
- return wallet(c).writeContract({ address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi, functionName: "setFeeParams", args: [mintFeeProtocolCutWad, harvestProtocolCutWad], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
43
+
44
+ /** Whether `hook` is approved for pools of `kind`. */
45
+ export async function hookApproved(c: LogswapClient, kind: FPoolKind, hook: Address): Promise<boolean> {
46
+ return c.public.readContract({ address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi, functionName: "hookApproved", args: [F_KIND[kind], hook] } as never) as Promise<boolean>;
25
47
  }
26
- /** Waive the protocol's cut of harvested income for one pool (`HARVEST_PROTOCOL_CUT`; F version 13 — `setHarvestFeeExempt` before). */
27
- export async function setHarvestCutExempt(c: LogswapClient, poolId: Hex, exempt: boolean): Promise<Hash> {
28
- return wallet(c).writeContract({ address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi, functionName: "setHarvestCutExempt", args: [poolId, exempt], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
48
+
49
+ // ─── the hooks' numbers (the collector's; each bounded where it reaches the manager) ─────
50
+
51
+ /** The protocol's rate on the income part of every harvest under `hook`, WAD ≤ `HARVEST_CUT_MAX`. */
52
+ export async function setHarvestCut(c: LogswapClient, hook: Address, rateWad: bigint): Promise<Hash> {
53
+ return write(c, hook, fHookBaseAbi, "setHarvestCut", [rateWad]);
29
54
  }
55
+
56
+ /** `PadHook.setSchedule`: `T(0)`, the rung's growth, the creator's and the protocol's shares of the pot (≤ `POT_CUT_MAX`), the burn per rung (≤ `BURN_MAX`). */
57
+ export async function padSetSchedule(
58
+ c: LogswapClient,
59
+ hook: Address,
60
+ s: { thresholdBase: bigint; thresholdGrowth: bigint; creatorShare: bigint; protocolShare: bigint; burnPerRung: bigint },
61
+ ): Promise<Hash> {
62
+ return write(c, hook, padHookAbi, "setSchedule", [s.thresholdBase, s.thresholdGrowth, s.creatorShare, s.protocolShare, s.burnPerRung]);
63
+ }
64
+
65
+ /** `PolHook.setPolicy`: what every harvest leaves in the bid and what a relaunch's seed must bring, WAD fractions of L. */
66
+ export async function polSetPolicy(c: LogswapClient, hook: Address, s: { keepQuote: bigint; minQuoteAtSeed: bigint }): Promise<Hash> {
67
+ return write(c, hook, polHookAbi, "setPolicy", [s.keepQuote, s.minQuoteAtSeed]);
68
+ }
69
+
70
+ /** `PublicHook.setListed`: an asset a curated seed may hold. */
71
+ export async function publicSetListed(c: LogswapClient, hook: Address, token: Address, listed: boolean): Promise<Hash> {
72
+ return write(c, hook, publicHookAbi, "setListed", [token, listed]);
73
+ }
74
+
75
+ /** `PublicHook.setCurated`: whether every public seed is checked against the list. */
76
+ export async function publicSetCurated(c: LogswapClient, hook: Address, curated: boolean): Promise<Hash> {
77
+ return write(c, hook, publicHookAbi, "setCurated", [curated]);
78
+ }
79
+
30
80
  export async function proposeCollector(c: LogswapClient, side: "C" | "F", next: Address): Promise<Hash> {
31
81
  const address = side === "C" ? c.addresses.cPoolManager : (c.addresses.fPoolManager as Address);
32
82
  const abi = side === "C" ? cPoolManagerAbi : fPoolManagerAbi;
33
- return wallet(c).writeContract({ address, abi, functionName: "proposeCollector", args: [next], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
83
+ return write(c, address, abi, "proposeCollector", [next]);
34
84
  }
35
85
  export async function acceptCollector(c: LogswapClient, side: "C" | "F"): Promise<Hash> {
36
86
  const address = side === "C" ? c.addresses.cPoolManager : (c.addresses.fPoolManager as Address);
37
87
  const abi = side === "C" ? cPoolManagerAbi : fPoolManagerAbi;
38
- return wallet(c).writeContract({ address, abi, functionName: "acceptCollector", args: [], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
88
+ return write(c, address, abi, "acceptCollector", []);
39
89
  }
package/src/client.ts CHANGED
@@ -23,6 +23,14 @@ export interface LogswapAddresses {
23
23
  * deployment predating it will not carry the address; every F-pool call needs it.
24
24
  */
25
25
  fPoolManager?: Address;
26
+ /**
27
+ * The protocol's four F hooks, one per kind (decisions 044): every F pool names one in its key,
28
+ * and the pool's roles, gates and terms live on it. A deployment predating them carries none.
29
+ */
30
+ publicHook?: Address;
31
+ privateHook?: Address;
32
+ polHook?: Address;
33
+ padHook?: Address;
26
34
  /** Optional — the router falls back to plain approvals when absent. */
27
35
  permit2?: Address;
28
36
  }
@@ -102,7 +110,16 @@ export const EXPECTED_VERSION = 4n;
102
110
  // is voided by the handover of the role that granted it); `setLegs` needs a generation to have
103
111
  // lived (`gen > 0`); `initialize` refuses a codeless base and `mint` refuses `to = address(0)`
104
112
  // on both managers. Layout unchanged.
105
- export const EXPECTED_F_VERSION = 13n;
113
+ // 14 (2026-09-20): the hook (decisions 041) — `FPoolKey.hook`, every pool id moves; `dissolve` is
114
+ // `retire`, `regenerate` releases the dead shares' pot, `harvestable`/`unharvested` are the
115
+ // readouts; `feePerL`, `edgePerL`, `HARVEST_PROTOCOL_CUT`, `harvestCutExempt` are gone.
116
+ // 15 (2026-09-20): the hook answers every question (decisions 044) — `FPoolKey.authority` is
117
+ // `creator` (every pool id moves again); the roles, gates and list are the pool's HOOK's
118
+ // (`FHookBase` / `PrivateHook`), not the manager's: `getPool` has `hook` and `asks` and no
119
+ // role; `proposeAuthority`, `appointOperator`, `setGates`, `setAllowed` are hook writes;
120
+ // `hookApproved(kind, hook)` / `setHookApproved(kind, hook, ok)`; `Regenerated` names the payee;
121
+ // `HARVEST_CUT_MAX` / `POT_CUT_MAX` cap what a hook may route to the protocol.
122
+ export const EXPECTED_F_VERSION = 15n;
106
123
 
107
124
  export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSION): Promise<void> {
108
125
  const { cPoolManagerAbi } = await import("./generated.js");