@logswap/sdk 0.5.43 → 0.5.45

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/indexer.js CHANGED
@@ -100,7 +100,7 @@ export async function indexerHealthy(url, signal) {
100
100
  */
101
101
  export async function discoverMarketsIndexed(url, signal) {
102
102
  const q = `{ allInitializes(first: 1000) { nodes {
103
- poolId base quote tickSpacing phiMin kappa alpha x0 blockNumber txHash
103
+ poolId base quote tickSpacing phi x0 blockNumber txHash
104
104
  } } }`;
105
105
  const d = await gql(url, q, undefined, signal);
106
106
  return d.allInitializes.nodes.map((n) => {
@@ -108,9 +108,7 @@ export async function discoverMarketsIndexed(url, signal) {
108
108
  base: n.base,
109
109
  quote: n.quote,
110
110
  tickSpacing: BigInt(n.tickSpacing),
111
- phiMin: BigInt(n.phiMin),
112
- kappa: BigInt(n.kappa),
113
- alpha: BigInt(n.alpha),
111
+ phi: BigInt(n.phi),
114
112
  };
115
113
  return {
116
114
  key,
@@ -142,7 +140,7 @@ export async function discoverMarketsBest(c, url, signal) {
142
140
  await c.public.readContract({
143
141
  address: c.addresses.cPoolManager,
144
142
  abi: cPoolManagerAbi,
145
- functionName: "phiEff",
143
+ functionName: "phiOf",
146
144
  args: [m.key],
147
145
  });
148
146
  return m;
package/dist/keys.d.ts CHANGED
@@ -20,18 +20,19 @@ export interface PoolKey {
20
20
  quote: Address;
21
21
  /** Log-tick spacing, WAD. The LP-boundary ladder — position floors and caps. */
22
22
  tickSpacing: bigint;
23
- /** Fee floor, WAD. `0n` selects `DEFAULT_FEE_MIN` (2 bp) at read time. */
24
- phiMin: bigint;
25
- /** Variance-fee coefficient, WAD. `0n` disables the dynamic fee. */
26
- kappa: bigint;
27
- /** EMA decay, WAD. `0n` selects `DEFAULT_ALPHA` (1/2) at read time. */
28
- alpha: bigint;
23
+ /**
24
+ * The swap fee, WAD, fixed for the life of the market: `FEE_MIN` (1 bp) ≤ φ ≤ `FEE_MAX` (25%),
25
+ * or `0n`, which selects `DEFAULT_FEE` (2 bp) at read time. Four fields since C version 4
26
+ * (decisions 042): `kappa` and `alpha` left with the variance kernel, and `phiMin` — a floor with
27
+ * nothing above it — became `phi`. Every pool id changed with the shape.
28
+ */
29
+ phi: bigint;
29
30
  }
30
31
  /**
31
32
  * `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
32
33
  *
33
- * Note the zero-vs-default caveat the Solidity type documents: `phiMin` and `alpha` of `0` resolve
34
- * to their defaults at READ time, so a key carrying `0n` and one carrying the resolved default are
34
+ * Note the zero-vs-default caveat the Solidity type documents: a `phi` of `0` resolves to
35
+ * `DEFAULT_FEE` at READ time, so a key carrying `0n` and one carrying the resolved default are
35
36
  * DIFFERENT markets with different ids, even though they behave identically. Always address a
36
37
  * market by the key it was initialized with.
37
38
  */
package/dist/keys.js CHANGED
@@ -18,17 +18,15 @@ const POOL_KEY_ABI = [
18
18
  { name: "base", type: "address" },
19
19
  { name: "quote", type: "address" },
20
20
  { name: "tickSpacing", type: "int256" },
21
- { name: "phiMin", type: "uint256" },
22
- { name: "kappa", type: "uint256" },
23
- { name: "alpha", type: "uint256" },
21
+ { name: "phi", type: "uint256" },
24
22
  ],
25
23
  },
26
24
  ];
27
25
  /**
28
26
  * `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
29
27
  *
30
- * Note the zero-vs-default caveat the Solidity type documents: `phiMin` and `alpha` of `0` resolve
31
- * to their defaults at READ time, so a key carrying `0n` and one carrying the resolved default are
28
+ * Note the zero-vs-default caveat the Solidity type documents: a `phi` of `0` resolves to
29
+ * `DEFAULT_FEE` at READ time, so a key carrying `0n` and one carrying the resolved default are
32
30
  * DIFFERENT markets with different ids, even though they behave identically. Always address a
33
31
  * market by the key it was initialized with.
34
32
  */
@@ -38,9 +36,7 @@ export function poolId(key) {
38
36
  base: key.base,
39
37
  quote: key.quote,
40
38
  tickSpacing: key.tickSpacing,
41
- phiMin: key.phiMin,
42
- kappa: key.kappa,
43
- alpha: key.alpha,
39
+ phi: key.phi,
44
40
  },
45
41
  ]));
46
42
  }
