@logswap/sdk 0.5.90 → 0.5.91

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.
Files changed (59) hide show
  1. package/README.md +74 -12
  2. package/dist/actions.js +4 -3
  3. package/dist/admin.d.ts +213 -219
  4. package/dist/admin.js +118 -144
  5. package/dist/chains.d.ts +13 -4
  6. package/dist/chains.js +23 -9
  7. package/dist/claims.d.ts +1 -1
  8. package/dist/claims.js +11 -9
  9. package/dist/client.d.ts +43 -20
  10. package/dist/client.js +75 -26
  11. package/dist/fees.d.ts +1 -1
  12. package/dist/fees.js +5 -4
  13. package/dist/fpool.d.ts +170 -460
  14. package/dist/fpool.js +175 -218
  15. package/dist/generated.d.ts +5549 -6027
  16. package/dist/generated.js +2580 -3153
  17. package/dist/history.js +13 -11
  18. package/dist/index.d.ts +5 -7
  19. package/dist/index.js +5 -7
  20. package/dist/indexer.d.ts +2 -2
  21. package/dist/indexer.js +12 -9
  22. package/dist/keys.d.ts +15 -3
  23. package/dist/keys.js +5 -1
  24. package/dist/liquidity.d.ts +1 -1
  25. package/dist/liquidity.js +16 -9
  26. package/dist/onboard.d.ts +16 -11
  27. package/dist/onboard.js +27 -21
  28. package/dist/pools.d.ts +2 -0
  29. package/dist/pools.js +21 -13
  30. package/dist/positions.d.ts +1 -1
  31. package/dist/positions.js +18 -17
  32. package/dist/quote.d.ts +15 -0
  33. package/dist/quote.js +36 -0
  34. package/dist/swap.d.ts +7 -9
  35. package/dist/swap.js +40 -25
  36. package/dist/views.d.ts +1 -1
  37. package/dist/write.d.ts +7 -2
  38. package/dist/write.js +10 -7
  39. package/package.json +3 -3
  40. package/src/actions.ts +4 -3
  41. package/src/admin.ts +168 -171
  42. package/src/chains.ts +33 -13
  43. package/src/claims.ts +11 -10
  44. package/src/client.ts +101 -39
  45. package/src/fees.ts +6 -6
  46. package/src/fpool.ts +240 -272
  47. package/src/generated.ts +2525 -3094
  48. package/src/history.ts +11 -9
  49. package/src/index.ts +5 -7
  50. package/src/indexer.ts +13 -11
  51. package/src/keys.ts +19 -3
  52. package/src/liquidity.ts +16 -10
  53. package/src/onboard.ts +29 -21
  54. package/src/pools.ts +23 -15
  55. package/src/positions.ts +18 -18
  56. package/src/quote.ts +36 -0
  57. package/src/swap.ts +46 -25
  58. package/src/views.ts +1 -2
  59. package/src/write.ts +11 -10
package/dist/fpool.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * fpool.ts — the `FPoolManager` surface: n bases, one quote, one shared floor.
2
+ * fpool.ts — the `ManagerF` surface: n bases, one quote, one shared floor.
3
3
  *
4
- * The other primitive. `CPoolManager` gives every position its own floor on a tick ladder;
5
- * `FPoolManager` gives every share the SAME floor and deletes the ladder, the accumulators and the
4
+ * The other primitive. `ManagerC` gives every position its own floor on a tick ladder;
5
+ * `ManagerF` gives every share the SAME floor and deletes the ladder, the accumulators and the
6
6
  * per-position accounting with it. Reading the two side by side is the fastest way to understand
7
7
  * either.
8
8
  *
@@ -19,33 +19,37 @@
19
19
  * which shape a given pool is, because a UI has to decide what to render.
20
20
  *
21
21
  * **The roles are the policy's, not the manager's** (F version 15). The manager holds no
22
- * authority, operator, gate or list: it asks the pool's policy `may(who, action)` and acts on the
23
- * answer. So `getFPool` carries the policy and what it declared, {@link getFPoolRoles} reads the
24
- * roles FROM the policy, and every role write — the handover, the operator, the gates, the list —
25
- * is a write to the policy ({@link fPoolProposeAuthority}, {@link fPoolSetGates}, …).
22
+ * authority, gate or list: it asks the pool's policy `may(who, action)` and acts on the answer (the
23
+ * one thing it caches is the operator the gates admit with no call, F 40). So `getFPool` carries the
24
+ * policy and what it declared (`flags`), {@link getFPoolRoles} reads the roles FROM the policy, and
25
+ * every setting — the operator, the gate modes, the whitelist — is a write to the policy
26
+ * ({@link fPoolAppointOperator}, {@link fPoolSetSwapMode}, {@link fPoolSetListed}, …). Since decision 098
27
+ * the authority is `key.creator` for life (no handover) and a policy has no setter of its own: its numbers
28
+ * are constructor immutables, and a change is a new policy the LOG moves a pool to ({@link fPoolMigrate}).
26
29
  *
27
- * **Zaps live on the ROUTER, not here.** Permit2 is AllowanceTransfer mode, whose standing
28
- * allowance is keyed by spender, so a second router would cost the user an allowance per token
29
- * twice, forever. One router is one spender — see `fPoolZapIn`/`fPoolZapOut` below, which target
30
- * `addresses.router`.
30
+ * **Zaps live on the ROUTER, not here.** `RouterF` is F's own router and its own Permit2 spender (decision 096: one
31
+ * router per manager; a second spender is a second signature, not a second on-chain approval). See
32
+ * `fPoolZapIn`/`fPoolZapOut` below, which target `addresses.routerF`; a wallet's Permit2 allowance for it is
33
+ * `onboardToken(c, "F", token, need)`.
31
34
  */
32
- import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, keccak256, toFunctionSelector } from "viem";
33
- import { fPoolManagerAbi, lensAbi, routerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
35
+ import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, erc20Abi, keccak256 } from "viem";
36
+ import { managerFAbi, lensFAbi, routerFAbi, orphanPolicyFAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, sponsorPolicyFAbi } from "./generated.js";
34
37
  /**
35
- * One contract, one ABI (F version 12): `harvest`, `claim`, `retire`, `regenerate`,
36
- * `setLegs`, the names, the fee parameters are `FPoolManager`'s own code. The roles left it for
37
- * the policies in F version 15: {@link fPolicyBaseAbi} is what every policy shares,
38
- * {@link privatePolicyAbi} the desk's, {@link padPolicyAbi} / {@link polPolicyAbi} / {@link publicPolicyAbi}
39
- * the kinds'.
38
+ * One contract, one ABI (F version 12): `harvest`, `claim`, `regenerate`, `close`, `deployLiquidity`,
39
+ * the fee parameters are `ManagerF`'s own code. The roles left it for the policies in F version 15:
40
+ * {@link fPolicyBaseAbi} is what the policies share, {@link sponsorPolicyFAbi} the sponsored one (kind
41
+ * `"sponsor"`, decision 098), {@link padPolicyAbi} / {@link polPolicyAbi} the other kinds', and
42
+ * {@link orphanPolicyFAbi} the neutral policy of a pool the LOG orphaned.
40
43
  */
