AAVE V1 's redeem() function requires us to wait for COOLDOWN_SECONDS and withdraw money in UNSTAKE_WINDOW.

   * @dev Redeems staked tokens, and stop earning rewards
   * @param to Address to redeem to
   * @param amount Amount to redeem
  function redeem(address to, uint256 amount) external override {
    require(amount != 0, 'INVALID_ZERO_AMOUNT');

    uint256 cooldownStartTimestamp = stakersCooldowns[msg.sender];

      block.timestamp > cooldownStartTimestamp.add(COOLDOWN_SECONDS),
      block.timestamp.sub(cooldownStartTimestamp.add(COOLDOWN_SECONDS)) <= UNSTAKE_WINDOW,
    uint256 balanceOfMessageSender = balanceOf(msg.sender);

    uint256 amountToRedeem = (amount > balanceOfMessageSender) ? balanceOfMessageSender : amount;

    _updateCurrentUnclaimedRewards(msg.sender, balanceOfMessageSender, true);

    _burn(msg.sender, amountToRedeem);

    if (balanceOfMessageSender.sub(amountToRedeem) == 0) {
      stakersCooldowns[msg.sender] = 0;

    IERC20(STAKED_TOKEN).safeTransfer(to, amountToRedeem);

    emit Redeem(msg.sender, to, amountToRedeem);

   * @dev Activates the cooldown period to unstake
   * - It can't be called if the user is not staking
  function cooldown() external override {
    require(balanceOf(msg.sender) != 0, "INVALID_BALANCE_ON_COOLDOWN");
    stakersCooldowns[msg.sender] = block.timestamp;

    emit Cooldown(msg.sender);

The unstake window is 2 days after the cooldown completes. If you don't unstake during this time, you'll have to activate the cooldown again. link : https://twitter.com/AaveAave/status/1347250535087419402

My question 1: waiting for COOLDOWN_SECONDS to call redeem() is to make sure that users can not stake and redeem again and again in a short time. But why? What will happend if stake and redeem again and again in a short time.

My question 2: why design UNSTAKE_WINDOW? We need to call cooldown() ,wait for another time and must withdraw in UNSTAKE_WINDOW time. It costs more gas and it's not convenient for users. Maybe it is for security or the Business Logic of AAVE.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.