@cloakely/sdk 0.2.0 → 0.2.2
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/private/client.js +15 -3
- package/package.json +7 -4
package/dist/private/client.js
CHANGED
|
@@ -305,8 +305,10 @@ export class CloakPrivate {
|
|
|
305
305
|
const fee = (await this.relayFee("placeOrder", poolIn)).fee;
|
|
306
306
|
if (fee > 0n) {
|
|
307
307
|
const have = await this.balance(poolIn);
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
// headroom: the fee is re-quoted before every order (gas moves), and combining notes first costs one more fee
|
|
309
|
+
const reserve = (n) => (fee * BigInt(n) * 5n) / 4n + fee;
|
|
310
|
+
if (sizes.reduce((a, x) => a + x, 0n) + reserve(sizes.length) > have) {
|
|
311
|
+
const budget = have - reserve(maxOrders);
|
|
310
312
|
if (budget <= 0n)
|
|
311
313
|
throw new Error("insufficient private balance");
|
|
312
314
|
({ sizes } = splitStandard(budget < amount ? budget : amount, maxOrders));
|
|
@@ -320,7 +322,17 @@ export class CloakPrivate {
|
|
|
320
322
|
const size = sizes[i];
|
|
321
323
|
onStatus(`Order ${i + 1}/${sizes.length}: syncing…`);
|
|
322
324
|
const q = await this.relayFee("placeOrder", poolIn);
|
|
323
|
-
|
|
325
|
+
let inputs;
|
|
326
|
+
try {
|
|
327
|
+
inputs = await this.inputsFor(poolIn, size + q.fee, onStatus);
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
// if fees rose mid-way, keep the orders already placed and leave the rest in the balance
|
|
331
|
+
if (!placed.length || !/insufficient private balance/.test(String(e.message)))
|
|
332
|
+
throw e;
|
|
333
|
+
rest += sizes.slice(i).reduce((a, x) => a + x, 0n);
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
324
336
|
const keyIndex = randomKeyIndex();
|
|
325
337
|
const outKey = await this.keys.key(keyIndex);
|
|
326
338
|
const outBlinding = randomField();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloakely/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|
|
@@ -65,10 +65,13 @@
|
|
|
65
65
|
"@noble/hashes": "1.5.0",
|
|
66
66
|
"circomlibjs": "0.1.7",
|
|
67
67
|
"snarkjs": "0.7.5",
|
|
68
|
-
"tlock-js": "0.9.0"
|
|
69
|
-
"viem": "2.21.54"
|
|
68
|
+
"tlock-js": "0.9.0"
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
|
-
"typescript": "5.6.3"
|
|
71
|
+
"typescript": "5.6.3",
|
|
72
|
+
"viem": "2.21.54"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"viem": ">=2.21.0 <3"
|
|
73
76
|
}
|
|
74
77
|
}
|