Skip to content

Commit

Permalink
M-07
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes committed Jul 14, 2023
1 parent 94c4e51 commit f8d0bf7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions contracts/transmuter/facets/Redeemer.sol
Expand Up @@ -44,7 +44,7 @@ contract Redeemer is IRedeemer, AccessControlModifiers {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc IRedeemer
/// @dev The `minAmountOuts` list must reflect or be longer than the amount of `tokens` returned
/// @dev The `minAmountOuts` list must reflect the amount of `tokens` returned
/// @dev In normal conditions, the amount of tokens outputted by this function should be the amount
/// of collateral assets supported by the system, following their order in the `collateralList`.
/// @dev If one collateral has its liquidity managed through strategies, then it's possible that this asset
Expand Down Expand Up @@ -108,10 +108,15 @@ contract Redeemer is IRedeemer, AccessControlModifiers {
address[] memory forfeitTokens
) internal nonReentrant returns (address[] memory tokens, uint256[] memory amounts) {
TransmuterStorage storage ts = s.transmuterStorage();

if (ts.isRedemptionLive == 0) revert Paused();
if (block.timestamp > deadline) revert TooLate();

uint256[] memory subCollateralsTracker;
(tokens, amounts, subCollateralsTracker) = _quoteRedemptionCurve(amount);
// Check that the provided slippage tokens length is identical to the redeem one
uint256 amountsLength = amounts.length;
if (amountsLength != minAmountOuts.length) revert InvalidLengths();
// Updating the normalizer enables to simultaneously and proportionally reduce the amount
// of stablecoins issued from each collateral without having to loop through each of them
_updateNormalizer(amount, false);
Expand All @@ -120,7 +125,7 @@ contract Redeemer is IRedeemer, AccessControlModifiers {

address[] memory collateralListMem = ts.collateralList;
uint256 indexCollateral;
for (uint256 i; i < amounts.length; ++i) {
for (uint256 i; i < amountsLength; ++i) {
if (amounts[i] < minAmountOuts[i]) revert TooSmallAmountOut();
// If a token is in the `forfeitTokens` list, then it is not sent as part of the redemption process
if (amounts[i] > 0 && LibHelpers.checkList(tokens[i], forfeitTokens) < 0) {
Expand Down Expand Up @@ -197,7 +202,7 @@ contract Redeemer is IRedeemer, AccessControlModifiers {
// For each asset, we store the actual amount of stablecoins issued based on the `newNormalizerValue`
// (and not a normalized value)
// We ensure to preserve the invariant `sum(collateralNewNormalizedStables) = normalizedStables`
uint128 newNormalizedStables = 0;
uint128 newNormalizedStables;
for (uint256 i; i < collateralListLength; ++i) {
uint128 newCollateralNormalizedStable = ((uint256(
ts.collaterals[collateralListMem[i]].normalizedStables
Expand Down

0 comments on commit f8d0bf7

Please sign in to comment.