From 89f268f249309789d379beb1dd947a6022788619 Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 08:43:58 -0600 Subject: [PATCH 01/10] fix: validate that window is not zero i nthe valdiate method --- .gas-snapshot | 107 +++++++++++----------- src/settlement/DutchAuctionSettlement.sol | 4 +- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 12013561..b919d885 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,25 +1,25 @@ -IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130086) -IntegrationTestCaveats:testInvalidCaveats() (gas: 162366) -IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332567) -IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283456) -IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 308978) -IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159595) -IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 168066) -IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 317755) -IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 142246) -IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283770) -IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053752) -IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407964) -IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347805) -IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456578) -IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377260) -IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402978) -ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 438123) -ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441499) -ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440948) -ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437157) -ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 438044) -ModuleTesting:testModuleValidation() (gas: 1274344) +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: 437043) +ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437950) +ModuleTesting:testModuleValidation() (gas: 1274270) PausableNonReentrantImpl:test() (gas: 2464) PausableNonReentrantImpl:testReentrancy() (gas: 2757) TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462) @@ -98,38 +98,37 @@ TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858771) TestSimpleInterestPricing:test_calculateInterest() (gas: 881296) TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510) TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314) -TestStarport:testAcquireTokensFail() (gas: 60473) -TestStarport:testAcquireTokensSuccess() (gas: 163042) -TestStarport:testActive() (gas: 69358) -TestStarport:testAdditionalTransfers() (gas: 300755) -TestStarport:testAdditionalTransfersOriginate() (gas: 275540) -TestStarport:testAdditionalTransfersRefinance() (gas: 218206) -TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129484) -TestStarport:testCannotIssueSameLoanTwice() (gas: 364125) -TestStarport:testCannotOriginateWhilePaused() (gas: 73479) -TestStarport:testCannotSettleInvalidLoan() (gas: 74969) -TestStarport:testCannotSettleUnlessValidCustodian() (gas: 71007) -TestStarport:testCaveatEnforcerRevert() (gas: 102601) -TestStarport:testDefaultFeeRake1() (gas: 383458) -TestStarport:testDefaultFeeRake2() (gas: 445821) -TestStarport:testDefaultFeeRakeExoticDebt() (gas: 394564) -TestStarport:testEIP712Signing() (gas: 83109) -TestStarport:testExcessiveFeeRake() (gas: 19992) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237783) -TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1692826) -TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376831) -TestStarport:testIncrementCaveatNonce() (gas: 35117) -TestStarport:testInitializedFlagSetProperly() (gas: 67372) -TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230426) -TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170766) -TestStarport:testInvalidAmountCollateral() (gas: 165968) -TestStarport:testInvalidAmountCollateral721() (gas: 165968) -TestStarport:testInvalidItemType() (gas: 151916) -TestStarport:testInvalidTransferLengthCollateral() (gas: 154185) -TestStarport:testInvalidTransferLengthDebt() (gas: 175984) -TestStarport:testInvalidateCaveatSalt() (gas: 33428) -TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264267) -TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290392) +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: 363991) +TestStarport:testCannotOriginateWhilePaused() (gas: 73523) +TestStarport:testCannotSettleInvalidLoan() (gas: 74881) +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: 1695724) +TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376786) +TestStarport:testIncrementCaveatNonce() (gas: 35183) +TestStarport:testInitializedFlagSetProperly() (gas: 67416) +TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230359) +TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170774) +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: 264200) +TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290347) TestStarport:testNonPayableFunctions() (gas: 114479) TestStarport:testOverrideFeeRake() (gas: 379873) TestStarport:testPause() (gas: 18127) diff --git a/src/settlement/DutchAuctionSettlement.sol b/src/settlement/DutchAuctionSettlement.sol index 2835f614..14e5dda2 100644 --- a/src/settlement/DutchAuctionSettlement.sol +++ b/src/settlement/DutchAuctionSettlement.sol @@ -92,7 +92,9 @@ abstract contract DutchAuctionSettlement is Settlement, AmountDeriver { // @inheritdoc Validation function validate(Starport.Loan calldata loan) external view virtual override returns (bytes4) { Details memory details = abi.decode(loan.terms.settlementData, (Details)); - return (details.startingPrice > details.endingPrice) ? Validation.validate.selector : bytes4(0xFFFFFFFF); + return (details.startingPrice > details.endingPrice && details.window != 0) + ? Validation.validate.selector + : bytes4(0xFFFFFFFF); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ From 94544f585185c513340dab3e27aff09af2408d05 Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 10:46:22 -0600 Subject: [PATCH 02/10] =?UTF-8?q?fix:=20I-10.=20maximumSpent=20isn?= =?UTF-8?q?=E2=80=99t=20used=20on=20Custodian.generateOrder=20and=20can=20?= =?UTF-8?q?be=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Custodian.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Custodian.sol b/src/Custodian.sol index 9da68f90..553f2c95 100644 --- a/src/Custodian.sol +++ b/src/Custodian.sol @@ -210,7 +210,6 @@ contract Custodian is ERC721, ContractOffererInterface { /** * @dev Generates the order for this contract offerer * @param fulfiller The address of the contract fulfiller - * @param maximumSpent The maximum amount of items to be spent by the order * @param context The context of the order * @return offer The items spent by the order * @return consideration The items received by the order @@ -218,7 +217,7 @@ contract Custodian is ERC721, ContractOffererInterface { function generateOrder( address fulfiller, SpentItem[] calldata, - SpentItem[] calldata maximumSpent, + SpentItem[] calldata, bytes calldata context // encoded based on the schemaID ) external onlySeaport returns (SpentItem[] memory offer, ReceivedItem[] memory consideration) { (Command memory close) = abi.decode(context, (Command)); From 28b684d4047334acb6ce0ea025e82d3de10b996e Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 10:56:35 -0600 Subject: [PATCH 03/10] fix: activeUserDataHash unused in BNPLHelper --- src/BNPLHelper.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BNPLHelper.sol b/src/BNPLHelper.sol index 21e63c42..1d0be0c4 100644 --- a/src/BNPLHelper.sol +++ b/src/BNPLHelper.sol @@ -87,8 +87,6 @@ contract BNPLHelper is IFlashLoanRecipient, Ownable { /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - bytes32 private activeUserDataHash; - /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRUCTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ From e7444b88e8ef9d4947f41897efa35c17e6b19669 Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 12:57:44 -0600 Subject: [PATCH 04/10] fix: M-3. Error-prone string casting for tokenURI --- .gas-snapshot | 110 ++++++++++++++-------------- src/Custodian.sol | 3 +- test/unit-testing/TestCustodian.sol | 2 +- 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index b919d885..264c190e 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -26,75 +26,75 @@ TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462) TestBorrowerEnforcer:testBERevertInvalidLoanTerms() (gas: 81160) TestBorrowerEnforcer:testBEValidLoanTerms() (gas: 72257) TestBorrowerEnforcer:testBEValidLoanTermsAnyIssuer() (gas: 72343) -TestCustodian:testCannotLazyMintTwice() (gas: 82123) -TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72495) -TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77961) -TestCustodian:testCustodianCannotBeAuthorized() (gas: 142120) -TestCustodian:testCustodySelector() (gas: 2731962) +TestCustodian:testCannotLazyMintTwice() (gas: 82149) +TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72477) +TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77987) +TestCustodian:testCustodianCannotBeAuthorized() (gas: 142006) +TestCustodian:testCustodySelector() (gas: 2740377) TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) -TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 173134) -TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163297) -TestCustodian:testGenerateOrderRepay() (gas: 177292) -TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193778) -TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 876355) -TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804921) -TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97670) -TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 92031) -TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106909) -TestCustodian:testGenerateOrderSettlement() (gas: 155008) -TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160405) -TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163475) -TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101874) -TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461703) -TestCustodian:testGetBorrower() (gas: 78621) -TestCustodian:testInvalidAction() (gas: 173464) -TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130152) -TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130090) +TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172904) +TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163085) +TestCustodian:testGenerateOrderRepay() (gas: 177062) +TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193530) +TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875627) +TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804229) +TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97618) +TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 91979) +TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106821) +TestCustodian:testGenerateOrderSettlement() (gas: 154796) +TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160193) +TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163281) +TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101804) +TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461569) +TestCustodian:testGetBorrower() (gas: 78603) +TestCustodian:testInvalidAction() (gas: 173412) +TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130074) +TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130012) TestCustodian:testInvalidEncodedData() (gas: 26160) -TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366758) -TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64523) +TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366650) +TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64505) TestCustodian:testMintWithApprovalSetNotAuthorized() (gas: 66842) -TestCustodian:testName() (gas: 7099) +TestCustodian:testName() (gas: 7077) TestCustodian:testNonPayableFunctions() (gas: 215289) TestCustodian:testOnlySeaport() (gas: 17918) -TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105688) -TestCustodian:testPreviewOrderRepay() (gas: 230231) -TestCustodian:testPreviewOrderSettlement() (gas: 191959) -TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108249) -TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116960) -TestCustodian:testRatifyOrder() (gas: 184113) -TestCustodian:testSeaportMetadata() (gas: 8644) +TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105714) +TestCustodian:testPreviewOrderRepay() (gas: 229939) +TestCustodian:testPreviewOrderSettlement() (gas: 191703) +TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108205) +TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116898) +TestCustodian:testRatifyOrder() (gas: 183883) +TestCustodian:testSeaportMetadata() (gas: 8588) TestCustodian:testSupportsInterface() (gas: 9428) -TestCustodian:testSymbol() (gas: 7216) -TestCustodian:testTokenURI() (gas: 85150) +TestCustodian:testSymbol() (gas: 7194) +TestCustodian:testTokenURI() (gas: 85244) TestCustodian:testTokenURIInvalidLoan() (gas: 13179) TestLenderEnforcer:testLERevertAdditionalTransfersFromLender() (gas: 76455) TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096) TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169) TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234) TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) -TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592934) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 600147) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590365) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 580182) -TestNewLoan:testBuyNowPayLater() (gas: 3018529) -TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874195) -TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885220) -TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429635) -TestNewLoan:testNewLoanRefinance() (gas: 590070) -TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324676) -TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383472) -TestNewLoan:testSettleLoan() (gas: 642281) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592508) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599721) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589872) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579756) +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: 641935) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) -TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 667145) -TestRepayLoan:testRepayLoanBase() (gas: 599975) -TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438777) -TestRepayLoan:testRepayLoanInSettlement() (gas: 585811) -TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 604010) -TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 858771) +TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666727) +TestRepayLoan:testRepayLoanBase() (gas: 599549) +TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438643) +TestRepayLoan:testRepayLoanInSettlement() (gas: 585529) +TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603638) +TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857859) TestSimpleInterestPricing:test_calculateInterest() (gas: 881296) TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510) TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314) @@ -114,8 +114,8 @@ TestStarport:testDefaultFeeRake1() (gas: 387913) TestStarport:testDefaultFeeRake2() (gas: 450256) TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397742) TestStarport:testEIP712Signing() (gas: 83064) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237672) -TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695724) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237664) +TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695704) TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376786) TestStarport:testIncrementCaveatNonce() (gas: 35183) TestStarport:testInitializedFlagSetProperly() (gas: 67416) diff --git a/src/Custodian.sol b/src/Custodian.sol index 553f2c95..c4862ed6 100644 --- a/src/Custodian.sol +++ b/src/Custodian.sol @@ -44,6 +44,7 @@ import {LibString} from "solady/src/utils/LibString.sol"; contract Custodian is ERC721, ContractOffererInterface { using {StarportLib.getId} for Starport.Loan; + using {LibString.concat} for string; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ @@ -124,7 +125,7 @@ contract Custodian is ERC721, ContractOffererInterface { if (!_exists(loanId)) { revert InvalidLoan(); } - return string(abi.encodePacked("https://astaria.xyz/loans/", LibString.toString(loanId))); + return string("https://astaria.xyz/metadata/loan/").concat(LibString.toString(loanId)); } /** diff --git a/test/unit-testing/TestCustodian.sol b/test/unit-testing/TestCustodian.sol index 7c9ffaf7..7643d7bb 100644 --- a/test/unit-testing/TestCustodian.sol +++ b/test/unit-testing/TestCustodian.sol @@ -106,7 +106,7 @@ contract TestCustodian is StarportTest, DeepEq, MockCall { function testTokenURI() public { string memory expected = string( abi.encodePacked( - "https://astaria.xyz/loans/", LibString.toString(uint256(keccak256(abi.encode(activeLoan)))) + "https://astaria.xyz/metadata/loan/", LibString.toString(uint256(keccak256(abi.encode(activeLoan)))) ) ); assertEq(custodian.tokenURI(uint256(keccak256(abi.encode(activeLoan)))), expected); From bc03032609bcdcf4ad60a60ba77af06cd7e25fce Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 15:02:02 -0600 Subject: [PATCH 05/10] fix: strategist fee unused --- .gas-snapshot | 115 +++++++++--------- src/BNPLHelper.sol | 20 ++- src/Custodian.sol | 5 +- src/originators/StrategistOriginator.sol | 17 +-- test/StarportTest.sol | 2 +- test/unit-testing/TestStarport.sol | 4 +- .../unit-testing/TestStrategistOriginator.sol | 7 -- 7 files changed, 74 insertions(+), 96 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 264c190e..b9cdc4e6 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -29,27 +29,27 @@ TestBorrowerEnforcer:testBEValidLoanTermsAnyIssuer() (gas: 72343) TestCustodian:testCannotLazyMintTwice() (gas: 82149) TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72477) TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77987) -TestCustodian:testCustodianCannotBeAuthorized() (gas: 142006) -TestCustodian:testCustodySelector() (gas: 2740377) +TestCustodian:testCustodianCannotBeAuthorized() (gas: 142011) +TestCustodian:testCustodySelector() (gas: 2717132) TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) -TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172904) -TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163085) -TestCustodian:testGenerateOrderRepay() (gas: 177062) -TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193530) -TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875627) -TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804229) -TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97618) -TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 91979) -TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106821) -TestCustodian:testGenerateOrderSettlement() (gas: 154796) -TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160193) -TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163281) -TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101804) +TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172910) +TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163090) +TestCustodian:testGenerateOrderRepay() (gas: 177070) +TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193538) +TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875643) +TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804243) +TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97556) +TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 91917) +TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106827) +TestCustodian:testGenerateOrderSettlement() (gas: 154803) +TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160200) +TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163286) +TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101809) TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461569) TestCustodian:testGetBorrower() (gas: 78603) -TestCustodian:testInvalidAction() (gas: 173412) -TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130074) -TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130012) +TestCustodian:testInvalidAction() (gas: 179778) +TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130080) +TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130017) TestCustodian:testInvalidEncodedData() (gas: 26160) TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366650) TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64505) @@ -58,11 +58,11 @@ TestCustodian:testName() (gas: 7077) TestCustodian:testNonPayableFunctions() (gas: 215289) TestCustodian:testOnlySeaport() (gas: 17918) TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105714) -TestCustodian:testPreviewOrderRepay() (gas: 229939) -TestCustodian:testPreviewOrderSettlement() (gas: 191703) +TestCustodian:testPreviewOrderRepay() (gas: 229947) +TestCustodian:testPreviewOrderSettlement() (gas: 191710) TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108205) TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116898) -TestCustodian:testRatifyOrder() (gas: 183883) +TestCustodian:testRatifyOrder() (gas: 183891) TestCustodian:testSeaportMetadata() (gas: 8588) TestCustodian:testSupportsInterface() (gas: 9428) TestCustodian:testSymbol() (gas: 7194) @@ -73,28 +73,28 @@ TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096) TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169) TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234) TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) -TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592508) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599721) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589872) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579756) -TestNewLoan:testBuyNowPayLater() (gas: 3018395) -TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874061) -TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885086) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592516) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599729) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589880) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579764) +TestNewLoan:testBuyNowPayLater() (gas: 3018379) +TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874045) +TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885070) TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429501) TestNewLoan:testNewLoanRefinance() (gas: 589921) -TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324498) -TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383316) -TestNewLoan:testSettleLoan() (gas: 641935) +TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324584) +TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383414) +TestNewLoan:testSettleLoan() (gas: 641934) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) -TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666727) -TestRepayLoan:testRepayLoanBase() (gas: 599549) +TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666737) +TestRepayLoan:testRepayLoanBase() (gas: 599559) TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438643) -TestRepayLoan:testRepayLoanInSettlement() (gas: 585529) -TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603638) -TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857859) +TestRepayLoan:testRepayLoanInSettlement() (gas: 585543) +TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603652) +TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857883) TestSimpleInterestPricing:test_calculateInterest() (gas: 881296) TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510) TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314) @@ -113,9 +113,9 @@ TestStarport:testCaveatEnforcerRevert() (gas: 102534) TestStarport:testDefaultFeeRake1() (gas: 387913) TestStarport:testDefaultFeeRake2() (gas: 450256) TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397742) -TestStarport:testEIP712Signing() (gas: 83064) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237664) -TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695704) +TestStarport:testEIP712Signing() (gas: 83056) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237672) +TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695711) TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376786) TestStarport:testIncrementCaveatNonce() (gas: 35183) TestStarport:testInitializedFlagSetProperly() (gas: 67416) @@ -133,22 +133,21 @@ TestStarport:testNonPayableFunctions() (gas: 114479) TestStarport:testOverrideFeeRake() (gas: 379873) TestStarport:testPause() (gas: 18127) TestStarport:testRefinancePostRepaymentFails() (gas: 127864) -TestStarport:testStargateGetOwner() (gas: 8851) -TestStarport:testTokenNoCodeCollateral() (gas: 150707) -TestStarport:testTokenNoCodeDebt() (gas: 180980) -TestStarport:testUnpause() (gas: 17187) -TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12330) -TestStrategistOriginator:testGetStrategistData() (gas: 1790990) -TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38488) -TestStrategistOriginator:testIncrementCounterNotAuthorized() (gas: 13423) -TestStrategistOriginator:testInvalidCollateral() (gas: 210380) -TestStrategistOriginator:testInvalidDeadline() (gas: 216201) -TestStrategistOriginator:testInvalidDebt() (gas: 212088) -TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 212462) -TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212792) -TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212727) -TestStrategistOriginator:testInvalidDebtLength() (gas: 211382) -TestStrategistOriginator:testInvalidOffer() (gas: 427161) -TestStrategistOriginator:testInvalidSigner() (gas: 214520) -TestStrategistOriginator:testSetStrategist() (gas: 17884) -TestStrategistOriginator:testWithdraw() (gas: 167966) \ No newline at end of file +TestStarport:testStargateGetOwner() (gas: 8786) +TestStarport:testTokenNoCodeCollateral() (gas: 150640) +TestStarport:testTokenNoCodeDebt() (gas: 180913) +TestStarport:testUnpause() (gas: 17275) +TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12429) +TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38457) +TestStrategistOriginator:testIncrementCounterNotAuthorized() (gas: 13468) +TestStrategistOriginator:testInvalidCollateral() (gas: 210360) +TestStrategistOriginator:testInvalidDeadline() (gas: 216181) +TestStrategistOriginator:testInvalidDebt() (gas: 212068) +TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 212552) +TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212772) +TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212707) +TestStrategistOriginator:testInvalidDebtLength() (gas: 211362) +TestStrategistOriginator:testInvalidOffer() (gas: 427184) +TestStrategistOriginator:testInvalidSigner() (gas: 214522) +TestStrategistOriginator:testSetStrategist() (gas: 17852) +TestStrategistOriginator:testWithdraw() (gas: 167948) diff --git a/src/BNPLHelper.sol b/src/BNPLHelper.sol index 1d0be0c4..8667642f 100644 --- a/src/BNPLHelper.sol +++ b/src/BNPLHelper.sol @@ -77,16 +77,12 @@ contract BNPLHelper is IFlashLoanRecipient, Ownable { error InvalidUserDataProvided(); error SenderNotVault(); - /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ - /* CONSTANTS AND IMMUTABLES */ - /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - - address private VAULT; - /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ + address private vault; + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRUCTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ @@ -103,13 +99,13 @@ contract BNPLHelper is IFlashLoanRecipient, Ownable { Fulfillment[] fulfillments; } - constructor(address vault, address owner) { - VAULT = vault; + constructor(address _vault, address owner) { + vault = _vault; _initializeOwner(owner); } function makeFlashLoan(address[] calldata tokens, uint256[] calldata amounts, bytes calldata userData) external { - IVault(VAULT).flashLoan(this, tokens, amounts, userData); + IVault(vault).flashLoan(this, tokens, amounts, userData); } function receiveFlashLoan( @@ -138,7 +134,7 @@ contract BNPLHelper is IFlashLoanRecipient, Ownable { identifier: 0, token: tokens[i], from: execution.borrower, - to: VAULT, + to: vault, amount: amounts[i] + feeAmounts[i] }); unchecked { @@ -150,7 +146,7 @@ contract BNPLHelper is IFlashLoanRecipient, Ownable { ); } - function setFlashVault(address vault) external onlyOwner { - VAULT = vault; + function setFlashVault(address _vault) external onlyOwner { + vault = _vault; } } diff --git a/src/Custodian.sol b/src/Custodian.sol index c4862ed6..ee6c5062 100644 --- a/src/Custodian.sol +++ b/src/Custodian.sol @@ -226,7 +226,8 @@ contract Custodian is ERC721, ContractOffererInterface { if (loan.start == block.timestamp) { revert InvalidLoan(); } - if (close.action == Actions.Repayment && Status(loan.terms.status).isActive(loan, close.extraData)) { + bool loanActive = Status(loan.terms.status).isActive(loan, close.extraData); + if (close.action == Actions.Repayment && loanActive) { if (fulfiller != getBorrower(loan) && fulfiller != _getApproved(loan.getId())) { revert InvalidRepayer(); } @@ -240,7 +241,7 @@ contract Custodian is ERC721, ContractOffererInterface { _settleLoan(loan); _postRepaymentExecute(loan, fulfiller); - } else if (close.action == Actions.Settlement && !Status(loan.terms.status).isActive(loan, close.extraData)) { + } else if (close.action == Actions.Settlement && !loanActive) { address authorized; _beforeGetSettlementConsideration(loan); (consideration, authorized) = Settlement(loan.terms.settlement).getSettlementConsideration(loan); diff --git a/src/originators/StrategistOriginator.sol b/src/originators/StrategistOriginator.sol index ea388978..f301dd16 100644 --- a/src/originators/StrategistOriginator.sol +++ b/src/originators/StrategistOriginator.sol @@ -86,7 +86,6 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { // Strategist address and fee address public strategist; - uint256 public strategistFee; uint256 private _counter; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ @@ -111,11 +110,10 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { /* CONSTRUCTOR */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - constructor(Starport SP_, address strategist_, uint256 fee_, address owner) { + constructor(Starport SP_, address strategist_, address owner) { _initializeOwner(owner); strategist = strategist_; emit StrategistTransferred(strategist_); - strategistFee = fee_; SP = SP_; _DOMAIN_SEPARATOR = keccak256( abi.encode( @@ -147,10 +145,11 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { if (msg.sender != strategist && msg.sender != owner()) { revert NotAuthorized(); } + uint256 counter; unchecked { - _counter += 1 + uint256(blockhash(block.number - 1) >> 0x80); + counter = _counter += 1 + uint256(blockhash(block.number - 1) >> 0x80); } - emit CounterUpdated(_counter); + emit CounterUpdated(counter); } /** @@ -190,14 +189,6 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { return abi.encodePacked(bytes1(0x19), bytes1(0x01), _DOMAIN_SEPARATOR, hash); } - /** - * @dev Returns the strategist and fee - * @return strategist address and fee - */ - - function getStrategistData() public view virtual returns (address, uint256) { - return (strategist, strategistFee); - } /** * @dev Returns the nonce of the contract diff --git a/test/StarportTest.sol b/test/StarportTest.sol index 6c9e7561..5598fa11 100644 --- a/test/StarportTest.sol +++ b/test/StarportTest.sol @@ -186,7 +186,7 @@ contract StarportTest is BaseOrderTest, Stargate { SP = new Starport(address(consideration), Stargate(address(this))); custodian = new Custodian(SP, address(consideration)); - SO = new StrategistOriginator(SP, strategist.addr, 1e16, address(this)); + SO = new StrategistOriginator(SP, strategist.addr, address(this)); pricing = new SimpleInterestPricing(SP); settlement = new FixedTermDutchAuctionSettlement(SP); status = new FixedTermStatus(); diff --git a/test/unit-testing/TestStarport.sol b/test/unit-testing/TestStarport.sol index 5edc16db..9aa8ee32 100644 --- a/test/unit-testing/TestStarport.sol +++ b/test/unit-testing/TestStarport.sol @@ -176,9 +176,7 @@ contract MockExoticPricing is Pricing { } contract MockOriginator is StrategistOriginator { - constructor(Starport SP_, address strategist_, uint256 fee_) - StrategistOriginator(SP_, strategist_, fee_, msg.sender) - {} + constructor(Starport SP_, address strategist_) StrategistOriginator(SP_, strategist_, msg.sender) {} function terms(bytes calldata) public view returns (Starport.Terms memory) { return Starport.Terms({ diff --git a/test/unit-testing/TestStrategistOriginator.sol b/test/unit-testing/TestStrategistOriginator.sol index 0ba9bc33..f980d40d 100644 --- a/test/unit-testing/TestStrategistOriginator.sol +++ b/test/unit-testing/TestStrategistOriginator.sol @@ -41,13 +41,6 @@ contract TestStrategistOriginator is StarportTest, DeepEq { ); } - function testGetStrategistData() public { - StrategistOriginator SOO = new StrategistOriginator(SP, strategist.addr, 1e17, address(this)); - (address activeStrategist, uint256 strategistFee) = SOO.getStrategistData(); - assert(activeStrategist == strategist.addr); - assert(strategistFee == 1e17); - } - function testIncrementCounterAsStrategist() public { uint256 newCounter = SO.getCounter() + 1 + uint256(blockhash(block.timestamp - 1) >> 0x80); vm.expectEmit(); From 5a1a49d4e0c75a6ff968b9e4e8d7e6e10df063ac Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 15:25:17 -0600 Subject: [PATCH 06/10] fix: remove mentions of loan manager --- src/originators/StrategistOriginator.sol | 4 ++-- test/unit-testing/TestStarport.sol | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/originators/StrategistOriginator.sol b/src/originators/StrategistOriginator.sol index f301dd16..97c8c2ba 100644 --- a/src/originators/StrategistOriginator.sol +++ b/src/originators/StrategistOriginator.sol @@ -162,8 +162,8 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { _validateOffer(params, details); Starport.Loan memory loan = Starport.Loan({ - start: uint256(0), // Set in the loan manager - originator: address(0), // Set in the loan manager + start: uint256(0), // Set in Starport + originator: address(0), // Set in Starport custodian: details.custodian, issuer: details.issuer, borrower: params.borrower, diff --git a/test/unit-testing/TestStarport.sol b/test/unit-testing/TestStarport.sol index 9aa8ee32..0f4ca3c0 100644 --- a/test/unit-testing/TestStarport.sol +++ b/test/unit-testing/TestStarport.sol @@ -194,8 +194,8 @@ contract MockOriginator is StrategistOriginator { _validateOffer(params, details); Starport.Loan memory loan = Starport.Loan({ - start: uint256(0), // are set in the loan manager - originator: address(0), // are set in the loan manager + start: uint256(0), // are set in Starport + originator: address(0), // are set in Starport custodian: details.custodian, issuer: details.issuer, borrower: params.borrower, From bb2cb0722837745b23c23757dcf87524efeeff6b Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 16:08:17 -0600 Subject: [PATCH 07/10] fix: remove mention of fee --- src/originators/StrategistOriginator.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/originators/StrategistOriginator.sol b/src/originators/StrategistOriginator.sol index 97c8c2ba..8bc9194b 100644 --- a/src/originators/StrategistOriginator.sol +++ b/src/originators/StrategistOriginator.sol @@ -84,7 +84,7 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { mapping(bytes32 => bool) public usedHashes; - // Strategist address and fee + // Strategist address address public strategist; uint256 private _counter; From 95c3d4f178a9b4e16f75c020216f22464ef45542 Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 16:18:14 -0600 Subject: [PATCH 08/10] fix: remove address(this) in params for call to transferSpentItemsSelf --- .gas-snapshot | 2 +- src/lib/StarportLib.sol | 6 ++++-- src/originators/StrategistOriginator.sol | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index b9cdc4e6..2c7a7ba6 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -150,4 +150,4 @@ TestStrategistOriginator:testInvalidDebtLength() (gas: 211362) TestStrategistOriginator:testInvalidOffer() (gas: 427184) TestStrategistOriginator:testInvalidSigner() (gas: 214522) TestStrategistOriginator:testSetStrategist() (gas: 17852) -TestStrategistOriginator:testWithdraw() (gas: 167948) +TestStrategistOriginator:testWithdraw() (gas: 167942) diff --git a/src/lib/StarportLib.sol b/src/lib/StarportLib.sol index 70cc284a..f951188b 100644 --- a/src/lib/StarportLib.sol +++ b/src/lib/StarportLib.sol @@ -308,12 +308,14 @@ library StarportLib { } } - function transferSpentItemsSelf(SpentItem[] memory transfers, address from, address to) internal { + function transferSpentItemsSelf(SpentItem[] memory transfers, address to) internal { if (transfers.length > 0) { uint256 i = 0; for (; i < transfers.length;) { SpentItem memory transfer = transfers[i]; - _transferItem(transfer.itemType, transfer.token, transfer.identifier, transfer.amount, from, to); + _transferItem( + transfer.itemType, transfer.token, transfer.identifier, transfer.amount, address(this), to + ); unchecked { ++i; } diff --git a/src/originators/StrategistOriginator.sol b/src/originators/StrategistOriginator.sol index 8bc9194b..75e2ded7 100644 --- a/src/originators/StrategistOriginator.sol +++ b/src/originators/StrategistOriginator.sol @@ -265,7 +265,7 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { } function withdraw(SpentItem[] memory transfers, address recipient) external onlyOwner { - StarportLib.transferSpentItemsSelf(transfers, address(this), recipient); + StarportLib.transferSpentItemsSelf(transfers, recipient); } // PUBLIC FUNCTIONS From e27d3ee08719f849134df573fe5dfe9e4c4ea46f Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 16:35:54 -0600 Subject: [PATCH 09/10] fix: gas optimization of assignment --- .gas-snapshot | 68 +++++++++++------------ src/lib/StarportLib.sol | 8 +-- src/originators/StrategistOriginator.sol | 3 +- src/pricing/BasePricing.sol | 3 +- src/settlement/DutchAuctionSettlement.sol | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 2c7a7ba6..54ec257a 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -16,10 +16,10 @@ IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377103) IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402755) ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 437989) ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441365) -ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440814) +ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440758) ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437043) ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437950) -ModuleTesting:testModuleValidation() (gas: 1274270) +ModuleTesting:testModuleValidation() (gas: 1262841) PausableNonReentrantImpl:test() (gas: 2464) PausableNonReentrantImpl:testReentrancy() (gas: 2757) TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462) @@ -32,12 +32,12 @@ TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77987) TestCustodian:testCustodianCannotBeAuthorized() (gas: 142011) TestCustodian:testCustodySelector() (gas: 2717132) TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) -TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172910) +TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172811) TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163090) -TestCustodian:testGenerateOrderRepay() (gas: 177070) -TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193538) -TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875643) -TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804243) +TestCustodian:testGenerateOrderRepay() (gas: 176971) +TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193439) +TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875233) +TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804051) TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97556) TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 91917) TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106827) @@ -45,7 +45,7 @@ TestCustodian:testGenerateOrderSettlement() (gas: 154803) TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160200) TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163286) TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101809) -TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461569) +TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461377) TestCustodian:testGetBorrower() (gas: 78603) TestCustodian:testInvalidAction() (gas: 179778) TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130080) @@ -58,11 +58,11 @@ TestCustodian:testName() (gas: 7077) TestCustodian:testNonPayableFunctions() (gas: 215289) TestCustodian:testOnlySeaport() (gas: 17918) TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105714) -TestCustodian:testPreviewOrderRepay() (gas: 229947) +TestCustodian:testPreviewOrderRepay() (gas: 229749) TestCustodian:testPreviewOrderSettlement() (gas: 191710) TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108205) TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116898) -TestCustodian:testRatifyOrder() (gas: 183891) +TestCustodian:testRatifyOrder() (gas: 183792) TestCustodian:testSeaportMetadata() (gas: 8588) TestCustodian:testSupportsInterface() (gas: 9428) TestCustodian:testSymbol() (gas: 7194) @@ -73,37 +73,37 @@ TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096) TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169) TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234) TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) -TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592516) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599729) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589880) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579764) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592318) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599531) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589682) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579566) TestNewLoan:testBuyNowPayLater() (gas: 3018379) TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874045) TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885070) TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429501) -TestNewLoan:testNewLoanRefinance() (gas: 589921) -TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324584) -TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383414) +TestNewLoan:testNewLoanRefinance() (gas: 589822) +TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324529) +TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383347) TestNewLoan:testSettleLoan() (gas: 641934) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) -TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666737) -TestRepayLoan:testRepayLoanBase() (gas: 599559) +TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666539) +TestRepayLoan:testRepayLoanBase() (gas: 599361) TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438643) TestRepayLoan:testRepayLoanInSettlement() (gas: 585543) -TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603652) -TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857883) -TestSimpleInterestPricing:test_calculateInterest() (gas: 881296) -TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 928510) -TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 919314) +TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603553) +TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857388) +TestSimpleInterestPricing:test_calculateInterest() (gas: 869870) +TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 916886) +TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 907796) TestStarport:testAcquireTokensFail() (gas: 60386) -TestStarport:testAcquireTokensSuccess() (gas: 162955) +TestStarport:testAcquireTokensSuccess() (gas: 162757) TestStarport:testActive() (gas: 69291) TestStarport:testAdditionalTransfers() (gas: 300688) TestStarport:testAdditionalTransfersOriginate() (gas: 275384) -TestStarport:testAdditionalTransfersRefinance() (gas: 218214) +TestStarport:testAdditionalTransfersRefinance() (gas: 218115) TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129820) TestStarport:testCannotIssueSameLoanTwice() (gas: 363991) TestStarport:testCannotOriginateWhilePaused() (gas: 73523) @@ -112,15 +112,15 @@ TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70919) TestStarport:testCaveatEnforcerRevert() (gas: 102534) TestStarport:testDefaultFeeRake1() (gas: 387913) TestStarport:testDefaultFeeRake2() (gas: 450256) -TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397742) +TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397546) TestStarport:testEIP712Signing() (gas: 83056) TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237672) TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695711) -TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376786) +TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376594) TestStarport:testIncrementCaveatNonce() (gas: 35183) TestStarport:testInitializedFlagSetProperly() (gas: 67416) TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230359) -TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170774) +TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170675) TestStarport:testInvalidAmountCollateral() (gas: 165901) TestStarport:testInvalidAmountCollateral721() (gas: 165901) TestStarport:testInvalidItemType() (gas: 151849) @@ -130,9 +130,9 @@ TestStarport:testInvalidateCaveatSalt() (gas: 33450) TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264200) TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290347) TestStarport:testNonPayableFunctions() (gas: 114479) -TestStarport:testOverrideFeeRake() (gas: 379873) -TestStarport:testPause() (gas: 18127) -TestStarport:testRefinancePostRepaymentFails() (gas: 127864) +TestStarport:testOverrideFeeRake() (gas: 384236) +TestStarport:testPause() (gas: 18193) +TestStarport:testRefinancePostRepaymentFails() (gas: 127765) TestStarport:testStargateGetOwner() (gas: 8786) TestStarport:testTokenNoCodeCollateral() (gas: 150640) TestStarport:testTokenNoCodeDebt() (gas: 180913) @@ -147,7 +147,7 @@ TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 2125 TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212772) TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212707) TestStrategistOriginator:testInvalidDebtLength() (gas: 211362) -TestStrategistOriginator:testInvalidOffer() (gas: 427184) +TestStrategistOriginator:testInvalidOffer() (gas: 427117) TestStrategistOriginator:testInvalidSigner() (gas: 214522) TestStrategistOriginator:testSetStrategist() (gas: 17852) -TestStrategistOriginator:testWithdraw() (gas: 167942) +TestStrategistOriginator:testWithdraw() (gas: 167733) diff --git a/src/lib/StarportLib.sol b/src/lib/StarportLib.sol index f951188b..5c74e8c1 100644 --- a/src/lib/StarportLib.sol +++ b/src/lib/StarportLib.sol @@ -250,7 +250,7 @@ library StarportLib { // erc1155 transfer if (transfer.amount > 0) { ERC1155(transfer.token).safeTransferFrom( - transfer.from, transfer.to, transfer.identifier, transfer.amount, new bytes(0) + transfer.from, transfer.to, transfer.identifier, transfer.amount, "" ); } } else { @@ -281,7 +281,7 @@ library StarportLib { // erc1155 transfer if (transfer.amount > 0) { ERC1155(transfer.token).safeTransferFrom( - transfer.from, transfer.to, transfer.identifier, transfer.amount, new bytes(0) + transfer.from, transfer.to, transfer.identifier, transfer.amount, "" ); } } else { @@ -360,7 +360,7 @@ library StarportLib { revert InvalidItemAmount(); } // erc1155 transfer - ERC1155(token).safeTransferFrom(from, to, identifier, amount, new bytes(0)); + ERC1155(token).safeTransferFrom(from, to, identifier, amount, ""); } else { revert InvalidItemType(); } @@ -384,7 +384,7 @@ library StarportLib { ERC721(token).transferFrom(from, to, identifier); } else if (itemType == ItemType.ERC1155) { // erc1155 transfer - ERC1155(token).safeTransferFrom(from, to, identifier, amount, new bytes(0)); + ERC1155(token).safeTransferFrom(from, to, identifier, amount, ""); } else { revert InvalidItemType(); } diff --git a/src/originators/StrategistOriginator.sol b/src/originators/StrategistOriginator.sol index 75e2ded7..01cedbb4 100644 --- a/src/originators/StrategistOriginator.sol +++ b/src/originators/StrategistOriginator.sol @@ -173,7 +173,8 @@ contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { }); CaveatEnforcer.SignedCaveats memory le; - SP.originate(new AdditionalTransfer[](0), params.borrowerCaveat, le, loan); + AdditionalTransfer[] memory at; + SP.originate(at, params.borrowerCaveat, le, loan); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ diff --git a/src/pricing/BasePricing.sol b/src/pricing/BasePricing.sol index 7a1590d6..189445dd 100644 --- a/src/pricing/BasePricing.sol +++ b/src/pricing/BasePricing.sol @@ -76,9 +76,8 @@ abstract contract BasePricing is Pricing { Details memory details = abi.decode(loan.terms.pricingData, (Details)); if (details.carryRate > 0 && loan.issuer != loan.originator) { carryConsideration = new SpentItem[](loan.debt.length); - } else { - carryConsideration = new SpentItem[](0); } + repayConsideration = new SpentItem[](loan.debt.length); uint256 i = 0; diff --git a/src/settlement/DutchAuctionSettlement.sol b/src/settlement/DutchAuctionSettlement.sol index 14e5dda2..ead92d13 100644 --- a/src/settlement/DutchAuctionSettlement.sol +++ b/src/settlement/DutchAuctionSettlement.sol @@ -125,7 +125,7 @@ abstract contract DutchAuctionSettlement is Settlement, AmountDeriver { } // DutchAuction has failed, allow lender to redeem if (start + details.window < block.timestamp) { - return (new ReceivedItem[](0), loan.issuer); + return (consideration, loan.issuer); } uint256 settlementPrice = _locateCurrentAmount({ From 71eb445c1b0ece2efde318ca7e39d0540a0906e2 Mon Sep 17 00:00:00 2001 From: Joseph Delong Date: Wed, 24 Jan 2024 17:41:20 -0600 Subject: [PATCH 10/10] fix: gas snapshot --- .gas-snapshot | 221 +++++++++++++++++++++++++------------------------- 1 file changed, 111 insertions(+), 110 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 54ec257a..17ffae23 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,68 +1,68 @@ -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: 440758) -ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437043) -ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 437950) -ModuleTesting:testModuleValidation() (gas: 1262841) +IntegrationTestCaveats:testInvalidCaveatLength() (gas: 130086) +IntegrationTestCaveats:testInvalidCaveats() (gas: 162366) +IntegrationTestCaveats:testOriginateUnapprovedFulfiller() (gas: 332567) +IntegrationTestCaveats:testOriginateWBorrowerApproval() (gas: 283456) +IntegrationTestCaveats:testOriginateWCaveatsAsBorrower() (gas: 308978) +IntegrationTestCaveats:testOriginateWCaveatsExpired() (gas: 159595) +IntegrationTestCaveats:testOriginateWCaveatsIncrementedNonce() (gas: 168066) +IntegrationTestCaveats:testOriginateWCaveatsInvalidSalt() (gas: 317755) +IntegrationTestCaveats:testOriginateWCaveatsInvalidSaltManual() (gas: 142246) +IntegrationTestCaveats:testOriginateWLenderApproval() (gas: 283770) +IntegrationTestCaveats:testRefinanceAsLender() (gas: 1053752) +IntegrationTestCaveats:testRefinanceCaveatFailure() (gas: 407964) +IntegrationTestCaveats:testRefinanceLoanStartAtBlockTimestampInvalidLoan() (gas: 347805) +IntegrationTestCaveats:testRefinanceUnapprovedFulfiller() (gas: 456578) +IntegrationTestCaveats:testRefinanceWCaveatsInvalidSalt() (gas: 377260) +IntegrationTestCaveats:testRefinanceWLenderApproval() (gas: 402978) +ModuleTesting:testFixedTermDutchAuctionSettlement() (gas: 438123) +ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 441499) +ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440892) +ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437177) +ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 438084) +ModuleTesting:testModuleValidation() (gas: 1262975) PausableNonReentrantImpl:test() (gas: 2464) PausableNonReentrantImpl:testReentrancy() (gas: 2757) TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462) TestBorrowerEnforcer:testBERevertInvalidLoanTerms() (gas: 81160) TestBorrowerEnforcer:testBEValidLoanTerms() (gas: 72257) TestBorrowerEnforcer:testBEValidLoanTermsAnyIssuer() (gas: 72343) -TestCustodian:testCannotLazyMintTwice() (gas: 82149) +TestCustodian:testCannotLazyMintTwice() (gas: 82105) TestCustodian:testCannotMintInvalidLoanInvalidCustodian() (gas: 72477) -TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77987) -TestCustodian:testCustodianCannotBeAuthorized() (gas: 142011) +TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77943) +TestCustodian:testCustodianCannotBeAuthorized() (gas: 141967) TestCustodian:testCustodySelector() (gas: 2717132) TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) -TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172811) -TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163090) -TestCustodian:testGenerateOrderRepay() (gas: 176971) -TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193439) -TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875233) -TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804051) +TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172899) +TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163178) +TestCustodian:testGenerateOrderRepay() (gas: 177059) +TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193527) +TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875677) +TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804495) TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97556) TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 91917) TestCustodian:testGenerateOrderRepayNotBorrower() (gas: 106827) -TestCustodian:testGenerateOrderSettlement() (gas: 154803) -TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160200) -TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163286) +TestCustodian:testGenerateOrderSettlement() (gas: 154891) +TestCustodian:testGenerateOrderSettlementHandlerAuthorized() (gas: 160288) +TestCustodian:testGenerateOrderSettlementNoActiveLoan() (gas: 163374) TestCustodian:testGenerateOrderSettlementUnauthorized() (gas: 101809) -TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461377) +TestCustodian:testGenerateOrdersWithLoanStartAtBlockTimestampInvalidLoan() (gas: 461511) TestCustodian:testGetBorrower() (gas: 78603) -TestCustodian:testInvalidAction() (gas: 179778) -TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130080) -TestCustodian:testInvalidActionSettleActiveLoan() (gas: 130017) +TestCustodian:testInvalidAction() (gas: 179690) +TestCustodian:testInvalidActionRepayInActiveLoan() (gas: 130036) +TestCustodian:testInvalidActionSettleActiveLoan() (gas: 129973) TestCustodian:testInvalidEncodedData() (gas: 26160) -TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366650) +TestCustodian:testMintWithApprovalSetAsBorrower() (gas: 366740) TestCustodian:testMintWithApprovalSetAsBorrowerInvalidLoan() (gas: 64505) TestCustodian:testMintWithApprovalSetNotAuthorized() (gas: 66842) TestCustodian:testName() (gas: 7077) TestCustodian:testNonPayableFunctions() (gas: 215289) TestCustodian:testOnlySeaport() (gas: 17918) -TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105714) -TestCustodian:testPreviewOrderRepay() (gas: 229749) -TestCustodian:testPreviewOrderSettlement() (gas: 191710) -TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108205) -TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116898) -TestCustodian:testRatifyOrder() (gas: 183792) +TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105670) +TestCustodian:testPreviewOrderRepay() (gas: 229793) +TestCustodian:testPreviewOrderSettlement() (gas: 191754) +TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 108161) +TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116854) +TestCustodian:testRatifyOrder() (gas: 183880) TestCustodian:testSeaportMetadata() (gas: 8588) TestCustodian:testSupportsInterface() (gas: 9428) TestCustodian:testSymbol() (gas: 7194) @@ -73,81 +73,82 @@ TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096) TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169) TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234) TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) -TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592318) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599531) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589682) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579566) -TestNewLoan:testBuyNowPayLater() (gas: 3018379) -TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874045) -TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885070) -TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429501) -TestNewLoan:testNewLoanRefinance() (gas: 589822) -TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324529) -TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383347) -TestNewLoan:testSettleLoan() (gas: 641934) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592496) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599709) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589927) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579744) +TestNewLoan:testBuyNowPayLater() (gas: 3018513) +TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874179) +TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885204) +TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429635) +TestNewLoan:testNewLoanRefinance() (gas: 589971) +TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324707) +TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383503) +TestNewLoan:testSettleLoan() (gas: 642156) TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) -TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666539) -TestRepayLoan:testRepayLoanBase() (gas: 599361) -TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438643) -TestRepayLoan:testRepayLoanInSettlement() (gas: 585543) -TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603553) -TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857388) +TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666673) +TestRepayLoan:testRepayLoanBase() (gas: 599539) +TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438777) +TestRepayLoan:testRepayLoanInSettlement() (gas: 585633) +TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603643) +TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857698) TestSimpleInterestPricing:test_calculateInterest() (gas: 869870) TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 916886) TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 907796) -TestStarport:testAcquireTokensFail() (gas: 60386) -TestStarport:testAcquireTokensSuccess() (gas: 162757) -TestStarport:testActive() (gas: 69291) -TestStarport:testAdditionalTransfers() (gas: 300688) -TestStarport:testAdditionalTransfersOriginate() (gas: 275384) -TestStarport:testAdditionalTransfersRefinance() (gas: 218115) -TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129820) -TestStarport:testCannotIssueSameLoanTwice() (gas: 363991) -TestStarport:testCannotOriginateWhilePaused() (gas: 73523) -TestStarport:testCannotSettleInvalidLoan() (gas: 74881) -TestStarport:testCannotSettleUnlessValidCustodian() (gas: 70919) -TestStarport:testCaveatEnforcerRevert() (gas: 102534) -TestStarport:testDefaultFeeRake1() (gas: 387913) -TestStarport:testDefaultFeeRake2() (gas: 450256) -TestStarport:testDefaultFeeRakeExoticDebt() (gas: 397546) -TestStarport:testEIP712Signing() (gas: 83056) -TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237672) -TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695711) -TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376594) -TestStarport:testIncrementCaveatNonce() (gas: 35183) -TestStarport:testInitializedFlagSetProperly() (gas: 67416) -TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230359) -TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170675) -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: 264200) -TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290347) +TestStarport:testAcquireTokensFail() (gas: 60473) +TestStarport:testAcquireTokensSuccess() (gas: 162844) +TestStarport:testActive() (gas: 69358) +TestStarport:testAdditionalTransfers() (gas: 300755) +TestStarport:testAdditionalTransfersOriginate() (gas: 275540) +TestStarport:testAdditionalTransfersRefinance() (gas: 218107) +TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129484) +TestStarport:testCannotIssueSameLoanTwice() (gas: 364125) +TestStarport:testCannotOriginateWhilePaused() (gas: 73479) +TestStarport:testCannotSettleInvalidLoan() (gas: 74969) +TestStarport:testCannotSettleUnlessValidCustodian() (gas: 71007) +TestStarport:testCaveatEnforcerRevert() (gas: 102601) +TestStarport:testDefaultFeeRake1() (gas: 383458) +TestStarport:testDefaultFeeRake2() (gas: 445821) +TestStarport:testDefaultFeeRakeExoticDebt() (gas: 394368) +TestStarport:testEIP712Signing() (gas: 83109) +TestStarport:testExcessiveFeeRake() (gas: 19992) +TestStarport:testExoticDebtWithCustomPricingAndRepayment() (gas: 1237783) +TestStarport:testExoticDebtWithCustomPricingAndSettlement() (gas: 1695822) +TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376639) +TestStarport:testIncrementCaveatNonce() (gas: 35117) +TestStarport:testInitializedFlagSetProperly() (gas: 67372) +TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230426) +TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170667) +TestStarport:testInvalidAmountCollateral() (gas: 165968) +TestStarport:testInvalidAmountCollateral721() (gas: 165968) +TestStarport:testInvalidItemType() (gas: 151916) +TestStarport:testInvalidTransferLengthCollateral() (gas: 154185) +TestStarport:testInvalidTransferLengthDebt() (gas: 175984) +TestStarport:testInvalidateCaveatSalt() (gas: 33428) +TestStarport:testNonDefaultCustodianCustodyCallFails() (gas: 264267) +TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290392) TestStarport:testNonPayableFunctions() (gas: 114479) -TestStarport:testOverrideFeeRake() (gas: 384236) -TestStarport:testPause() (gas: 18193) +TestStarport:testOverrideFeeRake() (gas: 379873) +TestStarport:testPause() (gas: 18127) TestStarport:testRefinancePostRepaymentFails() (gas: 127765) -TestStarport:testStargateGetOwner() (gas: 8786) -TestStarport:testTokenNoCodeCollateral() (gas: 150640) -TestStarport:testTokenNoCodeDebt() (gas: 180913) -TestStarport:testUnpause() (gas: 17275) +TestStarport:testStargateGetOwner() (gas: 8851) +TestStarport:testTokenNoCodeCollateral() (gas: 150707) +TestStarport:testTokenNoCodeDebt() (gas: 180980) +TestStarport:testUnpause() (gas: 17187) TestStrategistOriginator:testEncodeWithAccountCounter() (gas: 12429) TestStrategistOriginator:testIncrementCounterAsStrategist() (gas: 38457) TestStrategistOriginator:testIncrementCounterNotAuthorized() (gas: 13468) -TestStrategistOriginator:testInvalidCollateral() (gas: 210360) -TestStrategistOriginator:testInvalidDeadline() (gas: 216181) -TestStrategistOriginator:testInvalidDebt() (gas: 212068) -TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 212552) -TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212772) -TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212707) -TestStrategistOriginator:testInvalidDebtLength() (gas: 211362) -TestStrategistOriginator:testInvalidOffer() (gas: 427117) -TestStrategistOriginator:testInvalidSigner() (gas: 214522) +TestStrategistOriginator:testInvalidCollateral() (gas: 210516) +TestStrategistOriginator:testInvalidDeadline() (gas: 216337) +TestStrategistOriginator:testInvalidDebt() (gas: 212224) +TestStrategistOriginator:testInvalidDebtAmountAskingMoreThanOffered() (gas: 212708) +TestStrategistOriginator:testInvalidDebtAmountOfferingZero() (gas: 212928) +TestStrategistOriginator:testInvalidDebtAmountRequestingZero() (gas: 212863) +TestStrategistOriginator:testInvalidDebtLength() (gas: 211518) +TestStrategistOriginator:testInvalidOffer() (gas: 427273) +TestStrategistOriginator:testInvalidSigner() (gas: 214678) TestStrategistOriginator:testSetStrategist() (gas: 17852) -TestStrategistOriginator:testWithdraw() (gas: 167733) +TestStrategistOriginator:testWithdraw() (gas: 167733) \ No newline at end of file