@logswap/sdk 0.5.77 → 0.5.78
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 +3 -3
- package/dist/admin.d.ts +1 -1
- package/dist/admin.js +1 -1
- package/dist/client.d.ts +5 -2
- package/dist/client.js +8 -2
- package/dist/fpool.d.ts +3 -3
- package/dist/fpool.js +7 -7
- package/dist/generated.d.ts +365 -276
- package/dist/generated.js +367 -251
- package/dist/history.js +2 -2
- package/dist/indexer.d.ts +4 -4
- package/dist/indexer.js +6 -6
- package/dist/pools.d.ts +5 -5
- package/dist/pools.js +4 -4
- package/dist/positions.d.ts +4 -4
- package/dist/positions.js +6 -6
- package/package.json +1 -1
- package/src/admin.ts +1 -1
- package/src/client.ts +8 -2
- package/src/fpool.ts +11 -11
- package/src/generated.ts +367 -251
- package/src/history.ts +2 -2
- package/src/indexer.ts +6 -6
- package/src/pools.ts +9 -9
- package/src/positions.ts +7 -7
package/dist/history.js
CHANGED
|
@@ -44,7 +44,7 @@ function contractName(c, address, event) {
|
|
|
44
44
|
const is = (x) => x !== undefined && a === x.toLowerCase();
|
|
45
45
|
const { addresses: d } = c;
|
|
46
46
|
if (is(d.cPoolManager))
|
|
47
|
-
return "
|
|
47
|
+
return "CPoolManager";
|
|
48
48
|
if (is(d.fPoolManager))
|
|
49
49
|
return "FPoolManager";
|
|
50
50
|
if (is(d.router))
|
|
@@ -74,7 +74,7 @@ export function indexedContractOf(kind, event) {
|
|
|
74
74
|
}
|
|
75
75
|
/** Events whose name two indexed contracts share: postgraphile prefixes their tables. */
|
|
76
76
|
// `CollectorProposed` / `CollectorAccepted` are C 7 / F 26 and older; `TreasuryProposed` / `TreasuryAccepted` replace them (066).
|
|
77
|
-
const SHARED = new Set(["Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved", "Listed"]);
|
|
77
|
+
const SHARED = new Set(["Swap", "Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved", "Listed"]);
|
|
78
78
|
const plural = (n) => (/(s|x|ch|sh)$/.test(n) ? `${n}es` : `${n}s`);
|
|
79
79
|
/** A column's GraphQL name: postgraphile camelCases the snake_case rindexer writes (`F` → `f`). */
|
|
80
80
|
const column = (name) => name[0].toLowerCase() + name.slice(1);
|
package/dist/indexer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The division of labour matters and is not arbitrary: **the indexer enumerates, the chain
|
|
5
5
|
* values.** ERC-6909 has no enumeration, so there is no way to ask a node "which positions exist in
|
|
6
|
-
* this pool" — only the `
|
|
6
|
+
* this pool" — only the `ClassRegistered` log knows. But an indexed row is a historical fact, and `L`
|
|
7
7
|
* changes with every mint, burn and harvest afterwards. So ids come from here and the current `L`
|
|
8
8
|
* is read on-chain, rather than trusting a number that was true at index time.
|
|
9
9
|
*/
|
|
@@ -72,7 +72,7 @@ export declare function indexerHealthy(url: string, signal?: AbortSignal): Promi
|
|
|
72
72
|
/**
|
|
73
73
|
* Markets, from the indexer rather than a log scan.
|
|
74
74
|
*
|
|
75
|
-
* `discoverMarkets` reads `
|
|
75
|
+
* `discoverMarkets` reads `MarketCreated` logs straight from the node, which is correct until the node
|
|
76
76
|
* stops keeping them. anvil's `--prune-history` drops historical transactions and receipts beyond a
|
|
77
77
|
* window, so on a devnet that mines steadily the deployment's own logs age out and a scan from
|
|
78
78
|
* block 0 returns nothing — while the contracts remain perfectly alive. Any real chain has the same
|
|
@@ -82,7 +82,7 @@ export declare function indexerHealthy(url: string, signal?: AbortSignal): Promi
|
|
|
82
82
|
* the more durable path and should be preferred wherever an indexer is configured, with the log
|
|
83
83
|
* scan as the fallback for when it is not.
|
|
84
84
|
*
|
|
85
|
-
* `
|
|
85
|
+
* `MarketCreated` carries every field of the `PoolKey`, so the key is rebuilt exactly and `poolId` is
|
|
86
86
|
* recomputed locally rather than trusted from the row — the same offline derivation the SDK uses
|
|
87
87
|
* everywhere else, so a wrong id fails loudly instead of addressing the wrong pool.
|
|
88
88
|
*/
|
|
@@ -100,7 +100,7 @@ export declare function discoverMarketsBest(c: LogswapClient, url?: string | und
|
|
|
100
100
|
/**
|
|
101
101
|
* The UNCAPPED position classes of a pool, from the CHAIN alone: the lens enumerates live floors
|
|
102
102
|
* (one bitmap bit each), and an uncapped id is a pure function of (key, floor). No indexer.
|
|
103
|
-
* Capped classes need `
|
|
103
|
+
* Capped classes need `ClassRegistered` replay and are absent here — callers that also want those
|
|
104
104
|
* use the indexed `poolPositions` and fall back to this when the indexer is missing or stale.
|
|
105
105
|
*/
|
|
106
106
|
export declare function poolPositionsFromChain(c: LogswapClient, key: PoolKey, x: bigint): Promise<PoolPosition[]>;
|
package/dist/indexer.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The division of labour matters and is not arbitrary: **the indexer enumerates, the chain
|
|
5
5
|
* values.** ERC-6909 has no enumeration, so there is no way to ask a node "which positions exist in
|
|
6
|
-
* this pool" — only the `
|
|
6
|
+
* this pool" — only the `ClassRegistered` log knows. But an indexed row is a historical fact, and `L`
|
|
7
7
|
* changes with every mint, burn and harvest afterwards. So ids come from here and the current `L`
|
|
8
8
|
* is read on-chain, rather than trusting a number that was true at index time.
|
|
9
9
|
*/
|
|
@@ -81,7 +81,7 @@ export async function gqlAll(url, field, selection, opts = {}) {
|
|
|
81
81
|
}
|
|
82
82
|
/** Every position class ever registered in a pool. Historical — some may since have burnt to zero. */
|
|
83
83
|
export async function registeredIds(url, poolId, signal) {
|
|
84
|
-
const nodes = await gqlAll(url, "
|
|
84
|
+
const nodes = await gqlAll(url, "allClassRegistereds", "id floor cap capped", {
|
|
85
85
|
vars: { pool: { type: "String!", value: bytea(poolId) } },
|
|
86
86
|
condition: "{poolId: $pool}",
|
|
87
87
|
signal,
|
|
@@ -123,7 +123,7 @@ export async function indexerHealthy(url, signal) {
|
|
|
123
123
|
/**
|
|
124
124
|
* Markets, from the indexer rather than a log scan.
|
|
125
125
|
*
|
|
126
|
-
* `discoverMarkets` reads `
|
|
126
|
+
* `discoverMarkets` reads `MarketCreated` logs straight from the node, which is correct until the node
|
|
127
127
|
* stops keeping them. anvil's `--prune-history` drops historical transactions and receipts beyond a
|
|
128
128
|
* window, so on a devnet that mines steadily the deployment's own logs age out and a scan from
|
|
129
129
|
* block 0 returns nothing — while the contracts remain perfectly alive. Any real chain has the same
|
|
@@ -133,12 +133,12 @@ export async function indexerHealthy(url, signal) {
|
|
|
133
133
|
* the more durable path and should be preferred wherever an indexer is configured, with the log
|
|
134
134
|
* scan as the fallback for when it is not.
|
|
135
135
|
*
|
|
136
|
-
* `
|
|
136
|
+
* `MarketCreated` carries every field of the `PoolKey`, so the key is rebuilt exactly and `poolId` is
|
|
137
137
|
* recomputed locally rather than trusted from the row — the same offline derivation the SDK uses
|
|
138
138
|
* everywhere else, so a wrong id fails loudly instead of addressing the wrong pool.
|
|
139
139
|
*/
|
|
140
140
|
export async function discoverMarketsIndexed(url, signal) {
|
|
141
|
-
const nodes = await gqlAll(url, "
|
|
141
|
+
const nodes = await gqlAll(url, "allMarketCreateds", "poolId base quote tickSpacing swapFee x0 blockNumber txHash contractAddress", { signal });
|
|
142
142
|
return nodes.map((n) => {
|
|
143
143
|
const key = {
|
|
144
144
|
base: n.base,
|
|
@@ -185,7 +185,7 @@ export async function discoverMarketsBest(c, url = c.indexerUrl, signal) {
|
|
|
185
185
|
/**
|
|
186
186
|
* The UNCAPPED position classes of a pool, from the CHAIN alone: the lens enumerates live floors
|
|
187
187
|
* (one bitmap bit each), and an uncapped id is a pure function of (key, floor). No indexer.
|
|
188
|
-
* Capped classes need `
|
|
188
|
+
* Capped classes need `ClassRegistered` replay and are absent here — callers that also want those
|
|
189
189
|
* use the indexed `poolPositions` and fall back to this when the indexer is missing or stale.
|
|
190
190
|
*/
|
|
191
191
|
export async function poolPositionsFromChain(c, key, x) {
|
package/dist/pools.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Two things worth knowing before reading further.
|
|
5
5
|
*
|
|
6
|
-
* **Markets are discovered from logs, not configuration.** `
|
|
6
|
+
* **Markets are discovered from logs, not configuration.** `MarketCreated` carries the ENTIRE
|
|
7
7
|
* `PoolKey` in the clear, so a client can reconstruct any market's key — and therefore call any
|
|
8
8
|
* keyed function — having never been told the market exists. There is no registry to maintain.
|
|
9
9
|
*
|
|
@@ -99,7 +99,7 @@ export declare function cListable(price: number, baseDecimals: number, quoteDeci
|
|
|
99
99
|
* Signed: negative means variation has outrun fee income over the pool's life.
|
|
100
100
|
*/
|
|
101
101
|
export declare function lpEdge(state: Pick<PoolState, "F" | "bigSigma">): bigint;
|
|
102
|
-
/** A market discovered from
|
|
102
|
+
/** A market discovered from a `MarketCreated` log — the full key, plus where it was created. */
|
|
103
103
|
export interface DiscoveredMarket {
|
|
104
104
|
key: PoolKey;
|
|
105
105
|
poolId: Hex;
|
|
@@ -107,11 +107,11 @@ export interface DiscoveredMarket {
|
|
|
107
107
|
x0: bigint;
|
|
108
108
|
blockNumber: bigint;
|
|
109
109
|
transactionHash: Hex;
|
|
110
|
-
/** The manager that emitted the `
|
|
110
|
+
/** The manager that emitted the `MarketCreated` — set when the row came from the indexer. */
|
|
111
111
|
manager?: Address;
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* Enumerate markets from `
|
|
114
|
+
* Enumerate markets from `MarketCreated` logs.
|
|
115
115
|
*
|
|
116
116
|
* This is the whole market registry: the event carries every key field rather than just the id,
|
|
117
117
|
* deliberately, so nothing downstream needs a configured list. The scan starts at the client's
|
|
@@ -121,7 +121,7 @@ export declare function discoverMarkets(c: LogswapClient, opts?: {
|
|
|
121
121
|
fromBlock?: bigint;
|
|
122
122
|
toBlock?: bigint;
|
|
123
123
|
base?: Address;
|
|
124
|
-
quote?: Address; /** The rindexer GraphQL endpoint: `
|
|
124
|
+
quote?: Address; /** The rindexer GraphQL endpoint: `MarketCreated` from there, the node otherwise. */
|
|
125
125
|
indexer?: string;
|
|
126
126
|
}): Promise<DiscoveredMarket[]>;
|
|
127
127
|
/**
|
package/dist/pools.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Two things worth knowing before reading further.
|
|
5
5
|
*
|
|
6
|
-
* **Markets are discovered from logs, not configuration.** `
|
|
6
|
+
* **Markets are discovered from logs, not configuration.** `MarketCreated` carries the ENTIRE
|
|
7
7
|
* `PoolKey` in the clear, so a client can reconstruct any market's key — and therefore call any
|
|
8
8
|
* keyed function — having never been told the market exists. There is no registry to maintain.
|
|
9
9
|
*
|
|
@@ -103,16 +103,16 @@ export function lpEdge(state) {
|
|
|
103
103
|
return state.F - state.bigSigma / 2n;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
* Enumerate markets from `
|
|
106
|
+
* Enumerate markets from `MarketCreated` logs.
|
|
107
107
|
*
|
|
108
108
|
* This is the whole market registry: the event carries every key field rather than just the id,
|
|
109
109
|
* deliberately, so nothing downstream needs a configured list. The scan starts at the client's
|
|
110
110
|
* `deployBlock` unless `fromBlock` says otherwise.
|
|
111
111
|
*/
|
|
112
112
|
export async function discoverMarkets(c, opts = {}) {
|
|
113
|
-
const ev = cPoolManagerAbi.find((x) => x.type === "event" && x.name === "
|
|
113
|
+
const ev = cPoolManagerAbi.find((x) => x.type === "event" && x.name === "MarketCreated");
|
|
114
114
|
if (!ev)
|
|
115
|
-
throw new Error("logswap:
|
|
115
|
+
throw new Error("logswap: MarketCreated event missing from the generated ABI");
|
|
116
116
|
const args = {};
|
|
117
117
|
if (opts.base)
|
|
118
118
|
args.base = opts.base;
|
package/dist/positions.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare function getHolderPosition(c: LogswapClient, key: PoolKey, owner:
|
|
|
56
56
|
* Resolve an id the manager already knows back to its (pool, floor, cap).
|
|
57
57
|
*
|
|
58
58
|
* The inverse direction — id to class — needs the registry, because the id is a HASH: it cannot be
|
|
59
|
-
* unpacked offline the way `positionId` can be computed offline. `
|
|
59
|
+
* unpacked offline the way `positionId` can be computed offline. `ClassRegistered` carries the same
|
|
60
60
|
* information in the clear, so an indexer never needs this call.
|
|
61
61
|
*
|
|
62
62
|
* **Units.** The lens is inconsistent here and this wrapper hides it: `unpack` returns tick
|
|
@@ -83,7 +83,7 @@ export declare function partitionIds(ids: readonly bigint[]): {
|
|
|
83
83
|
positions: bigint[];
|
|
84
84
|
claims: bigint[];
|
|
85
85
|
};
|
|
86
|
-
/** Decode a class's floor and cap from its packed field (as carried by `
|
|
86
|
+
/** Decode a class's floor and cap from its packed field (as carried by `ClassRegistered`). */
|
|
87
87
|
export declare function describePacked(tickSpacing: bigint, packed: bigint): {
|
|
88
88
|
floor: bigint;
|
|
89
89
|
cap: bigint;
|
|
@@ -141,7 +141,7 @@ export declare function mintFee(p: {
|
|
|
141
141
|
* Every UNCAPPED position `owner` holds in a market, enumerated fully on-chain by the lens — a
|
|
142
142
|
* bitmap walk plus a balance check per live floor. No indexer, no log scan. Capped classes are
|
|
143
143
|
* not listed here by contract (their candidate set is quadratic in live ticks); they come from
|
|
144
|
-
* `
|
|
144
|
+
* `ClassRegistered` replay when an indexer exists.
|
|
145
145
|
*/
|
|
146
146
|
export interface HeldPositionRow {
|
|
147
147
|
id: bigint;
|
|
@@ -161,7 +161,7 @@ export declare function positionsOf(c: LogswapClient, key: PoolKey, owner: Addre
|
|
|
161
161
|
*
|
|
162
162
|
* `positionsOf` (the lens) enumerates the uncapped book from the ladder bitmap in one call and
|
|
163
163
|
* cannot list capped classes: a capped id is a (floor, cap) pair, quadratic in live ticks. This
|
|
164
|
-
* replays `
|
|
164
|
+
* replays `ClassRegistered` — every class is registered once, on first mint, with its floor and
|
|
165
165
|
* cap — then checks the owner's ERC-6909 balance on each and reads the class for its L, so the
|
|
166
166
|
* holder's slice is L · shares_owner / shares_class, and fees from the lens. One log query plus
|
|
167
167
|
* a read per registered class; fine for a pool's lifetime of classes.
|
package/dist/positions.js
CHANGED
|
@@ -81,7 +81,7 @@ export async function getHolderPosition(c, key, owner, floor, cap = NO_CAP) {
|
|
|
81
81
|
* Resolve an id the manager already knows back to its (pool, floor, cap).
|
|
82
82
|
*
|
|
83
83
|
* The inverse direction — id to class — needs the registry, because the id is a HASH: it cannot be
|
|
84
|
-
* unpacked offline the way `positionId` can be computed offline. `
|
|
84
|
+
* unpacked offline the way `positionId` can be computed offline. `ClassRegistered` carries the same
|
|
85
85
|
* information in the clear, so an indexer never needs this call.
|
|
86
86
|
*
|
|
87
87
|
* **Units.** The lens is inconsistent here and this wrapper hides it: `unpack` returns tick
|
|
@@ -119,7 +119,7 @@ export function partitionIds(ids) {
|
|
|
119
119
|
(isPosition(id) ? positions : claims).push(id);
|
|
120
120
|
return { positions, claims };
|
|
121
121
|
}
|
|
122
|
-
/** Decode a class's floor and cap from its packed field (as carried by `
|
|
122
|
+
/** Decode a class's floor and cap from its packed field (as carried by `ClassRegistered`). */
|
|
123
123
|
export function describePacked(tickSpacing, packed) {
|
|
124
124
|
return unpackFloorCap(tickSpacing, packed);
|
|
125
125
|
}
|
|
@@ -182,7 +182,7 @@ export async function positionsOf(c, key, owner) {
|
|
|
182
182
|
}));
|
|
183
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 }));
|
|
184
184
|
}
|
|
185
|
-
const ID_REGISTERED = parseAbiItem("event
|
|
185
|
+
const ID_REGISTERED = parseAbiItem("event ClassRegistered(uint256 indexed id, bytes32 indexed poolId, int256 floor, int256 cap, bool capped)");
|
|
186
186
|
/** The class ids `owner` holds in `pool`, from the indexer's `pool_holder` view; null when the indexer cannot answer. */
|
|
187
187
|
async function heldIdsFromView(c, indexer, pool, owner) {
|
|
188
188
|
try {
|
|
@@ -190,10 +190,10 @@ async function heldIdsFromView(c, indexer, pool, owner) {
|
|
|
190
190
|
return rows.filter((r) => r.balance > 0n && !r.isBackstop).map((r) => r.id);
|
|
191
191
|
}
|
|
192
192
|
catch {
|
|
193
|
-
return null; // the view is a cache: the
|
|
193
|
+
return null; // the view is a cache: the ClassRegistered replay below answers the same
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
/** Every class id ever registered in `pool` (`
|
|
196
|
+
/** Every class id ever registered in `pool` (`ClassRegistered`), from the indexer's table or the node. */
|
|
197
197
|
async function registeredIds(c, pool, fromBlock, indexer) {
|
|
198
198
|
const { logs } = await getEventLogs(c, { indexer, address: c.addresses.cPoolManager, event: ID_REGISTERED, args: { poolId: pool }, fromBlock });
|
|
199
199
|
return logs.map((l) => l.args.id ?? 0n).filter((id) => id !== 0n);
|
|
@@ -203,7 +203,7 @@ async function registeredIds(c, pool, fromBlock, indexer) {
|
|
|
203
203
|
*
|
|
204
204
|
* `positionsOf` (the lens) enumerates the uncapped book from the ladder bitmap in one call and
|
|
205
205
|
* cannot list capped classes: a capped id is a (floor, cap) pair, quadratic in live ticks. This
|
|
206
|
-
* replays `
|
|
206
|
+
* replays `ClassRegistered` — every class is registered once, on first mint, with its floor and
|
|
207
207
|
* cap — then checks the owner's ERC-6909 balance on each and reads the class for its L, so the
|
|
208
208
|
* holder's slice is L · shares_owner / shares_class, and fees from the lens. One log query plus
|
|
209
209
|
* a read per registered class; fine for a pool's lifetime of classes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logswap/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.78",
|
|
4
4
|
"description": "TypeScript SDK for Logswap, the liquidity primitive introducing the logarithmic invariant — typed wrappers over the CPoolManager / FPoolManager / Router / Lens surface.",
|
|
5
5
|
"license": "GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|
package/src/admin.ts
CHANGED
|
@@ -188,7 +188,7 @@ export async function setPolicyApproved(c: LogswapClient, policy: Address, appro
|
|
|
188
188
|
* answer); the operator and the lists void; no swap lands in the block.
|
|
189
189
|
*
|
|
190
190
|
* Pass the pool's `key` when in hand. Given only `poolId`, the key is rebuilt from the pool's
|
|
191
|
-
* `
|
|
191
|
+
* `PoolCreated` log ({@link fPoolKeyOfPool}) with `salt` (zero by default) and checked against
|
|
192
192
|
* the id — the log does not carry the salt, so a salted pool needs it named.
|
|
193
193
|
*/
|
|
194
194
|
export async function fPoolMigrate(
|
package/src/client.ts
CHANGED
|
@@ -176,8 +176,11 @@ function guardChain(wallet: WalletClient, pub: PublicClient): WalletClient {
|
|
|
176
176
|
* each market's, answered by the gate (`PublicPolicy.swapFeeTax`, the LOG Authority's) at birth and
|
|
177
177
|
* read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
|
|
178
178
|
* permissionless and pays the treasury. No pool id moved.
|
|
179
|
+
* 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
|
|
180
|
+
* takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
|
|
181
|
+
* `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
|
|
179
182
|
*/
|
|
180
|
-
export const EXPECTED_VERSION =
|
|
183
|
+
export const EXPECTED_VERSION = 9n;
|
|
181
184
|
/**
|
|
182
185
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
183
186
|
* 4 was the income-only harvest cut).
|
|
@@ -266,8 +269,11 @@ export const EXPECTED_VERSION = 8n;
|
|
|
266
269
|
// 29 (decision 068): the restructure guard and the registry's sunset read `block.timestamp` —
|
|
267
270
|
// `Pool.restructureBlock` is `restructureTime` (unix seconds, same slot), `PolicyRegistry.sunset(policy, untilTime)`.
|
|
268
271
|
// Names only: no pool id moved.
|
|
272
|
+
// 30 (decision 071): the events — `FSwap` is the shared `Swap` plus `FSwapState`, object-word names
|
|
273
|
+
// (`PoolCreated`, `GenerationSeeded`, `SharesMinted`, ...), `PoolCreated` carries the mint fee.
|
|
274
|
+
// No pool id moved.
|
|
269
275
|
// A breaking bump: raised in the same change.
|
|
270
|
-
export const EXPECTED_F_VERSION =
|
|
276
|
+
export const EXPECTED_F_VERSION = 30n;
|
|
271
277
|
|
|
272
278
|
export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSION): Promise<void> {
|
|
273
279
|
const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
|
package/src/fpool.ts
CHANGED
|
@@ -1153,17 +1153,17 @@ export async function fPoolIdOf(c: LogswapClient, a: Omit<FPoolCreateArgs, "acco
|
|
|
1153
1153
|
}
|
|
1154
1154
|
|
|
1155
1155
|
/**
|
|
1156
|
-
* Rebuild a live pool's KEY from its id: the `
|
|
1156
|
+
* Rebuild a live pool's KEY from its id: the `PoolCreated` log carries every field but the salt,
|
|
1157
1157
|
* which is taken from `opts.salt` (zero by default — every pool the SDK's create flow makes
|
|
1158
1158
|
* without naming one; a pad's carries its split, so it is rebuilt from the policy's record with nonce 0 — pass `opts.salt` for another nonce). The result is checked against the id, so a wrong salt throws rather than
|
|
1159
1159
|
* returning a key that names another pool. What {@link fPoolMigrate} needs when handed an id.
|
|
1160
1160
|
*/
|
|
1161
|
-
export async function fPoolKeyOfPool(c: LogswapClient, poolId: Hex, opts: { salt?: Hex; fromBlock?: bigint; /** The rindexer GraphQL endpoint: `
|
|
1162
|
-
type Ev = Extract<(typeof fPoolManagerAbi)[number], { type: "event"; name: "
|
|
1163
|
-
const ev = fPoolManagerAbi.find((x): x is Ev => x.type === "event" && x.name === "
|
|
1161
|
+
export async function fPoolKeyOfPool(c: LogswapClient, poolId: Hex, opts: { salt?: Hex; fromBlock?: bigint; /** The rindexer GraphQL endpoint: `PoolCreated` from there, the node otherwise. The salt is in neither (the event does not carry it). */ indexer?: string } = {}): Promise<FPoolKey> {
|
|
1162
|
+
type Ev = Extract<(typeof fPoolManagerAbi)[number], { type: "event"; name: "PoolCreated" }>;
|
|
1163
|
+
const ev = fPoolManagerAbi.find((x): x is Ev => x.type === "event" && x.name === "PoolCreated")!;
|
|
1164
1164
|
const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.fPoolManager!, event: ev as never, args: { poolId }, fromBlock: opts.fromBlock });
|
|
1165
1165
|
const l = logs[0];
|
|
1166
|
-
if (!l) throw new Error(`logswap: no
|
|
1166
|
+
if (!l) throw new Error(`logswap: no PoolCreated for F pool ${poolId}`);
|
|
1167
1167
|
const a = l.args as unknown as { quote: Address; creator: Address; bases: readonly Address[]; weights: readonly bigint[]; swapFee: bigint; policy: Address; lnCapOverFloor?: number | bigint; cap?: number | bigint };
|
|
1168
1168
|
const key: FPoolKey = {
|
|
1169
1169
|
quote: a.quote,
|
|
@@ -1871,7 +1871,7 @@ export interface DiscoveredFPool {
|
|
|
1871
1871
|
}
|
|
1872
1872
|
|
|
1873
1873
|
/**
|
|
1874
|
-
* Every F pool ever created, from `
|
|
1874
|
+
* Every F pool ever created, from `PoolCreated` logs alone — plus one `kind()` read per distinct
|
|
1875
1875
|
* policy, cached. Possible only because the event carries the full key preimage (bases,
|
|
1876
1876
|
* weights, swapFee, policy, lnCapOverFloor) — the poolId is a hash and could never be inverted; contracts PR #17
|
|
1877
1877
|
* exists for exactly this call. With `indexer`, the logs come from it (the node when it fails):
|
|
@@ -1881,11 +1881,11 @@ export async function discoverFPools(
|
|
|
1881
1881
|
c: LogswapClient,
|
|
1882
1882
|
opts: { fromBlock?: bigint; toBlock?: bigint; indexer?: string } = {},
|
|
1883
1883
|
): Promise<DiscoveredFPool[]> {
|
|
1884
|
-
type Ev = Extract<(typeof fPoolManagerAbi)[number], { type: "event"; name: "
|
|
1885
|
-
const ev = fPoolManagerAbi.find((x): x is Ev => x.type === "event" && x.name === "
|
|
1886
|
-
if (!ev) throw new Error("logswap: F
|
|
1887
|
-
type SeedEv = Extract<(typeof fPoolManagerAbi)[number], { type: "event"; name: "
|
|
1888
|
-
const seedEv = fPoolManagerAbi.find((x): x is SeedEv => x.type === "event" && x.name === "
|
|
1884
|
+
type Ev = Extract<(typeof fPoolManagerAbi)[number], { type: "event"; name: "PoolCreated" }>;
|
|
1885
|
+
const ev = fPoolManagerAbi.find((x): x is Ev => x.type === "event" && x.name === "PoolCreated");
|
|
1886
|
+
if (!ev) throw new Error("logswap: F PoolCreated event missing from the generated ABI");
|
|
1887
|
+
type SeedEv = Extract<(typeof fPoolManagerAbi)[number], { type: "event"; name: "GenerationSeeded" }>;
|
|
1888
|
+
const seedEv = fPoolManagerAbi.find((x): x is SeedEv => x.type === "event" && x.name === "GenerationSeeded");
|
|
1889
1889
|
const range = { indexer: opts.indexer, address: c.addresses.fPoolManager!, fromBlock: opts.fromBlock, toBlock: opts.toBlock };
|
|
1890
1890
|
const [{ logs }, { logs: seeds }] = await Promise.all([
|
|
1891
1891
|
getEventLogs(c, { ...range, event: ev }),
|