This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
cducrest-brainbot - Accounting error for TAU currentMinted #50
Labels
Non-Reward
This issue will not receive a payout
cducrest-brainbot
medium
Accounting error for TAU currentMinted
Summary
Due to accounting error in minted / burned TAU for vaults, it could be that a vault has more total debt than
TAU.currentMinted[vault]
, which will escalate into more accounting errors over time and may lead to reaching the mint limit set byTAU.sol
prematurely.Vulnerability Detail
The TAU token contract has limits set for each vault for the maximum amount of TAU that can be minted by the vault. This limit is set by the governance address.
When a vault mints token, the tracked amount of TAU minted by the vault is increased and the mint reverts if the amount exceeds the vault's limit. When a vault burns token using
burn()
,currentMinted[vault]
decreases by the burned amount if it is not bigger than the current minted amount for the vault.The
SwapHandler.swapForTau()
function swaps yield received for TAU, burns the TAU (so decreases currentMinted[vault]) and rewards users by repaying their debt for a portion of the burned TAU based on the_rewardProportion
value. Since only a portion of the burnt TAU repays debt, the total outstanding debt of the vault is higher thancurrentMinted[vault]
.If users repay their debts, we will reach a moment where
currentMinted[vault]
is lower than the amount of debt repaid by a user. At this point thecurrentMinted[vault]
will not be lowered by the amount of TAU burnt in the debt repayment.As result the
currentMinted[vault]
value can be higher than the value the vault actually minted.This issue can be repeated multiple times to further decorrelate the
currentMinted[vault]
value from its correct value. The issue amplifies itself as the more wrong this value is, the more likely it is that user repaid debt exceedscurrentMinted[vault]
.Impact
Accounting of
currentMinted[vault]
is not properly done and may bring vaults to reach the mint limit faster than planned, preventing them from minting TAU further (opening user positions with debt).Code Snippet
TAU mint function increase current minted and reverts above limit:
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/TAU.sol#L35-L47
TAU burn function decreases current minted:
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/TAU.sol#L54-L58
swapForTau burns an amount of TAU but only repays part of it towards user debt:
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/SwapHandler.sol#L87-L91
Tool used
Manual Review
Recommendation
Allow
currentMinted
to go negative e.g. by using an additional storage valuecurrentMintedDebt
that will be increased when an amount of token is burnt that is abovecurrentMinted[vault]
and used to lowercurrentMinted[vault]
when minting new tokens.The text was updated successfully, but these errors were encountered: