Skip to content

Commit

Permalink
[Router] Make all mint/redeem IXs permissioned (except router) (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-vincent authored Jul 29, 2023
1 parent fd5fc36 commit 1b3839a
Show file tree
Hide file tree
Showing 37 changed files with 614 additions and 296 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@project-serum/anchor": "0.26.0",
"@solana/spl-token": "0.3.7",
"@solana/web3.js": "1.73.0",
"@uxd-protocol/uxd-client": "7.3.1-rc2"
"@uxd-protocol/uxd-client": "8.1.0-rc1"
},
"devDependencies": {
"@types/bn.js": "^5.1.1",
Expand Down
4 changes: 2 additions & 2 deletions programs/uxd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uxd"
version = "7.3.1"
version = "8.1.0"
authors = [
"acammm <[email protected]>",
"cnek <[email protected]>",
Expand All @@ -27,7 +27,7 @@ production = []
development = []

[dependencies]
uxd-cpi = { version = "7.3.1", features = ["development"] }
uxd-cpi = { version = "8.1.0", features = ["development"] }

anchor-lang = "0.26.0"
anchor-spl = "0.26.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,23 @@ use crate::CREDIX_LP_EXTERNAL_PASS_NAMESPACE;
#[derive(Accounts)]
#[instruction(collateral_amount: u64)]
pub struct MintWithCredixLpDepository<'info> {
/// #1
pub user: Signer<'info>,
/// #1 This IX should only be accessible by the router or the DAO
#[account(
constraint = (
authority.key() == controller.key()
|| authority.key() == controller.load()?.authority
) @UxdError::InvalidAuthority,
)]
pub authority: Signer<'info>,

/// #2
pub user: Signer<'info>,

/// #3
#[account(mut)]
pub payer: Signer<'info>,

/// #3
/// #4
#[account(
mut,
seeds = [CONTROLLER_NAMESPACE],
Expand All @@ -43,7 +52,7 @@ pub struct MintWithCredixLpDepository<'info> {
)]
pub controller: AccountLoader<'info, Controller>,

/// #4
/// #5
#[account(
mut,
seeds = [
Expand All @@ -63,53 +72,53 @@ pub struct MintWithCredixLpDepository<'info> {
)]
pub depository: AccountLoader<'info, CredixLpDepository>,

/// #5
/// #6
#[account(mut)]
pub redeemable_mint: Box<Account<'info, Mint>>,

/// #6
/// #7
pub collateral_mint: Box<Account<'info, Mint>>,

/// #7
/// #8
#[account(
mut,
constraint = user_redeemable.owner == user.key() @UxdError::InvalidOwner,
constraint = user_redeemable.mint == redeemable_mint.key() @UxdError::InvalidRedeemableMint,
)]
pub user_redeemable: Box<Account<'info, TokenAccount>>,

/// #8
/// #9
#[account(
mut,
constraint = user_collateral.owner == user.key() @UxdError::InvalidOwner,
constraint = user_collateral.mint == collateral_mint.key() @UxdError::InvalidCollateralMint,
)]
pub user_collateral: Box<Account<'info, TokenAccount>>,

/// #9
/// #10
#[account(mut)]
pub depository_collateral: Box<Account<'info, TokenAccount>>,

/// #10
/// #11
#[account(mut)]
pub depository_shares: Box<Account<'info, TokenAccount>>,

/// #11
/// #12
pub credix_global_market_state: Box<Account<'info, credix_client::GlobalMarketState>>,

/// #12
/// #13
/// CHECK: unused by us, checked by credix
pub credix_signing_authority: AccountInfo<'info>,

/// #13
/// #14
#[account(mut)]
pub credix_liquidity_collateral: Box<Account<'info, TokenAccount>>,

/// #14
/// #15
#[account(mut)]
pub credix_shares_mint: Box<Account<'info, Mint>>,

/// #15
/// #16
#[account(
owner = credix_client::ID,
seeds = [
Expand All @@ -124,15 +133,15 @@ pub struct MintWithCredixLpDepository<'info> {
)]
pub credix_pass: Account<'info, credix_client::CredixPass>,

