@circuit-llm/vault 0.2.1

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.
@@ -0,0 +1,1548 @@
1
+ import * as anchor from '@anchor-lang/core';
2
+
3
+ /**
4
+ * Program IDL in camelCase format in order to be used in JS/TS.
5
+ *
6
+ * Note that this is only a type helper and is not the actual IDL. The original
7
+ * IDL can be found at `target/idl/circuit_agent_vault.json`.
8
+ */
9
+ type CircuitAgentVault = {
10
+ "address": "9AmhsDD9AwUM57pLwYsmNWhjdAP5vTy2HXxqbdKRaxXA";
11
+ "metadata": {
12
+ "name": "circuitAgentVault";
13
+ "version": "0.1.0";
14
+ "spec": "0.1.0";
15
+ "description": "Created with Anchor";
16
+ };
17
+ "instructions": [
18
+ {
19
+ "name": "closeVault";
20
+ "docs": [
21
+ "OWNER-ONLY. Close the vault and return ALL remaining lamports to the owner (Anchor `close`).",
22
+ "Phase 1 is SOL-only; Phase 3 adds a guard that token balances are zero before close."
23
+ ];
24
+ "discriminator": [
25
+ 141,
26
+ 103,
27
+ 17,
28
+ 126,
29
+ 72,
30
+ 75,
31
+ 29,
32
+ 29
33
+ ];
34
+ "accounts": [
35
+ {
36
+ "name": "vault";
37
+ "writable": true;
38
+ "pda": {
39
+ "seeds": [
40
+ {
41
+ "kind": "const";
42
+ "value": [
43
+ 118,
44
+ 97,
45
+ 117,
46
+ 108,
47
+ 116
48
+ ];
49
+ },
50
+ {
51
+ "kind": "account";
52
+ "path": "owner";
53
+ },
54
+ {
55
+ "kind": "account";
56
+ "path": "vault.agentSeed";
57
+ "account": "vault";
58
+ }
59
+ ];
60
+ };
61
+ },
62
+ {
63
+ "name": "owner";
64
+ "writable": true;
65
+ "signer": true;
66
+ "relations": [
67
+ "vault"
68
+ ];
69
+ }
70
+ ];
71
+ "args": [];
72
+ },
73
+ {
74
+ "name": "deposit";
75
+ "docs": [
76
+ "Fund the vault with SOL. Anyone may deposit (it's the owner's address either way); the",
77
+ "owner is the only one who can ever take it back out."
78
+ ];
79
+ "discriminator": [
80
+ 242,
81
+ 35,
82
+ 198,
83
+ 137,
84
+ 82,
85
+ 225,
86
+ 242,
87
+ 182
88
+ ];
89
+ "accounts": [
90
+ {
91
+ "name": "vault";
92
+ "writable": true;
93
+ "pda": {
94
+ "seeds": [
95
+ {
96
+ "kind": "const";
97
+ "value": [
98
+ 118,
99
+ 97,
100
+ 117,
101
+ 108,
102
+ 116
103
+ ];
104
+ },
105
+ {
106
+ "kind": "account";
107
+ "path": "vault.owner";
108
+ "account": "vault";
109
+ },
110
+ {
111
+ "kind": "account";
112
+ "path": "vault.agentSeed";
113
+ "account": "vault";
114
+ }
115
+ ];
116
+ };
117
+ },
118
+ {
119
+ "name": "depositor";
120
+ "writable": true;
121
+ "signer": true;
122
+ },
123
+ {
124
+ "name": "systemProgram";
125
+ "address": "11111111111111111111111111111111";
126
+ }
127
+ ];
128
+ "args": [
129
+ {
130
+ "name": "amount";
131
+ "type": "u64";
132
+ }
133
+ ];
134
+ },
135
+ {
136
+ "name": "initVault";
137
+ "docs": [
138
+ "Create a vault. The signer becomes the sovereign OWNER; `delegate` is the agent key that",
139
+ "will (Phase 2) be allowed to trade but never withdraw. One vault per (owner, agent_seed)."
140
+ ];
141
+ "discriminator": [
142
+ 77,
143
+ 79,
144
+ 85,
145
+ 150,
146
+ 33,
147
+ 217,
148
+ 52,
149
+ 106
150
+ ];
151
+ "accounts": [
152
+ {
153
+ "name": "vault";
154
+ "writable": true;
155
+ "pda": {
156
+ "seeds": [
157
+ {
158
+ "kind": "const";
159
+ "value": [
160
+ 118,
161
+ 97,
162
+ 117,
163
+ 108,
164
+ 116
165
+ ];
166
+ },
167
+ {
168
+ "kind": "account";
169
+ "path": "owner";
170
+ },
171
+ {
172
+ "kind": "arg";
173
+ "path": "agentSeed";
174
+ }
175
+ ];
176
+ };
177
+ },
178
+ {
179
+ "name": "owner";
180
+ "writable": true;
181
+ "signer": true;
182
+ },
183
+ {
184
+ "name": "systemProgram";
185
+ "address": "11111111111111111111111111111111";
186
+ }
187
+ ];
188
+ "args": [
189
+ {
190
+ "name": "agentSeed";
191
+ "type": {
192
+ "array": [
193
+ "u8",
194
+ 32
195
+ ];
196
+ };
197
+ },
198
+ {
199
+ "name": "delegate";
200
+ "type": "pubkey";
201
+ },
202
+ {
203
+ "name": "maxTradeLamports";
204
+ "type": "u64";
205
+ },
206
+ {
207
+ "name": "dailyLimitLamports";
208
+ "type": "u64";
209
+ }
210
+ ];
211
+ },
212
+ {
213
+ "name": "setDelegate";
214
+ "docs": [
215
+ "OWNER-ONLY. Rotate or revoke the agent's trading key. Bumps `epoch` so a stale delegate is",
216
+ "fenced out (Phase 2 trades check it)."
217
+ ];
218
+ "discriminator": [
219
+ 242,
220
+ 30,
221
+ 46,
222
+ 76,
223
+ 108,
224
+ 235,
225
+ 128,
226
+ 181
227
+ ];
228
+ "accounts": [
229
+ {
230
+ "name": "vault";
231
+ "writable": true;
232
+ "pda": {
233
+ "seeds": [
234
+ {
235
+ "kind": "const";
236
+ "value": [
237
+ 118,
238
+ 97,
239
+ 117,
240
+ 108,
241
+ 116
242
+ ];
243
+ },
244
+ {
245
+ "kind": "account";
246
+ "path": "owner";
247
+ },
248
+ {
249
+ "kind": "account";
250
+ "path": "vault.agentSeed";
251
+ "account": "vault";
252
+ }
253
+ ];
254
+ };
255
+ },
256
+ {
257
+ "name": "owner";
258
+ "writable": true;
259
+ "signer": true;
260
+ "relations": [
261
+ "vault"
262
+ ];
263
+ }
264
+ ];
265
+ "args": [
266
+ {
267
+ "name": "newDelegate";
268
+ "type": "pubkey";
269
+ }
270
+ ];
271
+ },
272
+ {
273
+ "name": "setRoutes";
274
+ "docs": [
275
+ "OWNER-ONLY. Set the route allowlist (up to 4 swap programs). Pass an empty list to clear it",
276
+ "(back to any-program / guard-only). Defense in depth: lock trading to audited routers so the",
277
+ "guard isn't the sole boundary."
278
+ ];
279
+ "discriminator": [
280
+ 95,
281
+ 172,
282
+ 119,
283
+ 157,
284
+ 123,
285
+ 127,
286
+ 91,
287
+ 208
288
+ ];
289
+ "accounts": [
290
+ {
291
+ "name": "vault";
292
+ "writable": true;
293
+ "pda": {
294
+ "seeds": [
295
+ {
296
+ "kind": "const";
297
+ "value": [
298
+ 118,
299
+ 97,
300
+ 117,
301
+ 108,
302
+ 116
303
+ ];
304
+ },
305
+ {
306
+ "kind": "account";
307
+ "path": "owner";
308
+ },
309
+ {
310
+ "kind": "account";
311
+ "path": "vault.agentSeed";
312
+ "account": "vault";
313
+ }
314
+ ];
315
+ };
316
+ },
317
+ {
318
+ "name": "owner";
319
+ "writable": true;
320
+ "signer": true;
321
+ "relations": [
322
+ "vault"
323
+ ];
324
+ }
325
+ ];
326
+ "args": [
327
+ {
328
+ "name": "programs";
329
+ "type": {
330
+ "vec": "pubkey";
331
+ };
332
+ }
333
+ ];
334
+ },
335
+ {
336
+ "name": "setRule";
337
+ "docs": [
338
+ "OWNER-ONLY. Commit (or clear) the Verified-Intents price rule. `op == 0` disables it. When set,",
339
+ "every trade must present a fresh `oracle`-signed price for `feed` satisfying `price <op> threshold`",
340
+ "(verified via an Ed25519 sibling instruction). This is enforced by the chain, not a server."
341
+ ];
342
+ "discriminator": [
343
+ 237,
344
+ 148,
345
+ 178,
346
+ 172,
347
+ 127,
348
+ 70,
349
+ 114,
350
+ 103
351
+ ];
352
+ "accounts": [
353
+ {
354
+ "name": "vault";
355
+ "writable": true;
356
+ "pda": {
357
+ "seeds": [
358
+ {
359
+ "kind": "const";
360
+ "value": [
361
+ 118,
362
+ 97,
363
+ 117,
364
+ 108,
365
+ 116
366
+ ];
367
+ },
368
+ {
369
+ "kind": "account";
370
+ "path": "owner";
371
+ },
372
+ {
373
+ "kind": "account";
374
+ "path": "vault.agentSeed";
375
+ "account": "vault";
376
+ }
377
+ ];
378
+ };
379
+ },
380
+ {
381
+ "name": "owner";
382
+ "writable": true;
383
+ "signer": true;
384
+ "relations": [
385
+ "vault"
386
+ ];
387
+ }
388
+ ];
389
+ "args": [
390
+ {
391
+ "name": "oracle";
392
+ "type": "pubkey";
393
+ },
394
+ {
395
+ "name": "feed";
396
+ "type": {
397
+ "array": [
398
+ "u8",
399
+ 32
400
+ ];
401
+ };
402
+ },
403
+ {
404
+ "name": "op";
405
+ "type": "u8";
406
+ },
407
+ {
408
+ "name": "threshold";
409
+ "type": "i64";
410
+ },
411
+ {
412
+ "name": "maxAge";
413
+ "type": "i64";
414
+ },
415
+ {
416
+ "name": "inMint";
417
+ "type": "pubkey";
418
+ },
419
+ {
420
+ "name": "outMint";
421
+ "type": "pubkey";
422
+ },
423
+ {
424
+ "name": "maxSlippageBps";
425
+ "type": "u16";
426
+ }
427
+ ];
428
+ },
429
+ {
430
+ "name": "trade";
431
+ "docs": [
432
+ "DELEGATE-ONLY. Execute a swap through ANY program (the agent supplies the program + accounts +",
433
+ "data via remaining_accounts), then GUARD the result on the vault's OWN accounts:",
434
+ "• the vault spends at most `amount_in` of the input, and",
435
+ "• receives at least `min_out` of the output ← the anti-theft line, and",
436
+ "• no OTHER vault-owned token account is involved, and",
437
+ "• NO approval/authority/ownership changed (catches approve / setAuthority that move no balance).",
438
+ "The route is untrusted; the OUTCOME is verified. That's what makes \"trade anything, can't",
439
+ "extract\" true. (Phase 2: cap is in input base units; SOL-notional + slippage-vs-quote is Phase 3.)"
440
+ ];
441
+ "discriminator": [
442
+ 178,
443
+ 144,
444
+ 26,
445
+ 216,
446
+ 241,
447
+ 187,
448
+ 206,
449
+ 130
450
+ ];
451
+ "accounts": [
452
+ {
453
+ "name": "vault";
454
+ "writable": true;
455
+ "pda": {
456
+ "seeds": [
457
+ {
458
+ "kind": "const";
459
+ "value": [
460
+ 118,
461
+ 97,
462
+ 117,
463
+ 108,
464
+ 116
465
+ ];
466
+ },
467
+ {
468
+ "kind": "account";
469
+ "path": "vault.owner";
470
+ "account": "vault";
471
+ },
472
+ {
473
+ "kind": "account";
474
+ "path": "vault.agentSeed";
475
+ "account": "vault";
476
+ }
477
+ ];
478
+ };
479
+ },
480
+ {
481
+ "name": "delegate";
482
+ "signer": true;
483
+ "relations": [
484
+ "vault"
485
+ ];
486
+ },
487
+ {
488
+ "name": "vaultInput";
489
+ "writable": true;
490
+ },
491
+ {
492
+ "name": "vaultOutput";
493
+ "writable": true;
494
+ },
495
+ {
496
+ "name": "swapProgram";
497
+ },
498
+ {
499
+ "name": "tokenProgram";
500
+ },
501
+ {
502
+ "name": "instructions";
503
+ "docs": [
504
+ "(Verified Intents). Address-checked; only read when a rule is active."
505
+ ];
506
+ "address": "Sysvar1nstructions1111111111111111111111111";
507
+ }
508
+ ];
509
+ "args": [
510
+ {
511
+ "name": "amountIn";
512
+ "type": "u64";
513
+ },
514
+ {
515
+ "name": "minOut";
516
+ "type": "u64";
517
+ },
518
+ {
519
+ "name": "swapData";
520
+ "type": "bytes";
521
+ }
522
+ ];
523
+ },
524
+ {
525
+ "name": "unwrapSol";
526
+ "docs": [
527
+ "OWNER-ONLY. Close the vault's wSOL account, returning ALL its lamports (rent + wrapped SOL) to the",
528
+ "vault PDA as native SOL — destination is the vault ONLY, never arbitrary. Owner-only (not delegate):",
529
+ "the agent trades in wSOL and never needs to unwrap; restricting it removes a delegate rent-griefing",
530
+ "vector (repeatedly closing the wSOL account) at no cost to the trading flow (audit hardening)."
531
+ ];
532
+ "discriminator": [
533
+ 99,
534
+ 40,
535
+ 14,
536
+ 105,
537
+ 45,
538
+ 107,
539
+ 172,
540
+ 201
541
+ ];
542
+ "accounts": [
543
+ {
544
+ "name": "vault";
545
+ "writable": true;
546
+ "pda": {
547
+ "seeds": [
548
+ {
549
+ "kind": "const";
550
+ "value": [
551
+ 118,
552
+ 97,
553
+ 117,
554
+ 108,
555
+ 116
556
+ ];
557
+ },
558
+ {
559
+ "kind": "account";
560
+ "path": "vault.owner";
561
+ "account": "vault";
562
+ },
563
+ {
564
+ "kind": "account";
565
+ "path": "vault.agentSeed";
566
+ "account": "vault";
567
+ }
568
+ ];
569
+ };
570
+ },
571
+ {
572
+ "name": "actor";
573
+ "signer": true;
574
+ },
575
+ {
576
+ "name": "wsol";
577
+ "writable": true;
578
+ },
579
+ {
580
+ "name": "tokenProgram";
581
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
582
+ }
583
+ ];
584
+ "args": [];
585
+ },
586
+ {
587
+ "name": "updateConfig";
588
+ "docs": [
589
+ "OWNER-ONLY. Update trading policy + the pause kill-switch. Withdraw still works when paused",
590
+ "(the owner is always sovereign over their funds)."
591
+ ];
592
+ "discriminator": [
593
+ 29,
594
+ 158,
595
+ 252,
596
+ 191,
597
+ 10,
598
+ 83,
599
+ 219,
600
+ 99
601
+ ];
602
+ "accounts": [
603
+ {
604
+ "name": "vault";
605
+ "writable": true;
606
+ "pda": {
607
+ "seeds": [
608
+ {
609
+ "kind": "const";
610
+ "value": [
611
+ 118,
612
+ 97,
613
+ 117,
614
+ 108,
615
+ 116
616
+ ];
617
+ },
618
+ {
619
+ "kind": "account";
620
+ "path": "owner";
621
+ },
622
+ {
623
+ "kind": "account";
624
+ "path": "vault.agentSeed";
625
+ "account": "vault";
626
+ }
627
+ ];
628
+ };
629
+ },
630
+ {
631
+ "name": "owner";
632
+ "writable": true;
633
+ "signer": true;
634
+ "relations": [
635
+ "vault"
636
+ ];
637
+ }
638
+ ];
639
+ "args": [
640
+ {
641
+ "name": "maxTradeLamports";
642
+ "type": "u64";
643
+ },
644
+ {
645
+ "name": "dailyLimitLamports";
646
+ "type": "u64";
647
+ },
648
+ {
649
+ "name": "paused";
650
+ "type": "bool";
651
+ }
652
+ ];
653
+ },
654
+ {
655
+ "name": "withdraw";
656
+ "docs": [
657
+ "OWNER-ONLY. Move SOL out of the vault to the owner. The rent-exempt minimum is protected",
658
+ "so the account stays alive. This is the only exit in Phase 1; the delegate has no path here."
659
+ ];
660
+ "discriminator": [
661
+ 183,
662
+ 18,
663
+ 70,
664
+ 156,
665
+ 148,
666
+ 109,
667
+ 161,
668
+ 34
669
+ ];
670
+ "accounts": [
671
+ {
672
+ "name": "vault";
673
+ "writable": true;
674
+ "pda": {
675
+ "seeds": [
676
+ {
677
+ "kind": "const";
678
+ "value": [
679
+ 118,
680
+ 97,
681
+ 117,
682
+ 108,
683
+ 116
684
+ ];
685
+ },
686
+ {
687
+ "kind": "account";
688
+ "path": "owner";
689
+ },
690
+ {
691
+ "kind": "account";
692
+ "path": "vault.agentSeed";
693
+ "account": "vault";
694
+ }
695
+ ];
696
+ };
697
+ },
698
+ {
699
+ "name": "owner";
700
+ "writable": true;
701
+ "signer": true;
702
+ "relations": [
703
+ "vault"
704
+ ];
705
+ }
706
+ ];
707
+ "args": [
708
+ {
709
+ "name": "amount";
710
+ "type": "u64";
711
+ }
712
+ ];
713
+ },
714
+ {
715
+ "name": "wrapSol";
716
+ "docs": [
717
+ "OWNER-or-DELEGATE. Fund the vault's wSOL trading account with `amount` SOL from the ACTOR's",
718
+ "wallet (system transfer + sync_native). wSOL is what DEXes trade; the agent then swaps it for",
719
+ "tokens via `trade`. Typically the owner calls this to provide trading capital (the agent has no",
720
+ "funds of its own). The wSOL account is authority'd by the vault, so the actor can't redirect it."
721
+ ];
722
+ "discriminator": [
723
+ 47,
724
+ 62,
725
+ 155,
726
+ 172,
727
+ 131,
728
+ 205,
729
+ 37,
730
+ 201
731
+ ];
732
+ "accounts": [
733
+ {
734
+ "name": "vault";
735
+ "pda": {
736
+ "seeds": [
737
+ {
738
+ "kind": "const";
739
+ "value": [
740
+ 118,
741
+ 97,
742
+ 117,
743
+ 108,
744
+ 116
745
+ ];
746
+ },
747
+ {
748
+ "kind": "account";
749
+ "path": "vault.owner";
750
+ "account": "vault";
751
+ },
752
+ {
753
+ "kind": "account";
754
+ "path": "vault.agentSeed";
755
+ "account": "vault";
756
+ }
757
+ ];
758
+ };
759
+ },
760
+ {
761
+ "name": "actor";
762
+ "writable": true;
763
+ "signer": true;
764
+ },
765
+ {
766
+ "name": "wsol";
767
+ "writable": true;
768
+ },
769
+ {
770
+ "name": "tokenProgram";
771
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
772
+ },
773
+ {
774
+ "name": "systemProgram";
775
+ "address": "11111111111111111111111111111111";
776
+ }
777
+ ];
778
+ "args": [
779
+ {
780
+ "name": "amount";
781
+ "type": "u64";
782
+ }
783
+ ];
784
+ }
785
+ ];
786
+ "accounts": [
787
+ {
788
+ "name": "vault";
789
+ "discriminator": [
790
+ 211,
791
+ 8,
792
+ 232,
793
+ 43,
794
+ 2,
795
+ 152,
796
+ 117,
797
+ 119
798
+ ];
799
+ }
800
+ ];
801
+ "events": [
802
+ {
803
+ "name": "delegateSet";
804
+ "discriminator": [
805
+ 103,
806
+ 126,
807
+ 239,
808
+ 131,
809
+ 201,
810
+ 31,
811
+ 212,
812
+ 253
813
+ ];
814
+ },
815
+ {
816
+ "name": "deposited";
817
+ "discriminator": [
818
+ 111,
819
+ 141,
820
+ 26,
821
+ 45,
822
+ 161,
823
+ 35,
824
+ 100,
825
+ 57
826
+ ];
827
+ },
828
+ {
829
+ "name": "routesSet";
830
+ "discriminator": [
831
+ 187,
832
+ 180,
833
+ 223,
834
+ 221,
835
+ 112,
836
+ 127,
837
+ 192,
838
+ 36
839
+ ];
840
+ },
841
+ {
842
+ "name": "ruleSet";
843
+ "discriminator": [
844
+ 141,
845
+ 22,
846
+ 70,
847
+ 140,
848
+ 45,
849
+ 27,
850
+ 175,
851
+ 119
852
+ ];
853
+ },
854
+ {
855
+ "name": "solUnwrapped";
856
+ "discriminator": [
857
+ 251,
858
+ 11,
859
+ 67,
860
+ 67,
861
+ 145,
862
+ 148,
863
+ 119,
864
+ 192
865
+ ];
866
+ },
867
+ {
868
+ "name": "solWrapped";
869
+ "discriminator": [
870
+ 13,
871
+ 17,
872
+ 193,
873
+ 193,
874
+ 199,
875
+ 177,
876
+ 177,
877
+ 23
878
+ ];
879
+ },
880
+ {
881
+ "name": "tradeExecuted";
882
+ "discriminator": [
883
+ 41,
884
+ 110,
885
+ 64,
886
+ 129,
887
+ 60,
888
+ 79,
889
+ 179,
890
+ 80
891
+ ];
892
+ },
893
+ {
894
+ "name": "vaultInitialized";
895
+ "discriminator": [
896
+ 180,
897
+ 43,
898
+ 207,
899
+ 2,
900
+ 18,
901
+ 71,
902
+ 3,
903
+ 75
904
+ ];
905
+ },
906
+ {
907
+ "name": "withdrawn";
908
+ "discriminator": [
909
+ 20,
910
+ 89,
911
+ 223,
912
+ 198,
913
+ 194,
914
+ 124,
915
+ 219,
916
+ 13
917
+ ];
918
+ }
919
+ ];
920
+ "errors": [
921
+ {
922
+ "code": 6000;
923
+ "name": "notOwner";
924
+ "msg": "only the vault owner may perform this action";
925
+ },
926
+ {
927
+ "code": 6001;
928
+ "name": "insufficientFunds";
929
+ "msg": "amount exceeds the withdrawable balance (rent-exempt minimum is protected)";
930
+ },
931
+ {
932
+ "code": 6002;
933
+ "name": "badAmount";
934
+ "msg": "amount must be greater than zero";
935
+ },
936
+ {
937
+ "code": 6003;
938
+ "name": "overflow";
939
+ "msg": "arithmetic overflow";
940
+ },
941
+ {
942
+ "code": 6004;
943
+ "name": "notDelegate";
944
+ "msg": "only the vault delegate may trade";
945
+ },
946
+ {
947
+ "code": 6005;
948
+ "name": "paused";
949
+ "msg": "trading is paused";
950
+ },
951
+ {
952
+ "code": 6006;
953
+ "name": "overTradeCap";
954
+ "msg": "amount_in exceeds the per-trade cap (or is zero)";
955
+ },
956
+ {
957
+ "code": 6007;
958
+ "name": "badMinOut";
959
+ "msg": "min_out must be greater than zero";
960
+ },
961
+ {
962
+ "code": 6008;
963
+ "name": "overDailyCap";
964
+ "msg": "trade exceeds the daily cap";
965
+ },
966
+ {
967
+ "code": 6009;
968
+ "name": "foreignVaultAccount";
969
+ "msg": "the swap may not touch another vault-owned token account";
970
+ },
971
+ {
972
+ "code": 6010;
973
+ "name": "inputIncreased";
974
+ "msg": "vault input balance increased — not a swap";
975
+ },
976
+ {
977
+ "code": 6011;
978
+ "name": "outputDecreased";
979
+ "msg": "vault output balance decreased — value left the vault";
980
+ },
981
+ {
982
+ "code": 6012;
983
+ "name": "slippage";
984
+ "msg": "received less than min_out (value left the vault / slippage)";
985
+ },
986
+ {
987
+ "code": 6013;
988
+ "name": "approvalGranted";
989
+ "msg": "an approval/delegate was granted on a vault account";
990
+ },
991
+ {
992
+ "code": 6014;
993
+ "name": "authorityChanged";
994
+ "msg": "a vault account's authority/mint/ownership changed";
995
+ },
996
+ {
997
+ "code": 6015;
998
+ "name": "notOwnerOrDelegate";
999
+ "msg": "only the vault owner or delegate may wrap/unwrap";
1000
+ },
1001
+ {
1002
+ "code": 6016;
1003
+ "name": "notWsol";
1004
+ "msg": "the account is not a wrapped-SOL (native mint) account";
1005
+ },
1006
+ {
1007
+ "code": 6017;
1008
+ "name": "tooManyRoutes";
1009
+ "msg": "at most 4 allowed route programs";
1010
+ },
1011
+ {
1012
+ "code": 6018;
1013
+ "name": "routeNotAllowed";
1014
+ "msg": "swap program is not in the vault's route allowlist";
1015
+ },
1016
+ {
1017
+ "code": 6019;
1018
+ "name": "badRule";
1019
+ "msg": "invalid rule (op must be 0..=4; max_age required when active)";
1020
+ },
1021
+ {
1022
+ "code": 6020;
1023
+ "name": "noOracleSig";
1024
+ "msg": "no Ed25519 oracle-signature instruction found in the transaction";
1025
+ },
1026
+ {
1027
+ "code": 6021;
1028
+ "name": "wrongOracle";
1029
+ "msg": "the signed price is not from the vault's committed oracle";
1030
+ },
1031
+ {
1032
+ "code": 6022;
1033
+ "name": "badAttestation";
1034
+ "msg": "malformed oracle attestation / Ed25519 instruction";
1035
+ },
1036
+ {
1037
+ "code": 6023;
1038
+ "name": "wrongFeed";
1039
+ "msg": "the attestation is for a different price feed";
1040
+ },
1041
+ {
1042
+ "code": 6024;
1043
+ "name": "staleAttestation";
1044
+ "msg": "the oracle price is stale (outside the freshness window)";
1045
+ },
1046
+ {
1047
+ "code": 6025;
1048
+ "name": "ruleNotSatisfied";
1049
+ "msg": "the trade is not justified by the committed rule (price condition not met)";
1050
+ },
1051
+ {
1052
+ "code": 6026;
1053
+ "name": "wrongDirection";
1054
+ "msg": "the trade's mints don't match the rule's pinned direction";
1055
+ },
1056
+ {
1057
+ "code": 6027;
1058
+ "name": "priceFloor";
1059
+ "msg": "min_out is below the oracle-attested execution floor (bad rate)";
1060
+ },
1061
+ {
1062
+ "code": 6028;
1063
+ "name": "lamportsDecreased";
1064
+ "msg": "the swap debited the vault's native lamports";
1065
+ }
1066
+ ];
1067
+ "types": [
1068
+ {
1069
+ "name": "delegateSet";
1070
+ "type": {
1071
+ "kind": "struct";
1072
+ "fields": [
1073
+ {
1074
+ "name": "vault";
1075
+ "type": "pubkey";
1076
+ },
1077
+ {
1078
+ "name": "delegate";
1079
+ "type": "pubkey";
1080
+ },
1081
+ {
1082
+ "name": "epoch";
1083
+ "type": "u64";
1084
+ }
1085
+ ];
1086
+ };
1087
+ },
1088
+ {
1089
+ "name": "deposited";
1090
+ "type": {
1091
+ "kind": "struct";
1092
+ "fields": [
1093
+ {
1094
+ "name": "vault";
1095
+ "type": "pubkey";
1096
+ },
1097
+ {
1098
+ "name": "amount";
1099
+ "type": "u64";
1100
+ }
1101
+ ];
1102
+ };
1103
+ },
1104
+ {
1105
+ "name": "routesSet";
1106
+ "type": {
1107
+ "kind": "struct";
1108
+ "fields": [
1109
+ {
1110
+ "name": "vault";
1111
+ "type": "pubkey";
1112
+ },
1113
+ {
1114
+ "name": "count";
1115
+ "type": "u8";
1116
+ }
1117
+ ];
1118
+ };
1119
+ },
1120
+ {
1121
+ "name": "ruleSet";
1122
+ "type": {
1123
+ "kind": "struct";
1124
+ "fields": [
1125
+ {
1126
+ "name": "vault";
1127
+ "type": "pubkey";
1128
+ },
1129
+ {
1130
+ "name": "oracle";
1131
+ "type": "pubkey";
1132
+ },
1133
+ {
1134
+ "name": "op";
1135
+ "type": "u8";
1136
+ }
1137
+ ];
1138
+ };
1139
+ },
1140
+ {
1141
+ "name": "solUnwrapped";
1142
+ "type": {
1143
+ "kind": "struct";
1144
+ "fields": [
1145
+ {
1146
+ "name": "vault";
1147
+ "type": "pubkey";
1148
+ }
1149
+ ];
1150
+ };
1151
+ },
1152
+ {
1153
+ "name": "solWrapped";
1154
+ "type": {
1155
+ "kind": "struct";
1156
+ "fields": [
1157
+ {
1158
+ "name": "vault";
1159
+ "type": "pubkey";
1160
+ },
1161
+ {
1162
+ "name": "amount";
1163
+ "type": "u64";
1164
+ }
1165
+ ];
1166
+ };
1167
+ },
1168
+ {
1169
+ "name": "tradeExecuted";
1170
+ "type": {
1171
+ "kind": "struct";
1172
+ "fields": [
1173
+ {
1174
+ "name": "vault";
1175
+ "type": "pubkey";
1176
+ },
1177
+ {
1178
+ "name": "spent";
1179
+ "type": "u64";
1180
+ },
1181
+ {
1182
+ "name": "received";
1183
+ "type": "u64";
1184
+ }
1185
+ ];
1186
+ };
1187
+ },
1188
+ {
1189
+ "name": "vault";
1190
+ "type": {
1191
+ "kind": "struct";
1192
+ "fields": [
1193
+ {
1194
+ "name": "owner";
1195
+ "type": "pubkey";
1196
+ },
1197
+ {
1198
+ "name": "delegate";
1199
+ "type": "pubkey";
1200
+ },
1201
+ {
1202
+ "name": "agentSeed";
1203
+ "type": {
1204
+ "array": [
1205
+ "u8",
1206
+ 32
1207
+ ];
1208
+ };
1209
+ },
1210
+ {
1211
+ "name": "maxTradeLamports";
1212
+ "type": "u64";
1213
+ },
1214
+ {
1215
+ "name": "dailyLimitLamports";
1216
+ "type": "u64";
1217
+ },
1218
+ {
1219
+ "name": "dayStartTs";
1220
+ "type": "i64";
1221
+ },
1222
+ {
1223
+ "name": "daySpentLamports";
1224
+ "type": "u64";
1225
+ },
1226
+ {
1227
+ "name": "lastTradeTs";
1228
+ "type": "i64";
1229
+ },
1230
+ {
1231
+ "name": "epoch";
1232
+ "type": "u64";
1233
+ },
1234
+ {
1235
+ "name": "paused";
1236
+ "type": "bool";
1237
+ },
1238
+ {
1239
+ "name": "oracle";
1240
+ "type": "pubkey";
1241
+ },
1242
+ {
1243
+ "name": "ruleFeed";
1244
+ "type": {
1245
+ "array": [
1246
+ "u8",
1247
+ 32
1248
+ ];
1249
+ };
1250
+ },
1251
+ {
1252
+ "name": "ruleOp";
1253
+ "type": "u8";
1254
+ },
1255
+ {
1256
+ "name": "ruleThreshold";
1257
+ "type": "i64";
1258
+ },
1259
+ {
1260
+ "name": "ruleMaxAge";
1261
+ "type": "i64";
1262
+ },
1263
+ {
1264
+ "name": "ruleInMint";
1265
+ "type": "pubkey";
1266
+ },
1267
+ {
1268
+ "name": "ruleOutMint";
1269
+ "type": "pubkey";
1270
+ },
1271
+ {
1272
+ "name": "maxSlippageBps";
1273
+ "type": "u16";
1274
+ },
1275
+ {
1276
+ "name": "allowedPrograms";
1277
+ "type": {
1278
+ "array": [
1279
+ "pubkey",
1280
+ 4
1281
+ ];
1282
+ };
1283
+ },
1284
+ {
1285
+ "name": "bump";
1286
+ "type": "u8";
1287
+ }
1288
+ ];
1289
+ };
1290
+ },
1291
+ {
1292
+ "name": "vaultInitialized";
1293
+ "type": {
1294
+ "kind": "struct";
1295
+ "fields": [
1296
+ {
1297
+ "name": "vault";
1298
+ "type": "pubkey";
1299
+ },
1300
+ {
1301
+ "name": "owner";
1302
+ "type": "pubkey";
1303
+ },
1304
+ {
1305
+ "name": "delegate";
1306
+ "type": "pubkey";
1307
+ }
1308
+ ];
1309
+ };
1310
+ },
1311
+ {
1312
+ "name": "withdrawn";
1313
+ "type": {
1314
+ "kind": "struct";
1315
+ "fields": [
1316
+ {
1317
+ "name": "vault";
1318
+ "type": "pubkey";
1319
+ },
1320
+ {
1321
+ "name": "to";
1322
+ "type": "pubkey";
1323
+ },
1324
+ {
1325
+ "name": "amount";
1326
+ "type": "u64";
1327
+ }
1328
+ ];
1329
+ };
1330
+ }
1331
+ ];
1332
+ };
1333
+
1334
+ type PublicKey$2 = anchor.web3.PublicKey;
1335
+ type Keypair$1 = anchor.web3.Keypair;
1336
+ type TransactionInstruction$2 = anchor.web3.TransactionInstruction;
1337
+ /** Classic SPL Token program. */
1338
+ declare const TOKEN_PROGRAM_ID: anchor.web3.PublicKey;
1339
+ /** Token-2022 program. */
1340
+ declare const TOKEN_2022_PROGRAM_ID: anchor.web3.PublicKey;
1341
+ type Numeric = number | bigint | anchor.BN | string;
1342
+ /** Identifies a vault: its sovereign owner + the per-agent seed. */
1343
+ interface VaultRef {
1344
+ owner: PublicKey$2;
1345
+ agentSeed: Uint8Array | Buffer;
1346
+ }
1347
+ interface InitParams extends VaultRef {
1348
+ ownerSigner: Keypair$1;
1349
+ delegate: PublicKey$2;
1350
+ maxTradeLamports: Numeric;
1351
+ dailyLimitLamports: Numeric;
1352
+ }
1353
+ interface TradeParams extends VaultRef {
1354
+ delegate: Keypair$1;
1355
+ vaultInput: PublicKey$2;
1356
+ vaultOutput: PublicKey$2;
1357
+ amountIn: Numeric;
1358
+ minOut: Numeric;
1359
+ swapIx: TransactionInstruction$2;
1360
+ tokenProgram?: PublicKey$2;
1361
+ oracleIx?: TransactionInstruction$2;
1362
+ addressLookupTables?: PublicKey$2[];
1363
+ preInstructions?: TransactionInstruction$2[];
1364
+ }
1365
+ declare class VaultClient {
1366
+ readonly program: anchor.Program<CircuitAgentVault>;
1367
+ readonly programId: PublicKey$2;
1368
+ constructor(program: anchor.Program<CircuitAgentVault>);
1369
+ /** Derive the vault PDA for (owner, agentSeed). No private key exists for it — it's a program address. */
1370
+ vaultPda(owner: PublicKey$2, agentSeed: Uint8Array | Buffer): PublicKey$2;
1371
+ /** Fetch the on-chain vault state (config, delegate, rule, routes). */
1372
+ fetch(ref: VaultRef): Promise<{
1373
+ owner: anchor.web3.PublicKey;
1374
+ delegate: anchor.web3.PublicKey;
1375
+ agentSeed: number[];
1376
+ maxTradeLamports: BN;
1377
+ dailyLimitLamports: BN;
1378
+ dayStartTs: BN;
1379
+ daySpentLamports: BN;
1380
+ lastTradeTs: BN;
1381
+ epoch: BN;
1382
+ paused: boolean;
1383
+ oracle: anchor.web3.PublicKey;
1384
+ ruleFeed: number[];
1385
+ ruleOp: number;
1386
+ ruleThreshold: BN;
1387
+ ruleMaxAge: BN;
1388
+ ruleInMint: anchor.web3.PublicKey;
1389
+ ruleOutMint: anchor.web3.PublicKey;
1390
+ maxSlippageBps: number;
1391
+ allowedPrograms: anchor.web3.PublicKey[];
1392
+ bump: number;
1393
+ }>;
1394
+ /** Create a vault. The signer becomes the owner; `delegate` is the agent that may trade. */
1395
+ initVault(p: InitParams): Promise<{
1396
+ vault: PublicKey$2;
1397
+ signature: string;
1398
+ }>;
1399
+ /** Fund the vault with SOL. Anyone may deposit; only the owner can take it back out. */
1400
+ deposit(ref: VaultRef, depositor: Keypair$1, amountLamports: Numeric): Promise<string>;
1401
+ /** OWNER-ONLY. Move SOL out of the vault to the owner. The only exit; the delegate has no path here. */
1402
+ withdraw(ref: VaultRef, ownerSigner: Keypair$1, amountLamports: Numeric): Promise<string>;
1403
+ /** OWNER-ONLY. Rotate or revoke the agent's trading key (bumps the fence epoch). */
1404
+ setDelegate(ref: VaultRef, ownerSigner: Keypair$1, newDelegate: PublicKey$2): Promise<string>;
1405
+ /** OWNER-ONLY. Update trading policy + the pause kill-switch. Withdraw still works when paused. */
1406
+ updateConfig(ref: VaultRef, ownerSigner: Keypair$1, cfg: {
1407
+ maxTradeLamports: Numeric;
1408
+ dailyLimitLamports: Numeric;
1409
+ paused: boolean;
1410
+ }): Promise<string>;
1411
+ /** OWNER-ONLY. Restrict trading to an allowlist of audited routers (≤4). Empty = any program. */
1412
+ setRoutes(ref: VaultRef, ownerSigner: Keypair$1, programs: PublicKey$2[]): Promise<string>;
1413
+ /**
1414
+ * OWNER-ONLY. Commit (or clear) the Verified-Intents price rule. With a rule active, every trade
1415
+ * must carry a fresh oracle-signed price satisfying the condition (see `oracleAttestation`) AND —
1416
+ * if `inMint`/`outMint` are set — match that exact swap direction. `op: 0` clears the rule.
1417
+ */
1418
+ setRule(ref: VaultRef, ownerSigner: Keypair$1, rule: {
1419
+ oracle: PublicKey$2;
1420
+ feed: Uint8Array | Buffer;
1421
+ op: number;
1422
+ threshold: Numeric;
1423
+ maxAge: Numeric;
1424
+ inMint?: PublicKey$2;
1425
+ outMint?: PublicKey$2;
1426
+ maxSlippageBps?: number;
1427
+ }): Promise<string>;
1428
+ /** OWNER-ONLY. Clear any committed rule (trades resume with no attestation). */
1429
+ clearRule(ref: VaultRef, ownerSigner: Keypair$1): Promise<string>;
1430
+ /** OWNER-ONLY. Close the vault and return all remaining lamports to the owner. */
1431
+ closeVault(ref: VaultRef, ownerSigner: Keypair$1): Promise<string>;
1432
+ /** OWNER-or-DELEGATE. Wrap SOL into the vault's wSOL account (funded from `actor`). */
1433
+ wrapSol(ref: VaultRef, actor: Keypair$1, wsol: PublicKey$2, amountLamports: Numeric): Promise<string>;
1434
+ /** OWNER-or-DELEGATE. Unwrap: close the vault's wSOL account back to native SOL in the vault PDA. */
1435
+ unwrapSol(ref: VaultRef, actor: Keypair$1, wsol: PublicKey$2): Promise<string>;
1436
+ /**
1437
+ * DELEGATE-ONLY. Execute a swap through the guarded vault. `swapIx` is the DEX instruction for the
1438
+ * route the agent picked (Jupiter, Orca, a test AMM — any program); this wraps it as the vault's
1439
+ * guarded CPI and lets the on-chain guard verify the result (input spent ≤ amountIn, output
1440
+ * received ≥ minOut, nothing else moved, no authority change). The agent never touches a private key
1441
+ * that can withdraw — the worst it can do is a bad-but-bounded trade.
1442
+ */
1443
+ trade(p: TradeParams): Promise<string>;
1444
+ /**
1445
+ * Build the Ed25519 attestation instruction a Verified-Intents trade must carry. The oracle signs
1446
+ * `feed(32) | price(i64 LE) | ts(i64 LE)`; the runtime verifies the signature and the vault confirms
1447
+ * which (pubkey, message) it covered. This is the on-chain half of the verified-intents mechanism.
1448
+ */
1449
+ static oracleAttestation(oracle: Keypair$1, feed: Uint8Array | Buffer, price: Numeric, tsUnixSecs: Numeric): TransactionInstruction$2;
1450
+ }
1451
+
1452
+ type PublicKey$1 = anchor.web3.PublicKey;
1453
+ type TransactionInstruction$1 = anchor.web3.TransactionInstruction;
1454
+ interface JupiterQuoteParams {
1455
+ inputMint: PublicKey$1;
1456
+ outputMint: PublicKey$1;
1457
+ amount: bigint | number | string;
1458
+ slippageBps?: number;
1459
+ maxAccounts?: number;
1460
+ dexes?: string;
1461
+ base?: string;
1462
+ }
1463
+ interface JupiterSwapResult {
1464
+ swapIx: TransactionInstruction$1;
1465
+ inAmount: bigint;
1466
+ minOut: bigint;
1467
+ routeLabels: string[];
1468
+ addressLookupTables: PublicKey$1[];
1469
+ }
1470
+ /**
1471
+ * Quote a route and fetch the swap instruction with the VAULT PDA as the user authority. The returned
1472
+ * `swapIx` is route-agnostic from the vault's perspective — VaultClient.trade() flips the vault PDA to
1473
+ * non-signer (the program re-signs it) and forwards the rest. Use the returned `inAmount`/`minOut` as
1474
+ * the trade's `amountIn`/`minOut` so the on-chain guard enforces exactly the slippage Jupiter quoted.
1475
+ *
1476
+ * `vaultAuthority` is the vault PDA (the swap's user). `fetchFn` defaults to global fetch; pass one in
1477
+ * for environments without it. Any setup instructions Jupiter returns (ATA creation, etc.) are returned
1478
+ * via `setupIxs` so the caller can land them in a separate, non-guarded transaction first.
1479
+ */
1480
+ declare function jupiterSwapInstruction(q: JupiterQuoteParams, vaultAuthority: PublicKey$1, fetchFn?: typeof fetch): Promise<JupiterSwapResult & {
1481
+ computeBudgetIxs: TransactionInstruction$1[];
1482
+ setupIxs: TransactionInstruction$1[];
1483
+ }>;
1484
+
1485
+ type PublicKey = anchor.web3.PublicKey;
1486
+ type Keypair = anchor.web3.Keypair;
1487
+ type TransactionInstruction = anchor.web3.TransactionInstruction;
1488
+ /** The minimal trade request VaultCustody hands the executor (a subset of circuit-sdk's Intent). */
1489
+ interface ExecIntent {
1490
+ kind: "buy" | "sell";
1491
+ token?: string;
1492
+ sizeSol?: number;
1493
+ amount?: number;
1494
+ maxSlippageBps?: number;
1495
+ }
1496
+ interface RouteQuote {
1497
+ swapIx: TransactionInstruction;
1498
+ inAmount: bigint;
1499
+ minOut: bigint;
1500
+ addressLookupTables?: PublicKey[];
1501
+ computeBudgetIxs?: TransactionInstruction[];
1502
+ }
1503
+ /** Where a swap route comes from. Default = Jupiter; injectable for tests / self-hosted aggregators. */
1504
+ interface RouteSource {
1505
+ quote(p: {
1506
+ inputMint: PublicKey;
1507
+ outputMint: PublicKey;
1508
+ amount: bigint;
1509
+ slippageBps: number;
1510
+ }, vaultAuthority: PublicKey): Promise<RouteQuote>;
1511
+ }
1512
+ /** The production route source: Jupiter v6. */
1513
+ declare function jupiterRouteSource(opts?: {
1514
+ base?: string;
1515
+ fetchFn?: typeof fetch;
1516
+ }): RouteSource;
1517
+ interface VaultExecutorOptions {
1518
+ client: VaultClient;
1519
+ owner: PublicKey;
1520
+ agentSeed: Uint8Array | Buffer;
1521
+ delegate: Keypair;
1522
+ /** Resolve the vault's token account (ATA) + its token program for a mint. Must already exist. */
1523
+ ataFor: (mint: PublicKey) => {
1524
+ account: PublicKey;
1525
+ tokenProgram?: PublicKey;
1526
+ };
1527
+ /** Route source; defaults to Jupiter. */
1528
+ route?: RouteSource;
1529
+ /** Verified-intents: build the Ed25519 oracle attestation for a VerifiedIntent (the vault verifies it). */
1530
+ attest?: (vi: unknown) => TransactionInstruction;
1531
+ /** wSOL mint; override only in tests. */
1532
+ wsolMint?: PublicKey;
1533
+ }
1534
+ /**
1535
+ * Build a VaultTradeExecutor (structurally matches circuit-sdk's `VaultTradeExecutor`). Returned object
1536
+ * has `execute(intent, vi?) → { signature, solValue? }`. No circuit-sdk import — the shape is the contract.
1537
+ */
1538
+ declare function makeVaultExecutor(o: VaultExecutorOptions): {
1539
+ execute(intent: ExecIntent, vi?: unknown): Promise<{
1540
+ signature: string;
1541
+ solValue?: number;
1542
+ }>;
1543
+ };
1544
+
1545
+ /** Build the vault `Program` from the bundled IDL against a connection + wallet. */
1546
+ declare function loadVaultProgram(connection: anchor.web3.Connection, wallet: anchor.Wallet): anchor.Program<CircuitAgentVault>;
1547
+
1548
+ export { type CircuitAgentVault, type ExecIntent, type InitParams, type JupiterQuoteParams, type JupiterSwapResult, type RouteQuote, type RouteSource, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, type TradeParams, VaultClient, type VaultExecutorOptions, type VaultRef, jupiterRouteSource, jupiterSwapInstruction, loadVaultProgram, makeVaultExecutor };