diff --git a/programs/uxd/src/instructions/credix_lp/rebalance_create_withdraw_request_from_credix_lp_depository.rs b/programs/uxd/src/instructions/credix_lp/rebalance_create_withdraw_request_from_credix_lp_depository.rs index 5fa134a3e..85d5482e1 100644 --- a/programs/uxd/src/instructions/credix_lp/rebalance_create_withdraw_request_from_credix_lp_depository.rs +++ b/programs/uxd/src/instructions/credix_lp/rebalance_create_withdraw_request_from_credix_lp_depository.rs @@ -39,17 +39,17 @@ pub struct RebalanceCreateWithdrawRequestFromCredixLpDepository<'info> { )] pub controller: AccountLoader<'info, Controller>, - /// #6 + /// #3 pub collateral_mint: Box>, - /// #3 + /// #4 #[account( mut, has_one = collateral_mint @UxdError::InvalidCollateralMint, )] pub identity_depository: AccountLoader<'info, IdentityDepository>, - /// #4 + /// #5 #[account( mut, has_one = controller @UxdError::InvalidController, @@ -57,7 +57,7 @@ pub struct RebalanceCreateWithdrawRequestFromCredixLpDepository<'info> { )] pub mercurial_vault_depository: AccountLoader<'info, MercurialVaultDepository>, - /// #5 + /// #6 #[account( mut, has_one = controller @UxdError::InvalidController, @@ -118,7 +118,7 @@ pub struct RebalanceCreateWithdrawRequestFromCredixLpDepository<'info> { )] pub credix_withdraw_epoch: Account<'info, credix_client::WithdrawEpoch>, - /// #6 + /// #14 #[account( mut, has_one = controller @UxdError::InvalidController, @@ -126,9 +126,9 @@ pub struct RebalanceCreateWithdrawRequestFromCredixLpDepository<'info> { )] pub alloyx_vault_depository: AccountLoader<'info, AlloyxVaultDepository>, - /// #14 - pub system_program: Program<'info, System>, /// #15 + pub system_program: Program<'info, System>, + /// #16 pub credix_program: Program<'info, credix_client::program::Credix>, } diff --git a/programs/uxd/src/instructions/credix_lp/rebalance_redeem_withdraw_request_from_credix_lp_depository.rs b/programs/uxd/src/instructions/credix_lp/rebalance_redeem_withdraw_request_from_credix_lp_depository.rs index 38d4f16ad..9595332b4 100644 --- a/programs/uxd/src/instructions/credix_lp/rebalance_redeem_withdraw_request_from_credix_lp_depository.rs +++ b/programs/uxd/src/instructions/credix_lp/rebalance_redeem_withdraw_request_from_credix_lp_depository.rs @@ -46,10 +46,10 @@ pub struct RebalanceRedeemWithdrawRequestFromCredixLpDepository<'info> { )] pub controller: AccountLoader<'info, Controller>, - /// #7 + /// #3 pub collateral_mint: Box>, - /// #3 + /// #4 #[account( mut, has_one = collateral_mint @UxdError::InvalidCollateralMint, @@ -57,11 +57,11 @@ pub struct RebalanceRedeemWithdrawRequestFromCredixLpDepository<'info> { )] pub identity_depository: AccountLoader<'info, IdentityDepository>, - /// #4 + /// #5 #[account(mut)] pub identity_depository_collateral: Box>, - /// #5 + /// #6 #[account( mut, has_one = controller @UxdError::InvalidController, @@ -69,7 +69,7 @@ pub struct RebalanceRedeemWithdrawRequestFromCredixLpDepository<'info> { )] pub mercurial_vault_depository: AccountLoader<'info, MercurialVaultDepository>, - /// #6 + /// #7 #[account( mut, has_one = controller @UxdError::InvalidController, @@ -167,7 +167,7 @@ pub struct RebalanceRedeemWithdrawRequestFromCredixLpDepository<'info> { )] pub credix_withdraw_epoch: Account<'info, credix_client::WithdrawEpoch>, - /// #6 + /// #20 #[account( mut, has_one = controller @UxdError::InvalidController, @@ -175,22 +175,22 @@ pub struct RebalanceRedeemWithdrawRequestFromCredixLpDepository<'info> { )] pub alloyx_vault_depository: AccountLoader<'info, AlloyxVaultDepository>, - /// #20 + /// #21 #[account( mut, token::mint = collateral_mint, )] pub profits_beneficiary_collateral: Box>, - /// #21 - pub system_program: Program<'info, System>, /// #22 - pub token_program: Program<'info, Token>, + pub system_program: Program<'info, System>, /// #23 - pub associated_token_program: Program<'info, AssociatedToken>, + pub token_program: Program<'info, Token>, /// #24 - pub credix_program: Program<'info, credix_client::program::Credix>, + pub associated_token_program: Program<'info, AssociatedToken>, /// #25 + pub credix_program: Program<'info, credix_client::program::Credix>, + /// #26 pub rent: Sysvar<'info, Rent>, } diff --git a/programs/uxd/src/instructions/edit_controller.rs b/programs/uxd/src/instructions/edit_controller.rs index a4727ce1c..4c7ab966a 100644 --- a/programs/uxd/src/instructions/edit_controller.rs +++ b/programs/uxd/src/instructions/edit_controller.rs @@ -208,7 +208,10 @@ impl<'info> EditController<'info> { depositories_routing_weight_bps.identity_depository_weight_bps, depositories_routing_weight_bps.mercurial_vault_depository_weight_bps, )?, - depositories_routing_weight_bps.credix_lp_depository_weight_bps, + checked_add( + depositories_routing_weight_bps.credix_lp_depository_weight_bps, + depositories_routing_weight_bps.alloyx_vault_depository_weight_bps, + )?, )?; require!( u64::from(total_weight_bps) == BPS_POWER, diff --git a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/mod.rs b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/mod.rs index c95fccd90..2b299e02b 100644 --- a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/mod.rs +++ b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/mod.rs @@ -1,5 +1,7 @@ pub mod process_deploy_program; -pub mod process_set_router_depositories; +pub mod process_set_controller_router_depositories; +pub mod process_setup_router_depositories_fields; pub use process_deploy_program::*; -pub use process_set_router_depositories::*; +pub use process_set_controller_router_depositories::*; +pub use process_setup_router_depositories_fields::*; diff --git a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_deploy_program.rs b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_deploy_program.rs index af3970472..09f789ba7 100644 --- a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_deploy_program.rs +++ b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_deploy_program.rs @@ -292,7 +292,7 @@ pub async fn process_deploy_program( .await?; // Make sure the controller has the proper router depositories set - program_uxd::procedures::process_set_router_depositories( + program_uxd::procedures::process_set_controller_router_depositories( program_context, payer, authority, diff --git a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_set_router_depositories.rs b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_set_controller_router_depositories.rs similarity index 97% rename from programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_set_router_depositories.rs rename to programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_set_controller_router_depositories.rs index c906bc949..b357607eb 100644 --- a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_set_router_depositories.rs +++ b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_set_controller_router_depositories.rs @@ -11,7 +11,7 @@ use crate::integration_tests::api::program_credix; use crate::integration_tests::api::program_mercurial; use crate::integration_tests::api::program_uxd; -pub async fn process_set_router_depositories( +pub async fn process_set_controller_router_depositories( program_context: &mut Box, payer: &Keypair, authority: &Keypair, diff --git a/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_setup_router_depositories_fields.rs b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_setup_router_depositories_fields.rs new file mode 100644 index 000000000..6dab2be02 --- /dev/null +++ b/programs/uxd/tests/integration_tests/api/program_uxd/procedures/process_setup_router_depositories_fields.rs @@ -0,0 +1,85 @@ +use solana_sdk::pubkey::Pubkey; +use solana_sdk::signature::Keypair; + +use uxd::instructions::EditCredixLpDepositoryFields; +use uxd::instructions::EditIdentityDepositoryFields; +use uxd::instructions::EditMercurialVaultDepositoryFields; +use uxd::instructions::EditAlloyxVaultDepositoryFields; + +use crate::integration_tests::api::program_context; +use crate::integration_tests::api::program_uxd; + +pub async fn process_setup_router_depositories_fields( + program_context: &mut Box, + payer: &Keypair, + authority: &Keypair, + collateral_mint: &Pubkey, + supply_cap: u64, + minting_fee_in_bps: Option, + redeeming_fee_in_bps: Option, + minting_disabled: Option, + profits_beneficiary_collateral: Option, +) -> Result<(), program_context::ProgramError> { + // Set the identity_depository cap and make sure minting is not disabled + program_uxd::instructions::process_edit_identity_depository( + program_context, + payer, + authority, + &EditIdentityDepositoryFields { + redeemable_amount_under_management_cap: Some(supply_cap.into()), + minting_disabled, + }, + ) + .await?; + + // Set the mercurial_vault_depository cap and make sure minting is not disabled + program_uxd::instructions::process_edit_mercurial_vault_depository( + program_context, + payer, + authority, + collateral_mint, + &EditMercurialVaultDepositoryFields { + redeemable_amount_under_management_cap: Some(supply_cap.into()), + minting_fee_in_bps, + redeeming_fee_in_bps, + minting_disabled, + profits_beneficiary_collateral, + }, + ) + .await?; + + // Set the credix_lp_depository cap and make sure minting is not disabled + program_uxd::instructions::process_edit_credix_lp_depository( + program_context, + payer, + authority, + collateral_mint, + &EditCredixLpDepositoryFields { + redeemable_amount_under_management_cap: Some(supply_cap.into()), + minting_fee_in_bps, + redeeming_fee_in_bps, + minting_disabled, + profits_beneficiary_collateral, + }, + ) + .await?; + + // Set the alloyx_vault_depository cap and make sure minting is not disabled + program_uxd::instructions::process_edit_alloyx_vault_depository( + program_context, + payer, + authority, + collateral_mint, + &EditAlloyxVaultDepositoryFields { + redeemable_amount_under_management_cap: Some(supply_cap), + minting_fee_in_bps, + redeeming_fee_in_bps, + minting_disabled, + profits_beneficiary_collateral, + }, + ) + .await?; + + // Done + Ok(()) +} diff --git a/programs/uxd/tests/integration_tests/suites/test_controller_edit.rs b/programs/uxd/tests/integration_tests/suites/test_controller_edit.rs index 884c60821..0e122393c 100644 --- a/programs/uxd/tests/integration_tests/suites/test_controller_edit.rs +++ b/programs/uxd/tests/integration_tests/suites/test_controller_edit.rs @@ -121,8 +121,8 @@ async fn test_controller_edit() -> Result<(), program_context::ProgramError> { depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { identity_depository_weight_bps: 25 * 100, // 25% mercurial_vault_depository_weight_bps: 35 * 100, // 35% - credix_lp_depository_weight_bps: 40 * 100, // 40% - alloyx_vault_depository_weight_bps: 0, // 0% + credix_lp_depository_weight_bps: 30 * 100, // 30% + alloyx_vault_depository_weight_bps: 10 * 100, // 10% }), router_depositories: None, outflow_limit_per_epoch_amount: None, @@ -179,8 +179,8 @@ async fn test_controller_edit() -> Result<(), program_context::ProgramError> { depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { identity_depository_weight_bps: 20 * 100, // 20% mercurial_vault_depository_weight_bps: 30 * 100, // 30% - credix_lp_depository_weight_bps: 50 * 100, // 50% - alloyx_vault_depository_weight_bps: 0, // 0% + credix_lp_depository_weight_bps: 40 * 100, // 40% + alloyx_vault_depository_weight_bps: 10 * 100, // 10% }), router_depositories: Some(EditRouterDepositories { identity_depository: Pubkey::default(), diff --git a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_illiquid.rs b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_illiquid.rs index 454644cc6..26aea1dc3 100644 --- a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_illiquid.rs +++ b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_illiquid.rs @@ -5,10 +5,7 @@ use solana_sdk::signer::Signer; use spl_token::state::Account; use uxd::instructions::EditControllerFields; -use uxd::instructions::EditCredixLpDepositoryFields; use uxd::instructions::EditDepositoriesRoutingWeightBps; -use uxd::instructions::EditIdentityDepositoryFields; -use uxd::instructions::EditMercurialVaultDepositoryFields; use crate::integration_tests::api::program_context; use crate::integration_tests::api::program_credix; @@ -125,10 +122,10 @@ async fn test_credix_lp_depository_rebalance_illiquid() -> Result<(), program_co &EditControllerFields { redeemable_global_supply_cap: Some(amount_we_use_as_supply_cap.into()), depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { - identity_depository_weight_bps: 50 * 100, - mercurial_vault_depository_weight_bps: 25 * 100, - credix_lp_depository_weight_bps: 25 * 100, - alloyx_vault_depository_weight_bps: 0, + identity_depository_weight_bps: 40 * 100, // 40% + mercurial_vault_depository_weight_bps: 25 * 100, // 25% + credix_lp_depository_weight_bps: 25 * 100, // 25% + alloyx_vault_depository_weight_bps: 10 * 100, // 10% }), router_depositories: None, outflow_limit_per_epoch_amount: None, @@ -139,7 +136,7 @@ async fn test_credix_lp_depository_rebalance_illiquid() -> Result<(), program_co .await?; // Now we set the router depositories to the correct PDAs - program_uxd::procedures::process_set_router_depositories( + program_uxd::procedures::process_set_controller_router_depositories( &mut program_context, &payer, &authority, @@ -147,47 +144,17 @@ async fn test_credix_lp_depository_rebalance_illiquid() -> Result<(), program_co ) .await?; - // Set the identity_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_identity_depository( - &mut program_context, - &payer, - &authority, - &EditIdentityDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_disabled: Some(false), - }, - ) - .await?; - - // Set the mercurial_vault_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_mercurial_vault_depository( - &mut program_context, - &payer, - &authority, - &collateral_mint.pubkey(), - &EditMercurialVaultDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, - ) - .await?; - - // Set the credix_lp_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_credix_lp_depository( + // Setup the fees, caps and profits beneficiary for router depositories + program_uxd::procedures::process_setup_router_depositories_fields( &mut program_context, &payer, &authority, &collateral_mint.pubkey(), - &EditCredixLpDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, + amount_we_use_as_supply_cap, + Some(100), + Some(100), + Some(false), + Some(profits_beneficiary_collateral), ) .await?; diff --git a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_liquid.rs b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_liquid.rs index 57c82b407..ea34d57ce 100644 --- a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_liquid.rs +++ b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_liquid.rs @@ -4,10 +4,7 @@ use solana_sdk::signer::keypair::Keypair; use solana_sdk::signer::Signer; use uxd::instructions::EditControllerFields; -use uxd::instructions::EditCredixLpDepositoryFields; use uxd::instructions::EditDepositoriesRoutingWeightBps; -use uxd::instructions::EditIdentityDepositoryFields; -use uxd::instructions::EditMercurialVaultDepositoryFields; use crate::integration_tests::api::program_context; use crate::integration_tests::api::program_credix; @@ -122,10 +119,10 @@ async fn test_credix_lp_depository_rebalance_liquid() -> Result<(), program_cont &EditControllerFields { redeemable_global_supply_cap: Some(amount_we_use_as_supply_cap.into()), depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { - identity_depository_weight_bps: 50 * 100, - mercurial_vault_depository_weight_bps: 25 * 100, - credix_lp_depository_weight_bps: 25 * 100, - alloyx_vault_depository_weight_bps: 0, + identity_depository_weight_bps: 40 * 100, // 40% + mercurial_vault_depository_weight_bps: 25 * 100, // 25% + credix_lp_depository_weight_bps: 25 * 100, // 25% + alloyx_vault_depository_weight_bps: 10 * 100, // 10% }), router_depositories: None, outflow_limit_per_epoch_amount: None, @@ -136,7 +133,7 @@ async fn test_credix_lp_depository_rebalance_liquid() -> Result<(), program_cont .await?; // Now we set the router depositories to the correct PDAs - program_uxd::procedures::process_set_router_depositories( + program_uxd::procedures::process_set_controller_router_depositories( &mut program_context, &payer, &authority, @@ -144,47 +141,17 @@ async fn test_credix_lp_depository_rebalance_liquid() -> Result<(), program_cont ) .await?; - // Set the identity_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_identity_depository( - &mut program_context, - &payer, - &authority, - &EditIdentityDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_disabled: Some(false), - }, - ) - .await?; - - // Set the mercurial_vault_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_mercurial_vault_depository( - &mut program_context, - &payer, - &authority, - &collateral_mint.pubkey(), - &EditMercurialVaultDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, - ) - .await?; - - // Set the credix_lp_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_credix_lp_depository( + // Setup the fees, caps and profits beneficiary for router depositories + program_uxd::procedures::process_setup_router_depositories_fields( &mut program_context, &payer, &authority, &collateral_mint.pubkey(), - &EditCredixLpDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, + amount_we_use_as_supply_cap, + Some(100), + Some(100), + Some(false), + Some(profits_beneficiary_collateral), ) .await?; diff --git a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_no_overflow.rs b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_no_overflow.rs index 08ff2c977..095630ffd 100644 --- a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_no_overflow.rs +++ b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_no_overflow.rs @@ -4,10 +4,7 @@ use solana_sdk::signer::keypair::Keypair; use solana_sdk::signer::Signer; use uxd::instructions::EditControllerFields; -use uxd::instructions::EditCredixLpDepositoryFields; use uxd::instructions::EditDepositoriesRoutingWeightBps; -use uxd::instructions::EditIdentityDepositoryFields; -use uxd::instructions::EditMercurialVaultDepositoryFields; use crate::integration_tests::api::program_context; use crate::integration_tests::api::program_credix; @@ -136,7 +133,7 @@ async fn test_credix_lp_depository_rebalance_no_overflow( .await?; // Now we set the router depositories to the correct PDAs - program_uxd::procedures::process_set_router_depositories( + program_uxd::procedures::process_set_controller_router_depositories( &mut program_context, &payer, &authority, @@ -144,47 +141,17 @@ async fn test_credix_lp_depository_rebalance_no_overflow( ) .await?; - // Set the identity_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_identity_depository( - &mut program_context, - &payer, - &authority, - &EditIdentityDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_disabled: Some(false), - }, - ) - .await?; - - // Set the mercurial_vault_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_mercurial_vault_depository( - &mut program_context, - &payer, - &authority, - &collateral_mint.pubkey(), - &EditMercurialVaultDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, - ) - .await?; - - // Set the credix_lp_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_credix_lp_depository( + // Setup the fees, caps and profits beneficiary for router depositories + program_uxd::procedures::process_setup_router_depositories_fields( &mut program_context, &payer, &authority, &collateral_mint.pubkey(), - &EditCredixLpDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, + amount_we_use_as_supply_cap, + Some(100), + Some(100), + Some(false), + Some(profits_beneficiary_collateral), ) .await?; diff --git a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_under_requested.rs b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_under_requested.rs index 167dc39e9..d30935b2f 100644 --- a/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_under_requested.rs +++ b/programs/uxd/tests/integration_tests/suites/test_credix_lp_depository_rebalance_under_requested.rs @@ -4,10 +4,7 @@ use solana_sdk::signer::keypair::Keypair; use solana_sdk::signer::Signer; use uxd::instructions::EditControllerFields; -use uxd::instructions::EditCredixLpDepositoryFields; use uxd::instructions::EditDepositoriesRoutingWeightBps; -use uxd::instructions::EditIdentityDepositoryFields; -use uxd::instructions::EditMercurialVaultDepositoryFields; use crate::integration_tests::api::program_context; use crate::integration_tests::api::program_credix; @@ -127,10 +124,10 @@ async fn test_credix_lp_depository_rebalance_under_requested( &EditControllerFields { redeemable_global_supply_cap: Some(amount_we_use_as_supply_cap.into()), depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { - identity_depository_weight_bps: 25 * 100, - mercurial_vault_depository_weight_bps: 25 * 100, - credix_lp_depository_weight_bps: 50 * 100, - alloyx_vault_depository_weight_bps: 0, + identity_depository_weight_bps: 15 * 100, // 15% + mercurial_vault_depository_weight_bps: 25 * 100, // 25% + credix_lp_depository_weight_bps: 50 * 100, // 50% + alloyx_vault_depository_weight_bps: 10 * 100, // 10% }), router_depositories: None, outflow_limit_per_epoch_amount: None, @@ -141,7 +138,7 @@ async fn test_credix_lp_depository_rebalance_under_requested( .await?; // Now we set the router depositories to the correct PDAs - program_uxd::procedures::process_set_router_depositories( + program_uxd::procedures::process_set_controller_router_depositories( &mut program_context, &payer, &authority, @@ -149,47 +146,17 @@ async fn test_credix_lp_depository_rebalance_under_requested( ) .await?; - // Set the identity_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_identity_depository( - &mut program_context, - &payer, - &authority, - &EditIdentityDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_disabled: Some(false), - }, - ) - .await?; - - // Set the mercurial_vault_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_mercurial_vault_depository( - &mut program_context, - &payer, - &authority, - &collateral_mint.pubkey(), - &EditMercurialVaultDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, - ) - .await?; - - // Set the credix_lp_depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_credix_lp_depository( + // Setup the fees, caps and profits beneficiary for router depositories + program_uxd::procedures::process_setup_router_depositories_fields( &mut program_context, &payer, &authority, &collateral_mint.pubkey(), - &EditCredixLpDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(100), - redeeming_fee_in_bps: Some(100), - minting_disabled: Some(false), - profits_beneficiary_collateral: Some(profits_beneficiary_collateral), - }, + amount_we_use_as_supply_cap, + Some(100), + Some(100), + Some(false), + Some(profits_beneficiary_collateral), ) .await?; diff --git a/programs/uxd/tests/integration_tests/suites/test_mint_and_redeem.rs b/programs/uxd/tests/integration_tests/suites/test_mint_and_redeem.rs index 3cbc58bf6..294bbf809 100644 --- a/programs/uxd/tests/integration_tests/suites/test_mint_and_redeem.rs +++ b/programs/uxd/tests/integration_tests/suites/test_mint_and_redeem.rs @@ -4,10 +4,7 @@ use solana_sdk::signer::keypair::Keypair; use solana_sdk::signer::Signer; use uxd::instructions::EditControllerFields; -use uxd::instructions::EditCredixLpDepositoryFields; use uxd::instructions::EditDepositoriesRoutingWeightBps; -use uxd::instructions::EditIdentityDepositoryFields; -use uxd::instructions::EditMercurialVaultDepositoryFields; use uxd::instructions::EditRouterDepositories; use crate::integration_tests::api::program_context; @@ -89,7 +86,7 @@ async fn test_mint_and_redeem() -> Result<(), program_context::ProgramError> { let amount_of_collateral_airdropped_to_user = amount_for_first_mint + amount_for_second_mint; // Just enough money to mint // Post mint supply should match the configured weights - let identity_depository_supply_after_first_mint = amount_for_first_mint * 10 / 100; + let identity_depository_supply_after_first_mint = amount_for_first_mint * 30 / 100; let mercurial_vault_depository_supply_after_first_mint = amount_for_first_mint * 50 / 100; let credix_lp_depository_supply_after_first_mint = amount_for_first_mint * 40 / 100; @@ -129,10 +126,10 @@ async fn test_mint_and_redeem() -> Result<(), program_context::ProgramError> { &EditControllerFields { redeemable_global_supply_cap: Some(amount_we_use_as_supply_cap.into()), depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { - identity_depository_weight_bps: 10 * 100, - mercurial_vault_depository_weight_bps: 50 * 100, - credix_lp_depository_weight_bps: 40 * 100, - alloyx_vault_depository_weight_bps: 0, + identity_depository_weight_bps: 10 * 100, // 10% + mercurial_vault_depository_weight_bps: 30 * 100, // 30% + credix_lp_depository_weight_bps: 30 * 100, // 30% + alloyx_vault_depository_weight_bps: 30 * 100, // 30% }), router_depositories: None, outflow_limit_per_epoch_amount: None, @@ -142,47 +139,17 @@ async fn test_mint_and_redeem() -> Result<(), program_context::ProgramError> { ) .await?; - // Set the depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_identity_depository( - &mut program_context, - &payer, - &authority, - &EditIdentityDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_disabled: Some(false), - }, - ) - .await?; - - // Set the depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_mercurial_vault_depository( - &mut program_context, - &payer, - &authority, - &collateral_mint.pubkey(), - &EditMercurialVaultDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(0), - redeeming_fee_in_bps: Some(0), - minting_disabled: Some(false), - profits_beneficiary_collateral: None, - }, - ) - .await?; - - // Set the depository cap and make sure minting is not disabled - program_uxd::instructions::process_edit_credix_lp_depository( + // Setup the fees, caps and profits beneficiary for router depositories + program_uxd::procedures::process_setup_router_depositories_fields( &mut program_context, &payer, &authority, &collateral_mint.pubkey(), - &EditCredixLpDepositoryFields { - redeemable_amount_under_management_cap: Some(amount_we_use_as_supply_cap.into()), - minting_fee_in_bps: Some(0), - redeeming_fee_in_bps: Some(0), - minting_disabled: Some(false), - profits_beneficiary_collateral: None, - }, + amount_we_use_as_supply_cap, + Some(0), + Some(0), + Some(false), + None, ) .await?; @@ -230,7 +197,7 @@ async fn test_mint_and_redeem() -> Result<(), program_context::ProgramError> { .is_err()); // Now we set the router depositories to the correct PDAs - program_uxd::procedures::process_set_router_depositories( + program_uxd::procedures::process_set_controller_router_depositories( &mut program_context, &payer, &authority, @@ -267,10 +234,10 @@ async fn test_mint_and_redeem() -> Result<(), program_context::ProgramError> { &EditControllerFields { redeemable_global_supply_cap: None, depositories_routing_weight_bps: Some(EditDepositoriesRoutingWeightBps { - identity_depository_weight_bps: 10 * 100, - mercurial_vault_depository_weight_bps: 40 * 100, - credix_lp_depository_weight_bps: 50 * 100, - alloyx_vault_depository_weight_bps: 0, + identity_depository_weight_bps: 10 * 100, // 10% + mercurial_vault_depository_weight_bps: 30 * 100, // 30% + credix_lp_depository_weight_bps: 50 * 100, // 50% + alloyx_vault_depository_weight_bps: 10 * 100, // 10% }), router_depositories: None, outflow_limit_per_epoch_amount: None,