@logswap/sdk 0.5.73 → 0.5.75
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 +40 -0
- package/dist/admin.d.ts +195 -0
- package/dist/admin.js +91 -0
- package/dist/client.d.ts +11 -2
- package/dist/client.js +12 -2
- package/dist/fees.d.ts +2 -1
- package/dist/fees.js +2 -1
- package/dist/fpool.d.ts +181 -2
- package/dist/fpool.js +5 -9
- package/dist/generated.d.ts +1113 -214
- package/dist/generated.js +736 -101
- package/dist/history.d.ts +82 -2
- package/dist/history.js +108 -16
- package/dist/indexer.js +1 -6
- package/dist/keys.d.ts +8 -6
- package/dist/keys.js +6 -5
- package/dist/liquidity.d.ts +8 -1
- package/dist/liquidity.js +5 -2
- package/dist/pools.d.ts +19 -10
- package/dist/pools.js +33 -25
- package/dist/positions.d.ts +23 -9
- package/dist/positions.js +39 -17
- package/package.json +1 -1
- package/src/admin.ts +123 -1
- package/src/client.ts +14 -2
- package/src/fees.ts +4 -3
- package/src/fpool.ts +16 -12
- package/src/generated.ts +736 -101
- package/src/history.ts +150 -17
- package/src/indexer.ts +1 -6
- package/src/keys.ts +8 -6
- package/src/liquidity.ts +10 -2
- package/src/pools.ts +45 -35
- package/src/positions.ts +43 -19
package/README.md
CHANGED
|
@@ -44,6 +44,46 @@ Both are computed **offline** — no RPC, no deployment needed to address a mark
|
|
|
44
44
|
floor price (was `theta`), `refLogFloor` θ₀ — the reference floor income counts from (was
|
|
45
45
|
`theta0`), `cap` (d in 1e-6 log units, 0 uncapped), and per leg `virtualReserves` and `kappa`.
|
|
46
46
|
|
|
47
|
+
## Who may create what: the gate, the menus (C version 7, F version 26)
|
|
48
|
+
|
|
49
|
+
Since logswap-contract #60 (decisions 064–065) creation is curated at launch, on both managers:
|
|
50
|
+
|
|
51
|
+
- **The C gate is the public policy**, set in the C manager's constructor. A C market is admitted if
|
|
52
|
+
its creator, quote, pair, swap-fee tier (2, 5, 10, 25, 50, 100 bp) and tick spacing (10 or 100 bp)
|
|
53
|
+
are listed, and only one market per (base, quote, fee) exists. `cGateRules(c, { key, creator })`
|
|
54
|
+
reads every check in one round; `gateErrorAbi` decodes the refusals (`CreatorNotListed`,
|
|
55
|
+
`MarketExists`, `SpacingNotListed`, `PairNotListed`, `MintFeeNotListed`, `NoForwardedUser`,
|
|
56
|
+
`PadExists`).
|
|
57
|
+
- **`createMarket` stays one transaction**: the router is a trusted forwarder, so the gate checks
|
|
58
|
+
the router's `user()` — the wallet that sent the call — against the creator list.
|
|
59
|
+
- **The mint fee is per pool**, the creator's pick from the policy's menu, proposed at
|
|
60
|
+
`initialize` / `createMarket` / `fPoolInitialize` / `fPoolLaunch` (`mintFee?`). It defaults to
|
|
61
|
+
`presetMintFee(swapFee)`: twice the swap fee, capped at `FEE_MAX` — guidance, not a contract rule.
|
|
62
|
+
`policyMintFeeMenu(c, policy, candidates)` lists what a policy accepts; `getPool(...).mintFee` /
|
|
63
|
+
`getFPool(...).mintFee` read a pool's. `mintFee(p, x, rate)` previews it at the market's rate.
|
|
64
|
+
- **A fee of 0 is no fee**: `swapFeeOf` and `DEFAULT_FEE` are gone; `marketSwapFee` returns the key's
|
|
65
|
+
own fee for an initialized market.
|
|
66
|
+
- **C reads**: `getPool` reads the lens's `getPools`; `getPositionClass` reads the class through
|
|
67
|
+
`extsload` at `CPoolState`'s slot (the manager's typed views are gone).
|
|
68
|
+
- **Creators are curated on every kind** at launch (onboarding under a service agreement); the
|
|
69
|
+
collector's helpers: `policySetCreatorListed`, `policySetMintFeeListed`, `gateSetPairListed`,
|
|
70
|
+
`gateSetSpacingListed`, `gateSetForwarderTrusted`, `setCGate`.
|
|
71
|
+
|
|
72
|
+
## History from the indexer (indexer phase 1)
|
|
73
|
+
|
|
74
|
+
Every event read goes through `getEventLogs` (one event) or `getEventsLogs` (several, tagged by
|
|
75
|
+
`eventName`): the rindexer GraphQL endpoint when one is given, the node otherwise or when it fails.
|
|
76
|
+
Since logswap-be #43 the indexer also holds the four policies (one `Policy` table per event, tracked
|
|
77
|
+
from the registry's `Approved`), the registry, the token factory and the managers' admin events, so
|
|
78
|
+
nothing has to scan the node from block 0 — which the devnet node, pruning logs after about a day,
|
|
79
|
+
answers only partly.
|
|
80
|
+
|
|
81
|
+
- `swapFees`, `holdingsOf`, `discoverMarkets` and `fPoolKeyOfPool` take `indexer` (the salt is not in
|
|
82
|
+
`FInitialize`, so a pad's key is still rebuilt from its split with nonce 0).
|
|
83
|
+
- `getEventLogs` takes several emitters (`address: [...]`); a policy outside the artifact names its
|
|
84
|
+
shared tables with `contract: indexedContractOf(kind, event)` (or `kind` on `getEventsLogs`).
|
|
85
|
+
- `tokensCreated` lists the factory's tokens (`addresses.tokenFactory`): the token list's provenance.
|
|
86
|
+
|
|
47
87
|
## Capped F pools and the lien (F version 25)
|
|
48
88
|
|
|
49
89
|
- **The cap** (decisions 061) is a key field: `FPoolKey.cap` / `FPoolCreateArgs.cap`, d =
|
package/dist/admin.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* is the policy's (`PadPolicy.setSchedule`), capped by the manager at `POT_CUT_MAX`.
|
|
10
10
|
*/
|
|
11
11
|
import type { Address, Hash } from "viem";
|
|
12
|
+
import type { PoolKey } from "./keys.js";
|
|
12
13
|
import type { LogswapClient } from "./client.js";
|
|
13
14
|
import { type FPoolKey, type FPoolKind } from "./fpool.js";
|
|
14
15
|
/**
|
|
@@ -140,6 +141,200 @@ export declare function policyFeeAllowed(c: LogswapClient, policy: Address, fee:
|
|
|
140
141
|
listed: boolean;
|
|
141
142
|
allowed: boolean;
|
|
142
143
|
}>;
|
|
144
|
+
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The collector's. */
|
|
145
|
+
export declare function policySetMintFeeListed(c: LogswapClient, policy: Address, mintFee: bigint, listed: boolean): Promise<Hash>;
|
|
146
|
+
/** `setMintFeeCurated` on any protocol policy: on, a birth proposing an unlisted mint fee is refused (`MintFeeNotListed`). */
|
|
147
|
+
export declare function policySetMintFeeCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash>;
|
|
148
|
+
/**
|
|
149
|
+
* A policy's mint-fee menu, for a create form (065): which of `candidates` it lists, and whether it
|
|
150
|
+
* curates at all (uncurated, any fee in the domain is accepted — the desk's policy never curates).
|
|
151
|
+
* The candidates are the app's — typically {@link presetMintFee} of each listed swap tier.
|
|
152
|
+
*/
|
|
153
|
+
export declare function policyMintFeeMenu(c: LogswapClient, policy: Address, candidates: readonly bigint[]): Promise<{
|
|
154
|
+
curated: boolean;
|
|
155
|
+
listed: bigint[];
|
|
156
|
+
}>;
|
|
157
|
+
/** `setCreatorListed` on any protocol policy (064): a creator onboarded under a service agreement. */
|
|
158
|
+
export declare function policySetCreatorListed(c: LogswapClient, policy: Address, who: Address, listed: boolean): Promise<Hash>;
|
|
159
|
+
/** `setCreatorCurated` on any protocol policy: on, only listed creators may create on that kind (C: the caller; F: `key.creator`). */
|
|
160
|
+
export declare function policySetCreatorCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash>;
|
|
161
|
+
/** `PublicPolicy.setPairListed` (064): a C pair a market may be born on while pairs are curated. Directional (base, quote). */
|
|
162
|
+
export declare function gateSetPairListed(c: LogswapClient, policy: Address, base: Address, quote: Address, listed: boolean): Promise<Hash>;
|
|
163
|
+
/** `PublicPolicy.setPairCurated` (064). */
|
|
164
|
+
export declare function gateSetPairCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash>;
|
|
165
|
+
/** `PublicPolicy.setSpacingListed` (064): a C tick spacing, WAD (10 bp = 1e15, 100 bp = 1e16). Always consulted. */
|
|
166
|
+
export declare function gateSetSpacingListed(c: LogswapClient, policy: Address, tickSpacing: bigint, listed: boolean): Promise<Hash>;
|
|
167
|
+
/** `PublicPolicy.setForwarderTrusted` (064): a router whose `user()` the gate takes as the creator. */
|
|
168
|
+
export declare function gateSetForwarderTrusted(c: LogswapClient, policy: Address, forwarder: Address, trusted: boolean): Promise<Hash>;
|
|
169
|
+
/** `CPoolManager.setGate` (064): name, change or lift (`address(0)`) the C gate. The C collector's. */
|
|
170
|
+
export declare function setCGate(c: LogswapClient, gate: Address): Promise<Hash>;
|
|
171
|
+
/** The C manager's gate (`address(0)`: permissionless, a fee-free market then refused). */
|
|
172
|
+
export declare function cGate(c: LogswapClient): Promise<Address>;
|
|
173
|
+
export interface CGateRules {
|
|
174
|
+
creatorOk: boolean;
|
|
175
|
+
quoteOk: boolean;
|
|
176
|
+
pairOk: boolean;
|
|
177
|
+
feeOk: boolean;
|
|
178
|
+
spacingOk: boolean;
|
|
179
|
+
/** A market on (base, quote, fee) already exists, whatever its spacing: the gate refuses another (064 (b)). */
|
|
180
|
+
exists: boolean;
|
|
181
|
+
/** Whether `router` is a trusted forwarder — `createMarket` through it is then checked against `creator`. */
|
|
182
|
+
routerTrusted: boolean;
|
|
183
|
+
/** Every check passes: the gate would admit this market from this creator (the mint fee aside — see {@link policyMintFeeMenu}). */
|
|
184
|
+
admitted: boolean;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The public policy's C checks for one candidate market and creator, in one round of reads — what
|
|
188
|
+
* the create form shows before a wallet is asked (064). `router` is the router the form will go
|
|
189
|
+
* through (`c.addresses.router` by default).
|
|
190
|
+
*/
|
|
191
|
+
export declare function cGateRules(c: LogswapClient, a: {
|
|
192
|
+
key: PoolKey;
|
|
193
|
+
creator: Address;
|
|
194
|
+
router?: Address;
|
|
195
|
+
gate?: Address;
|
|
196
|
+
}): Promise<CGateRules>;
|
|
197
|
+
/**
|
|
198
|
+
* Every refusal a birth can meet at the gate or a policy (064, 065), for `decodeErrorResult` on a
|
|
199
|
+
* failed simulation: the public policy's errors plus the pad's `PadExists` (one pad per base).
|
|
200
|
+
*/
|
|
201
|
+
export declare const gateErrorAbi: readonly ({
|
|
202
|
+
readonly type: "error";
|
|
203
|
+
readonly inputs: readonly [{
|
|
204
|
+
readonly name: "base";
|
|
205
|
+
readonly internalType: "address";
|
|
206
|
+
readonly type: "address";
|
|
207
|
+
}, {
|
|
208
|
+
readonly name: "pad";
|
|
209
|
+
readonly internalType: "bytes32";
|
|
210
|
+
readonly type: "bytes32";
|
|
211
|
+
}];
|
|
212
|
+
readonly name: "PadExists";
|
|
213
|
+
} | {
|
|
214
|
+
readonly type: "error";
|
|
215
|
+
readonly inputs: readonly [];
|
|
216
|
+
readonly name: "BadFee";
|
|
217
|
+
} | {
|
|
218
|
+
readonly type: "error";
|
|
219
|
+
readonly inputs: readonly [];
|
|
220
|
+
readonly name: "BadRate";
|
|
221
|
+
} | {
|
|
222
|
+
readonly type: "error";
|
|
223
|
+
readonly inputs: readonly [{
|
|
224
|
+
readonly name: "creator";
|
|
225
|
+
readonly internalType: "address";
|
|
226
|
+
readonly type: "address";
|
|
227
|
+
}];
|
|
228
|
+
readonly name: "CreatorNotListed";
|
|
229
|
+
} | {
|
|
230
|
+
readonly type: "error";
|
|
231
|
+
readonly inputs: readonly [{
|
|
232
|
+
readonly name: "fee";
|
|
233
|
+
readonly internalType: "uint256";
|
|
234
|
+
readonly type: "uint256";
|
|
235
|
+
}];
|
|
236
|
+
readonly name: "FeeNotListed";
|
|
237
|
+
} | {
|
|
238
|
+
readonly type: "error";
|
|
239
|
+
readonly inputs: readonly [{
|
|
240
|
+
readonly name: "base";
|
|
241
|
+
readonly internalType: "address";
|
|
242
|
+
readonly type: "address";
|
|
243
|
+
}, {
|
|
244
|
+
readonly name: "quote";
|
|
245
|
+
readonly internalType: "address";
|
|
246
|
+
readonly type: "address";
|
|
247
|
+
}, {
|
|
248
|
+
readonly name: "fee";
|
|
249
|
+
readonly internalType: "uint256";
|
|
250
|
+
readonly type: "uint256";
|
|
251
|
+
}];
|
|
252
|
+
readonly name: "MarketExists";
|
|
253
|
+
} | {
|
|
254
|
+
readonly type: "error";
|
|
255
|
+
readonly inputs: readonly [{
|
|
256
|
+
readonly name: "mintFee";
|
|
257
|
+
readonly internalType: "uint256";
|
|
258
|
+
readonly type: "uint256";
|
|
259
|
+
}];
|
|
260
|
+
readonly name: "MintFeeNotListed";
|
|
261
|
+
} | {
|
|
262
|
+
readonly type: "error";
|
|
263
|
+
readonly inputs: readonly [];
|
|
264
|
+
readonly name: "NoCreator";
|
|
265
|
+
} | {
|
|
266
|
+
readonly type: "error";
|
|
267
|
+
readonly inputs: readonly [{
|
|
268
|
+
readonly name: "forwarder";
|
|
269
|
+
readonly internalType: "address";
|
|
270
|
+
readonly type: "address";
|
|
271
|
+
}];
|
|
272
|
+
readonly name: "NoForwardedUser";
|
|
273
|
+
} | {
|
|
274
|
+
readonly type: "error";
|
|
275
|
+
readonly inputs: readonly [];
|
|
276
|
+
readonly name: "NotAuthority";
|
|
277
|
+
} | {
|
|
278
|
+
readonly type: "error";
|
|
279
|
+
readonly inputs: readonly [];
|
|
280
|
+
readonly name: "NotCanonical";
|
|
281
|
+
} | {
|
|
282
|
+
readonly type: "error";
|
|
283
|
+
readonly inputs: readonly [];
|
|
284
|
+
readonly name: "NotCollector";
|
|
285
|
+
} | {
|
|
286
|
+
readonly type: "error";
|
|
287
|
+
readonly inputs: readonly [{
|
|
288
|
+
readonly name: "token";
|
|
289
|
+
readonly internalType: "address";
|
|
290
|
+
readonly type: "address";
|
|
291
|
+
}];
|
|
292
|
+
readonly name: "NotListed";
|
|
293
|
+
} | {
|
|
294
|
+
readonly type: "error";
|
|
295
|
+
readonly inputs: readonly [];
|
|
296
|
+
readonly name: "NotManager";
|
|
297
|
+
} | {
|
|
298
|
+
readonly type: "error";
|
|
299
|
+
readonly inputs: readonly [];
|
|
300
|
+
readonly name: "NotRegistry";
|
|
301
|
+
} | {
|
|
302
|
+
readonly type: "error";
|
|
303
|
+
readonly inputs: readonly [];
|
|
304
|
+
readonly name: "OneBase";
|
|
305
|
+
} | {
|
|
306
|
+
readonly type: "error";
|
|
307
|
+
readonly inputs: readonly [{
|
|
308
|
+
readonly name: "base";
|
|
309
|
+
readonly internalType: "address";
|
|
310
|
+
readonly type: "address";
|
|
311
|
+
}, {
|
|
312
|
+
readonly name: "quote";
|
|
313
|
+
readonly internalType: "address";
|
|
314
|
+
readonly type: "address";
|
|
315
|
+
}];
|
|
316
|
+
readonly name: "PairNotListed";
|
|
317
|
+
} | {
|
|
318
|
+
readonly type: "error";
|
|
319
|
+
readonly inputs: readonly [{
|
|
320
|
+
readonly name: "quote";
|
|
321
|
+
readonly internalType: "address";
|
|
322
|
+
readonly type: "address";
|
|
323
|
+
}];
|
|
324
|
+
readonly name: "QuoteNotListed";
|
|
325
|
+
} | {
|
|
326
|
+
readonly type: "error";
|
|
327
|
+
readonly inputs: readonly [];
|
|
328
|
+
readonly name: "Refused";
|
|
329
|
+
} | {
|
|
330
|
+
readonly type: "error";
|
|
331
|
+
readonly inputs: readonly [{
|
|
332
|
+
readonly name: "tickSpacing";
|
|
333
|
+
readonly internalType: "int256";
|
|
334
|
+
readonly type: "int256";
|
|
335
|
+
}];
|
|
336
|
+
readonly name: "SpacingNotListed";
|
|
337
|
+
})[];
|
|
143
338
|
/** `PublicPolicy.setListed`: an asset a curated seed may hold. */
|
|
144
339
|
export declare function publicSetListed(c: LogswapClient, policy: Address, token: Address, listed: boolean): Promise<Hash>;
|
|
145
340
|
/** `PublicPolicy.setCurated`: whether every public seed is checked against the list. */
|
package/dist/admin.js
CHANGED
|
@@ -205,6 +205,97 @@ export async function policyFeeAllowed(c, policy, fee) {
|
|
|
205
205
|
]);
|
|
206
206
|
return { curated, listed, allowed: !curated || listed };
|
|
207
207
|
}
|
|
208
|
+
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The collector's. */
|
|
209
|
+
export async function policySetMintFeeListed(c, policy, mintFee, listed) {
|
|
210
|
+
return write(c, policy, fPolicyBaseAbi, "setMintFeeListed", [mintFee, listed]);
|
|
211
|
+
}
|
|
212
|
+
/** `setMintFeeCurated` on any protocol policy: on, a birth proposing an unlisted mint fee is refused (`MintFeeNotListed`). */
|
|
213
|
+
export async function policySetMintFeeCurated(c, policy, curated) {
|
|
214
|
+
return write(c, policy, fPolicyBaseAbi, "setMintFeeCurated", [curated]);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* A policy's mint-fee menu, for a create form (065): which of `candidates` it lists, and whether it
|
|
218
|
+
* curates at all (uncurated, any fee in the domain is accepted — the desk's policy never curates).
|
|
219
|
+
* The candidates are the app's — typically {@link presetMintFee} of each listed swap tier.
|
|
220
|
+
*/
|
|
221
|
+
export async function policyMintFeeMenu(c, policy, candidates) {
|
|
222
|
+
const rd = (functionName, args = []) => c.public.readContract({ address: policy, abi: fPolicyBaseAbi, functionName, args });
|
|
223
|
+
const [curated, ...flags] = await Promise.all([rd("mintFeeCurated"), ...candidates.map((m) => rd("mintFeeListed", [m]))]);
|
|
224
|
+
return { curated, listed: candidates.filter((_, i) => flags[i]) };
|
|
225
|
+
}
|
|
226
|
+
/** `setCreatorListed` on any protocol policy (064): a creator onboarded under a service agreement. */
|
|
227
|
+
export async function policySetCreatorListed(c, policy, who, listed) {
|
|
228
|
+
return write(c, policy, fPolicyBaseAbi, "setCreatorListed", [who, listed]);
|
|
229
|
+
}
|
|
230
|
+
/** `setCreatorCurated` on any protocol policy: on, only listed creators may create on that kind (C: the caller; F: `key.creator`). */
|
|
231
|
+
export async function policySetCreatorCurated(c, policy, curated) {
|
|
232
|
+
return write(c, policy, fPolicyBaseAbi, "setCreatorCurated", [curated]);
|
|
233
|
+
}
|
|
234
|
+
/** `PublicPolicy.setPairListed` (064): a C pair a market may be born on while pairs are curated. Directional (base, quote). */
|
|
235
|
+
export async function gateSetPairListed(c, policy, base, quote, listed) {
|
|
236
|
+
return write(c, policy, publicPolicyAbi, "setPairListed", [base, quote, listed]);
|
|
237
|
+
}
|
|
238
|
+
/** `PublicPolicy.setPairCurated` (064). */
|
|
239
|
+
export async function gateSetPairCurated(c, policy, curated) {
|
|
240
|
+
return write(c, policy, publicPolicyAbi, "setPairCurated", [curated]);
|
|
241
|
+
}
|
|
242
|
+
/** `PublicPolicy.setSpacingListed` (064): a C tick spacing, WAD (10 bp = 1e15, 100 bp = 1e16). Always consulted. */
|
|
243
|
+
export async function gateSetSpacingListed(c, policy, tickSpacing, listed) {
|
|
244
|
+
return write(c, policy, publicPolicyAbi, "setSpacingListed", [tickSpacing, listed]);
|
|
245
|
+
}
|
|
246
|
+
/** `PublicPolicy.setForwarderTrusted` (064): a router whose `user()` the gate takes as the creator. */
|
|
247
|
+
export async function gateSetForwarderTrusted(c, policy, forwarder, trusted) {
|
|
248
|
+
return write(c, policy, publicPolicyAbi, "setForwarderTrusted", [forwarder, trusted]);
|
|
249
|
+
}
|
|
250
|
+
/** `CPoolManager.setGate` (064): name, change or lift (`address(0)`) the C gate. The C collector's. */
|
|
251
|
+
export async function setCGate(c, gate) {
|
|
252
|
+
return write(c, c.addresses.cPoolManager, cPoolManagerAbi, "setGate", [gate]);
|
|
253
|
+
}
|
|
254
|
+
/** The C manager's gate (`address(0)`: permissionless, a fee-free market then refused). */
|
|
255
|
+
export async function cGate(c) {
|
|
256
|
+
return c.public.readContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "gate" });
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The public policy's C checks for one candidate market and creator, in one round of reads — what
|
|
260
|
+
* the create form shows before a wallet is asked (064). `router` is the router the form will go
|
|
261
|
+
* through (`c.addresses.router` by default).
|
|
262
|
+
*/
|
|
263
|
+
export async function cGateRules(c, a) {
|
|
264
|
+
const g = a.gate ?? c.addresses.publicPolicy;
|
|
265
|
+
const rd = (functionName, args = []) => c.public.readContract({ address: g, abi: publicPolicyAbi, functionName, args });
|
|
266
|
+
const { key } = a;
|
|
267
|
+
const [creatorCurated, creatorListed, quoteCurated, quoteListed, pairCurated, pairListed, feeCurated, feeListed, spacingListed, market, routerTrusted] = await Promise.all([
|
|
268
|
+
rd("creatorCurated"),
|
|
269
|
+
rd("creatorListed", [a.creator]),
|
|
270
|
+
rd("quoteCurated"),
|
|
271
|
+
rd("quoteListed", [key.quote]),
|
|
272
|
+
rd("pairCurated"),
|
|
273
|
+
rd("pairListed", [key.base, key.quote]),
|
|
274
|
+
rd("feeCurated"),
|
|
275
|
+
rd("feeListed", [key.swapFee]),
|
|
276
|
+
rd("spacingListed", [key.tickSpacing]),
|
|
277
|
+
rd("cMarketOf", [key.base, key.quote, key.swapFee]),
|
|
278
|
+
rd("forwarderTrusted", [a.router ?? c.addresses.router]),
|
|
279
|
+
]);
|
|
280
|
+
const r = {
|
|
281
|
+
creatorOk: !creatorCurated || creatorListed,
|
|
282
|
+
quoteOk: !quoteCurated || quoteListed,
|
|
283
|
+
pairOk: !pairCurated || pairListed,
|
|
284
|
+
feeOk: !feeCurated || feeListed,
|
|
285
|
+
spacingOk: spacingListed,
|
|
286
|
+
exists: BigInt(market) !== 0n,
|
|
287
|
+
routerTrusted,
|
|
288
|
+
};
|
|
289
|
+
return { ...r, admitted: r.creatorOk && r.quoteOk && r.pairOk && r.feeOk && r.spacingOk && !r.exists };
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Every refusal a birth can meet at the gate or a policy (064, 065), for `decodeErrorResult` on a
|
|
293
|
+
* failed simulation: the public policy's errors plus the pad's `PadExists` (one pad per base).
|
|
294
|
+
*/
|
|
295
|
+
export const gateErrorAbi = [
|
|
296
|
+
...publicPolicyAbi.filter((x) => x.type === "error"),
|
|
297
|
+
...padPolicyAbi.filter((x) => x.type === "error" && x.name === "PadExists"),
|
|
298
|
+
];
|
|
208
299
|
/** `PublicPolicy.setListed`: an asset a curated seed may hold. */
|
|
209
300
|
export async function publicSetListed(c, policy, token, listed) {
|
|
210
301
|
return write(c, policy, publicPolicyAbi, "setListed", [token, listed]);
|
package/dist/client.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface LogswapAddresses {
|
|
|
35
35
|
* absent; a deployment with none asks nobody.
|
|
36
36
|
*/
|
|
37
37
|
policyRegistry?: Address;
|
|
38
|
+
/** The devnet's token factory (`TokenFactory`, a mock): where launchable tokens come from. Optional. */
|
|
39
|
+
tokenFactory?: Address;
|
|
38
40
|
/** Optional — the router falls back to plain approvals when absent. */
|
|
39
41
|
permit2?: Address;
|
|
40
42
|
}
|
|
@@ -75,8 +77,15 @@ export declare function createLogswapClient(args: {
|
|
|
75
77
|
* (`MINT_FEE_PROTOCOL_CUT` and `setFeeParams` are gone, decisions 058); the swap-fee tax at payout,
|
|
76
78
|
* `swapFeeTax` / `setSwapFeeTax` (060); `phi` is `swapFee` and `phiOf` `swapFeeOf` (059) — field
|
|
77
79
|
* names only, no pool id moved.
|
|
80
|
+
*
|
|
81
|
+
* **7** since 2026-10-12 (logswap-contract#60, decisions 064–065): the typed views (`getPool`,
|
|
82
|
+
* `ticks`, `tickBitmapWord`, `positions`, `feeAcct`, `idInfo`) are behind `extsload` — the pool
|
|
83
|
+
* reads through the lens's `getPools`, a class through `CPoolState`'s layout; a fee of 0 is no
|
|
84
|
+
* fee (`swapFeeOf` and `DEFAULT_FEE` are gone); the mint fee is the market's, proposed at
|
|
85
|
+
* `initialize` / `createMarket` and answered by the gate; the gate (`gate`, `setGate`) is the
|
|
86
|
+
* public policy, set at construction. No pool id moved.
|
|
78
87
|
*/
|
|
79
|
-
export declare const EXPECTED_VERSION =
|
|
88
|
+
export declare const EXPECTED_VERSION = 7n;
|
|
80
89
|
/**
|
|
81
90
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
82
91
|
* 4 was the income-only harvest cut).
|
|
@@ -88,7 +97,7 @@ export declare const EXPECTED_VERSION = 6n;
|
|
|
88
97
|
* passes it; when one lands, raise this constant in the same change, which is the discipline
|
|
89
98
|
* `EXPECTED_VERSION` enforces mechanically and this one asks for.
|
|
90
99
|
*/
|
|
91
|
-
export declare const EXPECTED_F_VERSION =
|
|
100
|
+
export declare const EXPECTED_F_VERSION = 26n;
|
|
92
101
|
export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
|
|
93
102
|
/**
|
|
94
103
|
* The versions say the managers are the right code; this says the rest of the addresses belong
|
package/dist/client.js
CHANGED
|
@@ -69,8 +69,15 @@ function guardChain(wallet, pub) {
|
|
|
69
69
|
* (`MINT_FEE_PROTOCOL_CUT` and `setFeeParams` are gone, decisions 058); the swap-fee tax at payout,
|
|
70
70
|
* `swapFeeTax` / `setSwapFeeTax` (060); `phi` is `swapFee` and `phiOf` `swapFeeOf` (059) — field
|
|
71
71
|
* names only, no pool id moved.
|
|
72
|
+
*
|
|
73
|
+
* **7** since 2026-10-12 (logswap-contract#60, decisions 064–065): the typed views (`getPool`,
|
|
74
|
+
* `ticks`, `tickBitmapWord`, `positions`, `feeAcct`, `idInfo`) are behind `extsload` — the pool
|
|
75
|
+
* reads through the lens's `getPools`, a class through `CPoolState`'s layout; a fee of 0 is no
|
|
76
|
+
* fee (`swapFeeOf` and `DEFAULT_FEE` are gone); the mint fee is the market's, proposed at
|
|
77
|
+
* `initialize` / `createMarket` and answered by the gate; the gate (`gate`, `setGate`) is the
|
|
78
|
+
* public policy, set at construction. No pool id moved.
|
|
72
79
|
*/
|
|
73
|
-
export const EXPECTED_VERSION =
|
|
80
|
+
export const EXPECTED_VERSION = 7n;
|
|
74
81
|
/**
|
|
75
82
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
76
83
|
* 4 was the income-only harvest cut).
|
|
@@ -147,8 +154,11 @@ export const EXPECTED_VERSION = 6n;
|
|
|
147
154
|
// 25 (logswap-contract#59): the views moved behind `extsload` (062) — this SDK reads them through the
|
|
148
155
|
// lens (`fPool`, `getFPools`, `fBundleOf`, `fDividendOf`, `fLienOf`); the capped F pool, `FPoolKey.cap`
|
|
149
156
|
// appended so every pool id moved (061); the lien, `lock` / `unlock` (063); θ is `logFloor`, θ₀ `refLogFloor`.
|
|
157
|
+
// 26 (logswap-contract#60): the mint fee is per pool, proposed at `initialize(key, mintFee)` and answered
|
|
158
|
+
// by the policy's `onInitialize` from its menu (065); `MINT_FEE` is gone; a fee of 0 is no fee; the
|
|
159
|
+
// policies curate creators, a public pool is uncapped, one pad per base (064). No pool id moved.
|
|
150
160
|
// A breaking bump: raised in the same change.
|
|
151
|
-
export const EXPECTED_F_VERSION =
|
|
161
|
+
export const EXPECTED_F_VERSION = 26n;
|
|
152
162
|
export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
153
163
|
const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
|
|
154
164
|
// three independent reads: one round trip, not three in a row
|
package/dist/fees.d.ts
CHANGED
|
@@ -55,7 +55,8 @@ export declare function blockAtOrAfter(c: LogswapClient, t: bigint, lo: bigint,
|
|
|
55
55
|
export declare function swapFees(c: LogswapClient, m: DiscoveredMarket, opts?: {
|
|
56
56
|
since?: bigint;
|
|
57
57
|
fromBlock?: bigint;
|
|
58
|
-
toBlock?: bigint;
|
|
58
|
+
toBlock?: bigint; /** The rindexer GraphQL endpoint: the Swap rows from there, the node otherwise. */
|
|
59
|
+
indexer?: string;
|
|
59
60
|
}): Promise<SwapFeeWindow>;
|
|
60
61
|
/**
|
|
61
62
|
* The window's swap fees over the market's CURRENT active L, annualised linearly over the window.
|
package/dist/fees.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Both equal φ·L·|Δx| summed over the swap's segments — the same φ·|dx| per unit L that `F` books.
|
|
12
12
|
*/
|
|
13
13
|
import { cPoolManagerAbi } from "./generated.js";
|
|
14
|
+
import { getEventLogs } from "./history.js";
|
|
14
15
|
const WAD = 10n ** 18n;
|
|
15
16
|
const YEAR_SECONDS = 31_536_000;
|
|
16
17
|
/**
|
|
@@ -89,7 +90,7 @@ export async function swapFees(c, m, opts = {}) {
|
|
|
89
90
|
throw new Error("logswap: Swap event missing from the generated ABI");
|
|
90
91
|
const logs = fromBlock > toBlock
|
|
91
92
|
? []
|
|
92
|
-
: await c
|
|
93
|
+
: (await getEventLogs(c, { indexer: opts.indexer, address: c.addresses.cPoolManager, event: ev, args: { poolId: m.poolId }, fromBlock, toBlock })).logs;
|
|
93
94
|
// the event carries the fee the swap charged (decisions 050), exactly — no re-derivation from φ
|
|
94
95
|
let fees = 0n;
|
|
95
96
|
for (const l of logs)
|