@zebec-network/zebec-vault-sdk 5.0.3 → 5.1.0
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 +607 -577
- package/dist/service.js +12 -4
- package/dist/types.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,577 +1,607 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **Vault Management**: Create and manage secure vaults with proposal-based execution
|
|
8
|
-
- **Token Operations**: Deposit and withdraw SOL and SPL tokens
|
|
9
|
-
- **Streaming Payments**: Create, manage, and cancel payment streams
|
|
10
|
-
- **Staking**: Stake tokens with customizable lock periods
|
|
11
|
-
- **Virtual Cards**: Create and load Zebec cards with automatic token swapping
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
// for
|
|
38
|
-
const wallet = useAnchorWallet();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
await
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
await
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
A Typescript SDK for interacting with Zebec Vault on Solana, enabling secure multi operations, token streaming, staking, and virtual card management.
|
|
4
|
+
|
|
5
|
+
# **Features**
|
|
6
|
+
|
|
7
|
+
- **Vault Management**: Create and manage secure vaults with proposal-based execution
|
|
8
|
+
- **Token Operations**: Deposit and withdraw SOL and SPL tokens
|
|
9
|
+
- **Streaming Payments**: Create, manage, and cancel payment streams
|
|
10
|
+
- **Staking**: Stake tokens with customizable lock periods
|
|
11
|
+
- **Virtual Cards**: Create and load Zebec cards with automatic token swapping
|
|
12
|
+
- **Jupiter Integration**: Built-in token swapping for card operations
|
|
13
|
+
|
|
14
|
+
# **Installation**
|
|
15
|
+
|
|
16
|
+
```jsx
|
|
17
|
+
npm install @zebec-network/zebec-vault-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
yarn add @zebec-network/zebec-vault-sdk
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
# **Quick Start**
|
|
25
|
+
|
|
26
|
+
## **Setup**
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Connection, Keypair } from "@solana/web3.js";
|
|
30
|
+
import { createAnchorProvider, ZebecVaultService } from "@zebec-network/zebec-vault-sdk";
|
|
31
|
+
|
|
32
|
+
// Create connection
|
|
33
|
+
const connection = new Connection("https://api.mainnet-beta.solana.com"); // use private dedicatd rpc for production
|
|
34
|
+
|
|
35
|
+
// Create wallet adapter
|
|
36
|
+
// for frontend application you can use wallet provided by the wallet provider
|
|
37
|
+
// for example:
|
|
38
|
+
const wallet = useAnchorWallet();
|
|
39
|
+
|
|
40
|
+
// for server side app you can use Wallet class provided by @coral-xyz/anchor
|
|
41
|
+
const wallet = new Wallet(keypair); // create keypair from secret key
|
|
42
|
+
|
|
43
|
+
// Create provider
|
|
44
|
+
const provider = createAnchorProvider(connection, wallet);
|
|
45
|
+
|
|
46
|
+
// Initialize service
|
|
47
|
+
const vaultService = ZebecVaultService.create(provider, "mainnet-beta");
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Core Features
|
|
51
|
+
|
|
52
|
+
### **Vault Operations**
|
|
53
|
+
|
|
54
|
+
Each user has a vault that is derived from the seed containing user’s wallet. Then a vault signer is derived from the vault taking it as a seed. The vault signer is responsible for holding SPL Tokens and Sol balances and signing the transaction during CPI executions.
|
|
55
|
+
|
|
56
|
+
**Create a vault**
|
|
57
|
+
|
|
58
|
+
```jsx
|
|
59
|
+
const payload = await vaultService.createVault({
|
|
60
|
+
payer: wallet.publicKey, // optional if using AnchorProvider
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const signature = await payload.execute();
|
|
64
|
+
console.log("Vault created:", signature);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Get Vault Information**
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
// Get specific user's vault
|
|
71
|
+
const vaultInfo = await vaultService.getVaultInfoOfUser(userAddress);
|
|
72
|
+
|
|
73
|
+
if (vaultInfo) {
|
|
74
|
+
console.log("Vault:", vaultInfo.vault.toString());
|
|
75
|
+
console.log("Owner:", vaultInfo.owner.toString());
|
|
76
|
+
console.log("Created:", new Date(vaultInfo.createdDate * 1000));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Get all vaults
|
|
80
|
+
const allVaults = await vaultService.getAllVaultsInfo();
|
|
81
|
+
console.log(`Total vaults: ${allVaults.length}`);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Deposit SOL**
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
const payload = await vaultService.depositSol({
|
|
88
|
+
depositor: wallet.publicKey,
|
|
89
|
+
amount: 1.5, // SOL amount
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Deposit SPL Tokens**
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
const payload = await vaultService.deposit({
|
|
97
|
+
depositor: wallet.publicKey,
|
|
98
|
+
tokenMint: "TOKEN_MINT_ADDRESS",
|
|
99
|
+
amount: 100, // token amount
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const signature = await payload.execute();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> ***Note: If WSOL address is given in tokenMint, it will wrap SOL to WSOL and deposit as spl token.***
|
|
106
|
+
>
|
|
107
|
+
|
|
108
|
+
**Withdraw SOL**
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const payload = await vaultService.withdrawSol({
|
|
112
|
+
withdrawer: wallet.publicKey,
|
|
113
|
+
amount: 0.5,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const signature = await payload.execute();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Withdraw SPL Tokens**
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
const payload = await vaultService.withdraw({
|
|
123
|
+
withdrawer: wallet.publicKey,
|
|
124
|
+
tokenMint: "TOKEN_MINT_ADDRESS",
|
|
125
|
+
amount: 50,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const signature = await payload.execute();
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> ***Note: If WSOL is address in given in tokenMint, it will with withdraw WSOL and unwrap into withdrawer wallet.***
|
|
132
|
+
>
|
|
133
|
+
|
|
134
|
+
### Proposal System
|
|
135
|
+
|
|
136
|
+
Proposal System includes methods like creating proposal, appending actions and executing proposal. A proposal is like a transaction in Solana but with extra fields like proposal stage, created date, expiry dates, execution status, name, etc. Each Proposal contains one or more Proposal Action which is similar to Transaction Instruction in Solana. While executing the proposal, the Proposal Actions get executed in order in which its resides inside a Proposal. You can delete the Proposal and claim SOLs used in creating the Proposal. Each Proposal belongs to a vault and only signer of that vault can execute the Proposal, delete or append any Proposal Actions in the Proposal.
|
|
137
|
+
|
|
138
|
+
**Create a Proposal**
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { SystemProgram, Keypair } from "@solana/web3.js";
|
|
142
|
+
import { parseSol } from "@zebec-network/solana-common";
|
|
143
|
+
|
|
144
|
+
const [vault] = deriveUserVault(wallet.publicKey, service.vaultV1ProgramId);
|
|
145
|
+
const [vaultSigner] = deriveVaultSigner(vault, service.vaultV1ProgramId);
|
|
146
|
+
const recipient = "<Recipient PublicKey>";
|
|
147
|
+
|
|
148
|
+
// Create custom instructions. For example:
|
|
149
|
+
const instruction = SystemProgram.transfer({
|
|
150
|
+
fromPubkey: vaultSigner,
|
|
151
|
+
toPubkey: recipient,
|
|
152
|
+
lamports: Number(parseSol(1)),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const proposalKeypair = Keypair.generate()
|
|
156
|
+
console.log("Proposal:", proposalKeypair.publicKey.toString());
|
|
157
|
+
|
|
158
|
+
const payload = await vaultService.createProposal({
|
|
159
|
+
proposer: wallet.publicKey,
|
|
160
|
+
name: "Transfer SOL",
|
|
161
|
+
actions: [instruction],
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const signature = await payload.execute();
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### **Get Proposals**
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
const proposals = await vaultService.getProposalsInfoOfVault(vaultAddress);
|
|
171
|
+
|
|
172
|
+
proposals.forEach((proposal) => {
|
|
173
|
+
console.log("Proposal:", proposal.name);
|
|
174
|
+
console.log("Status:", proposal.proposalStage);
|
|
175
|
+
console.log("Actions:", proposal.actions.length);
|
|
176
|
+
console.log("Executed:", proposal.isExecuted);
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Append Actions**
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import { SystemProgram } from "@solana/web3.js";
|
|
184
|
+
import { parseSol } from "@zebec-network/solana-common";
|
|
185
|
+
|
|
186
|
+
const proposal = "<Proposal PublicKey>";
|
|
187
|
+
|
|
188
|
+
const instruction = SystemProgram.transfer({
|
|
189
|
+
fromPubkey: vaultSigner,
|
|
190
|
+
toPubkey: wallet.publicKey,
|
|
191
|
+
lamports: Number(parseSol(0.01)),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const payload = await service.appendActions({
|
|
195
|
+
actions: actionsB,
|
|
196
|
+
proposal,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const signature = await payload.execute()
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Delete Proposal**
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
const proposal = "<Proposal PublicKey>";
|
|
206
|
+
const payload = await service.deleteProposal({ proposal });
|
|
207
|
+
const deleteProposalSignature = await payload.execute();
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Execute a Proposal**
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
const proposal = "<Proposal PublicKey>";
|
|
214
|
+
const lookupTableAddress = "<Lookup Table Address PublicKey>";
|
|
215
|
+
|
|
216
|
+
const payload = await vaultService.executeProposal({
|
|
217
|
+
caller: wallet.publicKey,
|
|
218
|
+
proposal,
|
|
219
|
+
addressLookupTables: [lookupTableAddress], // optional
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const signature = await payload.execute();
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Execute Proposal Directly (Single Transaction)**
|
|
226
|
+
Proposal Action can be directly executed without creating Proposal. However, it may cause transaction size limit while some size limit can be mitigated using address lookup table.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
const [vault] = deriveUserVault(wallet.publicKey, service.vaultV1ProgramId);
|
|
230
|
+
const [vaultSigner] = deriveVaultSigner(vault, service.vaultV1ProgramId);
|
|
231
|
+
const recipient = "<Recipient PublicKey>";
|
|
232
|
+
|
|
233
|
+
const instruction1 = SystemProgram.transfer({
|
|
234
|
+
fromPubkey: vaultSigner,
|
|
235
|
+
toPubkey: recipient,
|
|
236
|
+
lamports: Number(parseSol(1)),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const instruction2 = new TransactionInstruction({
|
|
240
|
+
keys: [],
|
|
241
|
+
programId: MEMO_PROGRAM_ID,
|
|
242
|
+
data: Buffer.from("Transfer 1 sol from vault signer to recipient", "utf8"),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const payload = await vaultService.executeProposalDirect({
|
|
246
|
+
proposer: wallet.publicKey,
|
|
247
|
+
actions: [instruction1, instruction2],
|
|
248
|
+
addressLookupTables: [lookupTableAddress],
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const signature = await payload.execute();
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### **Payment Streaming**
|
|
255
|
+
|
|
256
|
+
**Create a Stream**
|
|
257
|
+
|
|
258
|
+
```tsx
|
|
259
|
+
const payload = await vaultService.createStreamFromVault({
|
|
260
|
+
vaultOwner: wallet.publicKey,
|
|
261
|
+
receiver: recipientAddress,
|
|
262
|
+
streamToken: tokenMintAddress,
|
|
263
|
+
amount: 1000, // total amount
|
|
264
|
+
duration: 2592000, // 30 days in seconds
|
|
265
|
+
startNow: true,
|
|
266
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
267
|
+
automaticWithdrawal: false,
|
|
268
|
+
cancelableByRecipient: true,
|
|
269
|
+
cancelableBySender: true,
|
|
270
|
+
isPausable: true,
|
|
271
|
+
transferableByRecipient: false,
|
|
272
|
+
transferableBySender: false,
|
|
273
|
+
canTopup: true,
|
|
274
|
+
rateUpdatable: false,
|
|
275
|
+
cliffPercentage: 0, // 0-100
|
|
276
|
+
autoWithdrawFrequency: 86400, // 1 day
|
|
277
|
+
streamName: "Monthly Payment",
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const await payload.execute();
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Create Multiple Streams**
|
|
284
|
+
|
|
285
|
+
There is a difference in payload that is return for creating multiple stream. While other payload is an instance of `TransactionPayload` class, the payload returned for creating multiple stream is an instance of `MultiTransactionPayload`. After invoking execute method in payload, it returns `MultiTransactionPayloadExecuteReturn` type which is an Array of union of `PromiseSettledResult<*string*>` and an object consisting of transactions data and transactions. The `PromiseSettledResult<*string*>` contains signature string as a value if the execution is success otherwise it it contains reason for the failure.
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
export type MultiTransactionPayloadExecuteReturn = (PromiseSettledResult<string> & {
|
|
289
|
+
transactionData: {
|
|
290
|
+
readonly instructions: web3.TransactionInstruction[];
|
|
291
|
+
readonly feePayer: web3.PublicKey;
|
|
292
|
+
readonly signers?: web3.Signer[];
|
|
293
|
+
readonly addressLookupTableAccounts?: web3.AddressLookupTableAccount[];
|
|
294
|
+
};
|
|
295
|
+
transaction: web3.VersionedTransaction;
|
|
296
|
+
})[];
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
```tsx
|
|
300
|
+
const payload = await vaultService.createMultipleStreamFromVault({
|
|
301
|
+
vaultOwner: wallet.publicKey,
|
|
302
|
+
streamInfo: [
|
|
303
|
+
{
|
|
304
|
+
receiver: recipient1,
|
|
305
|
+
streamToken: tokenMint,
|
|
306
|
+
amount: 500,
|
|
307
|
+
duration: 2592000,
|
|
308
|
+
// ... other stream parameters
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
receiver: recipient2,
|
|
312
|
+
streamToken: tokenMint,
|
|
313
|
+
amount: 1000,
|
|
314
|
+
duration: 2592000,
|
|
315
|
+
// ... other stream parameters
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Execute all streams in multiple transactions
|
|
321
|
+
const result = await payload.execute();
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### **Pause/Resume a Stream**
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
const payload = await vaultService.pauseResumeStream({
|
|
328
|
+
vaultOwner: wallet.publicKey,
|
|
329
|
+
streamMetadata: streamAddress,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const signature = await payload.execute();
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### **Cancel a Stream**
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
const payload = await vaultService.cancelStream({
|
|
339
|
+
vaultOwner: wallet.publicKey,
|
|
340
|
+
streamMetadata: streamAddress,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
await payload.execute();
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### **Withdraw from Stream**
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
const payload = await vaultService.withdrawStream({
|
|
351
|
+
vaultOwner: wallet.publicKey,
|
|
352
|
+
streamMetadata: streamAddress,
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
await payload.execute();
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### **Change Stream Receiver**
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
const payload = await vaultService.changeStreamReceiver({
|
|
362
|
+
vaultOwner: wallet.publicKey,
|
|
363
|
+
streamMetadata: streamAddress,
|
|
364
|
+
newRecipient: newRecipientAddress,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
await payload.execute();
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### **Get Stream Information**
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
const streamInfo = await vaultService.getStreamMetadataInfo(streamAddress);
|
|
375
|
+
|
|
376
|
+
console.log("Stream details:", {
|
|
377
|
+
sender: streamInfo.parties.sender,
|
|
378
|
+
receiver: streamInfo.parties.receiver,
|
|
379
|
+
token: streamInfo.financials.streamToken,
|
|
380
|
+
deposited: streamInfo.financials.depositedAmount,
|
|
381
|
+
withdrawn: streamInfo.financials.withdrawnAmount,
|
|
382
|
+
startTime: new Date(streamInfo.schedule.startTime * 1000),
|
|
383
|
+
endTime: new Date(streamInfo.schedule.endTime * 1000),
|
|
384
|
+
isPaused: streamInfo.schedule.pausedTimestamp > 0,
|
|
385
|
+
});
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Staking
|
|
389
|
+
|
|
390
|
+
**Stake Tokens**
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
const payload = await vaultService.stake({
|
|
394
|
+
lockupName: "main-lockup",
|
|
395
|
+
vaultOwner: wallet.publicKey,
|
|
396
|
+
amount: 1000,
|
|
397
|
+
lockPeriod: 7776000, // 90 days in seconds
|
|
398
|
+
nonce: 0n,
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
await payload.execute();
|
|
402
|
+
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
**Unstake Tokens**
|
|
406
|
+
|
|
407
|
+
```tsx
|
|
408
|
+
const payload = await vaultService.unstake({
|
|
409
|
+
lockupName: "main-lockup",
|
|
410
|
+
vaultOwner: wallet.publicKey,
|
|
411
|
+
nonce: 0n,
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
await payload.execute();
|
|
415
|
+
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
**Get Stake Nonce Information**
|
|
419
|
+
|
|
420
|
+
```tsx
|
|
421
|
+
const nonceInfo = await vaultService.getStakeUserNonceInfo("main-lockup", wallet.publicKey);
|
|
422
|
+
|
|
423
|
+
console.log("Current nonce:", nonceInfo ? nonceInfo.nonce : 0n);
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Zebec Cards
|
|
427
|
+
|
|
428
|
+
**Create a Silver Card**
|
|
429
|
+
|
|
430
|
+
```tsx
|
|
431
|
+
const nextIndex = await vaultService.getNextCardIndex();
|
|
432
|
+
|
|
433
|
+
const payload = await vaultService.createSilverCard({
|
|
434
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
435
|
+
nextCardIndex: nextIndex,
|
|
436
|
+
amount: 100, // USDC amount
|
|
437
|
+
usdcAddress: USDC_MINT_ADDRESS,
|
|
438
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
439
|
+
currency: "USD",
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
await payload.execute();
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**Load a Carbon Card**
|
|
447
|
+
|
|
448
|
+
```tsx
|
|
449
|
+
const nextIndex = await vaultService.getNextCardIndex();
|
|
450
|
+
|
|
451
|
+
const payload = await vaultService.loadCarbonCard({
|
|
452
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
453
|
+
nextCardIndex: nextIndex,
|
|
454
|
+
amount: 50,
|
|
455
|
+
usdcAddress: USDC_MINT_ADDRESS,
|
|
456
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
457
|
+
currency: "USD",
|
|
458
|
+
reloadCardId: "CARD_ID",
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
await payload.execute();
|
|
462
|
+
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
**Swap and Create Silver Card**
|
|
466
|
+
|
|
467
|
+
```tsx
|
|
468
|
+
// First, get a Jupiter quote
|
|
469
|
+
const quoteResponse = await fetch(
|
|
470
|
+
`https://quote-api.jup.ag/v6/quote?inputMint=${inputMint}&outputMint=${USDC}&amount=${amount}&slippageBps=50`,
|
|
471
|
+
);
|
|
472
|
+
const quoteInfo = await quoteResponse.json();
|
|
473
|
+
|
|
474
|
+
const payload = await vaultService.swapAndCreateSilverCard({
|
|
475
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
476
|
+
quoteInfo: quoteInfo,
|
|
477
|
+
nextCardCounter: nextIndex,
|
|
478
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
479
|
+
currency: "USD",
|
|
480
|
+
wrapAndUnwrapSol: true, // if swapping SOL
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
await payload.execute();
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
**Swap and Load Carbon Card**
|
|
488
|
+
|
|
489
|
+
```tsx
|
|
490
|
+
const payload = await vaultService.swapAndLoadCarbonCard({
|
|
491
|
+
vaultOwnerAddress: wallet.publicKey,
|
|
492
|
+
quoteInfo: quoteInfo,
|
|
493
|
+
nextCardCounter: nextIndex,
|
|
494
|
+
emailHash: Buffer.from("your-32-byte-hash"),
|
|
495
|
+
currency: "USD",
|
|
496
|
+
reloadCardId: "CARD_ID",
|
|
497
|
+
wrapAndUnwrapSol: true,
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
await payload.execute();
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Get Card Custom Token Fees**
|
|
504
|
+
|
|
505
|
+
```tsx
|
|
506
|
+
const tokenFees = await vaultService.getCardCustomTokenFees();
|
|
507
|
+
|
|
508
|
+
tokenFees.forEach((fee) => {
|
|
509
|
+
console.log(`Token: ${fee.tokenAddress}, Fee: ${fee.fee}%`);
|
|
510
|
+
});
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### **Read-only Provider**
|
|
514
|
+
|
|
515
|
+
For read-only operations without a wallet:
|
|
516
|
+
|
|
517
|
+
```tsx
|
|
518
|
+
import { createReadonlyProvider } from "@zebec-network/zebec-vault-sdk";
|
|
519
|
+
|
|
520
|
+
const readonlyProvider = createReadonlyProvider(connection, optionalWalletAddress);
|
|
521
|
+
|
|
522
|
+
const service = ZebecVaultService.create(readonlyProvider, "mainnet-beta");
|
|
523
|
+
|
|
524
|
+
// Can only call query methods
|
|
525
|
+
const vaultInfo = await service.getVaultInfoOfUser(someAddress);
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### **Advanced Features**
|
|
529
|
+
|
|
530
|
+
**Program Derived Addresses (PDAs)**
|
|
531
|
+
|
|
532
|
+
```tsx
|
|
533
|
+
import {
|
|
534
|
+
deriveUserVault,
|
|
535
|
+
deriveVaultSigner,
|
|
536
|
+
deriveStreamConfigPda,
|
|
537
|
+
deriveCardConfigPda,
|
|
538
|
+
deriveLockupAddress,
|
|
539
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
540
|
+
|
|
541
|
+
const [vaultAddress, vaultBump] = deriveUserVault(userAddress, vaultProgramId);
|
|
542
|
+
|
|
543
|
+
const [signerAddress, signerBump] = deriveVaultSigner(vaultAddress, vaultProgramId);
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
**Transaction Utilities**
|
|
547
|
+
|
|
548
|
+
```tsx
|
|
549
|
+
import { calculateProposalSize, transactionInstructionToProposalAction } from "@zebec-network/zebec-vault-sdk";
|
|
550
|
+
|
|
551
|
+
// Calculate proposal size
|
|
552
|
+
const size = calculateProposalSize("proposal-name", actions);
|
|
553
|
+
|
|
554
|
+
// Convert instruction to proposal action
|
|
555
|
+
const action = transactionInstructionToProposalAction(instruction);
|
|
556
|
+
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
**Network Configuration**
|
|
560
|
+
|
|
561
|
+
```tsx
|
|
562
|
+
// Mainnet
|
|
563
|
+
const mainnetService = ZebecVaultService.create(provider, "mainnet-beta");
|
|
564
|
+
|
|
565
|
+
// Devnet
|
|
566
|
+
const devnetService = ZebecVaultService.create(provider, "devnet");
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### **Constants**
|
|
570
|
+
|
|
571
|
+
```tsx
|
|
572
|
+
import {
|
|
573
|
+
ZEBEC_VAULT_PROGRAM_ID,
|
|
574
|
+
JUPITER_AGGREGATOR_PROGRAM_ID,
|
|
575
|
+
CARD_LOOKUP_TABLE_ADDRESS,
|
|
576
|
+
STAKE_LOOKUP_TABLE_ADDRESS,
|
|
577
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
578
|
+
|
|
579
|
+
console.log("Vault Program:", ZEBEC_VAULT_PROGRAM_ID["mainnet-beta"]);
|
|
580
|
+
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### **Types**
|
|
584
|
+
|
|
585
|
+
The SDK exports comprehensive TypeScript types:
|
|
586
|
+
|
|
587
|
+
```tsx
|
|
588
|
+
import type {
|
|
589
|
+
VaultInfo,
|
|
590
|
+
ProposalInfo,
|
|
591
|
+
ProposalAction,
|
|
592
|
+
CreateStreamFromVaultParams,
|
|
593
|
+
StreamMetadataInfo,
|
|
594
|
+
TokenFeeRecord,
|
|
595
|
+
QuoteInfo,
|
|
596
|
+
StakeUserNonceInfo,
|
|
597
|
+
} from "@zebec-network/zebec-vault-sdk";
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
## **Best Practices**
|
|
601
|
+
|
|
602
|
+
1. **Always check balances** before operations
|
|
603
|
+
2. **Use proposals** for critical operations that require multiple instructions and cannot be executed in a single transaction.
|
|
604
|
+
3. **Handle errors** appropriately with the provided error types
|
|
605
|
+
4. **Verify stream parameters** before creation (duration, amounts, permissions)
|
|
606
|
+
5. **Test on `devnet`** before deploying to `mainnet`
|
|
607
|
+
6. **Use address lookup tables** for complex transactions to reduce size
|
package/dist/service.js
CHANGED
|
@@ -1006,17 +1006,21 @@ class ZebecVaultService {
|
|
|
1006
1006
|
const STREAM_NAME_BUFFER_SIZE = 128;
|
|
1007
1007
|
const streamNameArray = new Uint8Array(STREAM_NAME_BUFFER_SIZE);
|
|
1008
1008
|
streamNameArray.set(anchor_1.utils.bytes.utf8.encode(params.streamName));
|
|
1009
|
+
const autoWithdrawFrequency = params.autoWithdrawFrequency ?? 0;
|
|
1010
|
+
if (params.automaticWithdrawal && autoWithdrawFrequency <= 0) {
|
|
1011
|
+
throw new Error("autoWithdrawFrequency must be greater than 0 when automaticWithdrawal is enabled");
|
|
1012
|
+
}
|
|
1009
1013
|
const ix = await this.getCreateStreamFromVaultInstruction(vaultOwner, vault, vaultSigner, vaultSignerAta, receiverVaultSigner, receiverVaultSignerAta, streamToken, streamMetadata, streamConfig, withdrawAccount, streamVault, streamVaultAta, this.streamProgramId, {
|
|
1010
1014
|
amount,
|
|
1011
1015
|
automaticWithdrawal: params.automaticWithdrawal,
|
|
1012
|
-
autoWithdrawFrequency: new anchor_1.BN(
|
|
1016
|
+
autoWithdrawFrequency: new anchor_1.BN(autoWithdrawFrequency),
|
|
1013
1017
|
cancelableByRecipient: params.cancelableByRecipient,
|
|
1014
1018
|
cancelableBySender: params.cancelableBySender,
|
|
1015
1019
|
canTopup: params.canTopup,
|
|
1016
1020
|
cliffPercentage,
|
|
1017
1021
|
duration: new anchor_1.BN(params.duration),
|
|
1018
1022
|
isPausable: params.isPausable,
|
|
1019
|
-
numberOfWithdrawls: new anchor_1.BN(Math.floor(params.duration /
|
|
1023
|
+
numberOfWithdrawls: autoWithdrawFrequency > 0 ? new anchor_1.BN(Math.floor(params.duration / autoWithdrawFrequency)) : new anchor_1.BN(0),
|
|
1020
1024
|
rateUpdatable: params.rateUpdatable,
|
|
1021
1025
|
startNow: params.startNow,
|
|
1022
1026
|
startTime: new anchor_1.BN(params.startTime),
|
|
@@ -1050,17 +1054,21 @@ class ZebecVaultService {
|
|
|
1050
1054
|
const STREAM_NAME_BUFFER_SIZE = 128;
|
|
1051
1055
|
const streamNameArray = new Uint8Array(STREAM_NAME_BUFFER_SIZE);
|
|
1052
1056
|
streamNameArray.set(anchor_1.utils.bytes.utf8.encode(info.streamName));
|
|
1057
|
+
const autoWithdrawFrequency = info.autoWithdrawFrequency ?? 0;
|
|
1058
|
+
if (info.automaticWithdrawal && autoWithdrawFrequency <= 0) {
|
|
1059
|
+
throw new Error("autoWithdrawFrequency must be greater than 0 when automaticWithdrawal is enabled");
|
|
1060
|
+
}
|
|
1053
1061
|
const ix = await this.getCreateStreamFromVaultInstruction(vaultOwner, vault, vaultSigner, vaultSignerAta, receiverVaultSigner, receiverVaultSignerAta, streamToken, streamMetadata, streamConfig, withdrawAccount, streamVault, streamVaultAta, this.streamProgramId, {
|
|
1054
1062
|
amount,
|
|
1055
1063
|
automaticWithdrawal: info.automaticWithdrawal,
|
|
1056
|
-
autoWithdrawFrequency: new anchor_1.BN(
|
|
1064
|
+
autoWithdrawFrequency: new anchor_1.BN(autoWithdrawFrequency),
|
|
1057
1065
|
cancelableByRecipient: info.cancelableByRecipient,
|
|
1058
1066
|
cancelableBySender: info.cancelableBySender,
|
|
1059
1067
|
canTopup: info.canTopup,
|
|
1060
1068
|
cliffPercentage,
|
|
1061
1069
|
duration: new anchor_1.BN(info.duration),
|
|
1062
1070
|
isPausable: info.isPausable,
|
|
1063
|
-
numberOfWithdrawls: new anchor_1.BN(Math.floor(info.duration /
|
|
1071
|
+
numberOfWithdrawls: autoWithdrawFrequency > 0 ? new anchor_1.BN(Math.floor(info.duration / autoWithdrawFrequency)) : new anchor_1.BN(0),
|
|
1064
1072
|
rateUpdatable: info.rateUpdatable,
|
|
1065
1073
|
startNow: info.startNow,
|
|
1066
1074
|
startTime: new anchor_1.BN(info.startTime),
|
package/dist/types.d.ts
CHANGED
|
@@ -172,7 +172,7 @@ export type CreateStreamFromVaultParams = {
|
|
|
172
172
|
isPausable: boolean;
|
|
173
173
|
startNow: boolean;
|
|
174
174
|
startTime: number;
|
|
175
|
-
autoWithdrawFrequency
|
|
175
|
+
autoWithdrawFrequency?: number;
|
|
176
176
|
streamName: string;
|
|
177
177
|
transferableByRecipient: boolean;
|
|
178
178
|
transferableBySender: boolean;
|
|
@@ -194,7 +194,7 @@ export type createMultipleStreamFromVaultParams = {
|
|
|
194
194
|
isPausable: boolean;
|
|
195
195
|
startNow: boolean;
|
|
196
196
|
startTime: number;
|
|
197
|
-
autoWithdrawFrequency
|
|
197
|
+
autoWithdrawFrequency?: number;
|
|
198
198
|
streamName: string;
|
|
199
199
|
transferableByRecipient: boolean;
|
|
200
200
|
transferableBySender: boolean;
|
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.1.0",
|
|
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
|
}
|