@drift-labs/vaults-sdk 0.1.0 → 0.1.2

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.
Files changed (41) hide show
  1. package/README.md +44 -8
  2. package/cli/cli.ts +45 -9
  3. package/cli/commands/applyProfitShare.ts +3 -6
  4. package/cli/commands/deposit.ts +0 -1
  5. package/cli/commands/deriveVaultAddress.ts +15 -0
  6. package/cli/commands/index.ts +4 -1
  7. package/cli/commands/initVault.ts +104 -23
  8. package/cli/commands/initVaultDepositor.ts +0 -1
  9. package/cli/commands/listDepositorsForVault.ts +0 -1
  10. package/cli/commands/managerCancelWithdraw.ts +0 -1
  11. package/cli/commands/managerDeposit.ts +0 -1
  12. package/cli/commands/managerRequestWithdraw.ts +0 -1
  13. package/cli/commands/managerUpdateMarginTradingEnabled.ts +26 -0
  14. package/cli/commands/managerUpdateVault.ts +91 -9
  15. package/cli/commands/managerUpdateVaultDelegate.ts +35 -0
  16. package/cli/commands/managerWithdraw.ts +0 -1
  17. package/cli/commands/requestWithdraw.ts +0 -1
  18. package/cli/commands/vaultDeposit.ts +0 -1
  19. package/cli/commands/vaultWithdraw.ts +0 -1
  20. package/cli/commands/viewVault.ts +4 -4
  21. package/cli/commands/viewVaultDepositor.ts +0 -1
  22. package/cli/commands/withdraw.ts +0 -1
  23. package/cli/utils.ts +15 -8
  24. package/lib/accountSubscribers/index.js +5 -1
  25. package/lib/accounts/index.js +5 -1
  26. package/lib/accounts/vaultAccount.js +1 -1
  27. package/lib/accounts/vaultDepositorAccount.js +1 -1
  28. package/lib/addresses.js +5 -1
  29. package/lib/index.js +5 -1
  30. package/lib/parsers/index.js +5 -1
  31. package/lib/parsers/logParser.d.ts +1 -1
  32. package/lib/types/drift_vaults.d.ts +113 -1
  33. package/lib/types/drift_vaults.js +112 -0
  34. package/lib/types/types.d.ts +13 -13
  35. package/lib/utils.js +6 -2
  36. package/lib/vaultClient.d.ts +22 -0
  37. package/lib/vaultClient.js +85 -24
  38. package/package.json +2 -4
  39. package/src/idl/drift_vaults.json +112 -0
  40. package/src/types/drift_vaults.ts +224 -0
  41. package/src/vaultClient.ts +97 -0
@@ -18,13 +18,13 @@ export const viewVault = async (program: Command, cmdOpts: OptionValues) => {
18
18
 
19
19
  const {
20
20
  driftVault
21
- } = await getCommandContext(program, true);
21
+ } = await getCommandContext(program, false);
22
22
 
23
23
  const vault = await driftVault.getVault(address);
24
- printVault(vault);
24
+ const { managerSharePct } = printVault(vault);
25
25
  const vaultEquity = await driftVault.calculateVaultEquity({
26
26
  vault,
27
27
  });
28
- console.log(`vaultEquity: ${convertToNumber(vaultEquity, QUOTE_PRECISION)}`);
29
- console.log("Done!");
28
+ console.log(`vaultEquity: $${convertToNumber(vaultEquity, QUOTE_PRECISION)}`);
29
+ console.log(`manager share: $${managerSharePct * convertToNumber(vaultEquity, QUOTE_PRECISION)}`);
30
30
  };
@@ -33,5 +33,4 @@ export const viewVaultDepositor = async (program: Command, cmdOpts: OptionValues
33
33
 
34
34
  const vaultDepositor = await driftVault.getVaultDepositor(vaultDepositorAddress);
35
35
  printVaultDepositor(vaultDepositor);
36
- console.log("Done!");
37
36
  };
