Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

optimize code #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions contracts/BentoBox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ contract BentoBox is MasterContractManager, BoringBatchable {
);

balanceOf[token][to] = balanceOf[token][to].add(share);
total.base = total.base.add(share.to128());
total.elastic = total.elastic.add(amount.to128());
total.add(amount, share);
totals[token] = total;

// Interactions
Expand Down Expand Up @@ -256,8 +255,7 @@ contract BentoBox is MasterContractManager, BoringBatchable {
}

balanceOf[token][from] = balanceOf[token][from].sub(share);
total.elastic = total.elastic.sub(amount.to128());
total.base = total.base.sub(share.to128());
total.sub(amount, share);
// There have to be at least 1000 shares left to prevent reseting the share/amount ratio (unless it's fully emptied)
require(total.base >= MINIMUM_SHARE_BALANCE || total.base == 0, "BentoBox: cannot empty");
totals[token] = total;
Expand Down