@drift-labs/vaults-sdk 0.1.423 → 0.1.424
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/lib/accounts/vaultAccount.d.ts +1 -6
- package/lib/accounts/vaultAccount.js +0 -116
- package/lib/addresses.d.ts +0 -1
- package/lib/addresses.js +0 -7
- package/lib/math/vaultDepositor.d.ts +2 -11
- package/lib/math/vaultDepositor.js +2 -20
- package/lib/types/drift_vaults.d.ts +24 -450
- package/lib/types/drift_vaults.js +24 -450
- package/lib/types/types.d.ts +1 -66
- package/lib/vaultClient.d.ts +5 -53
- package/lib/vaultClient.js +42 -407
- package/package.json +1 -1
- package/src/accounts/vaultAccount.ts +3 -164
- package/src/addresses.ts +0 -13
- package/src/idl/drift_vaults.json +24 -453
- package/src/math/vaultDepositor.ts +4 -36
- package/src/types/drift_vaults.ts +55 -907
- package/src/types/types.ts +1 -79
- package/src/vaultClient.ts +42 -540
package/lib/types/types.d.ts
CHANGED
|
@@ -19,36 +19,6 @@ export type WithdrawRequest = {
|
|
|
19
19
|
value: BN;
|
|
20
20
|
ts: BN;
|
|
21
21
|
};
|
|
22
|
-
export type VaultParams = {
|
|
23
|
-
name: number[];
|
|
24
|
-
spotMarketIndex: number;
|
|
25
|
-
redeemPeriod: BN;
|
|
26
|
-
maxTokens: BN;
|
|
27
|
-
minDepositAmount: BN;
|
|
28
|
-
managementFee: BN;
|
|
29
|
-
profitShare: number;
|
|
30
|
-
hurdleRate: number;
|
|
31
|
-
permissioned: boolean;
|
|
32
|
-
vaultProtocol: VaultProtocolParams | null;
|
|
33
|
-
};
|
|
34
|
-
export type VaultProtocolParams = {
|
|
35
|
-
protocol: PublicKey;
|
|
36
|
-
protocolFee: BN;
|
|
37
|
-
protocolProfitShare: number;
|
|
38
|
-
};
|
|
39
|
-
export type UpdateVaultParams = {
|
|
40
|
-
redeemPeriod: BN | null;
|
|
41
|
-
maxTokens: BN | null;
|
|
42
|
-
minDepositAmount: BN | null;
|
|
43
|
-
managementFee: BN | null;
|
|
44
|
-
profitShare: number | null;
|
|
45
|
-
hurdleRate: number | null;
|
|
46
|
-
permissioned: boolean | null;
|
|
47
|
-
};
|
|
48
|
-
export type UpdateVaultProtocolParams = {
|
|
49
|
-
protocolFee: BN | null;
|
|
50
|
-
protocolProfitShare: number | null;
|
|
51
|
-
};
|
|
52
22
|
export type Vault = {
|
|
53
23
|
name: number[];
|
|
54
24
|
pubkey: PublicKey;
|
|
@@ -83,7 +53,6 @@ export type Vault = {
|
|
|
83
53
|
bump: number;
|
|
84
54
|
permissioned: boolean;
|
|
85
55
|
lastManagerWithdrawRequest: WithdrawRequest;
|
|
86
|
-
vaultProtocol: PublicKey;
|
|
87
56
|
};
|
|
88
57
|
export type VaultDepositor = {
|
|
89
58
|
vault: PublicKey;
|
|
@@ -98,20 +67,7 @@ export type VaultDepositor = {
|
|
|
98
67
|
cumulativeProfitShareAmount: BN;
|
|
99
68
|
vaultSharesBase: number;
|
|
100
69
|
profitShareFeePaid: BN;
|
|
101
|
-
|
|
102
|
-
padding: BN[];
|
|
103
|
-
};
|
|
104
|
-
export type VaultProtocol = {
|
|
105
|
-
protocol: PublicKey;
|
|
106
|
-
protocolProfitAndFeeShares: BN;
|
|
107
|
-
protocolFee: BN;
|
|
108
|
-
protocolTotalWithdraws: BN;
|
|
109
|
-
protocolTotalFee: BN;
|
|
110
|
-
protocolTotalProfitShare: BN;
|
|
111
|
-
lastProtocolWithdrawRequest: WithdrawRequest;
|
|
112
|
-
protocolProfitShare: number;
|
|
113
|
-
bump: number;
|
|
114
|
-
version: number;
|
|
70
|
+
padding: number[];
|
|
115
71
|
};
|
|
116
72
|
export type VaultsProgramAccountBaseEvents = {
|
|
117
73
|
update: void;
|
|
@@ -169,27 +125,6 @@ export type VaultDepositorRecord = {
|
|
|
169
125
|
managementFee: BN;
|
|
170
126
|
managementFeeShares: BN;
|
|
171
127
|
};
|
|
172
|
-
export type VaultDepositorV1Record = {
|
|
173
|
-
ts: BN;
|
|
174
|
-
vault: PublicKey;
|
|
175
|
-
depositorAuthority: PublicKey;
|
|
176
|
-
action: VaultDepositorAction;
|
|
177
|
-
amount: BN;
|
|
178
|
-
spotMarketIndex: number;
|
|
179
|
-
vaultSharesBefore: BN;
|
|
180
|
-
vaultSharesAfter: BN;
|
|
181
|
-
vaultEquityBefore: BN;
|
|
182
|
-
userVaultSharesBefore: BN;
|
|
183
|
-
totalVaultSharesBefore: BN;
|
|
184
|
-
userVaultSharesAfter: BN;
|
|
185
|
-
totalVaultSharesAfter: BN;
|
|
186
|
-
protocolProfitShare: BN;
|
|
187
|
-
protocolFee: BN;
|
|
188
|
-
protocolFeeShares: BN;
|
|
189
|
-
managerProfitShare: BN;
|
|
190
|
-
managementFee: BN;
|
|
191
|
-
managementFeeShares: BN;
|
|
192
|
-
};
|
|
193
128
|
export type VaultsEventMap = {
|
|
194
129
|
VaultDepositorRecord: Event<VaultDepositorRecord>;
|
|
195
130
|
};
|
package/lib/vaultClient.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { BN, DriftClient, UserMap } from '@drift-labs/sdk';
|
|
|
2
2
|
import { Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
3
3
|
import { DriftVaults } from './types/drift_vaults';
|
|
4
4
|
import { CompetitionsClient } from '@drift-labs/competitions-sdk';
|
|
5
|
-
import {
|
|
6
|
-
import { Vault, VaultDepositor,
|
|
5
|
+
import { AddressLookupTableAccount, PublicKey, TransactionInstruction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
|
|
6
|
+
import { Vault, VaultDepositor, WithdrawUnit } from './types/types';
|
|
7
7
|
import { UserMapConfig } from '@drift-labs/sdk/lib/userMap/userMapConfig';
|
|
8
8
|
export type TxParams = {
|
|
9
9
|
cuLimit?: number;
|
|
@@ -25,10 +25,6 @@ export declare class VaultClient {
|
|
|
25
25
|
cliMode?: boolean;
|
|
26
26
|
userMapConfig?: UserMapConfig;
|
|
27
27
|
});
|
|
28
|
-
/**
|
|
29
|
-
* Unsubscribes from the vault users map. Call this to clean up any dangling promises.
|
|
30
|
-
*/
|
|
31
|
-
unsubscribe(): Promise<void>;
|
|
32
28
|
getVault(vault: PublicKey): Promise<Vault>;
|
|
33
29
|
getVaultAndSlot(vault: PublicKey): Promise<{
|
|
34
30
|
vault: Vault;
|
|
@@ -39,55 +35,26 @@ export declare class VaultClient {
|
|
|
39
35
|
vaultDepositor: any;
|
|
40
36
|
slot: number;
|
|
41
37
|
}>;
|
|
42
|
-
getVaultProtocolAddress(vault: PublicKey): PublicKey;
|
|
43
|
-
getVaultProtocol(vaultProtocol: PublicKey): Promise<VaultProtocol>;
|
|
44
|
-
getVaultProtocolAndSlot(vaultProtocol: PublicKey): Promise<{
|
|
45
|
-
vaultProtocol: VaultProtocol;
|
|
46
|
-
slot: number;
|
|
47
|
-
}>;
|
|
48
38
|
getAllVaultDepositorsWithNoWithdrawRequest(vault: PublicKey): Promise<ProgramAccount<VaultDepositor>[]>;
|
|
49
39
|
getAllVaultDepositors(vault: PublicKey): Promise<ProgramAccount<VaultDepositor>[]>;
|
|
50
40
|
getSubscribedVaultUser(vaultDriftUserAccountPubKey: PublicKey): Promise<import("@drift-labs/sdk").User>;
|
|
51
41
|
/**
|
|
52
42
|
*
|
|
53
43
|
* @param vault pubkey
|
|
54
|
-
* @param factorUnrealizedPNL add unrealized pnl to net balance
|
|
55
44
|
* @returns vault equity, in USDC
|
|
56
45
|
*/
|
|
57
46
|
calculateVaultEquity(params: {
|
|
58
47
|
address?: PublicKey;
|
|
59
48
|
vault?: Vault;
|
|
60
|
-
factorUnrealizedPNL?: boolean;
|
|
61
49
|
}): Promise<BN>;
|
|
62
50
|
/**
|
|
63
51
|
*
|
|
64
52
|
* @param vault pubkey
|
|
65
|
-
* @
|
|
66
|
-
* @returns total vault equity, in spot deposit asset
|
|
53
|
+
* @returns vault equity, in spot deposit asset
|
|
67
54
|
*/
|
|
68
55
|
calculateVaultEquityInDepositAsset(params: {
|
|
69
56
|
address?: PublicKey;
|
|
70
57
|
vault?: Vault;
|
|
71
|
-
factorUnrealizedPNL?: boolean;
|
|
72
|
-
}): Promise<BN>;
|
|
73
|
-
/**
|
|
74
|
-
* @param params
|
|
75
|
-
* @returns vault depositor equity, in spot market value (which is usually USDC)
|
|
76
|
-
*/
|
|
77
|
-
calculateWithdrawableVaultDepositorEquity(params: {
|
|
78
|
-
vaultDepositorAddress?: PublicKey;
|
|
79
|
-
vaultDepositor?: VaultDepositor;
|
|
80
|
-
vaultAddress?: PublicKey;
|
|
81
|
-
vault?: Vault;
|
|
82
|
-
}): Promise<BN>;
|
|
83
|
-
calculateWithdrawableVaultDepositorEquityInDepositAsset(params: {
|
|
84
|
-
vaultDepositorAddress?: PublicKey;
|
|
85
|
-
vaultDepositor?: VaultDepositor;
|
|
86
|
-
vaultAddress?: PublicKey;
|
|
87
|
-
vault?: Vault;
|
|
88
|
-
}): Promise<BN>;
|
|
89
|
-
calculateVaultProtocolEquity(params: {
|
|
90
|
-
vault: PublicKey;
|
|
91
58
|
}): Promise<BN>;
|
|
92
59
|
initializeVault(params: {
|
|
93
60
|
name: number[];
|
|
@@ -99,7 +66,6 @@ export declare class VaultClient {
|
|
|
99
66
|
profitShare: number;
|
|
100
67
|
hurdleRate: number;
|
|
101
68
|
permissioned: boolean;
|
|
102
|
-
vaultProtocol?: VaultProtocolParams;
|
|
103
69
|
}): Promise<TransactionSignature>;
|
|
104
70
|
/**
|
|
105
71
|
* Updates the delegate address for a vault. The delegate address will be allowed to trade
|
|
@@ -112,7 +78,7 @@ export declare class VaultClient {
|
|
|
112
78
|
/**
|
|
113
79
|
* Updates the vault margin trading status.
|
|
114
80
|
* @param vault vault address to update
|
|
115
|
-
* @param
|
|
81
|
+
* @param enabeld whether to enable margin trading
|
|
116
82
|
* @returns
|
|
117
83
|
*/
|
|
118
84
|
updateMarginTradingEnabled(vault: PublicKey, enabled: boolean): Promise<TransactionSignature>;
|
|
@@ -186,7 +152,6 @@ export declare class VaultClient {
|
|
|
186
152
|
spotMarketIndex: number;
|
|
187
153
|
bump: number;
|
|
188
154
|
permissioned: boolean;
|
|
189
|
-
vaultProtocol: PublicKey;
|
|
190
155
|
padding: BN[];
|
|
191
156
|
};
|
|
192
157
|
accounts: {
|
|
@@ -201,17 +166,8 @@ export declare class VaultClient {
|
|
|
201
166
|
driftProgram: PublicKey;
|
|
202
167
|
tokenProgram: PublicKey;
|
|
203
168
|
};
|
|
204
|
-
remainingAccounts: AccountMeta[];
|
|
169
|
+
remainingAccounts: import("@solana/web3.js").AccountMeta[];
|
|
205
170
|
}>;
|
|
206
|
-
/**
|
|
207
|
-
* Creates a transaction to deposit funds into the specified vault.
|
|
208
|
-
* Uses the associated token account of the vault depositor authority and spot market mint,
|
|
209
|
-
* and assumes it exists before calling this function.
|
|
210
|
-
* @param vaultDepositor
|
|
211
|
-
* @param amount
|
|
212
|
-
* @param initVaultDepositor If true, will initialize the vault depositor account
|
|
213
|
-
* @returns transaction
|
|
214
|
-
*/
|
|
215
171
|
createDepositTx(vaultDepositor: PublicKey, amount: BN, initVaultDepositor?: {
|
|
216
172
|
authority: PublicKey;
|
|
217
173
|
vault: PublicKey;
|
|
@@ -221,7 +177,6 @@ export declare class VaultClient {
|
|
|
221
177
|
* @param vaultDepositor
|
|
222
178
|
* @param amount
|
|
223
179
|
* @param initVaultDepositor If true, will initialize the vault depositor account
|
|
224
|
-
* @param txParams
|
|
225
180
|
* @returns
|
|
226
181
|
*/
|
|
227
182
|
deposit(vaultDepositor: PublicKey, amount: BN, initVaultDepositor?: {
|
|
@@ -259,7 +214,4 @@ export declare class VaultClient {
|
|
|
259
214
|
* @returns
|
|
260
215
|
*/
|
|
261
216
|
initializeCompetitor(vault: PublicKey, competitionsClient: CompetitionsClient, competitionName: string): Promise<TransactionSignature>;
|
|
262
|
-
protocolRequestWithdraw(vault: PublicKey, amount: BN, withdrawUnit: WithdrawUnit): Promise<TransactionSignature>;
|
|
263
|
-
protocolCancelWithdrawRequest(vault: PublicKey): Promise<TransactionSignature>;
|
|
264
|
-
protocolWithdraw(vault: PublicKey): Promise<TransactionSignature>;
|
|
265
217
|
}
|