41
- export { fPoolManagerAbi, padPolicyAbi, polPolicyAbi, privatePolicyAbi, publicPolicyAbi };
44
+ export { managerFAbi, orphanPolicyFAbi, padPolicyAbi, polPolicyAbi, sponsorPolicyFAbi };
42
45
  /**
43
- * What every protocol policy shares (`FPolicyBase`): the roles and their handover and the
44
- * `maxHarvest` readout (a harvest has no cut, decisions 056). `polPolicyAbi` is a superset of it and carries nothing that collides, so it stands
45
- * in for the base — a call through it to any of the four policies decodes the base's functions.
46
+ * What the protocol's policies share: `authority`, `nameOf` / `setName`, `kind`, `maxHarvest`
47
+ * (a harvest has no cut, decisions 056). `polPolicyAbi` is a superset of it, so it stands in for the base: a call
48
+ * through it to any F policy decodes the base's functions (`maxHarvest` is absent on the orphan policy, which refuses every harvest).
46
49
  */
47
50
  export const fPolicyBaseAbi = polPolicyAbi;
48
51
  import { clientChainId } from "./client.js";
52
+ import { findQuoteResult } from "./quote.js";
49
53
  import { fallBackUnlessRejected, signerFor } from "./write.js";
50
54
  import { getEventLogs } from "./history.js";
51
55
  import { poolHolders } from "./views.js";
@@ -53,30 +57,35 @@ import { presetMintFee } from "./positions.js";
53
57
  import { isValidMintFee, MINT_FEE_MAX } from "./keys.js";
54
58
  const WAD = 10n ** 18n;
55
59
  const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
56
- /** The optional questions a policy declared at birth, as bits of `Pool.asks`. */
57
- export const ASK_SWAP = 1;
58
- export const ASK_MINT = 2;
60
+ /**
61
+ * The bits a policy declares at birth, in `Pool.flags` (decision 098; `ASK_SWAP` / `ASK_MINT` before): with a gate bit off nothing is
62
+ * asked; with it on the manager admits the cached operator with no policy call and asks the policy about everyone else.
63
+ */
64
+ export const GATE_SWAP = 1;
65
+ export const GATE_MINT = 2;
66
+ /** `GATE_SWAP | GATE_MINT`: the bits `setGates` carries (`SEED_TO_DEAD` is the birth's alone). */
67
+ export const GATES = GATE_SWAP | GATE_MINT;
59
68
  /**
60
69
  * The lens's raw F pool struct — what the manager's `getPool` returned. Since F version 25 the
61
70
  * manager's typed views are behind `extsload` (decisions 062) and the lens reads them; one call.
62
71
  */
63
72
  async function rawFPool(c, poolId) {
64
73
  const [p] = await c.public.readContract({
65
- address: c.addresses.lens,
66
- abi: lensAbi,
67
- functionName: "getFPools",
74
+ address: c.addresses.lensF,
75
+ abi: lensFAbi,
76
+ functionName: "getPools",
68
77
  args: [[poolId]],
69
78
  });
70
79
  if (!p || /^0x0{40}$/i.test(p.quote))
71
80
  throw new Error(`logswap: no F pool with id ${poolId}`);
72
81
  return p;
73
82
  }
