@logswap/sdk 0.5.91 → 0.5.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,6 +45,48 @@ Both are computed **offline** — no RPC, no deployment needed to address a mark
45
45
  floor price (was `theta`), `refLogFloor` θ₀ — the reference floor income counts from (was
46
46
  `theta0`), `cap` (d in 1e-6 log units, 0 uncapped), and per leg `virtualReserves` and `kappa`.
47
47
 
48
+ ## F 41 (`policy.md`): one policy contract, the operator runs the pool, the fee is an index
49
+
50
+ Follows contracts `f3d1420` (logswap-contract #120, squash-merged to main on 2026-11-07). A breaking release: every F pool id moved, and the F policy surface is replaced.
51
+ The C side is untouched until Policy C follows.
52
+
53
+ - **One policy.** `PolicyF` replaces `SponsorPolicyF`, `PolPolicy`, `PadPolicy` and `OrphanPolicyF`; `policyFAbi` replaces their four ABIs.
54
+ Its kinds are parameter sets, every one an immutable: `fPolicyTermsOf(c, policy)` reads them once per policy (`FPolicyTerms`: `open`,
55
+ `seedToDead`, `incomeHarvestOnly`, `incomeTaxRate`, `feeMask`, `lenMax`, `lnCapMin`, `quoteBuffer`, `quoteCurated`, `baseCurated`,
56
+ `fixedAuthority`). `FPoolKind` is a LABEL off those terms — `"public" | "desk" | "pol" | "pad"` (`fPolicyKindOf`; the contract's `kind()` says
57
+ `"f"` for every instance); `fPoolKindOfPolicy` keeps its name. `FPolicySlot` and the artifact keys (`publicPolicy`, `privatePolicy`,
58
+ `polPolicy`, `padPolicy`) are unchanged; `orphanPolicy` is gone.
59
+ - **Authority and operator** (`policy.md` §2). The authority is the policy's, immutable (the LOG Authority of the day on the LOG's instances),
60
+ and appoints each pool's operator (`fPoolAppointOperator`; zero resets it to the authority). The operator runs the pool: `fPoolDeploy`,
61
+ `fPoolHarvest`, `fPoolClose`, the modes and the name. `FPoolRoles` is `{ policy, authority, operator, swapMode, mintMode }` (`gateMint` and
62
+ `maxHarvest` are gone); `fPoolRunners` is the operator alone.
63
+ - **Gates.** Two modes per pool, `FPoolMode = "open" | "listed" | "operator"` (the on-chain order, `fPoolModes`; `mintMode ≥ swapMode`):
64
+ `fPoolSetSwapMode` and `fPoolSetMintMode` (was `fPoolSetMintGate`), the operator's. The lists are per POLICY, not per pool:
65
+ `fPolicySetRights(c, { policy, who, right: "none" | "swap" | "mint" })` and `fPolicyRightsOf` (was `fPoolSetListed` / `fPoolIsListed`);
66
+ `mint` implies `swap`. `fPoolDeskOpening` is gone (`fPoolSetMintMode(…, "operator")`). Every gate write reverts `GatesUnavailable` on an open policy.
67
+ - **The key** (`policy.md` §5) is `FPoolKey = { quote, bases, swapFeeIdx, policy, salt }` (`F_POOL_KEY_ABI` is exported): no `creator`, no
68
+ `mintFee`. `FPoolCreateArgs` takes `swapFeeIdx` or a WAD `swapFee` on the list (`fFeeIndexOf` throws otherwise); `creator` and `mintFee` are gone.
69
+ `fPoolKeyOfPool` rebuilds the whole key from `PoolCreated(poolId, quote, policy, bases, swapFeeIdx, salt)` — the salt is in the event, so the
70
+ `salt` option and `padSalt` / `padSplitOfSalt` are gone.
71
+ - **The fee list** (`policy.md` §6): `F_FEE_LIST_BP = [1, 2, 5, 10, 20, 50, 100, 200]`, `F_FEE_LIST` in WAD, `fFeeOf`, `fFeeIndexOf`,
72
+ `fMintFeeIdxOf` / `fMintFeeOf` (the next entry, the same at the top), `fFeeListed` / `fFeesAllowed` over a policy's `feeMask`.
73
+ `policyFeeAllowed(c, policy, swapFeeIdx)` reads the mask; `policyBaseAllowed` is new beside `policyQuoteAllowed`. `FPoolState.swapFee` /
74
+ `mintFee` and `DiscoveredFPool.swapFee` / `mintFee` stay the resolved WAD values; `DiscoveredFPool` gains `swapFeeIdx` and `salt`, loses `creator`.
75
+ - **The lifecycle** (`policy.md` §9): `fPoolDeploy` has no `to` (the operator pays and holds the shares) and runs on an inactive pool only;
76
+ `fPoolHarvest(c, { poolId, extra?, to? })` takes the income and `extra` of capital (`amount` is gone); `fPoolClose` closes at any bid, harvesting
77
+ first, and refuses a pad; `fPoolCloseRaw`, `fPoolEmptyingHarvests` and `fPoolRegenerate` are gone — `fPoolRelaunch` / `fPoolRelaunchCalls` is
78
+ `multicall(close, redeem, deployLiquidity)`. `fPoolHarvestRoom(state, terms)` is what a harvest may take; `FPoolDescription` has `income`,
79
+ `capitalRoom` and `harvestable` (the dead shares' dividend is gone). `fPoolLaunch` is the policy authority's (it is the operator at birth).
80
+ - **Names** are events: `fPoolSetName` emits `NameSet`, `fPoolNameOf(c, poolId, { policy?, indexer? })` reads the last one; `FPoolState.name` is gone.
81
+ - **Registry.** `fPoolMigrate`, `fPoolOrphan`, `registryOrphanPolicyOf`, `registrySetOrphanPolicy` and `MigrationPermissions` are gone; the key's
82
+ policy is the pool's for life. `registryKindOf` returns the name recorded at approval (a string). `registryPolicies(c, kind?)` filters on the label.
83
+ The pad readers (`padThresholdBases`, `padThresholdOf`, `padThreshold`, `padScheduleOf`) and `getFPoolRules` / `FPoolRules` / `PadRanges` are gone:
84
+ the terms are `fPolicyTermsOf`; `FPoolControlled` carries `terms`, and `fPoolsControlledBy(c, who)` lists the pools `who` operates or sponsors.
85
+ - **Events.** `IncomeHarvested(poolId, to, gen, income, capital, tax, toOperator, Q)`; `GenerationFrozen` from `close` alone; `PolicyMigrated` and
86
+ `IncomeReleased` are gone. The policy emits `OperatorAppointed`, `SwapModeSet`, `MintModeSet`, `RightsSet(who, bits)`, `NameSet`. The indexer's
87
+ `allFPoolManagerPoolCreateds` rows carry `swapFeeIdx` and `salt` (logswap-be follows).
88
+ - **Versions.** `EXPECTED_F_VERSION` is 41; `EXPECTED_VERSION` stays 16.
89
+
48
90
  ## C 16 / F 40 (decision 098): immutable, LOG-deployed policies; one sponsored policy per manager
49
91
 
50
92
  Follows contracts `99827f8`. This is a breaking release: the policy surface is replaced.
@@ -173,8 +215,7 @@ from the registry's `Approved`), the registry, the token factory and the manager
173
215
  nothing has to scan the node from block 0 — which the devnet node, pruning logs after about a day,
174
216
  answers only partly.
175
217
 
176
- - `swapFees`, `holdingsOf`, `discoverMarkets` and `fPoolKeyOfPool` take `indexer` (the salt is not in
177
- `PoolCreated`, so a pad's key is still rebuilt from its split with nonce 0).
218
+ - `swapFees`, `holdingsOf`, `discoverMarkets` and `fPoolKeyOfPool` take `indexer` (since F 41 `PoolCreated` carries the whole key, the salt included).
178
219
  - `getEventLogs` takes several emitters (`address: [...]`); a policy outside the artifact names its
179
220
  shared tables with `contract: indexedContractOf(kind, event)` (or `kind` on `getEventsLogs`).
180
221
  - `tokensCreated` lists the factory's tokens (`addresses.tokenFactory`): the token list's provenance.
@@ -211,21 +252,23 @@ as the fallback, with the same answer on the same data:
211
252
  What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `cLegsOf`,
212
253
  `cHeldByIds`, `dividendOf`). They accrue without events, so no view holds them.
213
254
 
214
- ## The F pool's life: four calls (F 38)
215
-
216
- - **`fPoolInitialize`** creates an unfunded pool. Its key is `(quote, bases, swapFee, policy, creator, salt,
217
- mintFee)`: no weights and no cap, and the set of `bases` is fixed for the pool's life.
218
- - **`fPoolDeploy`** (`deployLiquidity`, decisions 083, 084) is the authority's and SETS THE BOOK. Each
219
- `baseAssets[j]` is the TOTAL base reserve of asset `j` after the call (`0` leaves it out) and the price
220
- that values it (`priceX36`), `quoteAmount` is the total bid, and the manager settles the difference with the caller:
221
- a larger total is pulled, a smaller one is pushed to `to`, so one call replaces an asset by another. Pass the
222
- book outright (`baseAssets`, `lnCapOverSeed`) or the sponsor's terms (`bases`, `weights`, `L0` and the wanted
223
- marks `x0` or the reserves `r0`; `fPoolBook` builds the book). On an UNFUNDED pool (new, or after `fPoolClose`)
224
- it funds the first or next generation. On a LIVE pool it is a regeneration that sets the book: income settles to
225
- `to`, every holder but the carried ones is frozen into the closing generation's bundle (`fPoolRedeem`), and the
226
- carried book becomes the one named. A pad is forward-only (`PadForwardOnly`): it uses `fPoolRegenerate`.
227
- - **`fPoolRegenerate`** is the same routine with nothing changed: the generation step, the pad's graduation.
228
- - **`fPoolClose`** harvests the bid out and closes the pool at an empty bid; the pool keeps its id and every role.
255
+ ## The F pool's life: four calls (F 41, `policy.md` §9–10)
256
+
257
+ - **`fPoolInitialize`** lists the pool, inactive. Its key is `(quote, bases, swapFeeIdx, policy, salt)`: no weights, no cap, no
258
+ creator and no mint fee; the set of `bases` is fixed for the pool's life. Anyone under an open policy (at salt zero), the policy's
259
+ authority under a closed one. The policy's authority is the pool's OPERATOR at birth; the authority may re-appoint it.
260
+ - **`fPoolDeploy`** (`deployLiquidity`) is the operator's and SETS THE BOOK of a generation, on an INACTIVE pool — listed and never
261
+ funded, or closed. Each `baseAssets[j]` is the base reserve of asset `j` (`0` leaves the leg dormant) and the price that values it
262
+ (`priceX36`), `quoteAmount` the bid; the operator pays them all by plain allowance and holds the shares (all to 0xdead on a pad). Pass the
263
+ book outright (`baseAssets`, `lnCapOverSeed`) or the terms (`bases`, `weights`, `L0` and the wanted marks `x0` or the reserves `r0`;
264
+ `fPoolBook` builds the book). The policy bounds it: `quoteAmount ≥ quoteBuffer · L`, a cap at least `lnCapMin` above the seed, at most
265
+ `lenMax` legs; a sunset policy refuses it.
266
+ - **`fPoolHarvest`** takes the generation's income and `extra` of capital out of the bid — a dividend to every share, the operator's slice paid
267
+ to `to` in the same call, the income taxed on the payer's slice. `fPoolHarvestRoom` says how much.
268
+ - **`fPoolClose`** closes at any bid: the income is harvested first, the reserves and the bid are frozen into the generation's bundle
269
+ (`fPoolRedeem`), the counter moves to `gen + 1`; the pool keeps its id, its policy and its roles. A pad never closes.
270
+ - **`fPoolRelaunch`** is what `regenerate` was: `close`, the operator's own `redeem`, the next `deployLiquidity`, in one `multicall` — every
271
+ other holder is frozen into the bundle; the new book may re-weight the key's bases and pick its own cap.
229
272
  - **The cap** (decisions 061, 075) is the pool's one log ratio `lnCapOverSeed` = ln(cap price / seed price) in 1e-6 log
230
273
  units, chosen at each deployment: each asset's maximum price is its own seed price times it.
231
274
  `fPoolCapOfLeverage(λ)` gives it for a leverage (λ = 2 → the cap at twice the seed price),
@@ -285,7 +328,7 @@ What changes for readers:
285
328
  - **The indexer is per chain**: `indexerUrl` on the client is the default `indexer` of every history
286
329
  read and of `discoverMarketsBest`. Its rows are filtered by contract address, which is the same on
287
330
  every chain, so one URL must serve one chain.
288
- - **Caches key on the chain id**: the policy-kind cache asks the node for the chain id when the
331
+ - **Caches key on the chain id**: the policy-terms cache asks the node for the chain id when the
289
332
  client has none; `RESETTABLE_CHAINS` is every registry chain flagged `devnet` (plus 1337 and 31338),
290
333
  extended with `addResettableChain`.
291
334
  - **F version 29** (decision 068): `FPoolState.restructureTime` (unix seconds; was