@drift-labs/vaults-sdk 0.5.19 → 0.5.21
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/cli/cli.ts +33 -0
- package/cli/commands/index.ts +1 -0
- package/cli/commands/initVault.ts +44 -19
- package/cli/commands/managerApplyProfitShare.ts +32 -0
- package/cli/commands/managerCancelWithdraw.ts +8 -3
- package/cli/commands/managerDeposit.ts +8 -3
- package/cli/commands/managerRequestWithdraw.ts +17 -5
- package/cli/commands/managerUpdateMarginTradingEnabled.ts +9 -4
- package/cli/commands/managerUpdatePoolId.ts +36 -0
- package/cli/commands/managerUpdateVault.ts +9 -4
- package/cli/commands/managerUpdateVaultDelegate.ts +9 -3
- package/cli/commands/managerUpdateVaultManager.ts +77 -0
- package/cli/commands/managerWithdraw.ts +8 -3
- package/cli/utils.ts +14 -1
- package/lib/types/drift_vaults.d.ts +21 -0
- package/lib/types/drift_vaults.js +21 -0
- package/lib/vaultClient.d.ts +68 -8
- package/lib/vaultClient.js +189 -94
- package/package.json +2 -2
- package/src/idl/drift_vaults.json +21 -0
- package/src/types/drift_vaults.ts +42 -0
- package/src/vaultClient.ts +373 -115
package/lib/vaultClient.d.ts
CHANGED
|
@@ -114,7 +114,21 @@ export declare class VaultClient {
|
|
|
114
114
|
hurdleRate: number;
|
|
115
115
|
permissioned: boolean;
|
|
116
116
|
vaultProtocol?: VaultProtocolParams;
|
|
117
|
+
manager?: PublicKey;
|
|
117
118
|
}, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
119
|
+
getInitializeVaultIx(params: {
|
|
120
|
+
name: number[];
|
|
121
|
+
spotMarketIndex: number;
|
|
122
|
+
redeemPeriod: BN;
|
|
123
|
+
maxTokens: BN;
|
|
124
|
+
minDepositAmount: BN;
|
|
125
|
+
managementFee: BN;
|
|
126
|
+
profitShare: number;
|
|
127
|
+
hurdleRate: number;
|
|
128
|
+
permissioned: boolean;
|
|
129
|
+
vaultProtocol?: VaultProtocolParams;
|
|
130
|
+
manager?: PublicKey;
|
|
131
|
+
}): Promise<TransactionInstruction>;
|
|
118
132
|
/**
|
|
119
133
|
* Updates the delegate address for a vault. The delegate address will be allowed to trade
|
|
120
134
|
* on behalf of the vault.
|
|
@@ -123,6 +137,7 @@ export declare class VaultClient {
|
|
|
123
137
|
* @returns
|
|
124
138
|
*/
|
|
125
139
|
updateDelegate(vault: PublicKey, delegate: PublicKey, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
140
|
+
getUpdateDelegateIx(vault: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>;
|
|
126
141
|
/**
|
|
127
142
|
* Updates the vault margin trading status.
|
|
128
143
|
* @param vault vault address to update
|
|
@@ -130,6 +145,7 @@ export declare class VaultClient {
|
|
|
130
145
|
* @returns
|
|
131
146
|
*/
|
|
132
147
|
updateMarginTradingEnabled(vault: PublicKey, enabled: boolean, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
148
|
+
getUpdateMarginTradingEnabledIx(vault: PublicKey, enabled: boolean): Promise<TransactionInstruction>;
|
|
133
149
|
/**
|
|
134
150
|
* Updates the vault's pool id (for isolated pools).
|
|
135
151
|
* @param vault vault address to update
|
|
@@ -153,9 +169,19 @@ export declare class VaultClient {
|
|
|
153
169
|
* @returns
|
|
154
170
|
*/
|
|
155
171
|
managerDeposit(vault: PublicKey, amount: BN, uiTxParams?: TxParams, managerTokenAccount?: PublicKey): Promise<TransactionSignature>;
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @param vault vault address to deposit to
|
|
175
|
+
* @param amount amount to deposit
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
getManagerDepositIx(vault: PublicKey, amount: BN, managerTokenAccount?: PublicKey): Promise<Array<TransactionInstruction>>;
|
|
156
179
|
managerRequestWithdraw(vault: PublicKey, amount: BN, withdrawUnit: WithdrawUnit, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
180
|
+
getManagerRequestWithdrawIx(vault: PublicKey, amount: BN, withdrawUnit: WithdrawUnit): Promise<TransactionInstruction>;
|
|
157
181
|
managerCancelWithdrawRequest(vault: PublicKey, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
182
|
+
getManagerCancelWithdrawRequestIx(vault: PublicKey): Promise<TransactionInstruction>;
|
|
158
183
|
managerWithdraw(vault: PublicKey, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
184
|
+
getManagerWithdrawIx(vault: PublicKey): Promise<TransactionInstruction>;
|
|
159
185
|
managerUpdateVault(vault: PublicKey, params: {
|
|
160
186
|
redeemPeriod: BN | null;
|
|
161
187
|
maxTokens: BN | null;
|
|
@@ -165,6 +191,18 @@ export declare class VaultClient {
|
|
|
165
191
|
hurdleRate: number | null;
|
|
166
192
|
permissioned: boolean | null;
|
|
167
193
|
}, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
194
|
+
getManagerUpdateVaultIx(vault: PublicKey, params: {
|
|
195
|
+
redeemPeriod: BN | null;
|
|
196
|
+
maxTokens: BN | null;
|
|
197
|
+
managementFee: BN | null;
|
|
198
|
+
minDepositAmount: BN | null;
|
|
199
|
+
profitShare: number | null;
|
|
200
|
+
hurdleRate: number | null;
|
|
201
|
+
permissioned: boolean | null;
|
|
202
|
+
}): Promise<TransactionInstruction>;
|
|
203
|
+
managerUpdateVaultManager(vault: PublicKey, manager: PublicKey, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
204
|
+
getManagerUpdateVaultManagerIx(vault: PublicKey, manager: PublicKey): Promise<TransactionInstruction>;
|
|
205
|
+
applyProfitShare(vault: PublicKey, vaultDepositor: PublicKey, uiTxParams?: TxParams): Promise<TransactionSignature>;
|
|
168
206
|
getApplyProfitShareIx(vault: PublicKey, vaultDepositor: PublicKey): Promise<TransactionInstruction>;
|
|
169
207
|
getApplyRebaseTokenizedDepositorIx(vault: PublicKey, tokenizedVaultDepositor: PublicKey): Promise<TransactionInstruction>;
|
|
170
208
|
applyRebase(vault: PublicKey, vaultDepositor: PublicKey): Promise<TransactionSignature>;
|
|
@@ -290,10 +328,19 @@ export declare class VaultClient {
|
|
|
290
328
|
vault: PublicKey;
|
|
291
329
|
}, txParams?: TxParams, userTokenAccount?: PublicKey): Promise<TransactionSignature>;
|
|
292
330
|
requestWithdraw(vaultDepositor: PublicKey, amount: BN, withdrawUnit: WithdrawUnit, txParams?: TxParams): Promise<TransactionSignature>;
|
|
331
|
+
getRequestWithdrawIx(vaultDepositor: PublicKey, amount: BN, withdrawUnit: WithdrawUnit, oracleFeedsToCrank?: {
|
|
332
|
+
feed: PublicKey;
|
|
333
|
+
oracleSource: OracleSource;
|
|
334
|
+
}[]): Promise<TransactionInstruction[]>;
|
|
293
335
|
withdraw(vaultDepositor: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
336
|
+
getWithdrawIx(vaultDepositor: PublicKey, oracleFeedsToCrank?: {
|
|
337
|
+
feed: PublicKey;
|
|
338
|
+
oracleSource: OracleSource;
|
|
339
|
+
}[]): Promise<TransactionInstruction[]>;
|
|
294
340
|
forceWithdraw(vaultDepositor: PublicKey): Promise<TransactionSignature>;
|
|
295
341
|
getForceWithdrawIx(vaultDepositor: PublicKey): Promise<TransactionInstruction[]>;
|
|
296
342
|
cancelRequestWithdraw(vaultDepositor: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
343
|
+
getCancelRequestWithdrawIx(vaultDepositor: PublicKey, oracleFeedsToCrank: TxParams['oracleFeedsToCrank']): Promise<TransactionInstruction[]>;
|
|
297
344
|
/**
|
|
298
345
|
* Liquidates (become delegate for) a vault.
|
|
299
346
|
* @param
|
|
@@ -301,6 +348,7 @@ export declare class VaultClient {
|
|
|
301
348
|
* @returns
|
|
302
349
|
*/
|
|
303
350
|
liquidate(vaultDepositor: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
351
|
+
getLiquidateIx(vaultDepositor: PublicKey): Promise<TransactionInstruction>;
|
|
304
352
|
createTxn(vaultIxs: TransactionInstruction[], txParams?: TxParams): Promise<VersionedTransaction>;
|
|
305
353
|
createTxnNoLut(vaultIxs: TransactionInstruction[], txParams?: TxParams): Promise<VersionedTransaction>;
|
|
306
354
|
sendTxn(transaction: VersionedTransaction, simulateTransaction?: boolean): Promise<TransactionSignature>;
|
|
@@ -314,7 +362,8 @@ export declare class VaultClient {
|
|
|
314
362
|
* @param spotMarketIndex spot market index of the insurance fund stake
|
|
315
363
|
* @returns
|
|
316
364
|
*/
|
|
317
|
-
initializeInsuranceFundStake(vault: PublicKey, spotMarketIndex: number): Promise<TransactionSignature>;
|
|
365
|
+
initializeInsuranceFundStake(vault: PublicKey, spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
366
|
+
getInitializeInsuranceFundStakeIx(vault: PublicKey, spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
318
367
|
/**
|
|
319
368
|
* Adds an amount to an insurance fund stake for the vault.
|
|
320
369
|
* @param vault vault address to update
|
|
@@ -322,18 +371,29 @@ export declare class VaultClient {
|
|
|
322
371
|
* @param amount amount to add to the insurance fund stake, in spotMarketIndex precision
|
|
323
372
|
* @returns
|
|
324
373
|
*/
|
|
325
|
-
addToInsuranceFundStake(vault: PublicKey, spotMarketIndex: number, amount: BN, managerTokenAccount?: PublicKey): Promise<TransactionSignature>;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
374
|
+
addToInsuranceFundStake(vault: PublicKey, spotMarketIndex: number, amount: BN, managerTokenAccount?: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
375
|
+
getAddToInsuranceFundStakeIx(vault: PublicKey, spotMarketIndex: number, amount: BN, managerTokenAccount?: PublicKey): Promise<TransactionInstruction>;
|
|
376
|
+
requestRemoveInsuranceFundStake(vault: PublicKey, spotMarketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
377
|
+
getRequestRemoveInsuranceFundStakeIx(vault: PublicKey, spotMarketIndex: number, amount: BN): Promise<TransactionInstruction>;
|
|
378
|
+
cancelRequestRemoveInsuranceFundStake(vault: PublicKey, spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
379
|
+
getCancelRequestRemoveInsuranceFundStakeIx(vault: PublicKey, spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
380
|
+
removeInsuranceFundStake(vault: PublicKey, spotMarketIndex: number, managerTokenAccount?: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
381
|
+
getRemoveInsuranceFundStakeIx(vault: PublicKey, spotMarketIndex: number, managerTokenAccount?: PublicKey): Promise<TransactionInstruction>;
|
|
382
|
+
protocolRequestWithdraw(vault: PublicKey, amount: BN, withdrawUnit: WithdrawUnit, txParams?: TxParams): Promise<TransactionSignature>;
|
|
383
|
+
getProtocolRequestWithdrawIx(vault: PublicKey, amount: BN, withdrawUnit: WithdrawUnit): Promise<TransactionInstruction>;
|
|
384
|
+
protocolCancelWithdrawRequest(vault: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
385
|
+
getProtocolCancelWithdrawRequestIx(vault: PublicKey): Promise<TransactionInstruction[]>;
|
|
386
|
+
protocolWithdraw(vault: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
387
|
+
getProtocolWithdrawIx(vault: PublicKey): Promise<TransactionInstruction[]>;
|
|
332
388
|
private getOracleFeedsToCrank;
|
|
333
389
|
updateVaultProtocol(vault: PublicKey, params: {
|
|
334
390
|
protocolFee: BN | null;
|
|
335
391
|
protocolProfitShare: number | null;
|
|
336
392
|
}, txParams?: TxParams): Promise<TransactionSignature>;
|
|
393
|
+
getUpdateVaultProtocolIx(vault: PublicKey, params: {
|
|
394
|
+
protocolFee: BN | null;
|
|
395
|
+
protocolProfitShare: number | null;
|
|
396
|
+
}): Promise<TransactionInstruction>;
|
|
337
397
|
updateCumulativeFuelAmount(vaultDepositor: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
338
398
|
getUpdateCumulativeFuelAmountIx(vaultDepositor: PublicKey): Promise<TransactionInstruction>;
|
|
339
399
|
resetFuelSeason(vaultDepositor: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|