📄

Report #13773

Report Date
November 20, 2022
Status
Closed
Payout

Possible Bug - withdrawDeposit

Report Info

BIC Response

Thank you for your report. This behavior occurs because of the calling of diamond.sunrise(). Beanstalk rewards the caller of this function with Beans to incentivize decentralized actors to call the function once per hour. You can learn more about it here: https://docs.bean.money/farm/sun

The sunrise() function can be found in SeasonFacet.sol. The reward beans are delivered in this line:

        incentivize(msg.sender, C.getAdvanceIncentive());

The number of Beans rewarded depends on how long after the hour the sunrise function is called (the longer the wait, the more Beanstalk is willing to pay). It caps out around ~2000 BEAN. You'll notice that the amount received is 1978821989 (1,978_821989).

Some other notes on Beanstalk's behavior that you may find useful in future investigations:

  1. No BEAN is transferred during withdrawDeposit, because the user must wait until the next season to claim the tokens from their withdrawal. In your test, you can see this by placing a balanceOf call before and after the withdrawDeposit like so:
    console.log("Bean balance of user after Sunrise, before withdrawDeposit :", bean.balanceOf(address(this)));
    diamond.withdrawDeposit(address(bean), 8487, 1);
    console.log("Bean balance of user after Sunrise, after withdrawDeposit :", bean.balanceOf(address(this)));
  This 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
  Bean balance user before deal : 0
  Bean balance of user before : 1
  Bean balance of user after Sunrise, before withdrawDeposit : 1978821989
  Bean balance of user after Sunrise, after withdrawDeposit : 1978821989
  1. "External mode" only applies when tokens are transferred; there is a FromMode parameter on the deposit function, but not on the withdrawDeposit function since it doesn't transfer any tokens (transfer happens during claimWithdrawal).

Due to the reasons outlined above, we are closing the submission and no reward will be issued.