🎛️
UXDProgram (Solana)
  • 💾Welcome
    • Purpose and philosophy
    • Testing
    • Audits
  • 📚Useful Informations
    • Glossary
      • 🪙Depository
      • 🪙Controller
      • 📘CPI
    • ✨Visualisations
  • On-chain Accounts
    • Controller
    • MercurialVaultDepository
    • IdentityDepository
  • Instructions
    • 🟢initialize_controller
    • 🔐register_mercurial_vault_depository
    • 🔐initialize_identity_depository
    • 🔐edit_controller
    • 🔐edit_identity_depository
    • 🔐edit_mercurial_vault_depository
    • 🟢mint_with_identity_depository
    • 🟢redeem_from_identity_depository
    • mercurial
      • 🟢mint_with_mercurial_vault_depository
      • 🟢redeem_from_mercurial_vault_depository
Powered by GitBook
On this page
  • Flow
  • Specificities
  • Parameters
  • Accounts input

Was this helpful?

  1. Instructions

initialize_controller

Permissionless - Callable once per deployed program

Flow

  • Checks

    • Anchor IDL accounts checks

    • Validates: check decimal input parameter

  • Handler

    • Initialises the controller PDA

    • Initialises the redeemable_mint PDA

    • Writes initial controller data

    • Emits Anchor InitializeControllerEvent event

Specificities

There can ever only be a single Controller for a given deployed program due to the seed derivation being a function of a static string and the programID

This instruction is preferably called right after program deployment. In the very unlikely event that someone front run you, nothing at stake yet so wipe and redeploy and call it faster.

This instruction is preferably called by a multisig/DAO instead of a specific user account, for safety.

Parameters

redeemable_mint_decimals the number of decimal the redeemable mint (UXD in our case) should be created with

Accounts input

programs/uxd/src/instructions/initialize_controller.rs
// ...

/// Takes 7 accounts - 4 used locally - 0 for CPI - 2 Programs - 1 Sysvar
#[derive(Accounts)]
#[instruction(
    redeemable_mint_decimals: u8,
)]
pub struct InitializeController<'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(
        init,
        seeds = [CONTROLLER_NAMESPACE],
        bump,
        payer = payer,
        space = CONTROLLER_SPACE
    )]
    pub controller: AccountLoader<'info, Controller>,

    /// #4 The redeemable mint managed by the `controller` instance
    #[account(
        init,
        seeds = [REDEEMABLE_MINT_NAMESPACE],
        bump,
        mint::authority = controller,
        mint::decimals = redeemable_mint_decimals,
        payer = payer,
        constraint = redeemable_mint_decimals <= SOLANA_MAX_MINT_DECIMALS
    )]
    pub redeemable_mint: Account<'info, Mint>,

    /// #5 System Program
    pub system_program: Program<'info, System>,

    /// #6 Token Program
    pub token_program: Program<'info, Token>,

    /// #7 Rent Sysvar
    pub rent: Sysvar<'info, Rent>,
}

// ...
PreviousIdentityDepositoryNextregister_mercurial_vault_depository

Last updated 2 years ago

Was this helpful?

🟢