@logswap/sdk 0.5.99 → 0.5.100

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 CHANGED
@@ -45,6 +45,44 @@ Both are computed **offline** — no RPC, no deployment needed to address a mark
45
45
  floor price (was `theta`), `refLogFloor` θ₀ — the reference floor income counts from (was
46
46
  `theta0`), `cap` (d in 1e-6 log units, 0 uncapped), and per leg `virtualReserves` and `kappa`.
47
47
 
48
+ ## C 17 / F 42 (decision 107): every event names its actor; `mint` takes a payer; the routers emit no event
49
+
50
+ Contracts `logswap/logswap-contract#142`. No pool id and no position id moved; the manager bindings regenerate.
51
+
52
+ - **`mint` takes a payer.** C `mint(poolId, payer, to, floor, cap, L)`, F `mint(poolId, payer, to, L, maxQuoteIn)`. `payer` is the
53
+ account the caller declares as funding the mint; only the event reads it. `fPoolMint` passes its `account` (a direct call: the
54
+ sender funds). The routed C mints (`mint`, `zapIn`, `execute`) are unchanged for a caller: the router declares its user.
55
+ - **F `claim` takes an owner.** `claim(poolId, gen, owner, to)`: the owner or its ERC-6909 operator. `fPoolClaim` takes an
56
+ optional `owner` (the `account` by default), as `fPoolBurn` and `fPoolRedeem` do.
57
+ - **`Settle.to`.** `RouterC`'s entries and its `Settle` struct name the receiving account `to` (`recipient` before). The SDK's
58
+ `Settle`, `settlement({ … to })` and `execute({ settle: { … to? } })` follow: **a caller that built a `Settle` with `recipient`
59
+ must rename the field**. `settleInKind` / `settleOnly` take it positionally and do not move; `WriteOptions.recipient` (the SDK's
60
+ own option on the named writers) is unchanged.
61
+ - **The actor, per event.** No `RouterCall`: a router emits no event, and nothing is attributed through a per-transaction lookup.
62
+ Read the user off the event itself:
63
+
64
+ | Action | Event | Actor |
65
+ |---|---|---|
66
+ | swap (both) | `Swap` | `taker` when `sender` is the deployment's router, else `sender` |
67
+ | mint (both) | `PositionMinted`, `SharesMinted` | `payer` when `sender` is the deployment's router, else `sender`; `to` holds the shares |
68
+ | burn, update, claim (C) | `PositionBurned`, `PositionUpdated`, `FeesClaimed` | `owner` |
69
+ | burn, redeem, claim (F) | `SharesBurned`, `SharesRedeemed`, `DividendClaimed` | `owner` |
70
+ | birth | `PoolCreated` | `creator` (the third topic on both managers) |
71
+ | deploy, harvest, close (F) | `LiquidityDeployed`, `IncomeHarvested`, `GenerationFrozen` | `operator` (a topic) |
72
+ | `collectProtocolFees` (C) | `ProtocolFeesCollected` | `sender` (a topic) |
73
+
74
+ - **Event shapes** (`getEventLogs` decodes by field name, so a consumer keyed on the old names follows):
75
+ `PositionMinted(poolId, to, id, sender, payer, shares, dBase, dQuote)`;
76
+ `SharesMinted(poolId, to, gen, sender, payer, L, shares, dQuote, poolL, supply)` and `SharesBurned` index `gen`;
77
+ F `PoolCreated(poolId, quote, creator, policy, bases, swapFeeIdx, salt)` (`policy` is data now, so it no longer filters as a topic);
78
+ `ProtocolFeesCollected(poolId, sender, to, amount)`; `ClassRegistered(poolId, id, floor, cap, capped)` (`poolId` first).
79
+ Renamed to `owner`: `PositionBurned.from`, `SharesBurned.from`, and `holder` on `FeesClaimed`, `PositionUpdated`, `DividendClaimed`.
80
+ `discoverFPools` rows carry `creator`.
81
+ - **Errors.** `RouterF.BadToken` is `WrongToken`, the name `RouterC` already uses.
82
+ - **Indexer.** The topic hashes moved (a pure rename's stands, and so does `SharesBurned`'s, whose `gen` is now a topic), and the columns follow the field names (`owner`, `sender`, `payer`,
83
+ `creator`, `operator`): the rindexer tables must be rebuilt from this ABI (logswap-be follows). Until then a read falls back to the node.
84
+ - **Versions.** `EXPECTED_VERSION` is 17 (C) and `EXPECTED_F_VERSION` is 42.
85
+
48
86
  ## F 41 (`policy.md`): one policy contract, the operator runs the pool, the fee is an index
