@perena/vault-sdk 1.0.37 → 1.0.40

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.
Files changed (4) hide show
  1. package/README.md +68 -1
  2. package/dist/index.d.ts +5106 -7996
  3. package/dist/index.js +6664 -9189
  4. package/package.json +4 -2
package/README.md CHANGED
@@ -125,6 +125,68 @@ for NAV accounts backed only by a current-price API. NAV cashflows have no
125
125
  `date` or `fundingNextDay` parameter: they execute immediately at the price the
126
126
  tracker fetches during submission.
127
127
 
128
+ ## Incentive campaigns
129
+
130
+ All six incentive instructions have exported `getTx` / `getIx` builders on
131
+ `client.tx`: `createIncentive`, `addIncentiveRecipient`, `setIncentiveLimits`,
132
+ `submitIncentive`, `cancelIncentiveProposal`, and `distributeIncentive`. Their
133
+ argument types are exported from `@perena/vault-sdk` alongside the builders.
134
+ Submission resolves the oracle PDA and any tranche accounts. Distribution resolves
135
+ registered recipients and creates their canonical share ATAs, including PDA wallet
136
+ owners, for both SPL Token and Token-2022.
137
+
138
+ ```typescript
139
+ import {
140
+ getIncentiveRecipients,
141
+ getIncentiveTotals,
142
+ getIncentiveRecipientShareAtas,
143
+ MAX_INCENTIVE_RECIPIENTS,
144
+ } from "@perena/vault-sdk";
145
+
146
+ const [incentive] = await client.pda.deriveIncentivePda(vault, 1n);
147
+ const data = await client.account.fetchIncentiveForVault(vault, 1n);
148
+ const recipients = getIncentiveRecipients(data); // registration order, bigint amounts
149
+ const totals = getIncentiveTotals(data); // settledShares, distributedShares, outstandingShares
150
+
151
+ // Discover IDs instead of maintaining an off-chain list.
152
+ const campaigns = await client.account.fetchAllIncentivesForVault(vault);
153
+ // Each result: { publicKey: Address, account: VaultIncentiveAccountData }.
154
+ const maybeCampaign = await client.account.fetchIncentiveNullable(incentive);
155
+ const batch = await client.account.fetchIncentives([incentive]);
156
+ // Batch preserves input order, duplicates, and nulls for missing accounts.
157
+
158
+ // Needed only for custom instruction composition; getTx derives these itself.
159
+ const recipientAtas = getIncentiveRecipientShareAtas(data, shareMint, shareTokenProgram);
160
+
161
+ // Prepare this payload once and share the SAME values with both oracle signers.
162
+ const proposal = {
163
+ vault,
164
+ incentive,
165
+ roundId: BigInt(data.roundId.toString()),
166
+ totals: recipients.map(recipient => recipient.settledTotal + 100n),
167
+ expiresAt: (await client.account.fetchClockUnixTimestamp()) + 600n,
168
+ maxSurplusValue: 0n,
169
+ };
170
+ const report = await client.tx.submitIncentive.getTx({ ...proposal, oracle });
171
+ // After both oracle reports agree and funding is reserved:
172
+ const payout = await client.tx.distributeIncentive.getTx({ cranker, vault, incentive });
173
+ ```
174
+
175
+ Incentive fetches always read fresh state. Raw decoded integers use Anchor `BN`;
176
+ the recipient and total helpers expose `bigint` without precision loss. Claims
177
+ are cumulative lifetime **atomic share amounts**: `settledTotal - distributedTotal`
178
+ is currently payable, and unfinished oracle reports are excluded. Up to
179
+ `MAX_INCENTIVE_RECIPIENTS` (five) wallets may be registered. `maxSurplusValue` and
180
+ `minSurplusReserve` use vault accounting units, rather than share units.
181
+
182
+ Use the live clock helper for deadlines; historical block timestamps can lag
183
+ execution time after validator time travel. Keep the round, expiry, surplus debit
184
+ limit and totals identical across the two oracle submissions. The program still
185
+ enforces authorization, campaign caps and available funding when agreement occurs.
186
+
187
+ For instruction semantics and the full accounting model, see
188
+ [`docs/incentives.md`](../../docs/incentives.md).
189
+
128
190
  ## Creating transactions
129
191
 
130
192
  ### The builder pattern
@@ -666,6 +728,12 @@ All builders are on `client.tx`:
666
728
  | Builder | Program instruction | Typical signer |
667
729
  | ------------------------------- | ----------------------------------------------------- | --------------------- |
668
730
  | `createVault` | `create_vault` | Curator |
731
+ | `createIncentive` | `create_incentive` | Curator |
732
+ | `addIncentiveRecipient` | `add_incentive_recipient` | Curator |
733
+ | `setIncentiveLimits` | `set_incentive_limits` | Curator |
734
+ | `submitIncentive` | `submit_incentive` | First two oracle slots |
735
+ | `cancelIncentiveProposal` | `cancel_incentive_proposal` | Curator, or anyone after expiry |
736
+ | `distributeIncentive` | `distribute_incentive` | Anyone |
669
737
  | `createAssetHolding` | `create_asset_holding` | HW manager |
670
738
  | `removeAssetHolding` | `remove_asset_holding` | HW manager |
671
739
  | `updateConsensusSigners` | `update_consensus_signers` | Curator |
@@ -692,7 +760,6 @@ All builders are on `client.tx`:
692
760
  | `updateAssetPrice` | `update_asset_price` | Oracle keeper |
693
761
  | `vaultReallocation` | `vault_reallocation` | HW manager |
694
762
  | `withdrawProtocolFees` | `withdraw_protocol_fees` | Curator |
695
- | `withdrawTrancheFees` | `withdraw_tranche_fees` | Curator |
696
763
 
697
764
  Argument shapes for each builder: [`src/client/builders/args.ts`](src/client/builders/args.ts).
698
765