@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/dist/admin.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
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
|
|
8
10
|
* is the protocol's on both managers. A harvest has no cut (056); a pad's protocol share of the pot
|
|
9
11
|
* is the policy's (`PadPolicy.setSchedule`), capped by the manager at `POT_CUT_MAX`.
|
|
10
12
|
*/
|
|
13
|
+
import { getPool } from "./pools.js";
|
|
11
14
|
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, publicPolicyAbi } from "./generated.js";
|
|
12
15
|
import { bytes32ToText, fPolicyBaseAbi, fPoolKeyOfPool, fPoolKindOfPolicy, textToBytes32 } from "./fpool.js";
|
|
13
16
|
function wallet(c) {
|
|
@@ -19,24 +22,30 @@ function write(c, address, abi, functionName, args) {
|
|
|
19
22
|
return wallet(c).writeContract({ address, abi, functionName, args, chain: c.wallet.chain, account: c.wallet.account });
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
|
-
* The C
|
|
23
|
-
*
|
|
25
|
+
* The C swap-fee tax (decisions 060, 066): the protocol's share of every swap fee a C position is
|
|
26
|
+
* paid (claims and the burn's auto-claim), WAD. `tax` is the level the gate (`PublicPolicy`) gives a
|
|
27
|
+
* market born NOW; each market keeps the level of its birth for life — read it with
|
|
28
|
+
* {@link cMarketSwapFeeTax} or `getPool(key).swapFeeTax`. `max` is the manager's bound.
|
|
24
29
|
*/
|
|
25
30
|
export async function cSwapFeeTax(c) {
|
|
26
31
|
const [tax, max] = await Promise.all([
|
|
27
|
-
c.public.readContract({ address: c.addresses.
|
|
32
|
+
c.public.readContract({ address: c.addresses.publicPolicy, abi: publicPolicyAbi, functionName: "swapFeeTax" }),
|
|
28
33
|
c.public.readContract({ address: c.addresses.cPoolManager, abi: cPoolManagerAbi, functionName: "SWAP_FEE_TAX_MAX" }),
|
|
29
34
|
]);
|
|
30
35
|
return { tax, max };
|
|
31
36
|
}
|
|
37
|
+
/** One C market's swap-fee tax, recorded at its birth (066). */
|
|
38
|
+
export async function cMarketSwapFeeTax(c, key) {
|
|
39
|
+
return (await getPool(c, key)).swapFeeTax;
|
|
40
|
+
}
|
|
32
41
|
/**
|
|
33
|
-
* `
|
|
34
|
-
*
|
|
42
|
+
* `PublicPolicy.setSwapFeeTax`: the level a C market born after it is given (066), at most
|
|
43
|
+
* `SWAP_FEE_TAX_MAX` (25%). The LOG Authority's. A live market keeps the level of its birth.
|
|
35
44
|
*/
|
|
36
45
|
export async function setCSwapFeeTax(c, taxWad) {
|
|
37
|
-
return write(c, c.addresses.
|
|
46
|
+
return write(c, c.addresses.publicPolicy, publicPolicyAbi, "setSwapFeeTax", [taxWad]);
|
|
38
47
|
}
|
|
39
|
-
// ─── the registry: the LOG
|
|
48
|
+
// ─── the registry: the LOG Authority's (046, 066) ───────────────────────────
|
|
40
49
|
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
41
50
|
/**
|
|
42
51
|
* The policy registry the F manager asks at every birth — `addresses.policyRegistry` when the
|
|
@@ -65,26 +74,36 @@ export async function registryPolicies(c, kind) {
|
|
|
65
74
|
if (registry === ZERO)
|
|
66
75
|
return [];
|
|
67
76
|
const list = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "policies" }));
|
|
68
|
-
|
|
77
|
+
// the registry compares `until` with block.timestamp (F version 29)
|
|
78
|
+
const now = (await c.public.getBlock({ blockTag: "latest" })).timestamp;
|
|
69
79
|
const all = await Promise.all(list.map(async (policy) => {
|
|
70
80
|
const [[listed, until, , name], tag] = await Promise.all([
|
|
71
81
|
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "entries", args: [policy] }),
|
|
72
82
|
fPoolKindOfPolicy(c, policy),
|
|
73
83
|
]);
|
|
74
|
-
return { policy, kind: tag, name: bytes32ToText(name), until, approved: listed && (until === 0n ||
|
|
84
|
+
return { policy, kind: tag, name: bytes32ToText(name), until, approved: listed && (until === 0n || now < until) };
|
|
75
85
|
}));
|
|
76
86
|
return kind ? all.filter((e) => e.kind === kind) : all;
|
|
77
87
|
}
|
|
78
|
-
/**
|
|
79
|
-
|
|
88
|
+
/**
|
|
89
|
+
* The LOG Authority (decision 066) — the registry's `logAuthority`, which administers the registry, both
|
|
90
|
+
* managers and every protocol policy — and the proposed next one. Zero with no registry: nothing on
|
|
91
|
+
* the deployment can be administered.
|
|
92
|
+
*/
|
|
93
|
+
export async function logAuthority(c) {
|
|
80
94
|
const registry = await policyRegistryOf(c);
|
|
81
95
|
if (registry === ZERO)
|
|
82
|
-
return {
|
|
83
|
-
const [
|
|
84
|
-
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "
|
|
85
|
-
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "
|
|
96
|
+
return { authority: ZERO, pending: ZERO };
|
|
97
|
+
const [authority, pending] = await Promise.all([
|
|
98
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "logAuthority" }),
|
|
99
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "pendingLogAuthority" }),
|
|
86
100
|
]);
|
|
87
|
-
return {
|
|
101
|
+
return { authority, pending };
|
|
102
|
+
}
|
|
103
|
+
/** @deprecated F version 27 renamed the registry's `owner` to `authority`: use {@link logAuthority}. */
|
|
104
|
+
export async function registryOwner(c) {
|
|
105
|
+
const { authority, pending } = await logAuthority(c);
|
|
106
|
+
return { owner: authority, pending };
|
|
88
107
|
}
|
|
89
108
|
async function registryWrite(c, functionName, args) {
|
|
90
109
|
const registry = await policyRegistryOf(c);
|
|
@@ -92,25 +111,33 @@ async function registryWrite(c, functionName, args) {
|
|
|
92
111
|
throw new Error("logswap: this deployment carries no policy registry");
|
|
93
112
|
return write(c, registry, policyRegistryAbi, functionName, args);
|
|
94
113
|
}
|
|
95
|
-
/** `PolicyRegistry.approve`: list `policy` under `name` (at most 31 bytes). Again renames it and clears its sunset. The
|
|
114
|
+
/** `PolicyRegistry.approve`: list `policy` under `name` (at most 31 bytes). Again renames it and clears its sunset. The LOG Authority's. */
|
|
96
115
|
export async function registryApprove(c, policy, name) {
|
|
97
116
|
return registryWrite(c, "approve", [policy, textToBytes32(name)]);
|
|
98
117
|
}
|
|
99
|
-
/** `PolicyRegistry.sunset`: close `policy` to new pools from `
|
|
100
|
-
export async function registrySunset(c, policy,
|
|
101
|
-
return registryWrite(c, "sunset", [policy,
|
|
118
|
+
/** `PolicyRegistry.sunset`: close `policy` to new pools from `untilTime` (unix seconds, F version 29) on; 0 reopens. The LOG Authority's. */
|
|
119
|
+
export async function registrySunset(c, policy, untilTime) {
|
|
120
|
+
return registryWrite(c, "sunset", [policy, untilTime]);
|
|
102
121
|
}
|
|
103
|
-
/** `PolicyRegistry.revoke`: remove `policy` from the list at once. Live pools are untouched. The
|
|
122
|
+
/** `PolicyRegistry.revoke`: remove `policy` from the list at once. Live pools are untouched. The LOG Authority's. */
|
|
104
123
|
export async function registryRevoke(c, policy) {
|
|
105
124
|
return registryWrite(c, "revoke", [policy]);
|
|
106
125
|
}
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
/**
|
|
127
|
+
* The LOG Authority's two-step handover (066): the authority proposes, the proposed address accepts
|
|
128
|
+
* by its own call (a Safe or a timelock sends `acceptLogAuthority` itself). One handover moves the
|
|
129
|
+
* administration of the registry, both managers and every policy; the treasury is a separate role.
|
|
130
|
+
*/
|
|
131
|
+
export async function proposeLogAuthority(c, next) {
|
|
132
|
+
return registryWrite(c, "proposeLogAuthority", [next]);
|
|
110
133
|
}
|
|
111
|
-
export async function
|
|
112
|
-
return registryWrite(c, "
|
|
134
|
+
export async function acceptLogAuthority(c) {
|
|
135
|
+
return registryWrite(c, "acceptLogAuthority", []);
|
|
113
136
|
}
|
|
137
|
+
/** @deprecated use {@link proposeLogAuthority}. */
|
|
138
|
+
export const registryProposeOwner = proposeLogAuthority;
|
|
139
|
+
/** @deprecated use {@link acceptLogAuthority}. */
|
|
140
|
+
export const registryAcceptOwner = acceptLogAuthority;
|
|
114
141
|
/**
|
|
115
142
|
* Approve or revoke, the F version 15–16 shape kept for callers: `approved` true is
|
|
116
143
|
* {@link registryApprove} under the policy's own tag as its name, false is {@link registryRevoke}.
|
|
@@ -119,7 +146,9 @@ export async function setPolicyApproved(c, policy, approved) {
|
|
|
119
146
|
return approved ? registryApprove(c, policy, await fPoolKindOfPolicy(c, policy)) : registryRevoke(c, policy);
|
|
120
147
|
}
|
|
121
148
|
/**
|
|
122
|
-
* Move a pool to another approved policy of the same kind: the
|
|
149
|
+
* Move a pool to another approved policy of the same kind: the LOG Authority's alone, a forced move
|
|
150
|
+
* (adoption at regeneration by the pool authority's consent is specified, not built — logswap-docs
|
|
151
|
+
* `specs/governance/policy-adoption.md`),
|
|
123
152
|
* orchestrated on the registry — `migrate(manager, key, to)` since F version 20 (it took the
|
|
124
153
|
* pool's id before). The registry checks the key against the manager (`NoPool`), checks the
|
|
125
154
|
* manager is its own (`WrongManager`), and compares the two policies' tags recorded at approval
|
|
@@ -128,7 +157,7 @@ export async function setPolicyApproved(c, policy, approved) {
|
|
|
128
157
|
* answer); the operator and the lists void; no swap lands in the block.
|
|
129
158
|
*
|
|
130
159
|
* Pass the pool's `key` when in hand. Given only `poolId`, the key is rebuilt from the pool's
|
|
131
|
-
* `
|
|
160
|
+
* `PoolCreated` log ({@link fPoolKeyOfPool}) with `salt` (zero by default) and checked against
|
|
132
161
|
* the id — the log does not carry the salt, so a salted pool needs it named.
|
|
133
162
|
*/
|
|
134
163
|
export async function fPoolMigrate(c, a) {
|
|
@@ -147,33 +176,63 @@ export async function registryKindOf(c, policy) {
|
|
|
147
176
|
const word = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "kindOf", args: [policy] }));
|
|
148
177
|
return bytes32ToText(word);
|
|
149
178
|
}
|
|
150
|
-
// ─── the policies' numbers (the
|
|
179
|
+
// ─── the policies' numbers (the LOG Authority's; each bounded where it reaches the manager) ─────
|
|
151
180
|
/**
|
|
152
|
-
* `PadPolicy.setSchedule` (decisions 056,
|
|
153
|
-
* recorded into each pad at birth), and the
|
|
154
|
-
*
|
|
155
|
-
*
|
|
181
|
+
* `PadPolicy.setSchedule` (decisions 056, 067, 070): the rung's growth, the protocol's share of the pot (≤ `POT_CUT_MAX`,
|
|
182
|
+
* recorded into each pad at birth), and the RANGE a creator chooses his cut of the pot inside at creation (its top ≤ the F
|
|
183
|
+
* 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
|
|
184
|
+
* 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
|
|
185
|
+
* next rung. The rung is the pool's generation. `T(0)` is per quote since decision 070: {@link padSetThresholdBase}.
|
|
156
186
|
*/
|
|
157
187
|
export async function padSetSchedule(c, policy, s) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
188
|
+
if ("thresholdBase" in s)
|
|
189
|
+
throw new Error("logswap: T(0) is per quote since decision 070 — padSetThresholdBase(c, policy, quote, base)");
|
|
190
|
+
return write(c, policy, padPolicyAbi, "setSchedule", [s.thresholdGrowth, s.protocolShare, s.creatorShareMin, s.creatorShareMax]);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* `PadPolicy.setThresholdBase(quote, base)` (decision 070): `T(0)` for pads quoted in `quote`, in that quote's units. A pad is
|
|
194
|
+
* 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
|
|
195
|
+
* Authority's.
|
|
196
|
+
*/
|
|
197
|
+
export async function padSetThresholdBase(c, policy, quote, base) {
|
|
198
|
+
return write(c, policy, padPolicyAbi, "setThresholdBase", [quote, base]);
|
|
199
|
+
}
|
|
200
|
+
/** `PadPolicy.thresholdSet(quote)` and `thresholdBaseOf(quote)` for each quote asked (decision 070). */
|
|
201
|
+
export async function padThresholdBases(c, policy, quotes) {
|
|
202
|
+
const rd = (functionName, quote) => c.public.readContract({ address: policy, abi: padPolicyAbi, functionName, args: [quote] });
|
|
203
|
+
return Promise.all(quotes.map(async (quote) => {
|
|
204
|
+
const [set, base] = await Promise.all([rd("thresholdSet", quote), rd("thresholdBaseOf", quote)]);
|
|
205
|
+
return { quote, set, base };
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
/** `PadPolicy.thresholdOf(quote, rung)` (decision 070): the pot a pad quoted in `quote` must bank to climb `rung` (0 reads `T(0)`). */
|
|
209
|
+
export async function padThresholdOf(c, policy, quote, rung = 0n) {
|
|
210
|
+
return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "thresholdOf", args: [quote, BigInt(rung)] }));
|
|
211
|
+
}
|
|
212
|
+
/** `PadPolicy.threshold(poolId, rung)` (decision 070): the pot pad `poolId` must bank to climb `rung`, in its own quote. */
|
|
213
|
+
export async function padThreshold(c, policy, poolId, rung) {
|
|
214
|
+
return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "threshold", args: [poolId, BigInt(rung)] }));
|
|
215
|
+
}
|
|
216
|
+
/** Read {@link PadSchedule} off a pad policy. */
|
|
217
|
+
export async function padScheduleOf(c, policy) {
|
|
218
|
+
const rd = (functionName) => c.public.readContract({ address: policy, abi: padPolicyAbi, functionName });
|
|
219
|
+
const [thresholdGrowth, protocolShare, creatorShareMin, creatorShareMax] = await Promise.all([
|
|
220
|
+
rd("thresholdGrowth"),
|
|
221
|
+
rd("protocolShare"),
|
|
222
|
+
rd("creatorShareMin"),
|
|
223
|
+
rd("creatorShareMax"),
|
|
166
224
|
]);
|
|
225
|
+
return { thresholdGrowth, protocolShare, creatorShareMin, creatorShareMax };
|
|
167
226
|
}
|
|
168
227
|
/** `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. */
|
|
169
228
|
export async function polSetRules(c, policy, s) {
|
|
170
229
|
return write(c, policy, polPolicyAbi, "setRules", [s.keepQuote, s.minQuoteAtSeed]);
|
|
171
230
|
}
|
|
172
|
-
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The
|
|
231
|
+
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The LOG Authority's. */
|
|
173
232
|
export async function policySetQuoteListed(c, policy, quote, listed) {
|
|
174
233
|
return write(c, policy, fPolicyBaseAbi, "setQuoteListed", [quote, listed]);
|
|
175
234
|
}
|
|
176
|
-
/** `setQuoteCurated` on any protocol policy: on, a birth against an unlisted quote is refused. The
|
|
235
|
+
/** `setQuoteCurated` on any protocol policy: on, a birth against an unlisted quote is refused. The LOG Authority's. */
|
|
177
236
|
export async function policySetQuoteCurated(c, policy, curated) {
|
|
178
237
|
return write(c, policy, fPolicyBaseAbi, "setQuoteCurated", [curated]);
|
|
179
238
|
}
|
|
@@ -188,12 +247,12 @@ export async function policyQuoteAllowed(c, policy, quote) {
|
|
|
188
247
|
/**
|
|
189
248
|
* `setFeeListed` on any protocol policy (decisions 059): a swap-fee tier a pool of that kind may be
|
|
190
249
|
* born with while the policy curates fees. Within the family's domain (`FEE_MIN` ≤ fee ≤ `FEE_MAX`).
|
|
191
|
-
* The
|
|
250
|
+
* The LOG Authority's.
|
|
192
251
|
*/
|
|
193
252
|
export async function policySetFeeListed(c, policy, fee, listed) {
|
|
194
253
|
return write(c, policy, fPolicyBaseAbi, "setFeeListed", [fee, listed]);
|
|
195
254
|
}
|
|
196
|
-
/** `setFeeCurated` on any protocol policy: on, a birth with an unlisted swap fee is refused (`FeeNotListed`). The
|
|
255
|
+
/** `setFeeCurated` on any protocol policy: on, a birth with an unlisted swap fee is refused (`FeeNotListed`). The LOG Authority's. */
|
|
197
256
|
export async function policySetFeeCurated(c, policy, curated) {
|
|
198
257
|
return write(c, policy, fPolicyBaseAbi, "setFeeCurated", [curated]);
|
|
199
258
|
}
|
|
@@ -205,7 +264,7 @@ export async function policyFeeAllowed(c, policy, fee) {
|
|
|
205
264
|
]);
|
|
206
265
|
return { curated, listed, allowed: !curated || listed };
|
|
207
266
|
}
|
|
208
|
-
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The
|
|
267
|
+
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The LOG Authority's. */
|
|
209
268
|
export async function policySetMintFeeListed(c, policy, mintFee, listed) {
|
|
210
269
|
return write(c, policy, fPolicyBaseAbi, "setMintFeeListed", [mintFee, listed]);
|
|
211
270
|
}
|
|
@@ -247,9 +306,12 @@ export async function gateSetSpacingListed(c, policy, tickSpacing, listed) {
|
|
|
247
306
|
export async function gateSetForwarderTrusted(c, policy, forwarder, trusted) {
|
|
248
307
|
return write(c, policy, publicPolicyAbi, "setForwarderTrusted", [forwarder, trusted]);
|
|
249
308
|
}
|
|
250
|
-
/**
|
|
251
|
-
|
|
252
|
-
|
|
309
|
+
/**
|
|
310
|
+
* @deprecated C version 8 fixes the gate at construction (066): there is no `setGate`. Open or close
|
|
311
|
+
* C through the gate's lists (`policySetCreatorCurated`, `gateSetPairCurated`, `gateSetSpacingListed`, …).
|
|
312
|
+
*/
|
|
313
|
+
export async function setCGate(_c, _gate) {
|
|
314
|
+
throw new Error("logswap: the C gate is fixed at construction since C version 8 (decision 066); change its lists instead");
|
|
253
315
|
}
|
|
254
316
|
/** The C manager's gate (`address(0)`: permissionless, a fee-free market then refused). */
|
|
255
317
|
export async function cGate(c) {
|
|
@@ -290,11 +352,12 @@ export async function cGateRules(c, a) {
|
|
|
290
352
|
}
|
|
291
353
|
/**
|
|
292
354
|
* 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)
|
|
355
|
+
* failed simulation: the public policy's errors plus the pad's `PadExists` (one pad per base) and `NoThreshold` (no `T(0)`
|
|
356
|
+
* in the pad's quote, decision 070).
|
|
294
357
|
*/
|
|
295
358
|
export const gateErrorAbi = [
|
|
296
359
|
...publicPolicyAbi.filter((x) => x.type === "error"),
|
|
297
|
-
...padPolicyAbi.filter((x) => x.type === "error" && x.name === "PadExists"),
|
|
360
|
+
...padPolicyAbi.filter((x) => x.type === "error" && (x.name === "PadExists" || x.name === "NoThreshold")),
|
|
298
361
|
];
|
|
299
362
|
/** `PublicPolicy.setListed`: an asset a curated seed may hold. */
|
|
300
363
|
export async function publicSetListed(c, policy, token, listed) {
|
|
@@ -304,13 +367,42 @@ export async function publicSetListed(c, policy, token, listed) {
|
|
|
304
367
|
export async function publicSetCurated(c, policy, curated) {
|
|
305
368
|
return write(c, policy, publicPolicyAbi, "setCurated", [curated]);
|
|
306
369
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
370
|
+
// ─── the LOG Treasury (066): receives, administers nothing ───────────────────
|
|
371
|
+
function manager(c, side) {
|
|
372
|
+
return side === "C"
|
|
373
|
+
? { address: c.addresses.cPoolManager, abi: cPoolManagerAbi }
|
|
374
|
+
: { address: c.addresses.fPoolManager, abi: fPoolManagerAbi };
|
|
375
|
+
}
|
|
376
|
+
/** A manager's treasury — where its protocol revenue goes — and the proposed next one. */
|
|
377
|
+
export async function logTreasury(c, side) {
|
|
378
|
+
const m = manager(c, side);
|
|
379
|
+
const [treasury, pending] = await Promise.all([
|
|
380
|
+
c.public.readContract({ ...m, functionName: "treasury" }),
|
|
381
|
+
c.public.readContract({ ...m, functionName: "pendingTreasury" }),
|
|
382
|
+
]);
|
|
383
|
+
return { treasury, pending };
|
|
311
384
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
385
|
+
/**
|
|
386
|
+
* Propose a manager's next treasury: the LOG Authority's call, never the treasury's own, so a
|
|
387
|
+
* treasury that can no longer act is replaced without it. Nothing the old treasury holds moves.
|
|
388
|
+
*/
|
|
389
|
+
export async function proposeTreasury(c, side, next) {
|
|
390
|
+
const m = manager(c, side);
|
|
391
|
+
return write(c, m.address, m.abi, "proposeTreasury", [next]);
|
|
392
|
+
}
|
|
393
|
+
/** The proposed treasury takes the role, sending from its own address. */
|
|
394
|
+
export async function acceptTreasury(c, side) {
|
|
395
|
+
const m = manager(c, side);
|
|
396
|
+
return write(c, m.address, m.abi, "acceptTreasury", []);
|
|
397
|
+
}
|
|
398
|
+
/** @deprecated the collector became the treasury (066), proposed by the LOG Authority: use {@link proposeTreasury}. */
|
|
399
|
+
export const proposeCollector = proposeTreasury;
|
|
400
|
+
/** @deprecated use {@link acceptTreasury}. */
|
|
401
|
+
export const acceptCollector = acceptTreasury;
|
|
402
|
+
/**
|
|
403
|
+
* `CPoolManager.collectProtocolFees(key)`: pay one market's `protocolOwed` (mint fees and swap-fee
|
|
404
|
+
* tax) to the treasury. Anyone may send it (066); the destination is fixed.
|
|
405
|
+
*/
|
|
406
|
+
export async function collectCProtocolFees(c, key) {
|
|
407
|
+
return write(c, c.addresses.cPoolManager, cPoolManagerAbi, "collectProtocolFees", [key]);
|
|
316
408
|
}
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chains.ts — the chains log(swap) runs on, and their deployments.
|
|
3
|
+
*
|
|
4
|
+
* The release chains carry the contracts at ONE address each (CREATE3 through CreateX, contracts
|
|
5
|
+
* decision 069): the same `LogswapAddresses` on every chain. What differs per chain is the deploy
|
|
6
|
+
* block, the quote tokens, the explorer and the indexer. An address therefore names a contract only
|
|
7
|
+
* together with a chain id; every cache and every indexer URL in this SDK is per chain.
|
|
8
|
+
*/
|
|
9
|
+
import { type Address, type Chain } from "viem";
|
|
10
|
+
import type { LogswapAddresses } from "./client.js";
|
|
11
|
+
/** A quote token a chain's policies list at deployment (`deployments/config/<chainId>.json`). */
|
|
12
|
+
export interface LogswapQuote {
|
|
13
|
+
symbol: string;
|
|
14
|
+
address: Address;
|
|
15
|
+
decimals: number;
|
|
16
|
+
}
|
|
17
|
+
export interface LogswapChain {
|
|
18
|
+
chainId: number;
|
|
19
|
+
/** The deployment artifact's `network` (`deployments/<chainId>.json`). */
|
|
20
|
+
network: string;
|
|
21
|
+
name: string;
|
|
22
|
+
/** The viem chain, for `createPublicClient({ chain })`. */
|
|
23
|
+
chain: Chain;
|
|
24
|
+
nativeCurrency: Chain["nativeCurrency"];
|
|
25
|
+
/** Block explorer root URL. */
|
|
26
|
+
explorer?: string;
|
|
27
|
+
/** A public JSON-RPC endpoint: rate-limited, for reads at low volume; production reads bring their own. */
|
|
28
|
+
publicRpc?: string;
|
|
29
|
+
/** A development chain: wiped and redeployed at the same addresses, so nothing keyed on its addresses persists. */
|
|
30
|
+
devnet: boolean;
|
|
31
|
+
testnet: boolean;
|
|
32
|
+
/** The quotes the deploy config lists, verified on chain (symbol, decimals). Empty where none is configured. */
|
|
33
|
+
quotes: readonly LogswapQuote[];
|
|
34
|
+
/** The quote pads launch against on this chain. */
|
|
35
|
+
padQuote?: Address;
|
|
36
|
+
/** Block span of one `eth_getLogs` call on this chain; the client's default {@link LogswapClient.maxLogRange}. */
|
|
37
|
+
maxLogRange: bigint;
|
|
38
|
+
}
|
|
39
|
+
/** The logswap devnet (anvil, persisted with `--state`). No public RPC. */
|
|
40
|
+
export declare const logswapDevnet: {
|
|
41
|
+
blockExplorers?: {
|
|
42
|
+
[key: string]: {
|
|
43
|
+
name: string;
|
|
44
|
+
url: string;
|
|
45
|
+
apiUrl?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
default: {
|
|
48
|
+
name: string;
|
|
49
|
+
url: string;
|
|
50
|
+
apiUrl?: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
} | undefined | undefined;
|
|
53
|
+
blockTime?: number | undefined | undefined;
|
|
54
|
+
contracts?: {
|
|
55
|
+
[x: string]: import("viem").ChainContract | {
|
|
56
|
+
[sourceId: number]: import("viem").ChainContract | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
ensRegistry?: import("viem").ChainContract | undefined;
|
|
59
|
+
ensUniversalResolver?: import("viem").ChainContract | undefined;
|
|
60
|
+
multicall3?: import("viem").ChainContract | undefined;
|
|
61
|
+
erc6492Verifier?: import("viem").ChainContract | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
ensTlds?: readonly string[] | undefined;
|
|
64
|
+
id: 31339;
|
|
65
|
+
name: "log(swap) devnet";
|
|
66
|
+
nativeCurrency: {
|
|
67
|
+
readonly name: "Ether";
|
|
68
|
+
readonly symbol: "ETH";
|
|
69
|
+
readonly decimals: 18;
|
|
70
|
+
};
|
|
71
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
72
|
+
rpcUrls: {
|
|
73
|
+
readonly default: {
|
|
74
|
+
readonly http: readonly [];
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
sourceId?: number | undefined | undefined;
|
|
78
|
+
supportsTransactionReplacementDetection?: boolean | undefined | undefined;
|
|
79
|
+
testnet: true;
|
|
80
|
+
custom?: Record<string, unknown> | undefined;
|
|
81
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
82
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
83
|
+
formatters?: undefined;
|
|
84
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
85
|
+
client: import("viem").Client;
|
|
86
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
87
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
88
|
+
client: import("viem").Client;
|
|
89
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
90
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
91
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
92
|
+
}] | undefined;
|
|
93
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
94
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
95
|
+
};
|
|
96
|
+
/** Default block span per `eth_getLogs` call: public endpoints refuse wider ranges (or cap the result). */
|
|
97
|
+
export declare const DEFAULT_MAX_LOG_RANGE = 2000n;
|
|
98
|
+
/** Every chain this SDK knows, by chain id. */
|
|
99
|
+
export declare const LOGSWAP_CHAINS: Readonly<Record<number, LogswapChain>>;
|
|
100
|
+
/** The production chains, in release order. */
|
|
101
|
+
export declare const RELEASE_CHAIN_IDS: readonly [1, 8453, 42161, 4663];
|
|
102
|
+
/** The registry entry for `chainId`, or undefined for a chain this SDK does not list. */
|
|
103
|
+
export declare function logswapChain(chainId: number): LogswapChain | undefined;
|
|
104
|
+
/** A quote of `chainId` by symbol (case-insensitive), or undefined. */
|
|
105
|
+
export declare function quoteOf(chainId: number, symbol: string): LogswapQuote | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* A deployment artifact: `deployments/<chainId>.json` as the contracts' `DeployChain.s.sol` writes
|
|
108
|
+
* it. `DeployLocal`'s artifact carries the same fields (without `deployTag` and `createX`) plus its
|
|
109
|
+
* devnet extras, of which `tokenFactory` is kept.
|
|
110
|
+
*/
|
|
111
|
+
export interface LogswapDeployment {
|
|
112
|
+
chainId: number;
|
|
113
|
+
network: string;
|
|
114
|
+
/** The first block of the deployment: where every log scan starts. */
|
|
115
|
+
deployBlock: bigint;
|
|
116
|
+
cVersion: bigint;
|
|
117
|
+
fVersion: bigint;
|
|
118
|
+
/** The CREATE3 salt namespace (`logswap.v1`); absent on a local deployment. */
|
|
119
|
+
deployTag?: string;
|
|
120
|
+
deployer: Address;
|
|
121
|
+
createX?: Address;
|
|
122
|
+
logAuthority: Address;
|
|
123
|
+
logTreasury: Address;
|
|
124
|
+
permit2: Address;
|
|
125
|
+
multicall3: Address;
|
|
126
|
+
policyRegistry: Address;
|
|
127
|
+
fPoolManager: Address;
|
|
128
|
+
cPoolManager: Address;
|
|
129
|
+
publicPolicy: Address;
|
|
130
|
+
privatePolicy: Address;
|
|
131
|
+
polPolicy: Address;
|
|
132
|
+
padPolicy: Address;
|
|
133
|
+
router: Address;
|
|
134
|
+
lens: Address;
|
|
135
|
+
/** The devnet's token factory; local deployments only. */
|
|
136
|
+
tokenFactory?: Address;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The published deployments, by chain id. Empty until the release chains are deployed; a
|
|
140
|
+
* deployment is added here from its artifact in the release that ships it.
|
|
141
|
+
*/
|
|
142
|
+
export declare const LOGSWAP_DEPLOYMENTS: Readonly<Record<number, LogswapDeployment>>;
|
|
143
|
+
/** The published deployment on `chainId`, or undefined. */
|
|
144
|
+
export declare function deploymentFor(chainId: number): LogswapDeployment | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Validate a deployment artifact (parsed JSON) and return it typed. Throws on a missing or
|
|
147
|
+
* malformed field, and on a `chainId` other than `opts.chainId` when given: one address set is valid
|
|
148
|
+
* on every release chain, so an artifact read for the wrong chain would otherwise load cleanly and
|
|
149
|
+
* scan from the wrong `deployBlock`.
|
|
150
|
+
*/
|
|
151
|
+
export declare function deploymentFromArtifact(json: unknown, opts?: {
|
|
152
|
+
chainId?: number;
|
|
153
|
+
}): LogswapDeployment;
|
|
154
|
+
/** The client's address set from a deployment. */
|
|
155
|
+
export declare function addressesOfDeployment(d: LogswapDeployment): LogswapAddresses;
|