northstar-eva-sdk 0.10.0 → 0.11.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.
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.NorthstarEva = exports.EVA_IDL = exports.userTokenAccount = exports.trenchTokenVault = exports.tokenMintPda = exports.agentPda = exports.trenchPda = exports.globalStatePda = exports.withdrawalSinkPda = exports.depositReceiptPda = exports.delegationRecordPda = exports.feeVaultPda = exports.sessionPda = exports.encodeUndelegate = exports.encodeDelegate = exports.encodeDepositFee = exports.encodeCloseSession = exports.encodeOpenSession = exports.NETWORKS = exports.TOKEN_DECIMALS = exports.INITIAL_TOKEN_SUPPLY = exports.DEFAULT_EVA_PROGRAM_ID = exports.DEFAULT_PORTAL_PROGRAM_ID = exports.SESSION_OFFSETS = exports.SESSION_DISCRIMINATOR = exports.SESSION_LEN = exports.TRENCH_LEN = exports.TRENCH_OFFSETS = exports.BASIS_POINTS = exports.FEE_RATE_BPS = void 0;
36
+ exports.NorthstarEva = exports.EVA_IDL = exports.userTokenAccount = exports.trenchTokenVault = exports.tokenMintPda = exports.agentPda = exports.trenchPda = exports.globalStatePda = exports.withdrawalSinkPda = exports.depositReceiptPda = exports.delegationRecordPda = exports.feeVaultPda = exports.sessionPda = exports.encodeUndelegate = exports.encodeDelegate = exports.encodeDepositFee = exports.encodeCloseSession = exports.encodeOpenSession = exports.NETWORKS = exports.TOKEN_DECIMALS = exports.INITIAL_TOKEN_SUPPLY = exports.DEFAULT_EVA_PROGRAM_ID = exports.DEFAULT_PORTAL_PROGRAM_ID = exports.SESSION_OFFSETS = exports.SESSION_DISCRIMINATOR = exports.SESSION_LEN = exports.GLOBAL_STATE_LEN = exports.TRENCH_LEN = exports.TRENCH_OFFSETS = exports.BASIS_POINTS = exports.FEE_RATE_BPS = void 0;
37
37
  exports.getBuyPrice = getBuyPrice;
38
38
  exports.applyBuy = applyBuy;
39
39
  exports.getSellPrice = getSellPrice;
@@ -67,119 +67,438 @@ const __EVA_IDL__ = {
67
67
  "address": "CQru6EauVg2UwepFCvY5qWuqCPEWYC4ta43wBbkFYtmo",
68
68
  "metadata": {
69
69
  "name": "eva_arena",
70
- "version": "0.1.6",
70
+ "version": "0.1.8",
71
71
  "spec": "0.1.0",
72
72
  "description": "Created with Anchor"
73
73
  },
74
74
  "instructions": [
75
75
  {
76
76
  "name": "buy",
77
- "discriminator": [102, 6, 61, 18, 1, 218, 235, 234],
77
+ "discriminator": [
78
+ 102,
79
+ 6,
80
+ 61,
81
+ 18,
82
+ 1,
83
+ 218,
84
+ 235,
85
+ 234
86
+ ],
78
87
  "accounts": [
79
- { "name": "trench", "writable": true },
80
- { "name": "global_state", "writable": true },
81
- { "name": "fee_recipient", "writable": true },
82
- { "name": "user", "writable": true, "signer": true },
88
+ {
89
+ "name": "trench",
90
+ "writable": true
91
+ },
92
+ {
93
+ "name": "global_state",
94
+ "writable": true
95
+ },
96
+ {
97
+ "name": "fee_recipient",
98
+ "writable": true
99
+ },
100
+ {
101
+ "name": "user",
102
+ "writable": true,
103
+ "signer": true
104
+ },
83
105
  {
84
106
  "name": "trench_token_vault",
85
- "docs": ["Vault holding trench's tokens (ATA owned by trench)"],
107
+ "docs": [
108
+ "Vault holding trench's tokens (ATA owned by trench)"
109
+ ],
86
110
  "writable": true,
87
111
  "pda": {
88
112
  "seeds": [
89
- { "kind": "account", "path": "trench" },
90
- { "kind": "const", "value": [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] },
91
- { "kind": "account", "path": "trench.token_mint", "account": "Trench" }
113
+ {
114
+ "kind": "account",
115
+ "path": "trench"
116
+ },
117
+ {
118
+ "kind": "const",
119
+ "value": [
120
+ 6,
121
+ 221,
122
+ 246,
123
+ 225,
124
+ 215,
125
+ 101,
126
+ 161,
127
+ 147,
128
+ 217,
129
+ 203,
130
+ 225,
131
+ 70,
132
+ 206,
133
+ 235,
134
+ 121,
135
+ 172,
136
+ 28,
137
+ 180,
138
+ 133,
139
+ 237,
140
+ 95,
141
+ 91,
142
+ 55,
143
+ 145,
144
+ 58,
145
+ 140,
146
+ 245,
147
+ 133,
148
+ 126,
149
+ 255,
150
+ 0,
151
+ 169
152
+ ]
153
+ },
154
+ {
155
+ "kind": "account",
156
+ "path": "trench.token_mint",
157
+ "account": "Trench"
158
+ }
92
159
  ],
93
160
  "program": {
94
161
  "kind": "const",
95
- "value": [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89]
162
+ "value": [
163
+ 140,
164
+ 151,
165
+ 37,
166
+ 143,
167
+ 78,
168
+ 36,
169
+ 137,
170
+ 241,
171
+ 187,
172
+ 61,
173
+ 16,
174
+ 41,
175
+ 20,
176
+ 142,
177
+ 13,
178
+ 131,
179
+ 11,
180
+ 90,
181
+ 19,
182
+ 153,
183
+ 218,
184
+ 255,
185
+ 16,
186
+ 132,
187
+ 4,
188
+ 142,
189
+ 123,
190
+ 216,
191
+ 219,
192
+ 233,
193
+ 248,
194
+ 89
195
+ ]
96
196
  }
97
197
  }
98
198
  },
99
- { "name": "user_token_account", "docs": ["User's token account (must match trench's token mint)"], "writable": true },
100
- { "name": "system_program", "address": "11111111111111111111111111111111" },
101
- { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }
199
+ {
200
+ "name": "user_token_account",
201
+ "docs": [
202
+ "User's token account (must match trench's token mint)"
203
+ ],
204
+ "writable": true
205
+ },
206
+ {
207
+ "name": "system_program",
208
+ "address": "11111111111111111111111111111111"
209
+ },
210
+ {
211
+ "name": "token_program",
212
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
213
+ }
102
214
  ],
103
215
  "args": [
104
- { "name": "sol_pay_with_fee", "type": "u64" },
105
- { "name": "think_id", "type": "u64" }
216
+ {
217
+ "name": "sol_pay_with_fee",
218
+ "type": "u64"
219
+ },
220
+ {
221
+ "name": "think_id",
222
+ "type": "u64"
223
+ }
106
224
  ]
107
225
  },
108
226
  {
109
227
  "name": "claim_tokens",
110
- "discriminator": [108, 216, 210, 231, 0, 212, 42, 64],
228
+ "discriminator": [
229
+ 108,
230
+ 216,
231
+ 210,
232
+ 231,
233
+ 0,
234
+ 212,
235
+ 42,
236
+ 64
237
+ ],
111
238
  "accounts": [
112
239
  {
113
240
  "name": "global_state",
114
- "pda": { "seeds": [{ "kind": "const", "value": [103, 108, 111, 98, 97, 108] }] }
241
+ "pda": {
242
+ "seeds": [
243
+ {
244
+ "kind": "const",
245
+ "value": [
246
+ 103,
247
+ 108,
248
+ 111,
249
+ 98,
250
+ 97,
251
+ 108
252
+ ]
253
+ }
254
+ ]
255
+ }
256
+ },
257
+ {
258
+ "name": "trench",
259
+ "writable": true
115
260
  },
116
- { "name": "trench", "writable": true },
117
261
  {
118
262
  "name": "agent",
119
263
  "writable": true,
120
264
  "pda": {
121
265
  "seeds": [
122
- { "kind": "const", "value": [97, 103, 101, 110, 116] },
123
- { "kind": "account", "path": "trench" },
124
- { "kind": "account", "path": "user" }
266
+ {
267
+ "kind": "const",
268
+ "value": [
269
+ 97,
270
+ 103,
271
+ 101,
272
+ 110,
273
+ 116
274
+ ]
275
+ },
276
+ {
277
+ "kind": "account",
278
+ "path": "trench"
279
+ },
280
+ {
281
+ "kind": "account",
282
+ "path": "user"
283
+ }
125
284
  ]
126
285
  }
127
286
  },
128
- { "name": "user" },
129
- { "name": "admin", "docs": ["Admin who can claim tokens for user"], "writable": true, "signer": true },
287
+ {
288
+ "name": "user"
289
+ },
290
+ {
291
+ "name": "back_authority",
292
+ "docs": [
293
+ "back_authority who can claim tokens for user"
294
+ ],
295
+ "writable": true,
296
+ "signer": true
297
+ },
130
298
  {
131
299
  "name": "trench_token_vault",
132
300
  "writable": true,
133
301
  "pda": {
134
302
  "seeds": [
135
- { "kind": "account", "path": "trench" },
136
- { "kind": "const", "value": [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] },
137
- { "kind": "account", "path": "trench.token_mint", "account": "Trench" }
303
+ {
304
+ "kind": "account",
305
+ "path": "trench"
306
+ },
307
+ {
308
+ "kind": "const",
309
+ "value": [
310
+ 6,
311
+ 221,
312
+ 246,
313
+ 225,
314
+ 215,
315
+ 101,
316
+ 161,
317
+ 147,
318
+ 217,
319
+ 203,
320
+ 225,
321
+ 70,
322
+ 206,
323
+ 235,
324
+ 121,
325
+ 172,
326
+ 28,
327
+ 180,
328
+ 133,
329
+ 237,
330
+ 95,
331
+ 91,
332
+ 55,
333
+ 145,
334
+ 58,
335
+ 140,
336
+ 245,
337
+ 133,
338
+ 126,
339
+ 255,
340
+ 0,
341
+ 169
342
+ ]
343
+ },
344
+ {
345
+ "kind": "account",
346
+ "path": "trench.token_mint",
347
+ "account": "Trench"
348
+ }
138
349
  ],
139
350
  "program": {
140
351
  "kind": "const",
141
- "value": [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89]
352
+ "value": [
353
+ 140,
354
+ 151,
355
+ 37,
356
+ 143,
357
+ 78,
358
+ 36,
359
+ 137,
360
+ 241,
361
+ 187,
362
+ 61,
363
+ 16,
364
+ 41,
365
+ 20,
366
+ 142,
367
+ 13,
368
+ 131,
369
+ 11,
370
+ 90,
371
+ 19,
372
+ 153,
373
+ 218,
374
+ 255,
375
+ 16,
376
+ 132,
377
+ 4,
378
+ 142,
379
+ 123,
380
+ 216,
381
+ 219,
382
+ 233,
383
+ 248,
384
+ 89
385
+ ]
142
386
  }
143
387
  }
144
388
  },
145
- { "name": "user_token_account", "writable": true },
146
- { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }
389
+ {
390
+ "name": "user_token_account",
391
+ "writable": true
392
+ },
393
+ {
394
+ "name": "token_program",
395
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
396
+ }
147
397
  ],
148
398
  "args": []
149
399
  },
150
400
  {
151
401
  "name": "close_pool",
152
- "discriminator": [140, 189, 209, 23, 239, 62, 239, 11],
402
+ "discriminator": [
403
+ 140,
404
+ 189,
405
+ 209,
406
+ 23,
407
+ 239,
408
+ 62,
409
+ 239,
410
+ 11
411
+ ],
153
412
  "accounts": [
154
- { "name": "trench", "writable": true },
155
- { "name": "global_state", "writable": true },
156
- { "name": "fee_recipient", "writable": true },
157
- { "name": "admin", "writable": true, "signer": true },
158
- { "name": "system_program", "address": "11111111111111111111111111111111" }
413
+ {
414
+ "name": "trench",
415
+ "writable": true
416
+ },
417
+ {
418
+ "name": "global_state",
419
+ "writable": true
420
+ },
421
+ {
422
+ "name": "fee_recipient",
423
+ "writable": true
424
+ },
425
+ {
426
+ "name": "back_authority",
427
+ "writable": true,
428
+ "signer": true
429
+ },
430
+ {
431
+ "name": "system_program",
432
+ "address": "11111111111111111111111111111111"
433
+ }
159
434
  ],
160
435
  "args": []
161
436
  },
162
437
  {
163
438
  "name": "close_trench",
164
- "discriminator": [249, 176, 185, 73, 24, 59, 234, 84],
439
+ "discriminator": [
440
+ 249,
441
+ 176,
442
+ 185,
443
+ 73,
444
+ 24,
445
+ 59,
446
+ 234,
447
+ 84
448
+ ],
165
449
  "accounts": [
166
- { "name": "trench", "writable": true },
167
- { "name": "creator", "writable": true, "signer": true, "relations": ["trench"] }
450
+ {
451
+ "name": "trench",
452
+ "writable": true
453
+ },
454
+ {
455
+ "name": "creator",
456
+ "writable": true,
457
+ "signer": true,
458
+ "relations": [
459
+ "trench"
460
+ ]
461
+ }
168
462
  ],
169
463
  "args": []
170
464
  },
171
465
  {
172
466
  "name": "create_trench",
173
- "discriminator": [66, 74, 73, 171, 206, 39, 116, 230],
467
+ "discriminator": [
468
+ 66,
469
+ 74,
470
+ 73,
471
+ 171,
472
+ 206,
473
+ 39,
474
+ 116,
475
+ 230
476
+ ],
174
477
  "accounts": [
175
- { "name": "global_state", "writable": true },
478
+ {
479
+ "name": "global_state",
480
+ "writable": true
481
+ },
176
482
  {
177
483
  "name": "trench",
178
484
  "writable": true,
179
485
  "pda": {
180
486
  "seeds": [
181
- { "kind": "const", "value": [116, 114, 101, 110, 99, 104] },
182
- { "kind": "arg", "path": "id" }
487
+ {
488
+ "kind": "const",
489
+ "value": [
490
+ 116,
491
+ 114,
492
+ 101,
493
+ 110,
494
+ 99,
495
+ 104
496
+ ]
497
+ },
498
+ {
499
+ "kind": "arg",
500
+ "path": "id"
501
+ }
183
502
  ]
184
503
  }
185
504
  },
@@ -188,8 +507,19 @@ const __EVA_IDL__ = {
188
507
  "writable": true,
189
508
  "pda": {
190
509
  "seeds": [
191
- { "kind": "const", "value": [109, 105, 110, 116] },
192
- { "kind": "account", "path": "trench" }
510
+ {
511
+ "kind": "const",
512
+ "value": [
513
+ 109,
514
+ 105,
515
+ 110,
516
+ 116
517
+ ]
518
+ },
519
+ {
520
+ "kind": "account",
521
+ "path": "trench"
522
+ }
193
523
  ]
194
524
  }
195
525
  },
@@ -198,204 +528,870 @@ const __EVA_IDL__ = {
198
528
  "writable": true,
199
529
  "pda": {
200
530
  "seeds": [
201
- { "kind": "account", "path": "trench" },
202
- { "kind": "const", "value": [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] },
203
- { "kind": "account", "path": "token_mint" }
531
+ {
532
+ "kind": "account",
533
+ "path": "trench"
534
+ },
535
+ {
536
+ "kind": "const",
537
+ "value": [
538
+ 6,
539
+ 221,
540
+ 246,
541
+ 225,
542
+ 215,
543
+ 101,
544
+ 161,
545
+ 147,
546
+ 217,
547
+ 203,
548
+ 225,
549
+ 70,
550
+ 206,
551
+ 235,
552
+ 121,
553
+ 172,
554
+ 28,
555
+ 180,
556
+ 133,
557
+ 237,
558
+ 95,
559
+ 91,
560
+ 55,
561
+ 145,
562
+ 58,
563
+ 140,
564
+ 245,
565
+ 133,
566
+ 126,
567
+ 255,
568
+ 0,
569
+ 169
570
+ ]
571
+ },
572
+ {
573
+ "kind": "account",
574
+ "path": "token_mint"
575
+ }
204
576
  ],
205
577
  "program": {
206
578
  "kind": "const",
207
- "value": [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89]
579
+ "value": [
580
+ 140,
581
+ 151,
582
+ 37,
583
+ 143,
584
+ 78,
585
+ 36,
586
+ 137,
587
+ 241,
588
+ 187,
589
+ 61,
590
+ 16,
591
+ 41,
592
+ 20,
593
+ 142,
594
+ 13,
595
+ 131,
596
+ 11,
597
+ 90,
598
+ 19,
599
+ 153,
600
+ 218,
601
+ 255,
602
+ 16,
603
+ 132,
604
+ 4,
605
+ 142,
606
+ 123,
607
+ 216,
608
+ 219,
609
+ 233,
610
+ 248,
611
+ 89
612
+ ]
208
613
  }
209
614
  }
210
615
  },
211
- { "name": "creator", "writable": true, "signer": true },
212
- { "name": "system_program", "address": "11111111111111111111111111111111" },
213
- { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
214
- { "name": "associated_token_program", "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" },
215
- { "name": "rent", "address": "SysvarRent111111111111111111111111111111111" }
616
+ {
617
+ "name": "creator",
618
+ "writable": true,
619
+ "signer": true
620
+ },
621
+ {
622
+ "name": "system_program",
623
+ "address": "11111111111111111111111111111111"
624
+ },
625
+ {
626
+ "name": "token_program",
627
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
628
+ },
629
+ {
630
+ "name": "associated_token_program",
631
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
632
+ },
633
+ {
634
+ "name": "rent",
635
+ "address": "SysvarRent111111111111111111111111111111111"
636
+ }
216
637
  ],
217
638
  "args": [
218
- { "name": "id", "type": "u64" },
219
- { "name": "initial_virtual_token_reserves", "type": "u64" }
639
+ {
640
+ "name": "id",
641
+ "type": "u64"
642
+ },
643
+ {
644
+ "name": "initial_virtual_token_reserves",
645
+ "type": "u64"
646
+ }
220
647
  ]
221
648
  },
222
649
  {
223
650
  "name": "deposit",
224
- "discriminator": [242, 35, 198, 137, 82, 225, 242, 182],
651
+ "discriminator": [
652
+ 242,
653
+ 35,
654
+ 198,
655
+ 137,
656
+ 82,
657
+ 225,
658
+ 242,
659
+ 182
660
+ ],
225
661
  "accounts": [
226
- { "name": "trench", "writable": true },
662
+ {
663
+ "name": "trench",
664
+ "writable": true
665
+ },
227
666
  {
228
667
  "name": "agent",
229
668
  "writable": true,
230
669
  "pda": {
231
670
  "seeds": [
232
- { "kind": "const", "value": [97, 103, 101, 110, 116] },
233
- { "kind": "account", "path": "trench" },
234
- { "kind": "account", "path": "user" }
671
+ {
672
+ "kind": "const",
673
+ "value": [
674
+ 97,
675
+ 103,
676
+ 101,
677
+ 110,
678
+ 116
679
+ ]
680
+ },
681
+ {
682
+ "kind": "account",
683
+ "path": "trench"
684
+ },
685
+ {
686
+ "kind": "account",
687
+ "path": "user"
688
+ }
235
689
  ]
236
690
  }
237
691
  },
238
- { "name": "user", "writable": true, "signer": true },
239
- { "name": "system_program", "address": "11111111111111111111111111111111" }
692
+ {
693
+ "name": "user",
694
+ "writable": true,
695
+ "signer": true
696
+ },
697
+ {
698
+ "name": "system_program",
699
+ "address": "11111111111111111111111111111111"
700
+ }
240
701
  ],
241
702
  "args": [
242
- { "name": "amount", "type": "u64" },
243
- { "name": "think_id", "type": "u64" }
703
+ {
704
+ "name": "amount",
705
+ "type": "u64"
706
+ },
707
+ {
708
+ "name": "think_id",
709
+ "type": "u64"
710
+ }
244
711
  ]
245
712
  },
246
713
  {
247
714
  "name": "distribute_prize",
248
- "discriminator": [153, 175, 67, 111, 205, 207, 106, 15],
715
+ "discriminator": [
716
+ 153,
717
+ 175,
718
+ 67,
719
+ 111,
720
+ 205,
721
+ 207,
722
+ 106,
723
+ 15
724
+ ],
249
725
  "accounts": [
250
- { "name": "trench", "writable": true },
251
- { "name": "global_state", "writable": true },
252
- { "name": "fee_recipient", "writable": true },
253
- { "name": "admin", "writable": true, "signer": true },
254
- { "name": "system_program", "address": "11111111111111111111111111111111" }
726
+ {
727
+ "name": "trench",
728
+ "writable": true
729
+ },
730
+ {
731
+ "name": "global_state",
732
+ "writable": true
733
+ },
734
+ {
735
+ "name": "fee_recipient",
736
+ "writable": true
737
+ },
738
+ {
739
+ "name": "back_authority",
740
+ "writable": true,
741
+ "signer": true
742
+ },
743
+ {
744
+ "name": "system_program",
745
+ "address": "11111111111111111111111111111111"
746
+ }
255
747
  ],
256
748
  "args": [
257
- { "name": "winners", "type": { "vec": "pubkey" } },
258
- { "name": "amounts", "type": { "vec": "u64" } }
749
+ {
750
+ "name": "winners",
751
+ "type": {
752
+ "vec": "pubkey"
753
+ }
754
+ },
755
+ {
756
+ "name": "amounts",
757
+ "type": {
758
+ "vec": "u64"
759
+ }
760
+ }
259
761
  ]
260
762
  },
261
763
  {
262
764
  "name": "finalize",
263
- "discriminator": [171, 61, 218, 56, 127, 115, 12, 217],
765
+ "discriminator": [
766
+ 171,
767
+ 61,
768
+ 218,
769
+ 56,
770
+ 127,
771
+ 115,
772
+ 12,
773
+ 217
774
+ ],
264
775
  "accounts": [
265
- { "name": "trench", "writable": true },
266
- { "name": "global_state", "writable": true },
267
- { "name": "fee_recipient", "writable": true },
268
- { "name": "admin", "writable": true, "signer": true },
269
- { "name": "system_program", "address": "11111111111111111111111111111111" },
270
- { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
271
- { "name": "rent", "address": "SysvarRent111111111111111111111111111111111" }
776
+ {
777
+ "name": "trench",
778
+ "writable": true
779
+ },
780
+ {
781
+ "name": "global_state",
782
+ "writable": true
783
+ },
784
+ {
785
+ "name": "fee_recipient",
786
+ "writable": true
787
+ },
788
+ {
789
+ "name": "back_authority",
790
+ "writable": true,
791
+ "signer": true
792
+ },
793
+ {
794
+ "name": "system_program",
795
+ "address": "11111111111111111111111111111111"
796
+ },
797
+ {
798
+ "name": "token_program",
799
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
800
+ },
801
+ {
802
+ "name": "rent",
803
+ "address": "SysvarRent111111111111111111111111111111111"
804
+ }
272
805
  ],
273
806
  "args": []
274
807
  },
275
808
  {
276
809
  "name": "initialize",
277
- "discriminator": [175, 175, 109, 31, 13, 152, 155, 237],
810
+ "discriminator": [
811
+ 175,
812
+ 175,
813
+ 109,
814
+ 31,
815
+ 13,
816
+ 152,
817
+ 155,
818
+ 237
819
+ ],
278
820
  "accounts": [
279
821
  {
280
822
  "name": "global_state",
281
823
  "writable": true,
282
- "pda": { "seeds": [{ "kind": "const", "value": [103, 108, 111, 98, 97, 108] }] }
824
+ "pda": {
825
+ "seeds": [
826
+ {
827
+ "kind": "const",
828
+ "value": [
829
+ 103,
830
+ 108,
831
+ 111,
832
+ 98,
833
+ 97,
834
+ 108
835
+ ]
836
+ }
837
+ ]
838
+ }
839
+ },
840
+ {
841
+ "name": "admin",
842
+ "writable": true,
843
+ "signer": true
283
844
  },
284
- { "name": "admin", "writable": true, "signer": true },
285
- { "name": "system_program", "address": "11111111111111111111111111111111" }
845
+ {
846
+ "name": "system_program",
847
+ "address": "11111111111111111111111111111111"
848
+ }
286
849
  ],
287
850
  "args": [
288
- { "name": "bidding_duration", "type": "u64" },
289
- { "name": "trading_duration", "type": "u64" }
851
+ {
852
+ "name": "bidding_duration",
853
+ "type": "u64"
854
+ },
855
+ {
856
+ "name": "trading_duration",
857
+ "type": "u64"
858
+ }
290
859
  ]
291
860
  },
292
861
  {
293
862
  "name": "sell",
294
- "discriminator": [51, 230, 133, 164, 1, 127, 131, 173],
863
+ "discriminator": [
864
+ 51,
865
+ 230,
866
+ 133,
867
+ 164,
868
+ 1,
869
+ 127,
870
+ 131,
871
+ 173
872
+ ],
295
873
  "accounts": [
296
- { "name": "trench", "writable": true },
297
- { "name": "global_state", "writable": true },
298
- { "name": "fee_recipient", "writable": true },
299
- { "name": "user", "writable": true, "signer": true },
874
+ {
875
+ "name": "trench",
876
+ "writable": true
877
+ },
878
+ {
879
+ "name": "global_state",
880
+ "writable": true
881
+ },
882
+ {
883
+ "name": "fee_recipient",
884
+ "writable": true
885
+ },
886
+ {
887
+ "name": "user",
888
+ "writable": true,
889
+ "signer": true
890
+ },
300
891
  {
301
892
  "name": "trench_token_vault",
302
- "docs": ["Vault holding trench's tokens (ATA owned by trench)"],
893
+ "docs": [
894
+ "Vault holding trench's tokens (ATA owned by trench)"
895
+ ],
303
896
  "writable": true,
304
897
  "pda": {
305
898
  "seeds": [
306
- { "kind": "account", "path": "trench" },
307
- { "kind": "const", "value": [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] },
308
- { "kind": "account", "path": "trench.token_mint", "account": "Trench" }
899
+ {
900
+ "kind": "account",
901
+ "path": "trench"
902
+ },
903
+ {
904
+ "kind": "const",
905
+ "value": [
906
+ 6,
907
+ 221,
908
+ 246,
909
+ 225,
910
+ 215,
911
+ 101,
912
+ 161,
913
+ 147,
914
+ 217,
915
+ 203,
916
+ 225,
917
+ 70,
918
+ 206,
919
+ 235,
920
+ 121,
921
+ 172,
922
+ 28,
923
+ 180,
924
+ 133,
925
+ 237,
926
+ 95,
927
+ 91,
928
+ 55,
929
+ 145,
930
+ 58,
931
+ 140,
932
+ 245,
933
+ 133,
934
+ 126,
935
+ 255,
936
+ 0,
937
+ 169
938
+ ]
939
+ },
940
+ {
941
+ "kind": "account",
942
+ "path": "trench.token_mint",
943
+ "account": "Trench"
944
+ }
309
945
  ],
310
946
  "program": {
311
947
  "kind": "const",
312
- "value": [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89]
948
+ "value": [
949
+ 140,
950
+ 151,
951
+ 37,
952
+ 143,
953
+ 78,
954
+ 36,
955
+ 137,
956
+ 241,
957
+ 187,
958
+ 61,
959
+ 16,
960
+ 41,
961
+ 20,
962
+ 142,
963
+ 13,
964
+ 131,
965
+ 11,
966
+ 90,
967
+ 19,
968
+ 153,
969
+ 218,
970
+ 255,
971
+ 16,
972
+ 132,
973
+ 4,
974
+ 142,
975
+ 123,
976
+ 216,
977
+ 219,
978
+ 233,
979
+ 248,
980
+ 89
981
+ ]
313
982
  }
314
983
  }
315
984
  },
316
- { "name": "user_token_account", "docs": ["User's token account (must match trench's token mint)"], "writable": true },
317
- { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }
985
+ {
986
+ "name": "user_token_account",
987
+ "docs": [
988
+ "User's token account (must match trench's token mint)"
989
+ ],
990
+ "writable": true
991
+ },
992
+ {
993
+ "name": "token_program",
994
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
995
+ }
318
996
  ],
319
997
  "args": [
320
- { "name": "amount_in", "type": "u64" },
321
- { "name": "min_sol_output", "type": "u64" },
322
- { "name": "think_id", "type": "u64" }
998
+ {
999
+ "name": "amount_in",
1000
+ "type": "u64"
1001
+ },
1002
+ {
1003
+ "name": "min_sol_output",
1004
+ "type": "u64"
1005
+ },
1006
+ {
1007
+ "name": "think_id",
1008
+ "type": "u64"
1009
+ }
323
1010
  ]
324
1011
  },
325
1012
  {
326
1013
  "name": "update_config",
327
- "discriminator": [29, 158, 252, 191, 10, 83, 219, 99],
1014
+ "discriminator": [
1015
+ 29,
1016
+ 158,
1017
+ 252,
1018
+ 191,
1019
+ 10,
1020
+ 83,
1021
+ 219,
1022
+ 99
1023
+ ],
328
1024
  "accounts": [
329
1025
  {
330
1026
  "name": "global_state",
331
1027
  "writable": true,
332
- "pda": { "seeds": [{ "kind": "const", "value": [103, 108, 111, 98, 97, 108] }] }
1028
+ "pda": {
1029
+ "seeds": [
1030
+ {
1031
+ "kind": "const",
1032
+ "value": [
1033
+ 103,
1034
+ 108,
1035
+ 111,
1036
+ 98,
1037
+ 97,
1038
+ 108
1039
+ ]
1040
+ }
1041
+ ]
1042
+ }
1043
+ },
1044
+ {
1045
+ "name": "admin",
1046
+ "writable": true,
1047
+ "signer": true
333
1048
  },
334
- { "name": "admin", "writable": true, "signer": true }
1049
+ {
1050
+ "name": "system_program",
1051
+ "address": "11111111111111111111111111111111"
1052
+ }
335
1053
  ],
336
1054
  "args": [
337
- { "name": "bidding_duration", "type": "u64" },
338
- { "name": "trading_duration", "type": "u64" },
339
- { "name": "fee_recipient", "type": "pubkey" }
1055
+ {
1056
+ "name": "bidding_duration",
1057
+ "type": "u64"
1058
+ },
1059
+ {
1060
+ "name": "trading_duration",
1061
+ "type": "u64"
1062
+ },
1063
+ {
1064
+ "name": "fee_recipient",
1065
+ "type": "pubkey"
1066
+ },
1067
+ {
1068
+ "name": "back_authority",
1069
+ "type": "pubkey"
1070
+ }
340
1071
  ]
341
1072
  },
342
1073
  {
343
1074
  "name": "withdraw",
344
- "discriminator": [183, 18, 70, 156, 148, 109, 161, 34],
1075
+ "discriminator": [
1076
+ 183,
1077
+ 18,
1078
+ 70,
1079
+ 156,
1080
+ 148,
1081
+ 109,
1082
+ 161,
1083
+ 34
1084
+ ],
345
1085
  "accounts": [
346
- { "name": "trench", "writable": true },
1086
+ {
1087
+ "name": "trench",
1088
+ "writable": true
1089
+ },
347
1090
  {
348
1091
  "name": "agent",
349
1092
  "writable": true,
350
1093
  "pda": {
351
1094
  "seeds": [
352
- { "kind": "const", "value": [97, 103, 101, 110, 116] },
353
- { "kind": "account", "path": "trench" },
354
- { "kind": "account", "path": "user" }
1095
+ {
1096
+ "kind": "const",
1097
+ "value": [
1098
+ 97,
1099
+ 103,
1100
+ 101,
1101
+ 110,
1102
+ 116
1103
+ ]
1104
+ },
1105
+ {
1106
+ "kind": "account",
1107
+ "path": "trench"
1108
+ },
1109
+ {
1110
+ "kind": "account",
1111
+ "path": "user"
1112
+ }
355
1113
  ]
356
1114
  }
357
1115
  },
358
- { "name": "user", "writable": true, "signer": true },
359
- { "name": "system_program", "address": "11111111111111111111111111111111" }
1116
+ {
1117
+ "name": "user",
1118
+ "writable": true,
1119
+ "signer": true
1120
+ },
1121
+ {
1122
+ "name": "system_program",
1123
+ "address": "11111111111111111111111111111111"
1124
+ }
360
1125
  ],
361
1126
  "args": [
362
- { "name": "amount", "type": "u64" },
363
- { "name": "think_id", "type": "u64" }
1127
+ {
1128
+ "name": "amount",
1129
+ "type": "u64"
1130
+ },
1131
+ {
1132
+ "name": "think_id",
1133
+ "type": "u64"
1134
+ }
364
1135
  ]
365
1136
  }
366
1137
  ],
367
1138
  "accounts": [
368
- { "name": "Agent", "discriminator": [47, 166, 112, 147, 155, 197, 86, 7] },
369
- { "name": "GlobalState", "discriminator": [163, 46, 74, 168, 216, 123, 133, 98] },
370
- { "name": "Trench", "discriminator": [70, 8, 211, 194, 255, 64, 8, 102] }
1139
+ {
1140
+ "name": "Agent",
1141
+ "discriminator": [
1142
+ 47,
1143
+ 166,
1144
+ 112,
1145
+ 147,
1146
+ 155,
1147
+ 197,
1148
+ 86,
1149
+ 7
1150
+ ]
1151
+ },
1152
+ {
1153
+ "name": "GlobalState",
1154
+ "discriminator": [
1155
+ 163,
1156
+ 46,
1157
+ 74,
1158
+ 168,
1159
+ 216,
1160
+ 123,
1161
+ 133,
1162
+ 98
1163
+ ]
1164
+ },
1165
+ {
1166
+ "name": "Trench",
1167
+ "discriminator": [
1168
+ 70,
1169
+ 8,
1170
+ 211,
1171
+ 194,
1172
+ 255,
1173
+ 64,
1174
+ 8,
1175
+ 102
1176
+ ]
1177
+ }
371
1178
  ],
372
1179
  "events": [
373
- { "name": "BuyEvent", "discriminator": [103, 244, 82, 31, 44, 245, 119, 119] },
374
- { "name": "ClaimTokensEvent", "discriminator": [71, 156, 103, 32, 16, 211, 150, 191] },
375
- { "name": "ClosePoolEvent", "discriminator": [242, 151, 109, 158, 250, 231, 235, 140] },
376
- { "name": "CloseTrenchEvent", "discriminator": [81, 249, 10, 69, 147, 183, 102, 136] },
377
- { "name": "CreateTrenchEvent", "discriminator": [24, 172, 85, 31, 101, 75, 32, 122] },
378
- { "name": "DepositEvent", "discriminator": [120, 248, 61, 83, 31, 142, 107, 144] },
379
- { "name": "DistributePrizeEvent", "discriminator": [10, 83, 171, 140, 12, 201, 34, 128] },
380
- { "name": "FinalizeEvent", "discriminator": [115, 140, 131, 4, 181, 52, 170, 148] },
381
- { "name": "InitializeEvent", "discriminator": [206, 175, 169, 208, 241, 210, 35, 221] },
382
- { "name": "SellEvent", "discriminator": [62, 47, 55, 10, 165, 3, 220, 42] },
383
- { "name": "WithdrawEvent", "discriminator": [22, 9, 133, 26, 160, 44, 71, 192] }
1180
+ {
1181
+ "name": "BuyEvent",
1182
+ "discriminator": [
1183
+ 103,
1184
+ 244,
1185
+ 82,
1186
+ 31,
1187
+ 44,
1188
+ 245,
1189
+ 119,
1190
+ 119
1191
+ ]
1192
+ },
1193
+ {
1194
+ "name": "ClaimTokensEvent",
1195
+ "discriminator": [
1196
+ 71,
1197
+ 156,
1198
+ 103,
1199
+ 32,
1200
+ 16,
1201
+ 211,
1202
+ 150,
1203
+ 191
1204
+ ]
1205
+ },
1206
+ {
1207
+ "name": "ClosePoolEvent",
1208
+ "discriminator": [
1209
+ 242,
1210
+ 151,
1211
+ 109,
1212
+ 158,
1213
+ 250,
1214
+ 231,
1215
+ 235,
1216
+ 140
1217
+ ]
1218
+ },
1219
+ {
1220
+ "name": "CloseTrenchEvent",
1221
+ "discriminator": [
1222
+ 81,
1223
+ 249,
1224
+ 10,
1225
+ 69,
1226
+ 147,
1227
+ 183,
1228
+ 102,
1229
+ 136
1230
+ ]
1231
+ },
1232
+ {
1233
+ "name": "CreateTrenchEvent",
1234
+ "discriminator": [
1235
+ 24,
1236
+ 172,
1237
+ 85,
1238
+ 31,
1239
+ 101,
1240
+ 75,
1241
+ 32,
1242
+ 122
1243
+ ]
1244
+ },
1245
+ {
1246
+ "name": "DepositEvent",
1247
+ "discriminator": [
1248
+ 120,
1249
+ 248,
1250
+ 61,
1251
+ 83,
1252
+ 31,
1253
+ 142,
1254
+ 107,
1255
+ 144
1256
+ ]
1257
+ },
1258
+ {
1259
+ "name": "DistributePrizeEvent",
1260
+ "discriminator": [
1261
+ 10,
1262
+ 83,
1263
+ 171,
1264
+ 140,
1265
+ 12,
1266
+ 201,
1267
+ 34,
1268
+ 128
1269
+ ]
1270
+ },
1271
+ {
1272
+ "name": "FinalizeEvent",
1273
+ "discriminator": [
1274
+ 115,
1275
+ 140,
1276
+ 131,
1277
+ 4,
1278
+ 181,
1279
+ 52,
1280
+ 170,
1281
+ 148
1282
+ ]
1283
+ },
1284
+ {
1285
+ "name": "InitializeEvent",
1286
+ "discriminator": [
1287
+ 206,
1288
+ 175,
1289
+ 169,
1290
+ 208,
1291
+ 241,
1292
+ 210,
1293
+ 35,
1294
+ 221
1295
+ ]
1296
+ },
1297
+ {
1298
+ "name": "SellEvent",
1299
+ "discriminator": [
1300
+ 62,
1301
+ 47,
1302
+ 55,
1303
+ 10,
1304
+ 165,
1305
+ 3,
1306
+ 220,
1307
+ 42
1308
+ ]
1309
+ },
1310
+ {
1311
+ "name": "WithdrawEvent",
1312
+ "discriminator": [
1313
+ 22,
1314
+ 9,
1315
+ 133,
1316
+ 26,
1317
+ 160,
1318
+ 44,
1319
+ 71,
1320
+ 192
1321
+ ]
1322
+ }
384
1323
  ],
385
1324
  "errors": [
386
- { "code": 6000, "name": "NotBiddingPhase", "msg": "Trench is not in bidding phase" },
387
- { "code": 6001, "name": "NotTradingPhase", "msg": "Trench is not in trading phase" },
388
- { "code": 6002, "name": "InsufficientFunds", "msg": "Insufficient funds" },
389
- { "code": 6003, "name": "SlippageExceeded", "msg": "Slippage tolerance exceeded" },
390
- { "code": 6004, "name": "Overflow", "msg": "Calculation overflow" },
391
- { "code": 6005, "name": "InvalidAmount", "msg": "Invalid amount" },
392
- { "code": 6006, "name": "Unauthorized", "msg": "Unauthorized access" },
393
- { "code": 6007, "name": "MathOverflow", "msg": "Math operation overflow" },
394
- { "code": 6008, "name": "InvalidStatus", "msg": "Invalid status" },
395
- { "code": 6009, "name": "AlreadyClaimed", "msg": "Tokens already claimed" },
396
- { "code": 6010, "name": "TradingPhaseNotEnded", "msg": "Trading phase not ended" },
397
- { "code": 6011, "name": "NoLiquidity", "msg": "No liquidity available" },
398
- { "code": 6012, "name": "InvalidTrenchId", "msg": "Invalid trench id" }
1325
+ {
1326
+ "code": 6000,
1327
+ "name": "NotBiddingPhase",
1328
+ "msg": "Trench is not in bidding phase"
1329
+ },
1330
+ {
1331
+ "code": 6001,
1332
+ "name": "NotTradingPhase",
1333
+ "msg": "Trench is not in trading phase"
1334
+ },
1335
+ {
1336
+ "code": 6002,
1337
+ "name": "InsufficientFunds",
1338
+ "msg": "Insufficient funds"
1339
+ },
1340
+ {
1341
+ "code": 6003,
1342
+ "name": "SlippageExceeded",
1343
+ "msg": "Slippage tolerance exceeded"
1344
+ },
1345
+ {
1346
+ "code": 6004,
1347
+ "name": "Overflow",
1348
+ "msg": "Calculation overflow"
1349
+ },
1350
+ {
1351
+ "code": 6005,
1352
+ "name": "InvalidAmount",
1353
+ "msg": "Invalid amount"
1354
+ },
1355
+ {
1356
+ "code": 6006,
1357
+ "name": "Unauthorized",
1358
+ "msg": "Unauthorized access"
1359
+ },
1360
+ {
1361
+ "code": 6007,
1362
+ "name": "MathOverflow",
1363
+ "msg": "Math operation overflow"
1364
+ },
1365
+ {
1366
+ "code": 6008,
1367
+ "name": "InvalidStatus",
1368
+ "msg": "Invalid status"
1369
+ },
1370
+ {
1371
+ "code": 6009,
1372
+ "name": "AlreadyClaimed",
1373
+ "msg": "Tokens already claimed"
1374
+ },
1375
+ {
1376
+ "code": 6010,
1377
+ "name": "TradingPhaseNotEnded",
1378
+ "msg": "Trading phase not ended"
1379
+ },
1380
+ {
1381
+ "code": 6011,
1382
+ "name": "NoLiquidity",
1383
+ "msg": "No liquidity available"
1384
+ },
1385
+ {
1386
+ "code": 6012,
1387
+ "name": "InvalidTrenchId",
1388
+ "msg": "Invalid trench id"
1389
+ },
1390
+ {
1391
+ "code": 6013,
1392
+ "name": "WinnerAccountMissing",
1393
+ "msg": "Winner pubkey not found in remaining_accounts"
1394
+ }
399
1395
  ],
400
1396
  "types": [
401
1397
  {
@@ -403,12 +1399,30 @@ const __EVA_IDL__ = {
403
1399
  "type": {
404
1400
  "kind": "struct",
405
1401
  "fields": [
406
- { "name": "authority", "type": "pubkey" },
407
- { "name": "trench", "type": "pubkey" },
408
- { "name": "deposited_sol", "type": "u64" },
409
- { "name": "token_balance", "type": "u64" },
410
- { "name": "is_claimed", "type": "bool" },
411
- { "name": "bump", "type": "u8" }
1402
+ {
1403
+ "name": "authority",
1404
+ "type": "pubkey"
1405
+ },
1406
+ {
1407
+ "name": "trench",
1408
+ "type": "pubkey"
1409
+ },
1410
+ {
1411
+ "name": "deposited_sol",
1412
+ "type": "u64"
1413
+ },
1414
+ {
1415
+ "name": "token_balance",
1416
+ "type": "u64"
1417
+ },
1418
+ {
1419
+ "name": "is_claimed",
1420
+ "type": "bool"
1421
+ },
1422
+ {
1423
+ "name": "bump",
1424
+ "type": "u8"
1425
+ }
412
1426
  ]
413
1427
  }
414
1428
  },
@@ -417,17 +1431,50 @@ const __EVA_IDL__ = {
417
1431
  "type": {
418
1432
  "kind": "struct",
419
1433
  "fields": [
420
- { "name": "trench", "type": "pubkey" },
421
- { "name": "user", "type": "pubkey" },
422
- { "name": "sol_amount", "type": "u64" },
423
- { "name": "token_amount", "type": "u64" },
424
- { "name": "trench_balance", "type": "u64" },
425
- { "name": "think_id", "type": "u64" },
426
- { "name": "timestamp", "type": "i64" },
427
- { "name": "pre_virtual_sol_reserves", "type": "u64" },
428
- { "name": "pre_virtual_token_reserves", "type": "u64" },
429
- { "name": "pre_real_sol_reserves", "type": "u64" },
430
- { "name": "pre_real_token_reserves", "type": "u64" }
1434
+ {
1435
+ "name": "trench",
1436
+ "type": "pubkey"
1437
+ },
1438
+ {
1439
+ "name": "user",
1440
+ "type": "pubkey"
1441
+ },
1442
+ {
1443
+ "name": "sol_amount",
1444
+ "type": "u64"
1445
+ },
1446
+ {
1447
+ "name": "token_amount",
1448
+ "type": "u64"
1449
+ },
1450
+ {
1451
+ "name": "trench_balance",
1452
+ "type": "u64"
1453
+ },
1454
+ {
1455
+ "name": "think_id",
1456
+ "type": "u64"
1457
+ },
1458
+ {
1459
+ "name": "timestamp",
1460
+ "type": "i64"
1461
+ },
1462
+ {
1463
+ "name": "pre_virtual_sol_reserves",
1464
+ "type": "u64"
1465
+ },
1466
+ {
1467
+ "name": "pre_virtual_token_reserves",
1468
+ "type": "u64"
1469
+ },
1470
+ {
1471
+ "name": "pre_real_sol_reserves",
1472
+ "type": "u64"
1473
+ },
1474
+ {
1475
+ "name": "pre_real_token_reserves",
1476
+ "type": "u64"
1477
+ }
431
1478
  ]
432
1479
  }
433
1480
  },
@@ -436,10 +1483,22 @@ const __EVA_IDL__ = {
436
1483
  "type": {
437
1484
  "kind": "struct",
438
1485
  "fields": [
439
- { "name": "trench", "type": "pubkey" },
440
- { "name": "user", "type": "pubkey" },
441
- { "name": "amount", "type": "u64" },
442
- { "name": "timestamp", "type": "i64" }
1486
+ {
1487
+ "name": "trench",
1488
+ "type": "pubkey"
1489
+ },
1490
+ {
1491
+ "name": "user",
1492
+ "type": "pubkey"
1493
+ },
1494
+ {
1495
+ "name": "amount",
1496
+ "type": "u64"
1497
+ },
1498
+ {
1499
+ "name": "timestamp",
1500
+ "type": "i64"
1501
+ }
443
1502
  ]
444
1503
  }
445
1504
  },
@@ -448,9 +1507,18 @@ const __EVA_IDL__ = {
448
1507
  "type": {
449
1508
  "kind": "struct",
450
1509
  "fields": [
451
- { "name": "trench", "type": "pubkey" },
452
- { "name": "sol_removed", "type": "u64" },
453
- { "name": "timestamp", "type": "i64" }
1510
+ {
1511
+ "name": "trench",
1512
+ "type": "pubkey"
1513
+ },
1514
+ {
1515
+ "name": "sol_removed",
1516
+ "type": "u64"
1517
+ },
1518
+ {
1519
+ "name": "timestamp",
1520
+ "type": "i64"
1521
+ }
454
1522
  ]
455
1523
  }
456
1524
  },
@@ -459,11 +1527,26 @@ const __EVA_IDL__ = {
459
1527
  "type": {
460
1528
  "kind": "struct",
461
1529
  "fields": [
462
- { "name": "trench", "type": "pubkey" },
463
- { "name": "creator", "type": "pubkey" },
464
- { "name": "id", "type": "u64" },
465
- { "name": "refund_lamports", "type": "u64" },
466
- { "name": "timestamp", "type": "i64" }
1530
+ {
1531
+ "name": "trench",
1532
+ "type": "pubkey"
1533
+ },
1534
+ {
1535
+ "name": "creator",
1536
+ "type": "pubkey"
1537
+ },
1538
+ {
1539
+ "name": "id",
1540
+ "type": "u64"
1541
+ },
1542
+ {
1543
+ "name": "refund_lamports",
1544
+ "type": "u64"
1545
+ },
1546
+ {
1547
+ "name": "timestamp",
1548
+ "type": "i64"
1549
+ }
467
1550
  ]
468
1551
  }
469
1552
  },
@@ -472,10 +1555,22 @@ const __EVA_IDL__ = {
472
1555
  "type": {
473
1556
  "kind": "struct",
474
1557
  "fields": [
475
- { "name": "trench", "type": "pubkey" },
476
- { "name": "creator", "type": "pubkey" },
477
- { "name": "id", "type": "u64" },
478
- { "name": "timestamp", "type": "i64" }
1558
+ {
1559
+ "name": "trench",
1560
+ "type": "pubkey"
1561
+ },
1562
+ {
1563
+ "name": "creator",
1564
+ "type": "pubkey"
1565
+ },
1566
+ {
1567
+ "name": "id",
1568
+ "type": "u64"
1569
+ },
1570
+ {
1571
+ "name": "timestamp",
1572
+ "type": "i64"
1573
+ }
479
1574
  ]
480
1575
  }
481
1576
  },
@@ -484,14 +1579,38 @@ const __EVA_IDL__ = {
484
1579
  "type": {
485
1580
  "kind": "struct",
486
1581
  "fields": [
487
- { "name": "trench", "type": "pubkey" },
488
- { "name": "user", "type": "pubkey" },
489
- { "name": "amount", "type": "u64" },
490
- { "name": "user_deposited", "type": "u64" },
491
- { "name": "total_deposited", "type": "u64" },
492
- { "name": "trench_balance", "type": "u64" },
493
- { "name": "timestamp", "type": "i64" },
494
- { "name": "think_id", "type": "u64" }
1582
+ {
1583
+ "name": "trench",
1584
+ "type": "pubkey"
1585
+ },
1586
+ {
1587
+ "name": "user",
1588
+ "type": "pubkey"
1589
+ },
1590
+ {
1591
+ "name": "amount",
1592
+ "type": "u64"
1593
+ },
1594
+ {
1595
+ "name": "user_deposited",
1596
+ "type": "u64"
1597
+ },
1598
+ {
1599
+ "name": "total_deposited",
1600
+ "type": "u64"
1601
+ },
1602
+ {
1603
+ "name": "trench_balance",
1604
+ "type": "u64"
1605
+ },
1606
+ {
1607
+ "name": "timestamp",
1608
+ "type": "i64"
1609
+ },
1610
+ {
1611
+ "name": "think_id",
1612
+ "type": "u64"
1613
+ }
495
1614
  ]
496
1615
  }
497
1616
  },
@@ -500,11 +1619,30 @@ const __EVA_IDL__ = {
500
1619
  "type": {
501
1620
  "kind": "struct",
502
1621
  "fields": [
503
- { "name": "trench", "type": "pubkey" },
504
- { "name": "winners", "type": { "vec": "pubkey" } },
505
- { "name": "amounts", "type": { "vec": "u64" } },
506
- { "name": "total_winners", "type": "u64" },
507
- { "name": "timestamp", "type": "i64" }
1622
+ {
1623
+ "name": "trench",
1624
+ "type": "pubkey"
1625
+ },
1626
+ {
1627
+ "name": "winners",
1628
+ "type": {
1629
+ "vec": "pubkey"
1630
+ }
1631
+ },
1632
+ {
1633
+ "name": "amounts",
1634
+ "type": {
1635
+ "vec": "u64"
1636
+ }
1637
+ },
1638
+ {
1639
+ "name": "total_winners",
1640
+ "type": "u64"
1641
+ },
1642
+ {
1643
+ "name": "timestamp",
1644
+ "type": "i64"
1645
+ }
508
1646
  ]
509
1647
  }
510
1648
  },
@@ -513,10 +1651,22 @@ const __EVA_IDL__ = {
513
1651
  "type": {
514
1652
  "kind": "struct",
515
1653
  "fields": [
516
- { "name": "trench", "type": "pubkey" },
517
- { "name": "sol_for_lp", "type": "u64" },
518
- { "name": "tokens_for_lp", "type": "u64" },
519
- { "name": "timestamp", "type": "i64" }
1654
+ {
1655
+ "name": "trench",
1656
+ "type": "pubkey"
1657
+ },
1658
+ {
1659
+ "name": "sol_for_lp",
1660
+ "type": "u64"
1661
+ },
1662
+ {
1663
+ "name": "tokens_for_lp",
1664
+ "type": "u64"
1665
+ },
1666
+ {
1667
+ "name": "timestamp",
1668
+ "type": "i64"
1669
+ }
520
1670
  ]
521
1671
  }
522
1672
  },
@@ -525,11 +1675,30 @@ const __EVA_IDL__ = {
525
1675
  "type": {
526
1676
  "kind": "struct",
527
1677
  "fields": [
528
- { "name": "admin", "type": "pubkey" },
529
- { "name": "fee_recipient", "type": "pubkey" },
530
- { "name": "total_trenches", "type": "u64" },
531
- { "name": "bidding_duration", "type": "u64" },
532
- { "name": "trading_duration", "type": "u64" }
1678
+ {
1679
+ "name": "admin",
1680
+ "type": "pubkey"
1681
+ },
1682
+ {
1683
+ "name": "fee_recipient",
1684
+ "type": "pubkey"
1685
+ },
1686
+ {
1687
+ "name": "back_authority",
1688
+ "type": "pubkey"
1689
+ },
1690
+ {
1691
+ "name": "total_trenches",
1692
+ "type": "u64"
1693
+ },
1694
+ {
1695
+ "name": "bidding_duration",
1696
+ "type": "u64"
1697
+ },
1698
+ {
1699
+ "name": "trading_duration",
1700
+ "type": "u64"
1701
+ }
533
1702
  ]
534
1703
  }
535
1704
  },
@@ -538,8 +1707,14 @@ const __EVA_IDL__ = {
538
1707
  "type": {
539
1708
  "kind": "struct",
540
1709
  "fields": [
541
- { "name": "admin", "type": "pubkey" },
542
- { "name": "timestamp", "type": "i64" }
1710
+ {
1711
+ "name": "admin",
1712
+ "type": "pubkey"
1713
+ },
1714
+ {
1715
+ "name": "timestamp",
1716
+ "type": "i64"
1717
+ }
543
1718
  ]
544
1719
  }
545
1720
  },
@@ -548,17 +1723,50 @@ const __EVA_IDL__ = {
548
1723
  "type": {
549
1724
  "kind": "struct",
550
1725
  "fields": [
551
- { "name": "trench", "type": "pubkey" },
552
- { "name": "user", "type": "pubkey" },
553
- { "name": "sol_amount", "type": "u64" },
554
- { "name": "token_amount", "type": "u64" },
555
- { "name": "trench_balance", "type": "u64" },
556
- { "name": "think_id", "type": "u64" },
557
- { "name": "timestamp", "type": "i64" },
558
- { "name": "pre_virtual_sol_reserves", "type": "u64" },
559
- { "name": "pre_virtual_token_reserves", "type": "u64" },
560
- { "name": "pre_real_sol_reserves", "type": "u64" },
561
- { "name": "pre_real_token_reserves", "type": "u64" }
1726
+ {
1727
+ "name": "trench",
1728
+ "type": "pubkey"
1729
+ },
1730
+ {
1731
+ "name": "user",
1732
+ "type": "pubkey"
1733
+ },
1734
+ {
1735
+ "name": "sol_amount",
1736
+ "type": "u64"
1737
+ },
1738
+ {
1739
+ "name": "token_amount",
1740
+ "type": "u64"
1741
+ },
1742
+ {
1743
+ "name": "trench_balance",
1744
+ "type": "u64"
1745
+ },
1746
+ {
1747
+ "name": "think_id",
1748
+ "type": "u64"
1749
+ },
1750
+ {
1751
+ "name": "timestamp",
1752
+ "type": "i64"
1753
+ },
1754
+ {
1755
+ "name": "pre_virtual_sol_reserves",
1756
+ "type": "u64"
1757
+ },
1758
+ {
1759
+ "name": "pre_virtual_token_reserves",
1760
+ "type": "u64"
1761
+ },
1762
+ {
1763
+ "name": "pre_real_sol_reserves",
1764
+ "type": "u64"
1765
+ },
1766
+ {
1767
+ "name": "pre_real_token_reserves",
1768
+ "type": "u64"
1769
+ }
562
1770
  ]
563
1771
  }
564
1772
  },
@@ -567,23 +1775,78 @@ const __EVA_IDL__ = {
567
1775
  "type": {
568
1776
  "kind": "struct",
569
1777
  "fields": [
570
- { "name": "id", "type": "u64" },
571
- { "name": "creator", "type": "pubkey" },
572
- { "name": "authority", "type": "pubkey" },
573
- { "name": "status", "type": { "defined": { "name": "TrenchStatus" } } },
574
- { "name": "total_deposited_sol", "type": "u64" },
575
- { "name": "virtual_sol_reserves", "type": "u128" },
576
- { "name": "virtual_token_reserves", "type": "u128" },
577
- { "name": "real_sol_reserves", "type": "u128" },
578
- { "name": "real_token_reserves", "type": "u128" },
579
- { "name": "initial_virtual_token_reserves", "type": "u128" },
580
- { "name": "bidding_start_block", "type": "u64" },
581
- { "name": "bidding_end_block", "type": "u64" },
582
- { "name": "trading_end_block", "type": "u64" },
583
- { "name": "token_mint", "type": "pubkey" },
584
- { "name": "start_time", "type": "i64" },
585
- { "name": "prize_pool_reserves", "type": "u64" },
586
- { "name": "bump", "type": "u8" }
1778
+ {
1779
+ "name": "id",
1780
+ "type": "u64"
1781
+ },
1782
+ {
1783
+ "name": "creator",
1784
+ "type": "pubkey"
1785
+ },
1786
+ {
1787
+ "name": "authority",
1788
+ "type": "pubkey"
1789
+ },
1790
+ {
1791
+ "name": "status",
1792
+ "type": {
1793
+ "defined": {
1794
+ "name": "TrenchStatus"
1795
+ }
1796
+ }
1797
+ },
1798
+ {
1799
+ "name": "total_deposited_sol",
1800
+ "type": "u64"
1801
+ },
1802
+ {
1803
+ "name": "virtual_sol_reserves",
1804
+ "type": "u128"
1805
+ },
1806
+ {
1807
+ "name": "virtual_token_reserves",
1808
+ "type": "u128"
1809
+ },
1810
+ {
1811
+ "name": "real_sol_reserves",
1812
+ "type": "u128"
1813
+ },
1814
+ {
1815
+ "name": "real_token_reserves",
1816
+ "type": "u128"
1817
+ },
1818
+ {
1819
+ "name": "initial_virtual_token_reserves",
1820
+ "type": "u128"
1821
+ },
1822
+ {
1823
+ "name": "bidding_start_block",
1824
+ "type": "u64"
1825
+ },
1826
+ {
1827
+ "name": "bidding_end_block",
1828
+ "type": "u64"
1829
+ },
1830
+ {
1831
+ "name": "trading_end_block",
1832
+ "type": "u64"
1833
+ },
1834
+ {
1835
+ "name": "token_mint",
1836
+ "type": "pubkey"
1837
+ },
1838
+ {
1839
+ "name": "start_time",
1840
+ "type": "i64"
1841
+ },
1842
+ {
1843
+ "name": "prize_pool_reserves",
1844
+ "type": "u64"
1845
+ },
1846
+ {
1847
+ "name": "bump",
1848
+ "type": "u8"
1849
+ }
587
1850
  ]
588
1851
  }
589
1852
  },
@@ -592,9 +1855,15 @@ const __EVA_IDL__ = {
592
1855
  "type": {
593
1856
  "kind": "enum",
594
1857
  "variants": [
595
- { "name": "Bidding" },
596
- { "name": "Trading" },
597
- { "name": "Ended" }
1858
+ {
1859
+ "name": "Bidding"
1860
+ },
1861
+ {
1862
+ "name": "Trading"
1863
+ },
1864
+ {
1865
+ "name": "Ended"
1866
+ }
598
1867
  ]
599
1868
  }
600
1869
  },
@@ -603,14 +1872,38 @@ const __EVA_IDL__ = {
603
1872
  "type": {
604
1873
  "kind": "struct",
605
1874
  "fields": [
606
- { "name": "trench", "type": "pubkey" },
607
- { "name": "user", "type": "pubkey" },
608
- { "name": "amount", "type": "u64" },
609
- { "name": "user_deposited", "type": "u64" },
610
- { "name": "total_deposited", "type": "u64" },
611
- { "name": "trench_balance", "type": "u64" },
612
- { "name": "timestamp", "type": "i64" },
613
- { "name": "think_id", "type": "u64" }
1875
+ {
1876
+ "name": "trench",
1877
+ "type": "pubkey"
1878
+ },
1879
+ {
1880
+ "name": "user",
1881
+ "type": "pubkey"
1882
+ },
1883
+ {
1884
+ "name": "amount",
1885
+ "type": "u64"
1886
+ },
1887
+ {
1888
+ "name": "user_deposited",
1889
+ "type": "u64"
1890
+ },
1891
+ {
1892
+ "name": "total_deposited",
1893
+ "type": "u64"
1894
+ },
1895
+ {
1896
+ "name": "trench_balance",
1897
+ "type": "u64"
1898
+ },
1899
+ {
1900
+ "name": "timestamp",
1901
+ "type": "i64"
1902
+ },
1903
+ {
1904
+ "name": "think_id",
1905
+ "type": "u64"
1906
+ }
614
1907
  ]
615
1908
  }
616
1909
  }
@@ -773,15 +2066,21 @@ function decodeTrench(data) {
773
2066
  bump: data[exports.TRENCH_OFFSETS.bump],
774
2067
  };
775
2068
  }
2069
+ // ---- GlobalState (state.rs, eva ≥0.1.7): disc(8) admin(32) fee_recipient(32) back_authority(32) total_trenches(u64) bidding_duration(u64) trading_duration(u64) ----
2070
+ // `back_authority` (added in v0.1.7/0.1.8) signs the admin-gated game ops (finalize / close_pool /
2071
+ // claim_tokens / distribute_prize); `admin` still signs initialize / update_config. Its 32 bytes sit
2072
+ // between fee_recipient and total_trenches, shifting the three u64s by 32.
2073
+ exports.GLOBAL_STATE_LEN = 128; // 8 + 32*3 + 8*3
776
2074
  function decodeGlobalState(data) {
777
- if (data.length < 88)
778
- throw new Error(`GlobalState data too short: ${data.length} < 88`);
2075
+ if (data.length < exports.GLOBAL_STATE_LEN)
2076
+ throw new Error(`GlobalState data too short: ${data.length} < ${exports.GLOBAL_STATE_LEN}`);
779
2077
  return {
780
2078
  admin: data.slice(8, 40),
781
2079
  feeRecipient: data.slice(40, 72),
782
- totalTrenches: uLE(data, 72, 8),
783
- biddingDuration: uLE(data, 80, 8),
784
- tradingDuration: data.length >= 96 ? uLE(data, 88, 8) : 0n,
2080
+ backAuthority: data.slice(72, 104),
2081
+ totalTrenches: uLE(data, 104, 8),
2082
+ biddingDuration: uLE(data, 112, 8),
2083
+ tradingDuration: uLE(data, 120, 8),
785
2084
  };
786
2085
  }
787
2086
  // ---- Portal Session (portal/src/state.rs struct Session; Borsh, LEN 219, discriminator 1) ----
@@ -1042,7 +2341,7 @@ function loadBundledIdl() {
1042
2341
  return __EVA_IDL__;
1043
2342
  }
1044
2343
  /**
1045
- * The eva Anchor IDL (v0.1.6), exported as a typed constant so you can build your own `Program`
2344
+ * The eva Anchor IDL (v0.1.8), exported as a typed constant so you can build your own `Program`
1046
2345
  * with full types:
1047
2346
  * `new anchor.Program<EvaArena>(EVA_IDL, provider)` // then NorthstarEva.create({ program, provider, l1Endpoint })
1048
2347
  * The {@link EvaArena} type (the generated camelCase TS IDL) is also exported. The runtime value
@@ -1374,10 +2673,10 @@ class NorthstarEva {
1374
2673
  buildDepositIx(p) {
1375
2674
  return this.methods.deposit(this.bn(p.lamports), this.bn(p.thinkId ?? 0n)).accounts({ trench: this.trenchPda(p.trenchId), user: p.user ?? this.payer }).instruction();
1376
2675
  }
1377
- /** eva finalize instruction (ER). Reads global for feeRecipient; does NOT wait for the bidding window. */
2676
+ /** eva finalize instruction (ER, back_authority). Reads global for feeRecipient; does NOT wait for the bidding window. `backAuthority` (the signer) defaults to the SDK signer. */
1378
2677
  async buildFinalizeIx(p) {
1379
2678
  const g = await this.requireGlobal();
1380
- return this.methods.finalize().accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), admin: this.payer }).instruction();
2679
+ return this.methods.finalize().accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), backAuthority: p.backAuthority ?? this.payer }).instruction();
1381
2680
  }
