Skip to content

Latest commit

 

History

History
374 lines (209 loc) · 9.6 KB

report.md

File metadata and controls

374 lines (209 loc) · 9.6 KB

Aderyn Analysis Report

This report was generated by Aderyn, a static analysis tool built by Cyfrin, a blockchain security company. This report is not a substitute for manual audit or security review. It should not be relied upon for any purpose other than to assist in the identification of potential security vulnerabilities.

Table of Contents

Summary

Files Summary

Key Value
.sol Files 5
Total nSLOC 283

Files Details

Filepath nSLOC
src/Stable.sol 62
src/Utils.sol 47
src/mocks/MockOracle.sol 6
src/modules/StableLending.sol 157
src/tokens/StableUSD.sol 11
Total 283

Issue Summary

Category No. of Issues
High 0
Low 13

Low Issues

L-1: Centralization Risk for trusted owners

Contracts have owners with privileged rights to perform admin tasks and need to be trusted to not perform malicious updates or drain funds.

3 Found Instances
  • Found in src/Stable.sol Line: 88

         function whitelistTokens(address _token) external onlyOwner {
  • Found in src/tokens/StableUSD.sol Line: 10

     contract StableUSD is ERC20, ERC20Burnable, Ownable, ERC20Permit {
  • Found in src/tokens/StableUSD.sol Line: 13

         function mint(address to, uint256 amount) public onlyOwner {

L-2: public functions not used internally could be marked external

Instead of marking a function as public, consider marking it as external if it is not used internally.

1 Found Instances
  • Found in src/tokens/StableUSD.sol Line: 13

         function mint(address to, uint256 amount) public onlyOwner {

L-3: Define and use constant variables instead of using literals

If the same constant literal value is used multiple times, create a constant state variable and reference it throughout the contract.

2 Found Instances
  • Found in src/modules/StableLending.sol Line: 80

             if (healthFactor < 100) {
  • Found in src/modules/StableLending.sol Line: 129

             if (healthFactor > 100) {

L-4: Modifiers invoked only once can be shoe-horned into the function

1 Found Instances
  • Found in src/Utils.sol Line: 37

         modifier onlyOwner() {

L-5: Contract still has TODOs

Contract contains comments with TODOS

1 Found Instances
  • Found in src/modules/StableLending.sol Line: 22

     abstract contract StableLending is Utils {

L-6: Unused Custom Error

it is recommended that the definition be removed when custom error is unused

1 Found Instances
  • Found in src/Stable.sol Line: 23

         error StopDoingWeirdStuff();

L-7: Loop contains require/revert statements

Avoid require / revert statements in a loop because a single bad item can cause the whole transaction to fail. It's better to forgive on fail and return failed elements post processing of the loop

5 Found Instances
  • Found in src/modules/StableLending.sol Line: 75

             for (uint256 i; i < _colleteral.length; i++) {
  • Found in src/modules/StableLending.sol Line: 152

                 for (uint256 i; i < s_depositedColleteralsByUser[_user].length; i++) {
  • Found in src/modules/StableLending.sol Line: 198

             for (uint256 i; i < allowlist.length; i++) {
  • Found in src/modules/StableLending.sol Line: 214

             for (uint256 i; i < s_depositedColleteralsByUser[_user].length; i++) {
  • Found in src/modules/StableLending.sol Line: 225

             for (uint256 i = 0; i < _colleteral.length; i++) {

L-8: Uninitialized local variables.

Initialize all the variables. If a variable is meant to be initialized to zero, explicitly set it to zero to improve code readability.

3 Found Instances
  • Found in src/modules/StableLending.sol Line: 75

             for (uint256 i; i < _colleteral.length; i++) {
  • Found in src/modules/StableLending.sol Line: 198

             for (uint256 i; i < allowlist.length; i++) {
  • Found in src/modules/StableLending.sol Line: 214

             for (uint256 i; i < s_depositedColleteralsByUser[_user].length; i++) {

L-9: Loop condition contains state_variable.length that could be cached outside.

Cache the lengths of storage arrays if they are used and not modified in for loops.

1 Found Instances
  • Found in src/modules/StableLending.sol Line: 198

             for (uint256 i; i < allowlist.length; i++) {

L-10: Costly operations inside loops.

Invoking SSTOREoperations in loops may lead to Out-of-gas errors. Use a local variable to hold the loop computation result.

2 Found Instances
  • Found in src/modules/StableLending.sol Line: 83

             for (uint256 i; i < _colleteral.length; i++) {
  • Found in src/modules/StableLending.sol Line: 152

                 for (uint256 i; i < s_depositedColleteralsByUser[_user].length; i++) {

L-11: Unused Imports

Redundant import statement. Consider removing it.

1 Found Instances
  • Found in src/Stable.sol Line: 9

     import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

L-12: State variable changes but no event is emitted.

State variable changes in this function but no event is emitted.

7 Found Instances
  • Found in src/Stable.sol Line: 39

         function deposit(address _asset, uint256 _amount) external payable {
  • Found in src/Stable.sol Line: 62

         function withdraw(address _asset, uint256 _amount) external nonReentrant {
  • Found in src/Stable.sol Line: 88

         function whitelistTokens(address _token) external onlyOwner {
  • Found in src/modules/StableLending.sol Line: 71

         function mintStable(uint256 _amountToMint, uint256[] calldata _amountColleteral, address[] calldata _colleteral)
  • Found in src/modules/StableLending.sol Line: 97

         function repayStable(uint256 _amount) external {
  • Found in src/modules/StableLending.sol Line: 116

         function unlockColleteral(address _asset, uint256 _amount) external nonReentrant {
  • Found in src/modules/StableLending.sol Line: 145

         function liquidatePosition(address _user) external nonReentrant {

L-13: State variable could be declared immutable

State variables that are should be declared immutable to save gas. Add the immutable attribute to state variables that are only changed in the constructor

1 Found Instances
  • Found in src/Utils.sol Line: 26

         address owner;