@flayerlabs/gamemode-gate 0.5.5 → 0.6.0

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.
Files changed (54) hide show
  1. package/DEPLOY.md +37 -9
  2. package/README.md +7 -1
  3. package/dist/chain/chains.d.ts +14 -6
  4. package/dist/chain/chains.d.ts.map +1 -1
  5. package/dist/chain/chains.js +8 -4
  6. package/dist/chain/chains.js.map +1 -1
  7. package/dist/chain/discover.d.ts +61 -3
  8. package/dist/chain/discover.d.ts.map +1 -1
  9. package/dist/chain/discover.js +181 -21
  10. package/dist/chain/discover.js.map +1 -1
  11. package/dist/chain/registry-prices.d.ts +69 -0
  12. package/dist/chain/registry-prices.d.ts.map +1 -0
  13. package/dist/chain/registry-prices.js +157 -0
  14. package/dist/chain/registry-prices.js.map +1 -0
  15. package/dist/chain/secure.d.ts +28 -0
  16. package/dist/chain/secure.d.ts.map +1 -1
  17. package/dist/chain/secure.js +55 -20
  18. package/dist/chain/secure.js.map +1 -1
  19. package/dist/economy.d.ts.map +1 -1
  20. package/dist/economy.js +12 -3
  21. package/dist/economy.js.map +1 -1
  22. package/dist/index.d.ts +7 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/main.d.ts +14 -3
  27. package/dist/main.d.ts.map +1 -1
  28. package/dist/main.js +44 -11
  29. package/dist/main.js.map +1 -1
  30. package/dist/room.d.ts +7 -0
  31. package/dist/room.d.ts.map +1 -1
  32. package/dist/room.js +15 -6
  33. package/dist/room.js.map +1 -1
  34. package/dist/server.d.ts +26 -0
  35. package/dist/server.d.ts.map +1 -1
  36. package/dist/server.js +21 -0
  37. package/dist/server.js.map +1 -1
  38. package/dist/store.d.ts +1 -1
  39. package/dist/store.d.ts.map +1 -1
  40. package/dist/store.js +6 -0
  41. package/dist/store.js.map +1 -1
  42. package/dist/version.js +2 -2
  43. package/package.json +2 -2
  44. package/src/chain/chains.ts +14 -6
  45. package/src/chain/discover.ts +212 -21
  46. package/src/chain/registry-prices.ts +194 -0
  47. package/src/chain/secure.ts +75 -31
  48. package/src/economy.ts +13 -3
  49. package/src/index.ts +7 -4
  50. package/src/main.ts +50 -11
  51. package/src/room.ts +14 -3
  52. package/src/server.ts +49 -0
  53. package/src/store.ts +6 -0
  54. package/src/version.ts +2 -2
