From be0b40bddeb459af36d106802b7091af61e0fbf1 Mon Sep 17 00:00:00 2001 From: GregTheDev <40359730+0xgregthedev@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:36:21 -0700 Subject: [PATCH] fix: repeat use caveat validation (#90) * fix: repeat use caveat validation * snapshot and add test * fix: bump snapshot --------- Co-authored-by: Joseph Delong --- .gas-snapshot | 212 +++++++++++------------ src/Starport.sol | 4 +- test/StarportTest.sol | 12 +- test/integration-testing/TestCaveats.sol | 15 +- 4 files changed, 134 insertions(+), 109 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 4a00d893..8c416940 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,154 +1,154 @@ -IntegrationTestCaveats:testInvalidCaveatLength() (gas: 129975) -IntegrationTestCaveats:testInvalidCaveats() (gas: 162024) -IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332103) -IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283244) -IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 306482) -IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159190) -IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 167771) -IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 284520) -IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 141940) -IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283364) -IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053539) -IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407606) -IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347413) -IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456197) -IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 376957) -IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402676) -ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 437967) -ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441343) -ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440792) -ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437001) -ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437778) -ModuleTesting:testModuleValidation() (gas: 1274188) +IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130019) +IntegrationTestCaveats:testInvalidCaveats() (gas: 162299) +IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332433) +IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283300) +IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 308844) +IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159528) +IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 168043) +IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 317621) +IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 142201) +IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283614) +IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053618) +IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407763) +IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347604) +IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456421) +IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377103) +IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402755) +ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 437989) +ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441365) +ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440814) +ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437023) +ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437910) +ModuleTesting:testModuleValidation() (gas: 1274210) PausableNonReentrantImpl:test() (gas: 2464) PausableNonReentrantImpl:testReentrancy() (gas: 2757) TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462) TestBorrowerEnforcer:testBERevertInvalidLoanTerms() (gas: 81160) TestBorrowerEnforcer:testBEValidLoanTerms() (gas: 72257) -TestBorrowerEnforcer:testBEValidLoanTermsAnyIssuer() (gas: 72321) +TestBorrowerEnforcer:testBEValidLoanTermsAnyIssuer() (gas: 72343) TestCustodian:testCannotLazyMintTwice() (gas: 82167) -TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72517) -TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77895) -TestCustodian:testCustodianCannotBeAuthorized() (gas: 142186) -TestCustodian:testCustodySelector() (gas: 2731984) -TestCustodian:testDefaultCustodySelectorRevert() (gas: 72370) +TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72495) +TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 78005) +TestCustodian:testCustodianCannotBeAuthorized() (gas: 142164) +TestCustodian:testCustodySelector() (gas: 2731962) +TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 173046) TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163209) TestCustodian:testGenerateOrderRepay() (gas: 177204) TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193690) -TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875889) +TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875911) TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804477) TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97670) TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 92031) -TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106931) +TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106909) TestCustodian:testGenerateOrderSettlement() (gas: 154920) TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160317) TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163387) -TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101896) -TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461580) -TestCustodian:testGetBorrower() (gas: 78643) +TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101874) +TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461569) +TestCustodian:testGetBorrower() (gas: 78621) TestCustodian:testInvalidAction() (gas: 173552) TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130196) TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130134) TestCustodian:testInvalidEncodedData() (gas: 26160) -TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366679) +TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366668) TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64523) TestCustodian:testMintWithApprovalSetNotAuthorized() (gas: 66842) -TestCustodian:testName() (gas: 7121) +TestCustodian:testName() (gas: 7099) TestCustodian:testNonPayableFunctions() (gas: 215289) -TestCustodian:testOnlySeaport() (gas: 17829) -TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105754) -TestCustodian:testPreviewOrderRepay() (gas: 230209) -TestCustodian:testPreviewOrderSettlement() (gas: 191937) -TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108315) -TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 117026) +TestCustodian:testOnlySeaport() (gas: 17918) +TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105732) +TestCustodian:testPreviewOrderRepay() (gas: 230187) +TestCustodian:testPreviewOrderSettlement() (gas: 191915) +TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108293) +TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 117004) TestCustodian:testRatifyOrder() (gas: 184025) -TestCustodian:testSeaportMetadata() (gas: 8666) +TestCustodian:testSeaportMetadata() (gas: 8644) TestCustodian:testSupportsInterface() (gas: 9428) -TestCustodian:testSymbol() (gas: 7127) -TestCustodian:testTokenURI() (gas: 85172) +TestCustodian:testSymbol() (gas: 7216) +TestCustodian:testTokenURI() (gas: 85150) TestCustodian:testTokenURIInvalidLoan() (gas: 13179) -TestLenderEnforcer:testLERevertAdditionalTransfersFromLender() (gas: 76366) -TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81118) -TestLenderEnforcer:testLEValidLoanTerms() (gas: 72191) +TestLenderEnforcer:testLERevertAdditionalTransfersFromLender() (gas: 76455) +TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096) +TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169) TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234) -TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73547) -TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592874) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 600087) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590238) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580122) -TestNewLoan:testBuyNowPayLater() (gas: 3018373) -TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874071) -TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885063) -TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429479) -TestNewLoan:testNewLoanRefinance() (gas: 589899) -TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324388) -TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383305) -TestNewLoan:testSettleLoan() (gas: 642037) +TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592756) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599969) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590120) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580004) +TestNewLoan:testBuyNowPayLater() (gas: 3018395) +TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874061) +TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885086) +TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429501) +TestNewLoan:testNewLoanRefinance() (gas: 589921) +TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324498) +TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383316) +TestNewLoan:testSettleLoan() (gas: 642059) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) -TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666991) -TestRepayLoan:testRepayLoanBase() (gas: 599777) -TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438621) -TestRepayLoan:testRepayLoanInSettlement() (gas: 585591) -TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603900) -TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858443) +TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 667011) +TestRepayLoan:testRepayLoanBase() (gas: 599797) +TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438643) +TestRepayLoan:testRepayLoanInSettlement() (gas: 585721) +TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603920) +TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858461) TestSimpleInterestPricing:test_calculateInterest() (gas: 881296) TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510) TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314) -TestStarport:testAcquireTokensFail() (gas: 60408) -TestStarport:testAcquireTokensSuccess() (gas: 162977) -TestStarport:testActive() (gas: 69202) -TestStarport:testAdditionalTransfers() (gas: 300677) -TestStarport:testAdditionalTransfersOriginate() (gas: 275373) -TestStarport:testAdditionalTransfersRefinance() (gas: 218125) +TestStarport:testAcquireTokensFail() (gas: 60386) +TestStarport:testAcquireTokensSuccess() (gas: 162955) +TestStarport:testActive() (gas: 69291) +TestStarport:testAdditionalTransfers() (gas: 300688) +TestStarport:testAdditionalTransfersOriginate() (gas: 275384) +TestStarport:testAdditionalTransfersRefinance() (gas: 218214) TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129820) -TestStarport:testCannotIssueSameLoanTwice() (gas: 363969) +TestStarport:testCannotIssueSameLoanTwice() (gas: 363991) TestStarport:testCannotOriginateWhilePaused() (gas: 73523) TestStarport:testCannotSettleInvalidLoan() (gas: 74881) -TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70941) -TestStarport:testCaveatEnforcerRevert() (gas: 100240) -TestStarport:testDefaultFeeRake1() (gas: 387902) -TestStarport:testDefaultFeeRake2() (gas: 450245) -TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397731) -TestStarport:testEIP712Signing() (gas: 83086) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237683) -TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692704) -TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376775) +TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70919) +TestStarport:testCaveatEnforcerRevert() (gas: 102534) +TestStarport:testDefaultFeeRake1() (gas: 387913) +TestStarport:testDefaultFeeRake2() (gas: 450256) +TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397742) +TestStarport:testEIP712Signing() (gas: 83064) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237672) +TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692715) +TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376786) TestStarport:testIncrementCaveatNonce() (gas: 35183) TestStarport:testInitializedFlagSetProperly() (gas: 67416) -TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230348) +TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230359) TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170774) -TestStarport:testInvalidAmountCollateral() (gas: 165890) -TestStarport:testInvalidAmountCollateral721() (gas: 165890) -TestStarport:testInvalidItemType() (gas: 151838) -TestStarport:testInvalidTransferLengthCollateral() (gas: 154129) -TestStarport:testInvalidTransferLengthDebt() (gas: 175906) +TestStarport:testInvalidAmountCollateral() (gas: 165901) +TestStarport:testInvalidAmountCollateral721() (gas: 165901) +TestStarport:testInvalidItemType() (gas: 151849) +TestStarport:testInvalidTransferLengthCollateral() (gas: 154118) +TestStarport:testInvalidTransferLengthDebt() (gas: 175917) TestStarport:testInvalidateCaveatSalt() (gas: 33450) -TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264211) -TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290336) -TestStarport:testNonPayableFunctions() (gas: 112185) -TestStarport:testOverrideFeeRake() (gas: 384225) -TestStarport:testPause() (gas: 18215) +TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264200) +TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290347) +TestStarport:testNonPayableFunctions() (gas: 114479) +TestStarport:testOverrideFeeRake() (gas: 384236) +TestStarport:testPause() (gas: 18193) TestStarport:testRefinancePostRepaymentFails() (gas: 127864) TestStarport:testStargateGetOwner() (gas: 8786) -TestStarport:testTokenNoCodeCollateral() (gas: 150651) -TestStarport:testTokenNoCodeDebt() (gas: 180902) -TestStarport:testUnpause() (gas: 17297) +TestStarport:testTokenNoCodeCollateral() (gas: 150640) +TestStarport:testTokenNoCodeDebt() (gas: 180913) +TestStarport:testUnpause() (gas: 17275) TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12330) TestStrategistOriginator:testGetStrategistData() (gas: 1790990) TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38488) TestStrategistOriginator:testIncrementCounterNotAuthorized() (gas: 13423) -TestStrategistOriginator:testInvalidCollateral() (gas: 210294) -TestStrategistOriginator:testInvalidDeadline() (gas: 216115) -TestStrategistOriginator:testInvalidDebt() (gas: 212002) -TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 212376) -TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212706) -TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212641) -TestStrategistOriginator:testInvalidDebtLength() (gas: 211296) -TestStrategistOriginator:testInvalidOffer() (gas: 427097) -TestStrategistOriginator:testInvalidSigner() (gas: 214434) +TestStrategistOriginator:testInvalidCollateral() (gas: 210224) +TestStrategistOriginator:testInvalidDeadline() (gas: 216045) +TestStrategistOriginator:testInvalidDebt() (gas: 211932) +TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 212306) +TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212636) +TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212571) +TestStrategistOriginator:testInvalidDebtLength() (gas: 211226) +TestStrategistOriginator:testInvalidOffer() (gas: 427005) +TestStrategistOriginator:testInvalidSigner() (gas: 214364) TestStrategistOriginator:testSetStrategist() (gas: 17884) -TestStrategistOriginator:testWithdraw() (gas: 168001) \ No newline at end of file +TestStrategistOriginator:testWithdraw() (gas: 167966) \ No newline at end of file diff --git a/src/Starport.sol b/src/Starport.sol index 779267ee..7895dd8f 100644 --- a/src/Starport.sol +++ b/src/Starport.sol @@ -579,8 +579,10 @@ contract Starport is PausableNonReentrant { ); if (signedCaveats.singleUse) { - invalidSalts.validateSalt(validator, signedCaveats.salt); + invalidSalts.validateSalt(validator, signedCaveats.salt); //Validates and invalidates salt emit CaveatFilled(validator, hash, signedCaveats.salt); + } else if (invalidSalts[validator][signedCaveats.salt]) { + revert StarportLib.InvalidSalt(); } if (block.timestamp > signedCaveats.deadline) { diff --git a/test/StarportTest.sol b/test/StarportTest.sol index ae8d4924..6c9e7561 100644 --- a/test/StarportTest.sol +++ b/test/StarportTest.sol @@ -410,10 +410,20 @@ contract StarportTest is BaseOrderTest, Stargate { Account memory signer, bytes32 salt, address enforcer + ) public view returns (CaveatEnforcer.SignedCaveats memory signedCaveats) { + return getBorrowerSignedCaveat(details, signer, salt, enforcer, true); + } + + function getBorrowerSignedCaveat( + BorrowerEnforcer.Details memory details, + Account memory signer, + bytes32 salt, + address enforcer, + bool singleUse ) public view returns (CaveatEnforcer.SignedCaveats memory signedCaveats) { signedCaveats.caveats = new CaveatEnforcer.Caveat[](1); signedCaveats.salt = salt; - signedCaveats.singleUse = true; + signedCaveats.singleUse = singleUse; signedCaveats.deadline = block.timestamp + 1 days; signedCaveats.caveats[0] = CaveatEnforcer.Caveat({enforcer: enforcer, data: abi.encode(details)}); bytes32 hash = SP.hashCaveatWithSaltAndNonce( diff --git a/test/integration-testing/TestCaveats.sol b/test/integration-testing/TestCaveats.sol index feb00f81..c8819a22 100644 --- a/test/integration-testing/TestCaveats.sol +++ b/test/integration-testing/TestCaveats.sol @@ -45,8 +45,10 @@ contract IntegrationTestCaveats is StarportTest, DeepEq, MockCall { details: BorrowerEnforcer.Details({loan: loan}), signer: borrower, salt: bytes32(uint256(1)), - enforcer: address(borrowerEnforcer) + enforcer: address(borrowerEnforcer), + singleUse: true }); + _setApprovalsForSpentItems(borrower.addr, loan.collateral); _setApprovalsForSpentItems(lender.addr, loan.debt); @@ -56,6 +58,17 @@ contract IntegrationTestCaveats is StarportTest, DeepEq, MockCall { vm.expectRevert(StarportLib.InvalidSalt.selector); SP.originate(new AdditionalTransfer[](0), borrowerCaveat, _emptyCaveat(), loan); + + borrowerCaveat = getBorrowerSignedCaveat({ + details: BorrowerEnforcer.Details({loan: loan}), + signer: borrower, + salt: bytes32(uint256(1)), + enforcer: address(borrowerEnforcer), + singleUse: false + }); + + vm.expectRevert(StarportLib.InvalidSalt.selector); + SP.originate(new AdditionalTransfer[](0), borrowerCaveat, _emptyCaveat(), loan); } function testOriginateWCaveatsExpired() public {