@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 +58 -5
- package/dist/admin.d.ts +16 -36
- package/dist/admin.js +26 -57
- package/dist/chains.d.ts +1 -1
- package/dist/client.d.ts +5 -5
- package/dist/client.js +10 -3
- package/dist/fpool.js +3 -2
- package/dist/generated.d.ts +1569 -2184
- package/dist/generated.js +547 -875
- package/dist/history.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/indexer.d.ts +1 -1
- package/dist/indexer.js +5 -12
- package/dist/keys.d.ts +39 -52
- package/dist/keys.js +59 -38
- package/dist/liquidity.d.ts +0 -23
- package/dist/liquidity.js +5 -32
- package/dist/pools.d.ts +23 -14
- package/dist/pools.js +36 -28
- package/dist/positions.d.ts +2 -7
- package/dist/positions.js +4 -12
- package/package.json +1 -1
- package/src/admin.ts +42 -85
- package/src/chains.ts +1 -1
- package/src/client.ts +12 -5
- package/src/fpool.ts +3 -2
- package/src/generated.ts +549 -877
- package/src/history.ts +1 -1
- package/src/index.ts +1 -1
- package/src/indexer.ts +6 -13
- package/src/keys.ts +80 -74
- package/src/liquidity.ts +5 -46
- package/src/pools.ts +45 -33
- package/src/positions.ts +4 -13
package/dist/positions.d.ts
CHANGED
|
@@ -109,16 +109,11 @@ export declare function positionQuote(p: {
|
|
|
109
109
|
cap: bigint;
|
|
110
110
|
capped: boolean;
|
|
111
111
|
}, x: bigint): bigint;
|
|
112
|
-
/**
|
|
113
|
-
* The mint fee a create form presets: the least the managers accept, twice the swap fee (C 12 / F 38, decision
|
|
114
|
-
* 078: `2 * swapFee <= mintFee <= {@link MINT_FEE_MAX}`). The creator selects it in the key; there is no menu.
|
|
115
|
-
*/
|
|
116
|
-
export declare function presetMintFee(swapFee: bigint): bigint;
|
|
117
112
|
/**
|
|
118
113
|
* The one-time mint fee at log-price `x`, in quote units — the amount `_mintCore` pulls ON TOP of
|
|
119
114
|
* the position's own legs, so a mint's total quote pull is `positionQuote(p, x) + mintFee(p, x, rate)`.
|
|
120
|
-
* `rate` is the MARKET's mint fee
|
|
121
|
-
* fixed for life; there is no global `MINT_FEE`.
|
|
115
|
+
* `rate` is the MARKET's mint fee, WAD of L (`mintFeeOfKey(key)`): the fee list's next entry after the key's swap fee
|
|
116
|
+
* (C 18, decision 099), fixed for life; there is no global `MINT_FEE`.
|
|
122
117
|
*
|
|
123
118
|
* Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
|
|
124
119
|
* capped class spot has already passed (`cap <= x`). Anything earning pays `rate · L`, all of it
|
package/dist/positions.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { encodeAbiParameters, keccak256, parseAbiItem } from "viem";
|
|
9
9
|
import { lensCAbi, managerCAbi } from "./generated.js";
|
|
10
10
|
import { managerC, lensC } from "./client.js";
|
|
11
|
-
import {
|
|
11
|
+
import { poolId, tickSpacingOf } from "./keys.js";
|
|
12
12
|
/** `CPoolState.POSITIONS_SLOT`: the manager's `positions` mapping (`forge inspect CPoolManager storageLayout`). */
|
|
13
13
|
const C_POSITIONS_SLOT = 4n;
|
|
14
14
|
const U128 = (1n << 128n) - 1n;
|
|
@@ -60,7 +60,7 @@ export async function feesOf(c, id, owner) {
|
|
|
60
60
|
* reads and no id lookup.
|
|
61
61
|
*/
|
|
62
62
|
export async function getHolderPosition(c, key, owner, floor, cap = NO_CAP) {
|
|
63
|
-
const id = positionId(poolId(key), key
|
|
63
|
+
const id = positionId(poolId(key), tickSpacingOf(key), floor, cap);
|
|
64
64
|
const [cls, shares, claimableFees] = await Promise.all([
|
|
65
65
|
getPositionClass(c, id),
|
|
66
66
|
balanceOf(c, owner, id),
|
|
@@ -143,19 +143,11 @@ export function positionQuote(p, x) {
|
|
|
143
143
|
const upper = p.capped && p.cap <= x ? p.cap : x;
|
|
144
144
|
return (p.L * (upper - p.floor)) / 10n ** 18n;
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
* The mint fee a create form presets: the least the managers accept, twice the swap fee (C 12 / F 38, decision
|
|
148
|
-
* 078: `2 * swapFee <= mintFee <= {@link MINT_FEE_MAX}`). The creator selects it in the key; there is no menu.
|
|
149
|
-
*/
|
|
150
|
-
export function presetMintFee(swapFee) {
|
|
151
|
-
const m = 2n * swapFee;
|
|
152
|
-
return m > MINT_FEE_MAX ? MINT_FEE_MAX : m;
|
|
153
|
-
}
|
|
154
146
|
/**
|
|
155
147
|
* The one-time mint fee at log-price `x`, in quote units — the amount `_mintCore` pulls ON TOP of
|
|
156
148
|
* the position's own legs, so a mint's total quote pull is `positionQuote(p, x) + mintFee(p, x, rate)`.
|
|
157
|
-
* `rate` is the MARKET's mint fee
|
|
158
|
-
* fixed for life; there is no global `MINT_FEE`.
|
|
149
|
+
* `rate` is the MARKET's mint fee, WAD of L (`mintFeeOfKey(key)`): the fee list's next entry after the key's swap fee
|
|
150
|
+
* (C 18, decision 099), fixed for life; there is no global `MINT_FEE`.
|
|
159
151
|
*
|
|
160
152
|
* Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
|
|
161
153
|
* capped class spot has already passed (`cap <= x`). Anything earning pays `rate · L`, all of it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logswap/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.102",
|
|
4
4
|
"description": "TypeScript SDK for Logswap, the liquidity primitive introducing the logarithmic invariant — typed wrappers over the ManagerF / ManagerC, RouterF / RouterC and LensF / LensC surface.",
|
|
5
5
|
"license": "GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|
package/src/admin.ts
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type { Address, Hash } from "viem";
|
|
19
|
-
import { poolId as keyId, type PoolKey } from "./keys.js";
|
|
20
|
-
import { managerC,
|
|
19
|
+
import { poolId as keyId, FEE_LIST, type PoolKey } from "./keys.js";
|
|
20
|
+
import { managerC, type LogswapClient, type Side } from "./client.js";
|
|
21
21
|
import { getPool } from "./pools.js";
|
|
22
|
-
import { managerCAbi, managerFAbi, policyFAbi,
|
|
22
|
+
import { managerCAbi, managerFAbi, policyFAbi, policyCAbi, policyRegistryAbi } from "./generated.js";
|
|
23
23
|
import { bytes32ToText, fFeeListed, fPoolKindOfPolicy, fPolicyTermsOf, textToBytes32, type FPoolKind } from "./fpool.js";
|
|
24
24
|
|
|
25
25
|
function wallet(c: LogswapClient) {
|
|
@@ -40,9 +40,9 @@ function write(c: LogswapClient, address: Address, abi: readonly unknown[], func
|
|
|
40
40
|
*/
|
|
41
41
|
export async function cSwapFeeTax(c: LogswapClient, policy?: Address): Promise<{ tax: bigint; max: bigint }> {
|
|
42
42
|
const address = policy ?? c.addresses.publicPolicyC;
|
|
43
|
-
if (!address) throw new Error("logswap: this deployment carries no C
|
|
43
|
+
if (!address) throw new Error("logswap: this deployment carries no C policy (addresses.publicPolicyC); pass one");
|
|
44
44
|
const [tax, max] = await Promise.all([
|
|
45
|
-
c.public.readContract({ address, abi:
|
|
45
|
+
c.public.readContract({ address, abi: policyCAbi, functionName: "swapFeeTax" } as never) as Promise<bigint>,
|
|
46
46
|
c.public.readContract({ address: managerC(c), abi: managerCAbi, functionName: "SWAP_FEE_TAX_MAX" }),
|
|
47
47
|
]);
|
|
48
48
|
return { tax, max };
|
|
@@ -77,7 +77,7 @@ export async function policyApproved(c: LogswapClient, policy: Address): Promise
|
|
|
77
77
|
/** One policy on the registry's list, with what it is. */
|
|
78
78
|
export interface RegistryEntry {
|
|
79
79
|
policy: Address;
|
|
80
|
-
/** 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 (
|
|
80
|
+
/** 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`). */
|
|
81
81
|
kind: FPoolKind | null;
|
|
82
82
|
/** The name recorded at approval (`approve(policy, name)`). */
|
|
83
83
|
name: string;
|
|
@@ -220,25 +220,14 @@ export async function policyFeeAllowed(c: LogswapClient, policy: Address, swapFe
|
|
|
220
220
|
return { curated: feeMask !== 0, listed, allowed: listed };
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
/** `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. */
|
|
224
|
-
export type CreationMode = "open" | "sponsorOnly";
|
|
225
|
-
const CREATION_MODES: readonly CreationMode[] = ["open", "sponsorOnly"];
|
|
226
|
-
|
|
227
|
-
/** `PolicyRegistry.setCreationMode(policy, mode)` (the LOG Authority). A sponsored policy is approved `sponsorOnly`. */
|
|
228
|
-
export async function registrySetCreationMode(c: LogswapClient, policy: Address, mode: CreationMode): Promise<Hash> {
|
|
229
|
-
return registryWrite(c, "setCreationMode", [policy, CREATION_MODES.indexOf(mode)]);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
223
|
/** `PolicyRegistry.setForwarderTrusted` (the LOG Authority): a router whose `user()` names the creator. Moved off the public policy in F version 33. */
|
|
233
224
|
export async function registrySetForwarderTrusted(c: LogswapClient, forwarder: Address, trusted: boolean): Promise<Hash> {
|
|
234
225
|
return registryWrite(c, "setForwarderTrusted", [forwarder, trusted]);
|
|
235
226
|
}
|
|
236
227
|
|
|
237
|
-
/** `PolicyRegistry.creationMode(policy)`. */
|
|
238
228
|
/**
|
|
239
229
|
* `PolicyRegistry.userOf(caller)` (C 15, decision 097): the account a caller acts for — the user a trusted forwarder
|
|
240
|
-
* (a router) names, else the caller itself. The account
|
|
241
|
-
* first minter; what a create form compares to the key's `creator`.
|
|
230
|
+
* (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.
|
|
242
231
|
*/
|
|
243
232
|
export async function registryUserOf(c: LogswapClient, caller: Address): Promise<Address> {
|
|
244
233
|
const registry = await policyRegistryOf(c);
|
|
@@ -246,94 +235,62 @@ export async function registryUserOf(c: LogswapClient, caller: Address): Promise
|
|
|
246
235
|
return (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "userOf", args: [caller] } as never)) as Address;
|
|
247
236
|
}
|
|
248
237
|
|
|
249
|
-
export async function registryCreationMode(c: LogswapClient, policy: Address): Promise<CreationMode> {
|
|
250
|
-
const registry = await policyRegistryOf(c);
|
|
251
|
-
if (registry === ZERO) return "open";
|
|
252
|
-
const m = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "creationMode", args: [policy] } as never)) as number;
|
|
253
|
-
return CREATION_MODES[Number(m)] ?? "open";
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/** Whether `policy` (a `SponsorPolicyC`) admits C tick spacing `tickSpacing`: it curates spacings (`spacingCurated`) and lists it, or it does not curate. */
|
|
257
|
-
export async function policySpacingAllowed(c: LogswapClient, policy: Address, tickSpacing: bigint): Promise<{ curated: boolean; listed: boolean; allowed: boolean }> {
|
|
258
|
-
const [curated, listed] = await Promise.all([
|
|
259
|
-
c.public.readContract({ address: policy, abi: sponsorPolicyCAbi, functionName: "spacingCurated" } as never) as Promise<boolean>,
|
|
260
|
-
c.public.readContract({ address: policy, abi: sponsorPolicyCAbi, functionName: "spacingListed", args: [tickSpacing] } as never) as Promise<boolean>,
|
|
261
|
-
]);
|
|
262
|
-
return { curated, listed, allowed: !curated || listed };
|
|
263
|
-
}
|
|
264
|
-
|
|
265
238
|
export interface CGateRules {
|
|
266
|
-
/**
|
|
267
|
-
* The registry admits `creator` to create under `key.policy` (creation mode and sponsor binding; decisions 073, 097, 098):
|
|
268
|
-
* `admit(policy, creator, creator)` resolves to `creator`. Both managers then require the initializer to BE the key's creator (`NotCreator`).
|
|
269
|
-
*/
|
|
239
|
+
/** The policy admits `creator` (`PolicyBase._admitBirth`): anyone on an open policy, the policy's authority on a closed one (`Refused`). */
|
|
270
240
|
creatorOk: boolean;
|
|
271
241
|
/** The quote is on the policy's list, or the policy lists none (`quoteCurated`). */
|
|
272
242
|
quoteOk: boolean;
|
|
273
|
-
/** The
|
|
243
|
+
/** The base is on the policy's list, or the policy lists none (`baseCurated`; `BaseNotListed`). */
|
|
244
|
+
baseOk: boolean;
|
|
245
|
+
/** The swap fee's index is on the policy's `feeMask` (an empty mask lists all eight; `FeeNotListed`). The mint fee follows it. */
|
|
274
246
|
feeOk: boolean;
|
|
275
|
-
/**
|
|
276
|
-
mintFeeOk: boolean;
|
|
277
|
-
/** The tick spacing is on the policy's list, or it lists none (`spacingCurated`). */
|
|
278
|
-
spacingOk: boolean;
|
|
279
|
-
/** A canonical policy (the LOG's open instance) needs `salt` zero (`NotCanonical`); a desk's may run several markets of one shape. */
|
|
247
|
+
/** An open policy needs `salt` zero (`NotCanonical`); a closed one may run several markets of one shape. */
|
|
280
248
|
saltOk: boolean;
|
|
249
|
+
/** The registry lists the policy and its sunset has not passed (`PolicyNotApproved`); true on a deployment with no registry. */
|
|
250
|
+
policyOk: boolean;
|
|
281
251
|
/** This exact market (the key's id) is already initialized: another is a different key. */
|
|
282
252
|
exists: boolean;
|
|
283
|
-
/**
|
|
284
|
-
routerTrusted: boolean;
|
|
285
|
-
/** Every check passes: the policy would admit this market from this creator (the manager checks the fee domain, `BadParam`). */
|
|
253
|
+
/** Every check passes: the policy would admit this market from this creator (the manager checks the two indices, `BadParam`). */
|
|
286
254
|
admitted: boolean;
|
|
287
255
|
}
|
|
288
256
|
|
|
289
257
|
/**
|
|
290
|
-
* A
|
|
291
|
-
* is asked (
|
|
292
|
-
*
|
|
293
|
-
* trusted forwarder's `user()`). The policy's pair list is gone (098).
|
|
258
|
+
* A C policy's birth checks for one candidate market and creator, in one round of reads — what the create form shows before a
|
|
259
|
+
* wallet is asked (C 18, decisions 099, 100: `PolicyC.mayInit`). The policy is `key.policy`; `creator` is the account that will call
|
|
260
|
+
* {@link initializeMarket}. The spacing is the manager's list ({@link SPACING_LIST}) and none of the policy's.
|
|
294
261
|
*/
|
|
295
|
-
export async function cGateRules(c: LogswapClient, a: { key: PoolKey; creator
|
|
262
|
+
export async function cGateRules(c: LogswapClient, a: { key: PoolKey; creator: Address; gate?: Address }): Promise<CGateRules> {
|
|
296
263
|
const g = a.gate ?? (a.key.policy as Address);
|
|
297
264
|
const rd = <T>(functionName: string, args: readonly unknown[] = []) =>
|
|
298
|
-
c.public.readContract({ address: g, abi:
|
|
265
|
+
c.public.readContract({ address: g, abi: policyCAbi, functionName, args } as never) as Promise<T>;
|
|
299
266
|
const { key } = a;
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
rd<boolean>("spacingCurated"),
|
|
312
|
-
rd<boolean>("spacingListed", [key.tickSpacing]),
|
|
313
|
-
rd<boolean>("canonical"),
|
|
314
|
-
getPool(c, key),
|
|
315
|
-
registry === ZERO ? Promise.resolve(false) : registryRd<boolean>("forwarderTrusted", [router]),
|
|
316
|
-
registry === ZERO
|
|
317
|
-
? Promise.resolve(true)
|
|
318
|
-
: registryRd<Address>("admit", [g, creator, creator]).then((who) => who.toLowerCase() === creator.toLowerCase(), () => false),
|
|
319
|
-
]);
|
|
267
|
+
const [open, authority, feeMask, quoteCurated, quoteListed, baseCurated, baseListed, state, policyOk] = await Promise.all([
|
|
268
|
+
rd<boolean>("open"),
|
|
269
|
+
rd<Address>("authority"),
|
|
270
|
+
rd<number | bigint>("feeMask"),
|
|
271
|
+
rd<boolean>("quoteCurated"),
|
|
272
|
+
rd<boolean>("quoteListed", [key.quote]),
|
|
273
|
+
rd<boolean>("baseCurated"),
|
|
274
|
+
rd<boolean>("baseListed", [key.base]),
|
|
275
|
+
getPool(c, key),
|
|
276
|
+
policyApproved(c, g),
|
|
277
|
+
]);
|
|
320
278
|
const r = {
|
|
321
|
-
creatorOk,
|
|
279
|
+
creatorOk: open || authority.toLowerCase() === a.creator.toLowerCase(),
|
|
322
280
|
quoteOk: !quoteCurated || quoteListed,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
281
|
+
baseOk: !baseCurated || baseListed,
|
|
282
|
+
feeOk: key.swapFeeIdx < FEE_LIST.length && fFeeListed(Number(feeMask), key.swapFeeIdx),
|
|
283
|
+
saltOk: !open || key.salt === "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
284
|
+
policyOk,
|
|
327
285
|
exists: state.initialized,
|
|
328
|
-
routerTrusted,
|
|
329
286
|
};
|
|
330
|
-
return { ...r, admitted: r.creatorOk && r.quoteOk && r.
|
|
287
|
+
return { ...r, admitted: r.creatorOk && r.quoteOk && r.baseOk && r.feeOk && r.saltOk && r.policyOk && !r.exists };
|
|
331
288
|
}
|
|
332
289
|
|
|
333
290
|
/**
|
|
334
291
|
* Every refusal a birth can meet at a policy or the registry (064, 065, 098; policy.md §4.4), for `decodeErrorResult` on a
|
|
335
|
-
* failed simulation: the
|
|
336
|
-
* `BaseNotListed`, `TooManyLegs`, `AlreadyHeld`, …) and the registry's
|
|
292
|
+
* failed simulation: the C policy's errors, the F policy's (`Refused`, `NotCanonical`, `FeeNotListed`, `QuoteNotListed`,
|
|
293
|
+
* `BaseNotListed`, `TooManyLegs`, `AlreadyHeld`, …) and the registry's `NotListed`. One entry per distinct signature.
|
|
337
294
|
*/
|
|
338
295
|
type AbiError = { type: "error"; name: string; inputs: readonly { type: string; name?: string }[] };
|
|
339
296
|
const isAbiError = (x: { type: string }): x is AbiError => x.type === "error";
|
|
@@ -342,10 +299,10 @@ export const gateErrorAbi: readonly AbiError[] = (() => {
|
|
|
342
299
|
const sig = (x: AbiError) => `${x.name}(${x.inputs.map((i) => i.type).join(",")})`;
|
|
343
300
|
const all = (abi: readonly unknown[]) => (abi as readonly { type: string }[]).filter(isAbiError);
|
|
344
301
|
const errors: AbiError[] = [
|
|
345
|
-
...all(
|
|
302
|
+
...all(policyCAbi),
|
|
346
303
|
...all(policyFAbi),
|
|
347
|
-
//
|
|
348
|
-
...all(policyRegistryAbi).filter((x) =>
|
|
304
|
+
// who creates under a policy is the policy's rule (C 18, decision 100); the registry only lists the policy
|
|
305
|
+
...all(policyRegistryAbi).filter((x) => x.name === "NotListed"),
|
|
349
306
|
];
|
|
350
307
|
return errors.filter((x) => (seen.has(sig(x)) ? false : (seen.add(sig(x)), true)));
|
|
351
308
|
})();
|
package/src/chains.ts
CHANGED
|
@@ -168,7 +168,7 @@ export interface LogswapDeployment {
|
|
|
168
168
|
polPolicy: Address;
|
|
169
169
|
/** The LOG's pad policy on F (`PolicyF`, `seedToDead`: income-only harvests, never closes). */
|
|
170
170
|
padPolicy: Address;
|
|
171
|
-
/** The LOG's open
|
|
171
|
+
/** 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. */
|
|
172
172
|
publicPolicyC?: Address;
|
|
173
173
|
/** The devnet's token factory; local deployments only. */
|
|
174
174
|
tokenFactory?: Address;
|
package/src/client.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface LogswapAddresses {
|
|
|
27
27
|
* The C stack is optional: F ships first, and a chain that has not opted into C carries none.
|
|
28
28
|
*/
|
|
29
29
|
managerC?: Address;
|
|
30
|
-
/** C's user entry: the batch, the named one-action entries,
|
|
30
|
+
/** C's user entry: the batch, the named one-action entries, Permit2 (a market is opened on the manager). Its own Permit2 spender. */
|
|
31
31
|
routerC?: Address;
|
|
32
32
|
/** C's read-only lens: ladder derivations and views. */
|
|
33
33
|
lensC?: Address;
|
|
@@ -42,7 +42,7 @@ export interface LogswapAddresses {
|
|
|
42
42
|
privatePolicy?: Address;
|
|
43
43
|
polPolicy?: Address;
|
|
44
44
|
padPolicy?: Address;
|
|
45
|
-
/** The LOG's open
|
|
45
|
+
/** The LOG's open policy on C (`PolicyC`): the policy of a public market. Absent with no C stack. */
|
|
46
46
|
publicPolicyC?: Address;
|
|
47
47
|
/**
|
|
48
48
|
* The policy registry: what a pool of each kind may be born under, and the
|
|
@@ -219,7 +219,7 @@ function guardChain(wallet: WalletClient, pub: PublicClient): WalletClient {
|
|
|
219
219
|
* **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
|
|
220
220
|
* `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
|
|
221
221
|
* LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
|
|
222
|
-
* each market's, answered by its policy at birth (
|
|
222
|
+
* each market's, answered by its policy at birth (`PolicyC.swapFeeTax`, an immutable; `SponsorPolicyC` before C 18) and
|
|
223
223
|
* read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
|
|
224
224
|
* permissionless and pays the treasury. No pool id moved.
|
|
225
225
|
* 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
|
|
@@ -247,7 +247,14 @@ function guardChain(wallet: WalletClient, pub: PublicClient): WalletClient {
|
|
|
247
247
|
// `PositionMinted(poolId, to, id, sender, payer, shares, dBase, dQuote)`; `ProtocolFeesCollected(poolId, sender, to, amount)`;
|
|
248
248
|
// `ClassRegistered(poolId, id, floor, cap, capped)` (poolId first); the account acted on is `owner` on `PositionBurned` (was `from`),
|
|
249
249
|
// `PositionUpdated` and `FeesClaimed` (was `holder`); `RouterC`'s entries and `Settle` name the receiver `to` (was `recipient`). No pool id moved.
|
|
250
|
-
|
|
250
|
+
// 18 (decisions 099, 100): `PoolKeyC` is `(quote, base, swapFeeIdx, spacingIdx, policy, salt)` — every C pool id and position id moved; the
|
|
251
|
+
// 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)`
|
|
252
|
+
// mints the backstop in the call (the caller pays dust of both tokens by allowance to the manager) and `RouterC.createMarket` is gone;
|
|
253
|
+
// `PoolCreated` carries the two indices; `claim(poolId, id, owner, to)`; `PoolView` has no `backstopSeeded`; `LensC.params()` is
|
|
254
|
+
// `(spacingList, noCap, cVersion)`; `PolicyC` replaces `SponsorPolicyC` (F's gate surface plus `baseListed`, `swapFeeTax`, `mayInit`); the
|
|
255
|
+
// registry lost its creation modes (`admit`, `creationMode`, `setCreationMode`, `sponsorOf`). `SpacingZero`, `BackstopTooSmall`,
|
|
256
|
+
// `BackstopMustBeUncapped` and `NotCreator` are gone, `PolicyNotApproved` is new.
|
|
257
|
+
export const EXPECTED_VERSION = 20n;
|
|
251
258
|
/**
|
|
252
259
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
253
260
|
* 4 was the income-only harvest cut).
|
|
@@ -371,7 +378,7 @@ export const EXPECTED_VERSION = 17n;
|
|
|
371
378
|
// poolL, supply)`; `SharesBurned` indexes `gen` and names `owner` (was `from`), `DividendClaimed` names `owner` (was `holder`);
|
|
372
379
|
// `PoolCreated(poolId, quote, creator, policy, bases, swapFeeIdx, salt)` (`creator` a topic, `policy` data); `LiquidityDeployed`,
|
|
373
380
|
// `IncomeHarvested` and `GenerationFrozen` carry `operator` as a topic; `RouterF.BadToken` is `WrongToken`. No pool id moved.
|
|
374
|
-
export const EXPECTED_F_VERSION =
|
|
381
|
+
export const EXPECTED_F_VERSION = 44n;
|
|
375
382
|
|
|
376
383
|
export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSION): Promise<void> {
|
|
377
384
|
const { managerCAbi, managerFAbi } = await import("./generated.js");
|
package/src/fpool.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { managerFAbi, lensFAbi, routerFAbi, policyFAbi, policyRegistryAbi } from
|
|
|
45
45
|
*/
|
|
46
46
|
export { managerFAbi, policyFAbi };
|
|
47
47
|
import { clientChainId, type LogswapClient } from "./client.js";
|
|
48
|
+
import { FEE_LIST, FEE_LIST_BP } from "./keys.js";
|
|
48
49
|
import { findQuoteResult } from "./quote.js";
|
|
49
50
|
import { fallBackUnlessRejected, signerFor } from "./write.js";
|
|
50
51
|
import { getEventLogs } from "./history.js";
|
|
@@ -1094,9 +1095,9 @@ const ZERO_SALT = `0x${"0".repeat(64)}` as const;
|
|
|
1094
1095
|
// ─── the fee list (policy.md §6) ──────────────────────────────────────────────
|
|
1095
1096
|
|
|
1096
1097
|
/** `FeeParams.FEE_LIST` in bp: the eight swap fees an F pool may be born with. The key carries the index. */
|
|
1097
|
-
export const F_FEE_LIST_BP =
|
|
1098
|
+
export const F_FEE_LIST_BP = FEE_LIST_BP;
|
|
1098
1099
|
/** The list in WAD (1 bp = 1e14). No zero: the fee-free pool cannot be born. */
|
|
1099
|
-
export const F_FEE_LIST: readonly bigint[] =
|
|
1100
|
+
export const F_FEE_LIST: readonly bigint[] = FEE_LIST;
|
|
1100
1101
|
|
|
1101
1102
|
/** The fee at `idx` of the list, WAD. Throws off the list. */
|
|
1102
1103
|
export function fFeeOf(idx: number): bigint {
|