Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf small gas opti #31

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Blue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract Blue {
function supply(Market calldata market, uint amount) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(amount > 0, "zero amount");
require(amount != 0, "zero amount");

accrueInterests(id);

Expand All @@ -87,7 +87,7 @@ contract Blue {
function withdraw(Market calldata market, uint amount) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(amount > 0, "zero amount");
require(amount != 0, "zero amount");

accrueInterests(id);

Expand All @@ -107,7 +107,7 @@ contract Blue {
function borrow(Market calldata market, uint amount) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(amount > 0, "zero amount");
require(amount != 0, "zero amount");

accrueInterests(id);

Expand All @@ -131,7 +131,7 @@ contract Blue {
function repay(Market calldata market, uint amount) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(amount > 0, "zero amount");
require(amount != 0, "zero amount");

accrueInterests(id);

Expand All @@ -149,7 +149,7 @@ contract Blue {
function supplyCollateral(Market calldata market, uint amount) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(amount > 0, "zero amount");
require(amount != 0, "zero amount");

accrueInterests(id);

Expand All @@ -161,7 +161,7 @@ contract Blue {
function withdrawCollateral(Market calldata market, uint amount) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(amount > 0, "zero amount");
require(amount != 0, "zero amount");

accrueInterests(id);

Expand All @@ -177,7 +177,7 @@ contract Blue {
function liquidate(Market calldata market, address borrower, uint seized) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
require(lastUpdate[id] != 0, "unknown market");
require(seized > 0, "zero amount");
require(seized != 0, "zero amount");

accrueInterests(id);

Expand Down Expand Up @@ -227,7 +227,7 @@ contract Blue {
function isHealthy(Market calldata market, Id id, address user) private view returns (bool) {
uint borrowShares = borrowShare[id][user];
// totalBorrowShares[id] > 0 when borrowShares > 0.
uint borrowValue = borrowShares > 0
uint borrowValue = borrowShares != 0
? borrowShares.wMul(totalBorrow[id]).wDiv(totalBorrowShares[id]).wMul(market.borrowableOracle.price())
: 0;
uint collateralValue = collateral[id][user].wMul(market.collateralOracle.price());
Expand Down