1382
2681
  /** ATA-create instruction (ER) for a user's trench token account (idempotent). */
1383
2682
  buildUserAtaIx(p) {
@@ -1396,19 +2695,24 @@ class NorthstarEva {
1396
2695
  const user = p.user ?? this.payer;
1397
2696
  return this.methods.sell(this.bn(p.tokenAmount), this.bn(p.minSolOutput ?? 0n), this.bn(p.thinkId ?? 0n)).accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), user, trenchTokenVault: this.trenchVault(p.trenchId), userTokenAccount: this.userAta(p.trenchId, user), tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }).instruction();
1398
2697
  }
1399
- /** eva updateConfig instruction (ER, admin) — change bidding/trading durations + fee recipient. */
1400
- buildUpdateConfigIx(p) {
1401
- return this.methods.updateConfig(this.bn(p.biddingDuration), this.bn(p.tradingDuration), p.feeRecipient).accounts({ globalState: this.globalStatePda(), admin: this.payer }).instruction();
2698
+ /**
2699
+ * eva updateConfig instruction (ER, admin) — change bidding/trading durations, fee recipient, and
2700
+ * the `back_authority` (eva ≥0.1.7). Still **admin**-signed. `backAuthority` defaults to the CURRENT
2701
+ * on-chain value (read from global) so callers that only change durations/fee don't reset it.
2702
+ */
2703
+ async buildUpdateConfigIx(p) {
2704
+ const backAuthority = p.backAuthority ?? new web3_js_1.PublicKey((await this.requireGlobal()).backAuthority);
2705
+ return this.methods.updateConfig(this.bn(p.biddingDuration), this.bn(p.tradingDuration), p.feeRecipient, backAuthority).accounts({ globalState: this.globalStatePda(), admin: this.payer }).instruction();
1402
2706
  }
1403
2707
  /** eva withdraw instruction (ER) — withdraw a bid deposit from a trench (inverse of {@link buildDepositIx}). NOT the Portal SOL bridge ({@link buildWithdrawFeeFromErIx}). */
1404
2708
  buildWithdrawIx(p) {
1405
2709
  const user = p.user ?? this.payer;
1406
2710
  return this.methods.withdraw(this.bn(p.amount), this.bn(p.thinkId ?? 0n)).accounts({ trench: this.trenchPda(p.trenchId), agent: this.agentPda(p.trenchId, user), user }).instruction();
1407
2711
  }
1408
- /** eva closePool instruction (ER, admin) — close a finished trench's pool. */
2712
+ /** eva closePool instruction (ER, back_authority) — close a finished trench's pool. `backAuthority` (the signer) defaults to the SDK signer. */
1409
2713
  async buildClosePoolIx(p) {
1410
2714
  const g = await this.requireGlobal();
1411
- return this.methods.closePool().accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), admin: this.payer }).instruction();
2715
+ return this.methods.closePool().accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), backAuthority: p.backAuthority ?? this.payer }).instruction();
1412
2716
  }
