@logswap/sdk 0.5.76 → 0.5.78
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 +62 -4
- package/dist/admin.d.ts +117 -40
- package/dist/admin.js +152 -60
- package/dist/chains.d.ts +155 -0
- package/dist/chains.js +186 -0
- package/dist/client.d.ts +39 -5
- package/dist/client.js +53 -5
- package/dist/fees.js +3 -2
- package/dist/fpool.d.ts +74 -48
- package/dist/fpool.js +84 -54
- package/dist/generated.d.ts +692 -553
- package/dist/generated.js +613 -458
- package/dist/history.d.ts +10 -1
- package/dist/history.js +36 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/indexer.d.ts +5 -5
- package/dist/indexer.js +7 -7
- package/dist/pools.d.ts +10 -8
- package/dist/pools.js +9 -8
- package/dist/positions.d.ts +5 -5
- package/dist/positions.js +10 -9
- package/dist/tokencache.d.ts +2 -10
- package/dist/tokencache.js +14 -6
- package/dist/views.d.ts +1 -1
- package/dist/write.d.ts +2 -1
- package/dist/write.js +4 -3
- package/package.json +1 -1
- package/src/admin.ts +183 -74
- package/src/chains.ts +259 -0
- package/src/client.ts +77 -8
- package/src/fees.ts +3 -2
- package/src/fpool.ts +127 -84
- package/src/generated.ts +613 -458
- package/src/history.ts +41 -13
- package/src/index.ts +1 -0
- package/src/indexer.ts +7 -7
- package/src/pools.ts +16 -14
- package/src/positions.ts +12 -11
- package/src/tokencache.ts +15 -6
- package/src/views.ts +1 -1
- package/src/write.ts +4 -3
package/src/admin.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* admin — the protocol's writes: the C swap-fee tax (decisions 060), the policies a pool may be
|
|
3
3
|
* born with (the registry's), the policies' own numbers (the quote list, the fee tiers, a pad's
|
|
4
|
-
* schedule, a POL's rules), and the two-step
|
|
4
|
+
* schedule, a POL's rules), and the two roles' two-step handovers (decision 066): the LOG Authority
|
|
5
|
+
* (the registry's `authority`) administers everything here; the LOG Treasury (`treasury` on each
|
|
6
|
+
* manager) only receives, and is replaced by the authority's `proposeTreasury`. Plain writes to the managers, the
|
|
5
7
|
* registry and the policies; no router.
|
|
6
8
|
*
|
|
7
9
|
* The mint fee has no cut to set since C version 6 / F version 24 (decisions 058): the whole fee
|
|
@@ -12,6 +14,7 @@
|
|
|
12
14
|
import type { Address, Hash, Hex } from "viem";
|
|
13
15
|
import type { PoolKey } from "./keys.js";
|
|
14
16
|
import type { LogswapClient } from "./client.js";
|
|
17
|
+
import { getPool } from "./pools.js";
|
|
15
18
|
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, publicPolicyAbi } from "./generated.js";
|
|
16
19
|
import { bytes32ToText, fPolicyBaseAbi, fPoolKeyOfPool, fPoolKindOfPolicy, textToBytes32, type FPoolKey, type FPoolKind } from "./fpool.js";
|
|
17
20
|
|
|
@@ -25,26 +28,33 @@ function write(c: LogswapClient, address: Address, abi: readonly unknown[], func
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
|
-
* The C
|
|
29
|
-
*
|
|
31
|
+
* The C swap-fee tax (decisions 060, 066): the protocol's share of every swap fee a C position is
|
|
32
|
+
* paid (claims and the burn's auto-claim), WAD. `tax` is the level the gate (`PublicPolicy`) gives a
|
|
33
|
+
* market born NOW; each market keeps the level of its birth for life — read it with
|
|
34
|
+
* {@link cMarketSwapFeeTax} or `getPool(key).swapFeeTax`. `max` is the manager's bound.
|
|
30
35
|
*/
|
|
31
36
|
export async function cSwapFeeTax(c: LogswapClient): Promise<{ tax: bigint; max: bigint }> {
|
|
32
37
|
const [tax, max] = await Promise.all([
|
|
33
|
-
c.public.readContract({ address: c.addresses.
|
|
38
|
+
c.public.readContract({ address: c.addresses.publicPolicy as Address, abi: publicPolicyAbi, functionName: "swapFeeTax" } as never) as Promise<bigint>,
|
|
34
39
|
c.public.readContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "SWAP_FEE_TAX_MAX" }),
|
|
35
40
|
]);
|
|
36
41
|
return { tax, max };
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
/** One C market's swap-fee tax, recorded at its birth (066). */
|
|
45
|
+
export async function cMarketSwapFeeTax(c: LogswapClient, key: PoolKey): Promise<bigint> {
|
|
46
|
+
return (await getPool(c, key)).swapFeeTax;
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
/**
|
|
40
|
-
* `
|
|
41
|
-
*
|
|
50
|
+
* `PublicPolicy.setSwapFeeTax`: the level a C market born after it is given (066), at most
|
|
51
|
+
* `SWAP_FEE_TAX_MAX` (25%). The LOG Authority's. A live market keeps the level of its birth.
|
|
42
52
|
*/
|
|
43
53
|
export async function setCSwapFeeTax(c: LogswapClient, taxWad: bigint): Promise<Hash> {
|
|
44
|
-
return write(c, c.addresses.
|
|
54
|
+
return write(c, c.addresses.publicPolicy as Address, publicPolicyAbi, "setSwapFeeTax", [taxWad]);
|
|
45
55
|
}
|
|
46
56
|
|
|
47
|
-
// ─── the registry: the LOG
|
|
57
|
+
// ─── the registry: the LOG Authority's (046, 066) ───────────────────────────
|
|
48
58
|
|
|
49
59
|
const ZERO = "0x0000000000000000000000000000000000000000" as const;
|
|
50
60
|
|
|
@@ -71,7 +81,7 @@ export interface RegistryEntry {
|
|
|
71
81
|
/** The policy's own `kind()` tag — what a pool born under it is. */
|
|
72
82
|
kind: FPoolKind;
|
|
73
83
|
name: string;
|
|
74
|
-
/** The
|
|
84
|
+
/** The time (unix seconds) it closes to new pools from; 0 = open. A block number before F version 29. */
|
|
75
85
|
until: bigint;
|
|
76
86
|
/** Approved now: listed and not yet sunset. */
|
|
77
87
|
approved: boolean;
|
|
@@ -86,28 +96,39 @@ export async function registryPolicies(c: LogswapClient, kind?: FPoolKind): Prom
|
|
|
86
96
|
const registry = await policyRegistryOf(c);
|
|
87
97
|
if (registry === ZERO) return [];
|
|
88
98
|
const list = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "policies" } as never)) as readonly Address[];
|
|
89
|
-
|
|
99
|
+
// the registry compares `until` with block.timestamp (F version 29)
|
|
100
|
+
const now = (await c.public.getBlock({ blockTag: "latest" })).timestamp;
|
|
90
101
|
const all = await Promise.all(
|
|
91
102
|
list.map(async (policy) => {
|
|
92
103
|
const [[listed, until, , name], tag] = await Promise.all([
|
|
93
104
|
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "entries", args: [policy] } as never) as Promise<[boolean, bigint, number, `0x${string}`]>,
|
|
94
105
|
fPoolKindOfPolicy(c, policy),
|
|
95
106
|
]);
|
|
96
|
-
return { policy, kind: tag, name: bytes32ToText(name), until, approved: listed && (until === 0n ||
|
|
107
|
+
return { policy, kind: tag, name: bytes32ToText(name), until, approved: listed && (until === 0n || now < until) };
|
|
97
108
|
}),
|
|
98
109
|
);
|
|
99
110
|
return kind ? all.filter((e) => e.kind === kind) : all;
|
|
100
111
|
}
|
|
101
112
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The LOG Authority (decision 066) — the registry's `logAuthority`, which administers the registry, both
|
|
115
|
+
* managers and every protocol policy — and the proposed next one. Zero with no registry: nothing on
|
|
116
|
+
* the deployment can be administered.
|
|
117
|
+
*/
|
|
118
|
+
export async function logAuthority(c: LogswapClient): Promise<{ authority: Address; pending: Address }> {
|
|
104
119
|
const registry = await policyRegistryOf(c);
|
|
105
|
-
if (registry === ZERO) return {
|
|
106
|
-
const [
|
|
107
|
-
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "
|
|
108
|
-
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "
|
|
120
|
+
if (registry === ZERO) return { authority: ZERO, pending: ZERO };
|
|
121
|
+
const [authority, pending] = await Promise.all([
|
|
122
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "logAuthority" } as never) as Promise<Address>,
|
|
123
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "pendingLogAuthority" } as never) as Promise<Address>,
|
|
109
124
|
]);
|
|
110
|
-
return {
|
|
125
|
+
return { authority, pending };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @deprecated F version 27 renamed the registry's `owner` to `authority`: use {@link logAuthority}. */
|
|
129
|
+
export async function registryOwner(c: LogswapClient): Promise<{ owner: Address; pending: Address }> {
|
|
130
|
+
const { authority, pending } = await logAuthority(c);
|
|
131
|
+
return { owner: authority, pending };
|
|
111
132
|
}
|
|
112
133
|
|
|
113
134
|
async function registryWrite(c: LogswapClient, functionName: string, args: readonly unknown[]): Promise<Hash> {
|
|
@@ -116,28 +137,36 @@ async function registryWrite(c: LogswapClient, functionName: string, args: reado
|
|
|
116
137
|
return write(c, registry, policyRegistryAbi, functionName, args);
|
|
117
138
|
}
|
|
118
139
|
|
|
119
|
-
/** `PolicyRegistry.approve`: list `policy` under `name` (at most 31 bytes). Again renames it and clears its sunset. The
|
|
140
|
+
/** `PolicyRegistry.approve`: list `policy` under `name` (at most 31 bytes). Again renames it and clears its sunset. The LOG Authority's. */
|
|
120
141
|
export async function registryApprove(c: LogswapClient, policy: Address, name: string): Promise<Hash> {
|
|
121
142
|
return registryWrite(c, "approve", [policy, textToBytes32(name)]);
|
|
122
143
|
}
|
|
123
144
|
|
|
124
|
-
/** `PolicyRegistry.sunset`: close `policy` to new pools from `
|
|
125
|
-
export async function registrySunset(c: LogswapClient, policy: Address,
|
|
126
|
-
return registryWrite(c, "sunset", [policy,
|
|
145
|
+
/** `PolicyRegistry.sunset`: close `policy` to new pools from `untilTime` (unix seconds, F version 29) on; 0 reopens. The LOG Authority's. */
|
|
146
|
+
export async function registrySunset(c: LogswapClient, policy: Address, untilTime: bigint): Promise<Hash> {
|
|
147
|
+
return registryWrite(c, "sunset", [policy, untilTime]);
|
|
127
148
|
}
|
|
128
149
|
|
|
129
|
-
/** `PolicyRegistry.revoke`: remove `policy` from the list at once. Live pools are untouched. The
|
|
150
|
+
/** `PolicyRegistry.revoke`: remove `policy` from the list at once. Live pools are untouched. The LOG Authority's. */
|
|
130
151
|
export async function registryRevoke(c: LogswapClient, policy: Address): Promise<Hash> {
|
|
131
152
|
return registryWrite(c, "revoke", [policy]);
|
|
132
153
|
}
|
|
133
154
|
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
/**
|
|
156
|
+
* The LOG Authority's two-step handover (066): the authority proposes, the proposed address accepts
|
|
157
|
+
* by its own call (a Safe or a timelock sends `acceptLogAuthority` itself). One handover moves the
|
|
158
|
+
* administration of the registry, both managers and every policy; the treasury is a separate role.
|
|
159
|
+
*/
|
|
160
|
+
export async function proposeLogAuthority(c: LogswapClient, next: Address): Promise<Hash> {
|
|
161
|
+
return registryWrite(c, "proposeLogAuthority", [next]);
|
|
137
162
|
}
|
|
138
|
-
export async function
|
|
139
|
-
return registryWrite(c, "
|
|
163
|
+
export async function acceptLogAuthority(c: LogswapClient): Promise<Hash> {
|
|
164
|
+
return registryWrite(c, "acceptLogAuthority", []);
|
|
140
165
|
}
|
|
166
|
+
/** @deprecated use {@link proposeLogAuthority}. */
|
|
167
|
+
export const registryProposeOwner = proposeLogAuthority;
|
|
168
|
+
/** @deprecated use {@link acceptLogAuthority}. */
|
|
169
|
+
export const registryAcceptOwner = acceptLogAuthority;
|
|
141
170
|
|
|
142
171
|
/**
|
|
143
172
|
* Approve or revoke, the F version 15–16 shape kept for callers: `approved` true is
|
|
@@ -148,7 +177,9 @@ export async function setPolicyApproved(c: LogswapClient, policy: Address, appro
|
|
|
148
177
|
}
|
|
149
178
|
|
|
150
179
|
/**
|
|
151
|
-
* Move a pool to another approved policy of the same kind: the
|
|
180
|
+
* Move a pool to another approved policy of the same kind: the LOG Authority's alone, a forced move
|
|
181
|
+
* (adoption at regeneration by the pool authority's consent is specified, not built — logswap-docs
|
|
182
|
+
* `specs/governance/policy-adoption.md`),
|
|
152
183
|
* orchestrated on the registry — `migrate(manager, key, to)` since F version 20 (it took the
|
|
153
184
|
* pool's id before). The registry checks the key against the manager (`NoPool`), checks the
|
|
154
185
|
* manager is its own (`WrongManager`), and compares the two policies' tags recorded at approval
|
|
@@ -157,7 +188,7 @@ export async function setPolicyApproved(c: LogswapClient, policy: Address, appro
|
|
|
157
188
|
* answer); the operator and the lists void; no swap lands in the block.
|
|
158
189
|
*
|
|
159
190
|
* Pass the pool's `key` when in hand. Given only `poolId`, the key is rebuilt from the pool's
|
|
160
|
-
* `
|
|
191
|
+
* `PoolCreated` log ({@link fPoolKeyOfPool}) with `salt` (zero by default) and checked against
|
|
161
192
|
* the id — the log does not carry the salt, so a salted pool needs it named.
|
|
162
193
|
*/
|
|
163
194
|
export async function fPoolMigrate(
|
|
@@ -180,36 +211,77 @@ export async function registryKindOf(c: LogswapClient, policy: Address): Promise
|
|
|
180
211
|
return bytes32ToText(word) as FPoolKind | "";
|
|
181
212
|
}
|
|
182
213
|
|
|
183
|
-
// ─── the policies' numbers (the
|
|
214
|
+
// ─── the policies' numbers (the LOG Authority's; each bounded where it reaches the manager) ─────
|
|
184
215
|
|
|
185
216
|
/**
|
|
186
|
-
* `PadPolicy.setSchedule` (decisions 056,
|
|
187
|
-
* recorded into each pad at birth), and the
|
|
188
|
-
*
|
|
189
|
-
*
|
|
217
|
+
* `PadPolicy.setSchedule` (decisions 056, 067, 070): the rung's growth, the protocol's share of the pot (≤ `POT_CUT_MAX`,
|
|
218
|
+
* recorded into each pad at birth), and the RANGE a creator chooses his cut of the pot inside at creation (its top ≤ the F
|
|
219
|
+
* manager's `PAYEE_CUT_MAX`). The creator's top plus the protocol's share is at most the pot; the rest deepens the bid — nothing
|
|
220
|
+
* is bought or burnt since F version 28. A change to the split applies to pads born after it; the growth moves every pad at its
|
|
221
|
+
* next rung. The rung is the pool's generation. `T(0)` is per quote since decision 070: {@link padSetThresholdBase}.
|
|
190
222
|
*/
|
|
191
|
-
export async function padSetSchedule(
|
|
192
|
-
|
|
193
|
-
policy
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
223
|
+
export async function padSetSchedule(c: LogswapClient, policy: Address, s: PadSchedule): Promise<Hash> {
|
|
224
|
+
if ("thresholdBase" in s) throw new Error("logswap: T(0) is per quote since decision 070 — padSetThresholdBase(c, policy, quote, base)");
|
|
225
|
+
return write(c, policy, padPolicyAbi, "setSchedule", [s.thresholdGrowth, s.protocolShare, s.creatorShareMin, s.creatorShareMax]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* `PadPolicy.setThresholdBase(quote, base)` (decision 070): `T(0)` for pads quoted in `quote`, in that quote's units. A pad is
|
|
230
|
+
* born (or moved in) only on a quote that has one (`NoThreshold`). It moves every pad in that quote at its next rung. The LOG
|
|
231
|
+
* Authority's.
|
|
232
|
+
*/
|
|
233
|
+
export async function padSetThresholdBase(c: LogswapClient, policy: Address, quote: Address, base: bigint): Promise<Hash> {
|
|
234
|
+
return write(c, policy, padPolicyAbi, "setThresholdBase", [quote, base]);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** A pad policy's `T(0)` in one quote (decision 070): `set` false means no pad can be born on that quote. */
|
|
238
|
+
export interface PadThresholdBase {
|
|
239
|
+
quote: Address;
|
|
240
|
+
set: boolean;
|
|
241
|
+
/** In the quote's units; 0 when not set. */
|
|
242
|
+
base: bigint;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** `PadPolicy.thresholdSet(quote)` and `thresholdBaseOf(quote)` for each quote asked (decision 070). */
|
|
246
|
+
export async function padThresholdBases(c: LogswapClient, policy: Address, quotes: readonly Address[]): Promise<PadThresholdBase[]> {
|
|
247
|
+
const rd = <T>(functionName: string, quote: Address) =>
|
|
248
|
+
c.public.readContract({ address: policy, abi: padPolicyAbi, functionName, args: [quote] } as never) as Promise<T>;
|
|
249
|
+
return Promise.all(
|
|
250
|
+
quotes.map(async (quote) => {
|
|
251
|
+
const [set, base] = await Promise.all([rd<boolean>("thresholdSet", quote), rd<bigint>("thresholdBaseOf", quote)]);
|
|
252
|
+
return { quote, set, base };
|
|
253
|
+
}),
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** `PadPolicy.thresholdOf(quote, rung)` (decision 070): the pot a pad quoted in `quote` must bank to climb `rung` (0 reads `T(0)`). */
|
|
258
|
+
export async function padThresholdOf(c: LogswapClient, policy: Address, quote: Address, rung: bigint | number = 0n): Promise<bigint> {
|
|
259
|
+
return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "thresholdOf", args: [quote, BigInt(rung)] } as never)) as bigint;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** `PadPolicy.threshold(poolId, rung)` (decision 070): the pot pad `poolId` must bank to climb `rung`, in its own quote. */
|
|
263
|
+
export async function padThreshold(c: LogswapClient, policy: Address, poolId: Hex, rung: bigint | number): Promise<bigint> {
|
|
264
|
+
return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "threshold", args: [poolId, BigInt(rung)] } as never)) as bigint;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** A pad policy's schedule (decision 070: without `T(0)`, which is per quote — {@link padThresholdBases}). WAD numbers. */
|
|
268
|
+
export interface PadSchedule {
|
|
269
|
+
thresholdGrowth: bigint;
|
|
270
|
+
protocolShare: bigint;
|
|
271
|
+
creatorShareMin: bigint;
|
|
272
|
+
creatorShareMax: bigint;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** Read {@link PadSchedule} off a pad policy. */
|
|
276
|
+
export async function padScheduleOf(c: LogswapClient, policy: Address): Promise<PadSchedule> {
|
|
277
|
+
const rd = (functionName: string) => c.public.readContract({ address: policy, abi: padPolicyAbi, functionName } as never) as Promise<bigint>;
|
|
278
|
+
const [thresholdGrowth, protocolShare, creatorShareMin, creatorShareMax] = await Promise.all([
|
|
279
|
+
rd("thresholdGrowth"),
|
|
280
|
+
rd("protocolShare"),
|
|
281
|
+
rd("creatorShareMin"),
|
|
282
|
+
rd("creatorShareMax"),
|
|
212
283
|
]);
|
|
284
|
+
return { thresholdGrowth, protocolShare, creatorShareMin, creatorShareMax };
|
|
213
285
|
}
|
|
214
286
|
|
|
215
287
|
/** `PolPolicy.setRules`: the reserve a harvest must leave in the bid (`may(Harvest)` refuses less) and what a relaunch's seed must bring, WAD fractions of the pool's L. */
|
|
@@ -217,12 +289,12 @@ export async function polSetRules(c: LogswapClient, policy: Address, s: { keepQu
|
|
|
217
289
|
return write(c, policy, polPolicyAbi, "setRules", [s.keepQuote, s.minQuoteAtSeed]);
|
|
218
290
|
}
|
|
219
291
|
|
|
220
|
-
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The
|
|
292
|
+
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The LOG Authority's. */
|
|
221
293
|
export async function policySetQuoteListed(c: LogswapClient, policy: Address, quote: Address, listed: boolean): Promise<Hash> {
|
|
222
294
|
return write(c, policy, fPolicyBaseAbi, "setQuoteListed", [quote, listed]);
|
|
223
295
|
}
|
|
224
296
|
|
|
225
|
-
/** `setQuoteCurated` on any protocol policy: on, a birth against an unlisted quote is refused. The
|
|
297
|
+
/** `setQuoteCurated` on any protocol policy: on, a birth against an unlisted quote is refused. The LOG Authority's. */
|
|
226
298
|
export async function policySetQuoteCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash> {
|
|
227
299
|
return write(c, policy, fPolicyBaseAbi, "setQuoteCurated", [curated]);
|
|
228
300
|
}
|
|
@@ -239,13 +311,13 @@ export async function policyQuoteAllowed(c: LogswapClient, policy: Address, quot
|
|
|
239
311
|
/**
|
|
240
312
|
* `setFeeListed` on any protocol policy (decisions 059): a swap-fee tier a pool of that kind may be
|
|
241
313
|
* born with while the policy curates fees. Within the family's domain (`FEE_MIN` ≤ fee ≤ `FEE_MAX`).
|
|
242
|
-
* The
|
|
314
|
+
* The LOG Authority's.
|
|
243
315
|
*/
|
|
244
316
|
export async function policySetFeeListed(c: LogswapClient, policy: Address, fee: bigint, listed: boolean): Promise<Hash> {
|
|
245
317
|
return write(c, policy, fPolicyBaseAbi, "setFeeListed", [fee, listed]);
|
|
246
318
|
}
|
|
247
319
|
|
|
248
|
-
/** `setFeeCurated` on any protocol policy: on, a birth with an unlisted swap fee is refused (`FeeNotListed`). The
|
|
320
|
+
/** `setFeeCurated` on any protocol policy: on, a birth with an unlisted swap fee is refused (`FeeNotListed`). The LOG Authority's. */
|
|
249
321
|
export async function policySetFeeCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash> {
|
|
250
322
|
return write(c, policy, fPolicyBaseAbi, "setFeeCurated", [curated]);
|
|
251
323
|
}
|
|
@@ -259,7 +331,7 @@ export async function policyFeeAllowed(c: LogswapClient, policy: Address, fee: b
|
|
|
259
331
|
return { curated, listed, allowed: !curated || listed };
|
|
260
332
|
}
|
|
261
333
|
|
|
262
|
-
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The
|
|
334
|
+
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The LOG Authority's. */
|
|
263
335
|
export async function policySetMintFeeListed(c: LogswapClient, policy: Address, mintFee: bigint, listed: boolean): Promise<Hash> {
|
|
264
336
|
return write(c, policy, fPolicyBaseAbi, "setMintFeeListed", [mintFee, listed]);
|
|
265
337
|
}
|
|
@@ -311,9 +383,12 @@ export async function gateSetForwarderTrusted(c: LogswapClient, policy: Address,
|
|
|
311
383
|
return write(c, policy, publicPolicyAbi, "setForwarderTrusted", [forwarder, trusted]);
|
|
312
384
|
}
|
|
313
385
|
|
|
314
|
-
/**
|
|
315
|
-
|
|
316
|
-
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated C version 8 fixes the gate at construction (066): there is no `setGate`. Open or close
|
|
388
|
+
* C through the gate's lists (`policySetCreatorCurated`, `gateSetPairCurated`, `gateSetSpacingListed`, …).
|
|
389
|
+
*/
|
|
390
|
+
export async function setCGate(_c: LogswapClient, _gate: Address): Promise<Hash> {
|
|
391
|
+
throw new Error("logswap: the C gate is fixed at construction since C version 8 (decision 066); change its lists instead");
|
|
317
392
|
}
|
|
318
393
|
|
|
319
394
|
/** The C manager's gate (`address(0)`: permissionless, a fee-free market then refused). */
|
|
@@ -373,11 +448,12 @@ export async function cGateRules(c: LogswapClient, a: { key: PoolKey; creator: A
|
|
|
373
448
|
|
|
374
449
|
/**
|
|
375
450
|
* Every refusal a birth can meet at the gate or a policy (064, 065), for `decodeErrorResult` on a
|
|
376
|
-
* failed simulation: the public policy's errors plus the pad's `PadExists` (one pad per base)
|
|
451
|
+
* failed simulation: the public policy's errors plus the pad's `PadExists` (one pad per base) and `NoThreshold` (no `T(0)`
|
|
452
|
+
* in the pad's quote, decision 070).
|
|
377
453
|
*/
|
|
378
454
|
export const gateErrorAbi = [
|
|
379
455
|
...publicPolicyAbi.filter((x) => x.type === "error"),
|
|
380
|
-
...padPolicyAbi.filter((x) => x.type === "error" && x.name === "PadExists"),
|
|
456
|
+
...padPolicyAbi.filter((x) => x.type === "error" && (x.name === "PadExists" || x.name === "NoThreshold")),
|
|
381
457
|
] as const;
|
|
382
458
|
|
|
383
459
|
/** `PublicPolicy.setListed`: an asset a curated seed may hold. */
|
|
@@ -390,13 +466,46 @@ export async function publicSetCurated(c: LogswapClient, policy: Address, curate
|
|
|
390
466
|
return write(c, policy, publicPolicyAbi, "setCurated", [curated]);
|
|
391
467
|
}
|
|
392
468
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return
|
|
469
|
+
// ─── the LOG Treasury (066): receives, administers nothing ───────────────────
|
|
470
|
+
|
|
471
|
+
function manager(c: LogswapClient, side: "C" | "F"): { address: Address; abi: readonly unknown[] } {
|
|
472
|
+
return side === "C"
|
|
473
|
+
? { address: c.addresses.cPoolManager, abi: cPoolManagerAbi }
|
|
474
|
+
: { address: c.addresses.fPoolManager as Address, abi: fPoolManagerAbi };
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** A manager's treasury — where its protocol revenue goes — and the proposed next one. */
|
|
478
|
+
export async function logTreasury(c: LogswapClient, side: "C" | "F"): Promise<{ treasury: Address; pending: Address }> {
|
|
479
|
+
const m = manager(c, side);
|
|
480
|
+
const [treasury, pending] = await Promise.all([
|
|
481
|
+
c.public.readContract({ ...m, functionName: "treasury" } as never) as Promise<Address>,
|
|
482
|
+
c.public.readContract({ ...m, functionName: "pendingTreasury" } as never) as Promise<Address>,
|
|
483
|
+
]);
|
|
484
|
+
return { treasury, pending };
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Propose a manager's next treasury: the LOG Authority's call, never the treasury's own, so a
|
|
489
|
+
* treasury that can no longer act is replaced without it. Nothing the old treasury holds moves.
|
|
490
|
+
*/
|
|
491
|
+
export async function proposeTreasury(c: LogswapClient, side: "C" | "F", next: Address): Promise<Hash> {
|
|
492
|
+
const m = manager(c, side);
|
|
493
|
+
return write(c, m.address, m.abi, "proposeTreasury", [next]);
|
|
494
|
+
}
|
|
495
|
+
/** The proposed treasury takes the role, sending from its own address. */
|
|
496
|
+
export async function acceptTreasury(c: LogswapClient, side: "C" | "F"): Promise<Hash> {
|
|
497
|
+
const m = manager(c, side);
|
|
498
|
+
return write(c, m.address, m.abi, "acceptTreasury", []);
|
|
397
499
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
500
|
+
/** @deprecated the collector became the treasury (066), proposed by the LOG Authority: use {@link proposeTreasury}. */
|
|
501
|
+
export const proposeCollector = proposeTreasury;
|
|
502
|
+
/** @deprecated use {@link acceptTreasury}. */
|
|
503
|
+
export const acceptCollector = acceptTreasury;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* `CPoolManager.collectProtocolFees(key)`: pay one market's `protocolOwed` (mint fees and swap-fee
|
|
507
|
+
* tax) to the treasury. Anyone may send it (066); the destination is fixed.
|
|
508
|
+
*/
|
|
509
|
+
export async function collectCProtocolFees(c: LogswapClient, key: PoolKey): Promise<Hash> {
|
|
510
|
+
return write(c, c.addresses.cPoolManager, cPoolManagerAbi, "collectProtocolFees", [key]);
|
|
402
511
|
}
|