@logswap/sdk 0.5.90 → 0.5.91
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 +74 -12
- package/dist/actions.js +4 -3
- package/dist/admin.d.ts +213 -219
- package/dist/admin.js +118 -144
- package/dist/chains.d.ts +13 -4
- package/dist/chains.js +23 -9
- package/dist/claims.d.ts +1 -1
- package/dist/claims.js +11 -9
- package/dist/client.d.ts +43 -20
- package/dist/client.js +75 -26
- package/dist/fees.d.ts +1 -1
- package/dist/fees.js +5 -4
- package/dist/fpool.d.ts +170 -460
- package/dist/fpool.js +175 -218
- package/dist/generated.d.ts +5549 -6027
- package/dist/generated.js +2580 -3153
- package/dist/history.js +13 -11
- 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 +168 -171
- package/src/chains.ts +33 -13
- package/src/claims.ts +11 -10
- package/src/client.ts +101 -39
- package/src/fees.ts +6 -6
- package/src/fpool.ts +240 -272
- package/src/generated.ts +2525 -3094
- package/src/history.ts +11 -9
- 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,76 @@ 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
|
+
## C 16 / F 40 (decision 098): immutable, LOG-deployed policies; one sponsored policy per manager
|
|
49
|
+
|
|
50
|
+
Follows contracts `99827f8`. This is a breaking release: the policy surface is replaced.
|
|
51
|
+
|
|
52
|
+
- **Kinds.** `PublicPolicy` and `PrivatePolicy` are gone. A policy says it is `"sponsor"` (`SponsorPolicyF` / `SponsorPolicyC`: the LOG's own
|
|
53
|
+
instances, the open canonical one and a gated one, and a third party's deployed by the LOG), `"pol"`, `"pad"` or `"orphan"` (`OrphanPolicyF`).
|
|
54
|
+
`FPoolKind` is `"sponsor" | "pol" | "pad" | "orphan"`. `fPoolPolicyFor(c, slot)` and `FPoolCreateArgs.kind` take a deployment *slot*
|
|
55
|
+
(`FPolicySlot`: `"public"`, `"private"`, `"pol"`, `"pad"`, the artifact's keys: `publicPolicy` / `privatePolicy` are the LOG's open and gated
|
|
56
|
+
`SponsorPolicyF` instances). New optional addresses: `publicPolicyC` (the open `SponsorPolicyC`) and `orphanPolicy`.
|
|
57
|
+
`sponsorPolicyFAbi`, `sponsorPolicyCAbi` and `orphanPolicyFAbi` replace `publicPolicyAbi` / `privatePolicyAbi`.
|
|
58
|
+
- **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`,
|
|
59
|
+
`gatesAvailable`, `bornGated`, a pad's schedule and income tax rate, a POL's reserve ratio) are constructor immutables: a change is a new policy,
|
|
60
|
+
which the LOG approves (`registryApprove`) and moves pools to (`fPoolMigrate`). The wrappers for the old setters are removed
|
|
61
|
+
(`padSetSchedule`, `padSetThresholdBase`, `padSetIncomeTaxRate`, `polSetMinQuoteRatio`, `polSetIncomeTaxRate`, `policySetQuoteListed`,
|
|
62
|
+
`policySetQuoteCurated`, `policySetFeeListed`, `policySetFeeCurated`, `gateSetPairListed`, `gateSetPairCurated`, `gateSetSpacingListed`,
|
|
63
|
+
`policySetSpacingListed`, `policySetSpacingCurated`, `setCSwapFeeTax`, `setCGate`, `registrySetInitializerListed`). Readers remain:
|
|
64
|
+
`policyQuoteAllowed`, `policyFeeAllowed(c, policy, fee, "swap" | "mint")`, `policySpacingAllowed`, `cSwapFeeTax(c, policy?)`, `padScheduleOf`,
|
|
65
|
+
`padThresholdBases`, `padThresholdOf`, `padThreshold`, and `getFPoolRules` (which now returns the sponsored policy's immutables).
|
|
66
|
+
- **Authority and operator.** The authority is `key.creator` for life: no handover (`fPoolProposeAuthority` / `fPoolAcceptAuthority` are removed;
|
|
67
|
+
`FPoolRoles` loses `creator`, `pendingAuthority` and `swapExecutor`). The authority appoints a per-pool operator (`fPoolAppointOperator`, was
|
|
68
|
+
`fPoolSetPoolOperator`), sets the swap mode (`fPoolSetSwapMode`: `"open" | "operator" | "listed"`, no executor), the mint gate
|
|
69
|
+
(`fPoolSetMintGate`) and the whitelist (`fPoolSetListed(who, listed)` and `fPoolIsListed`; the minter and taker lists are gone). The same
|
|
70
|
+
functions exist on `SponsorPolicyC`: pass `policy: key.policy` for a C market. `fPoolDeskOpening` is now the one mint-gate write.
|
|
71
|
+
- **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
|
|
72
|
+
gone) and `FPoolState.operator` is the operator the manager caches (admitted by a gated swap or mint with no policy call). `setPermissions` /
|
|
73
|
+
`PermissionsSet` are `setGates(poolId, gates, operator)` / `GatesSet` on both managers; the indexer's shared table is `GatesSet`.
|
|
74
|
+
- **Registry.** `CreationMode` is `"open" | "sponsorOnly"` (`Restricted`, the initializer list and `InitializerNotListed` are gone; the initializer
|
|
75
|
+
must be `key.creator`, `NotCreator`). `fPoolMigrate(c, { key, to, permissions? })` installs the new policy's swap mode, operator, mint gate and
|
|
76
|
+
whitelist in the same transaction (`MigrationPermissions`; `migratePrivate` is gone). New: `fPoolOrphan` (`PolicyRegistry.orphan`, final),
|
|
77
|
+
`registryOrphanPolicyOf`, `registrySetOrphanPolicy`.
|
|
78
|
+
- **C gate.** `cGateRules` reads the sponsored C policy: `pairOk` is gone, `mintFeeOk` is new, `saltOk` binds only a canonical policy;
|
|
79
|
+
`gateErrorAbi` carries `FeeNotListed`, `MintFeeNotListed`, `QuoteNotListed`, `GatesUnavailable`, `NotCanonical`.
|
|
80
|
+
- **Versions.** `EXPECTED_VERSION` is 16 (C) and `EXPECTED_F_VERSION` is 40. No pool id moved.
|
|
81
|
+
|
|
82
|
+
## C 15 / F 39 (decisions 096, 097): a router and a lens per manager, and a C market has a creator and a salt
|
|
83
|
+
|
|
84
|
+
(The policy parts of this section are superseded by the one above.)
|
|
85
|
+
|
|
86
|
+
Follows contracts `f3164de` (096 + #112 + #113 + #115 + #116). What changes for a consumer:
|
|
87
|
+
|
|
88
|
+
- **Addresses.** `LogswapAddresses` is `managerF`, `routerF`, `lensF` (required) and `managerC`, `routerC`, `lensC` (optional:
|
|
89
|
+
F ships first, so a chain may have no C stack; the artifact then carries `address(0)` and `cVersion` 0). `managerC(c)`,
|
|
90
|
+
`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.
|
|
91
|
+
- **ABIs.** `managerCAbi` / `managerFAbi`, `routerCAbi` / `routerFAbi`, `lensCAbi` / `lensFAbi`, `routerActionsAbi`. Each router is its
|
|
92
|
+
own Permit2 spender: `approveToken`, `approvePermit2ForRouter`, `onboardToken`, `checkTokenReadiness`, `spenderFor` and
|
|
93
|
+
`permit2SigCalls` take the side (`"C"` or `"F"`) after the client, and `sendRouterWrite*` take `side` in their arguments.
|
|
94
|
+
- **Names.** The 095 `c`-prefixed C functions are back to the plain 096 names (`getPool`, `discoverMarkets`, `swapExactIn`, ...); the event
|
|
95
|
+
`PoolCreated`, `Swap` and `SwapState` are the same on both managers (declared once in `ManagerBase`). `TickCrossed`, `BackstopSeeded` and
|
|
96
|
+
`Stamped` are gone from the ABIs.
|
|
97
|
+
- **A C key has a creator and a salt** (decision 097): `PoolKey = { base, quote, tickSpacing, policy, creator, salt, swapFee, mintFee }`,
|
|
98
|
+
so every C pool id is new. Only the creator may `initialize` and make the first mint (the backstop seed; `NotCreator`), and `initializeMarket`
|
|
99
|
+
refuses an account that is not `key.creator` before sending. `PoolCreated` carries a trailing `salt`; the indexer rows carry `creator` and `salt`.
|
|
100
|
+
A malformed policy answer is `BadTerms` (#115). The public policy is canonical per exact key (`salt` 0, `NotCanonical`); `marketOf` and
|
|
101
|
+
`MarketExists` are gone, and `cGateRules` reads `getPool(key).initialized` for `exists` and adds `saltOk`.
|
|
102
|
+
- **Registry and policies.** `registryUserOf(c, caller)` reads `PolicyRegistry.userOf` (the account a routed caller acts for);
|
|
103
|
+
`policySpacingAllowed` reads the tick-spacing list (since 098 only on `SponsorPolicyC`, and read-only).
|
|
104
|
+
- **Versions.** `EXPECTED_VERSION` is 15 (C) and `EXPECTED_F_VERSION` is 39; `assertVersion` checks C only where the deployment has it, and
|
|
105
|
+
`assertWiring` checks each router and lens against its own manager.
|
|
106
|
+
|
|
47
107
|
## C 13 (decisions 088–090): a C market is addressed by its pool id
|
|
48
108
|
|
|
109
|
+
(The router and lens naming in this section is superseded by the one above.)
|
|
110
|
+
|
|
49
111
|
The consumer API still takes a `PoolKey`; the SDK hashes it (`poolId(key)`) and calls the contracts with the id.
|
|
50
112
|
What changes for a consumer:
|
|
51
113
|
|
|
@@ -66,7 +128,7 @@ What changes for a consumer:
|
|
|
66
128
|
you need no recipient, deadline or Permit2 (decision 091).
|
|
67
129
|
- **Layout.** F `getPool` has `swapFee` / `mintFee` as `uint56`; the `extsload` words are in the contracts' `FPoolState`.
|
|
68
130
|
|
|
69
|
-
## Who may create what: the gate, the menus (C version 7, F version 26)
|
|
131
|
+
## Who may create what: the gate, the menus (C version 7, F version 26; superseded by decision 098 above)
|
|
70
132
|
|
|
71
133
|
Since logswap-contract #60 (decisions 064–065) creation is curated at launch, on both managers:
|
|
72
134
|
|
|
@@ -89,16 +151,16 @@ Since logswap-contract #60 (decisions 064–065) creation is curated at launch,
|
|
|
89
151
|
own fee for an initialized market.
|
|
90
152
|
- **C reads**: `getPool` reads the lens's `getPools`; `getPositionClass` reads the class through
|
|
91
153
|
`extsload` at `CPoolState`'s slot (the manager's typed views are gone).
|
|
92
|
-
- **
|
|
93
|
-
LOG Authority's helpers
|
|
94
|
-
|
|
154
|
+
- **Creation** (098): the registry's creation mode per policy (`open`, or `sponsorOnly`: the policy's own immutable sponsor creates);
|
|
155
|
+
`registrySetCreationMode` and `registrySetForwarderTrusted` are the LOG Authority's helpers. The creator list, the pair list and
|
|
156
|
+
the policy setters are gone.
|
|
95
157
|
- **Two roles (decision 066, C 8 / F 27).** `logAuthority()` reads the LOG Authority (the
|
|
96
158
|
registry's `logAuthority`; `proposeLogAuthority` / `acceptLogAuthority`), which administers the
|
|
97
159
|
registry, both managers and every policy. `logTreasury(side)` reads a manager's treasury, which
|
|
98
160
|
only receives; `proposeTreasury` is the authority's, `acceptTreasury` the incoming treasury's own
|
|
99
161
|
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
|
-
|
|
162
|
+
market's from birth (`getPool(key).swapFeeTax`, `cMarketSwapFeeTax`); since 098 the level is the policy's
|
|
163
|
+
immutable (`cSwapFeeTax(c, policy?)` reads it; a different level is a different policy). `registryOwner`,
|
|
102
164
|
`registryProposeOwner` / `registryAcceptOwner` and `proposeCollector` / `acceptCollector` remain
|
|
103
165
|
as deprecated aliases.
|
|
104
166
|
|
|
@@ -146,8 +208,8 @@ as the fallback, with the same answer on the same data:
|
|
|
146
208
|
- `fPoolShareHolders`: the holders from `pool_holder`;
|
|
147
209
|
- `swapFees`: the window from `swap_flow`.
|
|
148
210
|
|
|
149
|
-
What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `
|
|
150
|
-
`
|
|
211
|
+
What stays a live read: a C position's value and every unclaimed fee or dividend (the lens: `cLegsOf`,
|
|
212
|
+
`cHeldByIds`, `dividendOf`). They accrue without events, so no view holds them.
|
|
151
213
|
|
|
152
214
|
## The F pool's life: four calls (F 38)
|
|
153
215
|
|
|
@@ -173,7 +235,7 @@ What stays a live read: a C position's value and every unclaimed fee or dividend
|
|
|
173
235
|
`fPoolBookWeights` and `fPoolBookL` derive the allocation and the liquidity from it. A regeneration emits no
|
|
174
236
|
such event; the freeze-out is read from `GenerationRetired` and `IncomeReleased`.
|
|
175
237
|
- **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`,
|
|
238
|
+
the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`; the rate is the policy's `incomeTaxRate`, an immutable since 098).
|
|
177
239
|
|
|
178
240
|
- **The lien** (decisions 063): a lending contract locks an owner's shares in place.
|
|
179
241
|
`fPoolApproveShares` (the owner's per-id allowance), `fPoolLock` / `fPoolUnlock` (the locker's;
|
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,
|