74
- /** Read a basket pool whole: one lens call (`fPool`, F version 25) plus the policy's kind and name. */
83
+ /** Read a basket pool whole: one lens call (`pool`, F version 25) plus the policy's kind and name. */
75
84
  export async function getFPool(c, poolId) {
76
85
  const v = await c.public.readContract({
77
- address: c.addresses.lens,
78
- abi: lensAbi,
79
- functionName: "fPool",
86
+ address: c.addresses.lensF,
87
+ abi: lensFAbi,
88
+ functionName: "pool",
80
89
  args: [poolId],
81
90
  });
82
91
  const p = v.pool;
@@ -105,7 +114,8 @@ export async function getFPool(c, poolId) {
105
114
  lnCapOverSeed: Number(p.lnCapOverSeed),
106
115
  realizedVariance: p.realizedVariance,
107
116
  policy: p.policy,
108
- asks: Number(p.asks),
117
+ flags: Number(p.flags),
118
+ operator: p.operator,
109
119
  name,
110
120
  restructureTime: Number(p.restructureTime),
111
121
  kind,
@@ -117,8 +127,8 @@ export async function getFPool(c, poolId) {
117
127
  kappa: v.baseAssets.map((l) => l.kappa),
118
128
  };
119
129
  }
120
- const F_KIND_NAMES = ["public", "private", "pol", "pad"];
121
- /** The policy's birth-time declaration that the seed's shares are the pool's (a pad's), in `asks`. */
130
+ const F_KIND_NAMES = ["sponsor", "pol", "pad", "orphan"];
131
+ /** The policy's birth-time declaration that the seed's shares are the pool's (a pad's), in `flags`. */
122
132
  export const SEED_TO_DEAD = 4;
123
133
  const kindCache = new Map();
124
134
  /**
@@ -148,35 +158,37 @@ export async function fPoolNameOf(c, poolId, policy) {
148
158
  const word = (await c.public.readContract({ address: p, abi: fPolicyBaseAbi, functionName: "nameOf", args: [poolId] }));
149
159
  return bytes32ToText(word);
150
160
  }
151
- /** The deployment's policy for a kind: the protocol's policy that IS that kind. */
152
- export function fPoolPolicyFor(c, kind) {
161
+ /** The deployment's policy for a slot — the one a key names when no `policy` is given. */
162
+ export function fPoolPolicyFor(c, slot) {
153
163
  const a = c.addresses;
154
- const policy = kind === "public" ? a.publicPolicy : kind === "private" ? a.privatePolicy : kind === "pol" ? a.polPolicy : a.padPolicy;
164
+ const policy = slot === "public" ? a.publicPolicy : slot === "private" ? a.privatePolicy : slot === "pol" ? a.polPolicy : a.padPolicy;
155
165
  if (!policy)
156
- throw new Error(`logswap: this deployment carries no ${kind} policy`);
166
+ throw new Error(`logswap: this deployment carries no ${slot} policy`);
157
167
  return policy;
158
168
  }
159
169
  /** The policy a pool named in its key — one read; {@link getFPool} carries it too. */
160
170
  export async function fPoolPolicyOf(c, poolId) {
161
171
  return (await rawFPool(c, poolId)).policy;
162
172
  }
163
- const SWAP_MODES = ["open", "listed", "executor"];
173
+ const SWAP_MODES = ["open", "operator", "listed"];
174
+ /** The swap modes in `SponsorPolicyBase.SwapMode` order — the index is the on-chain ordinal. */
175
+ export const fPoolSwapModes = SWAP_MODES;
164
176
  /** Read a pool's roles from its policy. `state` saves the `getPool` round trip when already in hand. */
165
177
  export async function getFPoolRoles(c, poolId, state) {
166
178
  const s = state ?? (await getFPool(c, poolId));
167
179
  const rdPolicy = (abi, functionName) => c.public.readContract({ address: s.policy, abi, functionName, args: [poolId] });
168
- const [creator, authority, pendingAuthority, maxHarvest] = await Promise.all([
169
- rdPolicy(fPolicyBaseAbi, "creator"),
180
+ const [authority, maxHarvest] = await Promise.all([
170
181
  rdPolicy(fPolicyBaseAbi, "authority"),
171
- rdPolicy(fPolicyBaseAbi, "pendingAuthority"),
172
- rdPolicy(fPolicyBaseAbi, "maxHarvest"),
182
+ s.kind === "orphan" ? Promise.resolve(0n) : rdPolicy(fPolicyBaseAbi, "maxHarvest"),
183
+ ]);
184
+ if (s.kind !== "sponsor")
185
+ return { policy: s.policy, authority, operator: ZERO_ADDRESS, gateMint: false, swapMode: "open", maxHarvest };
186
+ const [operator, gateMint, mode] = await Promise.all([
187
+ rdPolicy(sponsorPolicyFAbi, "operator"),
188
+ rdPolicy(sponsorPolicyFAbi, "gateMint"),
189
+ rdPolicy(sponsorPolicyFAbi, "swapMode"),
173
190
  ]);
174
- const desk = s.kind === "private";
175
- const permissions = desk
176
- ? (await c.public.readContract({ address: s.policy, abi: privatePolicyAbi, functionName: "permissionsOf", args: [poolId] }))
177
- : undefined;
178
- const [mode, swapExecutor, gateMint, , operator] = permissions ?? [0, ZERO_ADDRESS, false, ZERO_ADDRESS, ZERO_ADDRESS];
179
- return { policy: s.policy, creator, authority, pendingAuthority, operator, gateMint, swapMode: SWAP_MODES[Number(mode)] ?? "open", swapExecutor, maxHarvest };
191
+ return { policy: s.policy, authority, operator, gateMint, swapMode: SWAP_MODES[Number(mode)] ?? "open", maxHarvest };
180
192
  }
181
193
  export async function describeFPool(c, s) {
182
194
  // an unfunded pool has no L: nothing earned, nothing to harvest, no income. The bid is the
@@ -282,11 +294,11 @@ export function fPoolPreviewMintQuote(st, dL) {
282
294
  * and expect change back — do not treat it as exact.
283
295
  */
284
296
  export async function fPoolPreviewZapIn(c, poolId, dL) {
285
- // read-only lives on the LENS (the router's F flows moved to a facet; its previews came here)
286
- const { lensAbi } = await import("./generated.js");
297
+ // read-only lives on the LENS (LensF: the previews)
298
+ const { lensFAbi } = await import("./generated.js");
287
299
  return c.public.readContract({
288
- address: c.addresses.lens,
289
- abi: lensAbi,
300
+ address: c.addresses.lensF,
301
+ abi: lensFAbi,
290
302
  functionName: "previewZapIn",
291
303
  args: [poolId, dL],
292
304
  });
@@ -324,8 +336,8 @@ a) {
324
336
  */
325
337
  export async function fPoolPreviewZapOut(c, a) {
326
338
  const { result } = await c.public.simulateContract({
327
- address: c.addresses.router,
328
- abi: routerAbi,
339
+ address: c.addresses.routerF,
340
+ abi: routerFAbi,
329
341
  functionName: "zapOut",
330
342
  args: [a.poolId, a.shares, a.tokenOut, 0n, a.account, defaultDeadline()],
331
343
  account: a.account,
@@ -354,10 +366,10 @@ export async function fPoolRollIn(c, a) {
354
366
  * seed.
355
367
  */
356
368
  export async function fPoolPreviewRollIn(c, poolId, gen, holder, shares) {
357
- const { lensAbi } = await import("./generated.js");
369
+ const { lensFAbi } = await import("./generated.js");
358
370
  const [dL, quoteShort, quoteExcess] = (await c.public.readContract({
359
- address: c.addresses.lens,
360
- abi: lensAbi,
371
+ address: c.addresses.lensF,
372
+ abi: lensFAbi,
361
373
  functionName: "previewRollIn",
362
374
  args: [poolId, BigInt(gen), holder, shares],
363
375
  }));
@@ -392,9 +404,9 @@ export async function fPoolClaim(c, a) {
392
404
  export async function fPoolDividendOf(c, poolId, holder, gen) {
393
405
  const g = gen ?? (await fPoolGen(c, poolId));
394
406
  return c.public.readContract({
395
- address: c.addresses.lens,
396
- abi: lensAbi,
397
- functionName: "fDividendOf",
407
+ address: c.addresses.lensF,
408
+ abi: lensFAbi,
409
+ functionName: "dividendOf",
398
410
  args: [poolId, BigInt(g), holder],
399
411
  });
400
412
  }
@@ -406,9 +418,9 @@ export async function fPoolDividendOf(c, poolId, holder, gen) {
406
418
  export async function fPoolLienOf(c, poolId, owner, gen) {
407
419
  const g = gen ?? (await fPoolGen(c, poolId));
408
420
  const [locker, amount, owed] = await c.public.readContract({
409
- address: c.addresses.lens,
410
- abi: lensAbi,
411
- functionName: "fLienOf",
421
+ address: c.addresses.lensF,
422
+ abi: lensFAbi,
423
+ functionName: "lienOf",
412
424
  args: [fPoolShareId(poolId, g), owner],
413
425
  });
414
426
  return { locker, amount, owed };
@@ -453,8 +465,8 @@ function requireWallet(c) {
453
465
  async function writeFPool(c, poolId, functionName, args, account) {
454
466
  const wallet = requireWallet(c);
455
467
  const { request } = await c.public.simulateContract({
456
- address: c.addresses.fPoolManager,
457
- abi: fPoolManagerAbi,
468
+ address: c.addresses.managerF,
469
+ abi: managerFAbi,
458
470
  functionName,
459
471
  // Every manager write is keyed by poolId as its FIRST parameter; prepending it here, in the
460
472
  // one place all seven helpers share, is what keeps a caller from ever omitting it. The `as
@@ -468,8 +480,8 @@ async function writeFPool(c, poolId, functionName, args, account) {
468
480
  async function writeFPool0(c, functionName, args, account) {
469
481
  const wallet = requireWallet(c);
470
482
  const { request } = await c.public.simulateContract({
471
- address: c.addresses.fPoolManager,
472
- abi: fPoolManagerAbi,
483
+ address: c.addresses.managerF,
484
+ abi: managerFAbi,
473
485
  functionName,
474
486
  args,
475
487
  account: signerFor(c, account),
@@ -484,17 +496,17 @@ pullTokens = []) {
484
496
  let sendArgs = args;
485
497
  if (pullTokens.length) {
486
498
  const { permit2SigCalls } = await import("./onboard.js");
487
- const sigCalls = await permit2SigCalls(c, pullTokens).catch(fallBackUnlessRejected);
499
+ const sigCalls = await permit2SigCalls(c, "F", pullTokens).catch(fallBackUnlessRejected);
488
500
  if (sigCalls.length) {
489
501
  const { encodeFunctionData } = await import("viem");
490
- const inner = encodeFunctionData({ abi: routerAbi, functionName, args });
502
+ const inner = encodeFunctionData({ abi: routerFAbi, functionName, args });
491
503
  fn = "multicall";
492
504
  sendArgs = [[...sigCalls, inner]];
493
505
  }
494
506
  }
495
507
  const { request } = await c.public.simulateContract({
496
- address: c.addresses.router,
497
- abi: routerAbi,
508
+ address: c.addresses.routerF,
509
+ abi: routerFAbi,
498
510
  functionName: fn,
499
511
  args: sendArgs,
500
512
  account: signerFor(c, account),
@@ -515,7 +527,7 @@ export async function approveTokenForFPoolManager(c, token) {
515
527
  address: token,
516
528
  abi: [{ type: "function", name: "approve", stateMutability: "nonpayable", inputs: [{ name: "s", type: "address" }, { name: "a", type: "uint256" }], outputs: [{ type: "bool" }] }],
517
529
  functionName: "approve",
518
- args: [c.addresses.fPoolManager, (1n << 256n) - 1n],
530
+ args: [c.addresses.managerF, (1n << 256n) - 1n],
519
531
  account: wallet.account,
520
532
  chain: c.wallet.chain,
521
533
  });
@@ -526,7 +538,7 @@ export async function fPoolManagerAllowanceOk(c, token, owner, need) {
526
538
  address: token,
527
539
  abi: [{ type: "function", name: "allowance", stateMutability: "view", inputs: [{ name: "o", type: "address" }, { name: "s", type: "address" }], outputs: [{ type: "uint256" }] }],
528
540
  functionName: "allowance",
529
- args: [owner, c.addresses.fPoolManager],
541
+ args: [owner, c.addresses.managerF],
530
542
  }));
531
543
  return allowance >= need;
532
544
  }
@@ -538,20 +550,20 @@ export async function fPoolManagerAllowanceOk(c, token, owner, need) {
538
550
  // first `fPoolZapOut` revert with something unreadable.
539
551
  export async function isRouterOperatorForFPool(c, owner) {
540
552
  return c.public.readContract({
541
- address: c.addresses.fPoolManager,
542
- abi: fPoolManagerAbi,
553
+ address: c.addresses.managerF,
554
+ abi: managerFAbi,
543
555
  functionName: "isOperator",
544
- args: [owner, c.addresses.router],
556
+ args: [owner, c.addresses.routerF],
545
557
  });
546
558
  }
547
559
  /** Approve the router to move this account's F-pool shares. Needed once, before any `fPoolZapOut`. */
548
560
  export async function approveRouterForFPool(c, account) {
549
561
  const wallet = requireWallet(c);
550
562
  const { request } = await c.public.simulateContract({
551
- address: c.addresses.fPoolManager,
552
- abi: fPoolManagerAbi,
563
+ address: c.addresses.managerF,
564
+ abi: managerFAbi,
553
565
  functionName: "setOperator",
554
- args: [c.addresses.router, true],
566
+ args: [c.addresses.routerF, true],
555
567
  account: signerFor(c, account),
556
568
  });
557
569
  return wallet.writeContract(request);
@@ -585,8 +597,8 @@ export function fPoolClaimId(token) {
585
597
  export async function fPoolShareBalance(c, poolId, owner, gen) {
586
598
  const g = gen ?? (await fPoolGen(c, poolId));
587
599
  return c.public.readContract({
588
- address: c.addresses.fPoolManager,
589
- abi: fPoolManagerAbi,
600
+ address: c.addresses.managerF,
601
+ abi: managerFAbi,
590
602
  functionName: "balanceOf",
591
603
  args: [owner, fPoolShareId(poolId, g)],
592
604
  });
@@ -594,20 +606,20 @@ export async function fPoolShareBalance(c, poolId, owner, gen) {
594
606
  /** A retired generation's bundle: what is left to redeem — supply, quote, base per leg index. */
595
607
  export async function fPoolBundleOf(c, poolId, gen) {
596
608
  const [supply, quote, base] = await c.public.readContract({
597
- address: c.addresses.lens,
598
- abi: lensAbi,
599
- functionName: "fBundleOf",
609
+ address: c.addresses.lensF,
610
+ abi: lensFAbi,
611
+ functionName: "bundleOf",
600
612
  args: [poolId, BigInt(gen)],
601
613
  });
602
614
  return { supply, quote, base: [...base] };
603
615
  }
604
616
  /** A holder's claims on a pool's retired generations — one row per generation still held. */
605
617
  export async function fPoolClaimsOf(c, poolId, owner) {
606
- const { lensAbi } = await import("./generated.js");
618
+ const { lensFAbi } = await import("./generated.js");
607
619
  const rows = (await c.public.readContract({
608
- address: c.addresses.lens,
609
- abi: lensAbi,
610
- functionName: "fClaimsOf",
620
+ address: c.addresses.lensF,
621
+ abi: lensFAbi,
622
+ functionName: "claimsOf",
611
623
  args: [poolId, owner],
612
624
  }));
613
625
  return rows.map((r) => ({ gen: Number(r.gen), shares: r.shares, base: [...r.base], quote: r.quote, dividend: r.dividend }));
@@ -622,8 +634,8 @@ export async function fPoolRedeem(c, a) {
622
634
  }
623
635
  export async function fPoolClaimBalance(c, token, owner) {
624
636
  return c.public.readContract({
625
- address: c.addresses.fPoolManager,
626
- abi: fPoolManagerAbi,
637
+ address: c.addresses.managerF,
638
+ abi: managerFAbi,
627
639
  functionName: "balanceOf",
628
640
  args: [owner, fPoolClaimId(token)],
629
641
  });
@@ -646,8 +658,8 @@ export var FPoolQuoteKind;
646
658
  export async function fPoolQuoteSwap(c, a) {
647
659
  try {
648
660
  await c.public.simulateContract({
649
- address: c.addresses.router,
650
- abi: routerAbi,
661
+ address: c.addresses.routerF,
662
+ abi: routerFAbi,
651
663
  functionName: "quoteSwap",
652
664
  // the taker matters only on a gated pool: the connected account, or the zero address
653
665
  args: [a.poolId, a.kind, BigInt(a.j), BigInt(a.k ?? 0), a.amountIn, a.taker ?? c.wallet?.account?.address ?? ZERO_ADDRESS],
@@ -661,34 +673,6 @@ export async function fPoolQuoteSwap(c, a) {
661
673
  }
662
674
  throw new Error("logswap: quoteSwap returned without reverting, which it must never do");
663
675
  }
664
- /**
665
- * `QuoteResult(uint256)` — selector then one word. viem nests the revert data several layers deep
666
- * depending on the transport, so walk for it rather than guessing the shape.
667
- *
668
- * The selector is DERIVED, not written down. A hardcoded one is wrong silently: the decode simply
669
- * never matches and every quote rethrows as if the swap had failed.
670
- */
671
- function findQuoteResult(err) {
672
- const SELECTOR = toFunctionSelector("QuoteResult(uint256)");
673
- const seen = new Set();
674
- const walk = (e) => {
675
- if (!e || typeof e !== "object" || seen.has(e))
676
- return null;
677
- seen.add(e);
678
- const anyE = e;
679
- const data = anyE.data;
680
- if (typeof data === "string" && data.startsWith(SELECTOR) && data.length >= 10 + 64) {
681
- return BigInt("0x" + data.slice(10, 10 + 64));
682
- }
683
- for (const k of ["cause", "walk", "error", "details"]) {
684
- const found = walk(anyE[k]);
685
- if (found !== null)
686
- return found;
687
- }
688
- return null;
689
- };
690
- return walk(err);
691
- }
692
676
  const ZERO_SALT = `0x${"0".repeat(64)}`;
693
677
  /** `bytes32` ⇄ short UTF-8 text, for the pool and sponsor labels. */
694
678
  export function textToBytes32(text) {
@@ -755,8 +739,8 @@ export async function fPoolInitialize(c, a) {
755
739
  }
756
740
  const wallet = requireWallet(c);
757
741
  const { request } = await c.public.simulateContract({
758
- address: c.addresses.fPoolManager,
759
- abi: fPoolManagerAbi,
742
+ address: c.addresses.managerF,
743
+ abi: managerFAbi,
760
744
  functionName: "initialize",
761
745
  args: [key],
762
746
  account: wallet.account,
@@ -778,8 +762,8 @@ export async function fPoolIdOf(c, a) {
778
762
  * returning a key that names another pool. What {@link fPoolMigrate} needs when handed an id.
779
763
  */
780
764
  export async function fPoolKeyOfPool(c, poolId, opts = {}) {
781
- const ev = fPoolManagerAbi.find((x) => x.type === "event" && x.name === "PoolCreated");
782
- const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.fPoolManager, event: ev, args: { poolId }, fromBlock: opts.fromBlock });
765
+ const ev = managerFAbi.find((x) => x.type === "event" && x.name === "PoolCreated");
766
+ const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.managerF, event: ev, args: { poolId }, fromBlock: opts.fromBlock });
783
767
  const l = logs[0];
784
768
  if (!l)
785
769
  throw new Error(`logswap: no PoolCreated for F pool ${poolId}`);
@@ -966,7 +950,7 @@ export async function fPoolClose(c, a) {
966
950
  const harvests = await fPoolEmptyingHarvests(c, a.poolId);
967
951
  if (harvests.length === 0)
968
952
  return fPoolCloseRaw(c, a);
969
- const enc = (functionName, args) => encodeFunctionData({ abi: fPoolManagerAbi, functionName, args });
953
+ const enc = (functionName, args) => encodeFunctionData({ abi: managerFAbi, functionName, args });
970
954
  const calls = [...harvests.map((amount) => enc("harvest", [a.poolId, amount, a.account])), enc("close", [a.poolId, a.to ?? a.account])];
971
955
  return writeFPool0(c, "multicall", [calls], a.account);
972
956
  }
@@ -1004,8 +988,8 @@ export async function fPoolEmptyingHarvests(c, poolId) {
1004
988
  * - the income released (`IncomeReleased`), all in quote: `toPayee` to the payee and the rest into the bid
1005
989
  * (the floor down). No share is minted; L does not move. The book keeps its reserves, marks and cap.
1006
990
  *
1007
- * A pad's gate is `threshold(poolId, gen)`, in its quote (`PadPolicy.NotGraduated` below it); POL and private carry the
1008
- * authority and send it the whole income; a public pool refuses (`Refused`). A carried holder with no
991
+ * A pad's gate is `threshold(poolId, gen)`, in its quote (`PadPolicy.NotGraduated` below it); POL and a non-canonical sponsored pool carry the
992
+ * authority and send it the whole income; a canonical sponsored pool (the LOG's open instance) refuses (`Refused`). A carried holder with no
1009
993
  * share is `BadTerms`. Whoever runs the pool. To change the book (reserves, prices, cap) use {@link fPoolDeploy}.
1010
994
  */
1011
995
  export async function fPoolRegenerate(c, a) {
@@ -1035,7 +1019,7 @@ export function fPoolLaunchCalls(poolId, a) {
1035
1019
  salt: a.salt ?? ZERO_SALT,
1036
1020
  mintFee: a.mintFee ?? presetMintFee(a.swapFee),
1037
1021
  };
1038
- const enc = (functionName, args) => encodeFunctionData({ abi: fPoolManagerAbi, functionName, args });
1022
+ const enc = (functionName, args) => encodeFunctionData({ abi: managerFAbi, functionName, args });
1039
1023
  const calls = [];
1040
1024
  if (!a.initialized)
1041
1025
  calls.push(enc("initialize", [key]));
@@ -1048,7 +1032,7 @@ export function fPoolLaunchCalls(poolId, a) {
1048
1032
  throw new Error(`logswap: genesis row j = ${row.j} is not a leg`);
1049
1033
  calls.push(enc(row.side === "buy" ? "swapQuoteIn" : "swapBaseIn", [poolId, BigInt(j), row.amountIn, row.minOut ?? 0n, a.account]));
1050
1034
  }
1051
- // the name, the desk's gates and its list are the POLICY's, not the
1035
+ // the name, a sponsored policy's gates and its whitelist are the POLICY's, not the
1052
1036
  // manager's: they cannot ride in this batch — `fPoolLaunch` and `fPoolDeskOpening` send them
1053
1037
  // right after, as the same creator
1054
1038
  calls.push(...(a.extra ?? []));
@@ -1070,8 +1054,8 @@ export async function fPoolGenesisOutputs(c, poolId, a) {
1070
1054
  return [];
1071
1055
  const calls = fPoolLaunchCalls(poolId, a);
1072
1056
  const { result } = await c.public.simulateContract({
1073
- address: c.addresses.fPoolManager,
1074
- abi: fPoolManagerAbi,
1057
+ address: c.addresses.managerF,
1058
+ abi: managerFAbi,
1075
1059
  functionName: "multicall",
1076
1060
  args: [calls],
1077
1061
  account: signerFor(c, a.account),
@@ -1129,26 +1113,22 @@ export async function fPoolWalletBatchesAtomically(c, account) {
1129
1113
  }
1130
1114
  }
1131
1115
  /**
1132
- * The desk's opening posture, on its policy: gated minting, the creator a
1133
- * minter. No appointment: the authority is the operator until one is appointed.
1134
- * Two writes to `PrivatePolicy`; the launch batch cannot carry them (they are not manager calls).
1116
+ * The desk's opening posture, on its sponsored policy: gated minting (only the authority and the operator mint). The swap gate is
1117
+ * the policy's own birth (the gated instance is born with `GATE_SWAP` and the creator its operator, decision 098); this is the one write
1118
+ * that cannot ride in the launch batch (it is not a manager call).
1135
1119
  */
1136
1120
  export async function fPoolDeskOpening(c, a) {
1137
1121
  const policy = a.policy ?? fPoolPolicyFor(c, "private");
1138
- return [
1139
- await fPoolSetMintGate(c, { poolId: a.poolId, gated: true, account: a.account, policy }),
1140
- await fPoolSetMinters(c, { poolId: a.poolId, who: [a.account], allowed: true, account: a.account, policy }),
1141
- ];
1122
+ return [await fPoolSetMintGate(c, { poolId: a.poolId, gated: true, account: a.account, policy })];
1142
1123
  }
1143
1124
  /**
1144
1125
  * Create a pool as ONE transaction: `initialize`, `seed`, the seed lock, the opening buy, the
1145
- * name, the private-pool gates — the manager's `multicall`, the creator as sender throughout.
1126
+ * name — the manager's `multicall`, the creator as sender throughout (the creator is the initializer, `NotCreator`).
1146
1127
  * Either every call lands or none does; there is no half-built pool to resume.
1147
1128
  *
1148
1129
  * Why the manager and not the router: every one of these entries authenticates by `msg.sender`
1149
1130
  * (`seed` is authority-only, so is everything after it). Routed, the router would be the sender
1150
- * — the authority, the holder of the seed shares — and the handover back is two-step, so it
1151
- * could not even close in the same transaction. `multicall` is delegatecall-to-self, so the
1131
+ * — the authority, the holder of the seed shares — and `initialize` would refuse it (`NotCreator`). `multicall` is delegatecall-to-self, so the
1152
1132
  * sender survives, which is what the manager's own doc says a router cannot do.
1153
1133
  *
1154
1134
  * What the batch PULLS, by plain allowance to the manager (never Permit2): `r0[j]` of each base,
@@ -1179,7 +1159,7 @@ export async function fPoolLaunch(c, a) {
1179
1159
  account: signerFor(c, a.account),
1180
1160
  forceAtomic: true,
1181
1161
  calls: [
1182
- { to: c.addresses.fPoolManager, data: encodeFunctionData({ abi: fPoolManagerAbi, functionName: "multicall", args: [calls] }) },
1162
+ { to: c.addresses.managerF, data: encodeFunctionData({ abi: managerFAbi, functionName: "multicall", args: [calls] }) },
1183
1163
  ...transfers.map((t) => ({ to: t.token, data: encodeFunctionData({ abi: erc20Abi, functionName: "transfer", args: [t.to, t.amount] }) })),
1184
1164
  ],
1185
1165
  });
@@ -1214,63 +1194,40 @@ async function writePolicy(c, abi, a, functionName, args) {
1214
1194
  });
1215
1195
  return wallet.writeContract(request);
1216
1196
  }
1197
+ // ─── a sponsored policy's per-pool settings (the authority's; decision 098) ───────────────
1198
+ //
1199
+ // `SponsorPolicyF` and `SponsorPolicyC` share these functions, so one ABI writes both: for a C market pass `policy: key.policy`
1200
+ // (the default policy lookup reads F's lens). Where the policy offers no gates (`gatesAvailable` false: the LOG's open
1201
+ // instance) the mode, gate and list writes revert with `GatesUnavailable`.
1217
1202
  /**
1218
- * Propose the next authority — step one of two, on the pool's policy. Nothing moves
1219
- * until `next` accepts; proposing again (the zero address included) cancels a pending proposal.
1220
- * Indexed on-chain via the policy's AuthorityProposed.
1221
- */
1222
- export async function fPoolProposeAuthority(c, a) {
1223
- return writePolicy(c, fPolicyBaseAbi, a, "proposeAuthority", [a.next]);
1224
- }
1225
- /**
1226
- * Accept a pending proposal — step two; only the proposed address can. Indexed via the policy's
1227
- * AuthoritySet. On the desk's policy this clears the operator (pending and accepted) and voids the
1228
- * seller's list.
1203
+ * Appoint the pool's operator (the authority's; zero revokes, refused in `operator` swap mode): admitted by the gates with no policy call and a
1204
+ * runner of the pool; it may be a contract (an executor). Immediate, with no acceptance step, so check the address. Stamps the block.
1229
1205
  */
1230
- export async function fPoolAcceptAuthority(c, a) {
1231
- return writePolicy(c, fPolicyBaseAbi, a, "acceptAuthority", []);
1206
+ export async function fPoolAppointOperator(c, a) {
1207
+ return writePolicy(c, sponsorPolicyFAbi, a, "appointOperator", [a.operator]);
1232
1208
  }
1233
- // ─── the desk's controls (PrivatePolicy) ───────────────────────────────
1234
1209
  /**
1235
- * Set the desk's swap admission (the authority, on the desk's policy; decision 073): `open`, `listed` (the minters and takers
1236
- * lists) or `executor` (one address, cached on the manager, no policy call per swap). `executor` is required in `executor` mode
1237
- * and must be omitted otherwise. Preserves mint admission. `burn` is never gated.
1210
+ * Set swap admission (the authority's, where the policy offers gates): `open`, `operator` (only the operator swaps — needs one appointed) or
1211
+ * `listed` (the whitelist, {@link fPoolSetListed}; the operator always passes). `burn` is never gated.
1238
1212
  */
1239
1213
  export async function fPoolSetSwapMode(c, a) {
1240
- return writePolicy(c, privatePolicyAbi, a, "setSwapMode", [SWAP_MODES.indexOf(a.mode), a.executor ?? ZERO_ADDRESS]);
1214
+ return writePolicy(c, sponsorPolicyFAbi, a, "setSwapMode", [SWAP_MODES.indexOf(a.mode)]);
1241
1215
  }
1242
- /** Turn mint admission on or off (the authority, on the desk's policy), preserving the swap mode and its executor. */
1216
+ /** Turn the mint gate on or off (the authority's, where the policy offers gates): on, only the authority and the operator mint. */
1243
1217
  export async function fPoolSetMintGate(c, a) {
1244
- return writePolicy(c, privatePolicyAbi, a, "setMintGate", [a.gated]);
1218
+ return writePolicy(c, sponsorPolicyFAbi, a, "setMintGate", [a.gated]);
1245
1219
  }
1246
1220
  /**
1247
- * Add to or remove from the pool's MINTERS — who may mint, and swap (a zap in is both under one
1248
- * lock) — in one call (the authority, on the desk's policy). The list is keyed by
1249
- * the authority that granted it: a handover starts the buyer with an empty one. Stamps the
1250
- * block: no swap lands in it (047).
1221
+ * Add to or remove from the pool's swap WHITELIST in one call (the authority's, where the policy offers gates; consulted in `listed` mode).
1222
+ * The one list: the free-form minter and taker lists are gone. Stamps the block: no swap lands in it (047).
1251
1223
  */
1252
- export async function fPoolSetMinters(c, a) {
1253
- return writePolicy(c, privatePolicyAbi, a, "setMinters", [a.who, a.allowed]);
1254
- }
1255
- /** Add to or remove from the pool's TAKERS — who may swap only — in one call (the authority). Stamps the block. */
1256
- export async function fPoolSetTakers(c, a) {
1257
- return writePolicy(c, privatePolicyAbi, a, "setTakers", [a.who, a.allowed]);
1224
+ export async function fPoolSetListed(c, a) {
1225
+ return writePolicy(c, sponsorPolicyFAbi, a, "setListed", [a.who, a.listed]);
1258
1226
  }
1259
- async function readDesk(c, poolId, who, functionName, policy) {
1227
+ /** On the pool's swap whitelist now (the sponsored policy's `listed`). */
1228
+ export async function fPoolIsListed(c, poolId, who, policy) {
1260
1229
  const address = policy ?? (await fPoolPolicyOf(c, poolId));
1261
- return (await c.public.readContract({ address, abi: privatePolicyAbi, functionName, args: [poolId, who] }));
1262
- }
1263
- /** On the pool's minters under its current authority: may mint, and swap. */
1264
- export async function fPoolIsMinter(c, poolId, who, policy) {
1265
- return readDesk(c, poolId, who, "isMinter", policy);
1266
- }
1267
- /** On the pool's takers under its current authority: may swap only. */
1268
- export async function fPoolIsTaker(c, poolId, who, policy) {
1269
- return readDesk(c, poolId, who, "isTaker", policy);
1270
- }
1271
- /** May swap: a minter or a taker (consulted only while the swap gate is on). */
1272
- export async function fPoolIsAllowed(c, poolId, who, policy) {
1273
- return readDesk(c, poolId, who, "isAllowed", policy);
1230
+ return (await c.public.readContract({ address, abi: sponsorPolicyFAbi, functionName: "listed", args: [poolId, who] }));
1274
1231
  }
1275
1232
  /** Label the pool — the authority's own words on the pool's POLICY, mutable, never identity. At most 31 bytes of UTF-8. */
1276
1233
  export async function fPoolSetName(c, a) {
@@ -1305,7 +1262,7 @@ export async function fPoolSponsorName(c, who) {
1305
1262
  export async function fPoolRegistryOf(c) {
1306
1263
  if (c.addresses.policyRegistry)
1307
1264
  return c.addresses.policyRegistry;
1308
- return (await c.public.readContract({ address: c.addresses.fPoolManager, abi: fPoolManagerAbi, functionName: "registry" }));
1265
+ return (await c.public.readContract({ address: c.addresses.managerF, abi: managerFAbi, functionName: "registry" }));
1309
1266
  }
1310
1267
  async function registryAddress(c) {
1311
1268
  const registry = await fPoolRegistryOf(c);
@@ -1317,14 +1274,6 @@ async function registryAddress(c) {
1317
1274
  export function fPoolRunners(s) {
1318
1275
  return s.operator === ZERO_ADDRESS ? [s.authority] : [s.authority, s.operator];
1319
1276
  }
1320
- /**
1321
- * Grant, replace or revoke the pool operator (the authority, on the desk's policy; decision 073): one optional delegate who may
1322
- * `harvest`, `retire`, `regenerate` and `setLegs` besides the authority. Immediate, with no acceptance step, so check the
1323
- * address; the zero address revokes. A handover or a policy move clears it.
1324
- */
1325
- export async function fPoolSetPoolOperator(c, a) {
1326
- return writePolicy(c, privatePolicyAbi, a, "setPoolOperator", [a.operator]);
1327
- }
1328
1277
  /**
1329
1278
  * Move shares (ERC-6909 `transfer`) — to another holder, or to `0xdead` to lock them for good.
1330
1279
  * Burning to the dead address is a sponsor's way to make its liquidity permanent: the shares can
@@ -1334,8 +1283,8 @@ export async function fPoolTransferShares(c, a) {
1334
1283
  const wallet = requireWallet(c);
1335
1284
  const gen = a.gen ?? (await fPoolGen(c, a.poolId));
1336
1285
  const { request } = await c.public.simulateContract({
1337
- address: c.addresses.fPoolManager,
1338
- abi: fPoolManagerAbi,
1286
+ address: c.addresses.managerF,
1287
+ abi: managerFAbi,
1339
1288
  functionName: "transfer",
1340
1289
  args: [a.to, fPoolShareId(a.poolId, gen), a.shares],
1341
1290
  account: signerFor(c, a.account),
@@ -1350,11 +1299,11 @@ export async function fPoolTransferShares(c, a) {
1350
1299
  * a scan from block 0 per call is what made the first load wait on the node.
1351
1300
  */
1352
1301
  export async function discoverFPools(c, opts = {}) {
1353
- const ev = fPoolManagerAbi.find((x) => x.type === "event" && x.name === "PoolCreated");
1302
+ const ev = managerFAbi.find((x) => x.type === "event" && x.name === "PoolCreated");
1354
1303
  if (!ev)
1355
1304
  throw new Error("logswap: F PoolCreated event missing from the generated ABI");
1356
- const deployEv = fPoolManagerAbi.find((x) => x.type === "event" && x.name === "LiquidityDeployed");
1357
- const range = { indexer: opts.indexer, address: c.addresses.fPoolManager, fromBlock: opts.fromBlock, toBlock: opts.toBlock };
1305
+ const deployEv = managerFAbi.find((x) => x.type === "event" && x.name === "LiquidityDeployed");
1306
+ const range = { indexer: opts.indexer, address: c.addresses.managerF, fromBlock: opts.fromBlock, toBlock: opts.toBlock };
1358
1307
  const [{ logs }, { logs: deploys }] = await Promise.all([
1359
1308
  getEventLogs(c, { ...range, event: ev }),
1360
1309
  deployEv ? getEventLogs(c, { ...range, event: deployEv }) : Promise.resolve({ logs: [] }),
@@ -1434,19 +1383,27 @@ export async function getFPoolRules(c, s, roles) {
1434
1383
  const [minQuoteRatio, incomeTaxRate] = await Promise.all([rd(polPolicyAbi, "minQuoteRatio"), rd(polPolicyAbi, "incomeTaxRate")]);
1435
1384
  return { kind: "pol", minQuoteRatio, incomeTaxRate };
1436
1385
  }
1437
- case "public": {
1438
- return { kind: "public" };
1439
- }
1440
- case "private": {
1386
+ case "sponsor": {
1441
1387
  const r = roles ?? (await getFPoolRoles(c, s.poolId, s));
1442
- return { kind: "private", gateMint: r.gateMint, swapMode: r.swapMode, swapExecutor: r.swapExecutor, operator: r.operator };
1388
+ const [sponsor, canonical, gatesAvailable, bornGated, swapTiers, mintTiers] = await Promise.all([
1389
+ rd(sponsorPolicyFAbi, "sponsor"),
1390
+ rd(sponsorPolicyFAbi, "canonical"),
1391
+ rd(sponsorPolicyFAbi, "gatesAvailable"),
1392
+ rd(sponsorPolicyFAbi, "bornGated"),
1393
+ rd(sponsorPolicyFAbi, "swapTiers"),
1394
+ rd(sponsorPolicyFAbi, "mintTiers"),
1395
+ ]);
1396
+ return { kind: "sponsor", sponsor, canonical, gatesAvailable, bornGated, swapTiers, mintTiers, gateMint: r.gateMint, swapMode: r.swapMode, operator: r.operator };
1397
+ }
1398
+ case "orphan": {
1399
+ return { kind: "orphan" };
1443
1400
  }
1444
1401
  }
1445
1402
  }
1446
1403
  /**
1447
- * Every F pool `who` is the AUTHORITY of, across the four policies — the policy page's list. Pools
1448
- * `who` created and handed over are not here (the buyer's page shows them); pools handed TO
1449
- * `who` are. `pools` may be passed (from the indexer, say) to skip the log scan.
1404
+ * Every F pool `who` is the AUTHORITY of, across the policies — the policy page's list. The authority is `key.creator` for
1405
+ * life (decision 098), so these are the pools `who` created, minus any the LOG orphaned. `pools` may be passed (from the
1406
+ * indexer, say) to skip the log scan.
1450
1407
  */
1451
1408
  export async function fPoolsControlledBy(c, who, opts = {}) {
1452
1409
  const pools = opts.pools ?? (await discoverFPools(c, { fromBlock: opts.fromBlock }));
@@ -1472,14 +1429,14 @@ export async function fPoolsControlledBy(c, who, opts = {}) {
1472
1429
  * holder minted before the cut.
1473
1430
  */
1474
1431
  export async function fPoolShareHolders(c, poolIdHex, opts = {}) {
1475
- const ev = fPoolManagerAbi.find((x) => x.type === "event" && x.name === "Transfer");
1432
+ const ev = managerFAbi.find((x) => x.type === "event" && x.name === "Transfer");
1476
1433
  if (!ev)
1477
1434
  throw new Error("logswap: 6909 Transfer event missing from the generated ABI");
1478
1435
  const gen = opts.gen ?? (await fPoolGen(c, poolIdHex));
1479
1436
  const indexer = opts.indexer ?? c.indexerUrl;
1480
1437
  if (indexer) {
1481
1438
  try {
1482
- const rows = await poolHolders(indexer, { condition: { side: "F", poolId: poolIdHex.toLowerCase(), gen: Number(gen), manager: c.addresses.fPoolManager.toLowerCase() } });
1439
+ const rows = await poolHolders(indexer, { condition: { side: "F", poolId: poolIdHex.toLowerCase(), gen: Number(gen), manager: c.addresses.managerF.toLowerCase() } });
1483
1440
  return rows
1484
1441
  .filter((r) => r.balance > 0n)
1485
1442
  .map((r) => ({ holder: r.holder, shares: r.balance }))
@@ -1490,7 +1447,7 @@ export async function fPoolShareHolders(c, poolIdHex, opts = {}) {
1490
1447
  }
1491
1448
  }
1492
1449
  const id = fPoolShareId(poolIdHex, gen);
1493
- const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.fPoolManager, event: ev, args: { id }, fromBlock: opts.fromBlock });
1450
+ const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.managerF, event: ev, args: { id }, fromBlock: opts.fromBlock });
1494
1451
  const bal = new Map();
1495
1452
  for (const l of logs) {
1496
1453
  const a = l.args;
@@ -1504,13 +1461,13 @@ export async function fPoolShareHolders(c, poolIdHex, opts = {}) {
1504
1461
  .map(([holder, shares]) => ({ holder: holder, shares }))
1505
1462
  .sort((a, b) => (b.shares > a.shares ? 1 : -1));
1506
1463
  }
1507
- /** Every F pool's raw state in one lens call (the manager's `Pool` struct: quote, swapFee, policy, seeded, gen, n, restructureTime, asks, lnCapOverSeed, Q, realizedVariance, L, shares, refLogFloor). */
1464
+ /** Every F pool's raw state in one lens call (the manager's `Pool` struct: quote, swapFee, restructureTime, flags, policy, seeded, gen, n, lnCapOverSeed, Q, realizedVariance, L, shares, refLogFloor, operator, mintFee). */
1508
1465
  export async function getFPoolsRaw(c, poolIds) {
1509
- const { lensAbi } = await import("./generated.js");
1510
- return (await c.public.readContract({ address: c.addresses.lens, abi: lensAbi, functionName: "getFPools", args: [poolIds] }));
1466
+ const { lensFAbi } = await import("./generated.js");
1467
+ return (await c.public.readContract({ address: c.addresses.lensF, abi: lensFAbi, functionName: "getPools", args: [poolIds] }));
1511
1468
  }
1512
1469
  /** Share value from the lens — (L + Q)/shares, WAD per share — the same figure as `fPoolShareValue`, from one source. */
1513
1470
  export async function shareValueOnChain(c, poolId) {
1514
- const { lensAbi } = await import("./generated.js");
1515
- return (await c.public.readContract({ address: c.addresses.lens, abi: lensAbi, functionName: "shareValue", args: [poolId] }));
1471
+ const { lensFAbi } = await import("./generated.js");
1472
+ return (await c.public.readContract({ address: c.addresses.lensF, abi: lensFAbi, functionName: "shareValue", args: [poolId] }));
1516
1473
  }