@logswap/sdk 0.5.90 → 0.5.92

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 +136 -31
  2. package/dist/actions.js +4 -3
  3. package/dist/admin.d.ts +96 -925
  4. package/dist/admin.js +113 -194
  5. package/dist/chains.d.ts +13 -4
  6. package/dist/chains.js +22 -9
  7. package/dist/claims.d.ts +1 -1
  8. package/dist/claims.js +11 -9
  9. package/dist/client.d.ts +42 -20
  10. package/dist/client.js +86 -26
  11. package/dist/fees.d.ts +1 -1
  12. package/dist/fees.js +5 -4
  13. package/dist/fpool.d.ts +327 -1120
  14. package/dist/fpool.js +408 -475
  15. package/dist/generated.d.ts +5017 -7631
  16. package/dist/generated.js +3040 -4879
  17. package/dist/history.js +12 -14
  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 +143 -249
  42. package/src/chains.ts +32 -13
  43. package/src/claims.ts +11 -10
  44. package/src/client.ts +111 -39
  45. package/src/fees.ts +6 -6
  46. package/src/fpool.ts +555 -648
  47. package/src/generated.ts +3063 -4904
  48. package/src/history.ts +11 -11
  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/client.d.ts CHANGED
@@ -3,33 +3,44 @@
3
3
  *
4
4
  * Construct once and pass to every helper. `wallet` is optional: read helpers need only `public`.
5
5
  *
6
- * **Three addresses, permanently.** Not three per market — every market lives in the one manager,
7
- * and a market is an `initialize(key, x0)` call rather than a deployment. So this is a constant of
8
- * the protocol, not configuration that grows.
6
+ * **One stack per manager, permanently** (decision 096): a manager, its router and its lens, for F and for
7
+ * C. Not per market — every market lives in the one manager of its side, and a market is an
8
+ * `initialize` call rather than a deployment. F ships first, so the C stack is optional: a chain
9
+ * that has not opted into C carries `address(0)` for it, and every C call throws a plain error there.
9
10
  */
10
11
  import type { Address, PublicClient, WalletClient } from "viem";
11
12
  import { type LogswapDeployment } from "./chains.js";
13
+ /** The two singletons: `C` is the concentrated one (a floor per position, a tick ladder), `F` the fungible one. */
14
+ export type Side = "C" | "F";
12
15
  export interface LogswapAddresses {
13
- /** The C singleton — a floor per position, on a tick ladder. ERC-6909 positions and token
14
- * claims live here. */
15
- cPoolManager: Address;
16
- /** User entry for every market: multicall, blended mint, zap, routes, Permit2. */
17
- router: Address;
18
- /** Read-only: ladder derivations and revert-quoter previews. */
19
- lens: Address;
16
+ /** The F singleton — fungible claims, one shared floor, n bases. ERC-6909 shares and token claims live here. */
17
+ managerF: Address;
18
+ /** F's user entry: swaps, zaps, roll-in, Permit2. Its own Permit2 spender. */
19
+ routerF: Address;
20
+ /** F's read-only lens: pool views and previews. */
21
+ lensF: Address;
20
22
  /**
21
- * The F-pool singleton — fungible claims, one shared floor, n bases. Optional only because a
22
- * deployment predating it will not carry the address; every F-pool call needs it.
23
+ * The C singleton — a floor per position, on a tick ladder. ERC-6909 positions and token claims live here.
24
+ * The C stack is optional: F ships first, and a chain that has not opted into C carries none.
23
25
  */
24
- fPoolManager?: Address;
26
+ managerC?: Address;
27
+ /** C's user entry: the batch, the named one-action entries, `createMarket`, Permit2. Its own Permit2 spender. */
28
+ routerC?: Address;
29
+ /** C's read-only lens: ladder derivations and views. */
30
+ lensC?: Address;
25
31
  /**
26
- * The protocol's four F policies, one per kind: every F pool names one in its key,
27
- * and the pool's roles, gates and terms live on it. A deployment predating them carries none.
32
+ * The LOG's policies (decision 098: immutable, deployed by the LOG): every pool names one in its key for life, and the pool's
33
+ * roles, gates and terms live on it. On F the four are instances of one contract, `PolicyF` (F 41, policy.md), told apart by
34
+ * their immutables: `publicPolicy` is the open one (anyone creates at salt zero, no gate ever), `privatePolicy` the LOG's desk
35
+ * (closed, gates by pool), `polPolicy` and `padPolicy` the treasury's and the launch's. The artifact keys predate 098 and are
36
+ * kept. A deployment predating the policies carries none.
28
37
  */
29
38
  publicPolicy?: Address;
30
39
  privatePolicy?: Address;
31
40
  polPolicy?: Address;
32
41
  padPolicy?: Address;
42
+ /** The LOG's open sponsored instance on C (`SponsorPolicyC`): the policy of a public market. Absent with no C stack. */
43
+ publicPolicyC?: Address;
33
44
  /**
34
45
  * The policy registry: what a pool of each kind may be born under, and the
35
46
  * owner that may move a pool between policies. Read from the F manager (`registry()`) when
@@ -38,9 +49,19 @@ export interface LogswapAddresses {
38
49
  policyRegistry?: Address;
39
50
  /** The devnet's token factory (`TokenFactory`, a mock): where launchable tokens come from. Optional. */
40
51
  tokenFactory?: Address;
41
- /** Optional — the router falls back to plain approvals when absent. */
52
+ /** Optional — each router falls back to plain approvals when absent. */
42
53
  permit2?: Address;
43
54
  }
