@logswap/sdk 0.5.48 → 0.5.50
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 +44 -4
- package/dist/admin.js +79 -8
- package/dist/client.d.ts +7 -1
- package/dist/client.js +8 -2
- package/dist/fpool.d.ts +40 -8
- package/dist/fpool.js +40 -23
- package/dist/generated.d.ts +597 -130
- package/dist/generated.js +376 -55
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/admin.ts +97 -8
- package/src/client.ts +14 -2
- package/src/fpool.ts +49 -28
- package/src/generated.ts +378 -55
- package/src/index.ts +1 -1
package/dist/admin.d.ts
CHANGED
|
@@ -17,12 +17,52 @@ export declare function setFeeParamsC(c: LogswapClient, mintFeeProtocolCutWad: b
|
|
|
17
17
|
/** The F manager's `setFeeParams(mintFeeProtocolCut)` — one cut, the C manager's shape (F version 14). */
|
|
18
18
|
export declare function setFeeParams(c: LogswapClient, mintFeeProtocolCutWad: bigint): Promise<Hash>;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* The policy registry the F manager asks at every birth — `addresses.policyRegistry` when the
|
|
21
|
+
* deployment carries it, else read once from the manager. The zero address is a deployment with
|
|
22
|
+
* no registry: it asks nobody, and nothing here can be written.
|
|
22
23
|
*/
|
|
23
|
-
export declare function
|
|
24
|
-
/** Whether `policy` is approved for pools of `kind
|
|
24
|
+
export declare function policyRegistryOf(c: LogswapClient): Promise<Address>;
|
|
25
|
+
/** Whether `policy` is approved for pools of `kind` now — listed and not yet sunset. True everywhere on a deployment with no registry. */
|
|
25
26
|
export declare function policyApproved(c: LogswapClient, kind: FPoolKind, policy: Address): Promise<boolean>;
|
|
27
|
+
/** One policy on a kind's list, as the registry holds it. */
|
|
28
|
+
export interface RegistryEntry {
|
|
29
|
+
policy: Address;
|
|
30
|
+
name: string;
|
|
31
|
+
/** The block it closes to new pools from; 0 = open. */
|
|
32
|
+
until: bigint;
|
|
33
|
+
/** Approved now: listed and not yet sunset. */
|
|
34
|
+
approved: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Every policy listed for `kind`, sunset ones included — what a create form's dropdown reads. Empty with no registry. */
|
|
37
|
+
export declare function registryPolicies(c: LogswapClient, kind: FPoolKind): Promise<RegistryEntry[]>;
|
|
38
|
+
/** The registry's owner — the LOG authority — and the proposed next one. */
|
|
39
|
+
export declare function registryOwner(c: LogswapClient): Promise<{
|
|
40
|
+
owner: Address;
|
|
41
|
+
pending: Address;
|
|
42
|
+
}>;
|
|
43
|
+
/** `PolicyRegistry.approve`: list `policy` for pools of `kind`, under `name` (at most 31 bytes). Again renames it and clears its sunset. The owner's. */
|
|
44
|
+
export declare function registryApprove(c: LogswapClient, kind: FPoolKind, policy: Address, name: string): Promise<Hash>;
|
|
45
|
+
/** `PolicyRegistry.sunset`: close `policy` to new pools of `kind` from `untilBlock` on; 0 reopens. The owner's. */
|
|
46
|
+
export declare function registrySunset(c: LogswapClient, kind: FPoolKind, policy: Address, untilBlock: bigint): Promise<Hash>;
|
|
47
|
+
/** `PolicyRegistry.revoke`: remove `policy` from `kind`'s list at once. Live pools are untouched. The owner's. */
|
|
48
|
+
export declare function registryRevoke(c: LogswapClient, kind: FPoolKind, policy: Address): Promise<Hash>;
|
|
49
|
+
/** The registry owner's two-step handover. */
|
|
50
|
+
export declare function registryProposeOwner(c: LogswapClient, next: Address): Promise<Hash>;
|
|
51
|
+
export declare function registryAcceptOwner(c: LogswapClient): Promise<Hash>;
|
|
52
|
+
/**
|
|
53
|
+
* Approve or revoke, the F version 15–16 shape kept for callers: `approved` true is
|
|
54
|
+
* {@link registryApprove} under the kind's name, false is {@link registryRevoke}.
|
|
55
|
+
*/
|
|
56
|
+
export declare function setPolicyApproved(c: LogswapClient, kind: FPoolKind, policy: Address, approved: boolean): Promise<Hash>;
|
|
57
|
+
/**
|
|
58
|
+
* Move a pool to another policy the registry approves for its kind (decisions 046): the registry
|
|
59
|
+
* owner's alone. The new policy takes the authority from the old; the operator and the lists
|
|
60
|
+
* void; no swap lands in the block.
|
|
61
|
+
*/
|
|
62
|
+
export declare function fPoolMigrate(c: LogswapClient, a: {
|
|
63
|
+
poolId: `0x${string}`;
|
|
64
|
+
to: Address;
|
|
65
|
+
}): Promise<Hash>;
|
|
26
66
|
/** The protocol's rate on the income part of every harvest under `policy`, WAD ≤ `HARVEST_CUT_MAX`. */
|
|
27
67
|
export declare function setHarvestCut(c: LogswapClient, policy: Address, rateWad: bigint): Promise<Hash>;
|
|
28
68
|
/** `PadPolicy.setSchedule`: `T(0)`, the rung's growth, the creator's and the protocol's shares of the pot (≤ `POT_CUT_MAX`), the burn per rung (≤ `BURN_MAX`). */
|
package/dist/admin.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* 044), set on the policy (`setHarvestCut`) and capped by the manager (`HARVEST_CUT_MAX`); the
|
|
10
10
|
* release's protocol share likewise (`POT_CUT_MAX`).
|
|
11
11
|
*/
|
|
12
|
-
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi, polPolicyAbi, publicPolicyAbi } from "./generated.js";
|
|
13
|
-
import { F_KIND, fPolicyBaseAbi } from "./fpool.js";
|
|
12
|
+
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, publicPolicyAbi } from "./generated.js";
|
|
13
|
+
import { F_KIND, bytes32ToText, fPolicyBaseAbi, textToBytes32 } from "./fpool.js";
|
|
14
14
|
function wallet(c) {
|
|
15
15
|
if (!c.wallet)
|
|
16
16
|
throw new Error("a wallet client is required");
|
|
@@ -27,16 +27,87 @@ export async function setFeeParamsC(c, mintFeeProtocolCutWad) {
|
|
|
27
27
|
export async function setFeeParams(c, mintFeeProtocolCutWad) {
|
|
28
28
|
return write(c, c.addresses.fPoolManager, fPoolManagerAbi, "setFeeParams", [mintFeeProtocolCutWad]);
|
|
29
29
|
}
|
|
30
|
+
// ─── the registry (decisions 046): the LOG authority's, not the collector's ─────────────────
|
|
31
|
+
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
+
* The policy registry the F manager asks at every birth — `addresses.policyRegistry` when the
|
|
34
|
+
* deployment carries it, else read once from the manager. The zero address is a deployment with
|
|
35
|
+
* no registry: it asks nobody, and nothing here can be written.
|
|
33
36
|
*/
|
|
34
|
-
export async function
|
|
35
|
-
|
|
37
|
+
export async function policyRegistryOf(c) {
|
|
38
|
+
if (c.addresses.policyRegistry)
|
|
39
|
+
return c.addresses.policyRegistry;
|
|
40
|
+
return (await c.public.readContract({ address: c.addresses.fPoolManager, abi: fPoolManagerAbi, functionName: "registry" }));
|
|
36
41
|
}
|
|
37
|
-
/** Whether `policy` is approved for pools of `kind
|
|
42
|
+
/** Whether `policy` is approved for pools of `kind` now — listed and not yet sunset. True everywhere on a deployment with no registry. */
|
|
38
43
|
export async function policyApproved(c, kind, policy) {
|
|
39
|
-
|
|
44
|
+
const registry = await policyRegistryOf(c);
|
|
45
|
+
if (registry === ZERO)
|
|
46
|
+
return true;
|
|
47
|
+
return c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "isApproved", args: [F_KIND[kind], policy] });
|
|
48
|
+
}
|
|
49
|
+
/** Every policy listed for `kind`, sunset ones included — what a create form's dropdown reads. Empty with no registry. */
|
|
50
|
+
export async function registryPolicies(c, kind) {
|
|
51
|
+
const registry = await policyRegistryOf(c);
|
|
52
|
+
if (registry === ZERO)
|
|
53
|
+
return [];
|
|
54
|
+
const list = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "policiesOf", args: [F_KIND[kind]] }));
|
|
55
|
+
const block = await c.public.getBlockNumber();
|
|
56
|
+
return Promise.all(list.map(async (policy) => {
|
|
57
|
+
const [listed, until, , name] = (await c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "entries", args: [F_KIND[kind], policy] }));
|
|
58
|
+
return { policy, name: bytes32ToText(name), until, approved: listed && (until === 0n || block < until) };
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/** The registry's owner — the LOG authority — and the proposed next one. */
|
|
62
|
+
export async function registryOwner(c) {
|
|
63
|
+
const registry = await policyRegistryOf(c);
|
|
64
|
+
if (registry === ZERO)
|
|
65
|
+
return { owner: ZERO, pending: ZERO };
|
|
66
|
+
const [owner, pending] = await Promise.all([
|
|
67
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "owner" }),
|
|
68
|
+
c.public.readContract({ address: registry, abi: policyRegistryAbi, functionName: "pendingOwner" }),
|
|
69
|
+
]);
|
|
70
|
+
return { owner, pending };
|
|
71
|
+
}
|
|
72
|
+
async function registryWrite(c, functionName, args) {
|
|
73
|
+
const registry = await policyRegistryOf(c);
|
|
74
|
+
if (registry === ZERO)
|
|
75
|
+
throw new Error("logswap: this deployment carries no policy registry");
|
|
76
|
+
return write(c, registry, policyRegistryAbi, functionName, args);
|
|
77
|
+
}
|
|
78
|
+
/** `PolicyRegistry.approve`: list `policy` for pools of `kind`, under `name` (at most 31 bytes). Again renames it and clears its sunset. The owner's. */
|
|
79
|
+
export async function registryApprove(c, kind, policy, name) {
|
|
80
|
+
return registryWrite(c, "approve", [F_KIND[kind], policy, textToBytes32(name)]);
|
|
81
|
+
}
|
|
82
|
+
/** `PolicyRegistry.sunset`: close `policy` to new pools of `kind` from `untilBlock` on; 0 reopens. The owner's. */
|
|
83
|
+
export async function registrySunset(c, kind, policy, untilBlock) {
|
|
84
|
+
return registryWrite(c, "sunset", [F_KIND[kind], policy, untilBlock]);
|
|
85
|
+
}
|
|
86
|
+
/** `PolicyRegistry.revoke`: remove `policy` from `kind`'s list at once. Live pools are untouched. The owner's. */
|
|
87
|
+
export async function registryRevoke(c, kind, policy) {
|
|
88
|
+
return registryWrite(c, "revoke", [F_KIND[kind], policy]);
|
|
89
|
+
}
|
|
90
|
+
/** The registry owner's two-step handover. */
|
|
91
|
+
export async function registryProposeOwner(c, next) {
|
|
92
|
+
return registryWrite(c, "proposeOwner", [next]);
|
|
93
|
+
}
|
|
94
|
+
export async function registryAcceptOwner(c) {
|
|
95
|
+
return registryWrite(c, "acceptOwner", []);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Approve or revoke, the F version 15–16 shape kept for callers: `approved` true is
|
|
99
|
+
* {@link registryApprove} under the kind's name, false is {@link registryRevoke}.
|
|
100
|
+
*/
|
|
101
|
+
export async function setPolicyApproved(c, kind, policy, approved) {
|
|
102
|
+
return approved ? registryApprove(c, kind, policy, kind) : registryRevoke(c, kind, policy);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Move a pool to another policy the registry approves for its kind (decisions 046): the registry
|
|
106
|
+
* owner's alone. The new policy takes the authority from the old; the operator and the lists
|
|
107
|
+
* void; no swap lands in the block.
|
|
108
|
+
*/
|
|
109
|
+
export async function fPoolMigrate(c, a) {
|
|
110
|
+
return write(c, c.addresses.fPoolManager, fPoolManagerAbi, "migrate", [a.poolId, a.to]);
|
|
40
111
|
}
|
|
41
112
|
// ─── the policies' numbers (the collector's; each bounded where it reaches the manager) ─────
|
|
42
113
|
/** The protocol's rate on the income part of every harvest under `policy`, WAD ≤ `HARVEST_CUT_MAX`. */
|
package/dist/client.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ export interface LogswapAddresses {
|
|
|
29
29
|
privatePolicy?: Address;
|
|
30
30
|
polPolicy?: Address;
|
|
31
31
|
padPolicy?: Address;
|
|
32
|
+
/**
|
|
33
|
+
* The policy registry (decisions 046): what a pool of each kind may be born under, and the
|
|
34
|
+
* owner that may move a pool between policies. Read from the F manager (`registry()`) when
|
|
35
|
+
* absent; a deployment with none asks nobody.
|
|
36
|
+
*/
|
|
37
|
+
policyRegistry?: Address;
|
|
32
38
|
/** Optional — the router falls back to plain approvals when absent. */
|
|
33
39
|
permit2?: Address;
|
|
34
40
|
}
|
|
@@ -77,5 +83,5 @@ export declare const EXPECTED_VERSION = 4n;
|
|
|
77
83
|
* passes it; when one lands, raise this constant in the same change, which is the discipline
|
|
78
84
|
* `EXPECTED_VERSION` enforces mechanically and this one asks for.
|
|
79
85
|
*/
|
|
80
|
-
export declare const EXPECTED_F_VERSION =
|
|
86
|
+
export declare const EXPECTED_F_VERSION = 17n;
|
|
81
87
|
export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
|
package/dist/client.js
CHANGED
|
@@ -77,13 +77,19 @@ export const EXPECTED_VERSION = 4n;
|
|
|
77
77
|
// 15 (2026-09-20): the policy answers every question (decisions 044) — `FPoolKey.authority` is
|
|
78
78
|
// `creator` (every pool id moves again); the roles, gates and list are the pool's POLICY's
|
|
79
79
|
// (`FPolicyBase` / `PrivatePolicy`), not the manager's: `getPool` has `policy` and `asks` and no
|
|
80
|
-
// role; `proposeAuthority`, `appointOperator`, `setGates`, `setAllowed` are policy writes;
|
|
80
|
+
// role; `proposeAuthority`, `appointOperator`, `setGates`, `setAllowed` (`setMinters` / `setTakers` since 17) are policy writes;
|
|
81
81
|
// `policyApproved(kind, policy)` / `setPolicyApproved(kind, policy, ok)`; `Regenerated` names the payee;
|
|
82
82
|
// `HARVEST_CUT_MAX` / `POT_CUT_MAX` cap what a policy may route to the protocol.
|
|
83
83
|
// 16 (2026-09-21): the word is POLICY (decisions 045) — a rename, no pool id moves: `FPoolKey.policy`,
|
|
84
84
|
// `IFPolicy`, `FPolicyBase`, `PublicPolicy` … `PadPolicy`, `policyApproved` / `setPolicyApproved`,
|
|
85
85
|
// `PolicyApproved`; `PolPolicy.setPolicy` / `PolicySet` are `setRules` / `RulesSet`.
|
|
86
|
-
|
|
86
|
+
// 17 (2026-09-21): the registry, the move, the stamp, two lists, one base (decisions 046–048) — no
|
|
87
|
+
// pool id moves: the F manager takes a `PolicyRegistry` at construction and asks it at a birth
|
|
88
|
+
// (`policyApproved` / `setPolicyApproved` left the manager: `registryApprove` …); the key's policy
|
|
89
|
+
// is the policy at birth, `migrate` moves a pool for the registry's owner; `stamp` / `setAsks` are
|
|
90
|
+
// the policy's; the desk's `setAllowed` / `isAllowed` are `setMinters` / `setTakers` / `isMinter` /
|
|
91
|
+
// `isTaker`; a pad and a POL hold one base (`OneBase`).
|
|
92
|
+
export const EXPECTED_F_VERSION = 17n;
|
|
87
93
|
export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
88
94
|
const { cPoolManagerAbi } = await import("./generated.js");
|
|
89
95
|
const got = await c.public.readContract({
|
package/dist/fpool.d.ts
CHANGED
|
@@ -301,6 +301,24 @@ export declare const fPolicyBaseAbi: readonly [{
|
|
|
301
301
|
readonly type: "uint8";
|
|
302
302
|
}];
|
|
303
303
|
readonly stateMutability: "nonpayable";
|
|
304
|
+
}, {
|
|
305
|
+
readonly type: "function";
|
|
306
|
+
readonly inputs: readonly [{
|
|
307
|
+
readonly name: "poolId";
|
|
308
|
+
readonly internalType: "bytes32";
|
|
309
|
+
readonly type: "bytes32";
|
|
310
|
+
}, {
|
|
311
|
+
readonly name: "from";
|
|
312
|
+
readonly internalType: "address";
|
|
313
|
+
readonly type: "address";
|
|
314
|
+
}];
|
|
315
|
+
readonly name: "onMigrate";
|
|
316
|
+
readonly outputs: readonly [{
|
|
317
|
+
readonly name: "";
|
|
318
|
+
readonly internalType: "uint8";
|
|
319
|
+
readonly type: "uint8";
|
|
320
|
+
}];
|
|
321
|
+
readonly stateMutability: "nonpayable";
|
|
304
322
|
}, {
|
|
305
323
|
readonly type: "function";
|
|
306
324
|
readonly inputs: readonly [{
|
|
@@ -1044,9 +1062,9 @@ export declare function fPoolLaunchCalls(poolId: Hex, a: FPoolLaunchArgs & ({
|
|
|
1044
1062
|
x0: bigint[];
|
|
1045
1063
|
})): Hex[];
|
|
1046
1064
|
/**
|
|
1047
|
-
* The desk's opening posture, on its policy (decisions 044): gated minting, the creator
|
|
1048
|
-
* appointment: the authority is the operator until one is appointed (decisions 037).
|
|
1049
|
-
* to `PrivatePolicy`; the launch batch cannot carry them (they are not manager calls).
|
|
1065
|
+
* The desk's opening posture, on its policy (decisions 044, 048): gated minting, the creator a
|
|
1066
|
+
* minter. No appointment: the authority is the operator until one is appointed (decisions 037).
|
|
1067
|
+
* Two writes to `PrivatePolicy`; the launch batch cannot carry them (they are not manager calls).
|
|
1050
1068
|
*/
|
|
1051
1069
|
export declare function fPoolDeskOpening(c: LogswapClient, a: {
|
|
1052
1070
|
poolId: Hex;
|
|
@@ -1108,17 +1126,31 @@ export declare function fPoolSetGates(c: LogswapClient, a: {
|
|
|
1108
1126
|
policy?: Address;
|
|
1109
1127
|
}): Promise<`0x${string}`>;
|
|
1110
1128
|
/**
|
|
1111
|
-
* Add to or remove from the pool's
|
|
1112
|
-
*
|
|
1129
|
+
* Add to or remove from the pool's MINTERS — who may mint, and swap (a zap in is both under one
|
|
1130
|
+
* lock) — in one call (the authority, on the desk's policy; decisions 048). The list is keyed by
|
|
1131
|
+
* the authority that granted it: a handover starts the buyer with an empty one. Stamps the
|
|
1132
|
+
* block: no swap lands in it (047).
|
|
1113
1133
|
*/
|
|
1114
|
-
export declare function
|
|
1134
|
+
export declare function fPoolSetMinters(c: LogswapClient, a: {
|
|
1135
|
+
poolId: Hex;
|
|
1136
|
+
who: readonly Address[];
|
|
1137
|
+
allowed: boolean;
|
|
1138
|
+
account: Address;
|
|
1139
|
+
policy?: Address;
|
|
1140
|
+
}): Promise<`0x${string}`>;
|
|
1141
|
+
/** Add to or remove from the pool's TAKERS — who may swap only — in one call (the authority; decisions 048). Stamps the block. */
|
|
1142
|
+
export declare function fPoolSetTakers(c: LogswapClient, a: {
|
|
1115
1143
|
poolId: Hex;
|
|
1116
1144
|
who: readonly Address[];
|
|
1117
1145
|
allowed: boolean;
|
|
1118
1146
|
account: Address;
|
|
1119
1147
|
policy?: Address;
|
|
1120
1148
|
}): Promise<`0x${string}`>;
|
|
1121
|
-
/**
|
|
1149
|
+
/** On the pool's minters under its current authority: may mint, and swap. */
|
|
1150
|
+
export declare function fPoolIsMinter(c: LogswapClient, poolId: Hex, who: Address, policy?: Address): Promise<boolean>;
|
|
1151
|
+
/** On the pool's takers under its current authority: may swap only. */
|
|
1152
|
+
export declare function fPoolIsTaker(c: LogswapClient, poolId: Hex, who: Address, policy?: Address): Promise<boolean>;
|
|
1153
|
+
/** May swap: a minter or a taker (consulted only while the swap gate is on). */
|
|
1122
1154
|
export declare function fPoolIsAllowed(c: LogswapClient, poolId: Hex, who: Address, policy?: Address): Promise<boolean>;
|
|
1123
1155
|
/** Label the pool — the sponsor's own words, mutable, never identity. At most 31 bytes of UTF-8. */
|
|
1124
1156
|
export declare function fPoolSetName(c: LogswapClient, a: {
|
|
@@ -1189,7 +1221,7 @@ export interface DiscoveredFPool {
|
|
|
1189
1221
|
weights: bigint[];
|
|
1190
1222
|
phi: bigint;
|
|
1191
1223
|
kind: FPoolKind;
|
|
1192
|
-
/** The pool's policy — the contract the key names (decisions 041, 044, 045). */
|
|
1224
|
+
/** The pool's policy AT BIRTH — the contract the key names (decisions 041, 044, 045). The LIVE one is {@link getFPool}'s `policy`: the registry's owner may have moved the pool (046, `PolicyMigrated`). */
|
|
1193
1225
|
policy: Address;
|
|
1194
1226
|
/** Who was born holding the pool (immutable). The LIVE authority is the policy's — {@link getFPoolRoles}. */
|
|
1195
1227
|
creator: Address;
|
package/dist/fpool.js
CHANGED
|
@@ -791,15 +791,15 @@ export function fPoolLaunchCalls(poolId, a) {
|
|
|
791
791
|
return calls;
|
|
792
792
|
}
|
|
793
793
|
/**
|
|
794
|
-
* The desk's opening posture, on its policy (decisions 044): gated minting, the creator
|
|
795
|
-
* appointment: the authority is the operator until one is appointed (decisions 037).
|
|
796
|
-
* to `PrivatePolicy`; the launch batch cannot carry them (they are not manager calls).
|
|
794
|
+
* The desk's opening posture, on its policy (decisions 044, 048): gated minting, the creator a
|
|
795
|
+
* minter. No appointment: the authority is the operator until one is appointed (decisions 037).
|
|
796
|
+
* Two writes to `PrivatePolicy`; the launch batch cannot carry them (they are not manager calls).
|
|
797
797
|
*/
|
|
798
798
|
export async function fPoolDeskOpening(c, a) {
|
|
799
799
|
const policy = a.policy ?? fPoolPolicyFor(c, "private");
|
|
800
800
|
return [
|
|
801
801
|
await fPoolSetGates(c, { poolId: a.poolId, gateMint: true, gateSwap: false, account: a.account, policy }),
|
|
802
|
-
await
|
|
802
|
+
await fPoolSetMinters(c, { poolId: a.poolId, who: [a.account], allowed: true, account: a.account, policy }),
|
|
803
803
|
];
|
|
804
804
|
}
|
|
805
805
|
/**
|
|
@@ -864,21 +864,33 @@ export async function fPoolSetGates(c, a) {
|
|
|
864
864
|
return writePolicy(c, privatePolicyAbi, a, "setGates", [a.gateMint, a.gateSwap]);
|
|
865
865
|
}
|
|
866
866
|
/**
|
|
867
|
-
* Add to or remove from the pool's
|
|
868
|
-
*
|
|
867
|
+
* Add to or remove from the pool's MINTERS — who may mint, and swap (a zap in is both under one
|
|
868
|
+
* lock) — in one call (the authority, on the desk's policy; decisions 048). The list is keyed by
|
|
869
|
+
* the authority that granted it: a handover starts the buyer with an empty one. Stamps the
|
|
870
|
+
* block: no swap lands in it (047).
|
|
869
871
|
*/
|
|
870
|
-
export async function
|
|
871
|
-
return writePolicy(c, privatePolicyAbi, a, "
|
|
872
|
+
export async function fPoolSetMinters(c, a) {
|
|
873
|
+
return writePolicy(c, privatePolicyAbi, a, "setMinters", [a.who, a.allowed]);
|
|
872
874
|
}
|
|
873
|
-
/**
|
|
874
|
-
export async function
|
|
875
|
+
/** Add to or remove from the pool's TAKERS — who may swap only — in one call (the authority; decisions 048). Stamps the block. */
|
|
876
|
+
export async function fPoolSetTakers(c, a) {
|
|
877
|
+
return writePolicy(c, privatePolicyAbi, a, "setTakers", [a.who, a.allowed]);
|
|
878
|
+
}
|
|
879
|
+
async function readDesk(c, poolId, who, functionName, policy) {
|
|
875
880
|
const address = policy ?? (await fPoolPolicyOf(c, poolId));
|
|
876
|
-
return (await c.public.readContract({
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
881
|
+
return (await c.public.readContract({ address, abi: privatePolicyAbi, functionName, args: [poolId, who] }));
|
|
882
|
+
}
|
|
883
|
+
/** On the pool's minters under its current authority: may mint, and swap. */
|
|
884
|
+
export async function fPoolIsMinter(c, poolId, who, policy) {
|
|
885
|
+
return readDesk(c, poolId, who, "isMinter", policy);
|
|
886
|
+
}
|
|
887
|
+
/** On the pool's takers under its current authority: may swap only. */
|
|
888
|
+
export async function fPoolIsTaker(c, poolId, who, policy) {
|
|
889
|
+
return readDesk(c, poolId, who, "isTaker", policy);
|
|
890
|
+
}
|
|
891
|
+
/** May swap: a minter or a taker (consulted only while the swap gate is on). */
|
|
892
|
+
export async function fPoolIsAllowed(c, poolId, who, policy) {
|
|
893
|
+
return readDesk(c, poolId, who, "isAllowed", policy);
|
|
882
894
|
}
|
|
883
895
|
/** Label the pool — the sponsor's own words, mutable, never identity. At most 31 bytes of UTF-8. */
|
|
884
896
|
export async function fPoolSetName(c, a) {
|
|
@@ -1035,14 +1047,19 @@ export async function getFPoolRules(c, s, roles) {
|
|
|
1035
1047
|
*/
|
|
1036
1048
|
export async function fPoolsControlledBy(c, who, opts = {}) {
|
|
1037
1049
|
const pools = opts.pools ?? (await discoverFPools(c, { fromBlock: opts.fromBlock }));
|
|
1038
|
-
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1050
|
+
// the LIVE policy answers for the authority: a moved pool (046) is on another one than its birth's
|
|
1051
|
+
const states = await Promise.all(pools.map((p) => getFPool(c, p.poolId)));
|
|
1052
|
+
const authorities = await Promise.all(states.map((s) => c.public.readContract({ address: s.policy, abi: fPolicyBaseAbi, functionName: "authority", args: [s.poolId] })));
|
|
1053
|
+
const out = [];
|
|
1054
|
+
for (let i = 0; i < pools.length; ++i) {
|
|
1055
|
+
if (authorities[i].toLowerCase() !== who.toLowerCase())
|
|
1056
|
+
continue;
|
|
1057
|
+
const state = states[i];
|
|
1058
|
+
const roles = await getFPoolRoles(c, state.poolId, state);
|
|
1043
1059
|
const rules = await getFPoolRules(c, state, roles);
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1060
|
+
out.push({ pool: pools[i], roles, state, rules });
|
|
1061
|
+
}
|
|
1062
|
+
return out;
|
|
1046
1063
|
}
|
|
1047
1064
|
/**
|
|
1048
1065
|
* Every holder of a pool's shares, from the ERC-6909 Transfer stream — the id is an indexed
|