@cloakely/sdk 0.4.0 → 0.5.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.
package/dist/cloak.d.ts CHANGED
@@ -53,7 +53,10 @@ export interface AuctionState {
53
53
  clearingPrice: bigint;
54
54
  sold: bigint;
55
55
  raised: bigint;
56
+ /** The market Cloak trades: a CloakV2Market in front of a Uniswap V2 pool, or (earlier launches) a CloakPair. */
56
57
  pair: Address;
58
+ /** The launch's Uniswap V2 pool (token / WHYPE), tradable and tracked everywhere. Zero for a CloakPair market. */
59
+ uniPair: Address;
57
60
  tokenName: string;
58
61
  tokenSymbol: string;
59
62
  /** Launch fee on a successful raise, fixed when the auction was created. */
@@ -218,8 +221,15 @@ export declare class Cloak {
218
221
  readonly name: "config_";
219
222
  readonly type: "address";
220
223
  readonly internalType: "contract CloakConfig";
224
+ }, {
225
+ readonly name: "seeder_";
226
+ readonly type: "address";
227
+ readonly internalType: "contract IMarketSeeder";
221
228
  }];
222
229
  readonly stateMutability: "nonpayable";
230
+ }, {
231
+ readonly type: "receive";
232
+ readonly stateMutability: "payable";
223
233
  }, {
224
234
  readonly type: "function";
225
235
  readonly name: "DEAD";
@@ -830,6 +840,16 @@ export declare class Cloak {
830
840
  readonly internalType: "uint256";
831
841
  }];
832
842
  readonly stateMutability: "view";
843
+ }, {
844
+ readonly type: "function";
845
+ readonly name: "seeder";
846
+ readonly inputs: readonly [];
847
+ readonly outputs: readonly [{
848
+ readonly name: "";
849
+ readonly type: "address";
850
+ readonly internalType: "contract IMarketSeeder";
851
+ }];
852
+ readonly stateMutability: "view";
833
853
  }, {
834
854
  readonly type: "function";
835
855
  readonly name: "settle";
@@ -892,6 +912,16 @@ export declare class Cloak {
892
912
  readonly internalType: "uint256";
893
913
  }];
894
914
  readonly stateMutability: "view";
915
+ }, {
916
+ readonly type: "function";
917
+ readonly name: "uniPair";
918
+ readonly inputs: readonly [];
919
+ readonly outputs: readonly [{
920
+ readonly name: "";
921
+ readonly type: "address";
922
+ readonly internalType: "address";
923
+ }];
924
+ readonly stateMutability: "view";
895
925
  }, {
896
926
  readonly type: "function";
897
927
  readonly name: "withdrawProceeds";
@@ -1183,6 +1213,26 @@ export declare class Cloak {
1183
1213
  readonly internalType: "uint256";
1184
1214
  }];
1185
1215
  readonly anonymous: false;
1216
+ }, {
1217
+ readonly type: "event";
1218
+ readonly name: "UniswapMarket";
1219
+ readonly inputs: readonly [{
1220
+ readonly name: "uniPair";
1221
+ readonly type: "address";
1222
+ readonly indexed: true;
1223
+ readonly internalType: "address";
1224
+ }, {
1225
+ readonly name: "market";
1226
+ readonly type: "address";
1227
+ readonly indexed: false;
1228
+ readonly internalType: "address";
1229
+ }, {
1230
+ readonly name: "lpShares";
1231
+ readonly type: "uint256";
1232
+ readonly indexed: false;
1233
+ readonly internalType: "uint256";
1234
+ }];
1235
+ readonly anonymous: false;
1186
1236
  }], "Committed", true, bigint, bigint>>;