@@ -0,0 +1,69 @@
1
+ import { type PublicClient } from 'viem';
2
+ import type { AnnouncedSpendToken, PriceFor } from '../server.js';
3
+ /** The subset of a viem public client this module needs, so tests can script it. */
4
+ export type RegistryReader = Pick<PublicClient, 'readContract'>;
5
+ export interface RegistryPricesOptions {
6
+ /** The manager whose registry decides which pairings exist. */
7
+ positionManager: `0x${string}`;
8
+ /** The chain's flETH wrapper, priced as ETH and never asked of the registry. */
9
+ fleth?: `0x${string}`;
10
+ /** Dollars per ETH; every registry quote is in ETH. */
11
+ usdPerEth: number;
12
+ /** How long a quote is reused, in milliseconds. */
13
+ ttlMs?: number;
14
+ /** Injectable for tests. */
15
+ now?: () => number;
16
+ }
17
+ export interface RegistryQuote {
18
+ /** Dollars per whole token, to eight significant digits. */
19
+ usdPerToken: number;
20
+ /** Whole tokens per ETH as the registry's calculator quoted them. */
21
+ tokensPerEth: number;
22
+ priceCalculator: `0x${string}`;
23
+ }
24
+ /** What `/config/spend-tokens/:address` needs to size a launch's cap. */
25
+ export interface AnnounceOptions {
26
+ maxPointsPerPlayer: number;
27
+ pointsPerDollar: number;
28
+ /** Percent added over the smallest cap a flawless round fits under. */
29
+ headroomPercent: number;
30
+ }
31
+ export declare class RegistryPrices {
32
+ private readonly client;
33
+ private readonly options;
34
+ private registry;
35
+ private readonly quotes;
36
+ private readonly ttlMs;
37
+ private readonly now;
38
+ constructor(client: RegistryReader, options: RegistryPricesOptions);
39
+ /**
40
+ * The registry the manager names, or null for a manager that predates paired tokens. Read once:
41
+ * the address is immutable on chain, and a gate serves exactly one manager.
42
+ */
43
+ registryAddress(): Promise<`0x${string}` | null>;
44
+ /** ETH by any name is the operator's `USD_PER_ETH`; it is never asked of the registry. */
45
+ private isEthEquivalent;
46
+ /**
47
+ * The registry's quote for a token, or null when it is not approved or has no calculator.
48
+ * Throws when the chain cannot be read, so a caller refuses for now rather than for good.
49
+ */
50
+ quote(address: string): Promise<RegistryQuote | null>;
51
+ private read;
52
+ /** A {@link PriceFor}: dollars per whole token for any approved pairing, null for the rest. */
53
+ priceFor: PriceFor;
54
+ /**
55
+ * The entry launch tooling needs before a coin is paid for: the token as the chain describes
56
+ * it, the price the gate will fix a round at, and the smallest per-wallet cap a flawless round
57
+ * fits under plus the operator's headroom. Null for a token the registry does not approve.
58
+ */
59
+ announce(address: `0x${string}`, options: AnnounceOptions): Promise<AnnouncedSpendToken | null>;
60
+ }
61
+ /**
62
+ * The smallest per-wallet cap under which a flawless round fits, in the token's base units, or
63
+ * null when no cap makes the economy work at this price. Checked against {@link resolveEconomy}
64
+ * rather than trusted, because that function is the one place the rule is written down.
65
+ */
66
+ export declare function minimumWalletCap(usdPerToken: number, decimals: number, options: Pick<AnnounceOptions, 'maxPointsPerPlayer' | 'pointsPerDollar'>): bigint | null;
67
+ /** A cap with the operator's percentage headroom, rounded down to base units. */
68
+ export declare function withHeadroom(cap: bigint, headroomPercent: number): bigint;
69
+ //# sourceMappingURL=registry-prices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-prices.d.ts","sourceRoot":"","sources":["../../src/chain/registry-prices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA4BlE,oFAAoF;AACpF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAEhE,MAAM,WAAW,qBAAqB;IACpC,+DAA+D;IAC/D,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;I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C,mBAAmB,GAAG,IAAI,CAAC;CAkBtG;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,oBAAoB,GAAG,iBAAiB,CAAC,GACvE,MAAM,GAAG,IAAI,CAcf;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAKzE"}
@@ -0,0 +1,157 @@
1
+ import { formatUnits, parseAbi } from 'viem';
2
+ import { resolveEconomy, unitsPerToken } from '../economy.js';
3
+ /**
4
+ * Prices for any paired token the chain itself has approved, so a gate runs rounds on every
5
+ * pairing the protocol allows without anyone listing it first.
6
+ *
7
+ * A v1.3 PositionManager names its `PairedTokenRegistry`, and the registry names the price
8
+ * calculator each approved token was registered with — the same quote a launch uses to size a
9
+ * coin's starting price. That calculator answers "how many tokens is one ETH", and the operator's
10
+ * `USD_PER_ETH` turns that into dollars. Nothing here is typed by a person: an unapproved token has
11
+ * no calculator and is refused, exactly as the launch itself would be.
12
+ *
13
+ * Quotes are cached briefly. Adoption happens once per launch, so the cache protects the RPC from a
14
+ * burst of `/config/spend-tokens` reads by launch tooling, not from adoption itself. A quote that
15
+ * cannot be read throws, and the server answers adoption with 503 rather than a made-up price.
16
+ */
17
+ const managerAbi = parseAbi(['function pairedTokenRegistry() view returns (address)']);
18
+ const registryAbi = parseAbi([
19
+ 'function isApproved(address token) view returns (bool)',
20
+ 'function tokenConfig(address token) view returns ((bool approved, uint8 tokenType, uint8 decimals, address underlying, address feeEscrow, address priceCalculator, uint256 minDistribute, uint256 bidWallThreshold))',
21
+ ]);
22
+ const calculatorAbi = parseAbi(['function ethToPairedToken(uint256 ethAmount) view returns (uint256)']);
23
+ const erc20Abi = parseAbi(['function symbol() view returns (string)', 'function decimals() view returns (uint8)']);
24
+ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
25
+ export class RegistryPrices {
26
+ client;
27
+ options;
28
+ registry;
29
+ quotes = new Map();
30
+ ttlMs;
31
+ now;
32
+ constructor(client, options) {
33
+ this.client = client;
34
+ this.options = options;
35
+ this.ttlMs = options.ttlMs ?? 60_000;
36
+ this.now = options.now ?? Date.now;
37
+ }
38
+ /**
39
+ * The registry the manager names, or null for a manager that predates paired tokens. Read once:
40
+ * the address is immutable on chain, and a gate serves exactly one manager.
41
+ */
42
+ registryAddress() {
43
+ this.registry ??= this.client
44
+ .readContract({ address: this.options.positionManager, abi: managerAbi, functionName: 'pairedTokenRegistry' })
45
+ .then((address) => (address.toLowerCase() === ZERO_ADDRESS ? null : address))
46
+ .catch(() => null);
47
+ return this.registry;
48
+ }
49
+ /** ETH by any name is the operator's `USD_PER_ETH`; it is never asked of the registry. */
50
+ isEthEquivalent(address) {
51
+ const lower = address.toLowerCase();
52
+ return lower === ZERO_ADDRESS || (this.options.fleth !== undefined && lower === this.options.fleth.toLowerCase());
53
+ }
54
+ /**
55
+ * The registry's quote for a token, or null when it is not approved or has no calculator.
56
+ * Throws when the chain cannot be read, so a caller refuses for now rather than for good.
57
+ */
58
+ async quote(address) {
59
+ const key = address.toLowerCase();
60
+ const cached = this.quotes.get(key);
61
+ if (cached && this.now() - cached.at < this.ttlMs)
62
+ return cached.quote;
63
+ const quote = await this.read(address);
64
+ this.quotes.set(key, { quote, at: this.now() });
65
+ return quote;
66
+ }
67
+ async read(token) {
68
+ const registry = await this.registryAddress();
69
+ if (!registry)
70
+ return null;
71
+ const approved = await this.client.readContract({ address: registry, abi: registryAbi, functionName: 'isApproved', args: [token] });
72
+ if (!approved)
73
+ return null;
74
+ const config = await this.client.readContract({ address: registry, abi: registryAbi, functionName: 'tokenConfig', args: [token] });
75
+ const priceCalculator = config.priceCalculator;
76
+ if (!priceCalculator || priceCalculator.toLowerCase() === ZERO_ADDRESS)
77
+ return null;
78
+ const decimals = Number(config.decimals);
79
+ const perEth = await this.client.readContract({
80
+ address: priceCalculator,
81
+ abi: calculatorAbi,
82
+ functionName: 'ethToPairedToken',
83
+ args: [unitsPerToken(18)],
84
+ });
85
+ if (perEth <= 0n)
86
+ return null;
87
+ // String-based division: no binary float noise in a whole-token quote.
88
+ const tokensPerEth = Number(formatUnits(perEth, decimals));
89
+ if (!Number.isFinite(tokensPerEth) || tokensPerEth <= 0)
90
+ return null;
91
+ const usdPerToken = Number((this.options.usdPerEth / tokensPerEth).toPrecision(8));
92
+ return { usdPerToken, tokensPerEth, priceCalculator };
93
+ }
94
+ /** A {@link PriceFor}: dollars per whole token for any approved pairing, null for the rest. */
95
+ priceFor = async (token) => {
96
+ if (this.isEthEquivalent(token.address))
97
+ return null;
98
+ const quote = await this.quote(token.address);
99
+ return quote?.usdPerToken ?? null;
100
+ };
101
+ /**
102
+ * The entry launch tooling needs before a coin is paid for: the token as the chain describes
103
+ * it, the price the gate will fix a round at, and the smallest per-wallet cap a flawless round
104
+ * fits under plus the operator's headroom. Null for a token the registry does not approve.
105
+ */
106
+ async announce(address, options) {
107
+ if (this.isEthEquivalent(address))
108
+ return null;
109
+ const quote = await this.quote(address);
110
+ if (!quote)
111
+ return null;
112
+ const [symbol, decimals] = await Promise.all([
113
+ this.client.readContract({ address, abi: erc20Abi, functionName: 'symbol' }),
114
+ this.client.readContract({ address, abi: erc20Abi, functionName: 'decimals' }).then(Number),
115
+ ]);
116
+ const walletCap = minimumWalletCap(quote.usdPerToken, decimals, options);
117
+ if (walletCap === null)
118
+ return null;
119
+ return {
120
+ address,
121
+ symbol,
122
+ decimals,
123
+ usdPerToken: quote.usdPerToken,
124
+ walletCap: withHeadroom(walletCap, options.headroomPercent).toString(),
125
+ };
126
+ }
127
+ }
128
+ /**
129
+ * The smallest per-wallet cap under which a flawless round fits, in the token's base units, or
130
+ * null when no cap makes the economy work at this price. Checked against {@link resolveEconomy}
131
+ * rather than trusted, because that function is the one place the rule is written down.
132
+ */
133
+ export function minimumWalletCap(usdPerToken, decimals, options) {
134
+ const pointsPerToken = Math.round(usdPerToken * options.pointsPerDollar);
135
+ if (pointsPerToken <= 0)
136
+ return null;
137
+ const unitsPerPoint = unitsPerToken(decimals) / BigInt(pointsPerToken);
138
+ if (unitsPerPoint <= 0n)
139
+ return null;
140
+ const minimum = BigInt(Math.floor(options.maxPointsPerPlayer)) * unitsPerPoint;
141
+ const fit = resolveEconomy({
142
+ maxPointsPerPlayer: options.maxPointsPerPlayer,
143
+ walletCap: minimum,
144
+ pointsPerDollar: options.pointsPerDollar,
145
+ usdPerSpendToken: usdPerToken,
146
+ decimals,
147
+ });
148
+ return fit.ok ? minimum : null;
149
+ }
150
+ /** A cap with the operator's percentage headroom, rounded down to base units. */
151
+ export function withHeadroom(cap, headroomPercent) {
152
+ if (!Number.isSafeInteger(headroomPercent) || headroomPercent < 0) {
153
+ throw new Error('headroom percent must be a non-negative integer');
154
+ }
155
+ return (cap * BigInt(100 + headroomPercent)) / 100n;
156
+ }
157
+ //# sourceMappingURL=registry-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-prices.js","sourceRoot":"","sources":["../../src/chain/registry-prices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAqB,MAAM,MAAM,CAAC;AAGhE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AAEH,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,uDAAuD,CAAC,CAAC,CAAC;AACvF,MAAM,WAAW,GAAG,QAAQ,CAAC;IAC3B,wDAAwD;IACxD,sNAAsN;CACvN,CAAC,CAAC;AACH,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,qEAAqE,CAAC,CAAC,CAAC;AACxG,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,yCAAyC,EAAE,0CAA0C,CAAC,CAAC,CAAC;AAEnH,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAkClE,MAAM,OAAO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CAAC,kBAAkB;QAC9C,SAAS,EAAE,OAAO;QAClB,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,gBAAgB,EAAE,WAAW;QAC7B,QAAQ;KACT,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,eAAuB;IAC/D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC,GAAG,IAAI,CAAC;AACtD,CAAC"}
@@ -18,4 +18,32 @@ export interface SecureConfig {
18
18
  poolSwap?: `0x${string}`;
19
19
  }
