Skip to content

Commit

Permalink
adding-small-additional-require
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-vincent committed Aug 19, 2024
1 parent ed937b3 commit 27080af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ pub(crate) fn handler(
/ redeemable_amount_under_management,
)?;

// Check the amount swapped is non-zero
require!(
exchanged_shares_amount > 0,
UxdError::InvalidCollateralAmount
);

msg!(
"[redeemable_amount_under_management:{}]",
redeemable_amount_under_management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ async fn test_credix_lp_depository_exchange_liquidity() -> Result<(), program_co
)
.await?;

// Exchanging 0 should fail
assert!(
program_uxd::instructions::process_exchange_liquidity_with_credix_lp_depository(
&mut program_context,
&payer,
&collateral_mint.pubkey(),
&user,
&user_collateral,
&receiver_credix_shares,
0,
)
.await
.is_err()
);

// Proceed to the exchange in 2 separate partial transaction
let credix_lp_depository_redeemable_amount_under_management =
credix_lp_depository_collateral_amount_minted - 1; // precision-loss
Expand Down

0 comments on commit 27080af

Please sign in to comment.