@logswap/sdk 0.5.79 → 0.5.81

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/dist/admin.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * registry and the policies; no router.
8
8
  *
9
9
  * The mint fee has no cut to set since C version 6 / F version 24 (decisions 058): the whole fee
10
- * is the protocol's on both managers. A harvest has no cut (056); a pad's protocol share of the pot
10
+ * is the protocol's on both managers. A harvest has no cut (056); a pad's protocol share of the income
11
11
  * is the policy's (`PadPolicy.setSchedule`), capped by the manager at `POT_CUT_MAX`.
12
12
  */
13
13
  import { getPool } from "./pools.js";
@@ -178,16 +178,16 @@ export async function registryKindOf(c, policy) {
178
178
  }
179
179
  // ─── the policies' numbers (the LOG Authority's; each bounded where it reaches the manager) ─────
180
180
  /**
181
- * `PadPolicy.setSchedule` (decisions 056, 067, 070): the rung's growth, the protocol's share of the pot (≤ `POT_CUT_MAX`,
182
- * recorded into each pad at birth), and the RANGE a creator chooses his cut of the pot inside at creation (its top ≤ the F
183
- * manager's `PAYEE_CUT_MAX`). The creator's top plus the protocol's share is at most the pot; the rest deepens the bid — nothing
184
- * is bought or burnt since F version 28. A change to the split applies to pads born after it; the growth moves every pad at its
181
+ * `PadPolicy.setSchedule` (decisions 056, 067, 070, 073): the rung's growth and the RANGE inside which a creator chooses their cut of the income
182
+ * at creation (its top ≤ the F manager's `PAYEE_CUT_MAX`). The rest of the income deepens the bid — nothing is bought or
183
+ * burnt since F version 28, and the protocol takes no cut of the income since F version 33 (its revenue is the income tax,
184
+ * {@link padSetIncomeTaxRate}). A change to the range applies to pads born after it; the growth moves every pad at its
185
185
  * next rung. The rung is the pool's generation. `T(0)` is per quote since decision 070: {@link padSetThresholdBase}.
186
186
  */
187
187
  export async function padSetSchedule(c, policy, s) {
188
188
  if ("thresholdBase" in s)
189
189
  throw new Error("logswap: T(0) is per quote since decision 070 — padSetThresholdBase(c, policy, quote, base)");
190
- return write(c, policy, padPolicyAbi, "setSchedule", [s.thresholdGrowth, s.protocolShare, s.creatorShareMin, s.creatorShareMax]);
190
+ return write(c, policy, padPolicyAbi, "setSchedule", [s.thresholdGrowth, s.creatorShareMin, s.creatorShareMax]);
191
191
  }
192
192
  /**
193
193
  * `PadPolicy.setThresholdBase(quote, base)` (decision 070): `T(0)` for pads quoted in `quote`, in that quote's units. A pad is
@@ -205,28 +205,31 @@ export async function padThresholdBases(c, policy, quotes) {
205
205
  return { quote, set, base };
206
206
  }));
207
207
  }
208
- /** `PadPolicy.thresholdOf(quote, rung)` (decision 070): the pot a pad quoted in `quote` must bank to climb `rung` (0 reads `T(0)`). */
208
+ /** `PadPolicy.thresholdOf(quote, rung)` (decision 070): the income a pad quoted in `quote` must bank to climb `rung` (0 reads `T(0)`). */
209
209
  export async function padThresholdOf(c, policy, quote, rung = 0n) {
210
210
  return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "thresholdOf", args: [quote, BigInt(rung)] }));
211
211
  }
212
- /** `PadPolicy.threshold(poolId, rung)` (decision 070): the pot pad `poolId` must bank to climb `rung`, in its own quote. */
212
+ /** `PadPolicy.threshold(poolId, rung)` (decision 070): the income pad `poolId` must bank to climb `rung`, in its own quote. */
213
213
  export async function padThreshold(c, policy, poolId, rung) {
214
214
  return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "threshold", args: [poolId, BigInt(rung)] }));
