@logswap/sdk 0.5.79 → 0.5.80
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.d.ts +702 -51
- package/dist/admin.js +53 -46
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/fpool.d.ts +185 -119
- package/dist/fpool.js +41 -42
- package/dist/generated.d.ts +1280 -670
- package/dist/generated.js +781 -465
- package/dist/history.d.ts +1 -2
- package/dist/history.js +3 -5
- package/dist/indexer.js +2 -1
- package/dist/keys.d.ts +6 -0
- package/dist/keys.js +2 -0
- package/dist/pools.d.ts +3 -3
- package/dist/pools.js +2 -1
- package/package.json +1 -1
- package/src/admin.ts +64 -54
- package/src/client.ts +2 -2
- package/src/fpool.ts +59 -55
- package/src/generated.ts +781 -465
- package/src/history.ts +3 -4
- package/src/indexer.ts +3 -2
- package/src/keys.ts +8 -0
- package/src/pools.ts +6 -5
package/dist/admin.js
CHANGED
|
@@ -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
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
181
|
+
* `PadPolicy.setSchedule` (decisions 056, 067, 070, 073): the rung's growth and the RANGE a creator chooses his cut of the pot
|
|
182
|
+
* inside at creation (its top ≤ the F manager's `PAYEE_CUT_MAX`). The rest of the pot deepens the bid — nothing is bought or
|
|
183
|
+
* burnt since F version 28, and the protocol takes no cut of the pot since F version 33 (its revenue is the income fee,
|
|
184
|
+
* {@link padSetIncomeFeeRate}). 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.
|
|
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
|
|
@@ -216,17 +216,20 @@ export async function padThreshold(c, policy, poolId, rung) {
|
|
|
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,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
]);
|
|
225
|
-
|
|
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]);
|
|
225
|
+
}
|
|
226
|
+
/** `PadPolicy.setIncomeFeeRate` (decision 073): the share of its new income dividend the dead shares pay LOG Treasury, WAD, at most 50%. The policy sponsor's. */
|
|
227
|
+
export async function padSetIncomeFeeRate(c, policy, rate) {
|
|
228
|
+
return write(c, policy, padPolicyAbi, "setIncomeFeeRate", [rate]);
|
|
226
229
|
}
|
|
227
|
-
/** `PolPolicy.
|
|
228
|
-
export async function
|
|
229
|
-
return write(c, policy, polPolicyAbi, "
|
|
230
|
+
/** `PolPolicy.setIncomeFeeRate` (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 polSetIncomeFeeRate(c, policy, rate) {
|
|
232
|
+
return write(c, policy, polPolicyAbi, "setIncomeFeeRate", [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) {
|
|
@@ -282,13 +285,26 @@ export async function policyMintFeeMenu(c, policy, candidates) {
|
|
|
282
285
|
const [curated, ...flags] = await Promise.all([rd("mintFeeCurated"), ...candidates.map((m) => rd("mintFeeListed", [m]))]);
|
|
283
286
|
return { curated, listed: candidates.filter((_, i) => flags[i]) };
|
|
284
287
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
+
const CREATION_MODES = ["open", "restricted", "sponsorOnly"];
|
|
289
|
+
/** `PolicyRegistry.setCreationMode(policy, mode)` (the LOG Authority): replaces the per-policy creator lists (064). A sponsor-bound policy cannot leave `sponsorOnly`. */
|
|
290
|
+
export async function registrySetCreationMode(c, policy, mode) {
|
|
291
|
+
return registryWrite(c, "setCreationMode", [policy, CREATION_MODES.indexOf(mode)]);
|
|
288
292
|
}
|
|
289
|
-
/** `
|
|
290
|
-
export async function
|
|
291
|
-
return
|
|
293
|
+
/** `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. */
|
|
294
|
+
export async function registrySetInitializerListed(c, policy, who, allowed) {
|
|
295
|
+
return registryWrite(c, "setInitializerListed", [policy, who, allowed]);
|
|
296
|
+
}
|
|
297
|
+
/** `PolicyRegistry.setForwarderTrusted` (the LOG Authority): a router whose `user()` names the creator. Moved off the public policy in F version 33. */
|
|
298
|
+
export async function registrySetForwarderTrusted(c, forwarder, trusted) {
|
|
299
|
+
return registryWrite(c, "setForwarderTrusted", [forwarder, trusted]);
|
|
300
|
+
}
|
|
301
|
+
/** `PolicyRegistry.creationMode(policy)`. */
|
|
302
|
+
export async function registryCreationMode(c, policy) {
|
|
303
|
+
const registry = await policyRegistryOf(c);
|
|
304
|
+
if (registry === ZERO)
|
|
305
|
+
return "open";
|
|
306
|
+
const m = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "creationMode", args: [policy] }));
|
|
307
|
+
return CREATION_MODES[Number(m)] ?? "open";
|
|
292
308
|
}
|
|
293
309
|
/** `PublicPolicy.setPairListed` (064): a C pair a market may be born on while pairs are curated. Directional (base, quote). */
|
|
294
310
|
export async function gateSetPairListed(c, policy, base, quote, listed) {
|
|
@@ -302,33 +318,27 @@ export async function gateSetPairCurated(c, policy, curated) {
|
|
|
302
318
|
export async function gateSetSpacingListed(c, policy, tickSpacing, listed) {
|
|
303
319
|
return write(c, policy, publicPolicyAbi, "setSpacingListed", [tickSpacing, listed]);
|
|
304
320
|
}
|
|
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
321
|
/**
|
|
310
322
|
* @deprecated C version 8 fixes the gate at construction (066): there is no `setGate`. Open or close
|
|
311
|
-
* C through the gate's lists (`
|
|
323
|
+
* C through the gate's lists (`registrySetCreationMode`, `gateSetPairCurated`, `gateSetSpacingListed`, …).
|
|
312
324
|
*/
|
|
313
325
|
export async function setCGate(_c, _gate) {
|
|
314
326
|
throw new Error("logswap: the C gate is fixed at construction since C version 8 (decision 066); change its lists instead");
|
|
315
327
|
}
|
|
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
328
|
/**
|
|
321
329
|
* 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).
|
|
323
|
-
*
|
|
330
|
+
* the create form shows before a wallet is asked (064, 073). The policy is `key.policy`; the registry
|
|
331
|
+
* is asked `admit(policy, caller, 0)`, with the caller being the router when it is a trusted forwarder
|
|
332
|
+
* (it then names `creator` itself) and `creator` otherwise.
|
|
324
333
|
*/
|
|
325
334
|
export async function cGateRules(c, a) {
|
|
326
|
-
const g = a.gate ??
|
|
335
|
+
const g = a.gate ?? a.key.policy;
|
|
327
336
|
const rd = (functionName, args = []) => c.public.readContract({ address: g, abi: publicPolicyAbi, functionName, args });
|
|
328
337
|
const { key } = a;
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
338
|
+
const registry = await policyRegistryOf(c);
|
|
339
|
+
const router = a.router ?? c.addresses.router;
|
|
340
|
+
const registryRd = (functionName, args) => c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName, args });
|
|
341
|
+
const [quoteCurated, quoteListed, pairCurated, pairListed, feeCurated, feeListed, spacingListed, market, routerTrusted, creatorOk] = await Promise.all([
|
|
332
342
|
rd("quoteCurated"),
|
|
333
343
|
rd("quoteListed", [key.quote]),
|
|
334
344
|
rd("pairCurated"),
|
|
@@ -337,10 +347,13 @@ export async function cGateRules(c, a) {
|
|
|
337
347
|
rd("feeListed", [key.swapFee]),
|
|
338
348
|
rd("spacingListed", [key.tickSpacing]),
|
|
339
349
|
rd("cMarketOf", [key.base, key.quote, key.swapFee]),
|
|
340
|
-
|
|
350
|
+
registry === ZERO ? Promise.resolve(false) : registryRd("forwarderTrusted", [router]),
|
|
351
|
+
registry === ZERO
|
|
352
|
+
? Promise.resolve(true)
|
|
353
|
+
: registryRd("admit", [g, a.creator, ZERO]).then(() => true, () => false),
|
|
341
354
|
]);
|
|
342
355
|
const r = {
|
|
343
|
-
creatorOk
|
|
356
|
+
creatorOk,
|
|
344
357
|
quoteOk: !quoteCurated || quoteListed,
|
|
345
358
|
pairOk: !pairCurated || pairListed,
|
|
346
359
|
feeOk: !feeCurated || feeListed,
|
|
@@ -357,16 +370,10 @@ export async function cGateRules(c, a) {
|
|
|
357
370
|
*/
|
|
358
371
|
export const gateErrorAbi = [
|
|
359
372
|
...publicPolicyAbi.filter((x) => x.type === "error"),
|
|
373
|
+
// creation admission moved to the registry in F 33 / C 10 (073): a refusal there surfaces through the manager's birth
|
|
374
|
+
...policyRegistryAbi.filter((x) => x.type === "error" && ["SponsorOnly", "InitializerNotListed", "InvalidForwardedUser", "NotListed"].includes(x.name)),
|
|
360
375
|
...padPolicyAbi.filter((x) => x.type === "error" && (x.name === "PadExists" || x.name === "NoThreshold")),
|
|
361
376
|
];
|
|
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
377
|
// ─── the LOG Treasury (066): receives, administers nothing ───────────────────
|
|
371
378
|
function manager(c, side) {
|
|
372
379
|
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 =
|
|
122
|
+
export declare const EXPECTED_VERSION = 10n;
|
|
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 =
|
|
134
|
+
export declare const EXPECTED_F_VERSION = 33n;
|
|
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,7 @@ 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 =
|
|
116
|
+
export const EXPECTED_VERSION = 10n;
|
|
117
117
|
/**
|
|
118
118
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
119
119
|
* 4 was the income-only harvest cut).
|
|
@@ -208,7 +208,7 @@ export const EXPECTED_VERSION = 9n;
|
|
|
208
208
|
// 31 (decision 072): `DividendClaimed` names the generation (`gen`, indexed, after `poolId`); `lock` / `unlock` emit
|
|
209
209
|
// `LienLocked` / `LienUnlocked`. No selector, storage layout or pool id moved.
|
|
210
210
|
// A breaking bump: raised in the same change.
|
|
211
|
-
export const EXPECTED_F_VERSION =
|
|
211
|
+
export const EXPECTED_F_VERSION = 33n;
|
|
212
212
|
export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
213
213
|
const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
|
|
214
214
|
// three independent reads: one round trip, not three in a row
|