55
+ /** Whether the deployment carries the C stack. */
56
+ export declare function hasC(c: LogswapClient): boolean;
57
+ /** The C manager; throws where the deployment has none. */
58
+ export declare function managerC(c: LogswapClient): Address;
59
+ /** The C router; throws where the deployment has none. */
60
+ export declare function routerC(c: LogswapClient): Address;
61
+ /** The C lens; throws where the deployment has none. */
62
+ export declare function lensC(c: LogswapClient): Address;
63
+ /** The router of `side` — the contract that pulls the caller's tokens, and the spender to approve. */
64
+ export declare function routerOf(c: LogswapClient, side: Side): Address;
44
65
  export interface LogswapClient {
45
66
  public: PublicClient;
46
67
  wallet?: WalletClient;
@@ -112,14 +133,14 @@ export declare function clientChainId(c: LogswapClient): Promise<number>;
112
133
  * **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
113
134
  * `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
114
135
  * LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
115
- * each market's, answered by the gate (`PublicPolicy.swapFeeTax`, the LOG Authority's) at birth and
136
+ * each market's, answered by its policy at birth (since 098, `SponsorPolicyC.swapFeeTax`, an immutable) and
116
137
  * read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
117
138
  * permissionless and pays the treasury. No pool id moved.
118
139
  * 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
119
140
  * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
120
141
  * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
121
142
  */
122
- export declare const EXPECTED_VERSION = 13n;
143
+ export declare const EXPECTED_VERSION = 16n;
123
144
  /**
124
145
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
125
146
  * 4 was the income-only harvest cut).
@@ -131,12 +152,13 @@ export declare const EXPECTED_VERSION = 13n;
131
152
  * passes it; when one lands, raise this constant in the same change, which is the discipline
132
153
  * `EXPECTED_VERSION` enforces mechanically and this one asks for.
133
154
  */
134
- export declare const EXPECTED_F_VERSION = 39n;
155
+ export declare const EXPECTED_F_VERSION = 41n;
135
156
  export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
136
157
  /**
137
158
  * The versions say the managers are the right code; this says the rest of the addresses belong
138
159
  * to THEM. A stale router or lens from a previous deployment passes every version check and then
139
160
  * fails in the worst way: approvals go to a router that pulls for another manager, or every pull
140
- * reverts because the router's Permit2 is not the one the user approved.
161
+ * reverts because the router's Permit2 is not the one the user approved. Each side is checked on its
162
+ * own: the router and the lens name their manager (`mgr()`), and the router its Permit2.
141
163
  */
142
164
  export declare function assertWiring(c: LogswapClient): Promise<void>;
package/dist/client.js CHANGED
@@ -3,11 +3,45 @@
3
3
  *
4
4
  * Construct once and pass to every helper. `wallet` is optional: read helpers need only `public`.
5
5
  *
6
- * **Three addresses, permanently.** Not three per market — every market lives in the one manager,
7
- * and a market is an `initialize(key, x0)` call rather than a deployment. So this is a constant of
8
- * the protocol, not configuration that grows.
6
+ * **One stack per manager, permanently** (decision 096): a manager, its router and its lens, for F and for
7
+ * C. Not per market — every market lives in the one manager of its side, and a market is an
8
+ * `initialize` call rather than a deployment. F ships first, so the C stack is optional: a chain
9
+ * that has not opted into C carries `address(0)` for it, and every C call throws a plain error there.
9
10
  */
10
11
  import { addressesOfDeployment, DEFAULT_MAX_LOG_RANGE, logswapChain } from "./chains.js";
12
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
13
+ const NO_C = "logswap: this deployment has no C stack (managerC / routerC / lensC) — F ships first, C lands with its own deployment";
14
+ /** Whether the deployment carries the C stack. */
15
+ export function hasC(c) {
16
+ const a = c.addresses;
17
+ return has(a.managerC) && has(a.routerC) && has(a.lensC);
18
+ }
19
+ const has = (a) => !!a && a !== ZERO_ADDRESS;
20
+ /** The C manager; throws where the deployment has none. */
21
+ export function managerC(c) {
22
+ const a = c.addresses.managerC;
23
+ if (!has(a))
24
+ throw new Error(NO_C);
25
+ return a;
26
+ }
27
+ /** The C router; throws where the deployment has none. */
28
+ export function routerC(c) {
29
+ const a = c.addresses.routerC;
30
+ if (!has(a))
31
+ throw new Error(NO_C);
32
+ return a;
33
+ }
34
+ /** The C lens; throws where the deployment has none. */
35
+ export function lensC(c) {
36
+ const a = c.addresses.lensC;
37
+ if (!has(a))
38
+ throw new Error(NO_C);
39
+ return a;
40
+ }
41
+ /** The router of `side` — the contract that pulls the caller's tokens, and the spender to approve. */
42
+ export function routerOf(c, side) {
43
+ return side === "F" ? c.addresses.routerF : routerC(c);
44
+ }
11
45
  export function createLogswapClient(args) {
12
46
  const d = args.deployment;
13
47
  const addresses = args.addresses ?? (d && addressesOfDeployment(d));
@@ -106,7 +140,7 @@ function guardChain(wallet, pub) {
106
140
  * **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
107
141
  * `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
108
142
  * LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
109
- * each market's, answered by the gate (`PublicPolicy.swapFeeTax`, the LOG Authority's) at birth and
143
+ * each market's, answered by its policy at birth (since 098, `SponsorPolicyC.swapFeeTax`, an immutable) and
110
144
  * read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