215
215
  }
216
216
  /** Read {@link PadSchedule} off a pad policy. */
217
217
  export async function padScheduleOf(c, policy) {
218
218
  const rd = (functionName) => c.public.readContract({ address: policy, abi: padPolicyAbi, functionName });
219
- const [thresholdGrowth, protocolShare, creatorShareMin, creatorShareMax] = await Promise.all([
220
- rd("thresholdGrowth"),
221
- rd("protocolShare"),
222
- rd("creatorShareMin"),
223
- rd("creatorShareMax"),
224
- ]);
225
- return { thresholdGrowth, protocolShare, creatorShareMin, creatorShareMax };
219
+ const [thresholdGrowth, creatorShareMin, creatorShareMax] = await Promise.all([rd("thresholdGrowth"), rd("creatorShareMin"), rd("creatorShareMax")]);
220
+ return { thresholdGrowth, creatorShareMin, creatorShareMax };
221
+ }
222
+ /** `PolPolicy.setMinQuoteRatio` (decision 073): the reserve a harvest must leave in the bid (`may(Harvest)` refuses less) and a relaunch's seed must bring, a multiple of the pool's L in WAD (at most 100e18). The policy sponsor's. */
223
+ export async function polSetMinQuoteRatio(c, policy, ratio) {
224
+ return write(c, policy, polPolicyAbi, "setMinQuoteRatio", [ratio]);
226
225
  }
227
- /** `PolPolicy.setRules`: the reserve a harvest must leave in the bid (`may(Harvest)` refuses less) and what a relaunch's seed must bring, WAD fractions of the pool's L. */
228
- export async function polSetRules(c, policy, s) {
229
- return write(c, policy, polPolicyAbi, "setRules", [s.keepQuote, s.minQuoteAtSeed]);
226
+ /** `PadPolicy.setIncomeTaxRate` (decision 073): the share of its new income dividend the dead shares pay LOG Treasury as income tax, WAD, at most 50%. The policy sponsor's. */
227
+ export async function padSetIncomeTaxRate(c, policy, rate) {
228
+ return write(c, policy, padPolicyAbi, "setIncomeTaxRate", [rate]);
229
+ }
230
+ /** `PolPolicy.setIncomeTaxRate` (decision 073): the share of its new income dividend the pool's authority pays LOG Treasury, WAD, at most 50%. Paid on the authority's own shares only: an authority that holds through another address pays nothing. The policy sponsor's. */
231
+ export async function polSetIncomeTaxRate(c, policy, rate) {
232
+ return write(c, policy, polPolicyAbi, "setIncomeTaxRate", [rate]);
230
233
  }
231
234
  /** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The LOG Authority's. */
232
235
  export async function policySetQuoteListed(c, policy, quote, listed) {
@@ -264,31 +267,26 @@ export async function policyFeeAllowed(c, policy, fee) {
264
267
  ]);
265
268
  return { curated, listed, allowed: !curated || listed };
266
269
  }