1413
2717
  /**
1414
2718
  * eva closeTrench instruction (ER) — close an **Ended** trench (post close_pool + distribute_prize),
@@ -1418,15 +2722,22 @@ class NorthstarEva {
1418
2722
  buildCloseTrenchIx(p) {
1419
2723
  return this.methods.closeTrench().accounts({ trench: this.trenchPda(p.trenchId), creator: p.creator ?? this.payer }).instruction();
1420
2724
  }
1421
- /** eva claimTokens instruction (ER, admin) — release `user`'s tokens from the trench vault to their ATA. */
2725
+ /** eva claimTokens instruction (ER, back_authority) — release `user`'s tokens from the trench vault to their ATA. `backAuthority` (the signer) defaults to the SDK signer. */
1422
2726
  buildClaimTokensIx(p) {
1423
2727
  const user = p.user ?? this.payer;
1424
- return this.methods.claimTokens().accounts({ globalState: this.globalStatePda(), trench: this.trenchPda(p.trenchId), agent: this.agentPda(p.trenchId, user), user, admin: this.payer, trenchTokenVault: this.trenchVault(p.trenchId), userTokenAccount: this.userAta(p.trenchId, user), tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }).instruction();
2728
+ return this.methods.claimTokens().accounts({ globalState: this.globalStatePda(), trench: this.trenchPda(p.trenchId), agent: this.agentPda(p.trenchId, user), user, backAuthority: p.backAuthority ?? this.payer, trenchTokenVault: this.trenchVault(p.trenchId), userTokenAccount: this.userAta(p.trenchId, user), tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }).instruction();
1425
2729
  }
