@logswap/sdk 0.5.76 → 0.5.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chains.js ADDED
@@ -0,0 +1,186 @@
1
+ /**
2
+ * chains.ts — the chains log(swap) runs on, and their deployments.
3
+ *
4
+ * The release chains carry the contracts at ONE address each (CREATE3 through CreateX, contracts
5
+ * decision 069): the same `LogswapAddresses` on every chain. What differs per chain is the deploy
6
+ * block, the quote tokens, the explorer and the indexer. An address therefore names a contract only
7
+ * together with a chain id; every cache and every indexer URL in this SDK is per chain.
8
+ */
9
+ import { defineChain, getAddress, isAddress } from "viem";
10
+ import { arbitrum, base, foundry, mainnet, robinhood, robinhoodTestnet } from "viem/chains";
11
+ /** The logswap devnet (anvil, persisted with `--state`). No public RPC. */
12
+ export const logswapDevnet = defineChain({
13
+ id: 31339,
14
+ name: "log(swap) devnet",
15
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
16
+ rpcUrls: { default: { http: [] } },
17
+ testnet: true,
18
+ });
19
+ /** Default block span per `eth_getLogs` call: public endpoints refuse wider ranges (or cap the result). */
20
+ export const DEFAULT_MAX_LOG_RANGE = 2000n;
21
+ /** A local node answers any range. */
22
+ const LOCAL_MAX_LOG_RANGE = 1000000n;
23
+ const USDC = (address) => ({ symbol: "USDC", address, decimals: 6 });
24
+ const WETH = (address) => ({ symbol: "WETH", address, decimals: 18 });
25
+ function entry(chain, e) {
26
+ return {
27
+ chainId: chain.id,
28
+ name: chain.name,
29
+ chain,
30
+ nativeCurrency: chain.nativeCurrency,
31
+ testnet: chain.testnet ?? false,
32
+ maxLogRange: DEFAULT_MAX_LOG_RANGE,
33
+ ...e,
34
+ };
35
+ }
36
+ /** Every chain this SDK knows, by chain id. */
37
+ export const LOGSWAP_CHAINS = Object.freeze({
38
+ 1: entry(mainnet, {
39
+ network: "mainnet",
40
+ explorer: "https://etherscan.io",
41
+ publicRpc: "https://ethereum-rpc.publicnode.com",
42
+ devnet: false,
43
+ quotes: [USDC("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"), WETH("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")],
44
+ padQuote: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
45
+ }),
46
+ 8453: entry(base, {
47
+ network: "base",
48
+ explorer: "https://basescan.org",
49
+ publicRpc: "https://mainnet.base.org",
50
+ devnet: false,
51
+ quotes: [USDC("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"), WETH("0x4200000000000000000000000000000000000006")],
52
+ padQuote: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
53
+ }),
54
+ 42161: entry(arbitrum, {
55
+ network: "arbitrum",
56
+ explorer: "https://arbiscan.io",
57
+ publicRpc: "https://arb1.arbitrum.io/rpc",
58
+ devnet: false,
59
+ quotes: [USDC("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"), WETH("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1")],
60
+ padQuote: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
61
+ }),
62
+ // no native USDC: USDG is the dollar quote
63
+ 4663: entry(robinhood, {
64
+ network: "robinhood",
65
+ explorer: "https://robinhoodchain.blockscout.com",
66
+ publicRpc: "https://rpc.mainnet.chain.robinhood.com",
67
+ devnet: false,
68
+ quotes: [{ symbol: "USDG", address: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168", decimals: 6 }, WETH("0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73")],
69
+ padQuote: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
70
+ }),
71
+ 46630: entry(robinhoodTestnet, {
72
+ network: "robinhood-testnet",
73
+ explorer: robinhoodTestnet.blockExplorers.default.url,
74
+ publicRpc: robinhoodTestnet.rpcUrls.default.http[0],
75
+ devnet: false,
76
+ quotes: [],
77
+ }),
78
+ 31337: entry(foundry, { network: "local", publicRpc: "http://127.0.0.1:8545", devnet: true, quotes: [], maxLogRange: LOCAL_MAX_LOG_RANGE }),
79
+ 31339: entry(logswapDevnet, { network: "devnet", devnet: true, quotes: [], maxLogRange: LOCAL_MAX_LOG_RANGE }),
80
+ });
81
+ /** The production chains, in release order. */
82
+ export const RELEASE_CHAIN_IDS = [1, 8453, 42161, 4663];
83
+ /** The registry entry for `chainId`, or undefined for a chain this SDK does not list. */
84
+ export function logswapChain(chainId) {
85
+ return LOGSWAP_CHAINS[chainId];
86
+ }
87
+ /** A quote of `chainId` by symbol (case-insensitive), or undefined. */
88
+ export function quoteOf(chainId, symbol) {
89
+ const s = symbol.toLowerCase();
90
+ return LOGSWAP_CHAINS[chainId]?.quotes.find((q) => q.symbol.toLowerCase() === s);
91
+ }
92
+ /**
93
+ * The published deployments, by chain id. Empty until the release chains are deployed; a
94
+ * deployment is added here from its artifact in the release that ships it.
95
+ */
96
+ export const LOGSWAP_DEPLOYMENTS = Object.freeze({});
97
+ /** The published deployment on `chainId`, or undefined. */
98
+ export function deploymentFor(chainId) {
99
+ return LOGSWAP_DEPLOYMENTS[chainId];
100
+ }
101
+ const REQUIRED_ADDRESSES = [
102
+ "deployer",
103
+ "logAuthority",
104
+ "logTreasury",
105
+ "permit2",
106
+ "multicall3",
107
+ "policyRegistry",
108
+ "fPoolManager",
109
+ "cPoolManager",
110
+ "publicPolicy",
111
+ "privatePolicy",
112
+ "polPolicy",
113
+ "padPolicy",
114
+ "router",
115
+ "lens",
116
+ ];
117
+ const OPTIONAL_ADDRESSES = ["createX", "tokenFactory"];
118
+ function uint(o, k) {
119
+ const v = o[k];
120
+ if (typeof v === "bigint" && v >= 0n)
121
+ return v;
122
+ if (typeof v === "number" && Number.isSafeInteger(v) && v >= 0)
123
+ return BigInt(v);
124
+ if (typeof v === "string" && /^(0x[0-9a-fA-F]+|\d+)$/.test(v))
125
+ return BigInt(v);
126
+ throw new Error(`logswap: deployment artifact: "${k}" is ${JSON.stringify(v)}, expected a non-negative integer`);
127
+ }
128
+ function address(o, k) {
129
+ const v = o[k];
130
+ if (typeof v !== "string" || !isAddress(v, { strict: false })) {
131
+ throw new Error(`logswap: deployment artifact: "${k}" is ${JSON.stringify(v)}, expected an address`);
132
+ }
133
+ return getAddress(v);
134
+ }
135
+ /**
136
+ * Validate a deployment artifact (parsed JSON) and return it typed. Throws on a missing or
137
+ * malformed field, and on a `chainId` other than `opts.chainId` when given: one address set is valid
138
+ * on every release chain, so an artifact read for the wrong chain would otherwise load cleanly and
139
+ * scan from the wrong `deployBlock`.
140
+ */
141
+ export function deploymentFromArtifact(json, opts = {}) {
142
+ if (typeof json !== "object" || json === null || Array.isArray(json))
143
+ throw new Error("logswap: deployment artifact is not a JSON object");
144
+ const o = json;
145
+ const chainId = Number(uint(o, "chainId"));
146
+ if (opts.chainId !== undefined && chainId !== opts.chainId) {
147
+ throw new Error(`logswap: deployment artifact is for chain ${chainId}, expected chain ${opts.chainId}`);
148
+ }
149
+ const network = o.network;
150
+ if (typeof network !== "string" || network === "")
151
+ throw new Error(`logswap: deployment artifact: "network" is ${JSON.stringify(network)}`);
152
+ const d = {
153
+ chainId,
154
+ network,
155
+ deployBlock: uint(o, "deployBlock"),
156
+ cVersion: uint(o, "cVersion"),
157
+ fVersion: uint(o, "fVersion"),
158
+ };
159
+ if (o.deployTag !== undefined) {
160
+ if (typeof o.deployTag !== "string")
161
+ throw new Error(`logswap: deployment artifact: "deployTag" is ${JSON.stringify(o.deployTag)}`);
162
+ d.deployTag = o.deployTag;
163
+ }
164
+ for (const k of REQUIRED_ADDRESSES)
165
+ d[k] = address(o, k);
166
+ for (const k of OPTIONAL_ADDRESSES)
167
+ if (o[k] !== undefined)
168
+ d[k] = address(o, k);
169
+ return d;
170
+ }
171
+ /** The client's address set from a deployment. */
172
+ export function addressesOfDeployment(d) {
173
+ return {
174
+ cPoolManager: d.cPoolManager,
175
+ router: d.router,
176
+ lens: d.lens,
177
+ fPoolManager: d.fPoolManager,
178
+ publicPolicy: d.publicPolicy,
179
+ privatePolicy: d.privatePolicy,
180
+ polPolicy: d.polPolicy,
181
+ padPolicy: d.padPolicy,
182
+ policyRegistry: d.policyRegistry,
183
+ permit2: d.permit2,
184
+ ...(d.tokenFactory ? { tokenFactory: d.tokenFactory } : {}),
185
+ };
186
+ }
package/dist/client.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * the protocol, not configuration that grows.
9
9
  */
10
10
  import type { Address, PublicClient, WalletClient } from "viem";
11
+ import { type LogswapDeployment } from "./chains.js";
11
12
  export interface LogswapAddresses {
12
13
  /** The C singleton — a floor per position, on a tick ladder. ERC-6909 positions and token
13
14
  * claims live here. */
@@ -44,12 +45,35 @@ export interface LogswapClient {
44
45
  public: PublicClient;
45
46
  wallet?: WalletClient;
46
47
  addresses: LogswapAddresses;
48
+ /** The chain the client reads: the deployment's, else the public client's. Unset when neither says. */
49
+ chainId?: number;
50
+ /** The deployment's first block: the default `fromBlock` of every log scan. */
51
+ deployBlock?: bigint;
52
+ /** Block span of one `eth_getLogs` call on the chain path; wider scans are split. {@link DEFAULT_MAX_LOG_RANGE} when unset. */
53
+ maxLogRange?: bigint;
54
+ /**
55
+ * The rindexer GraphQL endpoint of THIS chain's indexer: the default `indexer` of every history
56
+ * read. The contracts sit at one address on every release chain, so an indexer's rows carry no
57
+ * chain a reader could filter on: one URL per chain.
58
+ */
59
+ indexerUrl?: string;
47
60
  }
48
- export declare function createLogswapClient(args: {
61
+ export interface CreateLogswapClientArgs {
49
62
  public: PublicClient;
50
63
  wallet?: WalletClient;
51
- addresses: LogswapAddresses;
52
- }): LogswapClient;
64
+ /** The addresses; derived from `deployment` when absent. One of the two is required. */
65
+ addresses?: LogswapAddresses;
66
+ /** A deployment ({@link deploymentFromArtifact}, {@link deploymentFor}): addresses, chain and deploy block. */
67
+ deployment?: LogswapDeployment;
68
+ /** Overrides the deployment's. */
69
+ deployBlock?: bigint;
70
+ /** Overrides the chain's default ({@link LogswapChain.maxLogRange}, else {@link DEFAULT_MAX_LOG_RANGE}). */
71
+ maxLogRange?: bigint;
72
+ indexerUrl?: string;
73
+ }
74
+ export declare function createLogswapClient(args: CreateLogswapClientArgs): LogswapClient;
75
+ /** The chain id the client reads: set at construction when known, else asked of the node. */
76
+ export declare function clientChainId(c: LogswapClient): Promise<number>;
53
77
  /**
54
78
  * Assert the deployment matches the ABI this build was generated against.
55
79
  *
@@ -84,8 +108,18 @@ export declare function createLogswapClient(args: {
84
108
  * fee (`swapFeeOf` and `DEFAULT_FEE` are gone); the mint fee is the market's, proposed at
85
109
  * `initialize` / `createMarket` and answered by the gate; the gate (`gate`, `setGate`) is the
86
110
  * public policy, set at construction. No pool id moved.
111
+ *
112
+ * **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
113
+ * `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
114
+ * LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
115
+ * each market's, answered by the gate (`PublicPolicy.swapFeeTax`, the LOG Authority's) at birth and
116
+ * read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
117
+ * permissionless and pays the treasury. No pool id moved.
118
+ * 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
119
+ * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
120
+ * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
87
121
  */
88
- export declare const EXPECTED_VERSION = 7n;
122
+ export declare const EXPECTED_VERSION = 9n;
89
123
  /**
90
124
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
91
125
  * 4 was the income-only harvest cut).
@@ -97,7 +131,7 @@ export declare const EXPECTED_VERSION = 7n;
97
131
  * passes it; when one lands, raise this constant in the same change, which is the discipline
98
132
  * `EXPECTED_VERSION` enforces mechanically and this one asks for.
99
133
  */
100
- export declare const EXPECTED_F_VERSION = 26n;
134
+ export declare const EXPECTED_F_VERSION = 30n;
101
135
  export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
102
136
  /**
103
137
  * The versions say the managers are the right code; this says the rest of the addresses belong
package/dist/client.js CHANGED
@@ -7,8 +7,34 @@
7
7
  * and a market is an `initialize(key, x0)` call rather than a deployment. So this is a constant of
8
8
  * the protocol, not configuration that grows.
9
9
  */
10
+ import { addressesOfDeployment, DEFAULT_MAX_LOG_RANGE, logswapChain } from "./chains.js";
10
11
  export function createLogswapClient(args) {
11
- return { public: args.public, wallet: args.wallet && guardChain(args.wallet, args.public), addresses: args.addresses };
12
+ const d = args.deployment;
13
+ const addresses = args.addresses ?? (d && addressesOfDeployment(d));
14
+ if (!addresses)
15
+ throw new Error("logswap: createLogswapClient needs `addresses` or `deployment`");
16
+ const readChain = args.public.chain?.id;
17
+ if (d && readChain !== undefined && readChain !== d.chainId) {
18
+ throw new Error(`logswap: the deployment is on chain ${d.chainId} but the public client reads chain ${readChain}`);
19
+ }
20
+ const chainId = d?.chainId ?? readChain;
21
+ const maxLogRange = args.maxLogRange ?? (chainId !== undefined ? logswapChain(chainId)?.maxLogRange : undefined) ?? DEFAULT_MAX_LOG_RANGE;
22
+ if (maxLogRange <= 0n)
23
+ throw new Error("logswap: maxLogRange must be positive");
24
+ const deployBlock = args.deployBlock ?? d?.deployBlock;
25
+ return {
26
+ public: args.public,
27
+ wallet: args.wallet && guardChain(args.wallet, args.public),
28
+ addresses,
29
+ maxLogRange,
30
+ ...(chainId !== undefined ? { chainId } : {}),
31
+ ...(deployBlock !== undefined ? { deployBlock } : {}),
32
+ ...(args.indexerUrl ? { indexerUrl: args.indexerUrl } : {}),
33
+ };
34
+ }
35
+ /** The chain id the client reads: set at construction when known, else asked of the node. */
36
+ export async function clientChainId(c) {
37
+ return c.chainId ?? c.public.chain?.id ?? (await c.public.getChainId());
12
38
  }
13
39
  /**
14
40
  * The wallet, with every signing call first checking that it is on the chain the reads come from.
@@ -76,8 +102,18 @@ function guardChain(wallet, pub) {
76
102
  * fee (`swapFeeOf` and `DEFAULT_FEE` are gone); the mint fee is the market's, proposed at
77
103
  * `initialize` / `createMarket` and answered by the gate; the gate (`gate`, `setGate`) is the
78
104
  * public policy, set at construction. No pool id moved.
105
+ *
106
+ * **8** since 2026-10-13 (logswap-contract decision 066): the collector is split into two roles —
107
+ * `feeCollector` / `proposeCollector` / `acceptCollector` are `treasury` / `proposeTreasury` (the
108
+ * LOG Authority's) / `acceptTreasury`; `setSwapFeeTax` and `setGate` leave the manager: the tax is
109
+ * each market's, answered by the gate (`PublicPolicy.swapFeeTax`, the LOG Authority's) at birth and
110
+ * read as `getPool(key).swapFeeTax`; the gate is fixed at construction; `collectProtocolFees(key)` is
111
+ * permissionless and pays the treasury. No pool id moved.
112
+ * 9 (decision 071): the events — one `Swap` on both managers (`taker`, `feeToken`), `CSwapState`, C's `swap`
113
+ * takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
114
+ * `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
79
115
  */
80
- export const EXPECTED_VERSION = 7n;
116
+ export const EXPECTED_VERSION = 9n;
81
117
  /**
82
118
  * The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
83
119
  * 4 was the income-only harvest cut).
@@ -149,16 +185,28 @@ export const EXPECTED_VERSION = 7n;
149
185
  // `harvestCut`, `setHarvestCut` are gone; a pad's split (creator's cut, token burn) rides in the key's salt.
150
186
  // 24 (logswap-contract#58): the pot splits in quote — `Terms.burn` is quote spent on a buy-and-burn, the
151
187
  // rest deepens the bid, no buy-in, `Regenerated` is (pot, payee, toPayee, cut, burnt, deepened), a pad's
152
- // salt carries `burnShare` of the pot (057); the mint fee all to the collector (058); `phi` → `swapFee`,
188
+ // salt carries `burnShare` of the pot (057); the mint fee all to the treasury (058, 066); `phi` → `swapFee`,
153
189
  // `MINT_FEE()` → `mintFee()`, the policies' fee tiers, a canonical public pool (059).
154
190
  // 25 (logswap-contract#59): the views moved behind `extsload` (062) — this SDK reads them through the
155
- // lens (`fPool`, `getFPools`, `fBundleOf`, `fDividendOf`, `fLienOf`); the capped F pool, `FPoolKey.cap`
191
+ // lens (`fPool`, `getFPools`, `fBundleOf`, `fDividendOf`, `fLienOf`); the capped F pool, `FPoolKey.cap` (`lnCapOverFloor` since 27)
156
192
  // appended so every pool id moved (061); the lien, `lock` / `unlock` (063); θ is `logFloor`, θ₀ `refLogFloor`.
157
193
  // 26 (logswap-contract#60): the mint fee is per pool, proposed at `initialize(key, mintFee)` and answered
158
194
  // by the policy's `onInitialize` from its menu (065); `MINT_FEE` is gone; a fee of 0 is no fee; the
159
195
  // policies curate creators, a public pool is uncapped, one pad per base (064). No pool id moved.
196
+ // 27 (decision 066): `FPoolKey.cap` → `lnCapOverFloor` (a name: no id moved); `feeCollector` → `treasury` (proposed by the LOG Authority, accepted by itself);
197
+ // the registry's `owner` → `logAuthority`, administering every policy's lists and numbers; a public pool
198
+ // is born to the LOG Authority. No pool id moved.
199
+ // 28 (decision 067): no buy-and-burn — `Terms` is four words, `Regenerated` loses `burnt`; on a pad the manager caps the
200
+ // payee at `PAYEE_CUT_MAX` and carries only the dead shares, and refuses `retire`; `PadPolicy.pack(creatorShare, nonce)`,
201
+ // `setSchedule` without a burn range, `splitOf` → (creatorShare, protocolShare). No pool id moved.
202
+ // 29 (decision 068): the restructure guard and the registry's sunset read `block.timestamp` —
203
+ // `Pool.restructureBlock` is `restructureTime` (unix seconds, same slot), `PolicyRegistry.sunset(policy, untilTime)`.
204
+ // Names only: no pool id moved.
205
+ // 30 (decision 071): the events — `FSwap` is the shared `Swap` plus `FSwapState`, object-word names
206
+ // (`PoolCreated`, `GenerationSeeded`, `SharesMinted`, ...), `PoolCreated` carries the mint fee.
207
+ // No pool id moved.
160
208
  // A breaking bump: raised in the same change.
161
- export const EXPECTED_F_VERSION = 26n;
209
+ export const EXPECTED_F_VERSION = 30n;
162
210
  export async function assertVersion(c, expected = EXPECTED_VERSION) {
163
211
  const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
164
212
  // three independent reads: one round trip, not three in a row
package/dist/fees.js CHANGED
@@ -109,12 +109,13 @@ export async function swapFees(c, m, opts = {}) {
109
109
  // the indexer's swap_flow view carries the same figure per swap (`feeQuote`, C)
110
110
  let fees = 0n;
111
111
  let swaps = 0;
112
- const viewed = fromBlock > toBlock || !opts.indexer ? null : await windowFromView(c, opts.indexer, m.poolId, fromBlock, toBlock);
112
+ const indexer = opts.indexer ?? c.indexerUrl;
113
+ const viewed = fromBlock > toBlock || !indexer ? null : await windowFromView(c, indexer, m.poolId, fromBlock, toBlock);
113
114
  if (viewed) {
114
115
  ({ fees, swaps } = viewed);
115
116
  }
116
117
  else if (fromBlock <= toBlock) {
117
- const { logs } = await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.cPoolManager, event: ev, args: { poolId: m.poolId }, fromBlock, toBlock });
118
+ const { logs } = await getEventLogs(c, { indexer, address: c.addresses.cPoolManager, event: ev, args: { poolId: m.poolId }, fromBlock, toBlock });
118
119
  for (const l of logs)
119
120
  fees += l.args.fee;
120
121
  swaps = logs.length;
package/dist/fpool.d.ts CHANGED
@@ -320,7 +320,7 @@ export declare const fPolicyBaseAbi: readonly [{
320
320
  readonly internalType: "bytes32";
321
321
  readonly type: "bytes32";
322
322
  }, {
323
- readonly name: "cap";
323
+ readonly name: "lnCapOverFloor";
324
324
  readonly internalType: "uint24";
325
325
  readonly type: "uint24";
326
326
  }];
@@ -431,10 +431,6 @@ export declare const fPolicyBaseAbi: readonly [{
431
431
  readonly name: "protocolCut";
432
432
  readonly internalType: "uint256";
433
433
  readonly type: "uint256";
434
- }, {
435
- readonly name: "burn";
436
- readonly internalType: "uint256";
437
- readonly type: "uint256";
438
434
  }, {
439
435
  readonly name: "carried";
440
436
  readonly internalType: "address";
@@ -831,7 +827,7 @@ export declare const fPolicyBaseAbi: readonly [{
831
827
  }, {
832
828
  readonly type: "error";
833
829
  readonly inputs: readonly [];
834
- readonly name: "NotCollector";
830
+ readonly name: "NotLogAuthority";
835
831
  }, {
836
832
  readonly type: "error";
837
833
  readonly inputs: readonly [];
@@ -861,7 +857,7 @@ export declare const fPolicyBaseAbi: readonly [{
861
857
  readonly inputs: readonly [];
862
858
  readonly name: "Refused";
863
859
  }];
864
- import type { LogswapClient } from "./client.js";
860
+ import { type LogswapClient } from "./client.js";
865
861
  /** The optional questions a policy declared at birth, as bits of `Pool.asks`. */
866
862
  export declare const ASK_SWAP = 1;
867
863
  export declare const ASK_MINT = 2;
@@ -892,10 +888,11 @@ export interface FPoolState {
892
888
  /** This generation's income still in the pool, quote: L·(θ₀ − θ). */
893
889
  unharvested: bigint;
894
890
  /**
895
- * The common cap (decisions 061): d = ln(cap price / floor price) in 1e-6 log units, from the key;
896
- * 0 is uncapped. Leverage at the floor is 1/(1 − e^{−d}): {@link fPoolLeverageOfCap}.
891
+ * The common cap as a log distance (decisions 061): ln(cap price / floor price) in 1e-6 log units,
892
+ * the key's `lnCapOverFloor`; 0 is uncapped (cap ∞). Leverage at the floor is 1/(1 − e^{−value}):
893
+ * {@link fPoolLeverageOfCap}.
897
894
  */
898
- cap: number;
895
+ lnCapOverFloor: number;
899
896
  /** Σ = ∫ Σ_j w_j (dx_j)², accrued even though the fee is fixed — the kernel stays calculable. */
900
897
  bigSigma: bigint;
901
898
  /**
@@ -908,8 +905,8 @@ export interface FPoolState {
908
905
  asks: number;
909
906
  /** The sponsor's own label for this pool — the policy's word, mutable and never identity. "" when unnamed. */
910
907
  name: string;
911
- /** The block of the last harvest / composition action: no swap runs in it. */
912
- restructureBlock: number;
908
+ /** The time (unix seconds) of the last harvest / composition action: no swap runs at that timestamp (F version 29; a block number before). */
909
+ restructureTime: number;
913
910
  /** What the pool is — its POLICY's self-description; see {@link FPoolKind}. */
914
911
  kind: FPoolKind;
915
912
  /** False before the first seed — and between a retire and the next one. */
@@ -936,7 +933,7 @@ export declare function getFPool(c: LogswapClient, poolId: Hex): Promise<FPoolSt
936
933
  /**
937
934
  * The kind of pool — the POLICY's self-description (the manager knows no kind; the
938
935
  * policy the key names is the kind, and what it promises is its code). `public`: the protocol's
939
- * own pool — its policy requires the collector as creator; no gate, no operator. `private`, the
936
+ * own pool — its policy requires the LOG Authority as creator; no gate, no operator. `private`, the
940
937
  * desk: the one whose policy may gate swaps and mints, with an operator that reshapes the legs
941
938
  * between generations. `pol`, a treasury's pool, one base: composition and access fixed at
942
939
  * birth. `pad`, a launch, one base: its policy answers income only at every harvest and declared
@@ -1333,10 +1330,15 @@ export interface FPoolCreateArgs {
1333
1330
  */
1334
1331
  mintFee?: bigint;
1335
1332
  /**
1336
- * The common cap (decisions 061): d = ln(cap price / floor price) in 1e-6 log units, a key field;
1337
- * 0 or absent is uncapped. From a leverage λ: {@link fPoolCapOfLeverage}.
1333
+ * The common cap as a log distance (decisions 061): ln(cap price / floor price) in 1e-6 log units,
1334
+ * the key's `lnCapOverFloor`; 0 or absent is uncapped (cap ∞). Pass `lnCapOverFloor` or `leverage`, not both.
1338
1335
  */
1339
- cap?: number;
1336
+ lnCapOverFloor?: number;
1337
+ /**
1338
+ * The leverage at the floor λ (decisions 061), converted to `lnCapOverFloor` by {@link fPoolCapOfLeverage}:
1339
+ * 1 is uncapped (cap ∞, `lnCapOverFloor` 0), 2 puts the cap at twice the floor price.
1340
+ */
1341
+ leverage?: number;
1340
1342
  /**
1341
1343
  * Which of the protocol's four the pool is — see {@link FPoolKind}. NOT a key field (decisions
1342
1344
  * 049: the manager knows no kind): it selects the deployment's policy of that kind when `policy`
@@ -1385,8 +1387,8 @@ export interface FPoolKey {
1385
1387
  policy: Address;
1386
1388
  creator: Address;
1387
1389
  salt: Hex;
1388
- /** The common cap, d in 1e-6 log units; 0 uncapped (decisions 061). Appended in F version 25: every pool id moved. */
1389
- cap: number;
1390
+ /** The common cap as ln(cap price / floor price), in 1e-6 log units; 0 uncapped, cap ∞ (decisions 061). Appended in F version 25 as `cap`; renamed in F version 27 (no id moved). */
1391
+ lnCapOverFloor: number;
1390
1392
  }
1391
1393
  /**
1392
1394
  * An F pool's id: `keccak256(abi.encode(key))`, offline — what `initialize` computes inline. The
@@ -1405,14 +1407,14 @@ export declare function fPoolInitialize(c: LogswapClient, a: FPoolCreateArgs): P
1405
1407
  */
1406
1408
  export declare function fPoolIdOf(c: LogswapClient, a: Omit<FPoolCreateArgs, "account">): Promise<Hex>;
1407
1409
  /**
1408
- * Rebuild a live pool's KEY from its id: the `FInitialize` log carries every field but the salt,
1410
+ * Rebuild a live pool's KEY from its id: the `PoolCreated` log carries every field but the salt,
1409
1411
  * which is taken from `opts.salt` (zero by default — every pool the SDK's create flow makes
1410
1412
  * without naming one; a pad's carries its split, so it is rebuilt from the policy's record with nonce 0 — pass `opts.salt` for another nonce). The result is checked against the id, so a wrong salt throws rather than
1411
1413
  * returning a key that names another pool. What {@link fPoolMigrate} needs when handed an id.
1412
1414
  */
1413
1415
  export declare function fPoolKeyOfPool(c: LogswapClient, poolId: Hex, opts?: {
1414
1416
  salt?: Hex;
1415
- fromBlock?: bigint; /** The rindexer GraphQL endpoint: `FInitialize` from there, the node otherwise. The salt is in neither (the event does not carry it). */
1417
+ fromBlock?: bigint; /** The rindexer GraphQL endpoint: `PoolCreated` from there, the node otherwise. The salt is in neither (the event does not carry it). */
1416
1418
  indexer?: string;
1417
1419
  }): Promise<FPoolKey>;
1418
1420
  /**
@@ -1428,11 +1430,36 @@ export declare function fPoolReserveAt(Lj: bigint, x: bigint, k?: number): bigin
1428
1430
  * 0 on an uncapped pool. Throws when the seed would be priced at or above its cap (Q0/L0 ≥ d), which
1429
1431
  * the manager refuses.
1430
1432
  */
1431
- export declare function fPoolCapK(cap: number, Q0: bigint, L0: bigint): number;
1432
- /** The cap d (1e-6 log units) for a leverage λ > 1 at the floor: d = ln(λ/(λ − 1)) (decisions 061). λ = 2 puts the cap at twice the floor. */
1433
+ export declare function fPoolCapK(lnCapOverFloor: number, Q0: bigint, L0: bigint): number;
1434
+ /**
1435
+ * The key's `lnCapOverFloor` = ln(cap/floor) (1e-6 log units) for a leverage λ at the floor: ln(λ/(λ − 1))
1436
+ * (decisions 061), so λ = 1/(1 − floor/cap) and the cap sits λ/(λ − 1) × the floor — λ = 2 puts it at twice.
1437
+ * **λ = 1 is uncapped**: cap ∞, `lnCapOverFloor` 0. A λ under 1, or one so close to
1438
+ * 1 (or so large) that d leaves a uint24 of 1e-6 units, is refused.
1439
+ */
1433
1440
  export declare function fPoolCapOfLeverage(lambda: number): number;
1434
- /** The leverage at the floor λ = 1/(1 − e^{−d}) for a cap d in 1e-6 log units; Infinity is impossible, 1 is uncapped. */
1435
- export declare function fPoolLeverageOfCap(cap: number): number;
1441
+ /** The leverage at the floor λ = 1/(1 − e^{−x}) for x = `lnCapOverFloor` (1e-6 log units); 1 for an uncapped pool (cap ∞). */
1442
+ export declare function fPoolLeverageOfCap(lnCapOverFloor: number): number;
1443
+ /** A pool's leverage, ready to tag: `capped` false and `capOverFloor` Infinity for an uncapped pool. */
1444
+ export interface FPoolLeverage {
1445
+ /** λ at the floor; exactly 1 when uncapped. */
1446
+ lambda: number;
1447
+ capped: boolean;
1448
+ /** The cap's price over the floor's, e^d = λ/(λ − 1): 2 at λ = 2; Infinity when uncapped. */
1449
+ capOverFloor: number;
1450
+ /** "1×" uncapped; otherwise λ to two decimals, trailing zeros dropped ("2×", "1.5×"), never "1×" for a capped pool ("1.01×" at least shown as "≈1×"). */
1451
+ label: string;
1452
+ }
1453
+ /**
1454
+ * The leverage tag of a pool from its key's `lnCapOverFloor` (decisions 061): `1×` means no cap — the only way a tag
1455
+ * reads 1× — and a capped pool always reads above it, so the two can never be confused on screen.
1456
+ */
1457
+ export declare function fPoolLeverage(lnCapOverFloor: number): FPoolLeverage;
1458
+ /** The key's `lnCapOverFloor` from creation args: as given, else from `leverage`, else 0 (uncapped, cap ∞). Both given and disagreeing is refused. */
1459
+ export declare function fPoolCapOfArgs(a: {
1460
+ lnCapOverFloor?: number;
1461
+ leverage?: number;
1462
+ }): number;
1436
1463
  /**
1437
1464
  * Arm the pool: deposit `r0[j]` of each base plus `Q0` of quote against exposure `L0`. Pass either
1438
1465
  * the reserves outright (`r0`) or the marks the pool should open at (`x0`, converted here with
@@ -1476,7 +1503,7 @@ export declare function fPoolRetire(c: LogswapClient, a: {
1476
1503
  /**
1477
1504
  * The harvests that empty an unlocked pool's bid, in order — what a relaunch sends before its
1478
1505
  * `retire` (a retire needs an empty bid on every pool). Since F version 14 one
1479
- * `harvest(Q)` does it: the protocol's cut leaves the pool with the amount (with no collector
1506
+ * `harvest(Q)` does it: the protocol's cut leaves the pool with the amount (with no treasury
1480
1507
  * there is no cut). `[]` when the bid is already empty. Throws on a pad (F version 21: a pad
1481
1508
  * never retires, whatever its bid), and when the pool's policy keeps a floor on the bid
1482
1509
  * (`PolPolicy.keepQuote`): a `retire` under that policy waits for the market.
@@ -1494,11 +1521,11 @@ export declare function fPoolEmptyingHarvests(c: LogswapClient, poolId: Hex): Pr
1494
1521
  * and redeems it with {@link fPoolRedeem} / rolls it with {@link fPoolRollIn} (`gen: g`); their
1495
1522
  * dividends on `g` stay claimable ({@link fPoolClaim} with `gen: g`). {@link fPoolClaimsOf}
1496
1523
  * lists them;
1497
- * - the pot, all in quote (decisions 057): `toPayee` to the payee, `protocolCut` to the collector,
1524
+ * - the pot, all in quote (decisions 057): `toPayee` to the payee, `protocolCut` to the treasury,
1498
1525
  * `burn` spent buying base at the curve and burning it (the price up, the floor held), and the
1499
1526
  * rest into the bid (the floor down). No share is minted; L does not move.
1500
1527
  *
1501
- * A pad's gate is `threshold(gen)` (`PadPolicy.NotGraduated` below it); POL and private carry the
1528
+ * A pad's gate is `threshold(poolId, gen)`, in its quote (`PadPolicy.NotGraduated` below it); POL and private carry the
1502
1529
  * authority and send it the whole pot; a public pool refuses (`Refused`). A carried holder with no
1503
1530
  * share is `BadTerms`. Whoever runs the pool.
1504
1531
  */
@@ -1805,8 +1832,8 @@ export interface DiscoveredFPool {
1805
1832
  bases: Address[];
1806
1833
  weights: bigint[];
1807
1834
  swapFee: bigint;
1808
- /** The common cap, d in 1e-6 log units; 0 uncapped (decisions 061). */
1809
- cap: number;
1835
+ /** The common cap as ln(cap price / floor price), in 1e-6 log units; 0 uncapped, cap ∞ (decisions 061). */
1836
+ lnCapOverFloor: number;
1810
1837
  kind: FPoolKind;
1811
1838
  /** The pool's policy AT BIRTH — the contract the key names. The LIVE one is {@link getFPool}'s `policy`: the registry's owner may have moved the pool (046, `PolicyMigrated`). */
1812
1839
  policy: Address;
@@ -1827,9 +1854,9 @@ export interface DiscoveredFPool {
1827
1854
  shape: FPoolShape;
1828
1855
  }
1829
1856
  /**
1830
- * Every F pool ever created, from `Initialize` logs alone — plus one `kind()` read per distinct
1857
+ * Every F pool ever created, from `PoolCreated` logs alone — plus one `kind()` read per distinct
1831
1858
  * policy, cached. Possible only because the event carries the full key preimage (bases,
1832
- * weights, swapFee, policy, cap) — the poolId is a hash and could never be inverted; contracts PR #17
1859
+ * weights, swapFee, policy, lnCapOverFloor) — the poolId is a hash and could never be inverted; contracts PR #17
1833
1860
  * exists for exactly this call. With `indexer`, the logs come from it (the node when it fails):
1834
1861
  * a scan from block 0 per call is what made the first load wait on the node.
1835
1862
  */
@@ -1853,14 +1880,13 @@ export type FPoolRules = {
1853
1880
  gen: number;
1854
1881
  /** @deprecated Equal to {@link gen} since F version 21, kept for callers; read `gen`. */
1855
1882
  rung: number;
1856
- /** The pot the next graduation needs: `PadPolicy.threshold(gen)`. */
1883
+ /** The pot the next graduation needs, in the pad's quote: `PadPolicy.threshold(poolId, gen)` (T(0) is per quote, decision 070). */
1857
1884
  threshold: bigint;
1858
1885
  pot: bigint;
1859
- /** This pad's split, recorded at its birth from the key's salt and never changed (decisions 056, 057): the creator's cut of the pot, the protocol's, and the burn — all fractions of the pot. The rest deepens the bid. */
1886
+ /** This pad's split, recorded at its birth from the key's salt and never changed (decisions 056, 057, 067): the creator's cut of the pot and the protocol's, fractions of the pot. The rest deepens the bid; nothing is bought or burnt (067). */
1860
1887
  creatorShare: bigint;
1861
1888
  protocolShare: bigint;
1862
- burnShare: bigint;
1863
- /** The ranges the collector's policy holds NOW for the pads born after this read: what a new creator may choose. */
1889
+ /** The ranges the LOG Authority set on the policy NOW for the pads born after this read: what a new creator may choose. */
1864
1890
  ranges: PadRanges;
1865
1891
  } | {
1866
1892
  kind: "pol";
@@ -1875,26 +1901,26 @@ export type FPoolRules = {
1875
1901
  gateSwap: boolean;
1876
1902
  operator: Address;
1877
1903
  };
1878
- /** The collector's ranges on a pad's creator choices (`PadPolicy`, decisions 056, 057), WAD fractions of the pot. */
1904
+ /** The LOG Authority's range on a pad's creator choice (`PadPolicy`, decisions 056, 067), WAD fractions of the pot. */
1879
1905
  export interface PadRanges {
1880
1906
  /** The protocol's share of the pot, recorded into each pad at birth. */
1881
1907
  protocolShare: bigint;
1882
1908
  creatorShareMin: bigint;
1909
+ /** At most the F manager's `PAYEE_CUT_MAX` (50%), which bounds a pad's payee whatever the policy (067). */
1883
1910
  creatorShareMax: bigint;
1884
- burnMin: bigint;
1885
- burnMax: bigint;
1886
1911
  }
1887
1912
  /**
1888
- * The salt that carries a pad's split (`PadPolicy.pack`, decisions 056, 057): `creatorShare` in the top 64 bits, `burnShare` in
1889
- * the next 64 (WAD fractions of the pot), a nonce in the low 128 that tells two otherwise identical pads apart. It is part of the pool's
1890
- * identity, so it is chosen at launch (`FPoolLaunchArgs.salt`) and never changes; the policy refuses a split outside its ranges.
1913
+ * The salt that carries a pad's split (`PadPolicy.pack(creatorShare, nonce)`, decisions 056, 067): `creatorShare` in the top 64
1914
+ * bits (a WAD fraction of the pot), zero in the next 64 — the burn share's place before F version 28, refused by the policy if
1915
+ * set — and a nonce in the low 128 that tells two otherwise identical pads apart. It is part of the pool's identity, so it is
1916
+ * chosen at launch (`FPoolLaunchArgs.salt`) and never changes; the policy refuses a cut outside its range.
1891
1917
  */
1892
1918
  export declare function padSalt(s: {
1893
1919
  creatorShare: bigint;
1894
- burnShare: bigint;
1895
- nonce?: bigint;
1920
+ nonce?: bigint; /** @deprecated F version 28 has no burn (067): only 0 is accepted. */
1921
+ burnShare?: bigint;
1896
1922
  }): Hex;
1897
- /** The inverse of {@link padSalt}. */
1923
+ /** The inverse of {@link padSalt}. `burnShare` is the old field's bits, nonzero only on a salt the F version 28 policy refuses. */
1898
1924
  export declare function padSplitOfSalt(salt: Hex): {
1899
1925
  creatorShare: bigint;
1900
1926
  burnShare: bigint;
@@ -1927,17 +1953,17 @@ export declare function fPoolShareHolders(c: LogswapClient, poolIdHex: Hex, opts
1927
1953
  shares: bigint;
1928
1954
  }>>;
1929
1955
  /**
1930
- * What a policy answers `onRegenerate` with: `IFPolicy.Terms`. `carried` is F version 21's fifth word — the holder the next generation
1931
- * carries beside the dead shares; the reply is exactly 160 bytes.
1956
+ * What a policy answers `onRegenerate` with: `IFPolicy.Terms` — four words, exactly 128 bytes since F version 28 (decision 067
1957
+ * removed `burn`). `carried` is the holder the next generation carries beside the dead shares; on a pad the manager requires
1958
+ * `0xdead` and caps `toPayee` at `PAYEE_CUT_MAX` of the pot.
1932
1959
  */
1933
1960
  export interface FPolicyTerms {
1934
1961
  payee: Address;
1935
1962
  toPayee: bigint;
1936
1963
  protocolCut: bigint;
1937
- burn: bigint;
1938
1964
  carried: Address;
1939
1965
  }
1940
- /** Every F pool's raw state in one lens call (the manager's `Pool` struct: quote, swapFee, policy, seeded, gen, n, restructureBlock, asks, cap, Q, bigSigma, L, shares, refLogFloor). */
1966
+ /** Every F pool's raw state in one lens call (the manager's `Pool` struct: quote, swapFee, policy, seeded, gen, n, restructureTime, asks, lnCapOverFloor, Q, bigSigma, L, shares, refLogFloor). */
1941
1967
  export declare function getFPoolsRaw(c: LogswapClient, poolIds: Hex[]): Promise<readonly unknown[]>;
1942
1968
  /** Share value from the lens — (L + Q)/shares, WAD per share — the same figure as `fPoolShareValue`, from one source. */
1943
1969
  export declare function shareValueOnChain(c: LogswapClient, poolId: Hex): Promise<bigint>;