@zebec-network/zebec-vault-sdk 1.1.0 → 2.0.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 +219 -219
- package/dist/artifacts/zebec_vault.d.ts +127 -2
- package/dist/artifacts/zebec_vault.json +305 -7
- package/dist/pda.d.ts +1 -0
- package/dist/pda.js +6 -1
- package/dist/service.d.ts +8 -15
- package/dist/service.js +30 -60
- package/package.json +3 -1
|
@@ -27,6 +27,35 @@
|
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"name": "vault",
|
|
30
|
+
"pda": {
|
|
31
|
+
"seeds": [
|
|
32
|
+
{
|
|
33
|
+
"kind": "const",
|
|
34
|
+
"value": [
|
|
35
|
+
122,
|
|
36
|
+
101,
|
|
37
|
+
98,
|
|
38
|
+
101,
|
|
39
|
+
99,
|
|
40
|
+
95,
|
|
41
|
+
117,
|
|
42
|
+
115,
|
|
43
|
+
101,
|
|
44
|
+
114,
|
|
45
|
+
95,
|
|
46
|
+
118,
|
|
47
|
+
97,
|
|
48
|
+
117,
|
|
49
|
+
108,
|
|
50
|
+
116
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"kind": "account",
|
|
55
|
+
"path": "proposer"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
30
59
|
"relations": [
|
|
31
60
|
"proposal"
|
|
32
61
|
]
|
|
@@ -70,7 +99,36 @@
|
|
|
70
99
|
"signer": true
|
|
71
100
|
},
|
|
72
101
|
{
|
|
73
|
-
"name": "vault"
|
|
102
|
+
"name": "vault",
|
|
103
|
+
"pda": {
|
|
104
|
+
"seeds": [
|
|
105
|
+
{
|
|
106
|
+
"kind": "const",
|
|
107
|
+
"value": [
|
|
108
|
+
122,
|
|
109
|
+
101,
|
|
110
|
+
98,
|
|
111
|
+
101,
|
|
112
|
+
99,
|
|
113
|
+
95,
|
|
114
|
+
117,
|
|
115
|
+
115,
|
|
116
|
+
101,
|
|
117
|
+
114,
|
|
118
|
+
95,
|
|
119
|
+
118,
|
|
120
|
+
97,
|
|
121
|
+
117,
|
|
122
|
+
108,
|
|
123
|
+
116
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"kind": "account",
|
|
128
|
+
"path": "proposer"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
74
132
|
},
|
|
75
133
|
{
|
|
76
134
|
"name": "proposal",
|
|
@@ -114,7 +172,35 @@
|
|
|
114
172
|
{
|
|
115
173
|
"name": "vault",
|
|
116
174
|
"writable": true,
|
|
117
|
-
"
|
|
175
|
+
"pda": {
|
|
176
|
+
"seeds": [
|
|
177
|
+
{
|
|
178
|
+
"kind": "const",
|
|
179
|
+
"value": [
|
|
180
|
+
122,
|
|
181
|
+
101,
|
|
182
|
+
98,
|
|
183
|
+
101,
|
|
184
|
+
99,
|
|
185
|
+
95,
|
|
186
|
+
117,
|
|
187
|
+
115,
|
|
188
|
+
101,
|
|
189
|
+
114,
|
|
190
|
+
95,
|
|
191
|
+
118,
|
|
192
|
+
97,
|
|
193
|
+
117,
|
|
194
|
+
108,
|
|
195
|
+
116
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"kind": "account",
|
|
200
|
+
"path": "payer"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
118
204
|
},
|
|
119
205
|
{
|
|
120
206
|
"name": "system_program",
|
|
@@ -151,6 +237,35 @@
|
|
|
151
237
|
},
|
|
152
238
|
{
|
|
153
239
|
"name": "vault",
|
|
240
|
+
"pda": {
|
|
241
|
+
"seeds": [
|
|
242
|
+
{
|
|
243
|
+
"kind": "const",
|
|
244
|
+
"value": [
|
|
245
|
+
122,
|
|
246
|
+
101,
|
|
247
|
+
98,
|
|
248
|
+
101,
|
|
249
|
+
99,
|
|
250
|
+
95,
|
|
251
|
+
117,
|
|
252
|
+
115,
|
|
253
|
+
101,
|
|
254
|
+
114,
|
|
255
|
+
95,
|
|
256
|
+
118,
|
|
257
|
+
97,
|
|
258
|
+
117,
|
|
259
|
+
108,
|
|
260
|
+
116
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"kind": "account",
|
|
265
|
+
"path": "proposer"
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
},
|
|
154
269
|
"relations": [
|
|
155
270
|
"proposal"
|
|
156
271
|
]
|
|
@@ -182,7 +297,36 @@
|
|
|
182
297
|
},
|
|
183
298
|
{
|
|
184
299
|
"name": "vault",
|
|
185
|
-
"writable": true
|
|
300
|
+
"writable": true,
|
|
301
|
+
"pda": {
|
|
302
|
+
"seeds": [
|
|
303
|
+
{
|
|
304
|
+
"kind": "const",
|
|
305
|
+
"value": [
|
|
306
|
+
122,
|
|
307
|
+
101,
|
|
308
|
+
98,
|
|
309
|
+
101,
|
|
310
|
+
99,
|
|
311
|
+
95,
|
|
312
|
+
117,
|
|
313
|
+
115,
|
|
314
|
+
101,
|
|
315
|
+
114,
|
|
316
|
+
95,
|
|
317
|
+
118,
|
|
318
|
+
97,
|
|
319
|
+
117,
|
|
320
|
+
108,
|
|
321
|
+
116
|
|
322
|
+
]
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"kind": "account",
|
|
326
|
+
"path": "depositor"
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
}
|
|
186
330
|
},
|
|
187
331
|
{
|
|
188
332
|
"name": "vault_signer",
|
|
@@ -254,7 +398,36 @@
|
|
|
254
398
|
"signer": true
|
|
255
399
|
},
|
|
256
400
|
{
|
|
257
|
-
"name": "vault"
|
|
401
|
+
"name": "vault",
|
|
402
|
+
"pda": {
|
|
403
|
+
"seeds": [
|
|
404
|
+
{
|
|
405
|
+
"kind": "const",
|
|
406
|
+
"value": [
|
|
407
|
+
122,
|
|
408
|
+
101,
|
|
409
|
+
98,
|
|
410
|
+
101,
|
|
411
|
+
99,
|
|
412
|
+
95,
|
|
413
|
+
117,
|
|
414
|
+
115,
|
|
415
|
+
101,
|
|
416
|
+
114,
|
|
417
|
+
95,
|
|
418
|
+
118,
|
|
419
|
+
97,
|
|
420
|
+
117,
|
|
421
|
+
108,
|
|
422
|
+
116
|
|
423
|
+
]
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"kind": "account",
|
|
427
|
+
"path": "depositor"
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
}
|
|
258
431
|
},
|
|
259
432
|
{
|
|
260
433
|
"name": "vault_signer",
|
|
@@ -520,6 +693,35 @@
|
|
|
520
693
|
},
|
|
521
694
|
{
|
|
522
695
|
"name": "vault",
|
|
696
|
+
"pda": {
|
|
697
|
+
"seeds": [
|
|
698
|
+
{
|
|
699
|
+
"kind": "const",
|
|
700
|
+
"value": [
|
|
701
|
+
122,
|
|
702
|
+
101,
|
|
703
|
+
98,
|
|
704
|
+
101,
|
|
705
|
+
99,
|
|
706
|
+
95,
|
|
707
|
+
117,
|
|
708
|
+
115,
|
|
709
|
+
101,
|
|
710
|
+
114,
|
|
711
|
+
95,
|
|
712
|
+
118,
|
|
713
|
+
97,
|
|
714
|
+
117,
|
|
715
|
+
108,
|
|
716
|
+
116
|
|
717
|
+
]
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"kind": "account",
|
|
721
|
+
"path": "caller"
|
|
722
|
+
}
|
|
723
|
+
]
|
|
724
|
+
},
|
|
523
725
|
"relations": [
|
|
524
726
|
"proposal"
|
|
525
727
|
]
|
|
@@ -580,7 +782,36 @@
|
|
|
580
782
|
"signer": true
|
|
581
783
|
},
|
|
582
784
|
{
|
|
583
|
-
"name": "vault"
|
|
785
|
+
"name": "vault",
|
|
786
|
+
"pda": {
|
|
787
|
+
"seeds": [
|
|
788
|
+
{
|
|
789
|
+
"kind": "const",
|
|
790
|
+
"value": [
|
|
791
|
+
122,
|
|
792
|
+
101,
|
|
793
|
+
98,
|
|
794
|
+
101,
|
|
795
|
+
99,
|
|
796
|
+
95,
|
|
797
|
+
117,
|
|
798
|
+
115,
|
|
799
|
+
101,
|
|
800
|
+
114,
|
|
801
|
+
95,
|
|
802
|
+
118,
|
|
803
|
+
97,
|
|
804
|
+
117,
|
|
805
|
+
108,
|
|
806
|
+
116
|
|
807
|
+
]
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
"kind": "account",
|
|
811
|
+
"path": "proposer"
|
|
812
|
+
}
|
|
813
|
+
]
|
|
814
|
+
}
|
|
584
815
|
},
|
|
585
816
|
{
|
|
586
817
|
"name": "vault_signer",
|
|
@@ -652,7 +883,35 @@
|
|
|
652
883
|
},
|
|
653
884
|
{
|
|
654
885
|
"name": "vault",
|
|
655
|
-
"
|
|
886
|
+
"pda": {
|
|
887
|
+
"seeds": [
|
|
888
|
+
{
|
|
889
|
+
"kind": "const",
|
|
890
|
+
"value": [
|
|
891
|
+
122,
|
|
892
|
+
101,
|
|
893
|
+
98,
|
|
894
|
+
101,
|
|
895
|
+
99,
|
|
896
|
+
95,
|
|
897
|
+
117,
|
|
898
|
+
115,
|
|
899
|
+
101,
|
|
900
|
+
114,
|
|
901
|
+
95,
|
|
902
|
+
118,
|
|
903
|
+
97,
|
|
904
|
+
117,
|
|
905
|
+
108,
|
|
906
|
+
116
|
|
907
|
+
]
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
"kind": "account",
|
|
911
|
+
"path": "withdrawer"
|
|
912
|
+
}
|
|
913
|
+
]
|
|
914
|
+
}
|
|
656
915
|
},
|
|
657
916
|
{
|
|
658
917
|
"name": "vault_signer",
|
|
@@ -724,7 +983,36 @@
|
|
|
724
983
|
"signer": true
|
|
725
984
|
},
|
|
726
985
|
{
|
|
727
|
-
"name": "vault"
|
|
986
|
+
"name": "vault",
|
|
987
|
+
"pda": {
|
|
988
|
+
"seeds": [
|
|
989
|
+
{
|
|
990
|
+
"kind": "const",
|
|
991
|
+
"value": [
|
|
992
|
+
122,
|
|
993
|
+
101,
|
|
994
|
+
98,
|
|
995
|
+
101,
|
|
996
|
+
99,
|
|
997
|
+
95,
|
|
998
|
+
117,
|
|
999
|
+
115,
|
|
1000
|
+
101,
|
|
1001
|
+
114,
|
|
1002
|
+
95,
|
|
1003
|
+
118,
|
|
1004
|
+
97,
|
|
1005
|
+
117,
|
|
1006
|
+
108,
|
|
1007
|
+
116
|
|
1008
|
+
]
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
"kind": "account",
|
|
1012
|
+
"path": "withdrawer"
|
|
1013
|
+
}
|
|
1014
|
+
]
|
|
1015
|
+
}
|
|
728
1016
|
},
|
|
729
1017
|
{
|
|
730
1018
|
"name": "vault_signer",
|
|
@@ -1797,6 +2085,16 @@
|
|
|
1797
2085
|
}
|
|
1798
2086
|
],
|
|
1799
2087
|
"constants": [
|
|
2088
|
+
{
|
|
2089
|
+
"name": "USER_VAULT_PREFIX",
|
|
2090
|
+
"type": {
|
|
2091
|
+
"array": [
|
|
2092
|
+
"u8",
|
|
2093
|
+
16
|
|
2094
|
+
]
|
|
2095
|
+
},
|
|
2096
|
+
"value": "[122, 101, 98, 101, 99, 95, 117, 115, 101, 114, 95, 118, 97, 117, 108, 116]"
|
|
2097
|
+
},
|
|
1800
2098
|
{
|
|
1801
2099
|
"name": "VAULT_SIGNER_PREFIX",
|
|
1802
2100
|
"type": {
|
package/dist/pda.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Address } from "@coral-xyz/anchor";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
export declare function deriveVaultSigner(vault: Address, programId: Address): [PublicKey, number];
|
|
4
|
+
export declare function deriveUserVault(user: Address, programId: Address): [PublicKey, number];
|
package/dist/pda.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deriveVaultSigner = deriveVaultSigner;
|
|
4
|
+
exports.deriveUserVault = deriveUserVault;
|
|
4
5
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
6
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
7
|
const SEEDS = {
|
|
8
|
+
USER_VAULT: [122, 101, 98, 101, 99, 95, 117, 115, 101, 114, 95, 118, 97, 117, 108, 116],
|
|
7
9
|
VAULT_SIGNER: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 115, 105, 103, 110, 101, 114],
|
|
8
|
-
WHITELIST: [122, 101, 98, 101, 99, 95, 118, 97, 117, 108, 116, 95, 119, 104, 105, 116, 101, 108, 105, 115, 116],
|
|
9
10
|
};
|
|
10
11
|
function deriveVaultSigner(vault, programId) {
|
|
11
12
|
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.VAULT_SIGNER), (0, anchor_1.translateAddress)(vault).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
12
13
|
return addressAndBump;
|
|
13
14
|
}
|
|
15
|
+
function deriveUserVault(user, programId) {
|
|
16
|
+
const addressAndBump = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.USER_VAULT), (0, anchor_1.translateAddress)(user).toBuffer()], (0, anchor_1.translateAddress)(programId));
|
|
17
|
+
return addressAndBump;
|
|
18
|
+
}
|
package/dist/service.d.ts
CHANGED
|
@@ -10,45 +10,39 @@ export declare class ZebecVaultService {
|
|
|
10
10
|
readonly network: RpcNetwork;
|
|
11
11
|
constructor(provider: Provider, program: Program<ZebecVaultIdlV1>, network: RpcNetwork);
|
|
12
12
|
static create(provider: Provider, network: RpcNetwork, program?: Program<ZebecVaultIdlV1>): Promise<ZebecVaultService>;
|
|
13
|
-
getCreateVaultInstruction(payer: PublicKey,
|
|
14
|
-
getDepositSolInstruction(depositor: PublicKey,
|
|
15
|
-
getWithdrawSolInstruction(withdrawer: PublicKey,
|
|
16
|
-
getDepositTokenInstruction(depositor: PublicKey,
|
|
17
|
-
getWithdrawTokenInstruction(withdrawer: PublicKey,
|
|
18
|
-
getCreateProposalInstruction(proposer: PublicKey,
|
|
13
|
+
getCreateVaultInstruction(payer: PublicKey, owner: PublicKey, signerBump: number): Promise<TransactionInstruction>;
|
|
14
|
+
getDepositSolInstruction(depositor: PublicKey, amount: BN): Promise<TransactionInstruction>;
|
|
15
|
+
getWithdrawSolInstruction(withdrawer: PublicKey, amount: BN): Promise<TransactionInstruction>;
|
|
16
|
+
getDepositTokenInstruction(depositor: PublicKey, tokenMint: PublicKey, amount: BN, decimals: number): Promise<TransactionInstruction>;
|
|
17
|
+
getWithdrawTokenInstruction(withdrawer: PublicKey, tokenMint: PublicKey, amount: BN, decimals: number): Promise<TransactionInstruction>;
|
|
18
|
+
getCreateProposalInstruction(proposer: PublicKey, proposal: PublicKey, name: string, actions: ProposalAction[], proposalAccountSize: number): Promise<TransactionInstruction>;
|
|
19
19
|
getAppendActionInstruction(proposer: PublicKey, proposal: PublicKey, actions: ProposalAction[], newProposalAccountSize: number): Promise<TransactionInstruction>;
|
|
20
20
|
getDeleteProposalInstruction(proposal: PublicKey): Promise<TransactionInstruction>;
|
|
21
21
|
getExecuteProposalInstruction(caller: PublicKey, proposal: PublicKey, remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
22
|
-
getExecuteProposalDirectInstruction(
|
|
22
|
+
getExecuteProposalDirectInstruction(proposer: PublicKey, actions: ProposalAction[], remainingAccounts: AccountMeta[]): Promise<TransactionInstruction>;
|
|
23
23
|
createVault(params: {
|
|
24
24
|
payer?: Address;
|
|
25
|
-
vaultKeypair?: Keypair;
|
|
26
25
|
}): Promise<TransactionPayload>;
|
|
27
26
|
depositSol(params: {
|
|
28
27
|
depositor?: Address;
|
|
29
|
-
vault: Address;
|
|
30
28
|
amount: Numeric;
|
|
31
29
|
}): Promise<TransactionPayload>;
|
|
32
30
|
withdrawSol(params: {
|
|
33
31
|
withdrawer?: Address;
|
|
34
|
-
vault: Address;
|
|
35
32
|
amount: Numeric;
|
|
36
33
|
}): Promise<TransactionPayload>;
|
|
37
34
|
depositToken(params: {
|
|
38
35
|
depositor?: Address;
|
|
39
|
-
vault: Address;
|
|
40
36
|
tokenMint: Address;
|
|
41
37
|
amount: Numeric;
|
|
42
38
|
}): Promise<TransactionPayload>;
|
|
43
39
|
withdrawToken(params: {
|
|
44
40
|
withdrawer?: Address;
|
|
45
|
-
vault: Address;
|
|
46
41
|
tokenMint: Address;
|
|
47
42
|
amount: Numeric;
|
|
48
43
|
}): Promise<TransactionPayload>;
|
|
49
44
|
createProposal(params: {
|
|
50
45
|
proposer?: Address;
|
|
51
|
-
vault: Address;
|
|
52
46
|
proposalKeypair?: Keypair;
|
|
53
47
|
name: string;
|
|
54
48
|
actions: TransactionInstruction[];
|
|
@@ -69,14 +63,13 @@ export declare class ZebecVaultService {
|
|
|
69
63
|
addressLookupTables?: Address[];
|
|
70
64
|
}): Promise<TransactionPayload>;
|
|
71
65
|
executeProposalDirect(params: {
|
|
72
|
-
vault: Address;
|
|
73
66
|
proposer?: Address;
|
|
74
67
|
actions: TransactionInstruction[];
|
|
75
68
|
partialSigners?: Signer[];
|
|
76
69
|
addressLookupTables?: Address[];
|
|
77
70
|
}): Promise<TransactionPayload>;
|
|
78
71
|
private _createTransactionPayload;
|
|
79
|
-
|
|
72
|
+
getVaultInfoOfUser(user?: Address): Promise<VaultInfo | null>;
|
|
80
73
|
getAllVaultsInfo(): Promise<VaultInfo[]>;
|
|
81
74
|
getProposalsInfoOfVault(vault: Address): Promise<ProposalInfo[]>;
|
|
82
75
|
get programId(): PublicKey;
|