package/dist/pools.d.ts CHANGED
@@ -26,9 +26,8 @@ export interface PoolState {
26
26
  reserveQuote: bigint;
27
27
  /** Fee-per-unit-L accumulator: $\phi \cdot \mathrm{TV}(\log p)$. */
28
28
  F: bigint;
29
- /** Quadratic variation of log-price, $\Sigma = \int (dx)^2$. */
29
+ /** Quadratic variation of log-price, $\Sigma = \sum_{\text{swaps}} (\Delta x_{\text{swap}})^2$ — one term per swap (decisions 042). */
30
30
  bigSigma: bigint;
31
- sigma2Ema: bigint;
32
31
  currentK: bigint;
33
32
  protocolOwed: bigint;
34
33
  minBackstopL: bigint;
@@ -36,8 +35,12 @@ export interface PoolState {
36
35
  }
37
36
  /** Read a market's full state by key. */
38
37
  export declare function getPool(c: LogswapClient, key: PoolKey): Promise<PoolState>;
39
- /** The effective fee right now: $\max(\phi_{\min}, \kappa\sqrt{\sigma^2_{\text{ema}}})$, capped. */
40
- export declare function phiEff(c: LogswapClient, key: PoolKey): Promise<bigint>;
38
+ /**
39
+ * The market's fee: the key's `phi` with `0n` resolved to `DEFAULT_FEE`. Constant for the market's
40
+ * life (C version 4, decisions 042 — `phiEff` and the variance kernel before). Reverts for a key
41
+ * nobody initialized, which `discoverMarkets` relies on to drop a stale indexer's rows.
42
+ */
43
+ export declare function phiOf(c: LogswapClient, key: PoolKey): Promise<bigint>;
41
44
  /**
42
45
  * Price from the stored log-price. **Lossy** — `x` is exact and this is a float, so use it for
43
46
  * display and never for arithmetic you intend to send back on-chain.
package/dist/pools.js CHANGED
@@ -25,12 +25,16 @@ export async function getPool(c, key) {
25
25
  });
26
26
  return v;
27
27
  }
28
- /** The effective fee right now: $\max(\phi_{\min}, \kappa\sqrt{\sigma^2_{\text{ema}}})$, capped. */
29
- export async function phiEff(c, key) {
28
+ /**
29
+ * The market's fee: the key's `phi` with `0n` resolved to `DEFAULT_FEE`. Constant for the market's
30
+ * life (C version 4, decisions 042 — `phiEff` and the variance kernel before). Reverts for a key
31
+ * nobody initialized, which `discoverMarkets` relies on to drop a stale indexer's rows.
32
+ */
33
+ export async function phiOf(c, key) {
30
34
  return c.public.readContract({
31
35
  address: c.addresses.cPoolManager,
32
36
  abi: cPoolManagerAbi,
33
- functionName: "phiEff",
37
+ functionName: "phiOf",
34
38
  args: [key],
35
39
  });
36
40
  }
@@ -88,9 +92,7 @@ export async function discoverMarkets(c, opts = {}) {
88
92
  base: a.base,
89
93
  quote: a.quote,
90
94
  tickSpacing: a.tickSpacing,
91
- phiMin: a.phiMin,
92
- kappa: a.kappa,
93
- alpha: a.alpha,
95
+ phi: a.phi,
94
96
  };
95
97
  return {
96
98
  key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logswap/sdk",
3
- "version": "0.5.43",
3
+ "version": "0.5.45",
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,6 +1,9 @@
1
1
  /**
2
- * admin — the protocol's (feeCollector's) writes: the fee rates, the harvest-fee exemption, and
3
- * 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 cuts, the harvest-cut exemption,
3
+ * and the two-step collector handover, on both managers. Plain writes to the managers; no router.
4
+ * 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.
4
7
  */
5
8
 
6
9
  import type { Address, Hash, Hex } from "viem";
@@ -12,14 +15,17 @@ function wallet(c: LogswapClient) {
12
15
  return c.wallet;
13
16
  }
14
17
 
15
- export async function setProtocolFeeCut(c: LogswapClient, cutWad: bigint): Promise<Hash> {
16
- return wallet(c).writeContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "setProtocolFeeCut", args: [cutWad], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
18
+ /** The C manager's `setFeeParams(mintFeeProtocolCut)` — one cut. */
19
+ 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);
17
21
  }
18
- export async function setFeeParams(c: LogswapClient, mintFeeProtocolCutWad: bigint, harvestFeeWad: bigint): Promise<Hash> {
19
- return wallet(c).writeContract({ address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi, functionName: "setFeeParams", args: [mintFeeProtocolCutWad, harvestFeeWad], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
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);
20
25
  }
21
- export async function setHarvestFeeExempt(c: LogswapClient, poolId: Hex, exempt: boolean): Promise<Hash> {
22
- return wallet(c).writeContract({ address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi, functionName: "setHarvestFeeExempt", args: [poolId, exempt], chain: c.wallet!.chain, account: c.wallet!.account! } as never);
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);
23
29
  }
24
30
  export async function proposeCollector(c: LogswapClient, side: "C" | "F", next: Address): Promise<Hash> {
25
31
  const address = side === "C" ? c.addresses.cPoolManager : (c.addresses.fPoolManager as Address);
package/src/client.ts CHANGED
@@ -58,8 +58,13 @@ export function createLogswapClient(args: {
58
58
  * **3** since 2026-09-03 (contracts `d8406fb`): `burnById` and `update` take an `owner`, `update`
59
59
  * mints to `to`, `positions()` returns `aps` as uint128 — and a returned quote flow now carries the
60
60
  * swept fees (decisions 018), which is why `exit`'s settle-to-one-asset math changed with it.
61
+ *
62
+ * **4** since 2026-09-18 (decisions 042 + 040): `PoolKey` is `(base, quote, tickSpacing, phi)` —
63
+ * the variance kernel and its two key fields are gone, so every pool id changed; `phiEff` is
64
+ * `phiOf`; `getPool` lost `sigma2Ema`; `Initialize` lost two fields; the cut is
65
+ * `MINT_FEE_PROTOCOL_CUT` / `setFeeParams`.
61
66
  */
62
- export const EXPECTED_VERSION = 3n;
67
+ export const EXPECTED_VERSION = 4n;
63
68
  /**
64
69
  * The F manager's own tag (contracts 25a7bcf: 5 — the key's salt, pool names, the sponsor registry;
65
70
  * 4 was the income-only harvest cut).
@@ -91,7 +96,13 @@ export const EXPECTED_VERSION = 3n;
91
96
  // 12 (2026-09-17): one contract (decisions 039) — the sponsor facet is folded back into the
92
97
  // manager; `sponsor()` and the fallback are gone, every entry, error and event unchanged, so
93
98
  // `fPoolManagerAbi` is the manager's own ABI and no longer a union. Layout unchanged.
94
- export const EXPECTED_F_VERSION = 12n;
99
+ // 13 (2026-09-18): one vocabulary (decisions 040) — `HARVEST_FEE` is `HARVEST_PROTOCOL_CUT` (a
100
+ // cut of harvested income, not a fee on the harvest) and the exemption is `harvestCutExempt` /
101
+ // `setHarvestCutExempt`; `acceptAuthority` clears the operator, pending and accepted (a mandate
102
+ // is voided by the handover of the role that granted it); `setLegs` needs a generation to have
103
+ // lived (`gen > 0`); `initialize` refuses a codeless base and `mint` refuses `to = address(0)`
104
+ // on both managers. Layout unchanged.
105
+ export const EXPECTED_F_VERSION = 13n;
95
106
 
96
107
  export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSION): Promise<void> {
97
108
  const { cPoolManagerAbi } = await import("./generated.js");
package/src/fpool.ts CHANGED
@@ -930,8 +930,8 @@ export async function fPoolEmptyingHarvests(c: LogswapClient, poolId: Hex): Prom
930
930
  const [p, feePerL, fee, exempt, collector] = await Promise.all([
931
931
  rd<{ Q: bigint; L: bigint; kind: number; incomeTaken: bigint }>("getPool", [poolId]),
932
932
  rd<bigint>("feePerL", [poolId]),
933
- rd<bigint>("HARVEST_FEE"),
934
- rd<boolean>("harvestFeeExempt", [poolId]),
933
+ rd<bigint>("HARVEST_PROTOCOL_CUT"),
934
+ rd<boolean>("harvestCutExempt", [poolId]),
935
935
  rd<Address>("feeCollector"),
936
936
  ]);
937
937
  if (p.Q === 0n) return [];