🔐initialize_identity_depository
Permissionned - Only one per controller could be initiated, for 1:1 mint/redeem against a desired collateral mint.
Flow
Checks
Anchor IDL accounts checks
Validates: same decimals for
collateral_mint
andredeemable_mint
Validates: enforced mint used for
collateral_mint
(hardcoded asUSDC:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
now)
Handler
Initialises the
depository
PDA (IdentityDepository)Initialises the
collateral_vault
PDASet
redeemable_amount_under_management_cap
to an initial value of 1000000 ui units.Emits Anchor
InitializeIdentityDepositoryEvent
event
Parameters
-
Accounts in
// ...
#[derive(Accounts)]
pub struct InitializeIdentityDepository<'info> {
/// #1 Authored call accessible only to the signer matching Controller.authority
pub authority: Signer<'info>,
/// #2
#[account(mut)]
pub payer: Signer<'info>,
/// #3 The top level UXDProgram on chain account managing the redeemable mint
#[account(
mut,
seeds = [CONTROLLER_NAMESPACE],
bump = controller.load()?.bump,
has_one = authority @UxdError::InvalidAuthority,
)]
pub controller: AccountLoader<'info, Controller>,
/// #4 UXDProgram on chain account bound to a Controller instance
#[account(
init,
seeds = [IDENTITY_DEPOSITORY_NAMESPACE], // Only a single instance per controller instance
bump,
payer = payer,
space = IDENTITY_DEPOSITORY_SPACE,
)]
pub depository: AccountLoader<'info, IdentityDepository>,
/// #5
/// Token account holding the collateral from minting
#[account(
init,
seeds = [IDENTITY_DEPOSITORY_COLLATERAL_NAMESPACE],
token::authority = depository,
token::mint = collateral_mint,
bump,
payer = payer,
)]
pub collateral_vault: Account<'info, TokenAccount>,
/// #6 The collateral mint used by the `depository` instance
pub collateral_mint: Account<'info, Mint>,
/// #7 System Program
pub system_program: Program<'info, System>,
/// #8 Token Program
pub token_program: Program<'info, Token>,
/// #9 Rent Sysvar
pub rent: Sysvar<'info, Rent>,
}
// ...
Last updated
Was this helpful?