northstar-eva-sdk 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,7 +69,7 @@ tx.sign(myKeypair); // or wallet.signTransaction(tx)
69
69
  await connection.sendRawTransaction(tx.serialize());
70
70
  ```
71
71
 
72
- Builders (each mirrors the send-method's inputs): `buildOpenSessionIx()`, `buildCloseSessionIx()`, `buildDepositFeeIx(lamports, recipient?)`, `buildWithdrawFeeFromErIx({ lamports, sender?, toL1? })` (Portal SOL bridge), `buildInitializeIx(p)`, `buildUpdateConfigIx(p)`, `buildCreateTrenchIx({ trenchId?, initialVirtualTokenReserves? })`, `buildDepositIx(p)`, `buildWithdrawIx({ trenchId, amount, thinkId? })` (eva trench withdraw), `buildFinalizeIx(p)`, `buildUserAtaIx(p)`, `buildBuyIx(p)`, `buildSellIx(p)`, `buildClosePoolIx(p)`, `buildClaimTokensIx(p)`, `buildDistributePrizeIx(p)`, plus `buildTransaction(ixs, { lane?, feePayer? })`, `nextTrenchId()`, and the `agentPda(id, user?)` PDA helper.
72
+ Builders (each mirrors the send-method's inputs): `buildOpenSessionIx()`, `buildCloseSessionIx()`, `buildDepositFeeIx(lamports, recipient?, sender?)` (sender = the depositor/signer; defaults to the SDK signer), `buildWithdrawFeeFromErIx({ lamports, sender?, toL1? })` (Portal SOL bridge), `buildInitializeIx(p)`, `buildUpdateConfigIx(p)`, `buildCreateTrenchIx({ trenchId?, initialVirtualTokenReserves? })`, `buildDepositIx(p)`, `buildWithdrawIx({ trenchId, amount, thinkId? })` (eva trench withdraw), `buildFinalizeIx(p)`, `buildUserAtaIx(p)`, `buildBuyIx(p)`, `buildSellIx(p)`, `buildClosePoolIx(p)`, `buildCloseTrenchIx({ trenchId, creator? })`, `buildClaimTokensIx(p)`, `buildDistributePrizeIx(p)`, plus `buildTransaction(ixs, { lane?, feePayer? })`, `nextTrenchId()`, and the `agentPda(id, user?)` PDA helper.
73
73
 
74
74
  > The existing send-methods (`buy`, `sell`, `fundFeeToErPayer`, …) are unchanged — they now just call these builders internally. Builders perform the same state **reads** to resolve accounts (e.g. `buildBuyIx` reads global for `feeRecipient`) but never **send**.
75
75
 
@@ -389,8 +389,13 @@ export declare class NorthstarEva {
389
389
  * `const ix = await sdk.buildEnsureSessionIx(); if (ix) tx.add(ix);`
390
390
  */
391
391
  buildEnsureSessionIx(): Promise<TransactionInstruction | null>;
392
- /** Portal DepositFee instruction (L1) — "fund fee to ER payer". (Caller must ensure a session exists.) */
393
- buildDepositFeeIx(lamports: bigint, recipient?: PublicKey): TransactionInstruction;
392
+ /**
393
+ * Portal DepositFee instruction (L1) "fund fee to ER payer". (Caller must ensure a session exists.)
394
+ * `sender` is the **depositor** — the account that pays the SOL on L1 and **must sign** the tx;
395
+ * defaults to the SDK signer, but pass it explicitly for user-signed flows (don't rely on the default).
396
+ * `recipient` is the account credited on the ER (defaults to the SDK signer).
397
+ */
398
+ buildDepositFeeIx(lamports: bigint, recipient?: PublicKey, sender?: PublicKey): TransactionInstruction;
394
399
  /** "Withdraw fee from ER" instruction (ER) — system transfer from `sender` (default: the signer) → its WithdrawalSink. (Portal SOL bridge; distinct from the eva `withdraw` instruction.) */
395
400
  buildWithdrawFeeFromErIx(p: {
396
401
  lamports: bigint;
@@ -457,6 +462,15 @@ export declare class NorthstarEva {
457
462
  buildClosePoolIx(p: {
458
463
  trenchId: bigint;
459
464
  }): Promise<TransactionInstruction>;
465
+ /**
466
+ * eva closeTrench instruction (ER) — close an **Ended** trench (post close_pool + distribute_prize),
467
+ * refunding the remaining lamports (rent + undistributed prize dust) to the trench **creator**.
468
+ * The trench's stored `creator` must sign (`has_one = creator`); defaults to the SDK signer.
469
+ */
470
+ buildCloseTrenchIx(p: {
471
+ trenchId: bigint;
472
+ creator?: PublicKey;
473
+ }): Promise<TransactionInstruction>;
460
474
  /** eva claimTokens instruction (ER, admin) — release `user`'s tokens from the trench vault to their ATA. */
461
475
  buildClaimTokensIx(p: {
462
476
  trenchId: bigint;
@@ -628,6 +642,11 @@ export declare class NorthstarEva {
628
642
  closePool(p: {
629
643
  trenchId: bigint;
630
644
  }): Promise<string>;
645
+ /** eva closeTrench (ER) — close an **Ended** trench, refunding remaining lamports to the creator (who signs). */
646
+ closeTrench(p: {
647
+ trenchId: bigint;
648
+ creator?: PublicKey;
649
+ }): Promise<string>;
631
650
  /** eva claimTokens (ER, admin) — release `user`'s tokens from the trench vault to their ATA. */
632
651
  claimTokens(p: {
633
652
  trenchId: bigint;
@@ -14,7 +14,7 @@ const __EVA_IDL__ = {
14
14
  "address": "CQru6EauVg2UwepFCvY5qWuqCPEWYC4ta43wBbkFYtmo",
15
15
  "metadata": {
16
16
  "name": "eva_arena",
17
- "version": "0.1.4",
17
+ "version": "0.1.6",
18
18
  "spec": "0.1.0",
19
19
  "description": "Created with Anchor"
20
20
  },
@@ -381,6 +381,31 @@ const __EVA_IDL__ = {
381
381
  ],
382
382
  "args": []
383
383
  },
384
+ {
385
+ "name": "close_trench",
386
+ "discriminator": [
387
+ 249,
388
+ 176,
389
+ 185,
390
+ 73,
391
+ 24,
392
+ 59,
393
+ 234,
394
+ 84
395
+ ],
396
+ "accounts": [
397
+ {
398
+ "name": "trench",
399
+ "writable": true
400
+ },
401
+ {
402
+ "name": "creator",
403
+ "writable": true,
404
+ "signer": true
405
+ }
406
+ ],
407
+ "args": []
408
+ },
384
409
  {
385
410
  "name": "create_trench",
386
411
  "discriminator": [
@@ -2478,9 +2503,14 @@ export class NorthstarEva {
2478
2503
  return null; // already created
2479
2504
  return this.buildOpenSessionIx();
2480
2505
  }
2481
- /** Portal DepositFee instruction (L1) — "fund fee to ER payer". (Caller must ensure a session exists.) */
2482
- buildDepositFeeIx(lamports, recipient = this.payer) {
2483
- return portal.depositFeeIx({ programId: this.cfg.portalProgramId, depositor: this.payer, recipient, lamports });
2506
+ /**
2507
+ * Portal DepositFee instruction (L1) "fund fee to ER payer". (Caller must ensure a session exists.)
2508
+ * `sender` is the **depositor** the account that pays the SOL on L1 and **must sign** the tx;
2509
+ * defaults to the SDK signer, but pass it explicitly for user-signed flows (don't rely on the default).
2510
+ * `recipient` is the account credited on the ER (defaults to the SDK signer).
2511
+ */
2512
+ buildDepositFeeIx(lamports, recipient = this.payer, sender = this.payer) {
2513
+ return portal.depositFeeIx({ programId: this.cfg.portalProgramId, depositor: sender, recipient, lamports });
2484
2514
  }
2485
2515
  /** "Withdraw fee from ER" instruction (ER) — system transfer from `sender` (default: the signer) → its WithdrawalSink. (Portal SOL bridge; distinct from the eva `withdraw` instruction.) */
2486
2516
  buildWithdrawFeeFromErIx(p) {
@@ -2541,6 +2571,14 @@ export class NorthstarEva {
2541
2571
  const g = await this.requireGlobal();
2542
2572
  return this.methods.closePool().accounts({ trench: this.trenchPda(p.trenchId), globalState: this.globalStatePda(), feeRecipient: new PublicKey(g.feeRecipient), admin: this.payer }).instruction();
2543
2573
  }
2574
+ /**
2575
+ * eva closeTrench instruction (ER) — close an **Ended** trench (post close_pool + distribute_prize),
2576
+ * refunding the remaining lamports (rent + undistributed prize dust) to the trench **creator**.
2577
+ * The trench's stored `creator` must sign (`has_one = creator`); defaults to the SDK signer.
2578
+ */
2579
+ buildCloseTrenchIx(p) {
2580
+ return this.methods.closeTrench().accounts({ trench: this.trenchPda(p.trenchId), creator: p.creator ?? this.payer }).instruction();
2581
+ }
2544
2582
  /** eva claimTokens instruction (ER, admin) — release `user`'s tokens from the trench vault to their ATA. */
2545
2583
  buildClaimTokensIx(p) {
2546
2584
  const user = p.user ?? this.payer;
@@ -2775,6 +2813,10 @@ export class NorthstarEva {
2775
2813
  async closePool(p) {
2776
2814
  return this.sendEva(await this.buildClosePoolIx(p), "closePool");
2777
2815
  }
2816
+ /** eva closeTrench (ER) — close an **Ended** trench, refunding remaining lamports to the creator (who signs). */
2817
+ async closeTrench(p) {
2818
+ return this.sendEva(await this.buildCloseTrenchIx(p), "closeTrench");
2819
+ }
2778
2820
  /** eva claimTokens (ER, admin) — release `user`'s tokens from the trench vault to their ATA. */
2779
2821
  async claimTokens(p) {
2780
2822
  return this.sendEva(await this.buildClaimTokensIx(p), "claimTokens");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "northstar-eva-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Run the eva program on a NorthStar ephemeral rollup (zero-fee hot path). A high-level class SDK over the NorthStar Portal/ER protocol + the eva Anchor program. Works localnet & devnet.",
5
5
  "type": "module",
6
6
  "license": "MIT",