diff --git a/.gas-snapshot b/.gas-snapshot index 9d13b9f1..919f9aab 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,89 +1,89 @@ -IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130030) -IntegrationTestCaveats:testInvalidCaveats() (gas: 162079) -IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332191) -IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283321) -IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 308842) -IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159245) -IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 168023) -IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 284597) -IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 141984) -IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283441) -IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053638) -IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407738) -IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347534) -IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456351) -IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377100) -IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402797) +IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130063) +IntegrationTestCaveats:testInvalidCaveats() (gas: 162343) +IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332499) +IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283366) +IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 308910) +IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159572) +IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 168284) +IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 317731) +IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 142245) +IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283680) +IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053706) +IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407873) +IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347714) +IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456553) +IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377235) +IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402865) ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 438055) ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441431) ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440880) ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437089) -ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437866) +ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437976) ModuleTesting:testModuleValidation() (gas: 1274276) 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: 82189) -TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72517) -TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77917) -TestCustodian:testCustodianCannotBeAuthorized() (gas: 142208) -TestCustodian:testCustodySelector() (gas: 2697893) -TestCustodian:testDefaultCustodySelectorRevert() (gas: 72370) +TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72495) +TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 78027) +TestCustodian:testCustodianCannotBeAuthorized() (gas: 142186) +TestCustodian:testCustodySelector() (gas: 2697871) +TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 173136) TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163299) TestCustodian:testGenerateOrderRepay() (gas: 177294) TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193780) TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875125) -TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804811) +TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804789) TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97670) TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 92031) -TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106931) +TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106909) TestCustodian:testGenerateOrderSettlement() (gas: 155010) TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160407) TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163477) -TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101896) -TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461657) -TestCustodian:testGetBorrower() (gas: 78643) +TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101874) +TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461635) +TestCustodian:testGetBorrower() (gas: 78621) TestCustodian:testInvalidAction() (gas: 173596) TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130218) TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130156) TestCustodian:testInvalidEncodedData() (gas: 26160) -TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366778) +TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366756) 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: 105776) -TestCustodian:testPreviewOrderRepay() (gas: 230321) -TestCustodian:testPreviewOrderSettlement() (gas: 192049) -TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108337) -TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 117048) +TestCustodian:testOnlySeaport() (gas: 17918) +TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105754) +TestCustodian:testPreviewOrderRepay() (gas: 230299) +TestCustodian:testPreviewOrderSettlement() (gas: 192027) +TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108315) +TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 117026) TestCustodian:testRatifyOrder() (gas: 184115) -TestCustodian:testSeaportMetadata() (gas: 8666) +TestCustodian:testSeaportMetadata() (gas: 8644) TestCustodian:testSupportsInterface() (gas: 9428) -TestCustodian:testSymbol() (gas: 7127) -TestCustodian:testTokenURI() (gas: 84268) +TestCustodian:testSymbol() (gas: 7216) +TestCustodian:testTokenURI() (gas: 84246) 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: 591976) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599189) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590460) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580322) -TestNewLoan:testBuyNowPayLater() (gas: 2873886) +TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 591836) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599049) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590320) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580182) +TestNewLoan:testBuyNowPayLater() (gas: 2873894) TestNewLoan:testInvalidSenderBNPL() (gas: 1613098) TestNewLoan:testInvalidUserDataHashBNPL() (gas: 1615699) -TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874126) -TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885151) +TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874195) +TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885184) TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429567) -TestNewLoan:testNewLoanRefinance() (gas: 590053) +TestNewLoan:testNewLoanRefinance() (gas: 589965) TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 326073) TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 384870) TestNewLoan:testSettleLoan() (gas: 642193) @@ -94,29 +94,29 @@ TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 667213) TestRepayLoan:testRepayLoanBase() (gas: 599977) TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438709) -TestRepayLoan:testRepayLoanInSettlement() (gas: 585914) +TestRepayLoan:testRepayLoanInSettlement() (gas: 586024) TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 604010) TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858845) TestSimpleInterestPricing:test_calculateInterest() (gas: 881296) TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510) TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314) -TestStarport:testAcquireTokensFail() (gas: 60430) -TestStarport:testAcquireTokensSuccess() (gas: 162999) -TestStarport:testActive() (gas: 69224) +TestStarport:testAcquireTokensFail() (gas: 60408) +TestStarport:testAcquireTokensSuccess() (gas: 162977) +TestStarport:testActive() (gas: 69313) TestStarport:testAdditionalTransfers() (gas: 300732) TestStarport:testAdditionalTransfersOriginate() (gas: 275428) -TestStarport:testAdditionalTransfersRefinance() (gas: 218147) +TestStarport:testAdditionalTransfersRefinance() (gas: 218236) TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129974) TestStarport:testCannotIssueSameLoanTwice() (gas: 364079) TestStarport:testCannotOriginateWhilePaused() (gas: 73567) TestStarport:testCannotSettleInvalidLoan() (gas: 74903) -TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70963) +TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70941) TestStarport:testCaveatEnforcerRevert() (gas: 102578) TestStarport:testDefaultFeeRake1() (gas: 387829) TestStarport:testDefaultFeeRake2() (gas: 450172) TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397652) -TestStarport:testEIP712Signing() (gas: 83020) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237850) +TestStarport:testEIP712Signing() (gas: 82998) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237828) TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692871) TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376830) TestStarport:testIncrementCaveatNonce() (gas: 35292) @@ -126,31 +126,31 @@ TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170796) TestStarport:testInvalidAmountCollateral() (gas: 165945) TestStarport:testInvalidAmountCollateral721() (gas: 165945) TestStarport:testInvalidItemType() (gas: 151893) -TestStarport:testInvalidTransferLengthCollateral() (gas: 154184) +TestStarport:testInvalidTransferLengthCollateral() (gas: 154162) TestStarport:testInvalidTransferLengthDebt() (gas: 175961) TestStarport:testInvalidateCaveatSalt() (gas: 33450) -TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264266) +TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264244) TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290391) TestStarport:testNonPayableFunctions() (gas: 114523) TestStarport:testOverrideFeeRake() (gas: 384063) -TestStarport:testPause() (gas: 18259) +TestStarport:testPause() (gas: 18237) TestStarport:testRefinancePostRepaymentFails() (gas: 127886) TestStarport:testStargateGetOwner() (gas: 8808) -TestStarport:testTokenNoCodeCollateral() (gas: 150706) +TestStarport:testTokenNoCodeCollateral() (gas: 150684) TestStarport:testTokenNoCodeDebt() (gas: 180957) -TestStarport:testUnpause() (gas: 17363) +TestStarport:testUnpause() (gas: 17341) TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12330) TestStrategistOriginator:testGetStrategistData() (gas: 1809233) TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38790) TestStrategistOriginator:testIncrementCounterNotAuthorized() (gas: 13423) -TestStrategistOriginator:testInvalidCollateral() (gas: 211094) -TestStrategistOriginator:testInvalidDeadline() (gas: 216915) -TestStrategistOriginator:testInvalidDebt() (gas: 212802) -TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 213176) -TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 213486) -TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 213441) -TestStrategistOriginator:testInvalidDebtLength() (gas: 212096) -TestStrategistOriginator:testInvalidOffer() (gas: 427930) -TestStrategistOriginator:testInvalidSigner() (gas: 215234) +TestStrategistOriginator:testInvalidCollateral() (gas: 211024) +TestStrategistOriginator:testInvalidDeadline() (gas: 216845) +TestStrategistOriginator:testInvalidDebt() (gas: 212732) +TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 213106) +TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 213416) +TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 213371) +TestStrategistOriginator:testInvalidDebtLength() (gas: 212026) +TestStrategistOriginator:testInvalidOffer() (gas: 427827) +TestStrategistOriginator:testInvalidSigner() (gas: 215164) 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/test/StarportTest.sol b/test/StarportTest.sol index 8efc3142..c3dacc3f 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 {