1187
1237
  /**
1188
1238
  * Decrypt every sealed bid whose drand round has passed and reveal them in batches. Anyone can run this — it needs no
package/dist/cloak.js CHANGED
@@ -120,47 +120,34 @@ export class Cloak {
120
120
  async listLaunches() {
121
121
  if (!this.factory)
122
122
  throw new Error("Cloak: factory address required");
123
- const legacy = [];
124
- for (const f of this.legacyFactories)
125
- legacy.push(...(await this.listLegacy(f)));
126
- return [...(await this.listCurrent()), ...legacy];
123
+ // every factory, and every launch in it, read at once (a multicall client folds them into a few requests)
124
+ const [current, ...legacy] = await Promise.all([this.listCurrent(), ...this.legacyFactories.map((f) => this.listLegacy(f))]);
125
+ return [...current, ...legacy.flat()];
127
126
  }
128
127
  async listLegacy(factory) {
129
128
  const n = await this.publicClient.readContract({ address: factory, abi: cloakFactoryAbi, functionName: "launchesCount" });
130
- const out = [];
131
- for (let i = 0n; i < n; i++) {
129
+ return Promise.all(Array.from({ length: Number(n) }, async (_, k) => {
130
+ const i = BigInt(k);
132
131
  // a factory from v2 on returns a vesting contract too; the first one returns five fields
133
132
  const six = await this.publicClient.readContract({ address: factory, abi: cloakFactoryAbi, functionName: "launches", args: [i] }).catch(() => null);
134
133
  const [auction, token, creator, launchpad, creatorAlloc] = six ?? (await this.publicClient.readContract({ address: factory, abi: LEGACY_LAUNCHES_ABI, functionName: "launches", args: [i] }));
135
- out.push({ auction, token, creator, launchpad, creatorAlloc, vesting: (six?.[5] ?? zeroAddress), factory, index: i, legacy: true });
136
- }
137
- return out;
134
+ return { auction, token, creator, launchpad, creatorAlloc, vesting: (six?.[5] ?? zeroAddress), factory, index: i, legacy: true };
135
+ }));
138
136
  }
139
137
  async listCurrent() {
140
- if (!this.factory)
141
- throw new Error("Cloak: factory address required");
142
- const n = await this.publicClient.readContract({
143
- address: this.factory,
144
- abi: cloakFactoryAbi,
145
- functionName: "launchesCount",
146
- });
147
- const out = [];
148
- for (let i = 0n; i < n; i++) {
149
- const [auction, token, creator, launchpad, creatorAlloc, vesting] = await this.publicClient.readContract({
150
- address: this.factory,
151
- abi: cloakFactoryAbi,
152
- functionName: "launches",
153
- args: [i],
154
- });
155
- out.push({ auction, token, creator, launchpad, creatorAlloc, vesting, factory: this.factory, index: i });
156
- }
157
- return out;
138
+ const factory = this.factory;
139
+ const n = await this.publicClient.readContract({ address: factory, abi: cloakFactoryAbi, functionName: "launchesCount" });
140
+ return Promise.all(Array.from({ length: Number(n) }, async (_, k) => {
141
+ const index = BigInt(k);
142
+ const [auction, token, creator, launchpad, creatorAlloc, vesting] = await this.publicClient.readContract({ address: factory, abi: cloakFactoryAbi, functionName: "launches", args: [index] });
143
+ return { auction, token, creator, launchpad, creatorAlloc, vesting, factory, index };
144
+ }));
158
145
  }
159
146
  // ───────────── reads ─────────────
160
147
  async getAuction(auction) {
161
148
  const c = { address: auction, abi: cloakAuctionAbi };
162
149
  const r = this.publicClient;
163
- const [params, token, phase, commits, reveals, totalDeposits, totalDemand, settled, failed, clearingTick, clearingPrice, sold, raised, pair, launchFeeBps, bidCap, depositCap, creatorOwed, feesOwed] = await Promise.all([
150
+ const [params, token, phase, commits, reveals, totalDeposits, totalDemand, settled, failed, clearingTick, clearingPrice, sold, raised, pair, launchFeeBps, bidCap, depositCap, creatorOwed, feesOwed, uniPair] = await Promise.all([
164
151
  r.readContract({ ...c, functionName: "params" }),
165
152
  r.readContract({ ...c, functionName: "token" }),
166
153
  r.readContract({ ...c, functionName: "phase" }),
@@ -181,6 +168,8 @@ export class Cloak {
181
168
  r.readContract({ ...c, functionName: "depositCap" }).catch(() => 0n),
182
169
  r.readContract({ ...c, functionName: "creatorOwed" }).catch(() => 0n),
183
170
  r.readContract({ ...c, functionName: "feesOwed" }).catch(() => 0n),
171
+ // launches from the Uniswap factory on
172
+ r.readContract({ ...c, functionName: "uniPair" }).catch(() => zeroAddress),
184
173
  ]);
185
174
  const [creator, saleSupply, lpReserve, minPrice, tickSize, numTicks, commitEnd, revealEnd, lpBps, noRevealPenaltyBps, lpLockUntil, tlockRound] = params;
186
175
  const [tokenName, tokenSymbol] = await Promise.all([
@@ -214,6 +203,7 @@ export class Cloak {
214
203
  sold,
215
204
  raised,
216
205
  pair,
206
+ uniPair,
217
207
  tokenName,
218
208
  tokenSymbol,
219
209
  launchFeeBps,
@@ -28,6 +28,10 @@ export interface CloakDeployment {
28
28
  factory: Address;
29
29
  /** Block the factory was deployed in: scan launch events from here. */
30
30
  factoryBlock: bigint;
31
+ /** Earlier factories of this same deployment (newest first): their launches still list, settle and trade. */
32
+ earlierFactories?: Address[];
33
+ /** Block of this deployment's first factory: scan its launches' bids from here (defaults to `factoryBlock`). */
34
+ firstFactoryBlock?: bigint;
31
35
  router: Address;
