Open code423n4 opened 1 year ago
require
&&
src/DBR.sol: L249
src/Market.sol: L75 L162 L173 L195 L512
src/escrows/GovTokenEscrow.sol: L31 L44
src/Oracle.sol: L36 L83 L104 L117 L143
src/Fed.sol: L49 L58 L67 L76 L88 L104 L107
src/escrows/SimpleERC20Escrow.sol: L26 L37
src/escrows/INVEscrow.sol: L45 L60
src/Market.sol: L74 L75 L93 L162 L184 L204 L214 L236 L390 L423 L448 L462 L487 L512 L533 L561 L567 L592 L595
src/DBR.sol: L45 L71 L171 L195 L224 L301 L303 L314 L328 L329 L350
src/BorrowController.sol: L18
src/Market.sol: L76 L214
src/DBR.sol: L63 L326
src/Market.sol: L397 L568 L395 L534 L565 L599
src/Fed.sol: L111 L91 L110
src/DBR.sol: L360 L174 L196 L362 L374 L304 L316 L332 L288
public
constant
immutable
private
src/DBR.sol: L13
src/Market.sol: L52 L53
src/Market.sol: L38
x < y + 1
x <= y
src/Fed.sol: L93 L107 L123
src/DBR.sol: L195 L224 L329 L373
src/Market.sol: L162 L361 L396 L423 L462 L487 L562 L567 L595
uint
require(x != 0)
require(x > 0)
src/Oracle.sol: L83 L96 L97 L117 L135
src/escrows/INVEscrow.sol: L81
src/DBR.sol: L63 L328
src/Market.sol: L75 L162 L173 L195 L592
src/Fed.sol: L133
require(x)
require(x == true)
src/DBR.sol: L350
src/DBR.sol: L11 L12
0xean marked the issue as grade-b
1. Use multiple
require
s instead of a single one with&&
src/DBR.sol: L249
src/Market.sol: L75 L162 L173 L195 L512
2. Custom error are cheaper than string messages
src/escrows/GovTokenEscrow.sol: L31 L44
src/Oracle.sol: L36 L83 L104 L117 L143
src/Fed.sol: L49 L58 L67 L76 L88 L104 L107
src/escrows/SimpleERC20Escrow.sol: L26 L37
src/escrows/INVEscrow.sol: L45 L60
src/Market.sol: L74 L75 L93 L162 L184 L204 L214 L236 L390 L423 L448 L462 L487 L512 L533 L561 L567 L592 L595
src/DBR.sol: L45 L71 L171 L195 L224 L301 L303 L314 L328 L329 L350
src/BorrowController.sol: L18
3. Strings messages in
require
statements should not be longer than 32 bytes of lengthsrc/Market.sol: L76 L214
src/DBR.sol: L63 L326
4. use x = x + y instead of x+= y
src/Market.sol: L397 L568 L395 L534 L565 L599
src/Fed.sol: L111 L91 L110
src/DBR.sol: L360 L174 L196 L362 L374 L304 L316 L332 L288
5.
public
storageconstant
(andimmutable
) variable should beprivate
saves tons of gas on deployment
src/DBR.sol: L13
6. Use 1 and 2 for true and false
src/Market.sol: L52 L53
7. You can make state variables take less slots than they currently are
src/Market.sol: L38
8. Use
x < y + 1
in stead ofx <= y
src/Fed.sol: L93 L107 L123
src/DBR.sol: L195 L224 L329 L373
src/Market.sol: L162 L361 L396 L423 L462 L487 L562 L567 L595
9. When comparing variables of type
uint
, userequire(x != 0)
instead ofrequire(x > 0)
src/Oracle.sol: L83 L96 L97 L117 L135
src/escrows/INVEscrow.sol: L81
src/DBR.sol: L63 L328
src/Market.sol: L75 L162 L173 L195 L592
src/Fed.sol: L133
10. Use
require(x)
instead ofrequire(x == true)
src/DBR.sol: L350
11. Use
constant
andimmutable
for constantssrc/DBR.sol: L11 L12