@logswap/sdk 0.5.75 → 0.5.76

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
@@ -84,6 +84,38 @@ answers only partly.
84
84
  shared tables with `contract: indexedContractOf(kind, event)` (or `kind` on `getEventsLogs`).
85
85
  - `tokensCreated` lists the factory's tokens (`addresses.tokenFactory`): the token list's provenance.
86
86
 
87
+ ## Indexer views (indexing phase 2)
88
+
89
+ The indexer also serves derived views (logswap-be `devnet/VIEWS.md`), joining its event tables with
90
+ the snapshotter's state. `views.ts` reads each as typed rows: amounts as `bigint`, prices, APYs and
91
+ progress as `number`, times as unix seconds. Every reader takes the GraphQL endpoint and a
92
+ `{ condition, filter, orderBy, first, signal }` query, and pages by offset.
93
+
94
+ | Reader | View | What a row is |
95
+ | --- | --- | --- |
96
+ | `poolDirectory` | `allPoolDirectories` | a pool of either manager, its kind and birth |
97
+ | `eventUsers` | `allEventUsers` | a manager event and who did it (the router's caller when routed) |
98
+ | `poolHolders` | `allPoolHolders` | a current ERC-6909 balance, with C's backstop and F's dead shares flagged |
99
+ | `walletPositions` | `allWalletPositions` | a wallet's holding; F valued at the latest share value |
100
+ | `walletPoolFlows` | `allWalletPoolFlows` | a wallet's in/out, fees and dividends per pool |
101
+ | `swapFlows` | `allSwapFlows` | a swap's volume and fee in quote |
102
+ | `priceTicks` | `allPriceTicks` | a price point per (pool, base) |
103
+ | `candles(url, "minute" \| "hour" \| "day")` | `allCandle…s` | OHLC with volume and fees |
104
+ | `poolTvlHours` | `allPoolTvlHours` | the hour's last snapshot: TVL, liquidity |
105
+ | `poolSummaries` | `allPoolSummaries` | 24 h / 7 d volume, fees, APY; latest TVL |
106
+ | `generationSteps` | `allGenerationSteps` | a `regenerate` step and its pot split |
107
+ | `padStatuses` | `allPadStatuses` | each pad and POL now, with the next threshold and progress |
108
+ | `protocolRevenueDays` | `allProtocolRevenueDays` | protocol revenue per day and source |
109
+
110
+ Given an `indexer`, three functions now take their figure from a view and keep their previous path
111
+ as the fallback, with the same answer on the same data:
112
+ - `holdingsOf`: the owner's held class ids from `pool_holder`, then the lens as before;
113
+ - `fPoolShareHolders`: the holders from `pool_holder`;
114
+ - `swapFees`: the window from `swap_flow`.
115
+
116
+ What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `legsOf`,
117
+ `heldByIds`, `fDividendOf`). They accrue without events, so no view holds them.
118
+
87
119
  ## Capped F pools and the lien (F version 25)
88
120
 
89
121
  - **The cap** (decisions 061) is a key field: `FPoolKey.cap` / `FPoolCreateArgs.cap`, d =
