@perena/vault-sdk 1.0.40 → 1.0.41
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 +44 -10
- package/dist/index.d.ts +3556 -4216
- package/dist/index.js +3589 -4208
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,25 +127,33 @@ tracker fetches during submission.
|
|
|
127
127
|
|
|
128
128
|
## Incentive campaigns
|
|
129
129
|
|
|
130
|
-
All
|
|
130
|
+
All seven incentive instructions have exported `getTx` / `getIx` builders on
|
|
131
131
|
`client.tx`: `createIncentive`, `addIncentiveRecipient`, `setIncentiveLimits`,
|
|
132
|
-
`submitIncentive`, `cancelIncentiveProposal`,
|
|
132
|
+
`submitIncentive`, `cancelIncentiveProposal`, `distributeIncentive`, and
|
|
133
|
+
`claimIncentive`. Their
|
|
133
134
|
argument types are exported from `@perena/vault-sdk` alongside the builders.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
Creation and enrollment take `oracle`, authorized against either of the first two
|
|
136
|
+
active reporting slots; `getTx` derives the vault oracle PDA. Submission also resolves
|
|
137
|
+
any tranche accounts. Distribution resolves registered recipients, creates canonical
|
|
138
|
+
share ATAs for both token programs, and requires every paid recipient to co-sign.
|
|
137
139
|
|
|
138
140
|
```typescript
|
|
139
141
|
import {
|
|
140
142
|
getIncentiveRecipients,
|
|
143
|
+
getIncentiveReportRecipients,
|
|
141
144
|
getIncentiveTotals,
|
|
142
145
|
getIncentiveRecipientShareAtas,
|
|
143
146
|
MAX_INCENTIVE_RECIPIENTS,
|
|
144
147
|
} from "@perena/vault-sdk";
|
|
145
148
|
|
|
146
149
|
const [incentive] = await client.pda.deriveIncentivePda(vault, 1n);
|
|
150
|
+
const create = await client.tx.createIncentive.getTx({
|
|
151
|
+
oracle, vault, id: 1n, recipients: [recipient], maxTotalShares: 1_000_000n,
|
|
152
|
+
});
|
|
153
|
+
// Send with the oracle, then fetch the created account.
|
|
147
154
|
const data = await client.account.fetchIncentiveForVault(vault, 1n);
|
|
148
155
|
const recipients = getIncentiveRecipients(data); // registration order, bigint amounts
|
|
156
|
+
const reportRecipients = getIncentiveReportRecipients(data); // frozen prefix while pending
|
|
149
157
|
const totals = getIncentiveTotals(data); // settledShares, distributedShares, outstandingShares
|
|
150
158
|
|
|
151
159
|
// Discover IDs instead of maintaining an off-chain list.
|
|
@@ -163,15 +171,40 @@ const proposal = {
|
|
|
163
171
|
vault,
|
|
164
172
|
incentive,
|
|
165
173
|
roundId: BigInt(data.roundId.toString()),
|
|
166
|
-
totals:
|
|
174
|
+
totals: reportRecipients.map(recipient => recipient.settledTotal + 100n),
|
|
167
175
|
expiresAt: (await client.account.fetchClockUnixTimestamp()) + 600n,
|
|
168
176
|
maxSurplusValue: 0n,
|
|
169
177
|
};
|
|
170
178
|
const report = await client.tx.submitIncentive.getTx({ ...proposal, oracle });
|
|
171
|
-
// After both
|
|
179
|
+
// After both reports agree and funding is reserved, the user signs when ready:
|
|
180
|
+
const claim = await client.tx.claimIncentive.getTx({ recipient, vault, incentive });
|
|
181
|
+
// Optional batch: collect signatures from every funded recipient as well as the cranker.
|
|
172
182
|
const payout = await client.tx.distributeIncentive.getTx({ cranker, vault, incentive });
|
|
173
183
|
```
|
|
174
184
|
|
|
185
|
+
`claimIncentive` reads the signing recipient's existing batch entry and creates no
|
|
186
|
+
per-wallet program account. Reporting remains batched. Its payout updates the same
|
|
187
|
+
lifetime counter as `distributeIncentive`, so claims and batch cranks can interleave
|
|
188
|
+
without duplicate payment. The SDK creates only the claiming recipient's missing
|
|
189
|
+
ATA. Five append-only recipients share each 408-byte batch account. Oracle enrollment
|
|
190
|
+
preserves pending reports: new wallets join the following round. When pending,
|
|
191
|
+
`getIncentiveReportRecipients` excludes those new slots; when idle, it returns all
|
|
192
|
+
registered recipients. Persist and share the original payload for both signers.
|
|
193
|
+
|
|
194
|
+
`distributeIncentive.getTx` adds required signer metas for each outstanding recipient;
|
|
195
|
+
it does not collect signatures. Supply them when sending the transaction. A curator
|
|
196
|
+
or oracle signature cannot replace recipient consent. For custom composition,
|
|
197
|
+
`getIx` accepts optional `recipientSigners` (default: all `recipients`); append these
|
|
198
|
+
after the full ordered ATA list. The program rejects any nonzero payout without
|
|
199
|
+
that wallet's signature, including attempts with the old unsigned batch layout.
|
|
200
|
+
A PDA recipient must consent through a signed CPI from its owning program.
|
|
201
|
+
|
|
202
|
+
Creation/enrollment `getIx` calls now require `vaultOracle`; their signer argument is
|
|
203
|
+
`oracle`, not `curator`. Upgrade the SDK with the program. Existing funded accounts
|
|
204
|
+
remain valid: `proposalRecipientCount` uses former padding and the report helper
|
|
205
|
+
handles pending version-1 accounts. Curator cap/floor changes and cancellation
|
|
206
|
+
permissions are unchanged.
|
|
207
|
+
|
|
175
208
|
Incentive fetches always read fresh state. Raw decoded integers use Anchor `BN`;
|
|
176
209
|
the recipient and total helpers expose `bigint` without precision loss. Claims
|
|
177
210
|
are cumulative lifetime **atomic share amounts**: `settledTotal - distributedTotal`
|
|
@@ -728,12 +761,13 @@ All builders are on `client.tx`:
|
|
|
728
761
|
| Builder | Program instruction | Typical signer |
|
|
729
762
|
| ------------------------------- | ----------------------------------------------------- | --------------------- |
|
|
730
763
|
| `createVault` | `create_vault` | Curator |
|
|
731
|
-
| `
|
|
732
|
-
| `
|
|
764
|
+
| `claimIncentive` | `claim_incentive` | Recipient |
|
|
765
|
+
| `createIncentive` | `create_incentive` | Either reporting oracle |
|
|
766
|
+
| `addIncentiveRecipient` | `add_incentive_recipient` | Either reporting oracle |
|
|
733
767
|
| `setIncentiveLimits` | `set_incentive_limits` | Curator |
|
|
734
768
|
| `submitIncentive` | `submit_incentive` | First two oracle slots |
|
|
735
769
|
| `cancelIncentiveProposal` | `cancel_incentive_proposal` | Curator, or anyone after expiry |
|
|
736
|
-
| `distributeIncentive` | `distribute_incentive` |
|
|
770
|
+
| `distributeIncentive` | `distribute_incentive` | Cranker + every paid recipient |
|
|
737
771
|
| `createAssetHolding` | `create_asset_holding` | HW manager |
|
|
738
772
|
| `removeAssetHolding` | `remove_asset_holding` | HW manager |
|
|
739
773
|
| `updateConsensusSigners` | `update_consensus_signers` | Curator |
|