@logswap/sdk 0.5.50 → 0.5.51
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/dist/admin.d.ts +43 -25
- package/dist/admin.js +61 -35
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/fpool.d.ts +194 -38
- package/dist/fpool.js +82 -43
- package/dist/generated.d.ts +837 -264
- package/dist/generated.js +563 -176
- package/package.json +1 -1
- package/src/admin.ts +68 -37
- package/src/client.ts +1 -1
- package/src/fpool.ts +122 -77
- package/src/generated.ts +564 -175
package/dist/admin.d.ts
CHANGED
|
@@ -1,63 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* admin — the protocol's
|
|
3
|
-
*
|
|
4
|
-
* two-step collector handover. Plain writes to the managers
|
|
2
|
+
* admin — the protocol's writes: the C manager's cut of the mint fee (the F manager's is a
|
|
3
|
+
* constant, decisions 049), the policies a pool may be born with (the registry's), the
|
|
4
|
+
* policies' own numbers, and the two-step collector handover. Plain writes to the managers,
|
|
5
|
+
* the registry and the policies; no router.
|
|
5
6
|
*
|
|
6
7
|
* One vocabulary (decisions 040): both managers call the protocol's cut of the mint fee
|
|
7
|
-
* `MINT_FEE_PROTOCOL_CUT
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* `MINT_FEE_PROTOCOL_CUT`; C sets it through `setFeeParams(uint256)`, F holds it as a constant
|
|
9
|
+
* (049). The harvest's cut is the policy's answer at every harvest (decisions 044), set on the
|
|
10
|
+
* policy (`setHarvestCut`) and capped by the manager (`HARVEST_CUT_MAX`); the release's
|
|
11
|
+
* protocol share likewise (`POT_CUT_MAX`).
|
|
11
12
|
*/
|
|
12
13
|
import type { Address, Hash } from "viem";
|
|
13
14
|
import type { LogswapClient } from "./client.js";
|
|
14
15
|
import { type FPoolKind } from "./fpool.js";
|
|
15
16
|
/** The C manager's `setFeeParams(mintFeeProtocolCut)` — one cut. */
|
|
16
17
|
export declare function setFeeParamsC(c: LogswapClient, mintFeeProtocolCutWad: bigint): Promise<Hash>;
|
|
17
|
-
/** The F manager's `
|
|
18
|
-
export declare function
|
|
18
|
+
/** The F manager's `MINT_FEE_PROTOCOL_CUT` — a constant since F version 18 (decisions 049); there is no setter. */
|
|
19
|
+
export declare function fMintFeeProtocolCut(c: LogswapClient): Promise<bigint>;
|
|
19
20
|
/**
|
|
20
21
|
* The policy registry the F manager asks at every birth — `addresses.policyRegistry` when the
|
|
21
22
|
* deployment carries it, else read once from the manager. The zero address is a deployment with
|
|
22
23
|
* no registry: it asks nobody, and nothing here can be written.
|
|
23
24
|
*/
|
|
24
25
|
export declare function policyRegistryOf(c: LogswapClient): Promise<Address>;
|
|
25
|
-
/** Whether `policy` is approved
|
|
26
|
-
export declare function policyApproved(c: LogswapClient,
|
|
27
|
-
/** One policy on
|
|
26
|
+
/** Whether `policy` is approved now — listed and not yet sunset. True everywhere on a deployment with no registry. */
|
|
27
|
+
export declare function policyApproved(c: LogswapClient, policy: Address): Promise<boolean>;
|
|
28
|
+
/** One policy on the registry's list, with what it says it is. */
|
|
28
29
|
export interface RegistryEntry {
|
|
29
30
|
policy: Address;
|
|
31
|
+
/** The policy's own `kind()` tag (decisions 049) — what a pool born under it is. */
|
|
32
|
+
kind: FPoolKind;
|
|
30
33
|
name: string;
|
|
31
34
|
/** The block it closes to new pools from; 0 = open. */
|
|
32
35
|
until: bigint;
|
|
33
36
|
/** Approved now: listed and not yet sunset. */
|
|
34
37
|
approved: boolean;
|
|
35
38
|
}
|
|
36
|
-
/**
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Every policy listed, sunset ones included — one flat list (decisions 049), each with the kind
|
|
41
|
+
* it says it is; `kind` narrows it to one, which is what a create form's dropdown reads. Empty
|
|
42
|
+
* with no registry.
|
|
43
|
+
*/
|
|
44
|
+
export declare function registryPolicies(c: LogswapClient, kind?: FPoolKind): Promise<RegistryEntry[]>;
|
|
38
45
|
/** The registry's owner — the LOG authority — and the proposed next one. */
|
|
39
46
|
export declare function registryOwner(c: LogswapClient): Promise<{
|
|
40
47
|
owner: Address;
|
|
41
48
|
pending: Address;
|
|
42
49
|
}>;
|
|
43
|
-
/** `PolicyRegistry.approve`: list `policy`
|
|
44
|
-
export declare function registryApprove(c: LogswapClient,
|
|
45
|
-
/** `PolicyRegistry.sunset`: close `policy` to new pools
|
|
46
|
-
export declare function registrySunset(c: LogswapClient,
|
|
47
|
-
/** `PolicyRegistry.revoke`: remove `policy` from
|
|
48
|
-
export declare function registryRevoke(c: LogswapClient,
|
|
50
|
+
/** `PolicyRegistry.approve`: list `policy` under `name` (at most 31 bytes). Again renames it and clears its sunset. The owner's. */
|
|
51
|
+
export declare function registryApprove(c: LogswapClient, policy: Address, name: string): Promise<Hash>;
|
|
52
|
+
/** `PolicyRegistry.sunset`: close `policy` to new pools from `untilBlock` on; 0 reopens. The owner's. */
|
|
53
|
+
export declare function registrySunset(c: LogswapClient, policy: Address, untilBlock: bigint): Promise<Hash>;
|
|
54
|
+
/** `PolicyRegistry.revoke`: remove `policy` from the list at once. Live pools are untouched. The owner's. */
|
|
55
|
+
export declare function registryRevoke(c: LogswapClient, policy: Address): Promise<Hash>;
|
|
49
56
|
/** The registry owner's two-step handover. */
|
|
50
57
|
export declare function registryProposeOwner(c: LogswapClient, next: Address): Promise<Hash>;
|
|
51
58
|
export declare function registryAcceptOwner(c: LogswapClient): Promise<Hash>;
|
|
52
59
|
/**
|
|
53
60
|
* Approve or revoke, the F version 15–16 shape kept for callers: `approved` true is
|
|
54
|
-
* {@link registryApprove} under the
|
|
61
|
+
* {@link registryApprove} under the policy's own tag as its name, false is {@link registryRevoke}.
|
|
55
62
|
*/
|
|
56
|
-
export declare function setPolicyApproved(c: LogswapClient,
|
|
63
|
+
export declare function setPolicyApproved(c: LogswapClient, policy: Address, approved: boolean): Promise<Hash>;
|
|
57
64
|
/**
|
|
58
|
-
* Move a pool to another policy the
|
|
59
|
-
* owner's alone
|
|
60
|
-
* void; no swap lands
|
|
65
|
+
* Move a pool to another approved policy of the same kind (decisions 046, 049): the registry
|
|
66
|
+
* owner's alone, orchestrated on the registry — `migrate(manager, poolId, to)`. The new policy
|
|
67
|
+
* takes the authority and the name from the old; the operator and the lists void; no swap lands
|
|
68
|
+
* in the block.
|
|
61
69
|
*/
|
|
62
70
|
export declare function fPoolMigrate(c: LogswapClient, a: {
|
|
63
71
|
poolId: `0x${string}`;
|
|
@@ -78,6 +86,16 @@ export declare function polSetRules(c: LogswapClient, policy: Address, s: {
|
|
|
78
86
|
keepQuote: bigint;
|
|
79
87
|
minQuoteAtSeed: bigint;
|
|
80
88
|
}): Promise<Hash>;
|
|
89
|
+
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The collector's. */
|
|
90
|
+
export declare function policySetQuoteListed(c: LogswapClient, policy: Address, quote: Address, listed: boolean): Promise<Hash>;
|
|
91
|
+
/** `setQuoteCurated` on any protocol policy: on, a birth against an unlisted quote is refused. The collector's. */
|
|
92
|
+
export declare function policySetQuoteCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash>;
|
|
93
|
+
/** Whether `quote` passes `policy`'s birth check now: listed, or the policy does not curate quotes. */
|
|
94
|
+
export declare function policyQuoteAllowed(c: LogswapClient, policy: Address, quote: Address): Promise<{
|
|
95
|
+
curated: boolean;
|
|
96
|
+
listed: boolean;
|
|
97
|
+
allowed: boolean;
|
|
98
|
+
}>;
|
|
81
99
|
/** `PublicPolicy.setListed`: an asset a curated seed may hold. */
|
|
82
100
|
export declare function publicSetListed(c: LogswapClient, policy: Address, token: Address, listed: boolean): Promise<Hash>;
|
|
83
101
|
/** `PublicPolicy.setCurated`: whether every public seed is checked against the list. */
|
package/dist/admin.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* admin — the protocol's
|
|
3
|
-
*
|
|
4
|
-
* two-step collector handover. Plain writes to the managers
|
|
2
|
+
* admin — the protocol's writes: the C manager's cut of the mint fee (the F manager's is a
|
|
3
|
+
* constant, decisions 049), the policies a pool may be born with (the registry's), the
|
|
4
|
+
* policies' own numbers, and the two-step collector handover. Plain writes to the managers,
|
|
5
|
+
* the registry and the policies; no router.
|
|
5
6
|
*
|
|
6
7
|
* One vocabulary (decisions 040): both managers call the protocol's cut of the mint fee
|
|
7
|
-
* `MINT_FEE_PROTOCOL_CUT
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* `MINT_FEE_PROTOCOL_CUT`; C sets it through `setFeeParams(uint256)`, F holds it as a constant
|
|
9
|
+
* (049). The harvest's cut is the policy's answer at every harvest (decisions 044), set on the
|
|
10
|
+
* policy (`setHarvestCut`) and capped by the manager (`HARVEST_CUT_MAX`); the release's
|
|
11
|
+
* protocol share likewise (`POT_CUT_MAX`).
|
|
11
12
|
*/
|
|
12
13
|
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, publicPolicyAbi } from "./generated.js";
|
|
13
|
-
import {
|
|
14
|
+
import { bytes32ToText, fPolicyBaseAbi, fPoolKindOfPolicy, textToBytes32 } from "./fpool.js";
|
|
14
15
|
function wallet(c) {
|
|
15
16
|
if (!c.wallet)
|
|
16
17
|
throw new Error("a wallet client is required");
|
|
@@ -23,9 +24,9 @@ function write(c, address, abi, functionName, args) {
|
|
|
23
24
|
export async function setFeeParamsC(c, mintFeeProtocolCutWad) {
|
|
24
25
|
return write(c, c.addresses.cPoolManager, cPoolManagerAbi, "setFeeParams", [mintFeeProtocolCutWad]);
|
|
25
26
|
}
|
|
26
|
-
/** The F manager's `
|
|
27
|
-
export async function
|
|
28
|
-
return
|
|
27
|
+
/** The F manager's `MINT_FEE_PROTOCOL_CUT` — a constant since F version 18 (decisions 049); there is no setter. */
|
|
28
|
+
export async function fMintFeeProtocolCut(c) {
|
|
29
|
+
return c.public.readContract({ address: c.addresses.fPoolManager, abi: fPoolManagerAbi, functionName: "MINT_FEE_PROTOCOL_CUT" });
|
|
29
30
|
}
|
|
30
31
|
// ─── the registry (decisions 046): the LOG authority's, not the collector's ─────────────────
|
|
31
32
|
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
@@ -39,24 +40,32 @@ export async function policyRegistryOf(c) {
|
|
|
39
40
|
return c.addresses.policyRegistry;
|
|
40
41
|
return (await c.public.readContract({ address: c.addresses.fPoolManager, abi: fPoolManagerAbi, functionName: "registry" }));
|
|
41
42
|
}
|
|
42
|
-
/** Whether `policy` is approved
|
|
43
|
-
export async function policyApproved(c,
|
|
43
|
+
/** Whether `policy` is approved now — listed and not yet sunset. True everywhere on a deployment with no registry. */
|
|
44
|
+
export async function policyApproved(c, policy) {
|
|
44
45
|
const registry = await policyRegistryOf(c);
|
|
45
46
|
if (registry === ZERO)
|
|
46
47
|
return true;
|
|
47
|
-
return c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "isApproved", args: [
|
|
48
|
+
return c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "isApproved", args: [policy] });
|
|
48
49
|
}
|
|
49
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Every policy listed, sunset ones included — one flat list (decisions 049), each with the kind
|
|
52
|
+
* it says it is; `kind` narrows it to one, which is what a create form's dropdown reads. Empty
|
|
53
|
+
* with no registry.
|
|
54
|
+
*/
|
|
50
55
|
export async function registryPolicies(c, kind) {
|
|
51
56
|
const registry = await policyRegistryOf(c);
|
|
52
57
|
if (registry === ZERO)
|
|
53
58
|
return [];
|
|
54
|
-
const list = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "
|
|
59
|
+
const list = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "policies" }));
|
|
55
60
|
const block = await c.public.getBlockNumber();
|
|
56
|
-
|
|
57
|
-
const [listed, until, , name] =
|
|
58
|
-
|
|
61
|
+
const all = await Promise.all(list.map(async (policy) => {
|
|
62
|
+
const [[listed, until, , name], tag] = await Promise.all([
|
|
63
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "entries", args: [policy] }),
|
|
64
|
+
fPoolKindOfPolicy(c, policy),
|
|
65
|
+
]);
|
|
66
|
+
return { policy, kind: tag, name: bytes32ToText(name), until, approved: listed && (until === 0n || block < until) };
|
|
59
67
|
}));
|
|
68
|
+
return kind ? all.filter((e) => e.kind === kind) : all;
|
|
60
69
|
}
|
|
61
70
|
/** The registry's owner — the LOG authority — and the proposed next one. */
|
|
62
71
|
export async function registryOwner(c) {
|
|
@@ -75,17 +84,17 @@ async function registryWrite(c, functionName, args) {
|
|
|
75
84
|
throw new Error("logswap: this deployment carries no policy registry");
|
|
76
85
|
return write(c, registry, policyRegistryAbi, functionName, args);
|
|
77
86
|
}
|
|
78
|
-
/** `PolicyRegistry.approve`: list `policy`
|
|
79
|
-
export async function registryApprove(c,
|
|
80
|
-
return registryWrite(c, "approve", [
|
|
87
|
+
/** `PolicyRegistry.approve`: list `policy` under `name` (at most 31 bytes). Again renames it and clears its sunset. The owner's. */
|
|
88
|
+
export async function registryApprove(c, policy, name) {
|
|
89
|
+
return registryWrite(c, "approve", [policy, textToBytes32(name)]);
|
|
81
90
|
}
|
|
82
|
-
/** `PolicyRegistry.sunset`: close `policy` to new pools
|
|
83
|
-
export async function registrySunset(c,
|
|
84
|
-
return registryWrite(c, "sunset", [
|
|
91
|
+
/** `PolicyRegistry.sunset`: close `policy` to new pools from `untilBlock` on; 0 reopens. The owner's. */
|
|
92
|
+
export async function registrySunset(c, policy, untilBlock) {
|
|
93
|
+
return registryWrite(c, "sunset", [policy, untilBlock]);
|
|
85
94
|
}
|
|
86
|
-
/** `PolicyRegistry.revoke`: remove `policy` from
|
|
87
|
-
export async function registryRevoke(c,
|
|
88
|
-
return registryWrite(c, "revoke", [
|
|
95
|
+
/** `PolicyRegistry.revoke`: remove `policy` from the list at once. Live pools are untouched. The owner's. */
|
|
96
|
+
export async function registryRevoke(c, policy) {
|
|
97
|
+
return registryWrite(c, "revoke", [policy]);
|
|
89
98
|
}
|
|
90
99
|
/** The registry owner's two-step handover. */
|
|
91
100
|
export async function registryProposeOwner(c, next) {
|
|
@@ -96,18 +105,19 @@ export async function registryAcceptOwner(c) {
|
|
|
96
105
|
}
|
|
97
106
|
/**
|
|
98
107
|
* Approve or revoke, the F version 15–16 shape kept for callers: `approved` true is
|
|
99
|
-
* {@link registryApprove} under the
|
|
108
|
+
* {@link registryApprove} under the policy's own tag as its name, false is {@link registryRevoke}.
|
|
100
109
|
*/
|
|
101
|
-
export async function setPolicyApproved(c,
|
|
102
|
-
return approved ? registryApprove(c,
|
|
110
|
+
export async function setPolicyApproved(c, policy, approved) {
|
|
111
|
+
return approved ? registryApprove(c, policy, await fPoolKindOfPolicy(c, policy)) : registryRevoke(c, policy);
|
|
103
112
|
}
|
|
104
113
|
/**
|
|
105
|
-
* Move a pool to another policy the
|
|
106
|
-
* owner's alone
|
|
107
|
-
* void; no swap lands
|
|
114
|
+
* Move a pool to another approved policy of the same kind (decisions 046, 049): the registry
|
|
115
|
+
* owner's alone, orchestrated on the registry — `migrate(manager, poolId, to)`. The new policy
|
|
116
|
+
* takes the authority and the name from the old; the operator and the lists void; no swap lands
|
|
117
|
+
* in the block.
|
|
108
118
|
*/
|
|
109
119
|
export async function fPoolMigrate(c, a) {
|
|
110
|
-
return
|
|
120
|
+
return registryWrite(c, "migrate", [c.addresses.fPoolManager, a.poolId, a.to]);
|
|
111
121
|
}
|
|
112
122
|
// ─── the policies' numbers (the collector's; each bounded where it reaches the manager) ─────
|
|
113
123
|
/** The protocol's rate on the income part of every harvest under `policy`, WAD ≤ `HARVEST_CUT_MAX`. */
|
|
@@ -122,6 +132,22 @@ export async function padSetSchedule(c, policy, s) {
|
|
|
122
132
|
export async function polSetRules(c, policy, s) {
|
|
123
133
|
return write(c, policy, polPolicyAbi, "setRules", [s.keepQuote, s.minQuoteAtSeed]);
|
|
124
134
|
}
|
|
135
|
+
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The collector's. */
|
|
136
|
+
export async function policySetQuoteListed(c, policy, quote, listed) {
|
|
137
|
+
return write(c, policy, fPolicyBaseAbi, "setQuoteListed", [quote, listed]);
|
|
138
|
+
}
|
|
139
|
+
/** `setQuoteCurated` on any protocol policy: on, a birth against an unlisted quote is refused. The collector's. */
|
|
140
|
+
export async function policySetQuoteCurated(c, policy, curated) {
|
|
141
|
+
return write(c, policy, fPolicyBaseAbi, "setQuoteCurated", [curated]);
|
|
142
|
+
}
|
|
143
|
+
/** Whether `quote` passes `policy`'s birth check now: listed, or the policy does not curate quotes. */
|
|
144
|
+
export async function policyQuoteAllowed(c, policy, quote) {
|
|
145
|
+
const [curated, listed] = await Promise.all([
|
|
146
|
+
c.public.readContract({ address: policy, abi: fPolicyBaseAbi, functionName: "quoteCurated" }),
|
|
147
|
+
c.public.readContract({ address: policy, abi: fPolicyBaseAbi, functionName: "quoteListed", args: [quote] }),
|
|
148
|
+
]);
|
|
149
|
+
return { curated, listed, allowed: !curated || listed };
|
|
150
|
+
}
|
|
125
151
|
/** `PublicPolicy.setListed`: an asset a curated seed may hold. */
|
|
126
152
|
export async function publicSetListed(c, policy, token, listed) {
|
|
127
153
|
return write(c, policy, publicPolicyAbi, "setListed", [token, listed]);
|
package/dist/client.d.ts
CHANGED
|
@@ -83,5 +83,5 @@ export declare const EXPECTED_VERSION = 4n;
|
|
|
83
83
|
* passes it; when one lands, raise this constant in the same change, which is the discipline
|
|
84
84
|
* `EXPECTED_VERSION` enforces mechanically and this one asks for.
|
|
85
85
|
*/
|
|
86
|
-
export declare const EXPECTED_F_VERSION =
|
|
86
|
+
export declare const EXPECTED_F_VERSION = 18n;
|
|
87
87
|
export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
|
package/dist/client.js
CHANGED
|
@@ -89,7 +89,7 @@ export const EXPECTED_VERSION = 4n;
|
|
|
89
89
|
// is the policy at birth, `migrate` moves a pool for the registry's owner; `stamp` / `setAsks` are
|
|
90
90
|
// the policy's; the desk's `setAllowed` / `isAllowed` are `setMinters` / `setTakers` / `isMinter` /
|
|
91
91
|
// `isTaker`; a pad and a POL hold one base (`OneBase`).
|
|
92
|
-
export const EXPECTED_F_VERSION =
|
|
92
|
+
export const EXPECTED_F_VERSION = 18n;
|
|
93
93
|
export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
94
94
|
const { cPoolManagerAbi } = await import("./generated.js");
|
|
95
95
|
const got = await c.public.readContract({
|