Submitted by jonah1005
In the _isWrappedFCash check, the notionalTradeModule check whether the component is a wrappedCash with the following logic.
The above logic is dangerous when _fCashPosition do not revert on getDecodedID but instead give a wrong format of return value. The contract would try to decode the return value into returns(uint16 _currencyId, uint40 _maturity) and revert. The revert would consume what ever gas its provided.
CETH is an example.
Theres a fallback function in ceth
As a result, calling getDecodedID would not revert. Instead, calling getDecodedID of CETH would consume all remaining gas.
This creates so many issues. First, users would waste too much gas on a regular operation. Second, the transaction might fail if ceth is not the last position. Third, the wallet contract can not interact with set token with ceth as it consumes all gas.
The following contract may fail to redeem setTokens as it consumes too much gas (with 20M gas limit).
Test.sol
Also, we can check how much gas it consumes with the following function.
Test this function with cdai and ceth, we can observe that theres huge difference of gas consumption here.
Hardhat
I recommend building a map in the notionalTradeModule and inserting the wrappeCash in the mintFCashPosition function.
Or we could replace the try-catch pattern with a low-level function call and check the return values length before decoding it.
Something like this might be a fix.
ckoopmann (Index Coop) confirmed and commented:
gzeoneth (judge) decreased severity to Medium and commented:
