@logswap/sdk 0.5.69 → 0.5.70
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 +11 -7
- package/dist/admin.js +16 -8
- package/dist/client.d.ts +1 -1
- package/dist/client.js +3 -1
- package/dist/fpool.d.ts +32 -94
- package/dist/fpool.js +48 -12
- package/dist/generated.d.ts +110 -349
- package/dist/generated.js +83 -240
- package/package.json +1 -1
- package/src/admin.ts +25 -10
- package/src/client.ts +3 -1
- package/src/fpool.ts +64 -18
- package/src/generated.ts +83 -240
package/dist/admin.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* One vocabulary: both managers call the protocol's cut of the mint fee
|
|
8
8
|
* `MINT_FEE_PROTOCOL_CUT`; C sets it through `setFeeParams(uint256)`, F holds it as a constant
|
|
9
9
|
* (049). The harvest's cut is the policy's answer at every harvest, set on the
|
|
10
|
-
* policy (`
|
|
10
|
+
* policy (`PadPolicy.setSchedule`: the protocol's pot share and the ranges a creator chooses inside) and capped by the manager (`POT_CUT_MAX`, `BURN_MAX`; a harvest has no cut, decisions 056); the release's
|
|
11
11
|
* protocol share likewise (`POT_CUT_MAX`).
|
|
12
12
|
*/
|
|
13
13
|
import type { Address, Hash } from "viem";
|
|
@@ -89,17 +89,21 @@ export declare function fPoolMigrate(c: LogswapClient, a: {
|
|
|
89
89
|
* answer. "" for a policy the registry never approved (or a deployment with no registry).
|
|
90
90
|
*/
|
|
91
91
|
export declare function registryKindOf(c: LogswapClient, policy: Address): Promise<FPoolKind | "">;
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
/**
|
|
93
|
+
* `PadPolicy.setSchedule` (decisions 056): `T(0)`, the rung's growth, the protocol's share of the pot (≤ `POT_CUT_MAX`,
|
|
94
|
+
* recorded into each pad at birth), and the RANGES a creator chooses inside at creation — his cut of the pot and the burn per
|
|
95
|
+
* rung (≤ `BURN_MAX`). A change applies to pads born after it. The rung is the pool's generation since F version 21.
|
|
96
|
+
*/
|
|
95
97
|
export declare function padSetSchedule(c: LogswapClient, policy: Address, s: {
|
|
96
98
|
thresholdBase: bigint;
|
|
97
99
|
thresholdGrowth: bigint;
|
|
98
|
-
creatorShare: bigint;
|
|
99
100
|
protocolShare: bigint;
|
|
100
|
-
|
|
101
|
+
creatorShareMin: bigint;
|
|
102
|
+
creatorShareMax: bigint;
|
|
103
|
+
burnMin: bigint;
|
|
104
|
+
burnMax: bigint;
|
|
101
105
|
}): Promise<Hash>;
|
|
102
|
-
/** `PolPolicy.setRules`:
|
|
106
|
+
/** `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. */
|
|
103
107
|
export declare function polSetRules(c: LogswapClient, policy: Address, s: {
|
|
104
108
|
keepQuote: bigint;
|
|
105
109
|
minQuoteAtSeed: bigint;
|
package/dist/admin.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* One vocabulary: both managers call the protocol's cut of the mint fee
|
|
8
8
|
* `MINT_FEE_PROTOCOL_CUT`; C sets it through `setFeeParams(uint256)`, F holds it as a constant
|
|
9
9
|
* (049). The harvest's cut is the policy's answer at every harvest, set on the
|
|
10
|
-
* policy (`
|
|
10
|
+
* policy (`PadPolicy.setSchedule`: the protocol's pot share and the ranges a creator chooses inside) and capped by the manager (`POT_CUT_MAX`, `BURN_MAX`; a harvest has no cut, decisions 056); the release's
|
|
11
11
|
* protocol share likewise (`POT_CUT_MAX`).
|
|
12
12
|
*/
|
|
13
13
|
import { cPoolManagerAbi, fPoolManagerAbi, padPolicyAbi, polPolicyAbi, policyRegistryAbi, publicPolicyAbi } from "./generated.js";
|
|
@@ -140,15 +140,23 @@ export async function registryKindOf(c, policy) {
|
|
|
140
140
|
return bytes32ToText(word);
|
|
141
141
|
}
|
|
142
142
|
// ─── the policies' numbers (the collector's; each bounded where it reaches the manager) ─────
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
/**
|
|
144
|
+
* `PadPolicy.setSchedule` (decisions 056): `T(0)`, the rung's growth, the protocol's share of the pot (≤ `POT_CUT_MAX`,
|
|
145
|
+
* recorded into each pad at birth), and the RANGES a creator chooses inside at creation — his cut of the pot and the burn per
|
|
146
|
+
* rung (≤ `BURN_MAX`). A change applies to pads born after it. The rung is the pool's generation since F version 21.
|
|
147
|
+
*/
|
|
148
148
|
export async function padSetSchedule(c, policy, s) {
|
|
149
|
-
return write(c, policy, padPolicyAbi, "setSchedule", [
|
|
149
|
+
return write(c, policy, padPolicyAbi, "setSchedule", [
|
|
150
|
+
s.thresholdBase,
|
|
151
|
+
s.thresholdGrowth,
|
|
152
|
+
s.protocolShare,
|
|
153
|
+
s.creatorShareMin,
|
|
154
|
+
s.creatorShareMax,
|
|
155
|
+
s.burnMin,
|
|
156
|
+
s.burnMax,
|
|
157
|
+
]);
|
|
150
158
|
}
|
|
151
|
-
/** `PolPolicy.setRules`:
|
|
159
|
+
/** `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. */
|
|
152
160
|
export async function polSetRules(c, policy, s) {
|
|
153
161
|
return write(c, policy, polPolicyAbi, "setRules", [s.keepQuote, s.minQuoteAtSeed]);
|
|
154
162
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare const EXPECTED_VERSION = 5n;
|
|
|
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 = 23n;
|
|
87
87
|
export declare function assertVersion(c: LogswapClient, expected?: bigint): Promise<void>;
|
|
88
88
|
/**
|
|
89
89
|
* The versions say the managers are the right code; this says the rest of the addresses belong
|
package/dist/client.js
CHANGED
|
@@ -133,7 +133,9 @@ export const EXPECTED_VERSION = 5n;
|
|
|
133
133
|
// (the bid: `getPool().Q` when L > 0), `idOf(FPoolKey)` (hashed locally, `fPoolIdOfKey`) and
|
|
134
134
|
// `reserveOf` (`legOf`'s fourth word). `PadPolicy.rung` is gone: the pad's rung is `gen`, the
|
|
135
135
|
// next threshold `threshold(gen)`. A pad never retires; a public pool refuses `regenerate`.
|
|
136
|
-
|
|
136
|
+
// 23: a harvest asks `may(Harvest)` and takes no terms and no cut (decisions 056): `onHarvest`, `HARVEST_CUT_MAX`,
|
|
137
|
+
// `harvestCut`, `setHarvestCut` are gone; a pad's split (creator's cut, token burn) rides in the key's salt.
|
|
138
|
+
export const EXPECTED_F_VERSION = 23n;
|
|
137
139
|
export async function assertVersion(c, expected = EXPECTED_VERSION) {
|
|
138
140
|
const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
|
|
139
141
|
// three independent reads: one round trip, not three in a row
|
package/dist/fpool.d.ts
CHANGED
|
@@ -40,8 +40,8 @@ import { fPoolManagerAbi, padPolicyAbi, polPolicyAbi, privatePolicyAbi, publicPo
|
|
|
40
40
|
*/
|
|
41
41
|
export { fPoolManagerAbi, padPolicyAbi, polPolicyAbi, privatePolicyAbi, publicPolicyAbi };
|
|
42
42
|
/**
|
|
43
|
-
* What every protocol policy shares (`FPolicyBase`): the roles and their handover
|
|
44
|
-
* `maxHarvest
|
|
43
|
+
* What every protocol policy shares (`FPolicyBase`): the roles and their handover and the
|
|
44
|
+
* `maxHarvest` readout (a harvest has no cut, decisions 056). `polPolicyAbi` is a superset of it and carries nothing that collides, so it stands
|
|
45
45
|
* in for the base — a call through it to any of the four policies decodes the base's functions.
|
|
46
46
|
*/
|
|
47
47
|
export declare const fPolicyBaseAbi: readonly [{
|
|
@@ -90,16 +90,6 @@ export declare const fPolicyBaseAbi: readonly [{
|
|
|
90
90
|
readonly type: "address";
|
|
91
91
|
}];
|
|
92
92
|
readonly stateMutability: "view";
|
|
93
|
-
}, {
|
|
94
|
-
readonly type: "function";
|
|
95
|
-
readonly inputs: readonly [];
|
|
96
|
-
readonly name: "harvestCut";
|
|
97
|
-
readonly outputs: readonly [{
|
|
98
|
-
readonly name: "";
|
|
99
|
-
readonly internalType: "uint256";
|
|
100
|
-
readonly type: "uint256";
|
|
101
|
-
}];
|
|
102
|
-
readonly stateMutability: "view";
|
|
103
93
|
}, {
|
|
104
94
|
readonly type: "function";
|
|
105
95
|
readonly inputs: readonly [];
|
|
@@ -219,61 +209,6 @@ export declare const fPolicyBaseAbi: readonly [{
|
|
|
219
209
|
readonly type: "bytes32";
|
|
220
210
|
}];
|
|
221
211
|
readonly stateMutability: "view";
|
|
222
|
-
}, {
|
|
223
|
-
readonly type: "function";
|
|
224
|
-
readonly inputs: readonly [{
|
|
225
|
-
readonly name: "a";
|
|
226
|
-
readonly internalType: "struct IFPolicy.Ask";
|
|
227
|
-
readonly type: "tuple";
|
|
228
|
-
readonly components: readonly [{
|
|
229
|
-
readonly name: "poolId";
|
|
230
|
-
readonly internalType: "bytes32";
|
|
231
|
-
readonly type: "bytes32";
|
|
232
|
-
}, {
|
|
233
|
-
readonly name: "gen";
|
|
234
|
-
readonly internalType: "uint256";
|
|
235
|
-
readonly type: "uint256";
|
|
236
|
-
}, {
|
|
237
|
-
readonly name: "action";
|
|
238
|
-
readonly internalType: "enum IFPolicy.Action";
|
|
239
|
-
readonly type: "uint8";
|
|
240
|
-
}, {
|
|
241
|
-
readonly name: "who";
|
|
242
|
-
readonly internalType: "address";
|
|
243
|
-
readonly type: "address";
|
|
244
|
-
}, {
|
|
245
|
-
readonly name: "amount";
|
|
246
|
-
readonly internalType: "uint256";
|
|
247
|
-
readonly type: "uint256";
|
|
248
|
-
}, {
|
|
249
|
-
readonly name: "income";
|
|
250
|
-
readonly internalType: "uint256";
|
|
251
|
-
readonly type: "uint256";
|
|
252
|
-
}, {
|
|
253
|
-
readonly name: "Q";
|
|
254
|
-
readonly internalType: "uint256";
|
|
255
|
-
readonly type: "uint256";
|
|
256
|
-
}, {
|
|
257
|
-
readonly name: "L";
|
|
258
|
-
readonly internalType: "uint256";
|
|
259
|
-
readonly type: "uint256";
|
|
260
|
-
}, {
|
|
261
|
-
readonly name: "n";
|
|
262
|
-
readonly internalType: "uint256";
|
|
263
|
-
readonly type: "uint256";
|
|
264
|
-
}];
|
|
265
|
-
}];
|
|
266
|
-
readonly name: "onHarvest";
|
|
267
|
-
readonly outputs: readonly [{
|
|
268
|
-
readonly name: "amount";
|
|
269
|
-
readonly internalType: "uint256";
|
|
270
|
-
readonly type: "uint256";
|
|
271
|
-
}, {
|
|
272
|
-
readonly name: "cut";
|
|
273
|
-
readonly internalType: "uint256";
|
|
274
|
-
readonly type: "uint256";
|
|
275
|
-
}];
|
|
276
|
-
readonly stateMutability: "view";
|
|
277
212
|
}, {
|
|
278
213
|
readonly type: "function";
|
|
279
214
|
readonly inputs: readonly [{
|
|
@@ -475,16 +410,6 @@ export declare const fPolicyBaseAbi: readonly [{
|
|
|
475
410
|
readonly type: "bool";
|
|
476
411
|
}];
|
|
477
412
|
readonly stateMutability: "view";
|
|
478
|
-
}, {
|
|
479
|
-
readonly type: "function";
|
|
480
|
-
readonly inputs: readonly [{
|
|
481
|
-
readonly name: "_harvestCut";
|
|
482
|
-
readonly internalType: "uint256";
|
|
483
|
-
readonly type: "uint256";
|
|
484
|
-
}];
|
|
485
|
-
readonly name: "setHarvestCut";
|
|
486
|
-
readonly outputs: readonly [];
|
|
487
|
-
readonly stateMutability: "nonpayable";
|
|
488
413
|
}, {
|
|
489
414
|
readonly type: "function";
|
|
490
415
|
readonly inputs: readonly [{
|
|
@@ -577,16 +502,6 @@ export declare const fPolicyBaseAbi: readonly [{
|
|
|
577
502
|
readonly indexed: true;
|
|
578
503
|
}];
|
|
579
504
|
readonly name: "AuthoritySet";
|
|
580
|
-
}, {
|
|
581
|
-
readonly type: "event";
|
|
582
|
-
readonly anonymous: false;
|
|
583
|
-
readonly inputs: readonly [{
|
|
584
|
-
readonly name: "harvestCut";
|
|
585
|
-
readonly internalType: "uint256";
|
|
586
|
-
readonly type: "uint256";
|
|
587
|
-
readonly indexed: false;
|
|
588
|
-
}];
|
|
589
|
-
readonly name: "HarvestCutSet";
|
|
590
505
|
}, {
|
|
591
506
|
readonly type: "event";
|
|
592
507
|
readonly anonymous: false;
|
|
@@ -1150,7 +1065,7 @@ export declare function fPoolIdOf(c: LogswapClient, a: Omit<FPoolCreateArgs, "ac
|
|
|
1150
1065
|
/**
|
|
1151
1066
|
* Rebuild a live pool's KEY from its id: the `FInitialize` log carries every field but the salt,
|
|
1152
1067
|
* which is taken from `opts.salt` (zero by default — every pool the SDK's create flow makes
|
|
1153
|
-
* without naming one). The result is checked against the id, so a wrong salt throws rather than
|
|
1068
|
+
* without naming one; a pad's carries its split, so it is rebuilt from the policy's record with nonce 0 — pass `opts.salt` for another nonce). The result is checked against the id, so a wrong salt throws rather than
|
|
1154
1069
|
* returning a key that names another pool. What {@link fPoolMigrate} needs when handed an id.
|
|
1155
1070
|
*/
|
|
1156
1071
|
export declare function fPoolKeyOfPool(c: LogswapClient, poolId: Hex, opts?: {
|
|
@@ -1578,7 +1493,6 @@ export interface FPoolControlled {
|
|
|
1578
1493
|
/** What a pool's policy says about it, by kind: the terms a buyer reads before entering. */
|
|
1579
1494
|
export type FPoolRules = {
|
|
1580
1495
|
kind: "pad";
|
|
1581
|
-
harvestCut: bigint;
|
|
1582
1496
|
/** The pad's graduation count: the pool's generation (F version 21 — `PadPolicy.rung` is gone). */
|
|
1583
1497
|
gen: number;
|
|
1584
1498
|
/** @deprecated Equal to {@link gen} since F version 21, kept for callers; read `gen`. */
|
|
@@ -1586,25 +1500,50 @@ export type FPoolRules = {
|
|
|
1586
1500
|
/** The pot the next graduation needs: `PadPolicy.threshold(gen)`. */
|
|
1587
1501
|
threshold: bigint;
|
|
1588
1502
|
pot: bigint;
|
|
1503
|
+
/** This pad's split, recorded at its birth from the key's salt and never changed (decisions 056): the creator's cut of the pot, the protocol's, and the burn per rung. The rest of the pot is bought in. */
|
|
1589
1504
|
creatorShare: bigint;
|
|
1590
1505
|
protocolShare: bigint;
|
|
1591
1506
|
burnPerRung: bigint;
|
|
1507
|
+
/** The ranges the collector's policy holds NOW for the pads born after this read: what a new creator may choose. */
|
|
1508
|
+
ranges: PadRanges;
|
|
1592
1509
|
} | {
|
|
1593
1510
|
kind: "pol";
|
|
1594
|
-
harvestCut: bigint;
|
|
1595
1511
|
keepQuote: bigint;
|
|
1596
1512
|
minQuoteAtSeed: bigint;
|
|
1597
1513
|
} | {
|
|
1598
1514
|
kind: "public";
|
|
1599
|
-
harvestCut: bigint;
|
|
1600
1515
|
curated: boolean;
|
|
1601
1516
|
} | {
|
|
1602
1517
|
kind: "private";
|
|
1603
|
-
harvestCut: bigint;
|
|
1604
1518
|
gateMint: boolean;
|
|
1605
1519
|
gateSwap: boolean;
|
|
1606
1520
|
operator: Address;
|
|
1607
1521
|
};
|
|
1522
|
+
/** The collector's ranges on a pad's creator choices (`PadPolicy`, decisions 056), WAD fractions: of the pot, and of every reserve per rung. */
|
|
1523
|
+
export interface PadRanges {
|
|
1524
|
+
/** The protocol's share of the pot, recorded into each pad at birth. */
|
|
1525
|
+
protocolShare: bigint;
|
|
1526
|
+
creatorShareMin: bigint;
|
|
1527
|
+
creatorShareMax: bigint;
|
|
1528
|
+
burnMin: bigint;
|
|
1529
|
+
burnMax: bigint;
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* The salt that carries a pad's split (`PadPolicy.pack`, decisions 056): `creatorShare` in the top 64 bits, `burnPerRung` in
|
|
1533
|
+
* the next 64 (WAD fractions), a nonce in the low 128 that tells two otherwise identical pads apart. It is part of the pool's
|
|
1534
|
+
* identity, so it is chosen at launch (`FPoolLaunchArgs.salt`) and never changes; the policy refuses a split outside its ranges.
|
|
1535
|
+
*/
|
|
1536
|
+
export declare function padSalt(s: {
|
|
1537
|
+
creatorShare: bigint;
|
|
1538
|
+
burnPerRung: bigint;
|
|
1539
|
+
nonce?: bigint;
|
|
1540
|
+
}): Hex;
|
|
1541
|
+
/** The inverse of {@link padSalt}. */
|
|
1542
|
+
export declare function padSplitOfSalt(salt: Hex): {
|
|
1543
|
+
creatorShare: bigint;
|
|
1544
|
+
burnPerRung: bigint;
|
|
1545
|
+
nonce: bigint;
|
|
1546
|
+
};
|
|
1608
1547
|
/** The policy's terms for one pool, by its kind. */
|
|
1609
1548
|
export declare function getFPoolRules(c: LogswapClient, s: Pick<FPoolState, "poolId" | "policy" | "kind" | "gen">, roles?: FPoolRoles): Promise<FPoolRules>;
|
|
1610
1549
|
/**
|
|
@@ -1629,8 +1568,7 @@ export declare function fPoolShareHolders(c: LogswapClient, poolIdHex: Hex, opts
|
|
|
1629
1568
|
shares: bigint;
|
|
1630
1569
|
}>>;
|
|
1631
1570
|
/**
|
|
1632
|
-
* What a policy answers `onRegenerate` with
|
|
1633
|
-
* `IFPolicy.Terms`. `carried` is F version 21's fifth word — the holder the next generation
|
|
1571
|
+
* What a policy answers `onRegenerate` with: `IFPolicy.Terms`. `carried` is F version 21's fifth word — the holder the next generation
|
|
1634
1572
|
* carries beside the dead shares; the reply is exactly 160 bytes.
|
|
1635
1573
|
*/
|
|
1636
1574
|
export interface FPolicyTerms {
|
package/dist/fpool.js
CHANGED
|
@@ -40,8 +40,8 @@ import { fPoolManagerAbi, logswapRouterAbi, padPolicyAbi, polPolicyAbi, policyRe
|
|
|
40
40
|
*/
|
|
41
41
|
export { fPoolManagerAbi, padPolicyAbi, polPolicyAbi, privatePolicyAbi, publicPolicyAbi };
|
|
42
42
|
/**
|
|
43
|
-
* What every protocol policy shares (`FPolicyBase`): the roles and their handover
|
|
44
|
-
* `maxHarvest
|
|
43
|
+
* What every protocol policy shares (`FPolicyBase`): the roles and their handover and the
|
|
44
|
+
* `maxHarvest` readout (a harvest has no cut, decisions 056). `polPolicyAbi` is a superset of it and carries nothing that collides, so it stands
|
|
45
45
|
* in for the base — a call through it to any of the four policies decodes the base's functions.
|
|
46
46
|
*/
|
|
47
47
|
export const fPolicyBaseAbi = polPolicyAbi;
|
|
@@ -733,7 +733,7 @@ export async function fPoolIdOf(c, a) {
|
|
|
733
733
|
/**
|
|
734
734
|
* Rebuild a live pool's KEY from its id: the `FInitialize` log carries every field but the salt,
|
|
735
735
|
* which is taken from `opts.salt` (zero by default — every pool the SDK's create flow makes
|
|
736
|
-
* without naming one). The result is checked against the id, so a wrong salt throws rather than
|
|
736
|
+
* without naming one; a pad's carries its split, so it is rebuilt from the policy's record with nonce 0 — pass `opts.salt` for another nonce). The result is checked against the id, so a wrong salt throws rather than
|
|
737
737
|
* returning a key that names another pool. What {@link fPoolMigrate} needs when handed an id.
|
|
738
738
|
*/
|
|
739
739
|
export async function fPoolKeyOfPool(c, poolId, opts = {}) {
|
|
@@ -758,6 +758,18 @@ export async function fPoolKeyOfPool(c, poolId, opts = {}) {
|
|
|
758
758
|
creator: a.creator,
|
|
759
759
|
salt: opts.salt ?? ZERO_SALT,
|
|
760
760
|
};
|
|
761
|
+
if (fPoolIdOfKey(key).toLowerCase() !== poolId.toLowerCase() && opts.salt === undefined) {
|
|
762
|
+
// a pad's salt carries its split (decisions 056): rebuild it from the policy's record with the default nonce
|
|
763
|
+
try {
|
|
764
|
+
const [creatorShare, burnPerRung] = (await c.public.readContract({ address: a.policy, abi: padPolicyAbi, functionName: "splitOf", args: [poolId] }));
|
|
765
|
+
const padKey = { ...key, salt: padSalt({ creatorShare, burnPerRung }) };
|
|
766
|
+
if (fPoolIdOfKey(padKey).toLowerCase() === poolId.toLowerCase())
|
|
767
|
+
return padKey;
|
|
768
|
+
}
|
|
769
|
+
catch {
|
|
770
|
+
/* not a pad: fall through to the error */
|
|
771
|
+
}
|
|
772
|
+
}
|
|
761
773
|
if (fPoolIdOfKey(key).toLowerCase() !== poolId.toLowerCase()) {
|
|
762
774
|
throw new Error(`logswap: F pool ${poolId} was not born with salt ${key.salt} — pass its salt, or its whole key`);
|
|
763
775
|
}
|
|
@@ -1256,34 +1268,58 @@ export async function discoverFPools(c, opts = {}) {
|
|
|
1256
1268
|
};
|
|
1257
1269
|
}));
|
|
1258
1270
|
}
|
|
1271
|
+
const MAX_U64 = (1n << 64n) - 1n;
|
|
1272
|
+
const MAX_U128 = (1n << 128n) - 1n;
|
|
1273
|
+
/**
|
|
1274
|
+
* The salt that carries a pad's split (`PadPolicy.pack`, decisions 056): `creatorShare` in the top 64 bits, `burnPerRung` in
|
|
1275
|
+
* the next 64 (WAD fractions), a nonce in the low 128 that tells two otherwise identical pads apart. It is part of the pool's
|
|
1276
|
+
* identity, so it is chosen at launch (`FPoolLaunchArgs.salt`) and never changes; the policy refuses a split outside its ranges.
|
|
1277
|
+
*/
|
|
1278
|
+
export function padSalt(s) {
|
|
1279
|
+
const nonce = s.nonce ?? 0n;
|
|
1280
|
+
if (s.creatorShare < 0n || s.creatorShare > MAX_U64 || s.burnPerRung < 0n || s.burnPerRung > MAX_U64)
|
|
1281
|
+
throw new Error("logswap: a pad's split is a WAD fraction that fits 64 bits");
|
|
1282
|
+
if (nonce < 0n || nonce > MAX_U128)
|
|
1283
|
+
throw new Error("logswap: a pad salt's nonce fits 128 bits");
|
|
1284
|
+
return `0x${((s.creatorShare << 192n) | (s.burnPerRung << 128n) | nonce).toString(16).padStart(64, "0")}`;
|
|
1285
|
+
}
|
|
1286
|
+
/** The inverse of {@link padSalt}. */
|
|
1287
|
+
export function padSplitOfSalt(salt) {
|
|
1288
|
+
const v = BigInt(salt);
|
|
1289
|
+
return { creatorShare: v >> 192n, burnPerRung: (v >> 128n) & MAX_U64, nonce: v & MAX_U128 };
|
|
1290
|
+
}
|
|
1259
1291
|
/** The policy's terms for one pool, by its kind. */
|
|
1260
1292
|
export async function getFPoolRules(c, s, roles) {
|
|
1261
1293
|
const rd = (abi, functionName, args = []) => c.public.readContract({ address: s.policy, abi, functionName, args });
|
|
1262
|
-
const harvestCut = await rd(fPolicyBaseAbi, "harvestCut");
|
|
1263
1294
|
switch (s.kind) {
|
|
1264
1295
|
case "pad": {
|
|
1265
1296
|
// the rung is the manager's generation (F version 21): a move carries it, nothing to ask the policy
|
|
1266
1297
|
const gen = s.gen;
|
|
1267
|
-
const [
|
|
1268
|
-
rd(padPolicyAbi, "
|
|
1269
|
-
rd(padPolicyAbi, "protocolShare"),
|
|
1270
|
-
rd(padPolicyAbi, "burnPerRung"),
|
|
1298
|
+
const [split, pot, threshold, protocolNow, creatorShareMin, creatorShareMax, burnMin, burnMax] = await Promise.all([
|
|
1299
|
+
rd(padPolicyAbi, "splitOf", [s.poolId]),
|
|
1271
1300
|
fPoolDividendOf(c, s.poolId, DEAD_ADDRESS, gen),
|
|
1272
1301
|
rd(padPolicyAbi, "threshold", [BigInt(gen)]),
|
|
1302
|
+
rd(padPolicyAbi, "protocolShare"),
|
|
1303
|
+
rd(padPolicyAbi, "creatorShareMin"),
|
|
1304
|
+
rd(padPolicyAbi, "creatorShareMax"),
|
|
1305
|
+
rd(padPolicyAbi, "burnMin"),
|
|
1306
|
+
rd(padPolicyAbi, "burnMax"),
|
|
1273
1307
|
]);
|
|
1274
|
-
|
|
1308
|
+
const [creatorShare, burnPerRung, protocolShare] = split;
|
|
1309
|
+
const ranges = { protocolShare: protocolNow, creatorShareMin, creatorShareMax, burnMin, burnMax };
|
|
1310
|
+
return { kind: "pad", gen, rung: gen, threshold, pot, creatorShare, protocolShare, burnPerRung, ranges };
|
|
1275
1311
|
}
|
|
1276
1312
|
case "pol": {
|
|
1277
1313
|
const [keepQuote, minQuoteAtSeed] = await Promise.all([rd(polPolicyAbi, "keepQuote"), rd(polPolicyAbi, "minQuoteAtSeed")]);
|
|
1278
|
-
return { kind: "pol",
|
|
1314
|
+
return { kind: "pol", keepQuote, minQuoteAtSeed };
|
|
1279
1315
|
}
|
|
1280
1316
|
case "public": {
|
|
1281
1317
|
const curated = await rd(publicPolicyAbi, "curated");
|
|
1282
|
-
return { kind: "public",
|
|
1318
|
+
return { kind: "public", curated };
|
|
1283
1319
|
}
|
|
1284
1320
|
case "private": {
|
|
1285
1321
|
const r = roles ?? (await getFPoolRoles(c, s.poolId, s));
|
|
1286
|
-
return { kind: "private",
|
|
1322
|
+
return { kind: "private", gateMint: r.gateMint, gateSwap: r.gateSwap, operator: fPoolOperatorOf(r) };
|
|
1287
1323
|
}
|
|
1288
1324
|
}
|
|
1289
1325
|
}
|