1426
- /** eva distributePrize instruction (ER, admin) — pay out the prize pool to `winners` by `amounts` (lamports). */
2730
+ /** eva distributePrize instruction (ER, back_authority) — pay out the prize pool to `winners` by `amounts` (lamports). `backAuthority` (the signer) defaults to the SDK signer. */
1427
2731
  async buildDistributePrizeIx(p) {
2732
+ if (p.winners.length !== p.amounts.length)
2733
+ throw new Error(`distributePrize: winners (${p.winners.length}) and amounts (${p.amounts.length}) must be the same length`);
1428
2734
  const g = await this.requireGlobal();
1429
- return this.methods.distributePrize(p.winners, p.amounts.map((a) => this.bn(a))).accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), admin: this.payer }).instruction();
2735
+ // The program pays each winner by finding its account in remaining_accounts, so EACH winner must
2736
+ // be appended as a writable account — otherwise it fails with WinnerAccountMissing (6013).
2737
+ return this.methods.distributePrize(p.winners, p.amounts.map((a) => this.bn(a)))
2738
+ .accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new web3_js_1.PublicKey(g.feeRecipient), backAuthority: p.backAuthority ?? this.payer })
2739
+ .remainingAccounts(p.winners.map((w) => ({ pubkey: w, isWritable: true, isSigner: false })))
2740
+ .instruction();
1430
2741
  }