20
20
  export declare function assertSecureConfig(client: PublicClient, config: SecureConfig): Promise<void>;
21
+ /**
22
+ * The verdict of {@link checkPositionManagerWiring}: wired, with the dispatcher the manager routes
23
+ * through, or not, with a reason written for the operator who has to fix it.
24
+ */
25
+ export type PositionManagerWiring = {
26
+ ok: true;
27
+ dispatcher: `0x${string}`;
28
+ } | {
29
+ ok: false;
30
+ reason: string;
31
+ };
32
+ /**
33
+ * Is this manager's fee wiring routed to this calculator?
34
+ *
35
+ * The manager must route fees through a dispatcher that knows the calculator, and the calculator
36
+ * must accept calls from that dispatcher. Both are one-time owner actions on chain, and a stack
37
+ * missing either ADOPTS launches whose swaps never reach the gate: the pool trades ungated while
38
+ * the gate believes it is enforcing a cap. That is the whole failure this function refuses.
39
+ *
40
+ * It is also how a manager is APPROVED for a gate. The gate never holds a list of managers: a coin
41
+ * offered for adoption names its own manager, and the manager is accepted when these three reads
42
+ * say its fees reach the gate's calculator. Wiring a new manager to the dispatcher on chain is the
43
+ * approval, and needs no gate release. Boot asks the same question of the primary manager.
44
+ */
45
+ export declare function checkPositionManagerWiring(client: Pick<PublicClient, 'readContract'>, wiring: {
46
+ positionManager: `0x${string}`;
47
+ spendGatedCalculator: `0x${string}`;
48
+ }): Promise<PositionManagerWiring>;
21
49
  //# sourceMappingURL=secure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secure.d.ts","sourceRoot":"","sources":["../../src/chain/secure.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAelD,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,2CAA2C,CAAC;AAE5E,0GAA0G;AAC1G,eAAO,MAAM,qBAAqB,eAAsC,CAAC;AASzE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBlG"}
