You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
contracts/ClearingHouse.sol:122: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:130: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:170: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:194: for (uint i = 0; i < amms.length; i++) { // liquidate all positions
contracts/ClearingHouse.sol:251: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:263: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:277: for (uint i = 0; i < amms.length; i++) {
uint namms = amms.length;
for (uint i = 0; i < namms; i++) {
> 0
is less efficient than!= 0
for uint in require conditionRef: https://twitter.com/GalloDaSballo/status/1485430908165443590
Use custom errors
Solidity ^0.8.4 allow the use of custom errors to optimize gas usage.
https://blog.soliditylang.org/2021/04/21/custom-errors/
Cache array length
contracts/ClearingHouse.sol:122: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:130: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:170: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:194: for (uint i = 0; i < amms.length; i++) { // liquidate all positions
contracts/ClearingHouse.sol:251: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:263: for (uint i = 0; i < amms.length; i++) {
contracts/ClearingHouse.sol:277: for (uint i = 0; i < amms.length; i++) {
Functions can be mark as external
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/ClearingHouse.sol#L148
function liquidateMaker(address maker) override public whenNotPaused {
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/ClearingHouse.sol#L153
function liquidateTaker(address trader) override public whenNotPaused {
Safe math can be put in unchecked block
For example, ClearingHouse.sol#211-215 can be put in unchecked block
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/ClearingHouse.sol#L210
Unnecessary checks
There are implicit assert as commented in the code
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/AMM.sol#L487
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/AMM.sol#L511
Use stuct storage instead of memory
A struct in storage is call by ref which don't need to copy the contents to memory
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/AMM.sol#L528
Unused library
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/Oracle.sol#L13
Variables can be set immutable
https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/MarginAccountHelper.sol
The text was updated successfully, but these errors were encountered: