Platform: Code4rena
Start Date: 16/11/2021
Pot Size: $30,000 USDC
Total HM: 3
Participants: 18
Period: 3 days
Judge: leastwood
Total Solo HM: 2
Id: 56
League: ETH
Rank: 6/18
Findings: 3
Award: $1,161.54
🌟 Selected for report: 2
🚀 Solo Findings: 0
defsec
During the manual code review, It has been observed that minting progress is not checked when the contract is emergency paused. This can cause misfunctionality and unlocking user funds during the emergency pausing.
1-) Navigate to "https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/Alchemist.sol#L611" contract. 2-) Observe the following code on the Alchemist.sol.
Functions mint
function mint(uint256 _amount) external nonReentrant noContractAllowed onPriceCheck expectInitialized { CDP.Data storage _cdp = _cdps[msg.sender]; _cdp.update(_ctx); uint256 _totalCredit = _cdp.totalCredit; if (_totalCredit < _amount) { uint256 _remainingAmount = _amount.sub(_totalCredit); if (borrowFee > 0) { uint256 _borrowFeeAmount = _remainingAmount.mul(borrowFee).div( PERCENT_RESOLUTION ); _cdp.totalDebt = _cdp.totalDebt.add(_borrowFeeAmount); xtoken.mint(rewards, _borrowFeeAmount); } _cdp.totalDebt = _cdp.totalDebt.add(_remainingAmount); _cdp.totalCredit = 0; _cdp.checkHealth(_ctx, 'Alchemist: Loan-to-value ratio breached'); } else { _cdp.totalCredit = _totalCredit.sub(_amount); } xtoken.mint(msg.sender, _amount); if (_amount >= flushActivator) { flushActiveVault(); } }
None
Implement the the following require statement into the functions. Only withdraw functions should be allowed on the contract.
require(!emergencyExit, 'emergency pause enabled');
#0 - Xuefeng-Zhu
2021-12-09T06:41:08Z
21.2967 USDC - $21.30
defsec
Hardhat console is an unnecessary import in all contracts since it is used solely for development. It can therefore be removed.
"https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/Alchemist.sol#L2" "https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/adapters/YaxisVaultAdapter.sol#L2"
None
Remove import "hardhat/console.sol";
#0 - Xuefeng-Zhu
2021-11-23T17:46:03Z
does not impact deployed code
21.2967 USDC - $21.30
defsec
This does not directly impact the smart contract in anyway besides cost. This is a gas optimization to reduce cost of smart contract. Calling each function, we can see that the public function uses 496 gas, while the external function uses only 261.
According to Slither Analyzer documentation (https://github.com/crytic/slither/wiki/Detector-Documentation#public-function-that-could-be-declared-external), there are functions in the contract that are never called. These functions should be declared as external in order to save gas.
Slither Detector:
external-function:
https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/Transmuter.sol#L349
https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/Transmuter.sol#L341
https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/Transmuter.sol#L332
Slither
#0 - 0xleastwood
2021-12-21T05:09:01Z
Duplicate of #119
🌟 Selected for report: defsec
47.3259 USDC - $47.33
defsec
##Â Impact
Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks are available for free.
The advantages of versions 0.8.* over <0.8.0 are:
"https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/Alchemist.sol#L2" "https://github.com/code-423n4/2021-11-yaxis/blob/main/contracts/v3/alchemix/adapters/YaxisVaultAdapter.sol#L2"
None
Consider to upgrade pragma to at least 0.8.4.
defsec
The Alchemist.setBorrowFee function emits the HarvestFeeUpdated event but should emit BorrowFeeUpdated instead. SetBorrowFee can be understood as that never happened which could lead to serious issues when something like an accounting app uses this data.
function setBorrowFee(uint256 _borrowFee) external onlyGov { // Check that the borrow fee is within the acceptable range. Setting the borrow fee greater than 100% could // potentially break internal logic when calculating the borrow fee. require(_borrowFee <= PERCENT_RESOLUTION, 'Alchemist: borrow fee above maximum.'); borrowFee = _borrowFee; emit HarvestFeeUpdated(_borrowFee); }
Code Review
Emit the correct event. (BorrowFeeUpdated)
#0 - Xuefeng-Zhu
2021-12-09T06:10:02Z