@obelyzk/sdk 0.5.0 → 1.0.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/obelysk/index.d.mts +779 -1
- package/dist/obelysk/index.d.ts +779 -1
- package/dist/obelysk/index.js +1343 -0
- package/dist/obelysk/index.mjs +1337 -0
- package/package.json +1 -1
package/dist/obelysk/index.d.mts
CHANGED
|
@@ -150,6 +150,41 @@ interface EpochInfo {
|
|
|
150
150
|
phase: 'Commit' | 'Reveal' | 'Settle' | 'Closed';
|
|
151
151
|
blocksRemaining: number;
|
|
152
152
|
}
|
|
153
|
+
interface ClaimFillParams {
|
|
154
|
+
orderId: bigint;
|
|
155
|
+
receiveCipher: {
|
|
156
|
+
c1: {
|
|
157
|
+
x: bigint;
|
|
158
|
+
y: bigint;
|
|
159
|
+
};
|
|
160
|
+
c2: {
|
|
161
|
+
x: bigint;
|
|
162
|
+
y: bigint;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
receiveHint: bigint;
|
|
166
|
+
receiveProof: {
|
|
167
|
+
commitment: bigint;
|
|
168
|
+
challenge: bigint;
|
|
169
|
+
response: bigint;
|
|
170
|
+
};
|
|
171
|
+
spendCipher: {
|
|
172
|
+
c1: {
|
|
173
|
+
x: bigint;
|
|
174
|
+
y: bigint;
|
|
175
|
+
};
|
|
176
|
+
c2: {
|
|
177
|
+
x: bigint;
|
|
178
|
+
y: bigint;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
spendHint: bigint;
|
|
182
|
+
spendProof: {
|
|
183
|
+
commitment: bigint;
|
|
184
|
+
challenge: bigint;
|
|
185
|
+
response: bigint;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
153
188
|
declare class DarkPoolClient {
|
|
154
189
|
private readonly obelysk;
|
|
155
190
|
constructor(obelysk: ObelyskClient);
|
|
@@ -210,6 +245,72 @@ declare class DarkPoolClient {
|
|
|
210
245
|
}): Promise<{
|
|
211
246
|
txHash: string;
|
|
212
247
|
}>;
|
|
248
|
+
/** Cancel an order before reveal. */
|
|
249
|
+
cancelOrder(orderId: bigint): Promise<string>;
|
|
250
|
+
/** Claim fills after epoch settlement. */
|
|
251
|
+
claimFill(params: {
|
|
252
|
+
orderId: bigint;
|
|
253
|
+
receiveCipher: {
|
|
254
|
+
c1: {
|
|
255
|
+
x: bigint;
|
|
256
|
+
y: bigint;
|
|
257
|
+
};
|
|
258
|
+
c2: {
|
|
259
|
+
x: bigint;
|
|
260
|
+
y: bigint;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
receiveHint: bigint;
|
|
264
|
+
receiveProof: {
|
|
265
|
+
commitment: bigint;
|
|
266
|
+
challenge: bigint;
|
|
267
|
+
response: bigint;
|
|
268
|
+
};
|
|
269
|
+
spendCipher: {
|
|
270
|
+
c1: {
|
|
271
|
+
x: bigint;
|
|
272
|
+
y: bigint;
|
|
273
|
+
};
|
|
274
|
+
c2: {
|
|
275
|
+
x: bigint;
|
|
276
|
+
y: bigint;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
spendHint: bigint;
|
|
280
|
+
spendProof: {
|
|
281
|
+
commitment: bigint;
|
|
282
|
+
challenge: bigint;
|
|
283
|
+
response: bigint;
|
|
284
|
+
};
|
|
285
|
+
}): Promise<string>;
|
|
286
|
+
/** Register your ElGamal public key with the DarkPool. */
|
|
287
|
+
registerPubkey(pubkey: {
|
|
288
|
+
x: bigint;
|
|
289
|
+
y: bigint;
|
|
290
|
+
}): Promise<string>;
|
|
291
|
+
/** Get the result of a settled epoch. */
|
|
292
|
+
getEpochResult(epochId: number): Promise<{
|
|
293
|
+
settled: boolean;
|
|
294
|
+
clearingPrices: string[];
|
|
295
|
+
} | null>;
|
|
296
|
+
/** Check if an order has been claimed. */
|
|
297
|
+
isOrderClaimed(orderId: bigint): Promise<boolean>;
|
|
298
|
+
/** Get a trader's registered public key. */
|
|
299
|
+
getTraderPubkey(address: string): Promise<{
|
|
300
|
+
x: bigint;
|
|
301
|
+
y: bigint;
|
|
302
|
+
} | null>;
|
|
303
|
+
/** Get encrypted balance for a trader and asset. */
|
|
304
|
+
getEncryptedBalance(address: string, assetId: string): Promise<{
|
|
305
|
+
c1: {
|
|
306
|
+
x: bigint;
|
|
307
|
+
y: bigint;
|
|
308
|
+
};
|
|
309
|
+
c2: {
|
|
310
|
+
x: bigint;
|
|
311
|
+
y: bigint;
|
|
312
|
+
};
|
|
313
|
+
} | null>;
|
|
213
314
|
}
|
|
214
315
|
|
|
215
316
|
interface StealthSendParams {
|
|
@@ -230,6 +331,30 @@ interface StealthMetaAddress {
|
|
|
230
331
|
y: bigint;
|
|
231
332
|
};
|
|
232
333
|
}
|
|
334
|
+
interface StealthSpendingProof {
|
|
335
|
+
commitment: bigint;
|
|
336
|
+
challenge: bigint;
|
|
337
|
+
response: bigint;
|
|
338
|
+
stealthPubkey: {
|
|
339
|
+
x: bigint;
|
|
340
|
+
y: bigint;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
interface StealthAnnouncement {
|
|
344
|
+
ephemeralPubkey: {
|
|
345
|
+
x: bigint;
|
|
346
|
+
y: bigint;
|
|
347
|
+
};
|
|
348
|
+
stealthAddress: string;
|
|
349
|
+
viewTag: string;
|
|
350
|
+
token: string;
|
|
351
|
+
amount: bigint;
|
|
352
|
+
}
|
|
353
|
+
interface ClaimParams {
|
|
354
|
+
announcementIndex: number;
|
|
355
|
+
spendingProof: StealthSpendingProof;
|
|
356
|
+
recipient: string;
|
|
357
|
+
}
|
|
233
358
|
declare class StealthClient {
|
|
234
359
|
private readonly obelysk;
|
|
235
360
|
constructor(obelysk: ObelyskClient);
|
|
@@ -280,6 +405,64 @@ declare class StealthClient {
|
|
|
280
405
|
}): Promise<{
|
|
281
406
|
txHash: string;
|
|
282
407
|
}>;
|
|
408
|
+
/** Claim a stealth payment. */
|
|
409
|
+
claim(params: {
|
|
410
|
+
announcementIndex: number;
|
|
411
|
+
spendingProof: {
|
|
412
|
+
commitment: bigint;
|
|
413
|
+
challenge: bigint;
|
|
414
|
+
response: bigint;
|
|
415
|
+
stealthPubkey: {
|
|
416
|
+
x: bigint;
|
|
417
|
+
y: bigint;
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
recipient: string;
|
|
421
|
+
}): Promise<string>;
|
|
422
|
+
/** Batch claim multiple stealth payments. */
|
|
423
|
+
batchClaim(params: {
|
|
424
|
+
announcementIndices: number[];
|
|
425
|
+
spendingProofs: Array<{
|
|
426
|
+
commitment: bigint;
|
|
427
|
+
challenge: bigint;
|
|
428
|
+
response: bigint;
|
|
429
|
+
stealthPubkey: {
|
|
430
|
+
x: bigint;
|
|
431
|
+
y: bigint;
|
|
432
|
+
};
|
|
433
|
+
}>;
|
|
434
|
+
recipient: string;
|
|
435
|
+
}): Promise<string>;
|
|
436
|
+
/** Update your stealth meta-address. */
|
|
437
|
+
updateMetaAddress(spendPubKey: {
|
|
438
|
+
x: bigint;
|
|
439
|
+
y: bigint;
|
|
440
|
+
}, viewPubKey: {
|
|
441
|
+
x: bigint;
|
|
442
|
+
y: bigint;
|
|
443
|
+
}): Promise<string>;
|
|
444
|
+
/** Get a specific announcement by index. */
|
|
445
|
+
getAnnouncement(index: number): Promise<{
|
|
446
|
+
ephemeralPubkey: {
|
|
447
|
+
x: bigint;
|
|
448
|
+
y: bigint;
|
|
449
|
+
};
|
|
450
|
+
stealthAddress: string;
|
|
451
|
+
viewTag: string;
|
|
452
|
+
token: string;
|
|
453
|
+
amount: bigint;
|
|
454
|
+
} | null>;
|
|
455
|
+
/** Get announcements in a range. */
|
|
456
|
+
getAnnouncementsRange(start: number, end: number): Promise<Array<{
|
|
457
|
+
ephemeralPubkey: {
|
|
458
|
+
x: bigint;
|
|
459
|
+
y: bigint;
|
|
460
|
+
};
|
|
461
|
+
stealthAddress: string;
|
|
462
|
+
viewTag: string;
|
|
463
|
+
token: string;
|
|
464
|
+
amount: bigint;
|
|
465
|
+
}>>;
|
|
283
466
|
}
|
|
284
467
|
|
|
285
468
|
/** Modular reduction (always positive) */
|
|
@@ -326,6 +509,22 @@ interface TransferParams {
|
|
|
326
509
|
/** Token symbol */
|
|
327
510
|
token: string;
|
|
328
511
|
}
|
|
512
|
+
interface FundParams {
|
|
513
|
+
assetId: number;
|
|
514
|
+
amount: bigint;
|
|
515
|
+
encryptionRandomness: bigint;
|
|
516
|
+
aeHint: bigint;
|
|
517
|
+
}
|
|
518
|
+
interface WithdrawCTParams {
|
|
519
|
+
to: string;
|
|
520
|
+
assetId: number;
|
|
521
|
+
amount: bigint;
|
|
522
|
+
proof: {
|
|
523
|
+
commitment: bigint;
|
|
524
|
+
challenge: bigint;
|
|
525
|
+
response: bigint;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
329
528
|
declare class ConfidentialTransferClient {
|
|
330
529
|
private readonly obelysk;
|
|
331
530
|
constructor(obelysk: ObelyskClient);
|
|
@@ -345,6 +544,44 @@ declare class ConfidentialTransferClient {
|
|
|
345
544
|
c1: ECPoint;
|
|
346
545
|
c2: ECPoint;
|
|
347
546
|
} | null>;
|
|
547
|
+
/** Register an ElGamal public key for confidential transfers. */
|
|
548
|
+
register(publicKey: {
|
|
549
|
+
x: bigint;
|
|
550
|
+
y: bigint;
|
|
551
|
+
}): Promise<string>;
|
|
552
|
+
/** Fund: deposit public tokens into encrypted balance. */
|
|
553
|
+
fund(params: {
|
|
554
|
+
assetId: number;
|
|
555
|
+
amount: bigint;
|
|
556
|
+
encryptionRandomness: bigint;
|
|
557
|
+
aeHint: bigint;
|
|
558
|
+
}): Promise<string>;
|
|
559
|
+
/** Fund another account's encrypted balance. */
|
|
560
|
+
fundFor(params: {
|
|
561
|
+
account: string;
|
|
562
|
+
assetId: number;
|
|
563
|
+
amount: bigint;
|
|
564
|
+
encryptionRandomness: bigint;
|
|
565
|
+
aeHint: bigint;
|
|
566
|
+
}): Promise<string>;
|
|
567
|
+
/** Rollover: claim pending incoming transfers into your balance. */
|
|
568
|
+
rollover(assetId: number): Promise<string>;
|
|
569
|
+
/** Withdraw: convert encrypted balance back to public tokens. */
|
|
570
|
+
withdraw(params: {
|
|
571
|
+
to: string;
|
|
572
|
+
assetId: number;
|
|
573
|
+
amount: bigint;
|
|
574
|
+
proof: {
|
|
575
|
+
commitment: bigint;
|
|
576
|
+
challenge: bigint;
|
|
577
|
+
response: bigint;
|
|
578
|
+
};
|
|
579
|
+
}): Promise<string>;
|
|
580
|
+
/** Get a registered public key. */
|
|
581
|
+
getPublicKey(address: string): Promise<{
|
|
582
|
+
x: bigint;
|
|
583
|
+
y: bigint;
|
|
584
|
+
} | null>;
|
|
348
585
|
}
|
|
349
586
|
|
|
350
587
|
type GpuTier = 'Consumer' | 'Professional' | 'DataCenter' | 'H100';
|
|
@@ -466,6 +703,96 @@ declare class PrivacyRouterClient {
|
|
|
466
703
|
isLeanIMTActive(): Promise<boolean>;
|
|
467
704
|
/** Get pending audit/disclosure request count. */
|
|
468
705
|
getPendingRequestCount(): Promise<number>;
|
|
706
|
+
/** Register an account with the privacy router. */
|
|
707
|
+
registerAccount(publicKey: {
|
|
708
|
+
x: bigint;
|
|
709
|
+
y: bigint;
|
|
710
|
+
}): Promise<string>;
|
|
711
|
+
/** Deposit tokens into encrypted balance. */
|
|
712
|
+
deposit(params: {
|
|
713
|
+
amount: bigint;
|
|
714
|
+
encryptedAmount: {
|
|
715
|
+
c1: {
|
|
716
|
+
x: bigint;
|
|
717
|
+
y: bigint;
|
|
718
|
+
};
|
|
719
|
+
c2: {
|
|
720
|
+
x: bigint;
|
|
721
|
+
y: bigint;
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
proof: {
|
|
725
|
+
commitment: bigint;
|
|
726
|
+
challenge: bigint;
|
|
727
|
+
response: bigint;
|
|
728
|
+
};
|
|
729
|
+
}): Promise<string>;
|
|
730
|
+
/** Withdraw from encrypted balance to public. */
|
|
731
|
+
withdraw(params: {
|
|
732
|
+
amount: bigint;
|
|
733
|
+
encryptedDelta: {
|
|
734
|
+
c1: {
|
|
735
|
+
x: bigint;
|
|
736
|
+
y: bigint;
|
|
737
|
+
};
|
|
738
|
+
c2: {
|
|
739
|
+
x: bigint;
|
|
740
|
+
y: bigint;
|
|
741
|
+
};
|
|
742
|
+
};
|
|
743
|
+
proof: {
|
|
744
|
+
commitment: bigint;
|
|
745
|
+
challenge: bigint;
|
|
746
|
+
response: bigint;
|
|
747
|
+
};
|
|
748
|
+
rangeProofData?: string[];
|
|
749
|
+
}): Promise<string>;
|
|
750
|
+
/** Private transfer between accounts. */
|
|
751
|
+
privateTransfer(params: {
|
|
752
|
+
to: string;
|
|
753
|
+
senderCipher: {
|
|
754
|
+
c1: {
|
|
755
|
+
x: bigint;
|
|
756
|
+
y: bigint;
|
|
757
|
+
};
|
|
758
|
+
c2: {
|
|
759
|
+
x: bigint;
|
|
760
|
+
y: bigint;
|
|
761
|
+
};
|
|
762
|
+
};
|
|
763
|
+
receiverCipher: {
|
|
764
|
+
c1: {
|
|
765
|
+
x: bigint;
|
|
766
|
+
y: bigint;
|
|
767
|
+
};
|
|
768
|
+
c2: {
|
|
769
|
+
x: bigint;
|
|
770
|
+
y: bigint;
|
|
771
|
+
};
|
|
772
|
+
};
|
|
773
|
+
proof: {
|
|
774
|
+
commitment: bigint;
|
|
775
|
+
challenge: bigint;
|
|
776
|
+
response: bigint;
|
|
777
|
+
};
|
|
778
|
+
senderAeHint: bigint;
|
|
779
|
+
receiverAeHint: bigint;
|
|
780
|
+
}): Promise<string>;
|
|
781
|
+
/** Request disclosure of a nullifier (audit). */
|
|
782
|
+
requestDisclosure(nullifier: string, reason: string): Promise<string>;
|
|
783
|
+
/** Ragequit: emergency withdrawal with proof. */
|
|
784
|
+
ragequit(proof: string[]): Promise<string>;
|
|
785
|
+
/** Get the nullifier tree state. */
|
|
786
|
+
getNullifierTreeState(): Promise<{
|
|
787
|
+
root: string;
|
|
788
|
+
size: number;
|
|
789
|
+
}>;
|
|
790
|
+
/** Get account balance hints (for O(1) decryption). */
|
|
791
|
+
getAccountHints(address: string): Promise<{
|
|
792
|
+
balanceHint: bigint;
|
|
793
|
+
pendingInHint: bigint;
|
|
794
|
+
pendingOutHint: bigint;
|
|
795
|
+
} | null>;
|
|
469
796
|
}
|
|
470
797
|
|
|
471
798
|
/**
|
|
@@ -476,6 +803,18 @@ declare class PrivacyRouterClient {
|
|
|
476
803
|
* privacy pool → swap → re-deposit flow.
|
|
477
804
|
*/
|
|
478
805
|
|
|
806
|
+
interface ShieldedSwapParams {
|
|
807
|
+
tokenIn: string;
|
|
808
|
+
tokenOut: string;
|
|
809
|
+
amountIn: bigint;
|
|
810
|
+
minAmountOut: bigint;
|
|
811
|
+
nullifier: string;
|
|
812
|
+
merkleRoot: string;
|
|
813
|
+
merkleProof: string[];
|
|
814
|
+
newCommitment: string;
|
|
815
|
+
encryptedAmount: bigint;
|
|
816
|
+
proof: string;
|
|
817
|
+
}
|
|
479
818
|
declare class ShieldedSwapClient {
|
|
480
819
|
private readonly obelysk;
|
|
481
820
|
constructor(obelysk: ObelyskClient);
|
|
@@ -493,6 +832,433 @@ declare class ShieldedSwapClient {
|
|
|
493
832
|
} | null>;
|
|
494
833
|
/** Get contract owner. */
|
|
495
834
|
getOwner(): Promise<string>;
|
|
835
|
+
/**
|
|
836
|
+
* Execute a shielded swap (privacy pool -> AMM -> re-deposit).
|
|
837
|
+
* This is the full privacy-preserving swap flow.
|
|
838
|
+
*/
|
|
839
|
+
shieldedSwap(params: ShieldedSwapParams): Promise<string>;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* VM31 UTXO Privacy Vault Client
|
|
844
|
+
*
|
|
845
|
+
* Wraps both on-chain VM31Pool contract reads and the VM31 relayer HTTP API
|
|
846
|
+
* for transaction submission. The VM31 system uses Poseidon2-M31 hashing
|
|
847
|
+
* with a UTXO model for confidential token transfers.
|
|
848
|
+
*
|
|
849
|
+
* On-chain reads go through `callContract()` to the VM31Pool.
|
|
850
|
+
* Transaction submissions (deposit/withdraw/transfer) go through the
|
|
851
|
+
* VM31 relayer HTTP API, which batches and proves transactions.
|
|
852
|
+
*/
|
|
853
|
+
|
|
854
|
+
interface PackedDigest {
|
|
855
|
+
lo: string;
|
|
856
|
+
hi: string;
|
|
857
|
+
}
|
|
858
|
+
type VM31AssetId = number;
|
|
859
|
+
type BatchStatus = 'queued' | 'proving' | 'confirmed' | 'finalized' | 'error';
|
|
860
|
+
interface VaultNote {
|
|
861
|
+
owner_pubkey: [number, number, number, number];
|
|
862
|
+
asset_id: number;
|
|
863
|
+
amount_lo: number;
|
|
864
|
+
amount_hi: number;
|
|
865
|
+
blinding: [number, number, number, number];
|
|
866
|
+
}
|
|
867
|
+
interface VaultMerklePath {
|
|
868
|
+
siblings: number[][];
|
|
869
|
+
index: number;
|
|
870
|
+
}
|
|
871
|
+
interface VaultDepositParams {
|
|
872
|
+
amount: bigint;
|
|
873
|
+
assetId: number;
|
|
874
|
+
recipientPubkey: [number, number, number, number];
|
|
875
|
+
recipientViewingKey: [number, number, number, number];
|
|
876
|
+
}
|
|
877
|
+
interface VaultWithdrawParams {
|
|
878
|
+
amount: bigint;
|
|
879
|
+
assetId: number;
|
|
880
|
+
note: VaultNote;
|
|
881
|
+
spendingKey: [number, number, number, number];
|
|
882
|
+
merklePath: VaultMerklePath;
|
|
883
|
+
merkleRoot: number[];
|
|
884
|
+
withdrawalBinding: number[];
|
|
885
|
+
bindingSalt?: number[];
|
|
886
|
+
}
|
|
887
|
+
interface VaultTransferParams {
|
|
888
|
+
amount: bigint;
|
|
889
|
+
assetId: number;
|
|
890
|
+
recipientPubkey: [number, number, number, number];
|
|
891
|
+
recipientViewingKey: [number, number, number, number];
|
|
892
|
+
senderViewingKey: [number, number, number, number];
|
|
893
|
+
inputNotes: Array<{
|
|
894
|
+
note: VaultNote;
|
|
895
|
+
spendingKey: [number, number, number, number];
|
|
896
|
+
merklePath: VaultMerklePath;
|
|
897
|
+
}>;
|
|
898
|
+
merkleRoot: number[];
|
|
899
|
+
}
|
|
900
|
+
interface VaultSubmitResult {
|
|
901
|
+
status: 'queued' | 'batch_triggered' | 'duplicate';
|
|
902
|
+
batchId?: string;
|
|
903
|
+
queuePosition?: number;
|
|
904
|
+
idempotencyKey?: string;
|
|
905
|
+
}
|
|
906
|
+
interface VaultBatchInfo {
|
|
907
|
+
id: string;
|
|
908
|
+
status: BatchStatus;
|
|
909
|
+
txCount: number;
|
|
910
|
+
proofHash?: string;
|
|
911
|
+
batchIdOnchain?: string;
|
|
912
|
+
txHash?: string;
|
|
913
|
+
createdAt?: string;
|
|
914
|
+
error?: string;
|
|
915
|
+
}
|
|
916
|
+
interface RelayerInfo {
|
|
917
|
+
pendingTransactions: number;
|
|
918
|
+
batchMaxSize: number;
|
|
919
|
+
batchTimeoutSecs: number;
|
|
920
|
+
}
|
|
921
|
+
declare class VM31VaultClient {
|
|
922
|
+
private readonly obelysk;
|
|
923
|
+
constructor(obelysk: ObelyskClient);
|
|
924
|
+
private get contractAddress();
|
|
925
|
+
private get relayerUrl();
|
|
926
|
+
private get relayerApiKey();
|
|
927
|
+
private relayerFetch;
|
|
928
|
+
/** Get the current Merkle root of the VM31 commitment tree */
|
|
929
|
+
getMerkleRoot(): Promise<PackedDigest>;
|
|
930
|
+
/** Get the number of leaves in the commitment tree */
|
|
931
|
+
getTreeSize(): Promise<number>;
|
|
932
|
+
/** Check if a nullifier has been spent */
|
|
933
|
+
isNullifierSpent(nullifier: PackedDigest): Promise<boolean>;
|
|
934
|
+
/** Check if a Merkle root is known (valid historical root) */
|
|
935
|
+
isKnownRoot(root: PackedDigest): Promise<boolean>;
|
|
936
|
+
/** Get the total balance of an asset held in the pool */
|
|
937
|
+
getAssetBalance(assetId: number): Promise<bigint>;
|
|
938
|
+
/** Get on-chain batch status (0=NONE, 1=SUBMITTED, 2=FINALIZED, 3=CANCELLED) */
|
|
939
|
+
getBatchStatus(batchId: string): Promise<number>;
|
|
940
|
+
/** Get the currently active batch ID */
|
|
941
|
+
getActiveBatchId(): Promise<string>;
|
|
942
|
+
/** Get total transaction count in a batch */
|
|
943
|
+
getBatchTotalTxs(batchId: string): Promise<number>;
|
|
944
|
+
/** Get number of processed transactions in a batch */
|
|
945
|
+
getBatchProcessedCount(batchId: string): Promise<number>;
|
|
946
|
+
/** Get the ERC-20 token address for a VM31 asset ID */
|
|
947
|
+
getAssetToken(assetId: number): Promise<string>;
|
|
948
|
+
/** Get the VM31 asset ID for a given ERC-20 token address */
|
|
949
|
+
getTokenAsset(tokenAddress: string): Promise<number>;
|
|
950
|
+
/** Check if the VM31Pool contract is paused */
|
|
951
|
+
isPaused(): Promise<boolean>;
|
|
952
|
+
/** Get the contract owner address */
|
|
953
|
+
getOwner(): Promise<string>;
|
|
954
|
+
/** Get the authorized relayer address */
|
|
955
|
+
getRelayer(): Promise<string>;
|
|
956
|
+
/** Get batch timeout in blocks */
|
|
957
|
+
getBatchTimeoutBlocks(): Promise<number>;
|
|
958
|
+
/** Check relayer health (no auth required) */
|
|
959
|
+
getRelayerHealth(): Promise<{
|
|
960
|
+
status: string;
|
|
961
|
+
version: string;
|
|
962
|
+
service: string;
|
|
963
|
+
}>;
|
|
964
|
+
/** Get relayer queue status */
|
|
965
|
+
getRelayerStatus(): Promise<RelayerInfo>;
|
|
966
|
+
/** Get the relayer's public encryption key */
|
|
967
|
+
getRelayerPublicKey(): Promise<{
|
|
968
|
+
publicKey: string;
|
|
969
|
+
version: number;
|
|
970
|
+
algorithm: string;
|
|
971
|
+
}>;
|
|
972
|
+
/** Submit a deposit transaction to the relayer */
|
|
973
|
+
submitDeposit(params: VaultDepositParams): Promise<VaultSubmitResult>;
|
|
974
|
+
/** Submit a withdrawal transaction to the relayer */
|
|
975
|
+
submitWithdraw(params: VaultWithdrawParams): Promise<VaultSubmitResult>;
|
|
976
|
+
/** Submit a private transfer transaction to the relayer */
|
|
977
|
+
submitTransfer(params: VaultTransferParams): Promise<VaultSubmitResult>;
|
|
978
|
+
/** Query batch info from the relayer */
|
|
979
|
+
queryBatch(batchId: string): Promise<VaultBatchInfo>;
|
|
980
|
+
/** Fetch Merkle path for a commitment from the relayer */
|
|
981
|
+
fetchMerklePath(commitment: string): Promise<{
|
|
982
|
+
commitment: string;
|
|
983
|
+
merklePath: VaultMerklePath | null;
|
|
984
|
+
merkleRoot: number[] | null;
|
|
985
|
+
batchId: string | null;
|
|
986
|
+
createdAt?: string;
|
|
987
|
+
status?: string;
|
|
988
|
+
}>;
|
|
989
|
+
/** Force the relayer to prove the current batch immediately */
|
|
990
|
+
forceProve(): Promise<{
|
|
991
|
+
status: string;
|
|
992
|
+
batchId?: string;
|
|
993
|
+
}>;
|
|
994
|
+
/** Encode a bigint amount into M31 lo/hi pair (31-bit limbs) */
|
|
995
|
+
static encodeAmountM31(amount: bigint): {
|
|
996
|
+
lo: number;
|
|
997
|
+
hi: number;
|
|
998
|
+
};
|
|
999
|
+
/** Decode an M31 lo/hi pair back into a bigint amount */
|
|
1000
|
+
static decodeAmountM31(lo: number, hi: number): bigint;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* VM31 Confidential Bridge Client
|
|
1005
|
+
*
|
|
1006
|
+
* Read-only views into the VM31Bridge contract, which facilitates
|
|
1007
|
+
* bridging between the VM31 UTXO pool and the ElGamal-based
|
|
1008
|
+
* ConfidentialTransfer system.
|
|
1009
|
+
*/
|
|
1010
|
+
|
|
1011
|
+
interface AssetPair {
|
|
1012
|
+
vm31AssetId: string;
|
|
1013
|
+
confidentialAssetId: string;
|
|
1014
|
+
}
|
|
1015
|
+
interface BridgeConfig {
|
|
1016
|
+
relayer: string;
|
|
1017
|
+
vm31Pool: string;
|
|
1018
|
+
confidentialTransfer: string;
|
|
1019
|
+
}
|
|
1020
|
+
declare class VM31BridgeClient {
|
|
1021
|
+
private readonly obelysk;
|
|
1022
|
+
constructor(obelysk: ObelyskClient);
|
|
1023
|
+
private get contractAddress();
|
|
1024
|
+
/** Get the authorized relayer address */
|
|
1025
|
+
getRelayer(): Promise<string>;
|
|
1026
|
+
/** Get the VM31Pool contract address */
|
|
1027
|
+
getVM31Pool(): Promise<string>;
|
|
1028
|
+
/** Get the ConfidentialTransfer contract address */
|
|
1029
|
+
getConfidentialTransfer(): Promise<string>;
|
|
1030
|
+
/** Get the asset pair mapping for a given token address */
|
|
1031
|
+
getAssetPair(tokenAddress: string): Promise<AssetPair | null>;
|
|
1032
|
+
/** Check if a bridge key has already been processed */
|
|
1033
|
+
isBridgeKeyProcessed(bridgeKey: string): Promise<boolean>;
|
|
1034
|
+
/** Compute a bridge key from withdrawal parameters */
|
|
1035
|
+
computeBridgeKey(params: {
|
|
1036
|
+
batchId: string;
|
|
1037
|
+
withdrawalIdx: number;
|
|
1038
|
+
payoutRecipient: string;
|
|
1039
|
+
creditRecipient: string;
|
|
1040
|
+
token: string;
|
|
1041
|
+
amount: bigint;
|
|
1042
|
+
}): Promise<string>;
|
|
1043
|
+
/** Get full bridge configuration (relayer, vm31Pool, confidentialTransfer) */
|
|
1044
|
+
getConfig(): Promise<BridgeConfig>;
|
|
1045
|
+
/** Get pending upgrade info, if any */
|
|
1046
|
+
getPendingUpgrade(): Promise<{
|
|
1047
|
+
classHash: string;
|
|
1048
|
+
scheduledAt: number;
|
|
1049
|
+
} | null>;
|
|
1050
|
+
/** Check if the bridge contract is paused */
|
|
1051
|
+
isPaused(): Promise<boolean>;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* OTC Orderbook Client
|
|
1056
|
+
*
|
|
1057
|
+
* On-chain limit/market order book for peer-to-peer token trading.
|
|
1058
|
+
* Supports limit orders, market orders, batch operations, and
|
|
1059
|
+
* real-time orderbook depth queries.
|
|
1060
|
+
*/
|
|
1061
|
+
|
|
1062
|
+
declare enum OrderSide {
|
|
1063
|
+
Buy = 0,
|
|
1064
|
+
Sell = 1
|
|
1065
|
+
}
|
|
1066
|
+
declare enum OrderType {
|
|
1067
|
+
Limit = 0,
|
|
1068
|
+
Market = 1
|
|
1069
|
+
}
|
|
1070
|
+
declare enum OrderStatus {
|
|
1071
|
+
Open = 0,
|
|
1072
|
+
PartialFill = 1,
|
|
1073
|
+
Filled = 2,
|
|
1074
|
+
Cancelled = 3,
|
|
1075
|
+
Expired = 4
|
|
1076
|
+
}
|
|
1077
|
+
interface TradingPair {
|
|
1078
|
+
baseToken: string;
|
|
1079
|
+
quoteToken: string;
|
|
1080
|
+
minOrderSize: bigint;
|
|
1081
|
+
tickSize: bigint;
|
|
1082
|
+
isActive: boolean;
|
|
1083
|
+
}
|
|
1084
|
+
interface OTCOrder {
|
|
1085
|
+
orderId: bigint;
|
|
1086
|
+
maker: string;
|
|
1087
|
+
pairId: number;
|
|
1088
|
+
side: OrderSide;
|
|
1089
|
+
orderType: OrderType;
|
|
1090
|
+
price: bigint;
|
|
1091
|
+
remaining: bigint;
|
|
1092
|
+
amount: bigint;
|
|
1093
|
+
status: OrderStatus;
|
|
1094
|
+
createdAt: number;
|
|
1095
|
+
expiresAt: number;
|
|
1096
|
+
}
|
|
1097
|
+
interface OTCTrade {
|
|
1098
|
+
tradeId: bigint;
|
|
1099
|
+
makerOrderId: bigint;
|
|
1100
|
+
takerOrderId: bigint;
|
|
1101
|
+
maker: string;
|
|
1102
|
+
taker: string;
|
|
1103
|
+
price: bigint;
|
|
1104
|
+
amount: bigint;
|
|
1105
|
+
quoteAmount: bigint;
|
|
1106
|
+
executedAt: number;
|
|
1107
|
+
}
|
|
1108
|
+
interface OrderbookConfig {
|
|
1109
|
+
makerFeeBps: number;
|
|
1110
|
+
takerFeeBps: number;
|
|
1111
|
+
defaultExpirySecs: number;
|
|
1112
|
+
maxOrdersPerUser: number;
|
|
1113
|
+
paused: boolean;
|
|
1114
|
+
}
|
|
1115
|
+
interface PlaceLimitOrderParams {
|
|
1116
|
+
pairId: number;
|
|
1117
|
+
side: OrderSide;
|
|
1118
|
+
price: bigint;
|
|
1119
|
+
amount: bigint;
|
|
1120
|
+
/** Seconds until expiry. 0 or undefined uses the contract default. */
|
|
1121
|
+
expiresIn?: number;
|
|
1122
|
+
}
|
|
1123
|
+
interface PlaceMarketOrderParams {
|
|
1124
|
+
pairId: number;
|
|
1125
|
+
side: OrderSide;
|
|
1126
|
+
amount: bigint;
|
|
1127
|
+
}
|
|
1128
|
+
interface OrderbookDepthLevel {
|
|
1129
|
+
price: bigint;
|
|
1130
|
+
totalAmount: bigint;
|
|
1131
|
+
orderCount: number;
|
|
1132
|
+
}
|
|
1133
|
+
interface OrderbookDepth {
|
|
1134
|
+
bids: OrderbookDepthLevel[];
|
|
1135
|
+
asks: OrderbookDepthLevel[];
|
|
1136
|
+
}
|
|
1137
|
+
interface Stats24h {
|
|
1138
|
+
volume: bigint;
|
|
1139
|
+
high: bigint;
|
|
1140
|
+
low: bigint;
|
|
1141
|
+
tradeCount: bigint;
|
|
1142
|
+
}
|
|
1143
|
+
declare class OTCOrderbookClient {
|
|
1144
|
+
private readonly obelysk;
|
|
1145
|
+
constructor(obelysk: ObelyskClient);
|
|
1146
|
+
private get contractAddress();
|
|
1147
|
+
/**
|
|
1148
|
+
* Place a limit order on the orderbook.
|
|
1149
|
+
*
|
|
1150
|
+
* The contract handles internal matching against resting orders.
|
|
1151
|
+
* Returns the transaction hash.
|
|
1152
|
+
*/
|
|
1153
|
+
placeLimitOrder(params: PlaceLimitOrderParams): Promise<string>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Place a market order that fills immediately against resting liquidity.
|
|
1156
|
+
* Returns the transaction hash.
|
|
1157
|
+
*/
|
|
1158
|
+
placeMarketOrder(params: PlaceMarketOrderParams): Promise<string>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Cancel a single order by ID.
|
|
1161
|
+
* Only the maker can cancel their own order.
|
|
1162
|
+
*/
|
|
1163
|
+
cancelOrder(orderId: bigint): Promise<string>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Cancel all open orders for the caller.
|
|
1166
|
+
*/
|
|
1167
|
+
cancelAllOrders(): Promise<string>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Place multiple limit orders in a single transaction.
|
|
1170
|
+
*
|
|
1171
|
+
* Cairo expects an array of (u8, OrderSide, u256, u256, u64) tuples.
|
|
1172
|
+
* Calldata: [length, ...flattened orders].
|
|
1173
|
+
*/
|
|
1174
|
+
batchPlaceOrders(orders: PlaceLimitOrderParams[]): Promise<string>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Cancel multiple orders in a single transaction.
|
|
1177
|
+
*
|
|
1178
|
+
* Calldata: [length, ...flattened u256 order IDs].
|
|
1179
|
+
*/
|
|
1180
|
+
batchCancelOrders(orderIds: bigint[]): Promise<string>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Get a single order by ID.
|
|
1183
|
+
*/
|
|
1184
|
+
getOrder(orderId: bigint): Promise<OTCOrder>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Get all order IDs belonging to a user.
|
|
1187
|
+
*/
|
|
1188
|
+
getUserOrders(user: string): Promise<bigint[]>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Get the best (highest) bid price for a trading pair.
|
|
1191
|
+
*/
|
|
1192
|
+
getBestBid(pairId: number): Promise<bigint>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Get the best (lowest) ask price for a trading pair.
|
|
1195
|
+
*/
|
|
1196
|
+
getBestAsk(pairId: number): Promise<bigint>;
|
|
1197
|
+
/**
|
|
1198
|
+
* Get the bid-ask spread for a trading pair.
|
|
1199
|
+
*/
|
|
1200
|
+
getSpread(pairId: number): Promise<bigint>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Get trading pair configuration.
|
|
1203
|
+
*/
|
|
1204
|
+
getPair(pairId: number): Promise<TradingPair>;
|
|
1205
|
+
/**
|
|
1206
|
+
* Get the orderbook configuration (fees, limits, pause state).
|
|
1207
|
+
*/
|
|
1208
|
+
getConfig(): Promise<OrderbookConfig>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Get aggregate orderbook statistics.
|
|
1211
|
+
*/
|
|
1212
|
+
getStats(): Promise<{
|
|
1213
|
+
orderCount: bigint;
|
|
1214
|
+
tradeCount: bigint;
|
|
1215
|
+
totalVolume: bigint;
|
|
1216
|
+
totalFees: bigint;
|
|
1217
|
+
}>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Get total number of orders ever placed.
|
|
1220
|
+
*/
|
|
1221
|
+
getOrderCount(): Promise<bigint>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Get total number of trades executed.
|
|
1224
|
+
*/
|
|
1225
|
+
getTradeCount(): Promise<bigint>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Get the time-weighted average price for a trading pair.
|
|
1228
|
+
*/
|
|
1229
|
+
getTwap(pairId: number): Promise<bigint>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Get 24-hour rolling statistics for a trading pair.
|
|
1232
|
+
*/
|
|
1233
|
+
get24hStats(pairId: number): Promise<Stats24h>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Get the most recent trade for a trading pair.
|
|
1236
|
+
*/
|
|
1237
|
+
getLastTrade(pairId: number): Promise<{
|
|
1238
|
+
price: bigint;
|
|
1239
|
+
amount: bigint;
|
|
1240
|
+
timestamp: number;
|
|
1241
|
+
}>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get the orderbook depth (price levels) for a trading pair.
|
|
1244
|
+
*
|
|
1245
|
+
* Returns up to `maxLevels` aggregated price levels for both
|
|
1246
|
+
* bids and asks. Each level contains price, total amount, and
|
|
1247
|
+
* number of orders at that price.
|
|
1248
|
+
*/
|
|
1249
|
+
getOrderbookDepth(pairId: number, maxLevels: number): Promise<OrderbookDepth>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Get active orders for a trading pair with pagination.
|
|
1252
|
+
*/
|
|
1253
|
+
getActiveOrders(pairId: number, offset: number, limit: number): Promise<OTCOrder[]>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Get trade history for a trading pair with pagination.
|
|
1256
|
+
*/
|
|
1257
|
+
getTradeHistory(pairId: number, offset: number, limit: number): Promise<OTCTrade[]>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Get the contract owner address.
|
|
1260
|
+
*/
|
|
1261
|
+
getOwner(): Promise<string>;
|
|
496
1262
|
}
|
|
497
1263
|
|
|
498
1264
|
/**
|
|
@@ -532,6 +1298,10 @@ interface ObelyskConfig {
|
|
|
532
1298
|
rpcUrl?: string;
|
|
533
1299
|
/** Optional privacy key pair (hex private key). If omitted, generated fresh. */
|
|
534
1300
|
privacyPrivateKey?: string;
|
|
1301
|
+
/** VM31 relayer URL (default: https://relay.bitsage.network:3080) */
|
|
1302
|
+
relayerUrl?: string;
|
|
1303
|
+
/** VM31 relayer API key */
|
|
1304
|
+
relayerApiKey?: string;
|
|
535
1305
|
}
|
|
536
1306
|
declare class ObelyskClient {
|
|
537
1307
|
readonly network: ObelyskNetwork;
|
|
@@ -541,6 +1311,8 @@ declare class ObelyskClient {
|
|
|
541
1311
|
readonly contracts: Record<string, string>;
|
|
542
1312
|
readonly tokens: Record<string, string>;
|
|
543
1313
|
readonly privacyPools: Record<string, string>;
|
|
1314
|
+
readonly relayerUrl?: string;
|
|
1315
|
+
readonly relayerApiKey?: string;
|
|
544
1316
|
/** Privacy Pool operations (deposit/withdraw shielded tokens) */
|
|
545
1317
|
readonly privacyPool: PrivacyPoolClient;
|
|
546
1318
|
/** DarkPool batch auction trading */
|
|
@@ -555,6 +1327,12 @@ declare class ObelyskClient {
|
|
|
555
1327
|
readonly router: PrivacyRouterClient;
|
|
556
1328
|
/** Shielded swap router (privacy-preserving AMM swaps) */
|
|
557
1329
|
readonly swap: ShieldedSwapClient;
|
|
1330
|
+
/** VM31 UTXO privacy vault (deposits/withdrawals/transfers via relayer) */
|
|
1331
|
+
readonly vm31: VM31VaultClient;
|
|
1332
|
+
/** VM31 confidential bridge (bridge VM31 withdrawals to encrypted balances) */
|
|
1333
|
+
readonly bridge: VM31BridgeClient;
|
|
1334
|
+
/** OTC orderbook (limit/market orders, trade history) */
|
|
1335
|
+
readonly otc: OTCOrderbookClient;
|
|
558
1336
|
constructor(config: ObelyskConfig);
|
|
559
1337
|
/** Get token address by symbol */
|
|
560
1338
|
getTokenAddress(symbol: string): string;
|
|
@@ -564,4 +1342,4 @@ declare class ObelyskClient {
|
|
|
564
1342
|
requireAccount(): Account;
|
|
565
1343
|
}
|
|
566
1344
|
|
|
567
|
-
export { type CommitOrderParams, ConfidentialTransferClient, DARKPOOL_ASSET_IDS, DarkPoolClient, type DarkPoolDepositParams, type DarkPoolOrderData, type DepositParams, type DepositResult, ECPoint, type EpochInfo, type GpuTier, MAINNET_PRIVACY_POOLS, MAINNET_TOKENS, ObelyskClient, type ObelyskConfig, type ObelyskNetwork, ObelyskPrivacy, type PrivacyNote, PrivacyPoolClient, PrivacyRouterClient, type PrivateAccount, ProverStakingClient, type RevealOrderParams, ShieldedSwapClient, type StakingConfig, StealthClient, type StealthMetaAddress, type StealthSendParams, TOKEN_DECIMALS, type TransferParams, VM31_ASSET_IDS, type WithdrawParams, type WithdrawResult, type WorkerStake, commitmentToHash, createAEHint, createEncryptionProof, deriveNullifier, ecAdd, ecMul, elgamalEncrypt, formatAmount, getContracts, getRpcUrl, mod, modInverse, parseAmount, pedersenCommit, randomScalar };
|
|
1345
|
+
export { type AssetPair, type BatchStatus, type BridgeConfig, type ClaimFillParams, type ClaimParams, type CommitOrderParams, ConfidentialTransferClient, DARKPOOL_ASSET_IDS, DarkPoolClient, type DarkPoolDepositParams, type DarkPoolOrderData, type DepositParams, type DepositResult, ECPoint, type EpochInfo, type FundParams, type GpuTier, MAINNET_PRIVACY_POOLS, MAINNET_TOKENS, type OTCOrder, OTCOrderbookClient, type OTCTrade, ObelyskClient, type ObelyskConfig, type ObelyskNetwork, ObelyskPrivacy, OrderSide, OrderStatus, OrderType, type OrderbookConfig, type OrderbookDepth, type OrderbookDepthLevel, type PackedDigest, type PlaceLimitOrderParams, type PlaceMarketOrderParams, type PrivacyNote, PrivacyPoolClient, PrivacyRouterClient, type PrivateAccount, ProverStakingClient, type RelayerInfo, type RevealOrderParams, ShieldedSwapClient, type ShieldedSwapParams, type StakingConfig, type Stats24h, type StealthAnnouncement, StealthClient, type StealthMetaAddress, type StealthSendParams, type StealthSpendingProof, TOKEN_DECIMALS, type TradingPair, type TransferParams, type VM31AssetId, VM31BridgeClient, VM31VaultClient, VM31_ASSET_IDS, type VaultBatchInfo, type VaultDepositParams, type VaultMerklePath, type VaultNote, type VaultSubmitResult, type VaultTransferParams, type VaultWithdrawParams, type WithdrawCTParams, type WithdrawParams, type WithdrawResult, type WorkerStake, commitmentToHash, createAEHint, createEncryptionProof, deriveNullifier, ecAdd, ecMul, elgamalEncrypt, formatAmount, getContracts, getRpcUrl, mod, modInverse, parseAmount, pedersenCommit, randomScalar };
|