package/dist/fees.d.ts CHANGED
@@ -55,7 +55,7 @@ export declare function blockAtOrAfter(c: LogswapClient, t: bigint, lo: bigint,
55
55
  export declare function swapFees(c: LogswapClient, m: DiscoveredMarket, opts?: {
56
56
  since?: bigint;
57
57
  fromBlock?: bigint;
58
- toBlock?: bigint; /** The rindexer GraphQL endpoint: the Swap rows from there, the node otherwise. */
58
+ toBlock?: bigint; /** The rindexer GraphQL endpoint: the window from its swap_flow view (the Swap rows as fallback), the node otherwise. */
59
59
  indexer?: string;
60
60
  }): Promise<SwapFeeWindow>;
61
61
  /**
package/dist/fees.js CHANGED
@@ -12,6 +12,23 @@
12
12
  */
13
13
  import { cPoolManagerAbi } from "./generated.js";
14
14
  import { getEventLogs } from "./history.js";
15
+ import { swapFlows } from "./views.js";
16
+ /** A C market's swap fees over [fromBlock, toBlock] from the indexer's swap_flow view; null when the indexer cannot answer. */
17
+ async function windowFromView(c, indexer, poolId, fromBlock, toBlock) {
18
+ try {
19
+ const rows = await swapFlows(indexer, {
20
+ condition: { side: "C", poolId: poolId.toLowerCase(), manager: c.addresses.cPoolManager.toLowerCase() },
21
+ filter: { blockNumber: { greaterThanOrEqualTo: fromBlock.toString(), lessThanOrEqualTo: toBlock.toString() } },
22
+ });
23
+ let fees = 0n;
24
+ for (const r of rows)
25
+ fees += r.feeQuote;
26
+ return { fees, swaps: rows.length };
27
+ }
28
+ catch {
29
+ return null; // the view is a cache: the Swap rows answer the same
30
+ }
31
+ }
15
32
  const WAD = 10n ** 18n;
16
33
  const YEAR_SECONDS = 31_536_000;
17
34
  /**
@@ -88,15 +105,22 @@ export async function swapFees(c, m, opts = {}) {
88
105
  const ev = cPoolManagerAbi.find((x) => x.type === "event" && x.name === "Swap");
89
106
  if (!ev)
90
107
  throw new Error("logswap: Swap event missing from the generated ABI");
91
- const logs = fromBlock > toBlock
92
- ? []
93
- : (await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.cPoolManager, event: ev, args: { poolId: m.poolId }, fromBlock, toBlock })).logs;
94
- // the event carries the fee the swap charged (decisions 050), exactly — no re-derivation from φ
108
+ // the event carries the fee the swap charged (decisions 050), exactly — no re-derivation from φ;
109
+ // the indexer's swap_flow view carries the same figure per swap (`feeQuote`, C)
95
110
  let fees = 0n;
96
- for (const l of logs)
97
- fees += l.args.fee;
111
+ let swaps = 0;
112
+ const viewed = fromBlock > toBlock || !opts.indexer ? null : await windowFromView(c, opts.indexer, m.poolId, fromBlock, toBlock);
113
+ if (viewed) {
114
+ ({ fees, swaps } = viewed);
115
+ }
116
+ else if (fromBlock <= toBlock) {
117
+ const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.cPoolManager, event: ev, args: { poolId: m.poolId }, fromBlock, toBlock });
118
+ for (const l of logs)
119
+ fees += l.args.fee;
120
+ swaps = logs.length;
121
+ }
98
122
  const to = last.timestamp;
99
- return { fromBlock, toBlock, from, to, seconds: to > from ? to - from : 0n, swapFees: fees, swaps: logs.length };
123
+ return { fromBlock, toBlock, from, to, seconds: to > from ? to - from : 0n, swapFees: fees, swaps };
100
124
  }
101
125
  /**
102
126
  * The window's swap fees over the market's CURRENT active L, annualised linearly over the window.
package/dist/fpool.d.ts CHANGED
@@ -1914,7 +1914,7 @@ export declare function fPoolsControlledBy(c: LogswapClient, who: Address, opts?
1914
1914
  /**
1915
1915
  * Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
1916
1916
  * topic, so one filtered log query aggregates the whole ledger. The 0xdead entry is the
1917
- * MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: a node
1917
+ * 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
1918
1918
  * prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
1919
1919
  * holder minted before the cut.
1920
1920
  */
package/dist/fpool.js CHANGED
@@ -47,6 +47,7 @@ export { fPoolManagerAbi, padPolicyAbi, polPolicyAbi, privatePolicyAbi, publicPo
47
47
  export const fPolicyBaseAbi = polPolicyAbi;
48
48
  import { fallBackUnlessRejected, signerFor } from "./write.js";
49
49
  import { getEventLogs } from "./history.js";
50
+ import { poolHolders } from "./views.js";
50
51
  import { presetMintFee } from "./positions.js";
51
52
  const WAD = 10n ** 18n;
52
53
  const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
@@ -1422,7 +1423,7 @@ export async function fPoolsControlledBy(c, who, opts = {}) {
1422
1423
  /**
1423
1424
  * Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
1424
1425
  * topic, so one filtered log query aggregates the whole ledger. The 0xdead entry is the
1425
- * MIN_SHARES lock from seeding; callers usually label rather than hide it. Pass `indexer`: a node
1426
+ * 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
1426
1427
  * prunes its logs (anvil keeps about a day), and a ledger rebuilt from a pruned stream loses every
1427
1428
  * holder minted before the cut.
1428
1429
  */
@@ -1430,7 +1431,20 @@ export async function fPoolShareHolders(c, poolIdHex, opts = {}) {
1430
1431
  const ev = fPoolManagerAbi.find((x) => x.type === "event" && x.name === "Transfer");
1431
1432
  if (!ev)
1432
1433
  throw new Error("logswap: 6909 Transfer event missing from the generated ABI");
1433
- const id = fPoolShareId(poolIdHex, opts.gen ?? (await fPoolGen(c, poolIdHex)));
1434
+ const gen = opts.gen ?? (await fPoolGen(c, poolIdHex));
1435
+ if (opts.indexer) {
1436
+ try {
1437
+ const rows = await poolHolders(opts.indexer, { condition: { side: "F", poolId: poolIdHex.toLowerCase(), gen: Number(gen), manager: c.addresses.fPoolManager.toLowerCase() } });
1438
+ return rows
1439
+ .filter((r) => r.balance > 0n)
1440
+ .map((r) => ({ holder: r.holder, shares: r.balance }))
1441
+ .sort((a, b) => (b.shares > a.shares ? 1 : -1));
1442
+ }
1443
+ catch {
1444
+ /* the view is a cache: the Transfer replay below answers the same */
1445
+ }
1446
+ }
1447
+ const id = fPoolShareId(poolIdHex, gen);
1434
1448
  const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.fPoolManager, event: ev, args: { id }, fromBlock: opts.fromBlock });
1435
1449
  const bal = new Map();
1436
1450
  for (const l of logs) {
package/dist/index.d.ts CHANGED
@@ -21,5 +21,6 @@ export * from "./tokencache.js";
21
21
  export * from "./fpool.js";
22
22
  export * from "./fees.js";
23
23
  export * from "./history.js";
24
+ export * from "./views.js";
24
25
  export { cPoolManagerAbi, fPoolManagerAbi, logswapLensAbi, logswapRouterAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
25
26
  export * from "./admin.js";
package/dist/index.js CHANGED
@@ -21,5 +21,6 @@ export * from "./tokencache.js";
21
21
  export * from "./fpool.js";
22
22
  export * from "./fees.js";
23
23
  export * from "./history.js";
24
+ export * from "./views.js";
24
25
  export { cPoolManagerAbi, fPoolManagerAbi, logswapLensAbi, logswapRouterAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, privatePolicyAbi, publicPolicyAbi } from "./generated.js";
25
26
  export * from "./admin.js";
package/dist/positions.js CHANGED
@@ -13,6 +13,7 @@ const C_POSITIONS_SLOT = 4n;
13
13
  const U128 = (1n << 128n) - 1n;
14
14
  import { isPosition, NO_CAP, positionId, unpackFloorCap } from "./ids.js";
15
15
  import { getEventLogs } from "./history.js";
16
+ import { poolHolders } from "./views.js";
16
17
  /**
17
18
  * A class's aggregate state, read through `extsload` (C version 7: the manager's public
18
19
  * `positions` mapping is gone behind it, decisions 065). The slot is `CPoolState`'s:
@@ -182,6 +183,21 @@ export async function positionsOf(c, key, owner) {
182
183
  return rows.map((r) => ({ id: r.id, floor: r.floor, cap: NO_CAP, capped: false, shares: r.shares, L: r.L, fees: r.fees }));
183
184
  }
184
185
  const ID_REGISTERED = parseAbiItem("event IdRegistered(uint256 indexed id, bytes32 indexed poolId, int256 floor, int256 cap, bool capped)");
186
+ /** The class ids `owner` holds in `pool`, from the indexer's `pool_holder` view; null when the indexer cannot answer. */
187
+ async function heldIdsFromView(c, indexer, pool, owner) {
188
+ try {
189
+ const rows = await poolHolders(indexer, { condition: { side: "C", poolId: pool.toLowerCase(), holder: owner.toLowerCase(), manager: c.addresses.cPoolManager.toLowerCase() } });
190
+ return rows.filter((r) => r.balance > 0n && !r.isBackstop).map((r) => r.id);
191
+ }
192
+ catch {
193
+ return null; // the view is a cache: the IdRegistered replay below answers the same
194
+ }
195
+ }
196
+ /** Every class id ever registered in `pool` (`IdRegistered`), from the indexer's table or the node. */
197
+ async function registeredIds(c, pool, fromBlock, indexer) {
198
+ const { logs } = await getEventLogs(c, { indexer, address: c.addresses.cPoolManager, event: ID_REGISTERED, args: { poolId: pool }, fromBlock });
199
+ return logs.map((l) => l.args.id ?? 0n).filter((id) => id !== 0n);
200
+ }
185
201
  /**
186
202
  * EVERY class this owner holds in a pool, capped ones included — the complete book.
187
203
  *
@@ -194,8 +210,7 @@ const ID_REGISTERED = parseAbiItem("event IdRegistered(uint256 indexed id, bytes
194
210
  */
195
211
  export async function holdingsOf(c, key, owner, fromBlock = 0n, opts = {}) {
196
212
  const pool = poolId(key);
197
- const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.cPoolManager, event: ID_REGISTERED, args: { poolId: pool }, fromBlock });
198
- const ids = logs.map((l) => l.args.id ?? 0n).filter((id) => id !== 0n);
213
+ const ids = (opts.indexer ? await heldIdsFromView(c, opts.indexer, pool, owner) : null) ?? (await registeredIds(c, pool, fromBlock, opts.indexer));
199
214
  if (ids.length === 0)
200
215
  return [];
201
216
  // one lens call: balance, class L, fees, floor and cap for every id the owner holds
@@ -0,0 +1,285 @@
1
+ /**
2
+ * views.ts — the indexer's derived views (indexing phase 2, logswap-be `devnet/VIEWS.md`).
3
+ *
4
+ * The indexer records events and the snapshotter samples state; these views join the two in
5
+ * Postgres: holders, a wallet's positions and flows, per-swap volume and fee, price points and
6
+ * candles, TVL by the hour, the pools table's 24 h / 7 d figures, the generation steps and pad
7
+ * status, protocol revenue by day, and who did each routed action. Each reader returns typed rows:
8
+ *
9
+ * - **amounts** (Postgres `numeric`, GraphQL BigFloat strings) as `bigint`. The views floor every
10
+ * amount they compute, so the integer part is the value;
11
+ * - **prices, APYs, progress** (`double precision`) as `number`. `priceRaw` is quote wei per base
12
+ * wei: scale by 10^(baseDecimals − quoteDecimals) to display;
13
+ * - **times** as unix seconds (`number`), **addresses** checksummed, pool ids lowercase `0x…`.
14
+ *
15
+ * A view is a cache like any indexed table: the readers throw when the indexer cannot answer, and
16
+ * the SDK functions that use them ({@link holdingsOf}, {@link swapFees}, {@link fPoolShareHolders})
17
+ * keep their node path as the fallback.
18
+ */
19
+ import { type Address, type Hex } from "viem";
20
+ /** What a view query takes: postgraphile's `condition` (equality), `filter` (the connection-filter plugin's operators), an `orderBy` of the view's enum names, a row cap. */
21
+ export interface ViewQuery {
22
+ condition?: Record<string, unknown>;
23
+ filter?: Record<string, unknown>;
24
+ /** e.g. `["BLOCK_NUMBER_ASC"]`, `["VOLUME_24H_DESC"]`: the column's CONSTANT_CASE name and a direction. */
25
+ orderBy?: string[];
26
+ /** At most this many rows (one page up to 1000). All rows when omitted. */
27
+ first?: number;
28
+ signal?: AbortSignal;
29
+ }
30
+ export type Side = "C" | "F";
31
+ /** A pool of either manager: C markets are kind `market`; F pools carry their policy's registry name (`public`, `private`, `pol`, `pad`). */
32
+ export interface PoolDirectoryRow {
33
+ side: Side;
34
+ poolId: Hex;
35
+ manager: Address;
36
+ kind: string;
37
+ quote: Address;
38
+ bases: Address[];
39
+ swapFee: bigint;
40
+ /** C only. */
41
+ tickSpacing: bigint | null;
42
+ /** F only. */
43
+ policy: Address | null;
44
+ creator: Address | null;
45
+ birthBlock: bigint;
46
+ birthTime: number;
47
+ /** F only: the pool's share-id key (the id's bits above the generation). */
48
+ shareKey: bigint | null;
49
+ }
50
+ export declare function poolDirectory(url: string, q?: ViewQuery): Promise<PoolDirectoryRow[]>;
51
+ /** A manager event and who did it: the router's caller when the transaction went through the router (`viaRouter`), else the address the event names (`actor`). */
52
+ export interface EventUserRow {
53
+ side: Side;
54
+ /** `Swap` `Mint` `Burn` `Update` `Claim` (C); `FSwap` `FMint` `FBurn` `Harvest` `DividendClaimed` `Redeem` (F). */
55
+ event: string;
56
+ poolId: Hex;
57
+ actor: Address;
58
+ viaRouter: boolean;
59
+ user: Address;
60
+ txHash: Hex;
61
+ logIndex: number;
62
+ blockNumber: bigint;
63
+ blockTimestamp: number;
64
+ manager: Address;
65
+ }
66
+ export declare function eventUsers(url: string, q?: ViewQuery): Promise<EventUserRow[]>;
67
+ /** A current ERC-6909 balance: C ids resolve to their class (floor, cap), F ids to their pool and generation. C's backstop lock is held by address(0) (`isBackstop`), F's dead shares by 0xdead (`isDead`). */
68
+ export interface PoolHolderRow {
69
+ side: Side;
70
+ manager: Address;
71
+ id: bigint;
72
+ poolId: Hex | null;
73
+ /** F only. */
74
+ gen: number | null;
75
+ /** C only. */
76
+ floor: bigint | null;
77
+ cap: bigint | null;
78
+ capped: boolean | null;
79
+ holder: Address;
80
+ balance: bigint;
81
+ isBackstop: boolean;
82
+ isDead: boolean;
83
+ }
84
+ export declare function poolHolders(url: string, q?: ViewQuery): Promise<PoolHolderRow[]>;
85
+ /** A wallet's holding (backstop and dead excluded). `valueQuote`: an F share of the live generation at the latest snapshot's share value, a retired one at its bundle's quote per share; NULL for C (a lens read: {@link legsOf}). */
86
+ export interface WalletPositionRow {
87
+ side: Side;
88
+ manager: Address;
89
+ wallet: Address;
90
+ poolId: Hex | null;
91
+ kind: string | null;
92
+ quote: Address | null;
93
+ bases: Address[];
94
+ id: bigint;
95
+ gen: number | null;
96
+ floor: bigint | null;
97
+ cap: bigint | null;
98
+ capped: boolean | null;
99
+ shares: bigint;
100
+ valueQuote: bigint | null;
101
+ /** `live` / `retired` / `unknown` (F), `class` (C). */
102
+ status: string;
103
+ valuedAtBlock: bigint | null;
104
+ }
105
+ export declare function walletPositions(url: string, q?: ViewQuery): Promise<WalletPositionRow[]>;
106
+ /** A wallet's flows in a pool, from its own events: what it put in and took out, fees and dividends realised. F mints and burns carry the quote leg only. C `Update` is not counted (it repeats its Burn and Mint). */
107
+ export interface WalletPoolFlowRow {
108
+ side: Side;
109
+ manager: Address;
110
+ wallet: Address;
111
+ poolId: Hex;
112
+ baseIn: bigint;
113
+ quoteIn: bigint;
114
+ baseOut: bigint;
115
+ quoteOut: bigint;
116
+ feesRealised: bigint;
117
+ dividendsClaimed: bigint;
118
+ redeemedQuote: bigint;
119
+ entries: number;
120
+ exits: number;
121
+ firstTime: number;
122
+ lastTime: number;
123
+ }
124
+ export declare function walletPoolFlows(url: string, q?: ViewQuery): Promise<WalletPoolFlowRow[]>;
125
+ /** A swap's volume and fee in quote, the app's definitions (C: the quote leg and the event's fee; F: see VIEWS.md). F rows carry the traded legs and their L_j = w_j·L. */
126
+ export interface SwapFlowRow {
127
+ side: Side;
128
+ manager: Address;
129
+ poolId: Hex;
130
+ txHash: Hex;
131
+ logIndex: number;
132
+ blockNumber: bigint;
133
+ blockTimestamp: number;
134
+ volumeQuote: bigint;
135
+ feeQuote: bigint;
136
+ tokenIn: Address | null;
137
+ tokenOut: Address | null;
138
+ reserveIn: bigint | null;
139
+ reserveOut: bigint | null;
140
+ lIn: bigint | null;
141
+ lOut: bigint | null;
142
+ }
143
+ export declare function swapFlows(url: string, q?: ViewQuery): Promise<SwapFlowRow[]>;
144
+ /** A price point per (pool, base) after a swap: C e^newX, F the traded leg's mark L_j / R_j. Quote wei per base wei. */
145
+ export interface PriceTickRow {
146
+ side: Side;
147
+ poolId: Hex;
148
+ base: Address;
149
+ blockNumber: bigint;
150
+ blockTimestamp: number;
151
+ logIndex: number;
152
+ priceRaw: number;
153
+ volumeQuote: bigint;
154
+ feeQuote: bigint;
155
+ }
156
+ export declare function priceTicks(url: string, q?: ViewQuery): Promise<PriceTickRow[]>;
157
+ /** OHLC per (pool, base, UTC bucket). A base → base F swap counts in both legs' candles; pool totals come from {@link poolSummaries}. */
158
+ export interface CandleRow {
159
+ side: Side;
160
+ poolId: Hex;
161
+ base: Address;
162
+ /** Bucket start, unix seconds. */
163
+ bucket: number;
164
+ open: number;
165
+ high: number;
166
+ low: number;
167
+ close: number;
168
+ volumeQuote: bigint;
169
+ feeQuote: bigint;
170
+ swaps: number;
171
+ }
172
+ export type CandleInterval = "minute" | "hour" | "day";
173
+ export declare function candles(url: string, interval: CandleInterval, q?: ViewQuery): Promise<CandleRow[]>;
174
+ /** The hour's last snapshot per pool (forward-fill hours with none). `liquidity` is C's active L or F's L. */
175
+ export interface PoolTvlHourRow {
176
+ side: Side;
177
+ poolId: Hex;
178
+ bucket: number;
179
+ blockNumber: bigint;
180
+ tvlQuote: bigint | null;
181
+ liquidity: bigint | null;
182
+ /** C only. */
183
+ priceRaw: number | null;
184
+ feeGrowth: bigint | null;
185
+ /** F only. */
186
+ shareValue: bigint | null;
187
+ gen: number | null;
188
+ }
189
+ export declare function poolTvlHours(url: string, q?: ViewQuery): Promise<PoolTvlHourRow[]>;
190
+ /**
191
+ * A pool's trailing 24 h / 7 d figures and its latest state. APY, as the app shows it: the window's
192
+ * swap fees over the pool's current L, annualised over the window measured (clipped to the pool's
193
+ * birth) — `fees / L × 31 536 000 / seconds`; the same formula as {@link swapFeeApy}.
194
+ */
195
+ export interface PoolSummaryRow {
196
+ side: Side;
197
+ poolId: Hex;
198
+ kind: string;
199
+ quote: Address;
200
+ bases: Address[];
201
+ swapFee: bigint;
202
+ birthTime: number;
203
+ volume24h: bigint;
204
+ fees24h: bigint;
205
+ swaps24h: number;
206
+ volume7d: bigint;
207
+ fees7d: bigint;
208
+ volumeAll: bigint;
209
+ feesAll: bigint;
210
+ lastSwap: number | null;
211
+ tvlQuote: bigint | null;
212
+ liquidity: bigint | null;
213
+ priceRaw: number | null;
214
+ shareValue: bigint | null;
215
+ gen: number | null;
216
+ stateBlock: bigint | null;
217
+ seconds24h: number;
218
+ seconds7d: number;
219
+ apy24h: number | null;
220
+ apy7d: number | null;
221
+ }
222
+ export declare function poolSummaries(url: string, q?: ViewQuery): Promise<PoolSummaryRow[]>;
223
+ /** A `regenerate` step: the pot and its split (payee, the protocol's cut, the burn, the rest deepening the bid); a pad's `rung` from `Graduated`. */
224
+ export interface GenerationStepRow {
225
+ kind: string | null;
226
+ poolId: Hex;
227
+ /** The pool's generation after this step. */
228
+ genAfter: number;
229
+ pot: bigint;
230
+ payee: Address;
231
+ toPayee: bigint;
232
+ cut: bigint;
233
+ burnt: bigint;
234
+ deepened: bigint;
235
+ rung: number | null;
236
+ txHash: Hex;
237
+ blockNumber: bigint;
238
+ blockTimestamp: number;
239
+ }
240
+ export declare function generationSteps(url: string, q?: ViewQuery): Promise<GenerationStepRow[]>;
241
+ /** Every pad and POL now: the latest snapshot's state, the next graduation's threshold (pads) and the pot's progress to it, and the steps so far. */
242
+ export interface PadStatusRow {
243
+ kind: string;
244
+ poolId: Hex;
245
+ quote: Address;
246
+ bases: Address[];
247
+ creator: Address | null;
248
+ birthTime: number;
249
+ gen: number | null;
250
+ pot: bigint | null;
251
+ unharvested: bigint | null;
252
+ l: bigint | null;
253
+ q: bigint | null;
254
+ tvlQuote: bigint | null;
255
+ shareValue: bigint | null;
256
+ threshold: bigint | null;
257
+ /** pot / threshold, a fraction; null without a threshold. */
258
+ progress: number | null;
259
+ stateBlock: bigint | null;
260
+ stateTime: number | null;
261
+ steps: number;
262
+ burntTotal: bigint;
263
+ cutTotal: bigint;
264
+ paidTotal: bigint;
265
+ deepenedTotal: bigint;
266
+ lastStep: number | null;
267
+ }
268
+ export declare function padStatuses(url: string, q?: ViewQuery): Promise<PadStatusRow[]>;
269
+ /**
270
+ * Protocol revenue per UTC day, side, source and token. Sources: F `mint_fee` (shares minted to the
271
+ * collector, valued at the share value) and `pot_cut`; C `accrued` (the swap-fee tax and the mint fee
272
+ * together, from the snapshots) and `collected` — basis `collected`, cash moved, not revenue on top
273
+ * of `accrued`.
274
+ */
275
+ export interface ProtocolRevenueDayRow {
276
+ day: number;
277
+ side: Side;
278
+ source: string;
279
+ basis: "earned" | "collected";
280
+ token: Address;
281
+ amount: bigint;
282
+ amountQuote: bigint;
283
+ events: number;
284
+ }
285
+ export declare function protocolRevenueDays(url: string, q?: ViewQuery): Promise<ProtocolRevenueDayRow[]>;