From 1e6c3c3de8369df02fd35cc2f46a25792c3373ab Mon Sep 17 00:00:00 2001 From: GregTheDev Date: Wed, 17 Jan 2024 16:24:43 -0700 Subject: [PATCH] snapshot and add test --- .gas-snapshot | 141 ++++++++++++++++++----- lib/forge-std | 2 +- lib/seaport | 2 +- lib/solady | 2 +- lib/solmate | 2 +- test/StarportTest.sol | 12 +- test/integration-testing/TestCaveats.sol | 15 ++- 7 files changed, 144 insertions(+), 32 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index b82e7230..92f0feb6 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,3 +1,4 @@ +<<<<<<< HEAD IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130030) IntegrationTestCaveats:testInvalidCaveats() (gas: 162079) IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332191) @@ -14,19 +15,38 @@ IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 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) +>>>>>>> d5c1cb1 (snapshot and add test) 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) +<<<<<<< HEAD TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72517) TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77917) TestCustodian:testCustodianCannotBeAuthorized() (gas: 142208) @@ -47,15 +67,38 @@ TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163409) TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101896) TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461657) TestCustodian:testGetBorrower() (gas: 78643) +======= +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: 804789) +TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97670) +TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 92031) +TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106909) +TestCustodian:testGenerateOrderSettlement() (gas: 155010) +TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160407) +TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163477) +TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101874) +TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461635) +TestCustodian:testGetBorrower() (gas: 78621) +>>>>>>> d5c1cb1 (snapshot and add test) 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) +<<<<<<< HEAD TestCustodian:testOnlySeaport() (gas: 17829) TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105776) TestCustodian:testPreviewOrderRepay() (gas: 230253) @@ -67,11 +110,25 @@ TestCustodian:testSeaportMetadata() (gas: 8666) TestCustodian:testSupportsInterface() (gas: 9428) TestCustodian:testSymbol() (gas: 7127) TestCustodian:testTokenURI() (gas: 85046) +======= +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: 8644) +TestCustodian:testSupportsInterface() (gas: 9428) +TestCustodian:testSymbol() (gas: 7216) +TestCustodian:testTokenURI() (gas: 84246) +>>>>>>> d5c1cb1 (snapshot and add test) 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) +<<<<<<< HEAD TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73547) TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 593006) TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 600219) @@ -85,6 +142,23 @@ TestNewLoan:testNewLoanRefinance() (gas: 590053) TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 325963) TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 384892) TestNewLoan:testSettleLoan() (gas: 642147) +======= +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: 874195) +TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885184) +TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429567) +TestNewLoan:testNewLoanRefinance() (gas: 589965) +TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 326073) +TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 384870) +TestNewLoan:testSettleLoan() (gas: 642193) +>>>>>>> d5c1cb1 (snapshot and add test) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) @@ -92,30 +166,40 @@ TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 667145) TestRepayLoan:testRepayLoanBase() (gas: 599909) TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438709) +<<<<<<< HEAD TestRepayLoan:testRepayLoanInSettlement() (gas: 585701) +======= +TestRepayLoan:testRepayLoanInSettlement() (gas: 586024) +>>>>>>> d5c1cb1 (snapshot and add test) TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 604010) TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858641) 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: 387823) TestStarport:testDefaultFeeRake2() (gas: 450166) TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397652) +<<<<<<< HEAD TestStarport:testEIP712Signing() (gas: 83020) TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237782) TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692803) +======= +TestStarport:testEIP712Signing() (gas: 82998) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237828) +TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692871) +>>>>>>> d5c1cb1 (snapshot and add test) TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376830) TestStarport:testIncrementCaveatNonce() (gas: 35006) TestStarport:testInitializedFlagSetProperly() (gas: 67438) @@ -124,31 +208,36 @@ 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) +<<<<<<< HEAD TestStarport:testOverrideFeeRake() (gas: 384057) TestStarport:testPause() (gas: 18259) +======= +TestStarport:testOverrideFeeRake() (gas: 384063) +TestStarport:testPause() (gas: 18237) +>>>>>>> d5c1cb1 (snapshot and add test) 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: 1790990) TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38488) 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/lib/forge-std b/lib/forge-std index e8a047e3..87a2a0af 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit e8a047e3f40f13fa37af6fe14e6e06283d9a060e +Subproject commit 87a2a0afc5fafd6297538a45a52ac19e71a84562 diff --git a/lib/seaport b/lib/seaport index 43d06a18..50a0c096 160000 --- a/lib/seaport +++ b/lib/seaport @@ -1 +1 @@ -Subproject commit 43d06a187b082dfc27fc5867ba182301cf485af2 +Subproject commit 50a0c09621f90196e8d07dbfb6c564256a241e66 diff --git a/lib/solady b/lib/solady index 88bb5f22..741bda9b 160000 --- a/lib/solady +++ b/lib/solady @@ -1 +1 @@ -Subproject commit 88bb5f223ae3d8567229f39d6c19b5d4c7c4a069 +Subproject commit 741bda9b2914444bf3060da85c7615f64ce4eee1 diff --git a/lib/solmate b/lib/solmate index 2001af43..4b47a190 160000 --- a/lib/solmate +++ b/lib/solmate @@ -1 +1 @@ -Subproject commit 2001af43aedb46fdc2335d2a7714fb2dae7cfcd1 +Subproject commit 4b47a19038b798b4a33d9749d25e570443520647 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 {