49
87
 
50
88
  Follows contracts `f3d1420` (logswap-contract #120, squash-merged to main on 2026-11-07). A breaking release: every F pool id moved, and the F policy surface is replaced.
@@ -220,37 +258,14 @@ answers only partly.
220
258
  shared tables with `contract: indexedContractOf(kind, event)` (or `kind` on `getEventsLogs`).
221
259
  - `tokensCreated` lists the factory's tokens (`addresses.tokenFactory`): the token list's provenance.
222
260
 
223
- ## Indexer views (indexing phase 2)
224
-
225
- The indexer also serves derived views (logswap-be `devnet/VIEWS.md`), joining its event tables with
226
- the snapshotter's state. `views.ts` reads each as typed rows: amounts as `bigint`, prices, APYs and
227
- progress as `number`, times as unix seconds. Every reader takes the GraphQL endpoint and a
228
- `{ condition, filter, orderBy, first, signal }` query, and pages by offset.
229
-
230
- | Reader | View | What a row is |
231
- | --- | --- | --- |
232
- | `poolDirectory` | `allPoolDirectories` | a pool of either manager, its kind and birth |
233
- | `eventUsers` | `allEventUsers` | a manager event and who did it (the router's caller when routed) |
234
- | `poolHolders` | `allPoolHolders` | a current ERC-6909 balance, with C's backstop and F's dead shares flagged |
235
- | `walletPositions` | `allWalletPositions` | a wallet's holding; F valued at the latest share value |
236
- | `walletPoolFlows` | `allWalletPoolFlows` | a wallet's in/out, fees and dividends per pool |
237
- | `swapFlows` | `allSwapFlows` | a swap's volume and fee in quote |
238
- | `priceTicks` | `allPriceTicks` | a price point per (pool, base) |
239
- | `candles(url, "minute" \| "hour" \| "day")` | `allCandle…s` | OHLC with volume and fees |
240
- | `poolTvlHours` | `allPoolTvlHours` | the hour's last snapshot: TVL, liquidity |
241
- | `poolSummaries` | `allPoolSummaries` | 24 h / 7 d volume, fees, APY; latest TVL |
242
- | `generationSteps` | `allGenerationSteps` | a generation step and the split of the income it released |
243
- | `padStatuses` | `allPadStatuses` | each pad and POL now, with the next threshold and progress |
244
- | `protocolRevenueDays` | `allProtocolRevenueDays` | protocol revenue per day and source |
245
-
246
- Given an `indexer`, three functions now take their figure from a view and keep their previous path
247
- as the fallback, with the same answer on the same data:
248
- - `holdingsOf`: the owner's held class ids from `pool_holder`, then the lens as before;
249
- - `fPoolShareHolders`: the holders from `pool_holder`;
250
- - `swapFees`: the window from `swap_flow`.
251
-
252
- What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `cLegsOf`,
253
- `cHeldByIds`, `dividendOf`). They accrue without events, so no view holds them.
261
+ ## Indexer views
262
+
263
+ The SDK reads the indexer's event tables (`getEventLogs`, `indexer.ts`) and nothing above them. The derived views
264
+ (logswap-backend `devnet/VIEWS.md`: every F pool's replayed state, swap flows, candles, holders, positions, rules,
265
+ revenue) are read by the app's `@logswap/base` (`packages/base/src/indexer.ts` in logswap-app), which follows their
266
+ schema; the readers that lived here (`views.ts`) asked columns the indexer no longer has and are gone.
267
+
268
+ What stays a live read: every unclaimed fee or dividend (the lens: `dividendOf`). It accrues without events.
254
269
 
255
270
  ## The F pool's life: four calls (F 41, `policy.md` §9–10)
256
271
 
package/dist/actions.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * `execute(actions, settle)` runs a list of actions — mint, burn, update, claim, swap, path, in any
5
5
  * order, across any C markets — under ONE manager lock. Each action accrues deltas on the router
6
6
  * and settles nothing; the batch settles once per token in `settle.tokens`, pulling at most
7
- * `maxIn[i]` from the caller and taking at least `minOut[i]` to the recipient. A touched token
7
+ * `maxIn[i]` from the caller and taking at least `minOut[i]` to `settle.to`. A touched token
8
8
  * left off the list fails the manager's own close (`TokensNotSettled`), so the list is also the
9
9
  * caller's statement of which tokens may move.
10
10
  *
@@ -44,8 +44,8 @@ export interface Settle {
44
44
  tokens: readonly Address[];
45
45
  maxIn: readonly bigint[];
46
46
  minOut: readonly bigint[];
47
- /** Receives whatever is taken, and the shares the actions mint. */
48
- recipient: Address;
47
+ /** Receives whatever is taken, and the shares the actions mint (`Settle.to`; `recipient` before C 17). */
48
+ to: Address;
49
49
  }
50
50
  /** Mint exposure `L` at `targetFloor` (off-grid blends the two adjacent rungs), `cap` optional. */
51
51
  export declare function mintAction(a: {
@@ -99,7 +99,7 @@ export declare function settlement(a: {
99
99
  tokens: readonly Address[];
100
100
  maxIn?: readonly bigint[];
101
101
  minOut?: readonly bigint[];
102
- recipient: Address;
102
+ to: Address;
103
103
  }): Settle;
104
104
  export interface PairBounds {
105
105
  maxBaseIn?: bigint;
@@ -108,19 +108,19 @@ export interface PairBounds {
108
108
  minQuoteOut?: bigint;
109
109
  }
110
110
  /** Settle both of a market's tokens, in kind. */
111
- export declare function settleInKind(key: PoolKey, recipient: Address, b?: PairBounds): Settle;
111
+ export declare function settleInKind(key: PoolKey, to: Address, b?: PairBounds): Settle;
112
112
  /**
113
113
  * Settle in ONE of a market's tokens: the other is bound to zero both ways, so the batch must have
114
114
  * netted it — which is what a trailing `OPEN_DELTA` swap does.
115
115
  */
116
- export declare function settleOnly(key: PoolKey, recipient: Address, side: "base" | "quote", b?: {
116
+ export declare function settleOnly(key: PoolKey, to: Address, side: "base" | "quote", b?: {
117
117
  maxIn?: bigint;
118
118
  minOut?: bigint;
119
119
  }): Settle;
120
120
  export interface ExecuteArgs extends WriteOptions {
121
121
  actions: readonly Action[];
122
- settle: Omit<Settle, "recipient"> & {
123
- recipient?: Address;
122
+ settle: Omit<Settle, "to"> & {
123
+ to?: Address;
124
124
  };
125
125
  /** Tokens the batch may pull, for the Permit2 signatures. Defaults to every token with `maxIn > 0`. */
126
126
  pullTokens?: readonly Address[];
package/dist/actions.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * `execute(actions, settle)` runs a list of actions — mint, burn, update, claim, swap, path, in any
5
5
  * order, across any C markets — under ONE manager lock. Each action accrues deltas on the router
6
6
  * and settles nothing; the batch settles once per token in `settle.tokens`, pulling at most
7
- * `maxIn[i]` from the caller and taking at least `minOut[i]` to the recipient. A touched token
7
+ * `maxIn[i]` from the caller and taking at least `minOut[i]` to `settle.to`. A touched token
8
8
  * left off the list fails the manager's own close (`TokensNotSettled`), so the list is also the
9
9
  * caller's statement of which tokens may move.
10
10
  *
@@ -98,39 +98,39 @@ export function settlement(a) {
98
98
  const minOut = a.minOut ?? a.tokens.map(() => 0n);
99
99
  if (maxIn.length !== n || minOut.length !== n)
100
100
  throw new Error("logswap: settlement bounds length mismatch");
101
- return { tokens: a.tokens, maxIn, minOut, recipient: a.recipient };
101
+ return { tokens: a.tokens, maxIn, minOut, to: a.to };
102
102
  }
103
103
  /** Settle both of a market's tokens, in kind. */
104
- export function settleInKind(key, recipient, b = {}) {
104
+ export function settleInKind(key, to, b = {}) {
105
105
  return settlement({
106
106
  tokens: [key.base, key.quote],
107
107
  maxIn: [b.maxBaseIn ?? UNBOUNDED, b.maxQuoteIn ?? UNBOUNDED],
108
108
  minOut: [b.minBaseOut ?? 0n, b.minQuoteOut ?? 0n],
109
- recipient,
109
+ to,
110
110
  });
111
111
  }
112
112
  /**
113
113
  * Settle in ONE of a market's tokens: the other is bound to zero both ways, so the batch must have
114
114
  * netted it — which is what a trailing `OPEN_DELTA` swap does.
115
115
  */
116
- export function settleOnly(key, recipient, side, b = {}) {
116
+ export function settleOnly(key, to, side, b = {}) {
117
117
  const base = side === "base";
118
118
  return settlement({
119
119
  tokens: [key.base, key.quote],
120
120
  maxIn: [base ? (b.maxIn ?? UNBOUNDED) : 0n, base ? 0n : (b.maxIn ?? UNBOUNDED)],
121
121
  minOut: [base ? (b.minOut ?? 0n) : 0n, base ? 0n : (b.minOut ?? 0n)],
122
- recipient,
122
+ to,
123
123
  });
124
124
  }
125
125
  /** Run a batch: one lock, one settlement per token, one transaction (Permit2 signatures ride inside). */
126
126
  export async function execute(c, a) {
127
- const settle = { ...a.settle, recipient: a.settle.recipient ?? resolveRecipient(c, a) };
127
+ const settle = { ...a.settle, to: a.settle.to ?? resolveRecipient(c, a) };
128
128
  const pull = a.pullTokens ?? settle.tokens.filter((_, i) => settle.maxIn[i] > 0n);
129
129
  return sendRouterWriteWithPermits(c, { side: "C", abi: routerCAbi, functionName: "execute", args: [a.actions, settle, resolveDeadline(a)] }, [...pull]);
130
130
  }
131
131
  /** Simulate a batch: the per-action returns and the signed flows (+ = paid in), without sending. */
132
132
  export async function simulateExecute(c, a) {
133
- const settle = { ...a.settle, recipient: a.settle.recipient ?? a.account ?? resolveRecipient(c, a) };
133
+ const settle = { ...a.settle, to: a.settle.to ?? a.account ?? resolveRecipient(c, a) };
134
134
  const [results, flows] = await simulateRouterWrite(c, {
135
135
  side: "C",
136
136
  abi: routerCAbi,
package/dist/client.d.ts CHANGED
@@ -140,7 +140,7 @@ export declare function clientChainId(c: LogswapClient): Promise<number>;
140
140
  * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
141
141
  * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
142
142
  */
143
- export declare const EXPECTED_VERSION = 16n;
143
+ export declare const EXPECTED_VERSION = 17n;
144
144
  /**
145
145
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
146
146
  * 4 was the income-only harvest cut).
@@ -152,7 +152,7 @@ export declare const EXPECTED_VERSION = 16n;
152
152
  * passes it; when one lands, raise this constant in the same change, which is the discipline
153
153
  * `EXPECTED_VERSION` enforces mechanically and this one asks for.
154
154
  */
155
- export declare const EXPECTED_F_VERSION = 41n;
155
+ export declare const EXPECTED_F_VERSION = 42n;
156
156
  export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
157
157
  /**
158
158
  * The versions say the managers are the right code; this says the rest of the addresses belong
package/dist/client.js CHANGED
@@ -164,7 +164,11 @@ function guardChain(wallet, pub) {
164
164
  // `PermissionsSet` are `setGates(poolId, gates, operator)` / `GatesSet`; the birth answer is `(flags, tax, operator)`; the policy's
165
165
  // numbers (tiers, quotes, spacings, tax) are constructor immutables; the swap and mint gates are one bit each (`GATE_SWAP`,
166
166
  // `GATE_MINT`) and the cached operator passes with no policy call. No pool id moved.
167
- export const EXPECTED_VERSION = 16n;
167
+ // 17 (decision 107): every event names its actor and the routers emit none (`RouterCall` is gone). `mint(poolId, payer, to, floor, cap, L)`;
168
+ // `PositionMinted(poolId, to, id, sender, payer, shares, dBase, dQuote)`; `ProtocolFeesCollected(poolId, sender, to, amount)`;
169
+ // `ClassRegistered(poolId, id, floor, cap, capped)` (poolId first); the account acted on is `owner` on `PositionBurned` (was `from`),
170
+ // `PositionUpdated` and `FeesClaimed` (was `holder`); `RouterC`'s entries and `Settle` name the receiver `to` (was `recipient`). No pool id moved.
171
+ export const EXPECTED_VERSION = 17n;
168
172
  /**
169
173
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
170
174
  * 4 was the income-only harvest cut).
@@ -283,7 +287,12 @@ export const EXPECTED_VERSION = 16n;
283
287
  // `IncomeHarvested(poolId, to, gen, income, capital, tax, toOperator, Q)`; `GenerationFrozen` from `close` alone; `IncomeReleased` and
284
288
  // `PolicyMigrated` are gone. The policy's name is an event (`NameSet`), its lists are per policy (`setRights`, `RightsSet`), its
285
289
  // modes per pool (`setSwapMode` / `setMintMode`, each Open < Listed < Operator with `mintMode ≥ swapMode`).
286
- export const EXPECTED_F_VERSION = 41n;
290
+ // 42 (decision 107): every event names its actor and the routers emit none (`RouterCall` is gone). `mint(poolId, payer, to, L, maxQuoteIn)`;
291
+ // `claim(poolId, gen, owner, to)` (the owner or its ERC-6909 operator); `SharesMinted(poolId, to, gen, sender, payer, L, shares, dQuote,
292
+ // poolL, supply)`; `SharesBurned` indexes `gen` and names `owner` (was `from`), `DividendClaimed` names `owner` (was `holder`);
293
+ // `PoolCreated(poolId, quote, creator, policy, bases, swapFeeIdx, salt)` (`creator` a topic, `policy` data); `LiquidityDeployed`,
294
+ // `IncomeHarvested` and `GenerationFrozen` carry `operator` as a topic; `RouterF.BadToken` is `WrongToken`. No pool id moved.
295
+ export const EXPECTED_F_VERSION = 42n;
287
296
  export async function assertVersion(c, expected = EXPECTED_VERSION) {
288
297
  const { managerCAbi, managerFAbi } = await import("./generated.js");
289
298
  const withC = hasC(c);
package/dist/fees.js CHANGED
@@ -13,23 +13,6 @@
13
13
  import { managerC } from "./client.js";
14
14
  import { managerCAbi } from "./generated.js";
15
15
  import { getEventLogs } from "./history.js";
16
- import { swapFlows } from "./views.js";
17
- /** A C market's swap fees over [fromBlock, toBlock] from the indexer's swap_flow view; null when the indexer cannot answer. */
18
- async function windowFromView(c, indexer, poolId, fromBlock, toBlock) {
19
- try {
20
- const rows = await swapFlows(indexer, {
21
- condition: { side: "C", poolId: poolId.toLowerCase(), manager: managerC(c).toLowerCase() },
22
- filter: { blockNumber: { greaterThanOrEqualTo: fromBlock.toString(), lessThanOrEqualTo: toBlock.toString() } },
23
- });
24
- let fees = 0n;
25
- for (const r of rows)
26
- fees += r.feeQuote;
27
- return { fees, swaps: rows.length };
28
- }
29
- catch {
30
- return null; // the view is a cache: the Swap rows answer the same
31
- }
32
- }
33
16
  const WAD = 10n ** 18n;
34
17
  const YEAR_SECONDS = 31_536_000;
35
18
  /**
@@ -106,16 +89,11 @@ export async function swapFees(c, m, opts = {}) {
106
89
  const ev = managerCAbi.find((x) => x.type === "event" && x.name === "Swap");
107
90
  if (!ev)
108
91
  throw new Error("logswap: Swap event missing from the generated ABI");
109
- // the event carries the fee the swap charged (decisions 050), exactly — no re-derivation from φ;
110
- // the indexer's swap_flow view carries the same figure per swap (`feeQuote`, C)
92
+ // the event carries the fee the swap charged (decisions 050), exactly — no re-derivation from φ
111
93
  let fees = 0n;
112
94
  let swaps = 0;
113
95
  const indexer = opts.indexer ?? c.indexerUrl;
114
- const viewed = fromBlock > toBlock || !indexer ? null : await windowFromView(c, indexer, m.poolId, fromBlock, toBlock);
115
- if (viewed) {
116
- ({ fees, swaps } = viewed);
117
- }
118
- else if (fromBlock <= toBlock) {
96
+ if (fromBlock <= toBlock) {
119
97
  const { logs } = await getEventLogs(c, { indexer, address: managerC(c), event: ev, args: { poolId: m.poolId }, fromBlock, toBlock });
120
98
  for (const l of logs)
121
99
  fees += l.args.fee;
package/dist/fpool.d.ts CHANGED
@@ -420,13 +420,15 @@ export declare function fPoolHarvest(c: LogswapClient, a: {
420
420
  account: Address;
421
421
  }): Promise<`0x${string}`>;
422
422
  /**
423
- * Pull one's settled dividend on a generation's shares without moving them;
423
+ * Pull an owner's settled dividend on a generation's shares without moving them;
424
424
  * anyone with shares. `gen` defaults to the live generation; a retired generation's harvests
425
- * stay claimable under its own id.
425
+ * stay claimable under its own id. By owner (F 42), as {@link fPoolBurn} and {@link fPoolRedeem}: the account claims its
426
+ * own, and an ERC-6909 operator may pass another `owner`. Paid to `to` (the account by default).
426
427
  */
427
428
  export declare function fPoolClaim(c: LogswapClient, a: {
428
429
  poolId: Hex;
429
430
  gen?: bigint | number;
431
+ owner?: Address;
430
432
  to?: Address;
431
433
  account: Address;
432
434
  }): Promise<`0x${string}`>;
@@ -1084,6 +1086,8 @@ export interface DiscoveredFPool {
1084
1086
  policy: Address;
1085
1087
  /** The key's salt: zero under an open policy. */
1086
1088
  salt: Hex;
1089
+ /** The account that created the pool (`PoolCreated.creator`, F 42): the one the policy judged. Not a key field. */
1090
+ creator: Address;
1087
1091
  /** The block the pool was initialized in — its age, for annualising realized income. */
1088
1092
  block: bigint;
1089
1093
  /** Whether `deployLiquidity` has run; an unfunded pool has no floor and no float, so nothing to show. */
@@ -1100,7 +1104,7 @@ export interface DiscoveredFPool {
1100
1104
  }
1101
1105
  /**
1102
1106
  * Every F pool ever created, from `PoolCreated` logs alone — plus the terms of each distinct policy, read once and cached.
1103
- * Possible only because the event carries the full key (quote, policy, bases, swapFeeIdx, salt) — the poolId is a hash and
1107
+ * Possible only because the event carries the full key (quote, policy, bases, swapFeeIdx, salt) and the creator — the poolId is a hash and
1104
1108
  * could never be inverted; contracts PR #17 exists for exactly this call. With `indexer`, the logs come from it (the node
1105
1109
  * when it fails): a scan from block 0 per call is what made the first load wait on the node.
1106
1110
  */
@@ -1128,9 +1132,9 @@ export declare function fPoolsControlledBy(c: LogswapClient, who: Address, opts?
1128
1132
  /**
1129
1133
  * Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
1130
1134
  * topic, so one filtered log query aggregates the whole ledger. The 0xdead entry is the
1131
- * MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: the indexer's `pool_holder` view answers directly (the Transfer replay is the fallback) — a node
1132
- * prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
1133
- * holder minted before the cut.
1135
+ * MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: the Transfer rows come from
1136
+ * its tables — a node prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
1137
+ * holder minted before the cut. (The indexer's derived views are read by the app's `@logswap/base`, not here.)
1134
1138
  */
1135
1139
  export declare function fPoolShareHolders(c: LogswapClient, poolIdHex: Hex, opts?: {
1136
1140
  fromBlock?: bigint;
package/dist/fpool.js CHANGED
@@ -46,7 +46,6 @@ import { clientChainId } from "./client.js";
46
46
  import { findQuoteResult } from "./quote.js";
47
47
  import { fallBackUnlessRejected, signerFor } from "./write.js";
48
48
  import { getEventLogs } from "./history.js";
49
- import { poolHolders } from "./views.js";
50
49
  const WAD = 10n ** 18n;
51
50
  const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
52
51
  /**
@@ -299,8 +298,9 @@ export async function fPoolSwapBaseForBase(c, a) {
299
298
  export async function fPoolMint(c,
300
299
  /** `maxQuoteIn` is required: the quote leg is Q·dL/L at landing, and Q moves with every swap. */
301
300
  a) {
302
- // shares go to `to` (the account by default); on a gated pool `to` must be allowed
303
- return writeFPool(c, a.poolId, "mint", [a.to ?? a.account, a.dL, a.maxQuoteIn], a.account);
301
+ // shares go to `to` (the account by default); on a gated pool `to` must be allowed. `payer` (F 42, decision 107) is the
302
+ // account the caller declares as funding the mint, read by `SharesMinted` alone: on this direct call, the sender itself.
303
+ return writeFPool(c, a.poolId, "mint", [a.account, a.to ?? a.account, a.dL, a.maxQuoteIn], a.account);
304
304
  }
305
305
  /**
306
306
  * Burn shares for the pro-rata slice of every reserve. Available at any Q, and after dissolution.
@@ -431,13 +431,14 @@ export async function fPoolHarvest(c, a) {
431
431
  return writeFPool(c, a.poolId, "harvest", [a.extra ?? 0n, a.to ?? a.account], a.account);
432
432
  }
433
433
  /**
434
- * Pull one's settled dividend on a generation's shares without moving them;
434
+ * Pull an owner's settled dividend on a generation's shares without moving them;
435
435
  * anyone with shares. `gen` defaults to the live generation; a retired generation's harvests
436
- * stay claimable under its own id.
436
+ * stay claimable under its own id. By owner (F 42), as {@link fPoolBurn} and {@link fPoolRedeem}: the account claims its
437
+ * own, and an ERC-6909 operator may pass another `owner`. Paid to `to` (the account by default).
437
438
  */
438
439
  export async function fPoolClaim(c, a) {
439
440
  const gen = a.gen ?? (await fPoolGen(c, a.poolId));
440
- return writeFPool(c, a.poolId, "claim", [BigInt(gen), a.to ?? a.account], a.account);
441
+ return writeFPool(c, a.poolId, "claim", [BigInt(gen), a.owner ?? a.account, a.to ?? a.account], a.account);
441
442
  }
442
443
  /**
443
444
  * A holder's claimable dividend as of now on generation `gen` (the live one by default) — banked
@@ -1332,7 +1333,7 @@ export async function fPoolTransferShares(c, a) {
1332
1333
  }
1333
1334
  /**
1334
1335
  * Every F pool ever created, from `PoolCreated` logs alone — plus the terms of each distinct policy, read once and cached.
1335
- * Possible only because the event carries the full key (quote, policy, bases, swapFeeIdx, salt) — the poolId is a hash and
1336
+ * Possible only because the event carries the full key (quote, policy, bases, swapFeeIdx, salt) and the creator — the poolId is a hash and
1336
1337
  * could never be inverted; contracts PR #17 exists for exactly this call. With `indexer`, the logs come from it (the node
1337
1338
  * when it fails): a scan from block 0 per call is what made the first load wait on the node.
1338
1339
  */
@@ -1371,6 +1372,7 @@ export async function discoverFPools(c, opts = {}) {
1371
1372
  kind,
1372
1373
  policy: a.policy,
1373
1374
  salt: a.salt,
1375
+ creator: a.creator,
1374
1376
  block: l.blockNumber,
1375
1377
  seeded: g0 !== undefined,
1376
1378
  q0: g0?.q0 ?? 0n,
@@ -1400,28 +1402,15 @@ export async function fPoolsControlledBy(c, who, opts = {}) {
1400
1402
  /**
1401
1403
  * Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
1402
1404
  * topic, so one filtered log query aggregates the whole ledger. The 0xdead entry is the
1403
- * MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: the indexer's `pool_holder` view answers directly (the Transfer replay is the fallback) — a node
1404
- * prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
1405
- * holder minted before the cut.
1405
+ * MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: the Transfer rows come from
1406
+ * its tables — a node prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
1407
+ * holder minted before the cut. (The indexer's derived views are read by the app's `@logswap/base`, not here.)
1406
1408
  */
1407
1409
  export async function fPoolShareHolders(c, poolIdHex, opts = {}) {
1408
1410
  const ev = managerFAbi.find((x) => x.type === "event" && x.name === "Transfer");
1409
1411
  if (!ev)
1410
1412
  throw new Error("logswap: 6909 Transfer event missing from the generated ABI");
1411
1413
  const gen = opts.gen ?? (await fPoolGen(c, poolIdHex));
1412
- const indexer = opts.indexer ?? c.indexerUrl;
1413
- if (indexer) {
1414
- try {
1415
- const rows = await poolHolders(indexer, { condition: { side: "F", poolId: poolIdHex.toLowerCase(), gen: Number(gen), manager: c.addresses.managerF.toLowerCase() } });
1416
- return rows
1417
- .filter((r) => r.balance > 0n)
1418
- .map((r) => ({ holder: r.holder, shares: r.balance }))
1419
- .sort((a, b) => (b.shares > a.shares ? 1 : -1));
1420
- }
1421
- catch {
1422
- /* the view is a cache: the Transfer replay below answers the same */
1423
- }
1424
- }
1425
1414
  const id = fPoolShareId(poolIdHex, gen);
1426
1415
  const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.managerF, event: ev, args: { id }, fromBlock: opts.fromBlock });
1427
1416
  const bal = new Map();