32
36
  /** Block the router was deployed in: scan private-pool events from here. */
33
37
  routerBlock: bigint;
@@ -52,6 +56,8 @@ export interface CloakDeployment {
52
56
  previous?: PreviousDeployment[];
53
57
  }
54
58
  export declare const deployments: Record<number, CloakDeployment>;
59
+ /** Every factory before `d.factory` whose launches should still list, newest first: this deployment's, then earlier ones'. */
60
+ export declare function legacyFactories(d: CloakDeployment): Address[];
55
61
  /** The Cloak deployment on `chainId`, or an error naming the chains Cloak is on. */
56
62
  export declare function deploymentFor(chainId: number): CloakDeployment;
57
63
  /**
@@ -1,7 +1,7 @@
1
1
  import { privateRouterAbi } from "./abis.js";
2
2
  import { readRegistry } from "./registry.js";
3
3
  export const deployments = {
4
- // Cloak v4 (Oct 31), the permanent vaults: deployments/elysium-testnet-v4.json. CloakConfig's registry lists all of it;
4
+ // Cloak v4 (Oct 31), the permanent vaults, plus the Uniswap launch factory (Nov 2): deployments/elysium-testnet-v4.json. CloakConfig's registry lists all of it;
5
5
  // liveDeployment() reads the current contracts from there.
6
6
  99801: {
7
7
  chainId: 99801,
@@ -9,8 +9,11 @@ export const deployments = {
9
9
  config: "0x9fdf166f0671166148ea98cdd3ef0118d256167f",
10
10
  vaults: "0x24bc1d369aab3a2d741a48f8cac1af5dfd9f3d43",
11
11
  vaultsBlock: 19485039n,
12
- factory: "0xa88df63d7d44acc66052e5cbe5ba9503bf940993",
13
- factoryBlock: 19484794n,
12
+ // the Uniswap launch factory (Nov 2): every launch opens a Uniswap V2 pool at its clearing price
13
+ factory: "0xeac84944f5a8343edf49cde8ef74d71f4908a656",
14
+ factoryBlock: 21221250n,
15
+ earlierFactories: ["0xa88df63d7d44acc66052e5cbe5ba9503bf940993"],
16
+ firstFactoryBlock: 19484794n,
14
17
  router: "0x343ab9a7aac93cee28321410510ea24417cc6386",
15
18
  routerBlock: 19485063n,
16
19
  batcher: "0xc69e4bca18020ae93bc9f17093985bfb139a3203",
@@ -54,6 +57,10 @@ export const deployments = {
54
57
  ],
55
58
  },
56
59
  };
60
+ /** Every factory before `d.factory` whose launches should still list, newest first: this deployment's, then earlier ones'. */
61
+ export function legacyFactories(d) {
62
+ return [...(d.earlierFactories ?? []), ...(d.previous ?? []).map((p) => p.factory)].filter((f) => f && !/^0x0{40}$/i.test(f));
63
+ }
57
64
  /** The Cloak deployment on `chainId`, or an error naming the chains Cloak is on. */
58
65
  export function deploymentFor(chainId) {
59
66
  const d = deployments[chainId];
@@ -81,6 +88,7 @@ export async function liveDeployment(publicClient, base) {
81
88
  vaultsBlock: reg.vaultsBlock ?? base.vaultsBlock,
82
89
  factory: reg.factory,
83
90
  factoryBlock: reg.factoryBlock,
91
+ earlierFactories: reg.earlierFactories.length ? reg.earlierFactories : base.earlierFactories,
84
92
  router: reg.router,
85
93
  routerBlock: reg.routerBlock,
86
94
  batcher: reg.batcher ?? base.batcher,
@@ -39,6 +39,8 @@ export interface CloakRegistry {
39
39
  migrator?: Address;
40
40
  factory: Address;
41
41
  factoryBlock: bigint;
42
+ /** Earlier factories of the current version (a factory added next to the first), newest first. */
43
+ earlierFactories: Address[];
42
44
  /** Earlier deployments, newest first. */
43
45
  previous: RegistryVersion[];
44
46
  }
package/dist/registry.js CHANGED
@@ -34,6 +34,7 @@ export async function readRegistry(publicClient, config) {
34
34
  migrator: newest("migrator", router.version)?.addr,
35
35
  factory: factory.addr,
36
36
  factoryBlock: factory.startBlock,
37
+ earlierFactories: entries.filter((e) => e.kind === "factory" && e.version === factory.version && e.addr !== factory.addr).reverse().map((e) => e.addr),
37
38
  previous: versions.map((v) => {
38
39
  const r = newest("router", v);
39
40
  const b = newest("batcher", v);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloakely/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Cloak on Elysium: sealed-bid token launches and private trading (shielded balances, private swaps, batch auctions, private sends) with on-device zero-knowledge proofs.",
5
5
  "keywords": [
6
6
  "cloak",