@cloakely/sdk 0.5.0 → 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.
- package/README.md +14 -8
- package/dist/abis.d.ts +284 -0
- package/dist/abis.js +367 -0
- package/dist/bytecode.d.ts +5 -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 +4 -0
- package/dist/deployments.js +7 -4
- package/dist/private/client.d.ts +44 -1
- package/dist/private/client.js +129 -2
- package/dist/private/crypto.d.ts +6 -0
- package/dist/private/crypto.js +8 -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,7 @@ 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
|
-
The private account comes from one EIP-712 signature bound to the chain and the
|
|
90
|
+
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
91
|
|
|
86
92
|
## Fees (testnet beta)
|
|
87
93
|
|
|
@@ -92,7 +98,7 @@ The private account comes from one EIP-712 signature bound to the chain and the
|
|
|
92
98
|
| Successful launch | 1.5% of the raise |
|
|
93
99
|
| Relayer | the relayer's gas plus a margin, paid inside the proof |
|
|
94
100
|
|
|
95
|
-
Rules live in the on-chain `CloakConfig
|
|
101
|
+
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
102
|
|
|
97
103
|
## Exports
|
|
98
104
|
|
package/dist/abis.d.ts
CHANGED
|
@@ -912,6 +912,10 @@ export declare const cloakFactoryAbi: readonly [{
|
|
|
912
912
|
readonly name: "seeder_";
|
|
913
913
|
readonly type: "address";
|
|
914
914
|
readonly internalType: "contract IMarketSeeder";
|
|
915
|
+
}, {
|
|
916
|
+
readonly name: "feeLocker_";
|
|
917
|
+
readonly type: "address";
|
|
918
|
+
readonly internalType: "contract IFeeLocker";
|
|
915
919
|
}];
|
|
916
920
|
readonly stateMutability: "nonpayable";
|
|
917
921
|
}, {
|
|
@@ -1031,6 +1035,16 @@ export declare const cloakFactoryAbi: readonly [{
|
|
|
1031
1035
|
readonly internalType: "address";
|
|
1032
1036
|
}];
|
|
1033
1037
|
readonly stateMutability: "nonpayable";
|
|
1038
|
+
}, {
|
|
1039
|
+
readonly type: "function";
|
|
1040
|
+
readonly name: "feeLocker";
|
|
1041
|
+
readonly inputs: readonly [];
|
|
1042
|
+
readonly outputs: readonly [{
|
|
1043
|
+
readonly name: "";
|
|
1044
|
+
readonly type: "address";
|
|
1045
|
+
readonly internalType: "contract IFeeLocker";
|
|
1046
|
+
}];
|
|
1047
|
+
readonly stateMutability: "view";
|
|
1034
1048
|
}, {
|
|
1035
1049
|
readonly type: "function";
|
|
1036
1050
|
readonly name: "launches";
|
|
@@ -1219,6 +1233,10 @@ export declare const cloakAuctionAbi: readonly [{
|
|
|
1219
1233
|
readonly name: "seeder_";
|
|
1220
1234
|
readonly type: "address";
|
|
1221
1235
|
readonly internalType: "contract IMarketSeeder";
|
|
1236
|
+
}, {
|
|
1237
|
+
readonly name: "feeLocker_";
|
|
1238
|
+
readonly type: "address";
|
|
1239
|
+
readonly internalType: "contract IFeeLocker";
|
|
1222
1240
|
}];
|
|
1223
1241
|
readonly stateMutability: "nonpayable";
|
|
1224
1242
|
}, {
|
|
@@ -1254,6 +1272,16 @@ export declare const cloakAuctionAbi: readonly [{
|
|
|
1254
1272
|
readonly internalType: "uint256";
|
|
1255
1273
|
}];
|
|
1256
1274
|
readonly stateMutability: "view";
|
|
1275
|
+
}, {
|
|
1276
|
+
readonly type: "function";
|
|
1277
|
+
readonly name: "LOCK_FOREVER_FEES";
|
|
1278
|
+
readonly inputs: readonly [];
|
|
1279
|
+
readonly outputs: readonly [{
|
|
1280
|
+
readonly name: "";
|
|
1281
|
+
readonly type: "uint64";
|
|
1282
|
+
readonly internalType: "uint64";
|
|
1283
|
+
}];
|
|
1284
|
+
readonly stateMutability: "view";
|
|
1257
1285
|
}, {
|
|
1258
1286
|
readonly type: "function";
|
|
1259
1287
|
readonly name: "MAX_TICKS";
|
|
@@ -1476,6 +1504,16 @@ export declare const cloakAuctionAbi: readonly [{
|
|
|
1476
1504
|
readonly internalType: "uint256";
|
|
1477
1505
|
}];
|
|
1478
1506
|
readonly stateMutability: "view";
|
|
1507
|
+
}, {
|
|
1508
|
+
readonly type: "function";
|
|
1509
|
+
readonly name: "creatorFees";
|
|
1510
|
+
readonly inputs: readonly [];
|
|
1511
|
+
readonly outputs: readonly [{
|
|
1512
|
+
readonly name: "";
|
|
1513
|
+
readonly type: "bool";
|
|
1514
|
+
readonly internalType: "bool";
|
|
1515
|
+
}];
|
|
1516
|
+
readonly stateMutability: "view";
|
|
1479
1517
|
}, {
|
|
1480
1518
|
readonly type: "function";
|
|
1481
1519
|
readonly name: "creatorOwed";
|
|
@@ -1540,6 +1578,26 @@ export declare const cloakAuctionAbi: readonly [{
|
|
|
1540
1578
|
readonly internalType: "bool";
|
|
1541
1579
|
}];
|
|
1542
1580
|
readonly stateMutability: "view";
|
|
1581
|
+
}, {
|
|
1582
|
+
readonly type: "function";
|
|
1583
|
+
readonly name: "feeLocker";
|
|
1584
|
+
readonly inputs: readonly [];
|
|
1585
|
+
readonly outputs: readonly [{
|
|
1586
|
+
readonly name: "";
|
|
1587
|
+
readonly type: "address";
|
|
1588
|
+
readonly internalType: "contract IFeeLocker";
|
|
1589
|
+
}];
|
|
1590
|
+
readonly stateMutability: "view";
|
|
1591
|
+
}, {
|
|
1592
|
+
readonly type: "function";
|
|
1593
|
+
readonly name: "feePosition";
|
|
1594
|
+
readonly inputs: readonly [];
|
|
1595
|
+
readonly outputs: readonly [{
|
|
1596
|
+
readonly name: "";
|
|
1597
|
+
readonly type: "uint256";
|
|
1598
|
+
readonly internalType: "uint256";
|
|
1599
|
+
}];
|
|
1600
|
+
readonly stateMutability: "view";
|
|
1543
1601
|
}, {
|
|
1544
1602
|
readonly type: "function";
|
|
1545
1603
|
readonly name: "feesOwed";
|
|
@@ -2002,6 +2060,21 @@ export declare const cloakAuctionAbi: readonly [{
|
|
|
2002
2060
|
readonly internalType: "bytes";
|
|
2003
2061
|
}];
|
|
2004
2062
|
readonly anonymous: false;
|
|
2063
|
+
}, {
|
|
2064
|
+
readonly type: "event";
|
|
2065
|
+
readonly name: "CreatorFeesOn";
|
|
2066
|
+
readonly inputs: readonly [{
|
|
2067
|
+
readonly name: "locker";
|
|
2068
|
+
readonly type: "address";
|
|
2069
|
+
readonly indexed: false;
|
|
2070
|
+
readonly internalType: "address";
|
|
2071
|
+
}, {
|
|
2072
|
+
readonly name: "position";
|
|
2073
|
+
readonly type: "uint256";
|
|
2074
|
+
readonly indexed: false;
|
|
2075
|
+
readonly internalType: "uint256";
|
|
2076
|
+
}];
|
|
2077
|
+
readonly anonymous: false;
|
|
2005
2078
|
}, {
|
|
2006
2079
|
readonly type: "event";
|
|
2007
2080
|
readonly name: "DustSwept";
|
|
@@ -5591,3 +5664,214 @@ export declare const cloakV2MarketAbi: readonly [{
|
|
|
5591
5664
|
}];
|
|
5592
5665
|
readonly anonymous: false;
|
|
5593
5666
|
}];
|
|
5667
|
+
export declare const cloakFeeLockerAbi: readonly [{
|
|
5668
|
+
readonly type: "function";
|
|
5669
|
+
readonly name: "claim";
|
|
5670
|
+
readonly inputs: readonly [{
|
|
5671
|
+
readonly name: "id";
|
|
5672
|
+
readonly type: "uint256";
|
|
5673
|
+
readonly internalType: "uint256";
|
|
5674
|
+
}];
|
|
5675
|
+
readonly outputs: readonly [{
|
|
5676
|
+
readonly name: "amount0";
|
|
5677
|
+
readonly type: "uint256";
|
|
5678
|
+
readonly internalType: "uint256";
|
|
5679
|
+
}, {
|
|
5680
|
+
readonly name: "amount1";
|
|
5681
|
+
readonly type: "uint256";
|
|
5682
|
+
readonly internalType: "uint256";
|
|
5683
|
+
}];
|
|
5684
|
+
readonly stateMutability: "nonpayable";
|
|
5685
|
+
}, {
|
|
5686
|
+
readonly type: "function";
|
|
5687
|
+
readonly name: "claimable";
|
|
5688
|
+
readonly inputs: readonly [{
|
|
5689
|
+
readonly name: "id";
|
|
5690
|
+
readonly type: "uint256";
|
|
5691
|
+
readonly internalType: "uint256";
|
|
5692
|
+
}];
|
|
5693
|
+
readonly outputs: readonly [{
|
|
5694
|
+
readonly name: "lp";
|
|
5695
|
+
readonly type: "uint256";
|
|
5696
|
+
readonly internalType: "uint256";
|
|
5697
|
+
}];
|
|
5698
|
+
readonly stateMutability: "view";
|
|
5699
|
+
}, {
|
|
5700
|
+
readonly type: "function";
|
|
5701
|
+
readonly name: "claimableAmounts";
|
|
5702
|
+
readonly inputs: readonly [{
|
|
5703
|
+
readonly name: "id";
|
|
5704
|
+
readonly type: "uint256";
|
|
5705
|
+
readonly internalType: "uint256";
|
|
5706
|
+
}];
|
|
5707
|
+
readonly outputs: readonly [{
|
|
5708
|
+
readonly name: "amount0";
|
|
5709
|
+
readonly type: "uint256";
|
|
5710
|
+
readonly internalType: "uint256";
|
|
5711
|
+
}, {
|
|
5712
|
+
readonly name: "amount1";
|
|
5713
|
+
readonly type: "uint256";
|
|
5714
|
+
readonly internalType: "uint256";
|
|
5715
|
+
}];
|
|
5716
|
+
readonly stateMutability: "view";
|
|
5717
|
+
}, {
|
|
5718
|
+
readonly type: "function";
|
|
5719
|
+
readonly name: "lockFor";
|
|
5720
|
+
readonly inputs: readonly [{
|
|
5721
|
+
readonly name: "pair";
|
|
5722
|
+
readonly type: "address";
|
|
5723
|
+
readonly internalType: "contract IUniswapV2Pair";
|
|
5724
|
+
}, {
|
|
5725
|
+
readonly name: "shares";
|
|
5726
|
+
readonly type: "uint256";
|
|
5727
|
+
readonly internalType: "uint256";
|
|
5728
|
+
}, {
|
|
5729
|
+
readonly name: "beneficiary";
|
|
5730
|
+
readonly type: "address";
|
|
5731
|
+
readonly internalType: "address";
|
|
5732
|
+
}];
|
|
5733
|
+
readonly outputs: readonly [{
|
|
5734
|
+
readonly name: "id";
|
|
5735
|
+
readonly type: "uint256";
|
|
5736
|
+
readonly internalType: "uint256";
|
|
5737
|
+
}];
|
|
5738
|
+
readonly stateMutability: "nonpayable";
|
|
5739
|
+
}, {
|
|
5740
|
+
readonly type: "function";
|
|
5741
|
+
readonly name: "positions";
|
|
5742
|
+
readonly inputs: readonly [{
|
|
5743
|
+
readonly name: "id";
|
|
5744
|
+
readonly type: "uint256";
|
|
5745
|
+
readonly internalType: "uint256";
|
|
5746
|
+
}];
|
|
5747
|
+
readonly outputs: readonly [{
|
|
5748
|
+
readonly name: "";
|
|
5749
|
+
readonly type: "tuple";
|
|
5750
|
+
readonly internalType: "struct CloakFeeLocker.Position";
|
|
5751
|
+
readonly components: readonly [{
|
|
5752
|
+
readonly name: "pair";
|
|
5753
|
+
readonly type: "address";
|
|
5754
|
+
readonly internalType: "contract IUniswapV2Pair";
|
|
5755
|
+
}, {
|
|
5756
|
+
readonly name: "beneficiary";
|
|
5757
|
+
readonly type: "address";
|
|
5758
|
+
readonly internalType: "address";
|
|
5759
|
+
}, {
|
|
5760
|
+
readonly name: "shares";
|
|
5761
|
+
readonly type: "uint256";
|
|
5762
|
+
readonly internalType: "uint256";
|
|
5763
|
+
}, {
|
|
5764
|
+
readonly name: "locked";
|
|
5765
|
+
readonly type: "uint256";
|
|
5766
|
+
readonly internalType: "uint256";
|
|
5767
|
+
}];
|
|
5768
|
+
}];
|
|
5769
|
+
readonly stateMutability: "view";
|
|
5770
|
+
}, {
|
|
5771
|
+
readonly type: "function";
|
|
5772
|
+
readonly name: "positionsCount";
|
|
5773
|
+
readonly inputs: readonly [];
|
|
5774
|
+
readonly outputs: readonly [{
|
|
5775
|
+
readonly name: "";
|
|
5776
|
+
readonly type: "uint256";
|
|
5777
|
+
readonly internalType: "uint256";
|
|
5778
|
+
}];
|
|
5779
|
+
readonly stateMutability: "view";
|
|
5780
|
+
}, {
|
|
5781
|
+
readonly type: "function";
|
|
5782
|
+
readonly name: "setBeneficiary";
|
|
5783
|
+
readonly inputs: readonly [{
|
|
5784
|
+
readonly name: "id";
|
|
5785
|
+
readonly type: "uint256";
|
|
5786
|
+
readonly internalType: "uint256";
|
|
5787
|
+
}, {
|
|
5788
|
+
readonly name: "to";
|
|
5789
|
+
readonly type: "address";
|
|
5790
|
+
readonly internalType: "address";
|
|
5791
|
+
}];
|
|
5792
|
+
readonly outputs: readonly [];
|
|
5793
|
+
readonly stateMutability: "nonpayable";
|
|
5794
|
+
}, {
|
|
5795
|
+
readonly type: "event";
|
|
5796
|
+
readonly name: "BeneficiaryChanged";
|
|
5797
|
+
readonly inputs: readonly [{
|
|
5798
|
+
readonly name: "id";
|
|
5799
|
+
readonly type: "uint256";
|
|
5800
|
+
readonly indexed: true;
|
|
5801
|
+
readonly internalType: "uint256";
|
|
5802
|
+
}, {
|
|
5803
|
+
readonly name: "from";
|
|
5804
|
+
readonly type: "address";
|
|
5805
|
+
readonly indexed: false;
|
|
5806
|
+
readonly internalType: "address";
|
|
5807
|
+
}, {
|
|
5808
|
+
readonly name: "to";
|
|
5809
|
+
readonly type: "address";
|
|
5810
|
+
readonly indexed: false;
|
|
5811
|
+
readonly internalType: "address";
|
|
5812
|
+
}];
|
|
5813
|
+
readonly anonymous: false;
|
|
5814
|
+
}, {
|
|
5815
|
+
readonly type: "event";
|
|
5816
|
+
readonly name: "FeesClaimed";
|
|
5817
|
+
readonly inputs: readonly [{
|
|
5818
|
+
readonly name: "id";
|
|
5819
|
+
readonly type: "uint256";
|
|
5820
|
+
readonly indexed: true;
|
|
5821
|
+
readonly internalType: "uint256";
|
|
5822
|
+
}, {
|
|
5823
|
+
readonly name: "beneficiary";
|
|
5824
|
+
readonly type: "address";
|
|
5825
|
+
readonly indexed: true;
|
|
5826
|
+
readonly internalType: "address";
|
|
5827
|
+
}, {
|
|
5828
|
+
readonly name: "shares";
|
|
5829
|
+
readonly type: "uint256";
|
|
5830
|
+
readonly indexed: false;
|
|
5831
|
+
readonly internalType: "uint256";
|
|
5832
|
+
}, {
|
|
5833
|
+
readonly name: "amount0";
|
|
5834
|
+
readonly type: "uint256";
|
|
5835
|
+
readonly indexed: false;
|
|
5836
|
+
readonly internalType: "uint256";
|
|
5837
|
+
}, {
|
|
5838
|
+
readonly name: "amount1";
|
|
5839
|
+
readonly type: "uint256";
|
|
5840
|
+
readonly indexed: false;
|
|
5841
|
+
readonly internalType: "uint256";
|
|
5842
|
+
}];
|
|
5843
|
+
readonly anonymous: false;
|
|
5844
|
+
}, {
|
|
5845
|
+
readonly type: "event";
|
|
5846
|
+
readonly name: "Locked";
|
|
5847
|
+
readonly inputs: readonly [{
|
|
5848
|
+
readonly name: "id";
|
|
5849
|
+
readonly type: "uint256";
|
|
5850
|
+
readonly indexed: true;
|
|
5851
|
+
readonly internalType: "uint256";
|
|
5852
|
+
}, {
|
|
5853
|
+
readonly name: "pair";
|
|
5854
|
+
readonly type: "address";
|
|
5855
|
+
readonly indexed: true;
|
|
5856
|
+
readonly internalType: "address";
|
|
5857
|
+
}, {
|
|
5858
|
+
readonly name: "beneficiary";
|
|
5859
|
+
readonly type: "address";
|
|
5860
|
+
readonly indexed: true;
|
|
5861
|
+
readonly internalType: "address";
|
|
5862
|
+
}, {
|
|
5863
|
+
readonly name: "shares";
|
|
5864
|
+
readonly type: "uint256";
|
|
5865
|
+
readonly indexed: false;
|
|
5866
|
+
readonly internalType: "uint256";
|
|
5867
|
+
}];
|
|
5868
|
+
readonly anonymous: false;
|
|
5869
|
+
}, {
|
|
5870
|
+
readonly type: "error";
|
|
5871
|
+
readonly name: "NotBeneficiary";
|
|
5872
|
+
readonly inputs: readonly [];
|
|
5873
|
+
}, {
|
|
5874
|
+
readonly type: "error";
|
|
5875
|
+
readonly name: "Zero";
|
|
5876
|
+
readonly inputs: readonly [];
|
|
5877
|
+
}];
|