@zebec-network/zebec-vault-sdk 5.0.3 → 5.0.4
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 +177 -192
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,23 +27,23 @@ yarn add @zebec-network/zebec-vault-sdk
|
|
|
27
27
|
### Setup
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
|
-
import { Connection, Keypair } from
|
|
31
|
-
import { createAnchorProvider, ZebecVaultService } from
|
|
30
|
+
import { Connection, Keypair } from "@solana/web3.js";
|
|
31
|
+
import { createAnchorProvider, ZebecVaultService } from "@zebec-network/zebec-vault-sdk";
|
|
32
32
|
|
|
33
33
|
// Create connection
|
|
34
|
-
const connection = new Connection(
|
|
34
|
+
const connection = new Connection("https://api.mainnet-beta.solana.com"); // use private dedicatd rpc for production
|
|
35
35
|
|
|
36
36
|
// Create wallet adapter
|
|
37
37
|
// for frontend application you can use wallet provided by the wallet provider
|
|
38
|
-
const wallet = useAnchorWallet();
|
|
38
|
+
const wallet = useAnchorWallet();
|
|
39
39
|
// for server side app you can use Wallet class provided by @coral-xyz/anchor
|
|
40
|
-
const wallet = new Wallet(keypair) // create keypair from secret key
|
|
40
|
+
const wallet = new Wallet(keypair); // create keypair from secret key
|
|
41
41
|
|
|
42
42
|
// Create provider
|
|
43
43
|
const provider = createAnchorProvider(connection, wallet);
|
|
44
44
|
|
|
45
45
|
// Initialize service
|
|
46
|
-
const vaultService = ZebecVaultService.create(provider,
|
|
46
|
+
const vaultService = ZebecVaultService.create(provider, "mainnet-beta");
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
## Core Features
|
|
@@ -54,19 +54,19 @@ const vaultService = ZebecVaultService.create(provider, 'mainnet-beta');
|
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
56
|
const payload = await vaultService.createVault({
|
|
57
|
-
|
|
57
|
+
payer: wallet.publicKey, // optional if using AnchorProvider
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
const signature = await payload.execute();
|
|
61
|
-
console.log(
|
|
61
|
+
console.log("Vault created:", signature);
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
#### Deposit SOL
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
const payload = await vaultService.depositSol({
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
depositor: wallet.publicKey,
|
|
69
|
+
amount: 1.5, // SOL amount
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
await payload.execute();
|
|
@@ -76,9 +76,9 @@ await payload.execute();
|
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
78
|
const payload = await vaultService.deposit({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
depositor: wallet.publicKey,
|
|
80
|
+
tokenMint: "TOKEN_MINT_ADDRESS",
|
|
81
|
+
amount: 100, // token amount
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
await payload.execute();
|
|
@@ -90,8 +90,8 @@ await payload.execute();
|
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
const payload = await vaultService.withdrawSol({
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
withdrawer: wallet.publicKey,
|
|
94
|
+
amount: 0.5,
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
await payload.execute();
|
|
@@ -100,13 +100,13 @@ await payload.execute();
|
|
|
100
100
|
#### Withdraw SPL Tokens
|
|
101
101
|
|
|
102
102
|
```typescript
|
|
103
|
-
const payload = await vaultService.withdraw({
|
|
103
|
+
const payload = await vaultService.withdraw({
|
|
104
104
|
withdrawer: wallet.publicKey,
|
|
105
|
-
tokenMint:
|
|
106
|
-
amount: 50
|
|
107
|
-
});
|
|
105
|
+
tokenMint: "TOKEN_MINT_ADDRESS",
|
|
106
|
+
amount: 50,
|
|
107
|
+
});
|
|
108
108
|
|
|
109
|
-
await payload.execute();
|
|
109
|
+
await payload.execute();
|
|
110
110
|
|
|
111
111
|
// Note: if WSOL is address in given in tokenMint, it will with withdraw WSOL and unwrap into withdrawer wallet.
|
|
112
112
|
```
|
|
@@ -116,19 +116,19 @@ await payload.execute();
|
|
|
116
116
|
#### Create a Proposal
|
|
117
117
|
|
|
118
118
|
```typescript
|
|
119
|
-
import { SystemProgram } from
|
|
119
|
+
import { SystemProgram } from "@solana/web3.js";
|
|
120
120
|
|
|
121
121
|
// Create custom instructions
|
|
122
122
|
const instruction = SystemProgram.transfer({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
fromPubkey: vaultSigner,
|
|
124
|
+
toPubkey: recipient,
|
|
125
|
+
lamports: 1000000,
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
const payload = await vaultService.createProposal({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
proposer: wallet.publicKey,
|
|
130
|
+
name: "Transfer SOL",
|
|
131
|
+
actions: [instruction],
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
await payload.execute();
|
|
@@ -138,9 +138,9 @@ await payload.execute();
|
|
|
138
138
|
|
|
139
139
|
```typescript
|
|
140
140
|
const payload = await vaultService.executeProposal({
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
caller: wallet.publicKey,
|
|
142
|
+
proposal: proposalAddress,
|
|
143
|
+
addressLookupTables: [lookupTableAddress], // optional
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
await payload.execute();
|
|
@@ -150,9 +150,9 @@ await payload.execute();
|
|
|
150
150
|
|
|
151
151
|
```typescript
|
|
152
152
|
const payload = await vaultService.executeProposalDirect({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
proposer: wallet.publicKey,
|
|
154
|
+
actions: [instruction1, instruction2],
|
|
155
|
+
addressLookupTables: [lookupTableAddress],
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
await payload.execute();
|
|
@@ -164,24 +164,24 @@ await payload.execute();
|
|
|
164
164
|
|
|
165
165
|
```typescript
|
|
166
166
|
const payload = await vaultService.createStreamFromVault({
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
167
|
+
vaultOwner: wallet.publicKey,
|
|
168
|
+
receiver: recipientAddress,
|
|
169
|
+
streamToken: tokenMintAddress,
|
|
170
|
+
amount: 1000, // total amount
|
|
171
|
+
duration: 2592000, // 30 days in seconds
|
|
172
|
+
startNow: true,
|
|
173
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
174
|
+
automaticWithdrawal: false,
|
|
175
|
+
cancelableByRecipient: true,
|
|
176
|
+
cancelableBySender: true,
|
|
177
|
+
isPausable: true,
|
|
178
|
+
transferableByRecipient: false,
|
|
179
|
+
transferableBySender: false,
|
|
180
|
+
canTopup: true,
|
|
181
|
+
rateUpdatable: false,
|
|
182
|
+
cliffPercentage: 0, // 0-100
|
|
183
|
+
autoWithdrawFrequency: 86400, // 1 day
|
|
184
|
+
streamName: "Monthly Payment",
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
await payload.execute();
|
|
@@ -191,23 +191,23 @@ await payload.execute();
|
|
|
191
191
|
|
|
192
192
|
```typescript
|
|
193
193
|
const payload = await vaultService.createMultipleStreamFromVault({
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
194
|
+
vaultOwner: wallet.publicKey,
|
|
195
|
+
streamInfo: [
|
|
196
|
+
{
|
|
197
|
+
receiver: recipient1,
|
|
198
|
+
streamToken: tokenMint,
|
|
199
|
+
amount: 500,
|
|
200
|
+
duration: 2592000,
|
|
201
|
+
// ... other stream parameters
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
receiver: recipient2,
|
|
205
|
+
streamToken: tokenMint,
|
|
206
|
+
amount: 1000,
|
|
207
|
+
duration: 2592000,
|
|
208
|
+
// ... other stream parameters
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
// Execute all streams in multiple transactions
|
|
@@ -218,8 +218,8 @@ await payload.executeAll();
|
|
|
218
218
|
|
|
219
219
|
```typescript
|
|
220
220
|
const payload = await vaultService.pauseResumeStream({
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
vaultOwner: wallet.publicKey,
|
|
222
|
+
streamMetadata: streamAddress,
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
await payload.execute();
|
|
@@ -229,8 +229,8 @@ await payload.execute();
|
|
|
229
229
|
|
|
230
230
|
```typescript
|
|
231
231
|
const payload = await vaultService.cancelStream({
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
vaultOwner: wallet.publicKey,
|
|
233
|
+
streamMetadata: streamAddress,
|
|
234
234
|
});
|
|
235
235
|
|
|
236
236
|
await payload.execute();
|
|
@@ -240,8 +240,8 @@ await payload.execute();
|
|
|
240
240
|
|
|
241
241
|
```typescript
|
|
242
242
|
const payload = await vaultService.withdrawStream({
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
vaultOwner: wallet.publicKey,
|
|
244
|
+
streamMetadata: streamAddress,
|
|
245
245
|
});
|
|
246
246
|
|
|
247
247
|
await payload.execute();
|
|
@@ -251,9 +251,9 @@ await payload.execute();
|
|
|
251
251
|
|
|
252
252
|
```typescript
|
|
253
253
|
const payload = await vaultService.changeStreamReceiver({
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
vaultOwner: wallet.publicKey,
|
|
255
|
+
streamMetadata: streamAddress,
|
|
256
|
+
newRecipient: newRecipientAddress,
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
await payload.execute();
|
|
@@ -264,15 +264,15 @@ await payload.execute();
|
|
|
264
264
|
```typescript
|
|
265
265
|
const streamInfo = await vaultService.getStreamMetadataInfo(streamAddress);
|
|
266
266
|
|
|
267
|
-
console.log(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
267
|
+
console.log("Stream details:", {
|
|
268
|
+
sender: streamInfo.parties.sender,
|
|
269
|
+
receiver: streamInfo.parties.receiver,
|
|
270
|
+
token: streamInfo.financials.streamToken,
|
|
271
|
+
deposited: streamInfo.financials.depositedAmount,
|
|
272
|
+
withdrawn: streamInfo.financials.withdrawnAmount,
|
|
273
|
+
startTime: new Date(streamInfo.schedule.startTime * 1000),
|
|
274
|
+
endTime: new Date(streamInfo.schedule.endTime * 1000),
|
|
275
|
+
isPaused: streamInfo.schedule.pausedTimestamp > 0,
|
|
276
276
|
});
|
|
277
277
|
```
|
|
278
278
|
|
|
@@ -282,11 +282,11 @@ console.log('Stream details:', {
|
|
|
282
282
|
|
|
283
283
|
```typescript
|
|
284
284
|
const payload = await vaultService.stake({
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
lockupName: "main-lockup",
|
|
286
|
+
vaultOwner: wallet.publicKey,
|
|
287
|
+
amount: 1000,
|
|
288
|
+
lockPeriod: 7776000, // 90 days in seconds
|
|
289
|
+
nonce: 0n,
|
|
290
290
|
});
|
|
291
291
|
|
|
292
292
|
await payload.execute();
|
|
@@ -296,9 +296,9 @@ await payload.execute();
|
|
|
296
296
|
|
|
297
297
|
```typescript
|
|
298
298
|
const payload = await vaultService.unstake({
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
lockupName: "main-lockup",
|
|
300
|
+
vaultOwner: wallet.publicKey,
|
|
301
|
+
nonce: 0n,
|
|
302
302
|
});
|
|
303
303
|
|
|
304
304
|
await payload.execute();
|
|
@@ -307,12 +307,9 @@ await payload.execute();
|
|
|
307
307
|
#### Get Stake Nonce Information
|
|
308
308
|
|
|
309
309
|
```typescript
|
|
310
|
-
const nonceInfo = await vaultService.getStakeUserNonceInfo(
|
|
311
|
-
'main-lockup',
|
|
312
|
-
wallet.publicKey
|
|
313
|
-
);
|
|
310
|
+
const nonceInfo = await vaultService.getStakeUserNonceInfo("main-lockup", wallet.publicKey);
|
|
314
311
|
|
|
315
|
-
console.log(
|
|
312
|
+
console.log("Current nonce:", nonceInfo?.nonce);
|
|
316
313
|
```
|
|
317
314
|
|
|
318
315
|
### 5. Virtual Cards
|
|
@@ -323,12 +320,12 @@ console.log('Current nonce:', nonceInfo?.nonce);
|
|
|
323
320
|
const nextIndex = await vaultService.getNextCardIndex();
|
|
324
321
|
|
|
325
322
|
const payload = await vaultService.createSilverCard({
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
323
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
324
|
+
nextCardIndex: nextIndex,
|
|
325
|
+
amount: 100, // USDC amount
|
|
326
|
+
usdcAddress: USDC_MINT_ADDRESS,
|
|
327
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
328
|
+
currency: "USD",
|
|
332
329
|
});
|
|
333
330
|
|
|
334
331
|
await payload.execute();
|
|
@@ -340,13 +337,13 @@ await payload.execute();
|
|
|
340
337
|
const nextIndex = await vaultService.getNextCardIndex();
|
|
341
338
|
|
|
342
339
|
const payload = await vaultService.loadCarbonCard({
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
340
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
341
|
+
nextCardIndex: nextIndex,
|
|
342
|
+
amount: 50,
|
|
343
|
+
usdcAddress: USDC_MINT_ADDRESS,
|
|
344
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
345
|
+
currency: "USD",
|
|
346
|
+
reloadCardId: "CARD_ID",
|
|
350
347
|
});
|
|
351
348
|
|
|
352
349
|
await payload.execute();
|
|
@@ -357,17 +354,17 @@ await payload.execute();
|
|
|
357
354
|
```typescript
|
|
358
355
|
// First, get a Jupiter quote
|
|
359
356
|
const quoteResponse = await fetch(
|
|
360
|
-
|
|
357
|
+
`https://quote-api.jup.ag/v6/quote?inputMint=${inputMint}&outputMint=${USDC}&amount=${amount}&slippageBps=50`,
|
|
361
358
|
);
|
|
362
359
|
const quoteInfo = await quoteResponse.json();
|
|
363
360
|
|
|
364
361
|
const payload = await vaultService.swapAndCreateSilverCard({
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
362
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
363
|
+
quoteInfo: quoteInfo,
|
|
364
|
+
nextCardCounter: nextIndex,
|
|
365
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
366
|
+
currency: "USD",
|
|
367
|
+
wrapAndUnwrapSol: true, // if swapping SOL
|
|
371
368
|
});
|
|
372
369
|
|
|
373
370
|
await payload.execute();
|
|
@@ -377,13 +374,13 @@ await payload.execute();
|
|
|
377
374
|
|
|
378
375
|
```typescript
|
|
379
376
|
const payload = await vaultService.swapAndLoadCarbonCard({
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
377
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
378
|
+
quoteInfo: quoteInfo,
|
|
379
|
+
nextCardCounter: nextIndex,
|
|
380
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
381
|
+
currency: "USD",
|
|
382
|
+
reloadCardId: "CARD_ID",
|
|
383
|
+
wrapAndUnwrapSol: true,
|
|
387
384
|
});
|
|
388
385
|
|
|
389
386
|
await payload.execute();
|
|
@@ -394,8 +391,8 @@ await payload.execute();
|
|
|
394
391
|
```typescript
|
|
395
392
|
const tokenFees = await vaultService.getCardCustomTokenFees();
|
|
396
393
|
|
|
397
|
-
tokenFees.forEach(fee => {
|
|
398
|
-
|
|
394
|
+
tokenFees.forEach((fee) => {
|
|
395
|
+
console.log(`Token: ${fee.tokenAddress}, Fee: ${fee.fee}%`);
|
|
399
396
|
});
|
|
400
397
|
```
|
|
401
398
|
|
|
@@ -408,9 +405,9 @@ tokenFees.forEach(fee => {
|
|
|
408
405
|
const vaultInfo = await vaultService.getVaultInfoOfUser(userAddress);
|
|
409
406
|
|
|
410
407
|
if (vaultInfo) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
408
|
+
console.log("Vault:", vaultInfo.vault.toString());
|
|
409
|
+
console.log("Owner:", vaultInfo.owner.toString());
|
|
410
|
+
console.log("Created:", new Date(vaultInfo.createdDate * 1000));
|
|
414
411
|
}
|
|
415
412
|
|
|
416
413
|
// Get all vaults
|
|
@@ -423,11 +420,11 @@ console.log(`Total vaults: ${allVaults.length}`);
|
|
|
423
420
|
```typescript
|
|
424
421
|
const proposals = await vaultService.getProposalsInfoOfVault(vaultAddress);
|
|
425
422
|
|
|
426
|
-
proposals.forEach(proposal => {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
423
|
+
proposals.forEach((proposal) => {
|
|
424
|
+
console.log("Proposal:", proposal.name);
|
|
425
|
+
console.log("Status:", proposal.proposalStage);
|
|
426
|
+
console.log("Actions:", proposal.actions.length);
|
|
427
|
+
console.log("Executed:", proposal.isExecuted);
|
|
431
428
|
});
|
|
432
429
|
```
|
|
433
430
|
|
|
@@ -436,14 +433,11 @@ proposals.forEach(proposal => {
|
|
|
436
433
|
For read-only operations without a wallet:
|
|
437
434
|
|
|
438
435
|
```typescript
|
|
439
|
-
import { createReadonlyProvider } from
|
|
436
|
+
import { createReadonlyProvider } from "@zebec-network/zebec-vault-sdk";
|
|
440
437
|
|
|
441
|
-
const readonlyProvider = createReadonlyProvider(
|
|
442
|
-
connection,
|
|
443
|
-
optionalWalletAddress
|
|
444
|
-
);
|
|
438
|
+
const readonlyProvider = createReadonlyProvider(connection, optionalWalletAddress);
|
|
445
439
|
|
|
446
|
-
const service = ZebecVaultService.create(readonlyProvider,
|
|
440
|
+
const service = ZebecVaultService.create(readonlyProvider, "mainnet-beta");
|
|
447
441
|
|
|
448
442
|
// Can only call query methods
|
|
449
443
|
const vaultInfo = await service.getVaultInfoOfUser(someAddress);
|
|
@@ -455,22 +449,22 @@ The SDK provides custom error types:
|
|
|
455
449
|
|
|
456
450
|
```typescript
|
|
457
451
|
import {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
} from
|
|
452
|
+
AmountOutOfRangeError,
|
|
453
|
+
DailyCardLimitReachedError,
|
|
454
|
+
NotEnoughBalanceError,
|
|
455
|
+
AssociatedTokenAccountDoesNotExistsError,
|
|
456
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
463
457
|
|
|
464
458
|
try {
|
|
465
|
-
|
|
459
|
+
await payload.execute();
|
|
466
460
|
} catch (error) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
461
|
+
if (error instanceof AmountOutOfRangeError) {
|
|
462
|
+
console.error("Amount must be between", error.minRange, "and", error.maxRange);
|
|
463
|
+
} else if (error instanceof DailyCardLimitReachedError) {
|
|
464
|
+
console.error("Daily limit:", error.dailyCardLimit);
|
|
465
|
+
} else if (error instanceof NotEnoughBalanceError) {
|
|
466
|
+
console.error("Insufficient balance");
|
|
467
|
+
}
|
|
474
468
|
}
|
|
475
469
|
```
|
|
476
470
|
|
|
@@ -480,34 +474,25 @@ try {
|
|
|
480
474
|
|
|
481
475
|
```typescript
|
|
482
476
|
import {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
} from
|
|
489
|
-
|
|
490
|
-
const [vaultAddress, vaultBump] = deriveUserVault(
|
|
491
|
-
userAddress,
|
|
492
|
-
vaultProgramId
|
|
493
|
-
);
|
|
477
|
+
deriveUserVault,
|
|
478
|
+
deriveVaultSigner,
|
|
479
|
+
deriveStreamConfigPda,
|
|
480
|
+
deriveCardConfigPda,
|
|
481
|
+
deriveLockupAddress,
|
|
482
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
494
483
|
|
|
495
|
-
const [
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
);
|
|
484
|
+
const [vaultAddress, vaultBump] = deriveUserVault(userAddress, vaultProgramId);
|
|
485
|
+
|
|
486
|
+
const [signerAddress, signerBump] = deriveVaultSigner(vaultAddress, vaultProgramId);
|
|
499
487
|
```
|
|
500
488
|
|
|
501
489
|
### Transaction Utilities
|
|
502
490
|
|
|
503
491
|
```typescript
|
|
504
|
-
import {
|
|
505
|
-
calculateProposalSize,
|
|
506
|
-
transactionInstructionToProposalAction
|
|
507
|
-
} from '@zebec-network/zebec-vault-sdk';
|
|
492
|
+
import { calculateProposalSize, transactionInstructionToProposalAction } from "@zebec-network/zebec-vault-sdk";
|
|
508
493
|
|
|
509
494
|
// Calculate proposal size
|
|
510
|
-
const size = calculateProposalSize(
|
|
495
|
+
const size = calculateProposalSize("proposal-name", actions);
|
|
511
496
|
|
|
512
497
|
// Convert instruction to proposal action
|
|
513
498
|
const action = transactionInstructionToProposalAction(instruction);
|
|
@@ -517,23 +502,23 @@ const action = transactionInstructionToProposalAction(instruction);
|
|
|
517
502
|
|
|
518
503
|
```typescript
|
|
519
504
|
// Mainnet
|
|
520
|
-
const mainnetService = ZebecVaultService.create(provider,
|
|
505
|
+
const mainnetService = ZebecVaultService.create(provider, "mainnet-beta");
|
|
521
506
|
|
|
522
507
|
// Devnet
|
|
523
|
-
const devnetService = ZebecVaultService.create(provider,
|
|
508
|
+
const devnetService = ZebecVaultService.create(provider, "devnet");
|
|
524
509
|
```
|
|
525
510
|
|
|
526
511
|
## Constants
|
|
527
512
|
|
|
528
513
|
```typescript
|
|
529
514
|
import {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
} from
|
|
515
|
+
ZEBEC_VAULT_PROGRAM_ID,
|
|
516
|
+
JUPITER_AGGREGATOR_PROGRAM_ID,
|
|
517
|
+
CARD_LOOKUP_TABLE_ADDRESS,
|
|
518
|
+
STAKE_LOOKUP_TABLE_ADDRESS,
|
|
519
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
535
520
|
|
|
536
|
-
console.log(
|
|
521
|
+
console.log("Vault Program:", ZEBEC_VAULT_PROGRAM_ID["mainnet-beta"]);
|
|
537
522
|
```
|
|
538
523
|
|
|
539
524
|
## Types
|
|
@@ -542,15 +527,15 @@ The SDK exports comprehensive TypeScript types:
|
|
|
542
527
|
|
|
543
528
|
```typescript
|
|
544
529
|
import type {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
} from
|
|
530
|
+
VaultInfo,
|
|
531
|
+
ProposalInfo,
|
|
532
|
+
ProposalAction,
|
|
533
|
+
CreateStreamFromVaultParams,
|
|
534
|
+
StreamMetadataInfo,
|
|
535
|
+
TokenFeeRecord,
|
|
536
|
+
QuoteInfo,
|
|
537
|
+
StakeUserNonceInfo,
|
|
538
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
554
539
|
```
|
|
555
540
|
|
|
556
541
|
## Best Practices
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zebec-network/zebec-vault-sdk",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "An SDK for zebec vault solana program",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@solana/web3.js": "^1.98.2",
|
|
42
42
|
"@types/bn.js": "^5.2.0",
|
|
43
43
|
"@zebec-network/core-utils": "^1.1.1",
|
|
44
|
-
"@zebec-network/solana-common": "^2.3.
|
|
44
|
+
"@zebec-network/solana-common": "^2.3.1",
|
|
45
45
|
"bignumber.js": "^9.3.1",
|
|
46
46
|
"buffer": "^6.0.3"
|
|
47
47
|
}
|