-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1680703
commit 2b2aa75
Showing
24 changed files
with
263 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ node_modules | |
test-ledger | ||
.idea | ||
migrations | ||
ts/sdk/src/**/*.js | ||
ts/sdk/src/**/*.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
programs/drift_vaults/src/instructions/initialize_vault_depositor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::{Size, Vault, VaultDepositor}; | ||
use anchor_lang::prelude::*; | ||
|
||
pub fn initialize_vault_depositor(ctx: Context<InitializeVaultDepositor>) -> Result<()> { | ||
let mut vault_depositor = ctx.accounts.vault_depositor.load_init()?; | ||
vault_depositor.vault = ctx.accounts.vault.key(); | ||
vault_depositor.pubkey = ctx.accounts.vault_depositor.key(); | ||
vault_depositor.authority = *ctx.accounts.authority.key; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct InitializeVaultDepositor<'info> { | ||
pub vault: AccountLoader<'info, Vault>, | ||
#[account( | ||
init, | ||
seeds = [b"vault_depositor", vault.key().as_ref()], | ||
space = Vault::SIZE, | ||
bump, | ||
payer = payer | ||
)] | ||
pub vault_depositor: AccountLoader<'info, VaultDepositor>, | ||
pub authority: Signer<'info>, | ||
#[account(mut)] | ||
pub payer: Signer<'info>, | ||
pub rent: Sysvar<'info, Rent>, | ||
pub system_program: Program<'info, System>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub use initialize_vault::*; | ||
pub use initialize_vault_depositor::*; | ||
|
||
mod initialize_vault; | ||
mod initialize_vault_depositor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub use traits::*; | ||
pub use vault::*; | ||
pub use vault_depositor::*; | ||
|
||
mod traits; | ||
mod vault; | ||
mod vault_depositor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::Size; | ||
use anchor_lang::prelude::*; | ||
use static_assertions::const_assert_eq; | ||
|
||
#[account(zero_copy)] | ||
#[derive(Eq, PartialEq, Debug)] | ||
#[repr(C)] | ||
pub struct VaultDepositor { | ||
/// The vault deposited into | ||
pub vault: Pubkey, | ||
/// The vault depositor account's pubkey. It is a pda of vault and authority | ||
pub pubkey: Pubkey, | ||
/// The authority is the address w permission to deposit/withdraw | ||
pub authority: Pubkey, | ||
} | ||
|
||
impl Size for VaultDepositor { | ||
const SIZE: usize = 104; | ||
} | ||
|
||
const_assert_eq!( | ||
VaultDepositor::SIZE, | ||
std::mem::size_of::<VaultDepositor>() + 8 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.