@perena/vault-sdk 1.0.44 → 1.0.46
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/dist/browser/nest.d.mts +208 -0
- package/dist/browser/nest.mjs +757 -0
- package/dist/index.d.ts +816 -16
- package/dist/index.js +1185 -110
- package/package.json +4 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Connection, PublicKey, Transaction, SimulatedTransactionResponse, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
|
|
2
|
+
import { Instruction, Address } from '@solana/kit';
|
|
3
|
+
|
|
4
|
+
interface NestApiOptions {
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
fetchFn?: typeof fetch;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
interface NestRedemptionQuote {
|
|
10
|
+
nestVaultSlug: string;
|
|
11
|
+
redemptionAsset: "USDC";
|
|
12
|
+
shareAmount: string;
|
|
13
|
+
shareDecimals: number;
|
|
14
|
+
redemptionAmount: string;
|
|
15
|
+
redemptionDecimals: number;
|
|
16
|
+
feeAmount: string;
|
|
17
|
+
}
|
|
18
|
+
interface NestRedemptionStep {
|
|
19
|
+
status: string;
|
|
20
|
+
statusCode?: number;
|
|
21
|
+
signature?: string;
|
|
22
|
+
amount?: string;
|
|
23
|
+
usdcClaimed?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
interface NestRedemptionStatus {
|
|
27
|
+
solanaBurnSignature: string;
|
|
28
|
+
solanaWallet: string;
|
|
29
|
+
overallStatus: string;
|
|
30
|
+
progress?: string;
|
|
31
|
+
steps: {
|
|
32
|
+
solanaBurn: NestRedemptionStep;
|
|
33
|
+
plumeProcessing: NestRedemptionStep;
|
|
34
|
+
cctpAttestation: NestRedemptionStep;
|
|
35
|
+
solanaClaim: NestRedemptionStep;
|
|
36
|
+
};
|
|
37
|
+
error?: {
|
|
38
|
+
code?: string;
|
|
39
|
+
message?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
declare class NestApiError extends Error {
|
|
43
|
+
readonly status: number;
|
|
44
|
+
constructor(status: number, message: string);
|
|
45
|
+
}
|
|
46
|
+
/** Indicative quote only: the settlement price and fees may change in the queue. */
|
|
47
|
+
declare function fetchNestRedemptionQuote(args: {
|
|
48
|
+
nestVaultSlug: string;
|
|
49
|
+
rawAmountNestToken: bigint;
|
|
50
|
+
}, options?: NestApiOptions): Promise<NestRedemptionQuote>;
|
|
51
|
+
/** Use the Squads EXECUTION signature, not the proposal-creation signature. */
|
|
52
|
+
declare function fetchNestRedemptionStatus(signature: string, options?: NestApiOptions): Promise<NestRedemptionStatus | null>;
|
|
53
|
+
|
|
54
|
+
interface TransactionPlan {
|
|
55
|
+
instructions: Instruction[];
|
|
56
|
+
lookupTables?: Address[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface VaultCacheInvalidation {
|
|
60
|
+
vaultPda: Address;
|
|
61
|
+
vaultOraclePda?: Address;
|
|
62
|
+
vaultTrancheStatePda?: Address;
|
|
63
|
+
withdrawalQueuePda?: Address;
|
|
64
|
+
}
|
|
65
|
+
interface VaultTransactionPlan extends TransactionPlan {
|
|
66
|
+
instructions: Instruction[];
|
|
67
|
+
postSuccessCacheInvalidations?: VaultCacheInvalidation[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Build a standard nPERENA withdrawal from its current owner's ATA. The owner
|
|
72
|
+
* must already hold the shares; move program-held shares to the manager first.
|
|
73
|
+
* The returned plan can be proposed in Squads with the owner set to its vault PDA.
|
|
74
|
+
*
|
|
75
|
+
* Nest keepers settle the cross-chain withdrawal asynchronously and return USDC
|
|
76
|
+
* to the same owner. There is no user-signed Nest fulfillment transaction in the
|
|
77
|
+
* documented API. This plan deliberately does not append a premature redeposit.
|
|
78
|
+
*/
|
|
79
|
+
declare function buildNestWithdrawalRequest(args: {
|
|
80
|
+
connection: Connection;
|
|
81
|
+
owner: PublicKey;
|
|
82
|
+
rawAmountNestToken: bigint;
|
|
83
|
+
apiOptions?: NestApiOptions;
|
|
84
|
+
}): Promise<VaultTransactionPlan>;
|
|
85
|
+
/** Resolve ALTs before decompiling; reject additional signers Squads cannot supply. */
|
|
86
|
+
declare function decodeNestWithdrawalRequest(args: {
|
|
87
|
+
connection: Connection;
|
|
88
|
+
owner: PublicKey;
|
|
89
|
+
rawAmountNestToken: bigint;
|
|
90
|
+
txBase64: string;
|
|
91
|
+
}): Promise<VaultTransactionPlan>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* {@link PriceSource} adapter over the `nest` package's price API, bound to the
|
|
95
|
+
* Perena vault's Nest slug and share mint.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
declare const NEST_VAULT_SLUG = "nest-perena-vault";
|
|
99
|
+
declare const NEST_RWA_SHARE_MINT: Address;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Maps a transaction-proposing wallet to the Squads vault it operates.
|
|
103
|
+
*
|
|
104
|
+
* The member wallet pays for and signs proposal creation. The derived Squads
|
|
105
|
+
* vault PDA is the authority that signs the instructions when the proposal is
|
|
106
|
+
* eventually executed.
|
|
107
|
+
*/
|
|
108
|
+
interface SquadsWalletRouteConfig {
|
|
109
|
+
wallet: string;
|
|
110
|
+
multisigPda: string;
|
|
111
|
+
vaultIndex: number;
|
|
112
|
+
memo?: string;
|
|
113
|
+
}
|
|
114
|
+
interface ResolvedSquadsWalletRoute {
|
|
115
|
+
wallet: PublicKey;
|
|
116
|
+
multisigPda: PublicKey;
|
|
117
|
+
vaultIndex: number;
|
|
118
|
+
vaultPda: PublicKey;
|
|
119
|
+
memo?: string;
|
|
120
|
+
}
|
|
121
|
+
interface PreparedDirectTransaction {
|
|
122
|
+
kind: "direct";
|
|
123
|
+
transaction: Transaction;
|
|
124
|
+
authority: PublicKey;
|
|
125
|
+
}
|
|
126
|
+
interface PreparedSquadsTransaction {
|
|
127
|
+
kind: "squads";
|
|
128
|
+
transaction: Transaction;
|
|
129
|
+
authority: PublicKey;
|
|
130
|
+
multisigPda: PublicKey;
|
|
131
|
+
vaultIndex: number;
|
|
132
|
+
transactionIndex: bigint;
|
|
133
|
+
proposalPda: PublicKey;
|
|
134
|
+
vaultTransactionPda: PublicKey;
|
|
135
|
+
}
|
|
136
|
+
type PreparedVaultTransaction = PreparedDirectTransaction | PreparedSquadsTransaction;
|
|
137
|
+
type SquadsSimulationTransactionError = NonNullable<SimulatedTransactionResponse["err"]>;
|
|
138
|
+
declare class SquadsProposalExecutionSimulationError extends Error {
|
|
139
|
+
readonly transactionError: SquadsSimulationTransactionError;
|
|
140
|
+
readonly logs: string[];
|
|
141
|
+
readonly unitsConsumed?: number;
|
|
142
|
+
constructor(transactionError: SquadsSimulationTransactionError, logs: readonly string[], unitsConsumed?: number);
|
|
143
|
+
}
|
|
144
|
+
/** Resolve and validate a configured wallet route, including its vault PDA. */
|
|
145
|
+
declare function resolveSquadsWalletRoute(route: SquadsWalletRouteConfig): ResolvedSquadsWalletRoute;
|
|
146
|
+
/** Find the optional Squads route for a connected proposer wallet. */
|
|
147
|
+
declare function findSquadsWalletRoute(wallet: PublicKey | string, routes: readonly SquadsWalletRouteConfig[]): ResolvedSquadsWalletRoute | undefined;
|
|
148
|
+
/** Fail fast on ambiguous wallet mappings or malformed route values. */
|
|
149
|
+
declare function validateSquadsWalletRoutes(routes: readonly SquadsWalletRouteConfig[]): void;
|
|
150
|
+
/**
|
|
151
|
+
* Return the authority that should be used while building vault instructions.
|
|
152
|
+
* For a configured member wallet this is the Squads vault PDA; otherwise it is
|
|
153
|
+
* the wallet itself.
|
|
154
|
+
*/
|
|
155
|
+
declare function vaultAuthorityForWallet(wallet: PublicKey | string, routes: readonly SquadsWalletRouteConfig[]): PublicKey;
|
|
156
|
+
/**
|
|
157
|
+
* Simulate the instructions stored in a Squads proposal before creating it.
|
|
158
|
+
*
|
|
159
|
+
* Signature verification is intentionally disabled so the runtime treats the
|
|
160
|
+
* Squads vault PDA's signer account meta as signed, matching the privileges it
|
|
161
|
+
* receives from Squads' eventual `invoke_signed` execution. This validates the
|
|
162
|
+
* inner instructions against current chain state; it does not validate Squads
|
|
163
|
+
* approvals or the execution wrapper itself.
|
|
164
|
+
*
|
|
165
|
+
* Throws {@link SquadsProposalExecutionSimulationError} when the simulated
|
|
166
|
+
* instructions fail.
|
|
167
|
+
*/
|
|
168
|
+
declare function simulateSquadsProposalExecution(args: {
|
|
169
|
+
connection: Connection;
|
|
170
|
+
feePayer: PublicKey;
|
|
171
|
+
instructions: readonly TransactionInstruction[];
|
|
172
|
+
recentBlockhash?: string;
|
|
173
|
+
addressLookupTableAccounts?: AddressLookupTableAccount[];
|
|
174
|
+
}): Promise<SimulatedTransactionResponse>;
|
|
175
|
+
/**
|
|
176
|
+
* Build either a normal transaction or a Squads proposal-creation transaction,
|
|
177
|
+
* based on whether `proposer` has a configured wallet route.
|
|
178
|
+
*
|
|
179
|
+
* The returned Squads transaction creates both the vault transaction and its
|
|
180
|
+
* proposal. It does not approve or execute the proposal.
|
|
181
|
+
*/
|
|
182
|
+
declare function prepareVaultTransaction(args: {
|
|
183
|
+
connection: Connection;
|
|
184
|
+
proposer: PublicKey;
|
|
185
|
+
instructions: readonly TransactionInstruction[];
|
|
186
|
+
squadsRoutes?: readonly SquadsWalletRouteConfig[];
|
|
187
|
+
/** Skip execution simulation when proposing a transaction that depends on future funding. */
|
|
188
|
+
skipSimulation?: boolean;
|
|
189
|
+
addressLookupTableAccounts?: AddressLookupTableAccount[];
|
|
190
|
+
}): Promise<PreparedVaultTransaction>;
|
|
191
|
+
|
|
192
|
+
interface SquadsProposalUpload {
|
|
193
|
+
/** Send these sequentially, waiting for confirmation after each. */
|
|
194
|
+
setupTransactions: Transaction[];
|
|
195
|
+
/** Creates the proposal only after the entire message is stored. */
|
|
196
|
+
proposalTransaction: Transaction;
|
|
197
|
+
bufferPda?: PublicKey;
|
|
198
|
+
/** Explicit recovery if upload is interrupted. Never submit this automatically. */
|
|
199
|
+
closeBufferInstruction?: TransactionInstruction;
|
|
200
|
+
}
|
|
201
|
+
/** Large cross-chain messages need Squads' buffer upload even when execution uses ALTs. */
|
|
202
|
+
declare function prepareSquadsProposalUpload(args: {
|
|
203
|
+
connection: Connection;
|
|
204
|
+
proposer: PublicKey;
|
|
205
|
+
prepared: PreparedSquadsTransaction;
|
|
206
|
+
}): Promise<SquadsProposalUpload>;
|
|
207
|
+
|
|
208
|
+
export { NEST_RWA_SHARE_MINT, NEST_VAULT_SLUG, NestApiError, type NestApiOptions, type NestRedemptionQuote, type NestRedemptionStatus, type PreparedDirectTransaction, type PreparedSquadsTransaction, type PreparedVaultTransaction, type ResolvedSquadsWalletRoute, SquadsProposalExecutionSimulationError, type SquadsProposalUpload, type SquadsWalletRouteConfig, buildNestWithdrawalRequest, decodeNestWithdrawalRequest, fetchNestRedemptionQuote, fetchNestRedemptionStatus, findSquadsWalletRoute, prepareSquadsProposalUpload, prepareVaultTransaction, resolveSquadsWalletRoute, simulateSquadsProposalExecution, validateSquadsWalletRoutes, vaultAuthorityForWallet };
|