@@ -21,5 +21,4 @@ export const withdraw = async (program: Command, cmdOpts: OptionValues) => {
21
21
 
22
22
  const tx = await driftVault.withdraw(vaultDepositorAddress);
23
23
  console.log(`Withdrew from vault: ${tx}`);
24
- console.log("Done!");
25
24
  };
package/cli/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { DriftClient, PublicKey, Wallet, loadKeypair } from "@drift-labs/sdk";
2
- import { Vault, VaultClient, decodeName } from "../src";
1
+ import { DriftClient, Wallet, loadKeypair } from "@drift-labs/sdk";
2
+ import { VAULT_PROGRAM_ID, Vault, VaultClient, decodeName } from "../src";
3
3
  import { Command } from "commander";
4
4
  import { Connection, Keypair } from "@solana/web3.js";
5
5
  import { AnchorProvider } from "@coral-xyz/anchor";
@@ -18,7 +18,8 @@ export function printVault(vault: Vault) {
18
18
  console.log(`userShares: ${vault.userShares.toString()}`);
19
19
  console.log(`totalShares: ${vault.totalShares.toString()}`);
20
20
  const managerShares = vault.totalShares.sub(vault.userShares);
21
- console.log(` [managerShares]: ${managerShares.toString()} (${(managerShares.toNumber() / vault.totalShares.toNumber() * 100.0).toFixed(4)}%)`);
21
+ const managerSharePct = managerShares.toNumber() / vault.totalShares.toNumber();
22
+ console.log(` [managerShares]: ${managerShares.toString()} (${(managerSharePct * 100.0).toFixed(4)}%)`);
22
23
  console.log(`totalShares: ${vault.totalShares.toString()}`);
23
24
  console.log(`lastFeeUpdateTs: ${vault.lastFeeUpdateTs.toString()}`);
24
25
  console.log(`liquidationStartTs: ${vault.liquidationStartTs.toString()}`);
@@ -46,6 +47,11 @@ export function printVault(vault: Vault) {
46
47
  console.log(`hurdleRate: ${vault.hurdleRate}`);
47
48
  console.log(`spotMarketIndex: ${vault.spotMarketIndex}`);
48
49
  console.log(`permissioned: ${vault.permissioned}`);
50
+
51
+ return {
52
+ managerShares,
53
+ managerSharePct,
54
+ };
49
55
  }
50
56
 
51
57
  export function printVaultDepositor(vaultDepositor) {
@@ -53,9 +59,9 @@ export function printVaultDepositor(vaultDepositor) {
53
59
  console.log(`pubkey: ${vaultDepositor.pubkey.toBase58()}`);
54
60
  console.log(`authority: ${vaultDepositor.authority.toBase58()}`);
55
61
  console.log(`vaultShares: ${vaultDepositor.vaultShares.toString()}`);
56
- console.log(`lastWithdrawRequestShares: ${vaultDepositor.lastWithdrawRequestShares.toString()}`);
57
- console.log(`lastWithdrawRequestValue: ${vaultDepositor.lastWithdrawRequestValue.toString()}`);
58
- console.log(`lastWithdrawRequestTs: ${vaultDepositor.lastWithdrawRequestTs.toString()}`);
62
+ console.log(`lastWithdrawRequest.Shares: ${vaultDepositor.lastWithdrawRequest.shares.toString()}`);
63
+ console.log(`lastWithdrawRequest.Value: ${vaultDepositor.lastWithdrawRequest.value.toString()}`);
64
+ console.log(`lastWithdrawRequest.Ts: ${vaultDepositor.lastWithdrawRequest.ts.toString()}`);
59
65
  console.log(`lastValidTs: ${vaultDepositor.lastValidTs.toString()}`);
60
66
  console.log(`netDeposits: ${vaultDepositor.netDeposits.toString()}`);
61
67
  console.log(`totalDeposits: ${vaultDepositor.totalDeposits.toString()}`);
@@ -74,6 +80,7 @@ export async function getCommandContext(program: Command, needToSign: boolean):
74
80
  let keypair: Keypair;
75
81
  if (needToSign) {
76
82
  try {
83
+ console.log(opts.keypair);
77
84
  keypair = loadKeypair(opts.keypair as string);
78
85
  } catch (e) {
79
86
  console.error(`Need to provide a valid keypair: ${e}`);
@@ -86,7 +93,7 @@ export async function getCommandContext(program: Command, needToSign: boolean):
86
93
  const wallet = new Wallet(keypair);
87
94
  console.log(`Signing wallet address (need to sign: ${needToSign}): `, wallet.publicKey.toBase58());
88
95
 
89
- const connection = new Connection(opts.rpc, {
96
+ const connection = new Connection(opts.url, {
90
97
  commitment: opts.commitment,
91
98
  });
92
99
  const driftClient = new DriftClient({
@@ -103,7 +110,7 @@ export async function getCommandContext(program: Command, needToSign: boolean):
103
110
 
104
111
  const provider = new AnchorProvider(connection, wallet, {});
105
112
  anchor.setProvider(provider);
106
- const vaultProgramId = new PublicKey("vAuLTsyrvSfZRuRB3XgvkPwNGgYSs9YRYymVebLKoxR");
113
+ const vaultProgramId = VAULT_PROGRAM_ID;
107
114
  const vaultProgram = new anchor.Program(IDL, vaultProgramId, provider);
108
115
 
109
116
  const driftVault = new VaultClient({
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -18,7 +18,7 @@ class VaultAccount extends vaultsProgramAccount_1.VaultsProgramAccount {
18
18
  }
19
19
  }
20
20
  static getAddressSync(programId, vaultName) {
21
- return addresses_1.getVaultAddressSync(programId, name_1.encodeName(vaultName));
21
+ return (0, addresses_1.getVaultAddressSync)(programId, (0, name_1.encodeName)(vaultName));
22
22
  }
23
23
  calcSharesAfterManagementFee(vaultEquity) {
24
24
  const accountData = this.accountSubscriber.getAccountAndSlot().data;
@@ -17,7 +17,7 @@ class VaultDepositorAccount extends vaultsProgramAccount_1.VaultsProgramAccount
17
17
  }
18
18
  }
19
19
  static getAddressSync(programId, vault, authority) {
20
- return addresses_1.getVaultDepositorAddressSync(programId, vault, authority);
20
+ return (0, addresses_1.getVaultDepositorAddressSync)(programId, vault, authority);
21
21
  }
22
22
  /**
23
23
  * Calculates the percentage of a depositor's equity that will be paid as profit share fees.
package/lib/addresses.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,7 @@
1
1
  import { Program } from '@coral-xyz/anchor';
2
2
  import { TransactionSignature } from '@solana/web3.js';
3
3
  import { WrappedEvents } from '../types/types';
4
- declare type Log = {
4
+ type Log = {
5
5
  txSig: TransactionSignature;
6
6
  slot: number;
7
7
  logs: string[];
@@ -1,4 +1,4 @@
1
- export declare type DriftVaults = {
1
+ export type DriftVaults = {
2
2
  version: '0.1.0';
3
3
  name: 'drift_vaults';
4
4
  instructions: [
@@ -789,6 +789,118 @@ export declare type DriftVaults = {
789
789
  }
790
790
  ];
791
791
  args: [];
792
+ },
793
+ {
794
+ name: 'initializeInsuranceFundStake';
795
+ accounts: [
796
+ {
797
+ name: 'vault';
798
+ isMut: true;
799
+ isSigner: false;
800
+ },
801
+ {
802
+ name: 'manager';
803
+ isMut: false;
804
+ isSigner: true;
805
+ },
806
+ {
807
+ name: 'payer';
808
+ isMut: true;
809
+ isSigner: true;
810
+ },
811
+ {
812
+ name: 'rent';
813
+ isMut: false;
814
+ isSigner: false;
815
+ },
816
+ {
817
+ name: 'systemProgram';
818
+ isMut: false;
819
+ isSigner: false;
820
+ },
821
+ {
822
+ name: 'driftSpotMarket';
823
+ isMut: false;
824
+ isSigner: false;
825
+ },
826
+ {
827
+ name: 'insuranceFundStake';
828
+ isMut: true;
829
+ isSigner: false;
830
+ },
831
+ {
832
+ name: 'driftUserStats';
833
+ isMut: true;
834
+ isSigner: false;
835
+ },
836
+ {
837
+ name: 'driftState';
838
+ isMut: false;
839
+ isSigner: false;
840
+ },
841
+ {
842
+ name: 'driftProgram';
843
+ isMut: false;
844
+ isSigner: false;
845
+ }
846
+ ];
847
+ args: [
848
+ {
849
+ name: 'marketIndex';
850
+ type: 'u16';
851
+ }
852
+ ];
853
+ },
854
+ {
855
+ name: 'initializeCompetitor';
856
+ accounts: [
857
+ {
858
+ name: 'vault';
859
+ isMut: true;
860
+ isSigner: false;
861
+ },
862
+ {
863
+ name: 'manager';
864
+ isMut: false;
865
+ isSigner: true;
866
+ },
867
+ {
868
+ name: 'payer';
869
+ isMut: true;
870
+ isSigner: true;
871
+ },
872
+ {
873
+ name: 'rent';
874
+ isMut: false;
875
+ isSigner: false;
876
+ },
877
+ {
878
+ name: 'systemProgram';
879
+ isMut: false;
880
+ isSigner: false;
881
+ },
882
+ {
883
+ name: 'competitor';
884
+ isMut: true;
885
+ isSigner: false;
886
+ },
887
+ {
888
+ name: 'driftCompetitions';
889
+ isMut: true;
890
+ isSigner: false;
891
+ },
892
+ {
893
+ name: 'driftUserStats';
894
+ isMut: true;
895
+ isSigner: false;
896
+ },
897
+ {
898
+ name: 'driftCompetitionsProgram';
899
+ isMut: false;
900
+ isSigner: false;
901
+ }
902
+ ];
903
+ args: [];
792
904
  }
793
905
  ];
794
906
  accounts: [
@@ -793,6 +793,118 @@ exports.IDL = {
793
793
  ],
794
794
  args: [],
795
795
  },
796
+ {
797
+ name: 'initializeInsuranceFundStake',
798
+ accounts: [
799
+ {
800
+ name: 'vault',
801
+ isMut: true,
802
+ isSigner: false,
803
+ },
804
+ {
805
+ name: 'manager',
806
+ isMut: false,
807
+ isSigner: true,
808
+ },
809
+ {
810
+ name: 'payer',
811
+ isMut: true,
812
+ isSigner: true,
813
+ },
814
+ {
815
+ name: 'rent',
816
+ isMut: false,
817
+ isSigner: false,
818
+ },
819
+ {
820
+ name: 'systemProgram',
821
+ isMut: false,
822
+ isSigner: false,
823
+ },
824
+ {
825
+ name: 'driftSpotMarket',
826
+ isMut: false,
827
+ isSigner: false,
828
+ },
829
+ {
830
+ name: 'insuranceFundStake',
831
+ isMut: true,
832
+ isSigner: false,
833
+ },
834
+ {
835
+ name: 'driftUserStats',
836
+ isMut: true,
837
+ isSigner: false,
838
+ },
839
+ {
840
+ name: 'driftState',
841
+ isMut: false,
842
+ isSigner: false,
843
+ },
844
+ {
845
+ name: 'driftProgram',
846
+ isMut: false,
847
+ isSigner: false,
848
+ },
849
+ ],
850
+ args: [
851
+ {
852
+ name: 'marketIndex',
853
+ type: 'u16',
854
+ },
855
+ ],
856
+ },
857
+ {
858
+ name: 'initializeCompetitor',
859
+ accounts: [
860
+ {
861
+ name: 'vault',
862
+ isMut: true,
863
+ isSigner: false,
864
+ },
865
+ {
866
+ name: 'manager',
867
+ isMut: false,
868
+ isSigner: true,
869
+ },
870
+ {
871
+ name: 'payer',
872
+ isMut: true,
873
+ isSigner: true,
874
+ },
875
+ {
876
+ name: 'rent',
877
+ isMut: false,
878
+ isSigner: false,
879
+ },
880
+ {
881
+ name: 'systemProgram',
882
+ isMut: false,
883
+ isSigner: false,
884
+ },
885
+ {
886
+ name: 'competitor',
887
+ isMut: true,
888
+ isSigner: false,
889
+ },
890
+ {
891
+ name: 'driftCompetitions',
892
+ isMut: true,
893
+ isSigner: false,
894
+ },
895
+ {
896
+ name: 'driftUserStats',
897
+ isMut: true,
898
+ isSigner: false,
899
+ },
900
+ {
901
+ name: 'driftCompetitionsProgram',
902
+ isMut: false,
903
+ isSigner: false,
904
+ },
905
+ ],
906
+ args: [],
907
+ },
796
908
  ],
797
909
  accounts: [
798
910
  {
@@ -16,12 +16,12 @@ export declare class WithdrawUnit {
16
16
  sharesPercent: {};
17
17
  };
18
18
  }
19
- export declare type WithdrawRequest = {
19
+ export type WithdrawRequest = {
20
20
  shares: BN;
21
21
  value: BN;
22
22
  ts: BN;
23
23
  };
24
- export declare type Vault = {
24
+ export type Vault = {
25
25
  name: number[];
26
26
  pubkey: PublicKey;
27
27
  manager: PublicKey;
@@ -56,7 +56,7 @@ export declare type Vault = {
56
56
  permissioned: boolean;
57
57
  lastManagerWithdrawRequest: WithdrawRequest;
58
58
  };
59
- export declare type VaultDepositor = {
59
+ export type VaultDepositor = {
60
60
  vault: PublicKey;
61
61
  pubkey: PublicKey;
62
62
  authority: PublicKey;
@@ -71,14 +71,14 @@ export declare type VaultDepositor = {
71
71
  profitShareFeePaid: BN;
72
72
  padding: number[];
73
73
  };
74
- export declare type VaultsProgramAccountBaseEvents = {
74
+ export type VaultsProgramAccountBaseEvents = {
75
75
  update: void;
76
76
  error: (e: Error) => void;
77
77
  };
78
- export declare type VaultDepositorAccountEvents = {
78
+ export type VaultDepositorAccountEvents = {
79
79
  vaultDepositorUpdate: (payload: VaultDepositor) => void;
80
80
  } & VaultsProgramAccountBaseEvents;
81
- export declare type VaultAccountEvents = {
81
+ export type VaultAccountEvents = {
82
82
  vaultUpdate: (payload: Vault) => void;
83
83
  } & VaultsProgramAccountBaseEvents;
84
84
  export interface VaultsProgramAccountSubscriber<Account, AccountEvents extends VaultsProgramAccountBaseEvents> {
@@ -90,8 +90,8 @@ export interface VaultsProgramAccountSubscriber<Account, AccountEvents extends V
90
90
  unsubscribe(): Promise<void>;
91
91
  getAccountAndSlot(): DataAndSlot<Account>;
92
92
  }
93
- export declare type VaultAccountSubscriber = VaultsProgramAccountSubscriber<Vault, VaultAccountEvents>;
94
- export declare type VaultDepositorAccountSubscriber = VaultsProgramAccountSubscriber<VaultDepositor, VaultDepositorAccountEvents>;
93
+ export type VaultAccountSubscriber = VaultsProgramAccountSubscriber<Vault, VaultAccountEvents>;
94
+ export type VaultDepositorAccountSubscriber = VaultsProgramAccountSubscriber<VaultDepositor, VaultDepositorAccountEvents>;
95
95
  export declare class VaultDepositorAction {
96
96
  static readonly DEPOSIT: {
97
97
  deposit: {};
@@ -109,7 +109,7 @@ export declare class VaultDepositorAction {
109
109
  feePayment: {};
110
110
  };
111
111
  }
112
- export declare type VaultDepositorRecord = {
112
+ export type VaultDepositorRecord = {
113
113
  ts: BN;
114
114
  vault: PublicKey;
115
115
  depositorAuthority: PublicKey;
@@ -127,11 +127,11 @@ export declare type VaultDepositorRecord = {
127
127
  managementFee: BN;
128
128
  managementFeeShares: BN;
129
129
  };
130
- export declare type VaultsEventMap = {
130
+ export type VaultsEventMap = {
131
131
  VaultDepositorRecord: Event<VaultDepositorRecord>;
132
132
  };
133
- export declare type EventType = keyof VaultsEventMap;
134
- export declare type WrappedEvent<Type extends EventType> = VaultsEventMap[Type] & {
133
+ export type EventType = keyof VaultsEventMap;
134
+ export type WrappedEvent<Type extends EventType> = VaultsEventMap[Type] & {
135
135
  eventType: Type;
136
136
  };
137
- export declare type WrappedEvents = WrappedEvent<EventType>[];
137
+ export type WrappedEvents = WrappedEvent<EventType>[];
package/lib/utils.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -33,7 +37,7 @@ const getDriftVaultProgram = (connection, wallet) => {
33
37
  };
34
38
  exports.getDriftVaultProgram = getDriftVaultProgram;
35
39
  const getVaultClient = (connection, wallet, driftClient) => {
36
- const vaultProgram = exports.getDriftVaultProgram(connection, wallet);
40
+ const vaultProgram = (0, exports.getDriftVaultProgram)(connection, wallet);
37
41
  const vaultClient = new vaultClient_1.VaultClient({
38
42
  driftClient,
39
43
  program: vaultProgram,
@@ -2,6 +2,7 @@
2
2
  import { BN, DriftClient } from '@drift-labs/sdk';
3
3
  import { Program, ProgramAccount } from '@coral-xyz/anchor';
4
4
  import { DriftVaults } from './types/drift_vaults';
5
+ import { CompetitionsClient } from '@drift-labs/competitions-sdk/lib/competitionClient';
5
6
  import { PublicKey, SetComputeUnitLimitParams, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
6
7
  import { Vault, VaultDepositor, WithdrawUnit } from './types/types';
7
8
  export declare class VaultClient {
@@ -44,6 +45,13 @@ export declare class VaultClient {
44
45
  * @returns
45
46
  */
46
47
  updateDelegate(vault: PublicKey, delegate: PublicKey): Promise<TransactionSignature>;
48
+ /**
49
+ * Updates the vault margin trading status.
50
+ * @param vault vault address to update
51
+ * @param enabeld whether to enable margin trading
52
+ * @returns
53
+ */
54
+ updateMarginTradingEnabled(vault: PublicKey, enabled: boolean): Promise<TransactionSignature>;
47
55
  /**
48
56
  *
49
57
  * @param vault vault address to deposit to
@@ -97,4 +105,18 @@ export declare class VaultClient {
97
105
  * Used for UI wallet adapters compatibility
98
106
  */
99
107
  createAndSendTxn(ixs: TransactionInstruction[], computeUnitParams?: SetComputeUnitLimitParams): Promise<TransactionSignature>;
108
+ /**
109
+ * Initializes an insurance fund stake for the vault.
110
+ * @param vault vault address to update
111
+ * @param spotMarketIndex spot market index of the insurance fund stake
112
+ * @returns
113
+ */
114
+ initializeInsuranceFundStake(vault: PublicKey, spotMarketIndex: number): Promise<TransactionSignature>;
115
+ /**
116
+ * Initializes a DriftCompetitions Competitor account for the vault.
117
+ * @param vault vault address to initialize Competitor for
118
+ * @param competitionName name of the competition to initialize for
119
+ * @returns
120
+ */
121
+ initializeCompetitor(vault: PublicKey, competitionsClient: CompetitionsClient, competitionName: string): Promise<TransactionSignature>;
100
122
  }