@logswap/sdk 0.5.35
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 +130 -0
- package/dist/actions.d.ts +136 -0
- package/dist/actions.js +140 -0
- package/dist/admin.d.ts +11 -0
- package/dist/admin.js +29 -0
- package/dist/claims.d.ts +53 -0
- package/dist/claims.js +98 -0
- package/dist/client.d.ts +68 -0
- package/dist/client.js +68 -0
- package/dist/fpool.d.ts +416 -0
- package/dist/fpool.js +653 -0
- package/dist/generated.d.ts +6522 -0
- package/dist/generated.js +3755 -0
- package/dist/ids.d.ts +42 -0
- package/dist/ids.js +72 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/indexer.d.ts +91 -0
- package/dist/indexer.js +197 -0
- package/dist/keys.d.ts +40 -0
- package/dist/keys.js +50 -0
- package/dist/liquidity.d.ts +223 -0
- package/dist/liquidity.js +305 -0
- package/dist/onboard.d.ts +56 -0
- package/dist/onboard.js +188 -0
- package/dist/pools.d.ts +182 -0
- package/dist/pools.js +322 -0
- package/dist/positions.d.ts +164 -0
- package/dist/positions.js +197 -0
- package/dist/swap.d.ts +68 -0
- package/dist/swap.js +91 -0
- package/dist/tokencache.d.ts +76 -0
- package/dist/tokencache.js +150 -0
- package/dist/write.d.ts +86 -0
- package/dist/write.js +106 -0
- package/package.json +48 -0
- package/src/actions.ts +207 -0
- package/src/admin.ts +33 -0
- package/src/claims.ts +132 -0
- package/src/client.ts +104 -0
- package/src/fpool.ts +935 -0
- package/src/generated.ts +3762 -0
- package/src/ids.ts +78 -0
- package/src/index.ts +23 -0
- package/src/indexer.ts +252 -0
- package/src/keys.ts +73 -0
- package/src/liquidity.ts +430 -0
- package/src/onboard.ts +228 -0
- package/src/pools.ts +396 -0
- package/src/positions.ts +276 -0
- package/src/swap.ts +140 -0
- package/src/tokencache.ts +169 -0
- package/src/write.ts +134 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client.ts — the SDK handle: addresses + viem clients.
|
|
3
|
+
*
|
|
4
|
+
* Construct once and pass to every helper. `wallet` is optional: read helpers need only `public`.
|
|
5
|
+
*
|
|
6
|
+
* **Three addresses, permanently.** Not three per market — every market lives in the one manager,
|
|
7
|
+
* and a market is an `initialize(key, x0)` call rather than a deployment. So this is a constant of
|
|
8
|
+
* the protocol, not configuration that grows.
|
|
9
|
+
*/
|
|
10
|
+
export function createLogswapClient(args) {
|
|
11
|
+
return { public: args.public, wallet: args.wallet, addresses: args.addresses };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Assert the deployment matches the ABI this build was generated against.
|
|
15
|
+
*
|
|
16
|
+
* Cheap insurance worth taking at construction: without it, a manager from a different deployment
|
|
17
|
+
* decodes into plausible-looking garbage rather than failing. `version` is bumped on any tier-1 or
|
|
18
|
+
* tier-2 change (docs/app.md).
|
|
19
|
+
*
|
|
20
|
+
* **2** since 2026-09-01. It sat at 1 across a read surface that changed underneath it — the nine
|
|
21
|
+
* `public constant` getters left the manager for `CParams`, `move` gained its settlement bounds,
|
|
22
|
+
* `createMarket` arrived — so a 1 answered for two incompatible ABIs and this check passed against
|
|
23
|
+
* a manager it should have rejected. Observed, not theorised: a local chain running a pre-trim
|
|
24
|
+
* manager sailed through `assertVersion` while `FEE_MAX()` still answered on it. Move this in the
|
|
25
|
+
* same change as `CParams.VERSION`, never after it.
|
|
26
|
+
*
|
|
27
|
+
* **3** since 2026-09-03 (contracts `d8406fb`): `burnById` and `update` take an `owner`, `update`
|
|
28
|
+
* mints to `to`, `positions()` returns `aps` as uint128 — and a returned quote flow now carries the
|
|
29
|
+
* swept fees (decisions 018), which is why `exit`'s settle-to-one-asset math changed with it.
|
|
30
|
+
*/
|
|
31
|
+
export const EXPECTED_VERSION = 3n;
|
|
32
|
+
/**
|
|
33
|
+
* The F manager's own tag (contracts 25a7bcf: 5 — the key's salt, pool names, the sponsor registry;
|
|
34
|
+
* 4 was the income-only harvest cut).
|
|
35
|
+
*
|
|
36
|
+
* A FLOOR, not an equality — unlike `EXPECTED_VERSION` above. The F primitive is iterating fast and
|
|
37
|
+
* its bumps are mostly additive (6 is `multicall`, which nothing this SDK calls goes near), so an
|
|
38
|
+
* exact match meant each one bricked every app on the deployment until the SDK was republished — a
|
|
39
|
+
* version wall in front of a change that broke nothing. The cost is that a genuinely breaking bump
|
|
40
|
+
* passes it; when one lands, raise this constant in the same change, which is the discipline
|
|
41
|
+
* `EXPECTED_VERSION` enforces mechanically and this one asks for.
|
|
42
|
+
*/
|
|
43
|
+
export const EXPECTED_F_VERSION = 5n;
|
|
44
|
+
export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
45
|
+
const { cPoolManagerAbi } = await import("./generated.js");
|
|
46
|
+
const got = await c.public.readContract({
|
|
47
|
+
address: c.addresses.cPoolManager,
|
|
48
|
+
abi: cPoolManagerAbi,
|
|
49
|
+
functionName: "version",
|
|
50
|
+
});
|
|
51
|
+
if (got !== expected) {
|
|
52
|
+
throw new Error(`logswap: manager at ${c.addresses.cPoolManager} reports version ${got}, but this SDK was built ` +
|
|
53
|
+
`against version ${expected}. Upgrade the SDK or point at the matching deployment.`);
|
|
54
|
+
}
|
|
55
|
+
// the F manager carries its own tag since contracts c782811; assert it the same way when deployed
|
|
56
|
+
if (c.addresses.fPoolManager) {
|
|
57
|
+
const { fPoolManagerAbi } = await import("./generated.js");
|
|
58
|
+
const gotF = await c.public.readContract({
|
|
59
|
+
address: c.addresses.fPoolManager,
|
|
60
|
+
abi: fPoolManagerAbi,
|
|
61
|
+
functionName: "version",
|
|
62
|
+
});
|
|
63
|
+
if (gotF < EXPECTED_F_VERSION) {
|
|
64
|
+
throw new Error(`logswap: F manager at ${c.addresses.fPoolManager} reports version ${gotF}, but this SDK needs ` +
|
|
65
|
+
`at least F version ${EXPECTED_F_VERSION}. Upgrade the deployment or point at a newer one.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/fpool.d.ts
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fpool.ts — the `FPoolManager` surface: n bases, one quote, one shared floor.
|
|
3
|
+
*
|
|
4
|
+
* The other primitive. `CPoolManager` gives every position its own floor on a tick ladder;
|
|
5
|
+
* `FPoolManager` gives every share the SAME floor and deletes the ladder, the accumulators and the
|
|
6
|
+
* per-position accounting with it. Reading the two side by side is the fastest way to understand
|
|
7
|
+
* either (logswap-docs:docs/multi/f-pool.md).
|
|
8
|
+
*
|
|
9
|
+
* **A pool is an ID, not an address.** Both primitives are singletons now, so neither has a
|
|
10
|
+
* per-pool deployment — but they are addressed differently and for a reason. The C manager rides
|
|
11
|
+
* its whole `PoolKey` in calldata because that key is small, fixed and wholly needed. An F-pool
|
|
12
|
+
* key is variable-length and only ever partially needed (no swap path is O(n)), so it is stored
|
|
13
|
+
* once at `initialize` and every later call names `(poolId, j)`. Callers hold a `bytes32`.
|
|
14
|
+
*
|
|
15
|
+
* **Two products, one contract.** The basket (n > 1, public authority) and the launch (n = 1, the
|
|
16
|
+
* creator alone on the lever) are the same bytecode under different settings — what separates them
|
|
17
|
+
* is who holds `authority` and how many bases there are, and nothing in the maths. `describeFPool`
|
|
18
|
+
* below reports which shape a given pool is, because a UI has to decide what to render.
|
|
19
|
+
*
|
|
20
|
+
* **Zaps live on the ROUTER, not here.** Permit2 is AllowanceTransfer mode, whose standing
|
|
21
|
+
* allowance is keyed by spender, so a second router would cost the user an allowance per token
|
|
22
|
+
* twice, forever. One router is one spender — see `fPoolZapIn`/`fPoolZapOut` below, which target
|
|
23
|
+
* `addresses.router`.
|
|
24
|
+
*/
|
|
25
|
+
import { type Address, type Hash, type Hex } from "viem";
|
|
26
|
+
import type { LogswapClient } from "./client.js";
|
|
27
|
+
/** Everything scalar about a basket pool, in one round trip's worth of reads. */
|
|
28
|
+
export interface FPoolState {
|
|
29
|
+
/** The pool's id — the hash of its key. There is no per-pool address. */
|
|
30
|
+
poolId: Hex;
|
|
31
|
+
quote: Address;
|
|
32
|
+
bases: Address[];
|
|
33
|
+
/** WAD weights, summing to WAD. `L_j = w_j · L`. */
|
|
34
|
+
weights: bigint[];
|
|
35
|
+
/** Per-asset log prices, WAD. Price is derived; `x` is the state. */
|
|
36
|
+
x: bigint[];
|
|
37
|
+
/** Quote reserve. The one leg a base→quote swap can exhaust. */
|
|
38
|
+
Q: bigint;
|
|
39
|
+
/** Total exposure. Grows on mint, shrinks on burn; never moves on a swap. */
|
|
40
|
+
L: bigint;
|
|
41
|
+
/** Fixed fee, WAD. At or above `FEE_MIN` — a zero-fee basket is not constructible. */
|
|
42
|
+
phi: bigint;
|
|
43
|
+
/** The strike: θ at seeding, and the fees-only harvest bound. */
|
|
44
|
+
theta0: bigint;
|
|
45
|
+
/** θ = X − Q/L, the shared floor. Derived from the holdings, never stored. */
|
|
46
|
+
theta: bigint;
|
|
47
|
+
/** X = Σ w_j x_j, the composite index. */
|
|
48
|
+
compositeX: bigint;
|
|
49
|
+
/** Σ = ∫ Σ_j w_j (dx_j)², accrued even though the fee is fixed — the kernel stays calculable. */
|
|
50
|
+
bigSigma: bigint;
|
|
51
|
+
/** Creator (private) or a governance contract (public). Holds the floor lever. */
|
|
52
|
+
authority: Address;
|
|
53
|
+
/** The proposed next authority, until it accepts — zero when nothing is pending (decisions 020). */
|
|
54
|
+
pendingAuthority: Address;
|
|
55
|
+
/** The desk's hot key (`ma-private.md` §6): may reshape composition, never move value out. Zero when none. */
|
|
56
|
+
operator: Address;
|
|
57
|
+
/** The sponsor's own label for this pool, mutable and never identity. "" when unnamed. */
|
|
58
|
+
name: string;
|
|
59
|
+
/** `harvest` may not take Q/L under this (WAD log-distance); raise-only (decisions 021). */
|
|
60
|
+
minBuffer: bigint;
|
|
61
|
+
/** Only `allowed` accounts may receive minted shares. */
|
|
62
|
+
gateMint: boolean;
|
|
63
|
+
/** Only `allowed` takers may swap. */
|
|
64
|
+
gateSwap: boolean;
|
|
65
|
+
/** The block of the last lever / composition action: no swap runs in it. */
|
|
66
|
+
restructureBlock: number;
|
|
67
|
+
/** Whether harvest is bounded by θ ≤ θ₀ — income only, never the floor's backing. */
|
|
68
|
+
feesOnly: boolean;
|
|
69
|
+
seeded: boolean;
|
|
70
|
+
dissolved: boolean;
|
|
71
|
+
totalSupply: bigint;
|
|
72
|
+
/** Base holdings the state implies, `R_j = w_j·L·e^{−x_j}`. */
|
|
73
|
+
reserves: bigint[];
|
|
74
|
+
}
|
|
75
|
+
/** Read a basket pool whole. Batched — viem multicalls these when the transport allows. */
|
|
76
|
+
export declare function getFPool(c: LogswapClient, poolId: Hex): Promise<FPoolState>;
|
|
77
|
+
/** Which of the two products a pool is configured as. A UI has to choose what to render. */
|
|
78
|
+
export type FPoolShape = "launch" | "basket";
|
|
79
|
+
export interface FPoolDescription {
|
|
80
|
+
shape: FPoolShape;
|
|
81
|
+
/** n = 1 with a private authority is the launch shape (f-pool §6.5). */
|
|
82
|
+
legs: number;
|
|
83
|
+
/** True when the pool holds no quote: an all-base resting ask. base→quote is the one blocked path. */
|
|
84
|
+
atFloor: boolean;
|
|
85
|
+
/** Fee income earned per unit L so far, `θ₀ − θ` with the lever's displacement backed out. */
|
|
86
|
+
feePerL: bigint;
|
|
87
|
+
/** The model-free LP edge, `F − ½Σ`. Exact at any n: V is separable in the logs. */
|
|
88
|
+
edgePerL: bigint;
|
|
89
|
+
}
|
|
90
|
+
export declare function describeFPool(c: LogswapClient, s: FPoolState): Promise<FPoolDescription>;
|
|
91
|
+
/** `p_j = e^{x_j}`, lossy the way any float conversion is. Compare in log space when it matters. */
|
|
92
|
+
export declare function fPoolPriceOf(x: bigint, scale?: number): number;
|
|
93
|
+
/** Value per share at the pool's own marks. `V = L + Q`, so this is just that, pro-rated. */
|
|
94
|
+
export declare function fPoolShareValue(s: FPoolState): bigint;
|
|
95
|
+
export interface FPoolSwapArgs {
|
|
96
|
+
poolId: Hex;
|
|
97
|
+
/** Leg index into `bases`. */
|
|
98
|
+
j: number;
|
|
99
|
+
amountIn: bigint;
|
|
100
|
+
minOut?: bigint;
|
|
101
|
+
/** Who receives the out leg. Defaults to the account. */
|
|
102
|
+
to?: Address;
|
|
103
|
+
/** Absolute unix seconds. Defaulted to a bounded window, as every router write is. */
|
|
104
|
+
deadline?: bigint;
|
|
105
|
+
account: Address;
|
|
106
|
+
}
|
|
107
|
+
export declare function fPoolSwapQuoteIn(c: LogswapClient, a: FPoolSwapArgs): Promise<`0x${string}`>;
|
|
108
|
+
export declare function fPoolSwapBaseIn(c: LogswapClient, a: FPoolSwapArgs): Promise<`0x${string}`>;
|
|
109
|
+
/**
|
|
110
|
+
* Base j → base k. Needs no quote, works at Q = 0, and cannot cross the floor: X is held
|
|
111
|
+
* exactly up to the in-kind fee. Note it moves BOTH quote prices — p_j down, p_k up — because the
|
|
112
|
+
* pool has one coordinate per asset and every trade moves at least one.
|
|
113
|
+
*/
|
|
114
|
+
export declare function fPoolSwapBaseForBase(c: LogswapClient, a: FPoolSwapArgs & {
|
|
115
|
+
k: number;
|
|
116
|
+
}): Promise<`0x${string}`>;
|
|
117
|
+
/** Deposit dL/L of every reserve, receive shares ∝ dL. θ is untouched by construction. */
|
|
118
|
+
export declare function fPoolMint(c: LogswapClient, a: {
|
|
119
|
+
poolId: Hex;
|
|
120
|
+
dL: bigint;
|
|
121
|
+
maxQuoteIn?: bigint;
|
|
122
|
+
account: Address;
|
|
123
|
+
to?: Address;
|
|
124
|
+
}): Promise<`0x${string}`>;
|
|
125
|
+
/**
|
|
126
|
+
* Burn shares for the pro-rata slice of every reserve. Available at any Q, and after dissolution.
|
|
127
|
+
* By owner since contracts `c782811` (decisions 019): the account burns its own shares; an
|
|
128
|
+
* operator may pass another owner's address, as on the C manager's `burnById`.
|
|
129
|
+
*/
|
|
130
|
+
export declare function fPoolBurn(c: LogswapClient, a: {
|
|
131
|
+
poolId: Hex;
|
|
132
|
+
shares: bigint;
|
|
133
|
+
minQuoteOut?: bigint;
|
|
134
|
+
account: Address;
|
|
135
|
+
owner?: Address;
|
|
136
|
+
}): Promise<`0x${string}`>;
|
|
137
|
+
/**
|
|
138
|
+
* Quote needed to zap into exposure `dL`. An UPPER bound: buying each leg raises its mark, so the
|
|
139
|
+
* mint consumes less base than was bought for it and every zap ends with a refund. Size from this
|
|
140
|
+
* and expect change back — do not treat it as exact.
|
|
141
|
+
*/
|
|
142
|
+
export declare function fPoolPreviewZapIn(c: LogswapClient, poolId: Hex, dL: bigint): Promise<bigint>;
|
|
143
|
+
/**
|
|
144
|
+
* Buy `dL` of the basket with quote alone.
|
|
145
|
+
*
|
|
146
|
+
* The imbalanced part goes through the pool's own curve before anything is minted. That is not a
|
|
147
|
+
* penalty: minting against a quote-only deposit would be a zero-slippage, zero-fee swap at stale
|
|
148
|
+
* spot, paid for by the existing LPs — 27.4% in f-pool §6's worked example. Routing it through
|
|
149
|
+
* the curve deletes the subsidy and hands the fee and impact to the incumbents instead.
|
|
150
|
+
*/
|
|
151
|
+
export declare function fPoolZapIn(c: LogswapClient, a: {
|
|
152
|
+
poolId: Hex;
|
|
153
|
+
dL: bigint;
|
|
154
|
+
maxQuoteIn: bigint;
|
|
155
|
+
minShares?: bigint;
|
|
156
|
+
to?: Address;
|
|
157
|
+
account: Address;
|
|
158
|
+
deadline?: bigint;
|
|
159
|
+
}): Promise<`0x${string}`>;
|
|
160
|
+
/**
|
|
161
|
+
* Sell shares into ONE token — the quote, or any base.
|
|
162
|
+
*
|
|
163
|
+
* Into a base the other legs route through `swapBaseForBase`, which needs no quote and cannot
|
|
164
|
+
* cross the floor; only the burn's own quote slice touches the quote leg. Into the quote every
|
|
165
|
+
* base leg is sold, which is the one path a drained quote leg can block.
|
|
166
|
+
*/
|
|
167
|
+
export declare function fPoolZapOut(c: LogswapClient, a: {
|
|
168
|
+
poolId: Hex;
|
|
169
|
+
shares: bigint;
|
|
170
|
+
tokenOut: Address;
|
|
171
|
+
minOut?: bigint;
|
|
172
|
+
to?: Address;
|
|
173
|
+
account: Address;
|
|
174
|
+
deadline?: bigint;
|
|
175
|
+
}): Promise<`0x${string}`>;
|
|
176
|
+
/**
|
|
177
|
+
* Remove quote, lifting θ — price-neutral, pro-rata, no base moves. Under `feesOnly` the lift
|
|
178
|
+
* stops at θ₀, so the authority extracts income and never the proceeds backing the floor.
|
|
179
|
+
*/
|
|
180
|
+
export declare function fPoolHarvest(c: LogswapClient, a: {
|
|
181
|
+
poolId: Hex;
|
|
182
|
+
amount: bigint;
|
|
183
|
+
to?: Address;
|
|
184
|
+
account: Address;
|
|
185
|
+
}): Promise<`0x${string}`>;
|
|
186
|
+
/** Commit quote, deepening θ — the other sign of `harvest`, the same word as the C floor edit (decisions 011). The mark does not move: governance may write θ, never x. */
|
|
187
|
+
export declare function fPoolDeepen(c: LogswapClient, a: {
|
|
188
|
+
poolId: Hex;
|
|
189
|
+
amount: bigint;
|
|
190
|
+
account: Address;
|
|
191
|
+
}): Promise<`0x${string}`>;
|
|
192
|
+
/** Plain ERC-20 approval to the F manager — the allowance every DIRECT call pulls against. */
|
|
193
|
+
export declare function approveTokenForFPoolManager(c: LogswapClient, token: Address): Promise<Hash>;
|
|
194
|
+
/** Does `owner` have enough allowance on `token` for the MANAGER to pull `need`? */
|
|
195
|
+
export declare function fPoolManagerAllowanceOk(c: LogswapClient, token: Address, owner: Address, need: bigint): Promise<boolean>;
|
|
196
|
+
export declare function isRouterOperatorForFPool(c: LogswapClient, owner: Address): Promise<boolean>;
|
|
197
|
+
/** Approve the router to move this account's F-pool shares. Needed once, before any `fPoolZapOut`. */
|
|
198
|
+
export declare function approveRouterForFPool(c: LogswapClient, account: Address): Promise<`0x${string}`>;
|
|
199
|
+
/** The ERC-6909 id carrying a pool's shares. Bit 255 set. */
|
|
200
|
+
export declare function fPoolShareId(poolId: Hex): bigint;
|
|
201
|
+
/** The ERC-6909 id carrying claims on a token. Bit 255 clear, so it can never meet a share id. */
|
|
202
|
+
export declare function fPoolClaimId(token: Address): bigint;
|
|
203
|
+
export declare function fPoolShareBalance(c: LogswapClient, poolId: Hex, owner: Address): Promise<bigint>;
|
|
204
|
+
export declare function fPoolClaimBalance(c: LogswapClient, token: Address, owner: Address): Promise<bigint>;
|
|
205
|
+
export declare enum FPoolQuoteKind {
|
|
206
|
+
QuoteIn = 0,
|
|
207
|
+
BaseIn = 1,
|
|
208
|
+
BaseForBase = 2
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* An EXACT quote — what execution returns, not an estimate.
|
|
212
|
+
*
|
|
213
|
+
* `quoteSwap` runs the real swap and reverts with the answer, so the value has to be decoded out
|
|
214
|
+
* of the revert rather than returned. That is the point of the pattern: there is no second pricing
|
|
215
|
+
* path to drift from the first. It needs no tokens, no approvals and no balance, so it works from
|
|
216
|
+
* a disconnected wallet — unlike `fPoolPreviewZapIn`, which is a genuine upper bound.
|
|
217
|
+
*/
|
|
218
|
+
export declare function fPoolQuoteSwap(c: LogswapClient, a: {
|
|
219
|
+
poolId: Hex;
|
|
220
|
+
kind: FPoolQuoteKind;
|
|
221
|
+
j: number;
|
|
222
|
+
k?: number;
|
|
223
|
+
amountIn: bigint;
|
|
224
|
+
taker?: Address;
|
|
225
|
+
}): Promise<bigint>;
|
|
226
|
+
export interface FPoolCreateArgs {
|
|
227
|
+
quote: Address;
|
|
228
|
+
/** Legs in any order; sorted (with weights and marks kept aligned) before the call. */
|
|
229
|
+
bases: Address[];
|
|
230
|
+
/** WAD each; must sum to 1e18 — validated here so the revert is readable. */
|
|
231
|
+
weights: bigint[];
|
|
232
|
+
/** Fixed fee, WAD. The base-for-base fee is pinned at 2φ on-chain. */
|
|
233
|
+
phi: bigint;
|
|
234
|
+
/** true: the authority's harvest stops at the seed strike θ₀ (the launch posture). */
|
|
235
|
+
feesOnly: boolean;
|
|
236
|
+
authority: Address;
|
|
237
|
+
/**
|
|
238
|
+
* The differentiator, and nothing else. Identity is the key's hash, so one sponsor cannot run
|
|
239
|
+
* two pools of the same shape without varying it — the second `initialize` would land on the
|
|
240
|
+
* first pool's id. Defaults to zero, which is the first book of any shape. A pool's NAME is not
|
|
241
|
+
* this: names are mutable state (`fPoolSetName`), so a rename forks nothing.
|
|
242
|
+
*/
|
|
243
|
+
salt?: Hex;
|
|
244
|
+
account: Address;
|
|
245
|
+
}
|
|
246
|
+
/** `bytes32` ⇄ short UTF-8 text, for the pool and sponsor labels. */
|
|
247
|
+
export declare function textToBytes32(text: string): Hex;
|
|
248
|
+
export declare function bytes32ToText(word: Hex): string;
|
|
249
|
+
/** Sort legs by base address (the key's canonical order), carrying companion arrays along. */
|
|
250
|
+
export declare function sortFPoolLegs<T>(bases: Address[], ...companions: T[][]): {
|
|
251
|
+
bases: Address[];
|
|
252
|
+
companions: T[][];
|
|
253
|
+
};
|
|
254
|
+
/** Create the pool (no funds move — `seed` arms it). Returns the tx hash; read the id with `fPoolIdOf`. */
|
|
255
|
+
export declare function fPoolInitialize(c: LogswapClient, a: FPoolCreateArgs): Promise<`0x${string}`>;
|
|
256
|
+
/** The pool id is the key's hash — pure, so it can be read before or after creation. */
|
|
257
|
+
export declare function fPoolIdOf(c: LogswapClient, a: Omit<FPoolCreateArgs, "account">): Promise<Hex>;
|
|
258
|
+
/**
|
|
259
|
+
* Arm the pool: deposit the full basket at marks `x0` plus `Q0` of quote. Authority-only on-chain
|
|
260
|
+
* (an open seed lets anyone front-run the creator for the strike). `x0` must align with the
|
|
261
|
+
* SORTED bases — use {@link sortFPoolLegs} on (bases, weights, x0) together when building forms.
|
|
262
|
+
*/
|
|
263
|
+
export declare function fPoolSeed(c: LogswapClient, a: {
|
|
264
|
+
poolId: Hex;
|
|
265
|
+
L0: bigint;
|
|
266
|
+
x0: bigint[];
|
|
267
|
+
Q0: bigint;
|
|
268
|
+
account: Address;
|
|
269
|
+
}): Promise<`0x${string}`>;
|
|
270
|
+
/** End of life. Gated on-chain to the authority and to Q at dust (the raise is not abortable). */
|
|
271
|
+
export declare function fPoolDissolve(c: LogswapClient, a: {
|
|
272
|
+
poolId: Hex;
|
|
273
|
+
account: Address;
|
|
274
|
+
}): Promise<`0x${string}`>;
|
|
275
|
+
/**
|
|
276
|
+
* Propose the next authority — step one of two (contracts `2aa6b7b`, decisions 020). Nothing moves
|
|
277
|
+
* until `next` accepts; proposing again (the zero address included) cancels a pending proposal.
|
|
278
|
+
* Indexed on-chain via AuthorityProposed.
|
|
279
|
+
*/
|
|
280
|
+
export declare function fPoolProposeAuthority(c: LogswapClient, a: {
|
|
281
|
+
poolId: Hex;
|
|
282
|
+
next: Address;
|
|
283
|
+
account: Address;
|
|
284
|
+
}): Promise<`0x${string}`>;
|
|
285
|
+
/** Accept a pending proposal — step two; only the proposed address can. Indexed via AuthoritySet. */
|
|
286
|
+
export declare function fPoolAcceptAuthority(c: LogswapClient, a: {
|
|
287
|
+
poolId: Hex;
|
|
288
|
+
account: Address;
|
|
289
|
+
}): Promise<`0x${string}`>;
|
|
290
|
+
/** `setLegL`'s "keep the stored mark" sentinel — the only legal `x` for a live leg. */
|
|
291
|
+
export declare const NO_X: bigint;
|
|
292
|
+
/** Turn the mint / swap gates on or off (authority). `burn` is never gated. */
|
|
293
|
+
export declare function fPoolSetGates(c: LogswapClient, a: {
|
|
294
|
+
poolId: Hex;
|
|
295
|
+
gateMint: boolean;
|
|
296
|
+
gateSwap: boolean;
|
|
297
|
+
account: Address;
|
|
298
|
+
}): Promise<`0x${string}`>;
|
|
299
|
+
/** Add to or remove from the pool's list, in one call (authority). */
|
|
300
|
+
export declare function fPoolSetAllowed(c: LogswapClient, a: {
|
|
301
|
+
poolId: Hex;
|
|
302
|
+
who: readonly Address[];
|
|
303
|
+
allowed: boolean;
|
|
304
|
+
account: Address;
|
|
305
|
+
}): Promise<`0x${string}`>;
|
|
306
|
+
/** Whether `who` is on the pool's list (consulted only while a gate is on). */
|
|
307
|
+
export declare function fPoolIsAllowed(c: LogswapClient, poolId: Hex, who: Address): Promise<boolean>;
|
|
308
|
+
/** Label the pool — the sponsor's own words, mutable, never identity. At most 31 bytes of UTF-8. */
|
|
309
|
+
export declare function fPoolSetName(c: LogswapClient, a: {
|
|
310
|
+
poolId: Hex;
|
|
311
|
+
name: string;
|
|
312
|
+
account: Address;
|
|
313
|
+
}): Promise<`0x${string}`>;
|
|
314
|
+
/**
|
|
315
|
+
* What the PROTOCOL says an address is — "Keyrock". Only `feeCollector` may write it, which is
|
|
316
|
+
* what makes it an attestation rather than a claim anyone could make about themselves.
|
|
317
|
+
*/
|
|
318
|
+
export declare function fPoolSetSponsorName(c: LogswapClient, a: {
|
|
319
|
+
who: Address;
|
|
320
|
+
name: string;
|
|
321
|
+
account: Address;
|
|
322
|
+
}): Promise<`0x${string}`>;
|
|
323
|
+
/** The protocol's attestation for an address, or "" when unattested — which most addresses are. */
|
|
324
|
+
export declare function fPoolSponsorName(c: LogswapClient, who: Address): Promise<string>;
|
|
325
|
+
/** Appoint (or clear, with the zero address) the operator — the hot key that reshapes and never moves value out. */
|
|
326
|
+
export declare function fPoolAppointOperator(c: LogswapClient, a: {
|
|
327
|
+
poolId: Hex;
|
|
328
|
+
operator: Address;
|
|
329
|
+
account: Address;
|
|
330
|
+
}): Promise<`0x${string}`>;
|
|
331
|
+
/**
|
|
332
|
+
* Raise the floor guard: `harvest` may not take Q/L under `minBuffer` (WAD log-distance; 20% below
|
|
333
|
+
* spot is ln 1.25 ≈ 0.223e18). Raise-only — a commitment the authority cannot walk back.
|
|
334
|
+
*/
|
|
335
|
+
export declare function fPoolRaiseMinBuffer(c: LogswapClient, a: {
|
|
336
|
+
poolId: Hex;
|
|
337
|
+
minBuffer: bigint;
|
|
338
|
+
account: Address;
|
|
339
|
+
}): Promise<`0x${string}`>;
|
|
340
|
+
/**
|
|
341
|
+
* Set leg `j`'s liquidity (operator, sole LP only): grow, shrink, retire (`newLj = 0`), or re-admit
|
|
342
|
+
* a retired leg at a named mark `x`. For a live leg leave `x` undefined — its mark is the market's.
|
|
343
|
+
* The base moves single-sidedly through the lock; shares adjust to hold the share value.
|
|
344
|
+
*/
|
|
345
|
+
export declare function fPoolSetLegL(c: LogswapClient, a: {
|
|
346
|
+
poolId: Hex;
|
|
347
|
+
j: number;
|
|
348
|
+
newLj: bigint;
|
|
349
|
+
x?: bigint;
|
|
350
|
+
account: Address;
|
|
351
|
+
}): Promise<`0x${string}`>;
|
|
352
|
+
/** Admit a base the pool has never held, at a named mark, with liquidity `Lj` (operator, sole LP only). */
|
|
353
|
+
export declare function fPoolAdmitLeg(c: LogswapClient, a: {
|
|
354
|
+
poolId: Hex;
|
|
355
|
+
base: Address;
|
|
356
|
+
Lj: bigint;
|
|
357
|
+
x: bigint;
|
|
358
|
+
account: Address;
|
|
359
|
+
}): Promise<`0x${string}`>;
|
|
360
|
+
/**
|
|
361
|
+
* Move shares (ERC-6909 `transfer`) — to another holder, or to `0xdead` to lock them for good.
|
|
362
|
+
* Burning to the dead address is a sponsor's way to make its liquidity permanent: the shares can
|
|
363
|
+
* never be redeemed, and they never count against the sole-LP precondition.
|
|
364
|
+
*/
|
|
365
|
+
export declare function fPoolTransferShares(c: LogswapClient, a: {
|
|
366
|
+
poolId: Hex;
|
|
367
|
+
to: Address;
|
|
368
|
+
shares: bigint;
|
|
369
|
+
account: Address;
|
|
370
|
+
}): Promise<`0x${string}`>;
|
|
371
|
+
export interface DiscoveredFPool {
|
|
372
|
+
poolId: Hex;
|
|
373
|
+
quote: Address;
|
|
374
|
+
bases: Address[];
|
|
375
|
+
weights: bigint[];
|
|
376
|
+
phi: bigint;
|
|
377
|
+
feesOnly: boolean;
|
|
378
|
+
authority: Address;
|
|
379
|
+
/** The block the pool was initialized in — its age, for annualising realized income. */
|
|
380
|
+
block: bigint;
|
|
381
|
+
/** Whether `seed` has run; an unseeded pool has no floor and no float, so nothing to show. */
|
|
382
|
+
seeded: boolean;
|
|
383
|
+
/** The quote the pool was born with. Zero is the launchpad's signature (launchpad.md §3). */
|
|
384
|
+
q0: bigint;
|
|
385
|
+
/**
|
|
386
|
+
* The PRODUCT the pool is, by the spec's definition rather than a guess: a LAUNCH is one asset
|
|
387
|
+
* born at Q = 0 — a resting ask under a token, nothing raised, the creator alone on the lever;
|
|
388
|
+
* everything else is a liquidity BASKET (public, quote-funded). Read from the Seeded log, so a
|
|
389
|
+
* one-asset pool seeded WITH quote files correctly as liquidity, not as a pad.
|
|
390
|
+
*/
|
|
391
|
+
shape: FPoolShape;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Every F pool ever created, from `Initialize` logs alone. Possible only because the event
|
|
395
|
+
* carries the full key preimage (bases, weights, phi, feesOnly) — the poolId is a hash and could
|
|
396
|
+
* never be inverted; contracts PR #17 exists for exactly this call.
|
|
397
|
+
*/
|
|
398
|
+
export declare function discoverFPools(c: LogswapClient, opts?: {
|
|
399
|
+
fromBlock?: bigint;
|
|
400
|
+
toBlock?: bigint;
|
|
401
|
+
}): Promise<DiscoveredFPool[]>;
|
|
402
|
+
/**
|
|
403
|
+
* Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
|
|
404
|
+
* topic, so one filtered log query aggregates the whole ledger. The 0xdead entry is the
|
|
405
|
+
* MIN_SHARES lock from seeding; callers usually label rather than hide it.
|
|
406
|
+
*/
|
|
407
|
+
export declare function fPoolShareHolders(c: LogswapClient, poolIdHex: Hex, opts?: {
|
|
408
|
+
fromBlock?: bigint;
|
|
409
|
+
}): Promise<Array<{
|
|
410
|
+
holder: Address;
|
|
411
|
+
shares: bigint;
|
|
412
|
+
}>>;
|
|
413
|
+
/** Every F pool's state in one lens call (the raw manager struct: quote, phi, authority, feesOnly, seeded, dissolved, n, Q, L, shares, theta0, bigSigma, leverTheta). */
|
|
414
|
+
export declare function getFPoolsRaw(c: LogswapClient, poolIds: Hex[]): Promise<readonly unknown[]>;
|
|
415
|
+
/** Share value from the lens — (L + Q)/shares, WAD per share — the same figure as `fPoolShareValue`, from one source. */
|
|
416
|
+
export declare function shareValueOnChain(c: LogswapClient, poolId: Hex): Promise<bigint>;
|