@logswap/sdk 0.5.90 → 0.5.92
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 +136 -31
- package/dist/actions.js +4 -3
- package/dist/admin.d.ts +96 -925
- package/dist/admin.js +113 -194
- package/dist/chains.d.ts +13 -4
- package/dist/chains.js +22 -9
- package/dist/claims.d.ts +1 -1
- package/dist/claims.js +11 -9
- package/dist/client.d.ts +42 -20
- package/dist/client.js +86 -26
- package/dist/fees.d.ts +1 -1
- package/dist/fees.js +5 -4
- package/dist/fpool.d.ts +327 -1120
- package/dist/fpool.js +408 -475
- package/dist/generated.d.ts +5017 -7631
- package/dist/generated.js +3040 -4879
- package/dist/history.js +12 -14
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -7
- package/dist/indexer.d.ts +2 -2
- package/dist/indexer.js +12 -9
- package/dist/keys.d.ts +15 -3
- package/dist/keys.js +5 -1
- package/dist/liquidity.d.ts +1 -1
- package/dist/liquidity.js +16 -9
- package/dist/onboard.d.ts +16 -11
- package/dist/onboard.js +27 -21
- package/dist/pools.d.ts +2 -0
- package/dist/pools.js +21 -13
- package/dist/positions.d.ts +1 -1
- package/dist/positions.js +18 -17
- package/dist/quote.d.ts +15 -0
- package/dist/quote.js +36 -0
- package/dist/swap.d.ts +7 -9
- package/dist/swap.js +40 -25
- package/dist/views.d.ts +1 -1
- package/dist/write.d.ts +7 -2
- package/dist/write.js +10 -7
- package/package.json +3 -3
- package/src/actions.ts +4 -3
- package/src/admin.ts +143 -249
- package/src/chains.ts +32 -13
- package/src/claims.ts +11 -10
- package/src/client.ts +111 -39
- package/src/fees.ts +6 -6
- package/src/fpool.ts +555 -648
- package/src/generated.ts +3063 -4904
- package/src/history.ts +11 -11
- package/src/index.ts +5 -7
- package/src/indexer.ts +13 -11
- package/src/keys.ts +19 -3
- package/src/liquidity.ts +16 -10
- package/src/onboard.ts +29 -21
- package/src/pools.ts +23 -15
- package/src/positions.ts +18 -18
- package/src/quote.ts +36 -0
- package/src/swap.ts +46 -25
- package/src/views.ts +1 -2
- package/src/write.ts +11 -10
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# logswap-sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for [Logswap](https://logswap.org), the liquidity
|
|
4
|
-
primitive introducing the **logarithmic invariant** — typed wrappers over the `
|
|
5
|
-
`
|
|
4
|
+
primitive introducing the **logarithmic invariant** — typed wrappers over the `ManagerF` / `ManagerC`,
|
|
5
|
+
`RouterF` / `RouterC` and `LensF` / `LensC` surface (decision 096: one router and one lens per manager; the letter is
|
|
6
|
+
a suffix on the contract and never a prefix on a function or an event).
|
|
6
7
|
|
|
7
8
|
**Status: identity, reads and writes for both singletons.** Indexer next.
|
|
8
9
|
|
|
@@ -37,15 +38,118 @@ Both are computed **offline** — no RPC, no deployment needed to address a mark
|
|
|
37
38
|
- F side: `discoverFPools(c)` (shape, and the `block` the pool was initialized in), `getFPool`,
|
|
38
39
|
`fPoolShareBalance`, `fPoolShareValue`; `previewZapIn` reads the **lens** (the router's F flows
|
|
39
40
|
live in a facet, its previews moved to the lens). Since F version 25 every F state read goes
|
|
40
|
-
through the lens (`
|
|
41
|
+
through the lens (`pool`, `getPools`, `bundleOf`, `dividendOf`, `lienOf`): the manager's
|
|
41
42
|
typed views are behind `extsload` (decisions 062), and the lens decodes them with the contracts'
|
|
42
43
|
`FPoolState`, so the SDK never hard-codes the storage layout.
|
|
43
44
|
- F pool state names (F version 25): `swapFee` (was `phi`), `logFloor` θ — the log of the current
|
|
44
45
|
floor price (was `theta`), `refLogFloor` θ₀ — the reference floor income counts from (was
|
|
45
46
|
`theta0`), `cap` (d in 1e-6 log units, 0 uncapped), and per leg `virtualReserves` and `kappa`.
|
|
46
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
|
+
|
|
90
|
+
## C 16 / F 40 (decision 098): immutable, LOG-deployed policies; one sponsored policy per manager
|
|
91
|
+
|
|
92
|
+
Follows contracts `99827f8`. This is a breaking release: the policy surface is replaced.
|
|
93
|
+
|
|
94
|
+
- **Kinds.** `PublicPolicy` and `PrivatePolicy` are gone. A policy says it is `"sponsor"` (`SponsorPolicyF` / `SponsorPolicyC`: the LOG's own
|
|
95
|
+
instances, the open canonical one and a gated one, and a third party's deployed by the LOG), `"pol"`, `"pad"` or `"orphan"` (`OrphanPolicyF`).
|
|
96
|
+
`FPoolKind` is `"sponsor" | "pol" | "pad" | "orphan"`. `fPoolPolicyFor(c, slot)` and `FPoolCreateArgs.kind` take a deployment *slot*
|
|
97
|
+
(`FPolicySlot`: `"public"`, `"private"`, `"pol"`, `"pad"`, the artifact's keys: `publicPolicy` / `privatePolicy` are the LOG's open and gated
|
|
98
|
+
`SponsorPolicyF` instances). New optional addresses: `publicPolicyC` (the open `SponsorPolicyC`) and `orphanPolicy`.
|
|
99
|
+
`sponsorPolicyFAbi`, `sponsorPolicyCAbi` and `orphanPolicyFAbi` replace `publicPolicyAbi` / `privatePolicyAbi`.
|
|
100
|
+
- **A policy has no setter.** Its numbers (fee tiers as masks over the family's table, quotes, the C spacings, the swap-fee tax, `canonical`,
|
|
101
|
+
`gatesAvailable`, `bornGated`, a pad's schedule and income tax rate, a POL's reserve ratio) are constructor immutables: a change is a new policy,
|
|
102
|
+
which the LOG approves (`registryApprove`) and moves pools to (`fPoolMigrate`). The wrappers for the old setters are removed
|
|
103
|
+
(`padSetSchedule`, `padSetThresholdBase`, `padSetIncomeTaxRate`, `polSetMinQuoteRatio`, `polSetIncomeTaxRate`, `policySetQuoteListed`,
|
|
104
|
+
`policySetQuoteCurated`, `policySetFeeListed`, `policySetFeeCurated`, `gateSetPairListed`, `gateSetPairCurated`, `gateSetSpacingListed`,
|
|
105
|
+
`policySetSpacingListed`, `policySetSpacingCurated`, `setCSwapFeeTax`, `setCGate`, `registrySetInitializerListed`). Readers remain:
|
|
106
|
+
`policyQuoteAllowed`, `policyFeeAllowed(c, policy, fee, "swap" | "mint")`, `policySpacingAllowed`, `cSwapFeeTax(c, policy?)`, `padScheduleOf`,
|
|
107
|
+
`padThresholdBases`, `padThresholdOf`, `padThreshold`, and `getFPoolRules` (which now returns the sponsored policy's immutables).
|
|
108
|
+
- **Authority and operator.** The authority is `key.creator` for life: no handover (`fPoolProposeAuthority` / `fPoolAcceptAuthority` are removed;
|
|
109
|
+
`FPoolRoles` loses `creator`, `pendingAuthority` and `swapExecutor`). The authority appoints a per-pool operator (`fPoolAppointOperator`, was
|
|
110
|
+
`fPoolSetPoolOperator`), sets the swap mode (`fPoolSetSwapMode`: `"open" | "operator" | "listed"`, no executor), the mint gate
|
|
111
|
+
(`fPoolSetMintGate`) and the whitelist (`fPoolSetListed(who, listed)` and `fPoolIsListed`; the minter and taker lists are gone). The same
|
|
112
|
+
functions exist on `SponsorPolicyC`: pass `policy: key.policy` for a C market. `fPoolDeskOpening` is now the one mint-gate write.
|
|
113
|
+
- **Gates.** `Pool.asks` is `Pool.flags` (`FPoolState.flags`; `GATE_SWAP` 1, `GATE_MINT` 2, `GATES` 3, `SEED_TO_DEAD` 4; `ASK_SWAP` / `ASK_MINT` are
|
|
114
|
+
gone) and `FPoolState.operator` is the operator the manager caches (admitted by a gated swap or mint with no policy call). `setPermissions` /
|
|
115
|
+
`PermissionsSet` are `setGates(poolId, gates, operator)` / `GatesSet` on both managers; the indexer's shared table is `GatesSet`.
|
|
116
|
+
- **Registry.** `CreationMode` is `"open" | "sponsorOnly"` (`Restricted`, the initializer list and `InitializerNotListed` are gone; the initializer
|
|
117
|
+
must be `key.creator`, `NotCreator`). `fPoolMigrate(c, { key, to, permissions? })` installs the new policy's swap mode, operator, mint gate and
|
|
118
|
+
whitelist in the same transaction (`MigrationPermissions`; `migratePrivate` is gone). New: `fPoolOrphan` (`PolicyRegistry.orphan`, final),
|
|
119
|
+
`registryOrphanPolicyOf`, `registrySetOrphanPolicy`.
|
|
120
|
+
- **C gate.** `cGateRules` reads the sponsored C policy: `pairOk` is gone, `mintFeeOk` is new, `saltOk` binds only a canonical policy;
|
|
121
|
+
`gateErrorAbi` carries `FeeNotListed`, `MintFeeNotListed`, `QuoteNotListed`, `GatesUnavailable`, `NotCanonical`.
|
|
122
|
+
- **Versions.** `EXPECTED_VERSION` is 16 (C) and `EXPECTED_F_VERSION` is 40. No pool id moved.
|
|
123
|
+
|
|
124
|
+
## C 15 / F 39 (decisions 096, 097): a router and a lens per manager, and a C market has a creator and a salt
|
|
125
|
+
|
|
126
|
+
(The policy parts of this section are superseded by the one above.)
|
|
127
|
+
|
|
128
|
+
Follows contracts `f3164de` (096 + #112 + #113 + #115 + #116). What changes for a consumer:
|
|
129
|
+
|
|
130
|
+
- **Addresses.** `LogswapAddresses` is `managerF`, `routerF`, `lensF` (required) and `managerC`, `routerC`, `lensC` (optional:
|
|
131
|
+
F ships first, so a chain may have no C stack; the artifact then carries `address(0)` and `cVersion` 0). `managerC(c)`,
|
|
132
|
+
`routerC(c)`, `lensC(c)` throw where the stack is absent, and `hasC(c)` says whether it is there. The artifact's keys are the same names.
|
|
133
|
+
- **ABIs.** `managerCAbi` / `managerFAbi`, `routerCAbi` / `routerFAbi`, `lensCAbi` / `lensFAbi`, `routerActionsAbi`. Each router is its
|
|
134
|
+
own Permit2 spender: `approveToken`, `approvePermit2ForRouter`, `onboardToken`, `checkTokenReadiness`, `spenderFor` and
|
|
135
|
+
`permit2SigCalls` take the side (`"C"` or `"F"`) after the client, and `sendRouterWrite*` take `side` in their arguments.
|
|
136
|
+
- **Names.** The 095 `c`-prefixed C functions are back to the plain 096 names (`getPool`, `discoverMarkets`, `swapExactIn`, ...); the event
|
|
137
|
+
`PoolCreated`, `Swap` and `SwapState` are the same on both managers (declared once in `ManagerBase`). `TickCrossed`, `BackstopSeeded` and
|
|
138
|
+
`Stamped` are gone from the ABIs.
|
|
139
|
+
- **A C key has a creator and a salt** (decision 097): `PoolKey = { base, quote, tickSpacing, policy, creator, salt, swapFee, mintFee }`,
|
|
140
|
+
so every C pool id is new. Only the creator may `initialize` and make the first mint (the backstop seed; `NotCreator`), and `initializeMarket`
|
|
141
|
+
refuses an account that is not `key.creator` before sending. `PoolCreated` carries a trailing `salt`; the indexer rows carry `creator` and `salt`.
|
|
142
|
+
A malformed policy answer is `BadTerms` (#115). The public policy is canonical per exact key (`salt` 0, `NotCanonical`); `marketOf` and
|
|
143
|
+
`MarketExists` are gone, and `cGateRules` reads `getPool(key).initialized` for `exists` and adds `saltOk`.
|
|
144
|
+
- **Registry and policies.** `registryUserOf(c, caller)` reads `PolicyRegistry.userOf` (the account a routed caller acts for);
|
|
145
|
+
`policySpacingAllowed` reads the tick-spacing list (since 098 only on `SponsorPolicyC`, and read-only).
|
|
146
|
+
- **Versions.** `EXPECTED_VERSION` is 15 (C) and `EXPECTED_F_VERSION` is 39; `assertVersion` checks C only where the deployment has it, and
|
|
147
|
+
`assertWiring` checks each router and lens against its own manager.
|
|
148
|
+
|
|
47
149
|
## C 13 (decisions 088–090): a C market is addressed by its pool id
|
|
48
150
|
|
|
151
|
+
(The router and lens naming in this section is superseded by the one above.)
|
|
152
|
+
|
|
49
153
|
The consumer API still takes a `PoolKey`; the SDK hashes it (`poolId(key)`) and calls the contracts with the id.
|
|
50
154
|
What changes for a consumer:
|
|
51
155
|
|
|
@@ -66,7 +170,7 @@ What changes for a consumer:
|
|
|
66
170
|
you need no recipient, deadline or Permit2 (decision 091).
|
|
67
171
|
- **Layout.** F `getPool` has `swapFee` / `mintFee` as `uint56`; the `extsload` words are in the contracts' `FPoolState`.
|
|
68
172
|
|
|
69
|
-
## Who may create what: the gate, the menus (C version 7, F version 26)
|
|
173
|
+
## Who may create what: the gate, the menus (C version 7, F version 26; superseded by decision 098 above)
|
|
70
174
|
|
|
71
175
|
Since logswap-contract #60 (decisions 064–065) creation is curated at launch, on both managers:
|
|
72
176
|
|
|
@@ -89,16 +193,16 @@ Since logswap-contract #60 (decisions 064–065) creation is curated at launch,
|
|
|
89
193
|
own fee for an initialized market.
|
|
90
194
|
- **C reads**: `getPool` reads the lens's `getPools`; `getPositionClass` reads the class through
|
|
91
195
|
`extsload` at `CPoolState`'s slot (the manager's typed views are gone).
|
|
92
|
-
- **
|
|
93
|
-
LOG Authority's helpers
|
|
94
|
-
|
|
196
|
+
- **Creation** (098): the registry's creation mode per policy (`open`, or `sponsorOnly`: the policy's own immutable sponsor creates);
|
|
197
|
+
`registrySetCreationMode` and `registrySetForwarderTrusted` are the LOG Authority's helpers. The creator list, the pair list and
|
|
198
|
+
the policy setters are gone.
|
|
95
199
|
- **Two roles (decision 066, C 8 / F 27).** `logAuthority()` reads the LOG Authority (the
|
|
96
200
|
registry's `logAuthority`; `proposeLogAuthority` / `acceptLogAuthority`), which administers the
|
|
97
201
|
registry, both managers and every policy. `logTreasury(side)` reads a manager's treasury, which
|
|
98
202
|
only receives; `proposeTreasury` is the authority's, `acceptTreasury` the incoming treasury's own
|
|
99
203
|
call. `collectCProtocolFees(key)` may be sent by anyone and pays the treasury. The C swap-fee tax is each
|
|
100
|
-
market's from birth (`getPool(key).swapFeeTax`, `cMarketSwapFeeTax`);
|
|
101
|
-
|
|
204
|
+
market's from birth (`getPool(key).swapFeeTax`, `cMarketSwapFeeTax`); since 098 the level is the policy's
|
|
205
|
+
immutable (`cSwapFeeTax(c, policy?)` reads it; a different level is a different policy). `registryOwner`,
|
|
102
206
|
`registryProposeOwner` / `registryAcceptOwner` and `proposeCollector` / `acceptCollector` remain
|
|
103
207
|
as deprecated aliases.
|
|
104
208
|
|
|
@@ -111,8 +215,7 @@ from the registry's `Approved`), the registry, the token factory and the manager
|
|
|
111
215
|
nothing has to scan the node from block 0 — which the devnet node, pruning logs after about a day,
|
|
112
216
|
answers only partly.
|
|
113
217
|
|
|
114
|
-
- `swapFees`, `holdingsOf`, `discoverMarkets` and `fPoolKeyOfPool` take `indexer` (the
|
|
115
|
-
`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).
|
|
116
219
|
- `getEventLogs` takes several emitters (`address: [...]`); a policy outside the artifact names its
|
|
117
220
|
shared tables with `contract: indexedContractOf(kind, event)` (or `kind` on `getEventsLogs`).
|
|
118
221
|
- `tokensCreated` lists the factory's tokens (`addresses.tokenFactory`): the token list's provenance.
|
|
@@ -146,24 +249,26 @@ as the fallback, with the same answer on the same data:
|
|
|
146
249
|
- `fPoolShareHolders`: the holders from `pool_holder`;
|
|
147
250
|
- `swapFees`: the window from `swap_flow`.
|
|
148
251
|
|
|
149
|
-
What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `
|
|
150
|
-
`
|
|
151
|
-
|
|
152
|
-
## The F pool's life: four calls (F
|
|
153
|
-
|
|
154
|
-
- **`fPoolInitialize`**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
book outright (`baseAssets`, `lnCapOverSeed`) or the
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
- **`
|
|
166
|
-
|
|
252
|
+
What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `cLegsOf`,
|
|
253
|
+
`cHeldByIds`, `dividendOf`). They accrue without events, so no view holds them.
|
|
254
|
+
|
|
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.
|
|
167
272
|
- **The cap** (decisions 061, 075) is the pool's one log ratio `lnCapOverSeed` = ln(cap price / seed price) in 1e-6 log
|
|
168
273
|
units, chosen at each deployment: each asset's maximum price is its own seed price times it.
|
|
169
274
|
`fPoolCapOfLeverage(λ)` gives it for a leverage (λ = 2 → the cap at twice the seed price),
|
|
@@ -173,7 +278,7 @@ What stays a live read: a C position's value and every unclaimed fee or dividend
|
|
|
173
278
|
`fPoolBookWeights` and `fPoolBookL` derive the allocation and the liquidity from it. A regeneration emits no
|
|
174
279
|
such event; the freeze-out is read from `GenerationRetired` and `IncomeReleased`.
|
|
175
280
|
- **Income and income tax** (decision 085): the dead shares' dividend and the share of it the treasury takes are
|
|
176
|
-
the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`,
|
|
281
|
+
the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`; the rate is the policy's `incomeTaxRate`, an immutable since 098).
|
|
177
282
|
|
|
178
283
|
- **The lien** (decisions 063): a lending contract locks an owner's shares in place.
|
|
179
284
|
`fPoolApproveShares` (the owner's per-id allowance), `fPoolLock` / `fPoolUnlock` (the locker's;
|
|
@@ -223,7 +328,7 @@ What changes for readers:
|
|
|
223
328
|
- **The indexer is per chain**: `indexerUrl` on the client is the default `indexer` of every history
|
|
224
329
|
read and of `discoverMarketsBest`. Its rows are filtered by contract address, which is the same on
|
|
225
330
|
every chain, so one URL must serve one chain.
|
|
226
|
-
- **Caches key on the chain id**: the policy-
|
|
331
|
+
- **Caches key on the chain id**: the policy-terms cache asks the node for the chain id when the
|
|
227
332
|
client has none; `RESETTABLE_CHAINS` is every registry chain flagged `devnet` (plus 1337 and 31338),
|
|
228
333
|
extended with `addResettableChain`.
|
|
229
334
|
- **F version 29** (decision 068): `FPoolState.restructureTime` (unix seconds; was
|
package/dist/actions.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* hand-written and a struct change is a `tsc`/vector failure, not a runtime surprise.
|
|
19
19
|
*/
|
|
20
20
|
import { encodeAbiParameters } from "viem";
|
|
21
|
-
import {
|
|
21
|
+
import { routerCAbi, routerActionsAbi } from "./generated.js";
|
|
22
22
|
import { poolId as keyId } from "./keys.js";
|
|
23
23
|
import { NO_CAP } from "./ids.js";
|
|
24
24
|
import { resolveDeadline, resolveRecipient, sendRouterWriteWithPermits, simulateRouterWrite } from "./write.js";
|
|
@@ -126,13 +126,14 @@ export function settleOnly(key, recipient, side, b = {}) {
|
|
|
126
126
|
export async function execute(c, a) {
|
|
127
127
|
const settle = { ...a.settle, recipient: a.settle.recipient ?? resolveRecipient(c, a) };
|
|
128
128
|
const pull = a.pullTokens ?? settle.tokens.filter((_, i) => settle.maxIn[i] > 0n);
|
|
129
|
-
return sendRouterWriteWithPermits(c, { abi:
|
|
129
|
+
return sendRouterWriteWithPermits(c, { side: "C", abi: routerCAbi, functionName: "execute", args: [a.actions, settle, resolveDeadline(a)] }, [...pull]);
|
|
130
130
|
}
|
|
131
131
|
/** Simulate a batch: the per-action returns and the signed flows (+ = paid in), without sending. */
|
|
132
132
|
export async function simulateExecute(c, a) {
|
|
133
133
|
const settle = { ...a.settle, recipient: a.settle.recipient ?? a.account ?? resolveRecipient(c, a) };
|
|
134
134
|
const [results, flows] = await simulateRouterWrite(c, {
|
|
135
|
-
|
|
135
|
+
side: "C",
|
|
136
|
+
abi: routerCAbi,
|
|
136
137
|
functionName: "execute",
|
|
137
138
|
args: [a.actions, settle, resolveDeadline(a)],
|
|
138
139
|
account: a.account,
|