1
+ {"version":3,"file":"secure.d.ts","sourceRoot":"","sources":["../../src/chain/secure.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAelD,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,2CAA2C,CAAC;AAE5E,0GAA0G;AAC1G,eAAO,MAAM,qBAAqB,eAAsC,CAAC;AASzE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBlG;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC;;;;;;;;;;;;GAYG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,EAC1C,MAAM,EAAE;IAAE,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAAC,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAA;CAAE,GAC9E,OAAO,CAAC,qBAAqB,CAAC,CAmDhC"}
@@ -45,51 +45,86 @@ export async function assertSecureConfig(client, config) {
45
45
  await assertWiring(client, config);
46
46
  }
47
47
  /**
48
- * The manager must route fees through a dispatcher that knows this calculator, and the calculator
48
+ * Is this manager's fee wiring routed to this calculator?
49
+ *
50
+ * The manager must route fees through a dispatcher that knows the calculator, and the calculator
49
51
  * must accept calls from that dispatcher. Both are one-time owner actions on chain, and a stack
50
52
  * missing either ADOPTS launches whose swaps never reach the gate: the pool trades ungated while
51
53
  * the gate believes it is enforcing a cap. That is the whole failure this function refuses.
52
54
  *
53
- * A paired stack additionally needs its PoolSwap approved as a router, because a paired buy arrives
54
- * through it and the calculator binds a smart wallet's buyer identity to an approved router's
55
- * `msgSender()` — unapproved, every such buy reverts at the swap.
55
+ * It is also how a manager is APPROVED for a gate. The gate never holds a list of managers: a coin
56
+ * offered for adoption names its own manager, and the manager is accepted when these three reads
57
+ * say its fees reach the gate's calculator. Wiring a new manager to the dispatcher on chain is the
58
+ * approval, and needs no gate release. Boot asks the same question of the primary manager.
56
59
  */
57
- async function assertWiring(client, config) {
58
- const manager = config.positionManager;
59
- const calculator = config.spendGatedCalculator;
60
+ export async function checkPositionManagerWiring(client, wiring) {
61
+ const manager = wiring.positionManager;
62
+ const calculator = wiring.spendGatedCalculator;
60
63
  let dispatcher;
61
64
  try {
62
- dispatcher = await client.readContract({ address: manager, abi: wiringAbi, functionName: 'feeCalculator' });
65
+ dispatcher = (await client.readContract({
66
+ address: manager,
67
+ abi: wiringAbi,
68
+ functionName: 'feeCalculator',
69
+ }));
63
70
  }
64
71
  catch {
65
- throw new Error(`POSITION_MANAGER ${manager} does not answer feeCalculator() — is it a Flaunch PositionManager?`);
72
+ return { ok: false, reason: `${manager} does not answer feeCalculator() — is it a Flaunch PositionManager?` };
66
73
  }
67
74
  const [registered, hasRole] = await Promise.all([
68
- client.readContract({
75
+ client
76
+ .readContract({
69
77
  address: dispatcher,
70
78
  abi: wiringAbi,
71
79
  functionName: 'registeredCalculators',
72
80
  args: [calculator],
73
- }).catch(() => false),
74
- client.readContract({
81
+ })
82
+ .catch(() => false),
83
+ client
84
+ .readContract({
75
85
  address: calculator,
76
86
  abi: wiringAbi,
77
87
  functionName: 'hasRole',
78
88
  args: [POSITION_MANAGER_ROLE, dispatcher],
79
- }).catch(() => false),
89
+ })
90
+ .catch(() => false),
80
91
  ]);
81
92
  if (!registered) {
82
- throw new Error(`the fee dispatcher ${dispatcher} of POSITION_MANAGER ${manager} does not have SPEND_GATED_CALCULATOR ` +
83
- `${calculator} registered — its owner must call setCalculatorRegistered(${calculator}, true) before ` +
84
- 'this gate can serve launches on that manager');
93
+ return {
94
+ ok: false,
95
+ reason: `the fee dispatcher ${dispatcher} of PositionManager ${manager} does not have the spend-gated calculator ` +
96
+ `${calculator} registered — its owner must call setCalculatorRegistered(${calculator}, true) before ` +
97
+ 'a gate on that calculator can serve launches on that manager',
98
+ };
85
99
  }
86
100
  if (!hasRole) {
87
- throw new Error(`SPEND_GATED_CALCULATOR ${calculator} has not granted the PositionManager role to the dispatcher ${dispatcher} ` +
88
- `— its admin must call grantRole(${POSITION_MANAGER_ROLE}, ${dispatcher})`);
101
+ return {
102
+ ok: false,
103
+ reason: `the spend-gated calculator ${calculator} has not granted the PositionManager role to the dispatcher ` +
104
+ `${dispatcher} — its admin must call grantRole(${POSITION_MANAGER_ROLE}, ${dispatcher})`,
105
+ };
89
106
  }
90
- if (config.flaunchVariant === 'v1_3') {
107
+ return { ok: true, dispatcher };
108
+ }
109
+ /**
110
+ * Boot's assertion about the PRIMARY manager: {@link checkPositionManagerWiring}, thrown rather
111
+ * than returned, because a gate whose own address book is unwired must not come up at all.
112
+ *
113
+ * A paired stack additionally needs its PoolSwap approved as a router, because a paired buy arrives
114
+ * through it and the calculator binds a smart wallet's buyer identity to an approved router's
115
+ * `msgSender()` — unapproved, every such buy reverts at the swap.
116
+ */
117
+ async function assertWiring(client, config) {
118
+ const calculator = config.spendGatedCalculator;
119
+ const wiring = await checkPositionManagerWiring(client, {
120
+ positionManager: config.positionManager,
121
+ spendGatedCalculator: calculator,
122
+ });
123
+ if (!wiring.ok)
124
+ throw new Error(`POSITION_MANAGER: ${wiring.reason}`);
125
+ if (config.flaunchVariant === 'v1_3' || config.flaunchVariant === 'any_v1_3') {
91
126
  if (!config.poolSwap) {
92
- throw new Error('a v1_3 stack needs POOL_SWAP — the router a paired-token buy goes through');
127
+ throw new Error(`a ${config.flaunchVariant} stack needs POOL_SWAP — the router a paired-token buy goes through`);
93
128
  }
94
129
  const approved = await client
95
130
  .readContract({ address: calculator, abi: wiringAbi, functionName: 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M,CAAA;CAAE,CAAC;AASrE;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,CAEjE"}
package/dist/economy.js CHANGED
@@ -40,6 +40,15 @@ function resolveInputs(input) {
40
40
  * goes and reads this file.
41
41
  */
42
42
  export function resolveEconomy(input) {
43
+ return evaluate(input, true);
44
+ }
45
+ /**
46
+ * The check itself. `suggest` is false while {@link minimumPointsPerDollar} is probing candidates:
47
+ * a refusal there must not go looking for a suggestion of its own, or a cap one unit short of
48
+ * fitting recurses until the stack gives out — which is how this function once took a gate down at
49
+ * boot instead of printing the number that fixes it.
50
+ */
51
+ function evaluate(input, suggest) {
43
52
  const { maxPointsPerPlayer, walletCap, pointsPerDollar } = input;
44
53
  const { usdPerSpendToken, decimals } = resolveInputs(input);
45
54
  if (!Number.isFinite(pointsPerDollar) || pointsPerDollar <= 0) {
@@ -82,7 +91,7 @@ export function resolveEconomy(input) {
82
91
  return {
83
92
  ok: false,
84
93
  problem: 'one point would be worth more than a whole spend token, which cannot be what was meant',
85
- suggestedPointsPerDollar: minimumPointsPerDollar(input),
94
+ suggestedPointsPerDollar: suggest ? minimumPointsPerDollar(input) : pointsPerDollar,
86
95
  };
87
96
  }
88
97
  const units = unitsPerToken(decimals);
@@ -99,7 +108,7 @@ export function resolveEconomy(input) {
99
108
  return {
100
109
  ok: false,
101
110
  problem: 'a perfect round would earn more than this launch lets one wallet spend',
102
- suggestedPointsPerDollar: minimumPointsPerDollar(input),
111
+ suggestedPointsPerDollar: suggest ? minimumPointsPerDollar(input) : pointsPerDollar,
103
112
  };
104
113
  }
105
114
  return {
@@ -131,7 +140,7 @@ function minimumPointsPerDollar(input) {
131
140
  const units = Number.isSafeInteger(decimals) && decimals >= 0 && decimals <= 36 ? unitsPerToken(decimals) : WEI_PER_ETH;
132
141
  let candidate = Math.ceil(Number(units / maxUnitsPerPoint) / usdPerSpendToken);
133
142
  for (let i = 0; i < 3; i++) {
134
- const result = resolveEconomy({ ...input, pointsPerDollar: candidate });
143
+ const result = evaluate({ ...input, pointsPerDollar: candidate }, false);
135
144
  if (result.ok)
136
145
  return candidate;
137
146
  candidate += 1;
@@ -1 +1 @@
1
- {"version":3,"file":"economy.js","sourceRoot":"","sources":["../src/economy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,oGAAoG;AACpG,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,qGAAqG;AACrG,MAAM,WAAW,GAAG,oBAA0B,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAsCD,SAAS,aAAa,CAAC,KAAmB;IACxC,OAAO;QACL,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,IAAI,MAAM,CAAC,GAAG;QACtD,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,YAAY;KACzC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,KAAmB;IAChD,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;IACjE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAE5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,eAAe,IAAI,CAAC,EAAE,CAAC;QAC9D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,6CAA6C,EAAE,wBAAwB,EAAE,GAAG,EAAE,CAAC;IAC9G,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,EAAE,EAAE,CAAC;QACrE,OAAO;YACL,EAAE,EAAE,KAAK;YACT,OAAO,EAAE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;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAEjE,MAAM,KAAK,GACT,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAC5G,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,gBAAgB,CAAC,GAAG,gBAAgB,CAAC,CAAC;IAC/E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,GAAG,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;QACzE,IAAI,MAAM,CAAC,EAAE;YAAE,OAAO,SAAS,CAAC;QAChC,SAAS,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export type { BalanceKey, Claim, ClaimResult } from './ledger.js';
8
8
  export { CLAIM_AUTHORIZATION_TTL_MS } from './claims.js';
9
9
  export { PayloadSigner, encodeHookData } from './chain/signer.js';
10
10
  export type { SignedPayload } from './chain/signer.js';
11
- export { Discovery, poolIdOf, verifyLaunch } from './chain/discover.js';
12
- export type { ChainReader, Deployment, Launch, LaunchCheck, PoolKey, Refused } from './chain/discover.js';
11
+ export { Discovery, WiringCache, poolIdOf, resolvePositionManager, verifyLaunch } from './chain/discover.js';
12
+ export type { ChainReader, Deployment, Launch, LaunchCheck, PoolKey, Refused, WiringCheck } from './chain/discover.js';
13
13
  export { Settlement } from './settlement.js';
14
14
  export { Standings } from './standings.js';
15
15
  export { ETH_DECIMALS, resolveEconomy, unitsPerToken } from './economy.js';
@@ -30,12 +30,15 @@ export type { VerifiedPlayerJoin, VerifyPlayerJoinTicketOptions } from './player
30
30
  */
31
31
  export { startGate, resolveGateEnv } from './main.js';
32
32
  export type { ResolvedGateConfig, SpendTokenPricing, StartedGate, StartGateOverrides } from './main.js';
33
- export type { GateAnnouncement, ServedGateAnnouncement } from './server.js';
33
+ export type { GateAnnouncement, PositionManagerPolicy, ServedGateAnnouncement } from './server.js';
34
34
  export { GATE_MARKER, GATE_VERSION } from './version.js';
35
35
  export { NotSignedIn } from './sessions.js';
36
36
  export { DEPLOYMENTS, PAIRED_DEPLOYMENTS, deploymentFor } from './chain/chains.js';
37
37
  export type { FlaunchVariant, GateDeployment } from './chain/chains.js';
38
- export { POSITION_MANAGER_ROLE, assertSecureConfig } from './chain/secure.js';
38
+ export { POSITION_MANAGER_ROLE, assertSecureConfig, checkPositionManagerWiring } from './chain/secure.js';
39
+ export type { PositionManagerWiring } from './chain/secure.js';
40
+ export { RegistryPrices, minimumWalletCap, withHeadroom } from './chain/registry-prices.js';
41
+ export type { AnnounceOptions, RegistryPricesOptions, RegistryQuote, RegistryReader } from './chain/registry-prices.js';
39
42
  export { createGateReadiness } from './readiness.js';
40
43
  export type { GateReadinessOptions } from './readiness.js';
41
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,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,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export { createTurnstileAdmit } from './turnstile.js';
4
4
  export { Ledger } from './ledger.js';
5
5
  export { CLAIM_AUTHORIZATION_TTL_MS } from './claims.js';
6
6
  export { PayloadSigner, encodeHookData } from './chain/signer.js';
7
- export { Discovery, poolIdOf, verifyLaunch } from './chain/discover.js';
7
+ export { Discovery, WiringCache, poolIdOf, resolvePositionManager, verifyLaunch } from './chain/discover.js';
8
8
  export { Settlement } from './settlement.js';
9
9
  export { Standings } from './standings.js';
10
10
  export { ETH_DECIMALS, resolveEconomy, unitsPerToken } from './economy.js';
@@ -21,6 +21,7 @@ export { startGate, resolveGateEnv } from './main.js';
21
21
  export { GATE_MARKER, GATE_VERSION } from './version.js';
22
22
  export { NotSignedIn } from './sessions.js';
23
23
  export { DEPLOYMENTS, PAIRED_DEPLOYMENTS, deploymentFor } from './chain/chains.js';
24
- export { POSITION_MANAGER_ROLE, assertSecureConfig } from './chain/secure.js';
24
+ export { POSITION_MANAGER_ROLE, assertSecureConfig, checkPositionManagerWiring } from './chain/secure.js';
25
+ export { RegistryPrices, minimumWalletCap, withHeadroom } from './chain/registry-prices.js';
25
26
  export { createGateReadiness } from './readiness.js';
26
27
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAarB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,c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gB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG5F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/main.d.ts CHANGED
@@ -45,6 +45,12 @@ export interface ResolvedGateConfig {
45
45
  * refused at adoption — the gate does not guess a token's price.
46
46
  */
47
47
  spendTokens: ReadonlyMap<string, SpendTokenPricing>;
48
+ /**
49
+ * Percent added over the smallest cap a flawless round fits under when the gate sizes a cap for a
50
+ * registry-priced pairing (`/config/spend-tokens/:address`). Prices move between the quote and the
51
+ * launch; this is the room left for that.
52
+ */
53
+ pairedTokenCapHeadroomPercent: number;
48
54
  /** May lift the gate early or rotate the signer on-chain. Defaults to the signing key's address. */
49
55
  settler: `0x${string}` | null;
50
56
  }
@@ -71,9 +77,11 @@ export interface SpendTokenPricing {
71
77
  * POSITION_MANAGER optional; selects a recorded stack on the chain (the legacy one when
72
78
  * unset), or overrides the address for a chain with no address book
73
79
  * SPEND_GATED_CALCULATOR optional address-book override
74
- * POOL_SWAP optional address-book override; required for a v1_3 stack
80
+ * POOL_SWAP optional address-book override; required for a v1_3 or any_v1_3 stack
75
81
  * FLETH optional address-book override; the chain's flETH wrapper
76
- * FLAUNCH_VARIANT optional; v1_2, multichain or v1_3
82
+ * FLAUNCH_VARIANT optional; v1_2, multichain, v1_3 or any_v1_3 — the PRIMARY manager's
83
+ * generation. Adoption is not limited to it: any manager wired to the
84
+ * calculator is served (see chain/discover.ts)
77
85
  * SETTLER optional; defaults to the signing key's own address
78
86
  * WALLET_CAP_WEI default 0.025 ETH; the cap for ETH-paired launches
79
87
  * ROUND_MS default 90000
@@ -82,7 +90,10 @@ export interface SpendTokenPricing {
82
90
  * POINTS_PER_DOLLAR default 100
83
91
  * USD_PER_ETH default 3000; fractional allowed
84
92
  * SPEND_TOKENS optional JSON array of { address, usdPerToken, walletCap } — the non-ETH
85
- * paired tokens this gate runs rounds on. Unlisted tokens are refused.
93
+ * paired tokens this gate runs rounds on. Pins a price the registry
94
+ * would otherwise quote; tokens neither here nor approved on the
95
+ * manager's PairedTokenRegistry are refused.
96
+ * PAIRED_TOKEN_CAP_HEADROOM_PERCENT default 25; headroom on caps sized for registry-priced pairings
86
97
  */
87
98
  export declare function resolveGateEnv(env: Env): ResolvedGateConfig;
88
99
  export interface StartedGate {
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAiD,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAA+D,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AASzG,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGvE;;;;;;;;;;;;GAYG;AAEH,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,CAAC;IAC3B,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC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