Skip to content
Business logic Audit finding Intermediate

Unable to transfer fee reserve assets to treasury

xiaoming90 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-03-notional-judging/issues/190

Found by

xiaoming90 + 0xleastwood

Summary

Transferring fee reserve assets to the treasury manager contract will result in a revert, leading to a loss of rewards for NOTE stakers.

Vulnerability Detail

https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/external/actions/TreasuryAction.sol#L135

Solidity
File: TreasuryAction.sol
132:     /// @notice redeems and transfers tokens to the treasury manager contract
133:     function _redeemAndTransfer(uint16 currencyId, int256 primeCashRedeemAmount) private returns (uint256) {
134:         PrimeRate memory primeRate = PrimeRateLib.buildPrimeRateStateful(currencyId);
135:         int256 actualTransferExternal = TokenHandler.withdrawPrimeCash(
136:             treasuryManagerContract,
137:             currencyId,
138:             primeCashRedeemAmount.neg(),
139:             primeRate,
140:             true // if ETH, transfers it as WETH
141:         );
142: 
143:         require(actualTransferExternal > 0);
144:         return uint256(actualTransferExternal);
145:     }

The value returned by the TokenHandler.withdrawPrimeCash function is always less than or equal to zero. Thus, the condition actualTransferExternal > 0 will always be false, and the _redeemAndTransfer function will always revert.

The transferReserveToTreasury function depends on _redeemAndTransfer function. Thus, it is not possible to transfer any asset to the treasury manager contract.

Impact

The fee collected by Notional is stored in the Fee Reserve. The fee reserve assets will be transferred to Notional's Treasury to be invested into the sNOTE pool. Without the ability to do so, the NOTE stakers will not receive their rewards.

Code Snippet

https://github.com/sherlock-audit/2023-03-notional/blob/main/contracts-v2/contracts/external/actions/TreasuryAction.sol#L135

Tool used

Manual Review

Recommendation

Negate the value returned by the TokenHandler.withdrawPrimeCash function.

Diff
        int256 actualTransferExternal = TokenHandler.withdrawPrimeCash(
            treasuryManagerContract,
            currencyId,
            primeCashRedeemAmount.neg(),
            primeRate,
            true // if ETH, transfers it as WETH
-       );
+       ).neg();

Discussion

jeffywu

Fixed: https://github.com/notional-finance/contracts-v2/pull/119

xiaoming9090

@0xleastwood + @xiaoming9090 : Verified. Fixed in PR https://github.com/notional-finance/contracts-v2/pull/119

The original report as published on Sherlock, by xiaoming90 + 0xleastwood. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity business logic bug in Notional Update #4. Sherlock made it public on 30 May 2023. Found in the 59 audit contest (finding H-5).

About Business logic

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by xiaoming90

View all

17 more disclosed reports, best first.

More from Notional Update #4

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.