@perena/vault-sdk 1.0.66 → 1.0.67
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 +67 -1
- package/dist/index.d.ts +524 -18
- package/dist/index.js +1341 -559
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -663,6 +663,72 @@ const plan = await client.tx.executeTrancheDeposit.getTx({
|
|
|
663
663
|
await client.sendTransaction(payer, plan);
|
|
664
664
|
```
|
|
665
665
|
|
|
666
|
+
### Example: async regular-share redemption
|
|
667
|
+
|
|
668
|
+
Regular shares default to synchronous redemption. The curator can set
|
|
669
|
+
`redemptionMode: { asyncOnly: {} }` through `setVaultConfig` (or restore
|
|
670
|
+
`{ synchronous: {} }`). Configure `fulfiller` using the existing role timelock
|
|
671
|
+
before processing requests. Async-only mode blocks direct regular withdrawals,
|
|
672
|
+
including fee-exempt/external variants, and regular-to-tranche share swaps.
|
|
673
|
+
Junior and senior tranche redemption policies are unchanged.
|
|
674
|
+
|
|
675
|
+
```typescript
|
|
676
|
+
await client.sendTransaction(curator, await client.tx.setVaultConfig.getTx({
|
|
677
|
+
curator: fromWeb3Pk(curator.publicKey),
|
|
678
|
+
vault,
|
|
679
|
+
redemptionMode: { asyncOnly: {} },
|
|
680
|
+
}));
|
|
681
|
+
|
|
682
|
+
await client.sendTransaction(user, await client.tx.requestAsyncWithdraw.getTx({
|
|
683
|
+
user: fromWeb3Pk(user.publicKey),
|
|
684
|
+
vault,
|
|
685
|
+
assetMint,
|
|
686
|
+
queueId: 0,
|
|
687
|
+
shareAmount: 100_000n,
|
|
688
|
+
}));
|
|
689
|
+
|
|
690
|
+
const pending = await client.account.fetchPendingRedemptionQueues(vault);
|
|
691
|
+
// Optional second argument restricts the results to one owner.
|
|
692
|
+
|
|
693
|
+
await client.sendTransaction(fulfiller, await client.tx.fulfillAsyncWithdraw.getTx({
|
|
694
|
+
signer: fromWeb3Pk(fulfiller.publicKey),
|
|
695
|
+
owner: fromWeb3Pk(user.publicKey),
|
|
696
|
+
vault,
|
|
697
|
+
assetMint,
|
|
698
|
+
queueId: 0,
|
|
699
|
+
}));
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
Requests escrow shares without changing supply or NAV. There is no fixed lockup:
|
|
703
|
+
only the configured fulfiller can settle regular requests, using current NAV,
|
|
704
|
+
asset prices, burn fees, and withdrawal limits. Settlement is all-or-nothing,
|
|
705
|
+
burns the requested shares, pays the owner's asset ATA, returns surplus escrow
|
|
706
|
+
shares, and refunds queue/escrow rent to the original payer. The builder creates
|
|
707
|
+
missing owner ATAs and resolves the recorded rent payer. Settlement uses the
|
|
708
|
+
vault's local token balance first and pulls only the net payout's shortfall from
|
|
709
|
+
external liquidity. The builder checks fresh pricing, the queued share amount,
|
|
710
|
+
and the live local balance; when local funds cover the payout, it omits external
|
|
711
|
+
CPI accounts and lookups. Otherwise it prepares the same single-source external
|
|
712
|
+
resolution as junior queue fulfillment. Explicit CPI refs remain caller-controlled.
|
|
713
|
+
Insufficient combined liquidity leaves the request pending. If liquidity or
|
|
714
|
+
pricing changes after building a local-only transaction, rebuild it to resolve
|
|
715
|
+
any newly required external accounts; the fulfiller does this on its next run.
|
|
716
|
+
|
|
717
|
+
Both share classes share the existing `VaultWithdrawalQueue` layout and the
|
|
718
|
+
256 queue IDs per owner/vault. `fetchAllWithdrawalQueues` supports vault, owner,
|
|
719
|
+
and input-mint filters; `fetchPendingRedemptionQueues` selects regular shares.
|
|
720
|
+
`WithdrawalQueueService` routes by input mint, so previously accepted requests
|
|
721
|
+
remain fulfillable after switching back to synchronous mode. The existing
|
|
722
|
+
`cancelJuniorTrancheWithdraw` on-chain instruction also accepts regular queues;
|
|
723
|
+
its SDK builder can be used with the regular mint as `juniorShareMint` and an
|
|
724
|
+
explicit `shareTokenProgram` until a generic cancellation name is introduced.
|
|
725
|
+
|
|
726
|
+
The redemption mode occupies an existing zeroed vault padding byte, preserving
|
|
727
|
+
account size and offsets. Deploy the updated program and publish SDK 1.0.67
|
|
728
|
+
before rebuilding the backend fulfiller pinned to that version. Existing config
|
|
729
|
+
payloads that omit the trailing mode option remain valid.
|
|
730
|
+
Use the refreshed IDL/SDK to set the new policy.
|
|
731
|
+
|
|
666
732
|
### Example: junior withdrawal queue
|
|
667
733
|
|
|
668
734
|
```typescript
|
|
@@ -875,7 +941,7 @@ Argument shapes for each builder: [`src/client/builders/args.ts`](src/client/bui
|
|
|
875
941
|
For recurring backend work, prefer the services layer over reimplementing
|
|
876
942
|
discovery logic in your app:
|
|
877
943
|
|
|
878
|
-
- **`WithdrawalQueueService`** — scan and fulfill eligible junior withdrawal
|
|
944
|
+
- **`WithdrawalQueueService`** — scan and fulfill regular and eligible junior withdrawal
|
|
879
945
|
queues (`src/services/withdrawalQueueService.ts`)
|
|
880
946
|
- **`OracleService`** — consensus oracle / asset price updates
|
|
881
947
|
(`src/services/oracleService.ts`)
|