diff --git a/ts/sdk/cli/cli.ts b/ts/sdk/cli/cli.ts index 6d937d48..6957d593 100644 --- a/ts/sdk/cli/cli.ts +++ b/ts/sdk/cli/cli.ts @@ -11,6 +11,7 @@ import { deposit, requestWithdraw, withdraw, + listDepositorsForVault, } from "./commands"; import { Command, Option } from 'commander'; @@ -39,6 +40,11 @@ program .addOption(new Option("--vault-address
", "Address of the Vault to view").makeOptionMandatory(false)) .addOption(new Option("--authority ", "VaultDepositor authority address").makeOptionMandatory(false)) .action((opts) => viewVaultDepositor(program, opts)); +program + .command("list-vault-depositors") + .description("List VaultDepositors for a Vault") + .addOption(new Option("--vault-address
", "Address of the Vault to view").makeOptionMandatory(true)) + .action((opts) => listDepositorsForVault(program, opts)); program .command("manager-deposit") .description("Make a deposit to your vault") @@ -96,4 +102,4 @@ program .addOption(new Option("--authority ", "VaultDepositor authority address").makeOptionMandatory(false)) .action((opts) => withdraw(program, opts)); -program.parseAsync().then(() => {}); +program.parseAsync().then(() => { }); diff --git a/ts/sdk/cli/commands/index.ts b/ts/sdk/cli/commands/index.ts index f6cdf631..89342df2 100644 --- a/ts/sdk/cli/commands/index.ts +++ b/ts/sdk/cli/commands/index.ts @@ -9,4 +9,5 @@ export * from './applyProfitShare'; export * from './initVaultDepositor'; export * from './deposit'; export * from './requestWithdraw'; -export * from './withdraw'; \ No newline at end of file +export * from './withdraw'; +export * from './listDepositorsForVault'; \ No newline at end of file diff --git a/ts/sdk/cli/commands/listDepositorsForVault.ts b/ts/sdk/cli/commands/listDepositorsForVault.ts new file mode 100644 index 00000000..96b96a2e --- /dev/null +++ b/ts/sdk/cli/commands/listDepositorsForVault.ts @@ -0,0 +1,33 @@ +import { PublicKey } from "@solana/web3.js"; +import { + OptionValues, + Command +} from "commander"; +import { getCommandContext } from "../utils"; + +export const listDepositorsForVault = async (program: Command, cmdOpts: OptionValues) => { + + const { + driftVault + } = await getCommandContext(program, false); + + let vaultAddress: PublicKey | undefined = undefined; + try { + if (cmdOpts.vaultAddress !== undefined) { + vaultAddress = new PublicKey(cmdOpts.vaultAddress as string); + } else { + console.error("Must supply --vault-address"); + process.exit(1); + } + } catch (err) { + console.error("Failed to load VaultDepositor address"); + process.exit(1); + } + + const vaultDepositors = await driftVault.getAllVaultDepositors(vaultAddress); + vaultDepositors.forEach((vaultDepositor) => { + console.log(vaultDepositor.publicKey.toBase58()); + }); + // printVaultDepositor(vaultDepositor); + console.log("Done!"); +}; \ No newline at end of file