```\n if (amountIn > 0) {\n            // We calculate the exchange rate and the amount of underlying to be redeemed:\n            // uTokenAmount = amountIn\n            // underlyingAmount = amountIn x exchangeRateCurrent\n            uTokenAmount = amountIn;\n            underlyingAmount = (amountIn * exchangeRate) / WAD;\n        } else {\n            // We get the current exchange rate and calculate the amount to be redeemed:\n            // uTokenAmount = amountOut / exchangeRate\n            // underlyingAmount = amountOut\n            uTokenAmount = (amountOut * WAD) / exchangeRate;\n            underlyingAmount = amountOut;\n        }\n```\n