1431
2742
  /**
1432
2743
  * Bundle instruction(s) into an UNSIGNED `Transaction` (feePayer + recent blockhash set) for the
@@ -1616,7 +2927,7 @@ class NorthstarEva {
1616
2927
  async deposit(p) {
1617
2928
  return this.sendEva(await this.buildDepositIx(p), "deposit");
1618
2929
  }
1619
- /** finalize — waits for the ER slot to pass biddingEndBlock, then seeds the AMM. */
2930
+ /** finalize — waits for the ER slot to pass biddingEndBlock, then seeds the AMM. Signed by the back_authority (defaults to the SDK signer). */
1620
2931
  async finalize(p) {
1621
2932
  const t = await this.getTrench(p.trenchId, "er", 10);
1622
2933
  if (t)
@@ -1640,7 +2951,7 @@ class NorthstarEva {
1640
2951
  const signature = await this.sendEva(await this.buildSellIx(p), "sell");
1641
2952
  return { signature, trench: (await this.getTrench(p.trenchId, "er", 5)), userTokens: await this.getUserTokenBalance(p.trenchId) };
1642
2953
  }
1643
- /** eva updateConfig (ER, admin) — set bidding/trading durations + fee recipient on the global config. */
2954
+ /** eva updateConfig (ER, admin) — set bidding/trading durations, fee recipient + back_authority on the global config. `backAuthority` defaults to the current on-chain value. */
1644
2955
  async updateConfig(p) {
1645
2956
  return this.sendEva(await this.buildUpdateConfigIx(p), "updateConfig");
1646
2957
  }
@@ -1648,7 +2959,7 @@ class NorthstarEva {
1648
2959
  async withdraw(p) {
1649
2960
  return this.sendEva(await this.buildWithdrawIx(p), "withdraw");
1650
2961
  }
1651
- /** eva closePool (ER, admin) — close a finished trench's pool. */
2962
+ /** eva closePool (ER, back_authority) — close a finished trench's pool. Signed by the back_authority (defaults to the SDK signer). */
1652
2963
  async closePool(p) {
1653
2964
  return this.sendEva(await this.buildClosePoolIx(p), "closePool");
1654
2965
  }
@@ -1656,11 +2967,11 @@ class NorthstarEva {
1656
2967
  async closeTrench(p) {
1657
2968
  return this.sendEva(await this.buildCloseTrenchIx(p), "closeTrench");
1658
2969
  }
1659
- /** eva claimTokens (ER, admin) — release `user`'s tokens from the trench vault to their ATA. */
2970
+ /** eva claimTokens (ER, back_authority) — release `user`'s tokens from the trench vault to their ATA. Signed by the back_authority (defaults to the SDK signer). */
1660
2971
  async claimTokens(p) {
1661
2972
  return this.sendEva(await this.buildClaimTokensIx(p), "claimTokens");
1662
2973
  }
1663
- /** eva distributePrize (ER, admin) — pay the prize pool to `winners` by `amounts` (lamports). */
2974
+ /** eva distributePrize (ER, back_authority) — pay the prize pool to `winners` by `amounts` (lamports). Signed by the back_authority (defaults to the SDK signer). */
1664
2975
  async distributePrize(p) {
1665
2976
  return this.sendEva(await this.buildDistributePrizeIx(p), "distributePrize");
1666
2977
  }