From 2dc559359ef41f2e42f8118838c1c891a38b41e5 Mon Sep 17 00:00:00 2001 From: MerlinEgalite Date: Wed, 5 Jul 2023 15:37:59 +0200 Subject: [PATCH 1/3] perf: remove accrue interest from supplyCollateral function --- src/Blue.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Blue.sol b/src/Blue.sol index 50dee219d..8d384385e 100644 --- a/src/Blue.sol +++ b/src/Blue.sol @@ -151,8 +151,6 @@ contract Blue { require(lastUpdate[id] != 0, "unknown market"); require(amount > 0, "zero amount"); - accrueInterests(id); - collateral[id][msg.sender] += amount; market.collateralAsset.safeTransferFrom(msg.sender, address(this), amount); From d9cb441a7b309a9dcd423fac804ec71c1be9ae66 Mon Sep 17 00:00:00 2001 From: MerlinEgalite Date: Wed, 5 Jul 2023 16:30:58 +0200 Subject: [PATCH 2/3] docs: add comment --- src/Blue.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Blue.sol b/src/Blue.sol index 8d384385e..5554ee7f5 100644 --- a/src/Blue.sol +++ b/src/Blue.sol @@ -146,6 +146,7 @@ contract Blue { // Collateral management. + /// @dev The interests are not accrued since no health check is required when supplying collateral. function supplyCollateral(Market calldata market, uint amount) external { Id id = Id.wrap(keccak256(abi.encode(market))); require(lastUpdate[id] != 0, "unknown market"); From 9b9ed18cca94763e7fc9cf399766ee94bd9120de Mon Sep 17 00:00:00 2001 From: MerlinEgalite Date: Wed, 5 Jul 2023 19:27:52 +0200 Subject: [PATCH 3/3] docs: implement suggestion --- src/Blue.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Blue.sol b/src/Blue.sol index 5554ee7f5..164870bad 100644 --- a/src/Blue.sol +++ b/src/Blue.sol @@ -146,12 +146,14 @@ contract Blue { // Collateral management. - /// @dev The interests are not accrued since no health check is required when supplying collateral. + /// @dev Don't accrue interests because it's not required and it saves gas. 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"); + // Don't accrue interests because it's not required and it saves gas. + collateral[id][msg.sender] += amount; market.collateralAsset.safeTransferFrom(msg.sender, address(this), amount);