@logswap/sdk 0.5.100 → 0.5.102

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
@@ -14,7 +14,7 @@ wrong is silent:
14
14
 
15
15
  | module | what it does |
16
16
  |---|---|
17
- | `src/keys.ts` | `PoolKey` and `poolId = keccak256(abi.encode(key))` — market identity |
17
+ | `src/keys.ts` | `PoolKey` and `poolId = keccak256(abi.encode(key))` — market identity; the fee list and the spacing list |
18
18
  | `src/ids.ts` | the ERC-6909 id namespace: position-class ids, token-claim ids, floor/cap packing |
19
19
  | `src/client.ts` | the handle, plus `assertVersion` — refuse a deployment the ABI was not built for |
20
20
  | `src/pools.ts` | market discovery from the C manager's `PoolCreated` logs, pool state, `lpEdge` = `feeGrowth` − Σ/2 |
@@ -45,6 +45,58 @@ Both are computed **offline** — no RPC, no deployment needed to address a mark
45
45
  floor price (was `theta`), `refLogFloor` θ₀ — the reference floor income counts from (was
46
46
  `theta0`), `cap` (d in 1e-6 log units, 0 uncapped), and per leg `virtualReserves` and `kappa`.
47
47
 
48
+ ## C 20 / F 44 (contracts #146)
49
+
50
+ - `PoolCreated` (both managers) indexes `poolId`, `quote`, `policy`; `creator` is data. `discoverMarkets` filters `quote`
51
+ and `policy` by topic, `base` and `creator` after decoding.
52
+ - C `FeesClaimed` names `to`. `RouterC.user()` is gone. `SameAsset` replaces `IdenticalTokens`; a zero C burn reverts
53
+ `ZeroAmount`.
54
+ - `LensC.params()` returns `(feeList, spacingList, noCap, cVersion)`; `LensF.params()` returns `(feeList, fVersion)`.
55
+ - `EXPECTED_VERSION` 20, `EXPECTED_F_VERSION` 44.
56
+
57
+ ## C 19 / F 43 (contracts #145)
58
+
59
+ - `PoolCreated` (both managers) indexes `poolId`, `creator`, `policy`; `quote` is data. `discoverMarkets` takes
60
+ `policy` and `creator` as topic filters and filters `quote` and `base` after decoding.
61
+ - F: `SharesRedeemed` and `DividendClaimed` index `(poolId, owner, gen)`, as `SharesMinted` and `SharesBurned`.
62
+ - F: `dps` and `incomeHeld` are no longer `ManagerF` functions; the SDK never read them by call.
63
+ - `EXPECTED_VERSION` 19, `EXPECTED_F_VERSION` 43.
64
+
65
+ ## C 18 / F 42 (decisions 099, 100): the C key by index, the backstop at `initialize`, `PolicyC`
66
+
67
+ Contracts `logswap/logswap-contract#143`. **Every C pool id and position id moved**; F is unchanged (`EXPECTED_F_VERSION` stays 42).
68
+ This is a breaking release for C. Where a section below describes the C key, C market creation, `SponsorPolicyC` or the
69
+ registry's creation modes, this one supersedes it.
70
+
71
+ - **The key.** `PoolKey = { quote, base, swapFeeIdx, spacingIdx, policy, salt }` (`PoolKeyC`), `poolId = keccak256(abi.encode(key))`.
72
+ `swapFeeIdx` indexes `FEE_LIST` (1, 2, 5, 10, 20, 50, 100, 200 bp; one list for both managers, `F_FEE_LIST` is the same array), the
73
+ mint fee is the next entry (the same at the top) and `spacingIdx` indexes `SPACING_LIST` (`[1e15, 1e16, 1e17]`). `creator`, `swapFee`,
74
+ `mintFee` and `tickSpacing` are no key fields. The resolved values are `swapFeeOfKey(key)`, `mintFeeOfKey(key)` and
75
+ `tickSpacingOf(key)`; `feeOfIdx`, `feeIdxOf`, `mintFeeIdxOf` and `spacingIdxOf` convert, and throw off a list. `poolId` throws for
76
+ an index off its list. There is no fee-free market: `FEE_MIN` is 1 bp and `FEE_MAX` is now 200 bp.
77
+ - **Creation is one manager call.** `initializeMarket(c, { key, initialLogPrice, account })` calls `ManagerC.initialize`, which mints
78
+ the permanent backstop in the call: `account` pays dust of both tokens (and the mint fee on it) by **plain ERC-20 allowance to the
79
+ manager**. `approveTokenForCManager(c, token, account, amount?)` grants it and `cManagerAllowanceOk` reads it; Permit2 and the router
80
+ are not involved. `createMarket` and `CreateMarketArgs` are removed (`RouterC.createMarket` is gone), and so is the check that the
81
+ account is the key's creator. `PoolState` has no `backstopSeeded`: an initialized market has its backstop.
82
+ - **Discovery.** `PoolCreated` carries `swapFeeIdx` and `spacingIdx`; `discoverMarkets` and `discoverMarketsIndexed` rebuild the
83
+ six-field key, and `DiscoveredMarket.creator` names who opened it. The indexer's `allCPoolManagerPoolCreateds` rows need the columns
84
+ `swapFeeIdx` and `spacingIdx` (logswap-be follows); `tickSpacing`, `swapFee` and `mintFee` are no longer read.
85
+ - **Policies.** `policyCAbi` (`PolicyC`) replaces `sponsorPolicyCAbi`. `PolicyC` has `PolicyF`'s gate surface (`authority`, `open`,
86
+ `feeMask`, the quote list, the operator, the two modes, `rights`) plus `baseCurated` / `baseListed`, `swapFeeTax` and `mayInit`.
87
+ `cGateRules(c, { key, creator, gate? })` reads it: the result is `{ creatorOk, quoteOk, baseOk, feeOk, saltOk, policyOk, exists,
88
+ admitted }`; `creator` is required, `router` is not taken, and `mintFeeOk`, `spacingOk` and `routerTrusted` are gone (the mint fee
89
+ follows the swap fee, the spacing is the manager's list). `policySpacingAllowed` is removed.
90
+ - **Registry.** `CreationMode`, `registryCreationMode` and `registrySetCreationMode` are removed (`admit`, `creationMode`,
91
+ `setCreationMode`, `sponsorOf` left the contract): who creates under a policy is the policy's rule. `gateErrorAbi` carries
92
+ `PolicyC`'s and `PolicyF`'s errors and the registry's `NotListed`.
93
+ - **Mint fee helpers.** `minMintFee`, `isValidMintFee` and `presetMintFee` are removed: the mint fee is not chosen. `mintFee(p, x,
94
+ rate)` still previews it; pass `mintFeeOfKey(key)`.
95
+ - **Errors.** `SpacingZero`, `BackstopTooSmall`, `BackstopMustBeUncapped` and `NotCreator` left `ManagerC`; `PolicyNotApproved` is new.
96
+ - **Unchanged for a caller.** `claimFees` (the router's `claim`; the manager's own `claim` gained an `owner`, which the SDK does not
97
+ call directly), every swap, mint, edit and burn, and all of F.
98
+ - **Versions.** `EXPECTED_VERSION` is 18; `EXPECTED_F_VERSION` stays 42.
99
+
48
100
  ## C 17 / F 42 (decision 107): every event names its actor; `mint` takes a payer; the routers emit no event
49
101
 
50
102
  Contracts `logswap/logswap-contract#142`. No pool id and no position id moved; the manager bindings regenerate.
@@ -127,6 +179,8 @@ The C side is untouched until Policy C follows.
127
179
 
128
180
  ## C 16 / F 40 (decision 098): immutable, LOG-deployed policies; one sponsored policy per manager
129
181
 
182
+ (On C, superseded by C 18: `PolicyC` replaces `SponsorPolicyC` and the registry has no creation modes.)
183
+
130
184
  Follows contracts `99827f8`. This is a breaking release: the policy surface is replaced.
131
185
 
132
186
  - **Kinds.** `PublicPolicy` and `PrivatePolicy` are gone. A policy says it is `"sponsor"` (`SponsorPolicyF` / `SponsorPolicyC`: the LOG's own
@@ -161,7 +215,7 @@ Follows contracts `99827f8`. This is a breaking release: the policy surface is r
161
215
 
162
216
  ## C 15 / F 39 (decisions 096, 097): a router and a lens per manager, and a C market has a creator and a salt
163
217
 
164
- (The policy parts of this section are superseded by the one above.)
218
+ (The policy parts of this section are superseded by the one above; the C key and `createMarket` by C 18.)
165
219
 
166
220
  Follows contracts `f3164de` (096 + #112 + #113 + #115 + #116). What changes for a consumer:
167
221
 
@@ -359,9 +413,8 @@ What changes for readers:
359
413
  - **The SDK hides the manager/router/lens split.** Which contract hosts which action is currently
360
414
  decided by EIP-170 headroom, not by design — so a future re-homing must be an SDK patch, not a
361
415
  breaking change for consumers.
362
- - **Zero is not the default.** A `swapFee` of `0n` (`phi` before C version 6) resolves to `DEFAULT_FEE` at *read* time, so a key
363
- carrying `0n` and one carrying the resolved value are **different markets with different ids**.
364
- Always address a market by the key it was initialized with.
416
+ - **Address a market by its exact key.** The key carries indices (`swapFeeIdx`, `spacingIdx`), never resolved values; two keys
417
+ that differ in any field, the salt included, are **different markets with different ids**.
365
418
  - **Split every ERC-6909 `Transfer` on bit 255.** Clear means a token claim, not a position; an
366
419
  indexer that ignores this reports phantom LP positions for market makers parking inventory.
367
420
 
package/dist/admin.d.ts CHANGED
@@ -42,7 +42,7 @@ export declare function policyApproved(c: LogswapClient, policy: Address): Promi
42
42
  /** One policy on the registry's list, with what it is. */
43
43
  export interface RegistryEntry {
44
44
  policy: Address;
45
- /** The label the policy's terms spell ({@link fPolicyTermsOf}) — what a pool born under it is; `null` for a policy that answers no F terms (the C sponsored policy). */
45
+ /** The label the policy's terms spell ({@link fPolicyTermsOf}) — what a pool born under it is; `null` for a policy that answers no F terms (a `PolicyC`). */
46
46
  kind: FPoolKind | null;
47
47
  /** The name recorded at approval (`approve(policy, name)`). */
48
48
  name: string;
@@ -120,65 +120,45 @@ export declare function policyFeeAllowed(c: LogswapClient, policy: Address, swap
120
120
  listed: boolean;
121
121
  allowed: boolean;
122
122
  }>;
123
- /** `PolicyRegistry.CreationMode` (decisions 073, 098): who may create under a policy. Open = 0, SponsorOnly = 1 (the policy's own immutable sponsor, who must also be the key's creator). `Restricted` and the initializer list are gone. */
124
- export type CreationMode = "open" | "sponsorOnly";
125
- /** `PolicyRegistry.setCreationMode(policy, mode)` (the LOG Authority). A sponsored policy is approved `sponsorOnly`. */
126
- export declare function registrySetCreationMode(c: LogswapClient, policy: Address, mode: CreationMode): Promise<Hash>;
127
123
  /** `PolicyRegistry.setForwarderTrusted` (the LOG Authority): a router whose `user()` names the creator. Moved off the public policy in F version 33. */
128
124
  export declare function registrySetForwarderTrusted(c: LogswapClient, forwarder: Address, trusted: boolean): Promise<Hash>;
129
- /** `PolicyRegistry.creationMode(policy)`. */
130
125
  /**
131
126
  * `PolicyRegistry.userOf(caller)` (C 15, decision 097): the account a caller acts for — the user a trusted forwarder
132
- * (a router) names, else the caller itself. The account the managers authenticate as a market's creator and as the
133
- * first minter; what a create form compares to the key's `creator`.
127
+ * (a router) names, else the caller itself. The account a manager names as a pool's creator and asks its policy about at a birth.
134
128
  */
135
129
  export declare function registryUserOf(c: LogswapClient, caller: Address): Promise<Address>;
136
- export declare function registryCreationMode(c: LogswapClient, policy: Address): Promise<CreationMode>;
137
- /** Whether `policy` (a `SponsorPolicyC`) admits C tick spacing `tickSpacing`: it curates spacings (`spacingCurated`) and lists it, or it does not curate. */
138
- export declare function policySpacingAllowed(c: LogswapClient, policy: Address, tickSpacing: bigint): Promise<{
139
- curated: boolean;
140
- listed: boolean;
141
- allowed: boolean;
142
- }>;
143
130
  export interface CGateRules {
144
- /**
145
- * The registry admits `creator` to create under `key.policy` (creation mode and sponsor binding; decisions 073, 097, 098):
146
- * `admit(policy, creator, creator)` resolves to `creator`. Both managers then require the initializer to BE the key's creator (`NotCreator`).
147
- */
131
+ /** The policy admits `creator` (`PolicyBase._admitBirth`): anyone on an open policy, the policy's authority on a closed one (`Refused`). */
148
132
  creatorOk: boolean;
149
133
  /** The quote is on the policy's list, or the policy lists none (`quoteCurated`). */
150
134
  quoteOk: boolean;
151
- /** The swap fee is on the policy's swap tiers, or it lists none. */
135
+ /** The base is on the policy's list, or the policy lists none (`baseCurated`; `BaseNotListed`). */
136
+ baseOk: boolean;
137
+ /** The swap fee's index is on the policy's `feeMask` (an empty mask lists all eight; `FeeNotListed`). The mint fee follows it. */
152
138
  feeOk: boolean;
153
- /** The mint fee is on the policy's mint tiers, or it lists none. */
154
- mintFeeOk: boolean;
155
- /** The tick spacing is on the policy's list, or it lists none (`spacingCurated`). */
156
- spacingOk: boolean;
157
- /** A canonical policy (the LOG's open instance) needs `salt` zero (`NotCanonical`); a desk's may run several markets of one shape. */
139
+ /** An open policy needs `salt` zero (`NotCanonical`); a closed one may run several markets of one shape. */
158
140
  saltOk: boolean;
141
+ /** The registry lists the policy and its sunset has not passed (`PolicyNotApproved`); true on a deployment with no registry. */
142
+ policyOk: boolean;
159
143
  /** This exact market (the key's id) is already initialized: another is a different key. */
160
144
  exists: boolean;
161
- /** Whether `router` is a trusted forwarder on the registry — `createMarket` through it is then checked against `creator`. */
162
- routerTrusted: boolean;
163
- /** Every check passes: the policy would admit this market from this creator (the manager checks the fee domain, `BadParam`). */
145
+ /** Every check passes: the policy would admit this market from this creator (the manager checks the two indices, `BadParam`). */
164
146
  admitted: boolean;
165
147
  }
166
148
  /**
167
- * A sponsored C policy's checks for one candidate market and creator, in one round of reads — what the create form shows before a wallet
168
- * is asked (064, 073, 097, 098). The policy is `key.policy` (a `SponsorPolicyC`); the registry is asked `admit(policy, creator, creator)`: the
169
- * account that starts a market is its creator, so the key's `creator` is the connected account (a router call resolves to it through the
170
- * trusted forwarder's `user()`). The policy's pair list is gone (098).
149
+ * A C policy's birth checks for one candidate market and creator, in one round of reads — what the create form shows before a
150
+ * wallet is asked (C 18, decisions 099, 100: `PolicyC.mayInit`). The policy is `key.policy`; `creator` is the account that will call
151
+ * {@link initializeMarket}. The spacing is the manager's list ({@link SPACING_LIST}) and none of the policy's.
171
152
  */
172
153
  export declare function cGateRules(c: LogswapClient, a: {
173
154
  key: PoolKey;
174
- creator?: Address;
175
- router?: Address;
155
+ creator: Address;
176
156
  gate?: Address;
177
157
  }): Promise<CGateRules>;
178
158
  /**
179
159
  * Every refusal a birth can meet at a policy or the registry (064, 065, 098; policy.md §4.4), for `decodeErrorResult` on a
180
- * failed simulation: the sponsored C policy's errors, the F policy's (`Refused`, `NotCanonical`, `FeeNotListed`, `QuoteNotListed`,
181
- * `BaseNotListed`, `TooManyLegs`, `AlreadyHeld`, …) and the registry's admission errors. One entry per distinct signature.
160
+ * failed simulation: the C policy's errors, the F policy's (`Refused`, `NotCanonical`, `FeeNotListed`, `QuoteNotListed`,
161
+ * `BaseNotListed`, `TooManyLegs`, `AlreadyHeld`, …) and the registry's `NotListed`. One entry per distinct signature.
182
162
  */
183
163
  type AbiError = {
184
164
  type: "error";
package/dist/admin.js CHANGED
@@ -14,10 +14,10 @@
14
14
  * managers. A harvest has no cut (056); the protocol's share of a harvest's income is the policy's `incomeTaxRate` on the
15
15
  * payer's slice, capped by the manager at `INCOME_TAX_MAX`.
16
16
  */
17
- import { poolId as keyId } from "./keys.js";
18
- import { managerC, routerC } from "./client.js";
17
+ import { poolId as keyId, FEE_LIST } from "./keys.js";
18
+ import { managerC } from "./client.js";
19
19
  import { getPool } from "./pools.js";
20
- import { managerCAbi, managerFAbi, policyFAbi, policyRegistryAbi, sponsorPolicyCAbi } from "./generated.js";
20
+ import { managerCAbi, managerFAbi, policyFAbi, policyCAbi, policyRegistryAbi } from "./generated.js";
21
21
  import { bytes32ToText, fFeeListed, fPoolKindOfPolicy, fPolicyTermsOf, textToBytes32 } from "./fpool.js";
22
22
  function wallet(c) {
23
23
  if (!c.wallet)
@@ -37,9 +37,9 @@ function write(c, address, abi, functionName, args) {
37
37
  export async function cSwapFeeTax(c, policy) {
38
38
  const address = policy ?? c.addresses.publicPolicyC;
39
39
  if (!address)
40
- throw new Error("logswap: this deployment carries no C sponsored policy (addresses.publicPolicyC); pass one");
40
+ throw new Error("logswap: this deployment carries no C policy (addresses.publicPolicyC); pass one");
41
41
  const [tax, max] = await Promise.all([
42
- c.public.readContract({ address, abi: sponsorPolicyCAbi, functionName: "swapFeeTax" }),
42
+ c.public.readContract({ address, abi: policyCAbi, functionName: "swapFeeTax" }),
43
43
  c.public.readContract({ address: managerC(c), abi: managerCAbi, functionName: "SWAP_FEE_TAX_MAX" }),
44
44
  ]);
45
45
  return { tax, max };
@@ -188,20 +188,13 @@ export async function policyFeeAllowed(c, policy, swapFeeIdx) {
188
188
  const listed = fFeeListed(feeMask, swapFeeIdx);
189
189
  return { curated: feeMask !== 0, listed, allowed: listed };
190
190
  }
191
- const CREATION_MODES = ["open", "sponsorOnly"];
192
- /** `PolicyRegistry.setCreationMode(policy, mode)` (the LOG Authority). A sponsored policy is approved `sponsorOnly`. */
193
- export async function registrySetCreationMode(c, policy, mode) {
194
- return registryWrite(c, "setCreationMode", [policy, CREATION_MODES.indexOf(mode)]);
195
- }
196
191
  /** `PolicyRegistry.setForwarderTrusted` (the LOG Authority): a router whose `user()` names the creator. Moved off the public policy in F version 33. */
197
192
  export async function registrySetForwarderTrusted(c, forwarder, trusted) {
198
193
  return registryWrite(c, "setForwarderTrusted", [forwarder, trusted]);
199
194
  }
200
- /** `PolicyRegistry.creationMode(policy)`. */
201
195
  /**
202
196
  * `PolicyRegistry.userOf(caller)` (C 15, decision 097): the account a caller acts for — the user a trusted forwarder
203
- * (a router) names, else the caller itself. The account the managers authenticate as a market's creator and as the
204
- * first minter; what a create form compares to the key's `creator`.
197
+ * (a router) names, else the caller itself. The account a manager names as a pool's creator and asks its policy about at a birth.
205
198
  */
206
199
  export async function registryUserOf(c, caller) {
207
200
  const registry = await policyRegistryOf(c);
@@ -209,60 +202,36 @@ export async function registryUserOf(c, caller) {
209
202
  return caller;
210
203
  return (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "userOf", args: [caller] }));
211
204
  }
212
- export async function registryCreationMode(c, policy) {
213
- const registry = await policyRegistryOf(c);
214
- if (registry === ZERO)
215
- return "open";
216
- const m = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "creationMode", args: [policy] }));
217
- return CREATION_MODES[Number(m)] ?? "open";
218
- }
219
- /** Whether `policy` (a `SponsorPolicyC`) admits C tick spacing `tickSpacing`: it curates spacings (`spacingCurated`) and lists it, or it does not curate. */
220
- export async function policySpacingAllowed(c, policy, tickSpacing) {
221
- const [curated, listed] = await Promise.all([
222
- c.public.readContract({ address: policy, abi: sponsorPolicyCAbi, functionName: "spacingCurated" }),
223
- c.public.readContract({ address: policy, abi: sponsorPolicyCAbi, functionName: "spacingListed", args: [tickSpacing] }),
224
- ]);
225
- return { curated, listed, allowed: !curated || listed };
226
- }
227
205
  /**
228
- * A sponsored C policy's checks for one candidate market and creator, in one round of reads — what the create form shows before a wallet
229
- * is asked (064, 073, 097, 098). The policy is `key.policy` (a `SponsorPolicyC`); the registry is asked `admit(policy, creator, creator)`: the
230
- * account that starts a market is its creator, so the key's `creator` is the connected account (a router call resolves to it through the
231
- * trusted forwarder's `user()`). The policy's pair list is gone (098).
206
+ * A C policy's birth checks for one candidate market and creator, in one round of reads — what the create form shows before a
207
+ * wallet is asked (C 18, decisions 099, 100: `PolicyC.mayInit`). The policy is `key.policy`; `creator` is the account that will call
208
+ * {@link initializeMarket}. The spacing is the manager's list ({@link SPACING_LIST}) and none of the policy's.
232
209
  */
233
210
  export async function cGateRules(c, a) {
234
211
  const g = a.gate ?? a.key.policy;
235
- const rd = (functionName, args = []) => c.public.readContract({ address: g, abi: sponsorPolicyCAbi, functionName, args });
212
+ const rd = (functionName, args = []) => c.public.readContract({ address: g, abi: policyCAbi, functionName, args });
236
213
  const { key } = a;
237
- const creator = a.creator ?? key.creator;
238
- const registry = await policyRegistryOf(c);
239
- const router = a.router ?? routerC(c);
240
- const registryRd = (functionName, args) => c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName, args });
241
- const [quoteCurated, quoteListed, feeListed, mintFeeListed, spacingCurated, spacingListed, canonical, state, routerTrusted, creatorOk] = await Promise.all([
214
+ const [open, authority, feeMask, quoteCurated, quoteListed, baseCurated, baseListed, state, policyOk] = await Promise.all([
215
+ rd("open"),
216
+ rd("authority"),
217
+ rd("feeMask"),
242
218
  rd("quoteCurated"),
243
219
  rd("quoteListed", [key.quote]),
244
- rd("swapFeeListed", [key.swapFee]),
245
- rd("mintFeeListed", [key.mintFee]),
246
- rd("spacingCurated"),
247
- rd("spacingListed", [key.tickSpacing]),
248
- rd("canonical"),
220
+ rd("baseCurated"),
221
+ rd("baseListed", [key.base]),
249
222
  getPool(c, key),
250
- registry === ZERO ? Promise.resolve(false) : registryRd("forwarderTrusted", [router]),
251
- registry === ZERO
252
- ? Promise.resolve(true)
253
- : registryRd("admit", [g, creator, creator]).then((who) => who.toLowerCase() === creator.toLowerCase(), () => false),
223
+ policyApproved(c, g),
254
224
  ]);
255
225
  const r = {
256
- creatorOk,
226
+ creatorOk: open || authority.toLowerCase() === a.creator.toLowerCase(),
257
227
  quoteOk: !quoteCurated || quoteListed,
258
- feeOk: feeListed,
259
- mintFeeOk: mintFeeListed,
260
- spacingOk: !spacingCurated || spacingListed,
261
- saltOk: !canonical || key.salt === "0x0000000000000000000000000000000000000000000000000000000000000000",
228
+ baseOk: !baseCurated || baseListed,
229
+ feeOk: key.swapFeeIdx < FEE_LIST.length && fFeeListed(Number(feeMask), key.swapFeeIdx),
230
+ saltOk: !open || key.salt === "0x0000000000000000000000000000000000000000000000000000000000000000",
231
+ policyOk,
262
232
  exists: state.initialized,
263
- routerTrusted,
264
233
  };
265
- return { ...r, admitted: r.creatorOk && r.quoteOk && r.feeOk && r.mintFeeOk && r.spacingOk && r.saltOk && !r.exists };
234
+ return { ...r, admitted: r.creatorOk && r.quoteOk && r.baseOk && r.feeOk && r.saltOk && r.policyOk && !r.exists };
266
235
  }
267
236
  const isAbiError = (x) => x.type === "error";
268
237
  export const gateErrorAbi = (() => {
@@ -270,10 +239,10 @@ export const gateErrorAbi = (() => {
270
239
  const sig = (x) => `${x.name}(${x.inputs.map((i) => i.type).join(",")})`;
271
240
  const all = (abi) => abi.filter(isAbiError);
272
241
  const errors = [
273
- ...all(sponsorPolicyCAbi),
242
+ ...all(policyCAbi),
274
243
  ...all(policyFAbi),
275
- // creation admission is the registry's (F 33 / C 10, 073): a refusal there surfaces through the manager's birth
276
- ...all(policyRegistryAbi).filter((x) => ["SponsorOnly", "InvalidForwardedUser", "NotListed"].includes(x.name)),
244
+ // who creates under a policy is the policy's rule (C 18, decision 100); the registry only lists the policy
245
+ ...all(policyRegistryAbi).filter((x) => x.name === "NotListed"),
277
246
  ];
278
247
  return errors.filter((x) => (seen.has(sig(x)) ? false : (seen.add(sig(x)), true)));
279
248
  })();
package/dist/chains.d.ts CHANGED
@@ -139,7 +139,7 @@ export interface LogswapDeployment {
139
139
  polPolicy: Address;
140
140
  /** The LOG's pad policy on F (`PolicyF`, `seedToDead`: income-only harvests, never closes). */
141
141
  padPolicy: Address;
142
- /** The LOG's open sponsored instance on C (`SponsorPolicyC`). Absent while the chain has no C stack. */
142
+ /** The LOG's open policy on C (`PolicyC`, `open`: anyone creates at salt zero, no gate ever). Absent while the chain has no C stack. */
143
143
  publicPolicyC?: Address;
144
144
  /** The devnet's token factory; local deployments only. */
145
145
  tokenFactory?: Address;
package/dist/client.d.ts CHANGED
@@ -24,7 +24,7 @@ export interface LogswapAddresses {
24
24
  * The C stack is optional: F ships first, and a chain that has not opted into C carries none.
25
25
  */
26
26
  managerC?: Address;
27
- /** C's user entry: the batch, the named one-action entries, `createMarket`, Permit2. Its own Permit2 spender. */
27
+ /** C's user entry: the batch, the named one-action entries, Permit2 (a market is opened on the manager). Its own Permit2 spender. */
28
28
  routerC?: Address;
29
29
  /** C's read-only lens: ladder derivations and views. */
30
30
  lensC?: Address;
@@ -39,7 +39,7 @@ export interface LogswapAddresses {
39
39
  privatePolicy?: Address;
40
40
  polPolicy?: Address;
41
41
  padPolicy?: Address;
42
- /** The LOG's open sponsored instance on C (`SponsorPolicyC`): the policy of a public market. Absent with no C stack. */
42
+ /** The LOG's open policy on C (`PolicyC`): the policy of a public market. Absent with no C stack. */
43
43
  publicPolicyC?: Address;
44
44
  /**
45
45
  * The policy registry: what a pool of each kind may be born under, and the
@@ -133,14 +133,14 @@ export declare function clientChainId(c: LogswapClient): Promise<number>;
133
133
  * **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
134
134
  * `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
135
135
  * LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
136
- * each market's, answered by its policy at birth (since 098, `SponsorPolicyC.swapFeeTax`, an immutable) and
136
+ * each market's, answered by its policy at birth (`PolicyC.swapFeeTax`, an immutable; `SponsorPolicyC` before C 18) and
137
137
  * read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
138
138
  * permissionless and pays the treasury. No pool id moved.
139
139
  * 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
140
140
  * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
141
141
  * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
142
142
  */
143
- export declare const EXPECTED_VERSION = 17n;
143
+ export declare const EXPECTED_VERSION = 20n;
144
144
  /**
145
145
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
146
146
  * 4 was the income-only harvest cut).
@@ -152,7 +152,7 @@ export declare const EXPECTED_VERSION = 17n;
152
152
  * passes it; when one lands, raise this constant in the same change, which is the discipline
153
153
  * `EXPECTED_VERSION` enforces mechanically and this one asks for.
154
154
  */
155
- export declare const EXPECTED_F_VERSION = 42n;
155
+ export declare const EXPECTED_F_VERSION = 44n;
156
156
  export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
157
157
  /**
158
158
  * The versions say the managers are the right code; this says the rest of the addresses belong
package/dist/client.js CHANGED
@@ -140,7 +140,7 @@ function guardChain(wallet, pub) {
140
140
  * **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
141
141
  * `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
142
142
  * LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
143
- * each market's, answered by its policy at birth (since 098, `SponsorPolicyC.swapFeeTax`, an immutable) and
143
+ * each market's, answered by its policy at birth (`PolicyC.swapFeeTax`, an immutable; `SponsorPolicyC` before C 18) and
144
144
  * read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
145
145
  * permissionless and pays the treasury. No pool id moved.
146
146
  * 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
@@ -168,7 +168,14 @@ function guardChain(wallet, pub) {
168
168
  // `PositionMinted(poolId, to, id, sender, payer, shares, dBase, dQuote)`; `ProtocolFeesCollected(poolId, sender, to, amount)`;
169
169
  // `ClassRegistered(poolId, id, floor, cap, capped)` (poolId first); the account acted on is `owner` on `PositionBurned` (was `from`),
170
170
  // `PositionUpdated` and `FeesClaimed` (was `holder`); `RouterC`'s entries and `Settle` name the receiver `to` (was `recipient`). No pool id moved.
171
- export const EXPECTED_VERSION = 17n;
171
+ // 18 (decisions 099, 100): `PoolKeyC` is `(quote, base, swapFeeIdx, spacingIdx, policy, salt)` — every C pool id and position id moved; the
172
+ // fee is an index into the family's list (the mint fee the next entry) and the spacing an index into `[1e15, 1e16, 1e17]`; `initialize(key, x0)`
173
+ // mints the backstop in the call (the caller pays dust of both tokens by allowance to the manager) and `RouterC.createMarket` is gone;
174
+ // `PoolCreated` carries the two indices; `claim(poolId, id, owner, to)`; `PoolView` has no `backstopSeeded`; `LensC.params()` is
175
+ // `(spacingList, noCap, cVersion)`; `PolicyC` replaces `SponsorPolicyC` (F's gate surface plus `baseListed`, `swapFeeTax`, `mayInit`); the
176
+ // registry lost its creation modes (`admit`, `creationMode`, `setCreationMode`, `sponsorOf`). `SpacingZero`, `BackstopTooSmall`,
177
+ // `BackstopMustBeUncapped` and `NotCreator` are gone, `PolicyNotApproved` is new.
178
+ export const EXPECTED_VERSION = 20n;
172
179
  /**
173
180
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
174
181
  * 4 was the income-only harvest cut).
@@ -292,7 +299,7 @@ export const EXPECTED_VERSION = 17n;
292
299
  // poolL, supply)`; `SharesBurned` indexes `gen` and names `owner` (was `from`), `DividendClaimed` names `owner` (was `holder`);
293
300
  // `PoolCreated(poolId, quote, creator, policy, bases, swapFeeIdx, salt)` (`creator` a topic, `policy` data); `LiquidityDeployed`,
294
301
  // `IncomeHarvested` and `GenerationFrozen` carry `operator` as a topic; `RouterF.BadToken` is `WrongToken`. No pool id moved.
295
- export const EXPECTED_F_VERSION = 42n;
302
+ export const EXPECTED_F_VERSION = 44n;
296
303
  export async function assertVersion(c, expected = EXPECTED_VERSION) {
297
304
  const { managerCAbi, managerFAbi } = await import("./generated.js");
298
305
  const withC = hasC(c);
package/dist/fpool.js CHANGED
@@ -43,6 +43,7 @@ import { managerFAbi, lensFAbi, routerFAbi, policyFAbi, policyRegistryAbi } from
43
43
  */
44
44
  export { managerFAbi, policyFAbi };
45
45
  import { clientChainId } from "./client.js";
46
+ import { FEE_LIST, FEE_LIST_BP } from "./keys.js";
46
47
  import { findQuoteResult } from "./quote.js";
47
48
  import { fallBackUnlessRejected, signerFor } from "./write.js";
48
49
  import { getEventLogs } from "./history.js";
@@ -720,9 +721,9 @@ export async function fPoolQuoteSwap(c, a) {
720
721
  const ZERO_SALT = `0x${"0".repeat(64)}`;
721
722
  // ─── the fee list (policy.md §6) ──────────────────────────────────────────────
722
723
  /** `FeeParams.FEE_LIST` in bp: the eight swap fees an F pool may be born with. The key carries the index. */
723
- export const F_FEE_LIST_BP = [1, 2, 5, 10, 20, 50, 100, 200];
724
+ export const F_FEE_LIST_BP = FEE_LIST_BP;
724
725
  /** The list in WAD (1 bp = 1e14). No zero: the fee-free pool cannot be born. */
725
- export const F_FEE_LIST = F_FEE_LIST_BP.map((bp) => BigInt(bp) * 10n ** 14n);
726
+ export const F_FEE_LIST = FEE_LIST;
726
727
  /** The fee at `idx` of the list, WAD. Throws off the list. */
727
728
  export function fFeeOf(idx) {
728
729
  const fee = Number.isInteger(idx) ? F_FEE_LIST[idx] : undefined;