From 74d1cfc4cbbf45415ee818f695c8d76be2e72f3f Mon Sep 17 00:00:00 2001 From: MathisGD Date: Wed, 15 Apr 2026 15:28:50 +0200 Subject: [PATCH 1/3] minor naming changes --- README.md | 4 ++-- certora/specs/CollateralBitmap.spec | 2 +- certora/specs/Healthiness.spec | 6 +++--- certora/specs/NoDivisionByZero.spec | 4 ++-- src/periphery/TakeBundler.sol | 8 ++++---- test/BundlerTest.sol | 26 +++++++++++++++----------- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 404f5f24b..fdd123600 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Morpho Midnight +# Midnight -Morpho Midnight is a fixed-rate lending protocol based on zero-coupon obligations. +Midnight is a fixed-rate lending protocol based on zero-coupon obligations. ## Whitepaper diff --git a/certora/specs/CollateralBitmap.spec b/certora/specs/CollateralBitmap.spec index e0e6a2a56..35cd6aff7 100644 --- a/certora/specs/CollateralBitmap.spec +++ b/certora/specs/CollateralBitmap.spec @@ -15,7 +15,7 @@ methods { */ function _.price() external => PER_CALLEE_CONSTANT; function TickLib.tickToPrice(uint256 tick) internal returns (uint256) => NONDET; - function IdLib.toId(Midnight.Obligation memory obligation, uint256 chainId, address morpho) internal returns (bytes32) => NONDET; + function IdLib.toId(Midnight.Obligation memory obligation, uint256 chainId, address midnight) internal returns (bytes32) => NONDET; /* Simplify mulDiv reasoning for the solver. We summarize these by ghost functions, i.e., * arbitrary deterministic functions and axiomatize the axioms we need. diff --git a/certora/specs/Healthiness.spec b/certora/specs/Healthiness.spec index c9c91c669..579342802 100644 --- a/certora/specs/Healthiness.spec +++ b/certora/specs/Healthiness.spec @@ -17,7 +17,7 @@ methods { */ function _.price() external => summaryPrice(calledContract) expect(uint256); function TickLib.tickToPrice(uint256 tick) internal returns (uint256) => NONDET; - function IdLib.toId(Midnight.Obligation memory obligation, uint256 chainId, address morpho) internal returns (bytes32) => summaryToId(obligation, chainId, morpho); + function IdLib.toId(Midnight.Obligation memory obligation, uint256 chainId, address midnight) internal returns (bytes32) => summaryToId(obligation, chainId, midnight); /* Summarize mulDivDown and mulDivUp to simplify the verification task. * Use a ghost function that ensures mulDivDown/Up behaves deterministically and @@ -136,9 +136,9 @@ function getGlobalObligation() returns (Midnight.Obligation) { return obligation; } -function summaryToId(Midnight.Obligation obligation, uint256 chainId, address morpho) returns (bytes32) { +function summaryToId(Midnight.Obligation obligation, uint256 chainId, address midnight) returns (bytes32) { bytes32 id; - if (equalsGlobalObligation(obligation) && morpho == currentContract) { + if (equalsGlobalObligation(obligation) && midnight == currentContract) { require id == globalId, "toId() is deterministic"; } else { require id != globalId, "toId() is injective"; diff --git a/certora/specs/NoDivisionByZero.spec b/certora/specs/NoDivisionByZero.spec index 8e4bde805..ffa004754 100644 --- a/certora/specs/NoDivisionByZero.spec +++ b/certora/specs/NoDivisionByZero.spec @@ -84,9 +84,9 @@ function equalsGlobalObligation(Midnight.Obligation obligation) returns (bool) { return obligation.loanToken == globalObligationLoanToken && obligation.collateralParams.length == globalObligationCollateralLength && collateralMatches(obligation, 0) && collateralMatches(obligation, 1) && collateralMatches(obligation, 2) && obligation.maturity == globalObligationMaturity && obligation.rcfThreshold == globalObligationRcfThreshold && obligation.enterGate == globalObligationEnterGate && obligation.liquidatorGate == globalObligationLiquidatorGate; } -function summaryToId(Midnight.Obligation obligation, uint256 chainId, address morpho) returns (bytes32) { +function summaryToId(Midnight.Obligation obligation, uint256 chainId, address midnight) returns (bytes32) { bytes32 id; - if (equalsGlobalObligation(obligation) && morpho == currentContract) { + if (equalsGlobalObligation(obligation) && midnight == currentContract) { require id == globalId, "toId() is deterministic"; } else { require id != globalId, "toId() is injective"; diff --git a/src/periphery/TakeBundler.sol b/src/periphery/TakeBundler.sol index 09a3d8244..a11ca5802 100644 --- a/src/periphery/TakeBundler.sol +++ b/src/periphery/TakeBundler.sol @@ -13,7 +13,7 @@ contract TakeBundler { struct Take { uint256 units; Offer offer; - bytes sig; + bytes ratifierData; bytes32 root; bytes32[] proof; } @@ -47,7 +47,7 @@ contract TakeBundler { "", receiverIfTakerIsSeller, takes[i].offer, - takes[i].sig, + takes[i].ratifierData, takes[i].root, takes[i].proof ) returns ( @@ -98,7 +98,7 @@ contract TakeBundler { "", receiverIfTakerIsSeller, takes[i].offer, - takes[i].sig, + takes[i].ratifierData, takes[i].root, takes[i].proof ) returns ( @@ -145,7 +145,7 @@ contract TakeBundler { "", receiverIfTakerIsSeller, takes[i].offer, - takes[i].sig, + takes[i].ratifierData, takes[i].root, takes[i].proof ) returns ( diff --git a/test/BundlerTest.sol b/test/BundlerTest.sol index 9b4f66d73..b876df526 100644 --- a/test/BundlerTest.sol +++ b/test/BundlerTest.sol @@ -84,7 +84,11 @@ contract BundlerTest is BaseTest { function testUnauthorized() public { TakeBundler.Take[] memory takes = new TakeBundler.Take[](1); takes[0] = TakeBundler.Take({ - offer: offers[0], units: 100, sig: sig([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) + offer: offers[0], + units: 100, + ratifierData: sig([offers[0]]), + root: root([offers[0]]), + proof: proof([offers[0]]) }); vm.prank(address(0xdead)); @@ -106,14 +110,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - sig: sig([offers[0]]), + ratifierData: sig([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - sig: sig([offers[1]]), + ratifierData: sig([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -156,14 +160,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - sig: sig([offers[0]]), + ratifierData: sig([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - sig: sig([offers[1]]), + ratifierData: sig([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -208,14 +212,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - sig: sig([offers[0]]), + ratifierData: sig([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - sig: sig([offers[1]]), + ratifierData: sig([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -301,14 +305,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - sig: sig([offers[0]]), + ratifierData: sig([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - sig: sig([offers[1]]), + ratifierData: sig([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -351,14 +355,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - sig: sig([offers[0]]), + ratifierData: sig([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - sig: sig([offers[1]]), + ratifierData: sig([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); From 1bd1a61050cead2d03292a628e7b350d74f7bb66 Mon Sep 17 00:00:00 2001 From: MathisGD Date: Wed, 15 Apr 2026 15:34:18 +0200 Subject: [PATCH 2/3] further --- src/interfaces/IRatifier.sol | 2 +- test/AuthorizationTest.sol | 8 +++-- test/BaseTest.sol | 12 +++++--- test/BundlerTest.sol | 22 ++++++------- test/TakeTest.sol | 60 +++++++++++++++++++++++------------- 5 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/interfaces/IRatifier.sol b/src/interfaces/IRatifier.sol index 32253bc78..c3cfea0f1 100644 --- a/src/interfaces/IRatifier.sol +++ b/src/interfaces/IRatifier.sol @@ -5,5 +5,5 @@ pragma solidity >=0.5.0; import {Offer} from "./IMidnight.sol"; interface IRatifier { - function onRatify(Offer memory offer, bytes32 root, bytes memory data) external returns (bytes32); + function onRatify(Offer memory offer, bytes32 root, bytes memory ratifierData) external returns (bytes32); } diff --git a/test/AuthorizationTest.sol b/test/AuthorizationTest.sol index a27f97af4..464293cd7 100644 --- a/test/AuthorizationTest.sol +++ b/test/AuthorizationTest.sol @@ -214,7 +214,9 @@ contract AuthorizationTest is BaseTest { address attacker = makeAddr("attacker"); vm.prank(attacker); vm.expectRevert("taker unauthorized"); - midnight.take(units, taker, address(0), hex"", address(0), offer, sig([offer]), root([offer]), proof([offer])); + midnight.take( + units, taker, address(0), hex"", address(0), offer, ratifierData([offer]), root([offer]), proof([offer]) + ); } function testTakeAuthorized() public { @@ -240,7 +242,9 @@ contract AuthorizationTest is BaseTest { // Operator can take on behalf of taker vm.prank(operator); - midnight.take(units, taker, address(0), hex"", taker, offer, sig([offer]), root([offer]), proof([offer])); + midnight.take( + units, taker, address(0), hex"", taker, offer, ratifierData([offer]), root([offer]), proof([offer]) + ); assertEq(midnight.debtOf(id, taker), units); } diff --git a/test/BaseTest.sol b/test/BaseTest.sol index d3202defa..aeab71ee6 100644 --- a/test/BaseTest.sol +++ b/test/BaseTest.sol @@ -144,7 +144,9 @@ abstract contract BaseTest is Test { // receiverIfTakerIsSeller param is for taker (when offer.buy == true) // offer.receiverIfMakerIsSeller is for maker (when offer.buy == false) vm.prank(taker); - return midnight.take(units, taker, address(0), hex"", taker, offer, sig([offer]), root([offer]), proof([offer])); + return midnight.take( + units, taker, address(0), hex"", taker, offer, ratifierData([offer]), root([offer]), proof([offer]) + ); } function setupOtherUsers(Obligation memory obligation, uint256 units) internal { @@ -217,7 +219,7 @@ abstract contract BaseTest is Test { return IdLib.toId(obligation, block.chainid, address(midnight)); } - function sig(Offer[1] memory offers, address _signer) internal view returns (bytes memory) { + function ratifierData(Offer[1] memory offers, address _signer) internal view returns (bytes memory) { return abi.encode(signature(root(offers), privateKey[_signer], offers[0].ratifier)); } @@ -260,12 +262,12 @@ abstract contract BaseTest is Test { return _signature; } - function sig(Offer[1] memory offers) internal view returns (bytes memory) { + function ratifierData(Offer[1] memory offers) internal view returns (bytes memory) { bytes32 _root = root(offers); return abi.encode(signature(_root, privateKey[offers[0].maker], offers[0].ratifier)); } - function sig(Offer[2] memory offers) internal view returns (bytes memory) { + function ratifierData(Offer[2] memory offers) internal view returns (bytes memory) { bytes32 _root = root(offers); return abi.encode(signature(_root, privateKey[offers[0].maker], offers[0].ratifier)); } @@ -328,7 +330,7 @@ abstract contract BaseTest is Test { hex"", borrower, borrowerOffer, - sig([borrowerOffer]), + ratifierData([borrowerOffer]), root([borrowerOffer]), proof([borrowerOffer]) ); diff --git a/test/BundlerTest.sol b/test/BundlerTest.sol index b876df526..30f4b52f2 100644 --- a/test/BundlerTest.sol +++ b/test/BundlerTest.sol @@ -86,7 +86,7 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: 100, - ratifierData: sig([offers[0]]), + ratifierData: ratifierData([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); @@ -110,14 +110,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - ratifierData: sig([offers[0]]), + ratifierData: ratifierData([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - ratifierData: sig([offers[1]]), + ratifierData: ratifierData([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -160,14 +160,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - ratifierData: sig([offers[0]]), + ratifierData: ratifierData([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - ratifierData: sig([offers[1]]), + ratifierData: ratifierData([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -212,14 +212,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - ratifierData: sig([offers[0]]), + ratifierData: ratifierData([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - ratifierData: sig([offers[1]]), + ratifierData: ratifierData([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -305,14 +305,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - ratifierData: sig([offers[0]]), + ratifierData: ratifierData([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - ratifierData: sig([offers[1]]), + ratifierData: ratifierData([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); @@ -355,14 +355,14 @@ contract BundlerTest is BaseTest { takes[0] = TakeBundler.Take({ offer: offers[0], units: offerUnits0, - ratifierData: sig([offers[0]]), + ratifierData: ratifierData([offers[0]]), root: root([offers[0]]), proof: proof([offers[0]]) }); takes[1] = TakeBundler.Take({ offer: offers[1], units: offerUnits1, - ratifierData: sig([offers[1]]), + ratifierData: ratifierData([offers[1]]), root: root([offers[1]]), proof: proof([offers[1]]) }); diff --git a/test/TakeTest.sol b/test/TakeTest.sol index eee7db9b7..c849e7096 100644 --- a/test/TakeTest.sol +++ b/test/TakeTest.sol @@ -896,7 +896,15 @@ contract TakeTest is BaseTest { vm.expectRevert("invalid proof"); vm.prank(borrower); midnight.take( - 100, borrower, address(0), hex"", borrower, lenderOffer, sig([lenderOffer]), invalidRoot, new bytes32[](0) + 100, + borrower, + address(0), + hex"", + borrower, + lenderOffer, + ratifierData([lenderOffer]), + invalidRoot, + new bytes32[](0) ); } @@ -937,7 +945,7 @@ contract TakeTest is BaseTest { hex"", sender, lenderOffer, - sig([lenderOffer], vm.addr(otherPrivateKey)), + ratifierData([lenderOffer], vm.addr(otherPrivateKey)), root([lenderOffer]), proof([lenderOffer]) ); @@ -967,7 +975,7 @@ contract TakeTest is BaseTest { hex"", sender, lenderOffer, - sig([lenderOffer], vm.addr(otherPrivateKey)), + ratifierData([lenderOffer], vm.addr(otherPrivateKey)), root([lenderOffer]), proof([lenderOffer]) ); @@ -980,7 +988,15 @@ contract TakeTest is BaseTest { vm.expectRevert("invalid proof"); vm.prank(borrower); midnight.take( - 100, borrower, address(0), hex"", borrower, lenderOffer, sig([lenderOffer]), root([lenderOffer]), _path + 100, + borrower, + address(0), + hex"", + borrower, + lenderOffer, + ratifierData([lenderOffer]), + root([lenderOffer]), + _path ); } @@ -996,7 +1012,7 @@ contract TakeTest is BaseTest { hex"", borrower, lenderOffer, - sig([lenderOffer, otherOffer]), + ratifierData([lenderOffer, otherOffer]), root([lenderOffer, otherOffer]), _path ); @@ -1017,7 +1033,7 @@ contract TakeTest is BaseTest { hex"", borrower, lenderOffer, - sig([lenderOffer, otherOffer]), + ratifierData([lenderOffer, otherOffer]), root([lenderOffer, otherOffer]), proof([lenderOffer, otherOffer]) ); @@ -1047,7 +1063,7 @@ contract TakeTest is BaseTest { hex"", sender, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1088,7 +1104,7 @@ contract TakeTest is BaseTest { hex"", sender, lenderOffer, - sig([lenderOffer], vm.addr(otherSecretKey)), + ratifierData([lenderOffer], vm.addr(otherSecretKey)), root([lenderOffer]), proof([lenderOffer]) ); @@ -1120,7 +1136,7 @@ contract TakeTest is BaseTest { hex"", sender, lenderOffer, - sig([lenderOffer], vm.addr(otherSecretKey)), + ratifierData([lenderOffer], vm.addr(otherSecretKey)), root([lenderOffer]), proof([lenderOffer]) ); @@ -1147,7 +1163,7 @@ contract TakeTest is BaseTest { hex"", sender, lenderOffer, - sig([lenderOffer], vm.addr(signerPrivateKey)), + ratifierData([lenderOffer], vm.addr(signerPrivateKey)), root([lenderOffer]), proof([lenderOffer]) ); @@ -1167,7 +1183,7 @@ contract TakeTest is BaseTest { hex"", taker, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1184,7 +1200,7 @@ contract TakeTest is BaseTest { hex"", taker, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1205,7 +1221,7 @@ contract TakeTest is BaseTest { hex"", taker, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1257,7 +1273,7 @@ contract TakeTest is BaseTest { abi.encode(0, collateral), borrower, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1289,7 +1305,7 @@ contract TakeTest is BaseTest { abi.encode(0, collateral, repaidUnits), borrower, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1322,7 +1338,7 @@ contract TakeTest is BaseTest { callback.prepare( lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]), units, @@ -1339,7 +1355,7 @@ contract TakeTest is BaseTest { "", borrower, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1370,7 +1386,7 @@ contract TakeTest is BaseTest { hex"", borrower, lenderOffer, - sig([lenderOffer]), + ratifierData([lenderOffer]), root([lenderOffer]), proof([lenderOffer]) ); @@ -1412,7 +1428,7 @@ contract TakeTest is BaseTest { abi.encode(address(loanToken), assets), address(0), borrowerOffer, - sig([borrowerOffer]), + ratifierData([borrowerOffer]), root([borrowerOffer]), proof([borrowerOffer]) ); @@ -1523,7 +1539,7 @@ contract TakeTest is BaseTest { hex"", address(0), borrowerOffer, - sig([borrowerOffer]), + ratifierData([borrowerOffer]), root([borrowerOffer]), proof([borrowerOffer]) ); @@ -1556,7 +1572,9 @@ contract TakeTest is BaseTest { vm.expectRevert("buyer pendingFee exceeds credit"); vm.prank(lender); - midnight.take(units, lender, address(0), hex"", lender, bOffer, sig([bOffer]), root([bOffer]), proof([bOffer])); + midnight.take( + units, lender, address(0), hex"", lender, bOffer, ratifierData([bOffer]), root([bOffer]), proof([bOffer]) + ); } } From 86eb190a75dde3c25ee7698a918da2b8485d3821 Mon Sep 17 00:00:00 2001 From: MathisGD Date: Thu, 16 Apr 2026 15:50:42 +0200 Subject: [PATCH 3/3] suggestion --- test/EcrecoverRatifierTest.sol | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/EcrecoverRatifierTest.sol b/test/EcrecoverRatifierTest.sol index 26cbc00ed..a61727c99 100644 --- a/test/EcrecoverRatifierTest.sol +++ b/test/EcrecoverRatifierTest.sol @@ -27,9 +27,9 @@ contract EcrecoverRatifierTest is BaseTest { function testOnRatifyMakerSigns() public view { Offer memory offer = makeOffer(lender); bytes32 _root = keccak256(abi.encode(offer)); - bytes memory data = signRoot(_root, lender); + bytes memory ratifierData = signRoot(_root, lender); - bytes32 result = ecrecoverRatifier.onRatify(offer, _root, data); + bytes32 result = ecrecoverRatifier.onRatify(offer, _root, ratifierData); assertEq(result, CALLBACK_SUCCESS); } @@ -40,38 +40,38 @@ contract EcrecoverRatifierTest is BaseTest { vm.prank(lender); midnight.setIsAuthorized(lender, borrower, true); - bytes memory data = signRoot(_root, borrower); + bytes memory ratifierData = signRoot(_root, borrower); - bytes32 result = ecrecoverRatifier.onRatify(offer, _root, data); + bytes32 result = ecrecoverRatifier.onRatify(offer, _root, ratifierData); assertEq(result, CALLBACK_SUCCESS); } function testOnRatifyUnauthorizedSigner() public { Offer memory offer = makeOffer(lender); bytes32 _root = keccak256(abi.encode(offer)); - bytes memory data = signRoot(_root, borrower); + bytes memory ratifierData = signRoot(_root, borrower); vm.expectRevert(IEcrecoverRatifier.Unauthorized.selector); - ecrecoverRatifier.onRatify(offer, _root, data); + ecrecoverRatifier.onRatify(offer, _root, ratifierData); } function testOnRatifyInvalidSignature() public { Offer memory offer = makeOffer(lender); bytes32 _root = keccak256(abi.encode(offer)); - bytes memory data = abi.encode(Signature({v: 27, r: bytes32(uint256(1)), s: bytes32(uint256(2))})); + bytes memory ratifierData = abi.encode(Signature({v: 27, r: bytes32(uint256(1)), s: bytes32(uint256(2))})); vm.expectRevert(IEcrecoverRatifier.Unauthorized.selector); - ecrecoverRatifier.onRatify(offer, _root, data); + ecrecoverRatifier.onRatify(offer, _root, ratifierData); } function testOnRatifyWrongRoot() public { Offer memory offer = makeOffer(lender); bytes32 _root = keccak256(abi.encode(offer)); - bytes memory data = signRoot(_root, lender); + bytes memory ratifierData = signRoot(_root, lender); bytes32 wrongRoot = keccak256("wrong"); vm.expectRevert(IEcrecoverRatifier.Unauthorized.selector); - ecrecoverRatifier.onRatify(offer, wrongRoot, data); + ecrecoverRatifier.onRatify(offer, wrongRoot, ratifierData); } function testOnRatifyRevokeAuthorizationInvalidates() public { @@ -81,16 +81,16 @@ contract EcrecoverRatifierTest is BaseTest { vm.prank(lender); midnight.setIsAuthorized(lender, borrower, true); - bytes memory data = signRoot(_root, borrower); + bytes memory ratifierData = signRoot(_root, borrower); // Works while authorized. - ecrecoverRatifier.onRatify(offer, _root, data); + ecrecoverRatifier.onRatify(offer, _root, ratifierData); // Revoke. vm.prank(lender); midnight.setIsAuthorized(lender, borrower, false); vm.expectRevert(IEcrecoverRatifier.Unauthorized.selector); - ecrecoverRatifier.onRatify(offer, _root, data); + ecrecoverRatifier.onRatify(offer, _root, ratifierData); } }