111
145
  * permissionless and pays the treasury. No pool id moved.
112
146
  * 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
@@ -121,7 +155,16 @@ function guardChain(wallet, pub) {
121
155
  // only; no pool id moved), the router's named entries take the tokens the caller expects (`WrongToken`), `claimById` / `burnById` /
122
156
  // `claimManyFor` are `claim` / `burn` / `claimMany`, `mint(poolId, to, floor, cap, L)`, `MarketCreated` is `PoolCreated` (in F's field
123
157
  // order), `x0` is `initialLogPrice`, `PoolView.x` / `.F` are `logPrice` / `feeGrowth`, `swapFee` / `mintFee` are `uint56`.
124
- export const EXPECTED_VERSION = 13n;
158
+ // 14 (decision 092): the C quoter is the router's (`Router.quoteSwap(poolId, exactIn, baseSide, amount, taker)`); `CPoolManager.quoteSwap`
159
+ // and the Lens's `previewSwapExactIn` / `Out` / `InBatch` are gone. No pool id moved.
160
+ // 15 (decision 097): `PoolKeyC` is `(base, quote, tickSpacing, policy, creator, salt, swapFee, mintFee)` — every C pool id moved; the creator
161
+ // initializes and makes the first mint (`NotCreator`); `PoolCreated` carries the salt; the backstop is held by 0xdead; a malformed policy
162
+ // answer is `BadTerms`. The names are decision 096's (no `c` prefix on a function or an event; `SwapState`); a router and a lens per manager.
163
+ // 16 (decision 098): the policies are immutable and the LOG's — `SponsorPolicyC` replaces `PublicPolicy` / `PrivatePolicy`; `setPermissions` /
164
+ // `PermissionsSet` are `setGates(poolId, gates, operator)` / `GatesSet`; the birth answer is `(flags, tax, operator)`; the policy's
165
+ // numbers (tiers, quotes, spacings, tax) are constructor immutables; the swap and mint gates are one bit each (`GATE_SWAP`,
166
+ // `GATE_MINT`) and the cached operator passes with no policy call. No pool id moved.
167
+ export const EXPECTED_VERSION = 16n;
125
168
  /**
126
169
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
127
170
  * 4 was the income-only harvest cut).
@@ -224,24 +267,39 @@ export const EXPECTED_VERSION = 13n;
224
267
  // income fee are the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`); a pad is uncapped.
225
268
  // 39 (decision 087): `swapFeeB4B` is gone; base-for-base pays `swapFee` once, not 2·swapFee.
226
269
  // A breaking bump: raised in the same change.
227
- export const EXPECTED_F_VERSION = 39n;
270
+ // 40 (decision 098): the policies are immutable and the LOG's — `SponsorPolicyF` replaces `PublicPolicy` / `PrivatePolicy`, `PolPolicy` /
271
+ // `PadPolicy` lose their setters (and the lists, the handover and `creator`: the authority is `key.creator` for life); `Pool.asks` is
272
+ // `Pool.flags` (`GATE_SWAP` 1, `GATE_MINT` 2, `SEED_TO_DEAD` 4) and `Pool.operator` caches the operator; `setPermissions` /
273
+ // `PermissionsSet` are `setGates` / `GatesSet`; the registry's `migrate(manager, key, to, permissions)` replaces `migratePrivate`,
274
+ // `orphan(manager, key)` moves a pool to `OrphanPolicyF`. No pool id moved.
275
+ // 41 (policy.md): one policy contract, `PolicyF`, whose kinds are parameter sets — `SponsorPolicyF`, `PolPolicy`, `PadPolicy` and
276
+ // `OrphanPolicyF` are gone. The AUTHORITY is the policy's (immutable) and appoints each pool's OPERATOR, who funds, harvests, closes
277
+ // and sets the modes and the name. `PoolKeyF` is `(quote, bases, swapFeeIdx, policy, salt)` — no creator, no mint fee: the swap fee is
278
+ // an index into `FEE_LIST` (1, 2, 5, 10, 20, 50, 100, 200 bp) and the mint fee the next entry — so EVERY POOL ID MOVED.
279
+ // `deployLiquidity(poolId, baseAssets, quoteAmount, lnCapOverSeed)` on an inactive pool only (no `to`: the operator holds the
280
+ // shares); `harvest(poolId, extra, to)` takes the income and `extra` capital; `close(poolId, to)` at any bid, harvesting first,
281
+ // refused on a pad; `regenerate` is gone (`multicall(close, redeem, deployLiquidity)`); the registry's `migrate`, `orphan` and
282
+ // `setOrphanPolicy` are gone, `sunset` also refuses `deployLiquidity`. `PoolCreated(poolId, quote, policy, bases, swapFeeIdx, salt)`;
283
+ // `IncomeHarvested(poolId, to, gen, income, capital, tax, toOperator, Q)`; `GenerationFrozen` from `close` alone; `IncomeReleased` and
284
+ // `PolicyMigrated` are gone. The policy's name is an event (`NameSet`), its lists are per policy (`setRights`, `RightsSet`), its
285
+ // modes per pool (`setSwapMode` / `setMintMode`, each Open < Listed < Operator with `mintMode ≥ swapMode`).
286
+ export const EXPECTED_F_VERSION = 41n;
228
287
  export async function assertVersion(c, expected = EXPECTED_VERSION) {
229
- const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
230
- // three independent reads: one round trip, not three in a row
231
- const [got, gotF, wiring] = await Promise.all([
232
- c.public.readContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "version" }),
233
- // the F manager carries its own tag; assert it the same way when deployed
234
- c.addresses.fPoolManager
235
- ? c.public.readContract({ address: c.addresses.fPoolManager, abi: fPoolManagerAbi, functionName: "version" })
236
- : Promise.resolve(null),
288
+ const { managerCAbi, managerFAbi } = await import("./generated.js");
289
+ const withC = hasC(c);
290
+ // independent reads: one round trip, not one per manager
291
+ const [gotC, gotF, wiring] = await Promise.all([
292
+ // the C stack is optional (F ships first); asserted the same way when deployed
293
+ withC ? c.public.readContract({ address: c.addresses.managerC, abi: managerCAbi, functionName: "version" }) : Promise.resolve(null),
294
+ c.public.readContract({ address: c.addresses.managerF, abi: managerFAbi, functionName: "version" }),
237
295
  assertWiring(c).then(() => null, (e) => e),
238
296
  ]);
239
- if (got !== expected) {
240
- throw new Error(`logswap: manager at ${c.addresses.cPoolManager} reports version ${got}, but this SDK was built ` +
297
+ if (gotC !== null && gotC !== expected) {
298
+ throw new Error(`logswap: C manager at ${c.addresses.managerC} reports version ${gotC}, but this SDK was built ` +
241
299
  `against version ${expected}. Upgrade the SDK or point at the matching deployment.`);
242
300
  }
243
- if (gotF !== null && gotF < EXPECTED_F_VERSION) {
244
- throw new Error(`logswap: F manager at ${c.addresses.fPoolManager} reports version ${gotF}, but this SDK needs ` +
301
+ if (gotF < EXPECTED_F_VERSION) {
302
+ throw new Error(`logswap: F manager at ${c.addresses.managerF} reports version ${gotF}, but this SDK needs ` +
245
303
  `at least F version ${EXPECTED_F_VERSION}. Upgrade the deployment or point at a newer one.`);
246
304
  }
247
305
  // the wiring's error is the less specific one, so a version mismatch is reported first
@@ -252,20 +310,22 @@ export async function assertVersion(c, expected = EXPECTED_VERSION) {
252
310
  * The versions say the managers are the right code; this says the rest of the addresses belong
253
311
  * to THEM. A stale router or lens from a previous deployment passes every version check and then
254
312
  * fails in the worst way: approvals go to a router that pulls for another manager, or every pull
255
- * reverts because the router's Permit2 is not the one the user approved.
313
+ * reverts because the router's Permit2 is not the one the user approved. Each side is checked on its
314
+ * own: the router and the lens name their manager (`mgr()`), and the router its Permit2.
256
315
  */
257
316
  export async function assertWiring(c) {
258
- const { routerAbi, lensAbi } = await import("./generated.js");
317
+ const { routerCAbi, routerFAbi, lensCAbi, lensFAbi } = await import("./generated.js");
259
318
  const rd = (address, abi, functionName) => c.public.readContract({ address, abi, functionName });
260
319
  const ZERO = "0x0000000000000000000000000000000000000000";
261
320
  const want = [
262
- ["router.mgr()", rd(c.addresses.router, routerAbi, "mgr"), c.addresses.cPoolManager],
263
- ["router.permit2()", rd(c.addresses.router, routerAbi, "permit2"), c.addresses.permit2 ?? ZERO],
264
- ["lens.mgr()", rd(c.addresses.lens, lensAbi, "mgr"), c.addresses.cPoolManager],
321
+ ["routerF.mgr()", rd(c.addresses.routerF, routerFAbi, "mgr"), c.addresses.managerF],
322
+ ["routerF.permit2()", rd(c.addresses.routerF, routerFAbi, "permit2"), c.addresses.permit2 ?? ZERO],
323
+ ["lensF.mgr()", rd(c.addresses.lensF, lensFAbi, "mgr"), c.addresses.managerF],
265
324
  ];
266
- if (c.addresses.fPoolManager) {
267
- want.push(["router.fmgr()", rd(c.addresses.router, routerAbi, "fmgr"), c.addresses.fPoolManager]);
268
- want.push(["lens.fmgr()", rd(c.addresses.lens, lensAbi, "fmgr"), c.addresses.fPoolManager]);
325
+ if (hasC(c)) {
326
+ want.push(["routerC.mgr()", rd(c.addresses.routerC, routerCAbi, "mgr"), c.addresses.managerC]);
327
+ want.push(["routerC.permit2()", rd(c.addresses.routerC, routerCAbi, "permit2"), c.addresses.permit2 ?? ZERO]);
328
+ want.push(["lensC.mgr()", rd(c.addresses.lensC, lensCAbi, "mgr"), c.addresses.managerC]);
269
329
  }
270
330
  const got = await Promise.all(want.map((w) => w[1]));
271
331
  const bad = want.flatMap(([what, , expected], i) => got[i].toLowerCase() === expected.toLowerCase() ? [] : [`${what} is ${got[i]}, expected ${expected}`]);
package/dist/fees.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Both equal φ·L·|Δx| summed over the swap's segments — the same φ·|dx| per unit L that `F` books.
12
12
  */
13
- import type { LogswapClient } from "./client.js";
13
+ import { type LogswapClient } from "./client.js";
14
14
  import type { DiscoveredMarket } from "./pools.js";
15
15
  /**
16
16
  * The fee one swap paid, in quote, from its `Swap` event's fields.
package/dist/fees.js CHANGED
@@ -10,14 +10,15 @@
10
10
  *
11
11
  * Both equal φ·L·|Δx| summed over the swap's segments — the same φ·|dx| per unit L that `F` books.
12
12
  */
13
- import { cPoolManagerAbi } from "./generated.js";
13
+ import { managerC } from "./client.js";
14
+ import { managerCAbi } from "./generated.js";
14
15
  import { getEventLogs } from "./history.js";
15
16
  import { swapFlows } from "./views.js";
16
17
  /** A C market's swap fees over [fromBlock, toBlock] from the indexer's swap_flow view; null when the indexer cannot answer. */
17
18
  async function windowFromView(c, indexer, poolId, fromBlock, toBlock) {
18
19
  try {
19
20
  const rows = await swapFlows(indexer, {
20
- condition: { side: "C", poolId: poolId.toLowerCase(), manager: c.addresses.cPoolManager.toLowerCase() },
21
+ condition: { side: "C", poolId: poolId.toLowerCase(), manager: managerC(c).toLowerCase() },
21
22
  filter: { blockNumber: { greaterThanOrEqualTo: fromBlock.toString(), lessThanOrEqualTo: toBlock.toString() } },
22
23
  });
23
24
  let fees = 0n;
@@ -102,7 +103,7 @@ export async function swapFees(c, m, opts = {}) {
102
103
  fromBlock = m.blockNumber;
103
104
  from = opened.timestamp;
104
105
  }
105
- const ev = cPoolManagerAbi.find((x) => x.type === "event" && x.name === "Swap");
106
+ const ev = managerCAbi.find((x) => x.type === "event" && x.name === "Swap");
106
107
  if (!ev)
107
108
  throw new Error("logswap: Swap event missing from the generated ABI");
108
109
  // the event carries the fee the swap charged (decisions 050), exactly — no re-derivation from φ;
@@ -115,7 +116,7 @@ export async function swapFees(c, m, opts = {}) {
115
116
  ({ fees, swaps } = viewed);
116
117
  }
117
118
  else if (fromBlock <= toBlock) {
118
- const { logs } = await getEventLogs(c, { indexer, address: c.addresses.cPoolManager, event: ev, args: { poolId: m.poolId }, fromBlock, toBlock });
119
+ const { logs } = await getEventLogs(c, { indexer, address: managerC(c), event: ev, args: { poolId: m.poolId }, fromBlock, toBlock });
119
120
  for (const l of logs)
120
121
  fees += l.args.fee;
121
122
  swaps = logs.length;