267
- /** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The LOG Authority's. */
268
- export async function policySetMintFeeListed(c, policy, mintFee, listed) {
269
- return write(c, policy, fPolicyBaseAbi, "setMintFeeListed", [mintFee, listed]);
270
+ const CREATION_MODES = ["open", "restricted", "sponsorOnly"];
271
+ /** `PolicyRegistry.setCreationMode(policy, mode)` (the LOG Authority): replaces the per-policy creator lists (064). A sponsor-bound policy cannot leave `sponsorOnly`. */
272
+ export async function registrySetCreationMode(c, policy, mode) {
273
+ return registryWrite(c, "setCreationMode", [policy, CREATION_MODES.indexOf(mode)]);
270
274
  }
271
- /** `setMintFeeCurated` on any protocol policy: on, a birth proposing an unlisted mint fee is refused (`MintFeeNotListed`). */
272
- export async function policySetMintFeeCurated(c, policy, curated) {
273
- return write(c, policy, fPolicyBaseAbi, "setMintFeeCurated", [curated]);
275
+ /** `PolicyRegistry.setInitializerListed(policy, who, allowed)` (the LOG Authority): who may create under a `restricted` policy, authenticated as the caller or a trusted forwarder's user. */
276
+ export async function registrySetInitializerListed(c, policy, who, allowed) {
277
+ return registryWrite(c, "setInitializerListed", [policy, who, allowed]);
274
278
  }
275
- /**
276
- * A policy's mint-fee menu, for a create form (065): which of `candidates` it lists, and whether it
277
- * curates at all (uncurated, any fee in the domain is accepted — the desk's policy never curates).
278
- * The candidates are the app's — typically {@link presetMintFee} of each listed swap tier.
279
- */
280
- export async function policyMintFeeMenu(c, policy, candidates) {
281
- const rd = (functionName, args = []) => c.public.readContract({ address: policy, abi: fPolicyBaseAbi, functionName, args });
282
- const [curated, ...flags] = await Promise.all([rd("mintFeeCurated"), ...candidates.map((m) => rd("mintFeeListed", [m]))]);
283
- return { curated, listed: candidates.filter((_, i) => flags[i]) };
284
- }
285
- /** `setCreatorListed` on any protocol policy (064): a creator onboarded under a service agreement. */
286
- export async function policySetCreatorListed(c, policy, who, listed) {
287
- return write(c, policy, fPolicyBaseAbi, "setCreatorListed", [who, listed]);
279
+ /** `PolicyRegistry.setForwarderTrusted` (the LOG Authority): a router whose `user()` names the creator. Moved off the public policy in F version 33. */
280
+ export async function registrySetForwarderTrusted(c, forwarder, trusted) {
281
+ return registryWrite(c, "setForwarderTrusted", [forwarder, trusted]);
288
282
  }
289
- /** `setCreatorCurated` on any protocol policy: on, only listed creators may create on that kind (C: the caller; F: `key.creator`). */
290
- export async function policySetCreatorCurated(c, policy, curated) {
291
- return write(c, policy, fPolicyBaseAbi, "setCreatorCurated", [curated]);
283
+ /** `PolicyRegistry.creationMode(policy)`. */
284
+ export async function registryCreationMode(c, policy) {
285
+ const registry = await policyRegistryOf(c);
286
+ if (registry === ZERO)
287
+ return "open";
288
+ const m = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "creationMode", args: [policy] }));
289
+ return CREATION_MODES[Number(m)] ?? "open";
292
290
  }
293
291
  /** `PublicPolicy.setPairListed` (064): a C pair a market may be born on while pairs are curated. Directional (base, quote). */
294
292
  export async function gateSetPairListed(c, policy, base, quote, listed) {
@@ -302,33 +300,27 @@ export async function gateSetPairCurated(c, policy, curated) {
302
300
  export async function gateSetSpacingListed(c, policy, tickSpacing, listed) {
303
301
  return write(c, policy, publicPolicyAbi, "setSpacingListed", [tickSpacing, listed]);
304
302
  }
305
- /** `PublicPolicy.setForwarderTrusted` (064): a router whose `user()` the gate takes as the creator. */
306
- export async function gateSetForwarderTrusted(c, policy, forwarder, trusted) {
307
- return write(c, policy, publicPolicyAbi, "setForwarderTrusted", [forwarder, trusted]);
308
- }
309
303
  /**
310
304
  * @deprecated C version 8 fixes the gate at construction (066): there is no `setGate`. Open or close
311
- * C through the gate's lists (`policySetCreatorCurated`, `gateSetPairCurated`, `gateSetSpacingListed`, …).
305
+ * C through the gate's lists (`registrySetCreationMode`, `gateSetPairCurated`, `gateSetSpacingListed`, …).
312
306
  */
313
307
  export async function setCGate(_c, _gate) {
314
308
  throw new Error("logswap: the C gate is fixed at construction since C version 8 (decision 066); change its lists instead");
315
309
  }
316
- /** The C manager's gate (`address(0)`: permissionless, a fee-free market then refused). */
317
- export async function cGate(c) {
318
- return c.public.readContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "gate" });
319
- }
320
310
  /**
321
311
  * The public policy's C checks for one candidate market and creator, in one round of reads — what
322
- * the create form shows before a wallet is asked (064). `router` is the router the form will go
323
- * through (`c.addresses.router` by default).
312
+ * the create form shows before a wallet is asked (064, 073). The policy is `key.policy`; the registry
313
+ * is asked `admit(policy, caller, 0)`, with the caller being the router when it is a trusted forwarder
314
+ * (it then names `creator` itself) and `creator` otherwise.
324
315
  */
325
316
  export async function cGateRules(c, a) {
326
- const g = a.gate ?? c.addresses.publicPolicy;
317
+ const g = a.gate ?? a.key.policy;
327
318
  const rd = (functionName, args = []) => c.public.readContract({ address: g, abi: publicPolicyAbi, functionName, args });
328
319
  const { key } = a;
329
- const [creatorCurated, creatorListed, quoteCurated, quoteListed, pairCurated, pairListed, feeCurated, feeListed, spacingListed, market, routerTrusted] = await Promise.all([
330
- rd("creatorCurated"),
331
- rd("creatorListed", [a.creator]),
320
+ const registry = await policyRegistryOf(c);
321
+ const router = a.router ?? c.addresses.router;
322
+ const registryRd = (functionName, args) => c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName, args });
323
+ const [quoteCurated, quoteListed, pairCurated, pairListed, feeCurated, feeListed, spacingListed, market, routerTrusted, creatorOk] = await Promise.all([
332
324
  rd("quoteCurated"),
333
325
  rd("quoteListed", [key.quote]),
334
326
  rd("pairCurated"),
@@ -337,10 +329,13 @@ export async function cGateRules(c, a) {
337
329
  rd("feeListed", [key.swapFee]),
338
330
  rd("spacingListed", [key.tickSpacing]),
339
331
  rd("cMarketOf", [key.base, key.quote, key.swapFee]),
340
- rd("forwarderTrusted", [a.router ?? c.addresses.router]),
332
+ registry === ZERO ? Promise.resolve(false) : registryRd("forwarderTrusted", [router]),
333
+ registry === ZERO
334
+ ? Promise.resolve(true)
335
+ : registryRd("admit", [g, a.creator, ZERO]).then(() => true, () => false),
341
336
  ]);
342
337
  const r = {
343
- creatorOk: !creatorCurated || creatorListed,
338
+ creatorOk,
344
339
  quoteOk: !quoteCurated || quoteListed,
345
340
  pairOk: !pairCurated || pairListed,
346
341
  feeOk: !feeCurated || feeListed,
@@ -357,16 +352,10 @@ export async function cGateRules(c, a) {
357
352
  */
358
353
  export const gateErrorAbi = [
359
354
  ...publicPolicyAbi.filter((x) => x.type === "error"),
355
+ // creation admission moved to the registry in F 33 / C 10 (073): a refusal there surfaces through the manager's birth
356
+ ...policyRegistryAbi.filter((x) => x.type === "error" && ["SponsorOnly", "InitializerNotListed", "InvalidForwardedUser", "NotListed"].includes(x.name)),
360
357
  ...padPolicyAbi.filter((x) => x.type === "error" && (x.name === "PadExists" || x.name === "NoThreshold")),
361
358
  ];
362
- /** `PublicPolicy.setListed`: an asset a curated seed may hold. */
363
- export async function publicSetListed(c, policy, token, listed) {
364
- return write(c, policy, publicPolicyAbi, "setListed", [token, listed]);
365
- }
366
- /** `PublicPolicy.setCurated`: whether every public seed is checked against the list. */
367
- export async function publicSetCurated(c, policy, curated) {
368
- return write(c, policy, publicPolicyAbi, "setCurated", [curated]);
369
- }
370
359
  // ─── the LOG Treasury (066): receives, administers nothing ───────────────────
371
360
  function manager(c, side) {
372
361
  return side === "C"
package/dist/client.d.ts CHANGED
@@ -119,7 +119,7 @@ export declare function clientChainId(c: LogswapClient): Promise<number>;
119
119
  * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
120
120
  * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
121
121
  */
122
- export declare const EXPECTED_VERSION = 9n;
122
+ export declare const EXPECTED_VERSION = 12n;
123
123
  /**
124
124
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
125
125
  * 4 was the income-only harvest cut).
@@ -131,7 +131,7 @@ export declare const EXPECTED_VERSION = 9n;
131
131
  * passes it; when one lands, raise this constant in the same change, which is the discipline
132
132
  * `EXPECTED_VERSION` enforces mechanically and this one asks for.
133
133
  */
134
- export declare const EXPECTED_F_VERSION = 31n;
134
+ export declare const EXPECTED_F_VERSION = 38n;
135
135
  export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
136
136
  /**
137
137
  * The versions say the managers are the right code; this says the rest of the addresses belong
package/dist/client.js CHANGED
@@ -113,7 +113,11 @@ function guardChain(wallet, pub) {
113
113
  * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
114
114
  * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
115
115
  */
116
- export const EXPECTED_VERSION = 9n;
116
+ // 11 (decision 078): `mintFee` is a key field (the creator's pick, `2 * swapFee <= mintFee <= 2%`); `initialize(key, x0)`
117
+ // takes no separate mint fee, `createMarket` neither; `getPool` drops `mintFee` and the gates' mint-fee menus are gone.
118
+ // Every C pool id moved.
119
+ // 12 (decisions 079-081): `Action` ordinals, the key is `CPoolKey` (names only). No pool id moved.
120
+ export const EXPECTED_VERSION = 12n;
117
121
  /**
118
122
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
119
123
  * 4 was the income-only harvest cut).
@@ -207,8 +211,15 @@ export const EXPECTED_VERSION = 9n;
207
211
  // No pool id moved.
208
212
  // 31 (decision 072): `DividendClaimed` names the generation (`gen`, indexed, after `poolId`); `lock` / `unlock` emit
209
213
  // `LienLocked` / `LienUnlocked`. No selector, storage layout or pool id moved.
214
+ // 33 (decisions 073, 074): sponsor-bound policies, the income fee, registry admission.
215
+ // 34-38 (decisions 075-085): one liquidity routine. `FPoolKey` holds no weights and no cap and gains `mintFee` (every pool
216
+ // id moved); `initialize(key)`; `seed` / `retire` / `setLegs` are gone for `deployLiquidity(poolId, baseAssets,
217
+ // quoteAmount, lnCapOverSeed, to)` (it SETS THE BOOK on an unfunded or a live pool), `close(poolId, to)` and
218
+ // `regenerate(poolId, to)`; asset membership is fixed by the key; `LiquidityDeployed` echoes the input,
219
+ // `GenerationSeeded` / `LegsSet` are gone; the lens `fPool` field is `baseLegs`, the cap `lnCapOverSeed`; the pot and the
220
+ // income fee are the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`); a pad is uncapped.
210
221
  // A breaking bump: raised in the same change.
211
- export const EXPECTED_F_VERSION = 31n;
222
+ export const EXPECTED_F_VERSION = 38n;
212
223
  export async function assertVersion(c, expected = EXPECTED_VERSION) {
213
224
  const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
214
225
  // three independent reads: one round trip, not three in a row