Beanstalk is currently overpaying for Sunrise function calls. We propose changing the base incentive for Farmers to call the Sunrise function
gasUsed = min(deltaGas + GAS_OVERHEAD, MAX_SUNRISE_GAS)
gasFee = blockBaseGasFee + PRIORITY_FEE_BUFFER
sunriseReward = max(min(gasFee * gasUsed * beanEtherPrice + BASE_REWARD, MAX_REWARD), MIN_PAYOUT)
Where:
deltaGas
-> delta of gasleft()
at the start and end of transactionGAS_OVERHEAD
→ Estimated gas overhead not included in deltaGas
. Equal to 21k plus gas cost of paying callerMAX_SUNRISE_GAS
-> manipulation protection parameter. Determine the maximum possible gas cost of performing a Sunrise call (Probs when SOP occurs)blockBaseGasFee
-> block.basefeegasUsed
PRIORITY_FEE_BUFFER
-> Overestimation of maximum required priorityFee to call sunrise()
transactions. (We can access the baseGasFee
but not the priorityFee
in Solidity). Maybe start at 5?beanEtherPrice
-> 2 options:
MAX_REWARD
→ A max base reward to prevent manipulation (Probs =100 Beans as that is what it is now)BASE_REWARD
→ A fixed increase in Bean reward to cover costs of operating sunrise()
bots.MIN_REWARD
→ The minimum reward to payout.This solution seeks the mathematically minimize the number of Beans that Beanstalk needs to pay for the sunrise()
call.
The cost to execute a sunrise()
transaction in Beans is:
gasUsed * (baseGasFee + priorityFee) * beanEthPrice
This solution computes an on-chain estimation of the above formula function while adding sufficient tunable parameters to properly account for estimation error and potential manipulation.