/// #16
pub system_program: Program<'info, System>,
/// #17
pub token_program: Program<'info, Token>,
pub system_program: Program<'info, System>,
/// #18
pub associated_token_program: Program<'info, AssociatedToken>,
pub token_program: Program<'info, Token>,
/// #19
pub credix_program: Program<'info, credix_client::program::Credix>,
pub associated_token_program: Program<'info, AssociatedToken>,
/// #20
pub credix_program: Program<'info, credix_client::program::Credix>,
/// #21
pub rent: Sysvar<'info, Rent>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ use anchor_spl::token::TokenAccount;

#[derive(Accounts)]
pub struct MintWithMercurialVaultDepository<'info> {
/// #1
pub user: Signer<'info>,
/// #1 This IX should only be accessible by the router or the DAO
#[account(
constraint = (
authority.key() == controller.key()
|| authority.key() == controller.load()?.authority
) @UxdError::InvalidAuthority,
)]
pub authority: Signer<'info>,

/// #2
pub user: Signer<'info>,

/// #3
#[account(mut)]
pub payer: Signer<'info>,

/// #3
/// #4
#[account(
mut,
seeds = [CONTROLLER_NAMESPACE],
Expand All @@ -36,7 +45,7 @@ pub struct MintWithMercurialVaultDepository<'info> {
)]
pub controller: AccountLoader<'info, Controller>,

/// #4
/// #5
#[account(
mut,
seeds = [MERCURIAL_VAULT_DEPOSITORY_NAMESPACE, depository.load()?.mercurial_vault.key().as_ref(), depository.load()?.collateral_mint.as_ref()],
Expand All @@ -49,34 +58,34 @@ pub struct MintWithMercurialVaultDepository<'info> {
)]
pub depository: AccountLoader<'info, MercurialVaultDepository>,

/// #5
/// #6
#[account(
mut,
seeds = [REDEEMABLE_MINT_NAMESPACE],
bump = controller.load()?.redeemable_mint_bump,
)]
pub redeemable_mint: Box<Account<'info, Mint>>,

/// #6
/// #7
#[account(
mut,
constraint = user_redeemable.mint == controller.load()?.redeemable_mint @UxdError::InvalidRedeemableMint,
constraint = &user_redeemable.owner == user.key @UxdError::InvalidOwner,
)]
pub user_redeemable: Box<Account<'info, TokenAccount>>,

/// #7
/// #8
pub collateral_mint: Box<Account<'info, Mint>>,

/// #8
/// #9
#[account(
mut,
constraint = user_collateral.mint == depository.load()?.collateral_mint @UxdError::InvalidCollateralMint,
constraint = &user_collateral.owner == user.key @UxdError::InvalidOwner,
)]
pub user_collateral: Box<Account<'info, TokenAccount>>,

/// #9
/// #10
/// Token account holding the LP tokens minted by depositing collateral on mercurial vault
#[account(
mut,
Expand All @@ -87,29 +96,29 @@ pub struct MintWithMercurialVaultDepository<'info> {
)]
pub depository_lp_token_vault: Box<Account<'info, TokenAccount>>,

/// #10
/// #11
#[account(
mut,
constraint = mercurial_vault.token_vault == mercurial_vault_collateral_token_safe.key() @UxdError::InvalidMercurialVaultCollateralTokenSafe,
)]
pub mercurial_vault: Box<Account<'info, mercurial_vault::state::Vault>>,

/// #11
/// #12
#[account(mut)]
pub mercurial_vault_lp_mint: Box<Account<'info, Mint>>,

/// #12
/// #13
/// Token account owned by the mercurial vault program. Hold the collateral deposited in the mercurial vault.
#[account(mut)]
pub mercurial_vault_collateral_token_safe: Box<Account<'info, TokenAccount>>,

/// #13
/// #14
pub mercurial_vault_program: Program<'info, mercurial_vault::program::Vault>,

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

/// #15
/// #16
pub token_program: Program<'info, Token>,
}

Expand Down
Loading

0 comments on commit 1b3839a

Please sign in to comment.