Skip to content

Commit

Permalink
feat: id for liquidate + move function upward
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Jul 5, 2023
1 parent fbaa7c9 commit c0282d8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Blue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ struct Market {
uint lLTV;
}

using {toId} for Market;
function toId(Market calldata market) pure returns (Id) {
return Id.wrap(keccak256(abi.encode(market)));
}

function irm(uint utilization) pure returns (uint) {
// Divide by the number of seconds in a year.
// This is a very simple model (to refine later) where x% utilization corresponds to x% APR.
return utilization / 365 days;
}

using {toId} for Market;
function toId(Market calldata market) pure returns (Id) {
return Id.wrap(keccak256(abi.encode(market)));
}

contract Blue {
using MathLib for uint;
using SafeTransferLib for IERC20;
Expand Down Expand Up @@ -180,7 +180,7 @@ contract Blue {
// Liquidation.

function liquidate(Market calldata market, address borrower, uint seized) external {
Id id = Id.wrap(keccak256(abi.encode(market)));
Id id = market.toId();
require(lastUpdate[id] != 0, "unknown market");
require(seized > 0, "zero amount");

Expand Down

0 comments on commit c0282d8

Please sign in to comment.