@cloakely/sdk 0.5.0 → 0.7.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/README.md +30 -8
- package/dist/abis.d.ts +1565 -0
- package/dist/abis.js +2023 -0
- package/dist/bytecode.d.ts +9 -4
- package/dist/bytecode.js +1 -1
- package/dist/cloak.d.ts +82 -2
- package/dist/cloak.js +42 -4
- package/dist/deployments.d.ts +10 -0
- package/dist/deployments.js +14 -4
- package/dist/private/client.d.ts +55 -3
- package/dist/private/client.js +132 -2
- package/dist/private/crypto.d.ts +8 -0
- package/dist/private/crypto.js +9 -1
- package/dist/private/index.d.ts +1 -0
- package/dist/private/index.js +1 -0
- package/dist/private/prover.d.ts +19 -0
- package/dist/private/prover.js +48 -0
- package/dist/private/shared.d.ts +127 -0
- package/dist/private/shared.js +459 -0
- package/dist/private/tx.d.ts +5 -0
- package/dist/private/tx.js +8 -2
- package/dist/registry.d.ts +5 -0
- package/dist/registry.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,14 +22,16 @@ npm install @cloakely/sdk viem
|
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
import { createPublicClient, createWalletClient, custom, http, parseEther } from "viem";
|
|
25
|
-
import { Cloak, deploymentFor, elysiumTestnet } from "@cloakely/sdk";
|
|
25
|
+
import { Cloak, deploymentFor, elysiumTestnet, legacyFactories } from "@cloakely/sdk";
|
|
26
26
|
|
|
27
27
|
const d = deploymentFor(elysiumTestnet.id);
|
|
28
28
|
const publicClient = createPublicClient({ chain: elysiumTestnet, transport: http() });
|
|
29
29
|
const walletClient = createWalletClient({ chain: elysiumTestnet, transport: custom(window.ethereum) });
|
|
30
|
-
|
|
30
|
+
// earlier factories too, so every launch lists, settles and pays out
|
|
31
|
+
const cloak = new Cloak(publicClient, walletClient, d.factory, legacyFactories(d));
|
|
31
32
|
|
|
32
|
-
// a project or launchpad: a sealed-bid launch
|
|
33
|
+
// a project or launchpad: a sealed-bid launch. At settlement it opens a Uniswap V2 pool (token / WHYPE) at the
|
|
34
|
+
// clearing price, with the LP burned ("burn") or locked until a date
|
|
33
35
|
const now = Math.floor(Date.now() / 1000);
|
|
34
36
|
const { auction } = await cloak.createLaunch({
|
|
35
37
|
name: "Shade", symbol: "SHADE",
|
|
@@ -47,6 +49,10 @@ await cloak.revealAll(auction);
|
|
|
47
49
|
await cloak.settle(auction);
|
|
48
50
|
await cloak.claimAll(auction);
|
|
49
51
|
await cloak.payOut(auction); // the creator's proceeds, and the launch fee to the treasury
|
|
52
|
+
|
|
53
|
+
const s = await cloak.getAuction(auction);
|
|
54
|
+
s.uniPair; // the Uniswap V2 pool, tradable and trackable anywhere (zero for launches before Nov 2, which use a CloakPair)
|
|
55
|
+
s.pair; // the market Cloak's private router and batcher trade: a CloakV2Market in front of that pool
|
|
50
56
|
```
|
|
51
57
|
|
|
52
58
|
## Private trading
|
|
@@ -55,17 +61,17 @@ await cloak.payOut(auction); // the creator's proceeds, and the launch fee to th
|
|
|
55
61
|
import { CloakPrivate, deploymentFor, elysiumTestnet, loadProver, relayerSubmitter } from "@cloakely/sdk";
|
|
56
62
|
|
|
57
63
|
const d = deploymentFor(elysiumTestnet.id);
|
|
58
|
-
const keys = await CloakPrivate.keysFromWallet(walletClient, { chainId: d.chainId,
|
|
64
|
+
const keys = await CloakPrivate.keysFromWallet(walletClient, { chainId: d.chainId, verify: true });
|
|
59
65
|
const priv = new CloakPrivate(
|
|
60
66
|
publicClient, d.router, keys,
|
|
61
67
|
() => loadProver(d.circuitsUrl), // 12 MB of circuit files, fetched once and hash-checked
|
|
62
68
|
relayerSubmitter(d.relayerUrl), // the relayer submits, so the wallet never appears
|
|
63
|
-
d.
|
|
69
|
+
d.vaultsBlock!, d.batcher, d.migrator, // notes are scanned from the permanent vaults' first block
|
|
64
70
|
);
|
|
65
71
|
await priv.loadMarkets();
|
|
66
72
|
|
|
67
73
|
await priv.shieldHype(walletClient, parseEther("1")); // the one public step
|
|
68
|
-
await priv.buy(token, parseEther("0.25")); // private buy through the launch's pool
|
|
74
|
+
await priv.buy(token, parseEther("0.25")); // private buy through the launch's Uniswap pool
|
|
69
75
|
await priv.batch(token, "buy", parseEther("0.37")); // batch round: trade size hidden too
|
|
70
76
|
await priv.send(token, "cloak:…", parseEther("100")); // private transfer: amount hidden
|
|
71
77
|
await priv.unshieldHype(freshAddress, parseEther("0.5")); // back to any wallet
|
|
@@ -81,7 +87,23 @@ await priv.send(usdc.token, "cloak:…", parseUnits("20", 6)); // am
|
|
|
81
87
|
await priv.unshieldToken(usdc.token, freshAddress, parseUnits("10", 6)); // 0.25% fee kept
|
|
82
88
|
```
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
Launches from Nov 2 on keep their private balances in one shared launch-token vault (a testnet experiment). There a
|
|
91
|
+
private send doesn't even show which token moved: its relayer is paid from your private HYPE in the same transaction.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const shared = new SharedVaultClient(
|
|
95
|
+
priv, d.shared!, d.sharedRouter!,
|
|
96
|
+
() => loadSharedProver(d.circuitsUrl), // its own circuit (the token is inside each note), hash-checked
|
|
97
|
+
sharedRelayerSubmitter(d.relayerUrl), d.sharedBlock,
|
|
98
|
+
);
|
|
99
|
+
await shared.buy(token, parseEther("0.25")); // private HYPE → private token, through the Uniswap pool
|
|
100
|
+
await shared.send(token, parseEther("100"), "cloak:…"); // amount, parties and the token itself hidden
|
|
101
|
+
await shared.sell(token, parseEther("50")); // back to private HYPE
|
|
102
|
+
await shared.unshield(token, parseEther("10"), freshAddress);
|
|
103
|
+
console.log(await shared.balances()); // every token this account holds there
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The private account comes from one EIP-712 signature bound to the chain only (never to a contract), so it and the `cloak:` address never change. The same wallet always restores it, and nothing is stored on a server. In Node, read the circuit files yourself and pass them to `createProver(wasm, zkey)`.
|
|
85
107
|
|
|
86
108
|
## Fees (testnet beta)
|
|
87
109
|
|
|
@@ -92,7 +114,7 @@ The private account comes from one EIP-712 signature bound to the chain and the
|
|
|
92
114
|
| Successful launch | 1.5% of the raise |
|
|
93
115
|
| Relayer | the relayer's gas plus a margin, paid inside the proof |
|
|
94
116
|
|
|
95
|
-
Rules live in the on-chain `CloakConfig
|
|
117
|
+
Rules live in the on-chain `CloakConfig`, and no function in any Cloak contract can move user funds. Testnet is still in setup, so the owner can change fees and caps at once (within hard ceilings of 1% and 3%); once setup ends, before mainnet, raising a fee or a cap waits a public 3-day delay. Every rule with its number: [docs/RULES.md](https://github.com/NECOKIZZ/Cloak/blob/main/docs/RULES.md).
|
|
96
118
|
|
|
97
119
|
## Exports
|
|
98
120
|
|