Open hats-bug-reporter[bot] opened 4 months ago
Thank you for the submission.
I wanted to see options in which this or that mode will really break something without assumptions.
AlgebraPool is basically able to work with rebasing tokens. Testing shows that AlgebraPool works as expected and correctly regardless of the mode of the Rebasing token.
Github username: @zilayo Twitter username: -- Submission hash (on-chain): 0x74b2a565bdb8bb5552c8030e68c51c3051e3df9637fd1a276ed00b82efa3ed51 Severity: medium
Description: Description\
AlgebraPool
contracts inherit fromBlastERC20RebasingManage
which allows claiming & configuring yield mode from the Blast rebasing ERC20s.Blast's rebasing ERC20s have a few differences to standard ERC20, and careful consideration needs to be given - especially in protocols which rely heavily on accurate accounting.
The main differences are around balance calculations, and how
transfer
/transferFrom
operates.Unless an account with the
POOLS_ADMINISTRATOR
role configures theYieldMode
, all pools will beYieldAutomatic
by default. This means thatbalanceOf
,transfer
, andtransferFrom
calls will utilize theshares
andremainder
values to calculate balances and amounts to transfer.Since a
YieldAutomatic
account calculates amounts based on the underlying share price of the rebasing tokens, this may break certain invariants / assumptions that the contract has about it's own balances.It is unreasonable for a
POOLS_ADMINISTRATOR
account to manually configure each and every pool that's created, so ideally theYieldMode
should be set during pool initialization.In addition, the function to configure yield modes for the Algebra Pools don't have any safeguards against setting it to
YieldAutomatic
In the event that the
YieldMode
is misconfigured, this will also lead to the above issues.Given that there is also functionality to claim accumulated yields, I assume that the intention is to have these pools be set to
YieldClaimable
.It's important to note that attempts to claim yield will revert unless the contract is set to
YieldClaimable
:Recommendations
YieldMode
should be set to eitherYieldClaimable
orYieldVoid
upon pool deployment. This will avoid any issues caused by balances changing, whilst remaining static within the pool's internal accounting.One option is to set the YieldMode for USDB & WETH in all pools to
YieldClaimable
by default. Alternatively logic could be placed elsewhere to configure only the relevant rebasing contract, depending on which tokens are in the pair.Safeguards should be placed to prevent the
YieldMode
from ever being set toAutomatic
: