Skip to content

Commit

Permalink
Merge pull request #63 from morpho-org/fix/market-id
Browse files Browse the repository at this point in the history
fix(sdk): fix market id hash
  • Loading branch information
Rubilmax authored Sep 6, 2024
2 parents deea062 + f05fa05 commit d5d5ae4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/blue-sdk/src/market/MarketUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export namespace MarketUtils {
market.collateralToken.substring(2).toLowerCase().padStart(64, "0") +
market.oracle.substring(2).padStart(64, "0") +
market.irm.substring(2).toLowerCase().padStart(64, "0") +
market.lltv.toString(16).padStart(64, "0"),
BigInt(market.lltv).toString(16).padStart(64, "0"),
).toString("hex")}` as MarketId;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/blue-sdk/src/maths/AdaptiveCurveIrmLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,16 @@ export namespace AdaptiveCurveIrmLib {
if (borrowRate >= rateAtTarget) {
const maxBorrowRate = MathLib.wMulDown(rateAtTarget, CURVE_STEEPNESS);

const diffToMaxBorrowRate = maxBorrowRate - rateAtTarget;
if (diffToMaxBorrowRate === 0n) return MathLib.WAD;

return MathLib.min(
MathLib.WAD,
TARGET_UTILIZATION +
MathLib.mulDivDown(
MathLib.WAD - TARGET_UTILIZATION,
borrowRate - rateAtTarget,
maxBorrowRate - rateAtTarget,
diffToMaxBorrowRate,
),
);
}
Expand Down

0 comments on commit d5d5ae4

Please sign in to comment.