Skip to content
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

Closed
sherlock-admin opened this issue Mar 13, 2023 · 1 comment
Closed
Labels
Non-Reward This issue will not receive a payout

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 13, 2023

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 by TAU.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 than currentMinted[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 the currentMinted[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 exceeds currentMinted[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 value currentMintedDebt that will be increased when an amount of token is burnt that is above currentMinted[vault] and used to lower currentMinted[vault] when minting new tokens.

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Mar 21, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 1, 2023
@hrishibhat
Copy link
Contributor

Not a valid duplicate of #149
However not a valid issue on its own
Sponsor comment:

The Taurus Loans is a self repaying loan protocol which means whoever borrows any amount of debt against collateral will always be paying less than the borrowed amount i.e. the debt is being repaid partly/fully (varies on the duration of borrow) by the rewards earned for the collateral that the user has put in.
Coming back to the issue, whenever the swap adapter swaps the yield for the tau, we are burning the tau which means that the vault has repaid its debt and also the debt of the user. When the user manually closes the position by clearing the debt, we will be burning the tau that the user has provided which means that the user has repaid the debt of the vault as well. So, the issue is not correct.

@hrishibhat hrishibhat removed the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Apr 7, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Medium A valid Medium severity issue Reward A payout will be made for this issue labels Apr 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

2 participants