diff --git a/.gas-snapshot b/.gas-snapshot index 91954f27..d7e0d354 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -19,7 +19,7 @@ ModuleTesting:testFixedTermDutchAuctionSettlementAuctionNotStarted() (gas: 44149 ModuleTesting:testFixedTermDutchAuctionSettlementGetSettlementAuctionExpired() (gas: 440892) ModuleTesting:testFixedTermDutchAuctionSettlementNotValid() (gas: 437177) ModuleTesting:testFixedTermDutchAuctionSettlementValid() (gas: 438084) -ModuleTesting:testModuleValidation() (gas: 1262975) +ModuleTesting:testModuleValidation() (gas: 1280821) PausableNonReentrantImpl:test() (gas: 2464) PausableNonReentrantImpl:testReentrancy() (gas: 2757) TestBorrowerEnforcer:testBERevertAdditionalTransfersFromBorrower() (gas: 76462) @@ -32,11 +32,11 @@ TestCustodian:testCannotMintInvalidLoanValidCustodian() (gas: 77943) TestCustodian:testCustodianCannotBeAuthorized() (gas: 142026) TestCustodian:testCustodySelector() (gas: 2732377) TestCustodian:testDefaultCustodySelectorRevert() (gas: 72478) -TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172899) +TestCustodian:testGenerateOrderInvalidPostRepayment() (gas: 172939) TestCustodian:testGenerateOrderInvalidPostSettlement() (gas: 163178) -TestCustodian:testGenerateOrderRepay() (gas: 177059) -TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193527) -TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 875677) +TestCustodian:testGenerateOrderRepay() (gas: 177099) +TestCustodian:testGenerateOrderRepayAsRepayApprovedBorrower() (gas: 193567) +TestCustodian:testGenerateOrderRepayERC1155AndERC20() (gas: 876545) TestCustodian:testGenerateOrderRepayERC1155AndERC20HandlerAuthorized() (gas: 804495) TestCustodian:testGenerateOrderRepayInvalidHookAddress() (gas: 97556) TestCustodian:testGenerateOrderRepayInvalidHookReturnType() (gas: 91917) @@ -58,11 +58,11 @@ TestCustodian:testName() (gas: 7077) TestCustodian:testNonPayableFunctions() (gas: 215289) TestCustodian:testOnlySeaport() (gas: 17915) TestCustodian:testPreviewOrderNoActiveLoan() (gas: 105729) -TestCustodian:testPreviewOrderRepay() (gas: 231938) +TestCustodian:testPreviewOrderRepay() (gas: 232018) TestCustodian:testPreviewOrderSettlement() (gas: 191813) TestCustodian:testPreviewOrderSettlementInvalidFufliller() (gas: 110326) TestCustodian:testPreviewOrderSettlementInvalidRepayer() (gas: 116902) -TestCustodian:testRatifyOrder() (gas: 183877) +TestCustodian:testRatifyOrder() (gas: 183917) TestCustodian:testSeaportMetadata() (gas: 8588) TestCustodian:testSupportsInterface() (gas: 9428) TestCustodian:testSymbol() (gas: 7194) @@ -73,15 +73,15 @@ TestLenderEnforcer:testLERevertInvalidLoanTerms() (gas: 81096) TestLenderEnforcer:testLEValidLoanTerms() (gas: 72169) TestLenderEnforcer:testLEValidLoanTermsAnyBorrower() (gas: 72234) TestLenderEnforcer:testLEValidLoanTermsWithAdditionalTransfers() (gas: 73525) -TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 592542) -TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599755) -TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 589973) -TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579790) +TestLoanCombinations:testLoan20For721SimpleInterestDutchFixedRepay() (gas: 593400) +TestLoanCombinations:testLoan20for20SimpleInterestDutchFixedRepay() (gas: 599835) +TestLoanCombinations:testLoan721for20SimpleInterestDutchFixedRepay() (gas: 590053) +TestLoanCombinations:testLoanAstariaSettlementRepay() (gas: 579870) TestNewLoan:testBuyNowPayLater() (gas: 3018543) TestNewLoan:testNewLoanAs1271ProxyAccountSender() (gas: 874195) TestNewLoan:testNewLoanAs1271ProxyAccountThirdPartyFiller() (gas: 885220) TestNewLoan:testNewLoanERC721CollateralDefaultTerms2() (gas: 429635) -TestNewLoan:testNewLoanRefinance() (gas: 589971) +TestNewLoan:testNewLoanRefinance() (gas: 593205) TestNewLoan:testNewLoanViaOriginatorBorrowerApprovalAndLenderApproval() (gas: 324707) TestNewLoan:testNewLoanViaOriginatorLenderApproval() (gas: 383503) TestNewLoan:testSettleLoan() (gas: 642162) @@ -89,21 +89,21 @@ TestPausableNonReentrant:testNotOwner() (gas: 21276) TestPausableNonReentrant:testPauseAndUnpause() (gas: 22643) TestPausableNonReentrant:testReentrancy() (gas: 15404) TestPausableNonReentrant:testUnpauseWhenNotPaused() (gas: 12604) -TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666719) -TestRepayLoan:testRepayLoanBase() (gas: 599585) +TestRepayLoan:testRepayLoanApprovedRepayer() (gas: 666799) +TestRepayLoan:testRepayLoanBase() (gas: 599665) TestRepayLoan:testRepayLoanGenerateOrderNotSeaport() (gas: 438777) TestRepayLoan:testRepayLoanInSettlement() (gas: 585692) -TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603689) -TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857790) -TestSimpleInterestPricing:test_calculateInterest() (gas: 869870) -TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 916886) -TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 907796) +TestRepayLoan:testRepayLoanInvalidRepayer() (gas: 603729) +TestRepayLoan:testRepayLoanThatDoesNotExist() (gas: 857990) +TestSimpleInterestPricing:test_calculateInterest() (gas: 887709) +TestSimpleInterestPricing:test_getPaymentConsideration() (gas: 935199) +TestSimpleInterestPricing:test_getRefinanceConsideration() (gas: 926059) TestStarport:testAcquireTokensFail() (gas: 60473) TestStarport:testAcquireTokensSuccess() (gas: 162844) TestStarport:testActive() (gas: 69358) TestStarport:testAdditionalTransfers() (gas: 300747) TestStarport:testAdditionalTransfersOriginate() (gas: 275532) -TestStarport:testAdditionalTransfersRefinance() (gas: 218120) +TestStarport:testAdditionalTransfersRefinance() (gas: 218554) TestStarport:testApplyRefinanceConsiderationToLoanMalformed() (gas: 129484) TestStarport:testCannotIssueSameLoanTwice() (gas: 364109) TestStarport:testCannotOriginateWhilePaused() (gas: 73479) @@ -121,7 +121,7 @@ TestStarport:testExoticDebtWithNoCaveatsNotAsBorrower() (gas: 376631) TestStarport:testIncrementCaveatNonce() (gas: 35117) TestStarport:testInitializedFlagSetProperly() (gas: 67372) TestStarport:testInvalidAdditionalTransfersOriginate() (gas: 230418) -TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 170620) +TestStarport:testInvalidAdditionalTransfersRefinance() (gas: 171054) TestStarport:testInvalidAmountCollateral() (gas: 165960) TestStarport:testInvalidAmountCollateral721() (gas: 165960) TestStarport:testInvalidItemType() (gas: 151908) @@ -133,7 +133,7 @@ TestStarport:testNonDefaultCustodianCustodyCallSuccess() (gas: 290384) TestStarport:testNonPayableFunctions() (gas: 114479) TestStarport:testOverrideFeeRake() (gas: 379857) TestStarport:testPause() (gas: 18127) -TestStarport:testRefinancePostRepaymentFails() (gas: 127765) +TestStarport:testRefinancePostRepaymentFails() (gas: 127805) TestStarport:testStargateGetOwner() (gas: 8851) TestStarport:testTokenNoCodeCollateral() (gas: 150699) TestStarport:testTokenNoCodeDebt() (gas: 180972) diff --git a/lib/seaport b/lib/seaport index 4f4e7c20..50a0c096 160000 --- a/lib/seaport +++ b/lib/seaport @@ -1 +1 @@ -Subproject commit 4f4e7c205b957b91bc74f93d69838c9c32eece40 +Subproject commit 50a0c09621f90196e8d07dbfb6c564256a241e66 diff --git a/src/pricing/BasePricing.sol b/src/pricing/BasePricing.sol index 189445dd..2190d549 100644 --- a/src/pricing/BasePricing.sol +++ b/src/pricing/BasePricing.sol @@ -34,7 +34,7 @@ import {Validation} from "../lib/Validation.sol"; import {StarportLib} from "../lib/StarportLib.sol"; import {ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; -import {SpentItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; +import {SpentItem, ItemType} from "seaport-types/src/lib/ConsiderationStructs.sol"; import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; abstract contract BasePricing is Pricing { @@ -84,6 +84,7 @@ abstract contract BasePricing is Pricing { for (; i < loan.debt.length;) { uint256 interest = getInterest(loan, details.rate, loan.start, block.timestamp, i, details.decimals); + if (interest == 0 && loan.debt[i].itemType == ItemType.ERC20) interest = 1; if (carryConsideration.length > 0) { carryConsideration[i] = SpentItem({ itemType: loan.debt[i].itemType, diff --git a/test/unit-testing/TestPricing.sol b/test/unit-testing/TestPricing.sol index 41d0e638..56e7211c 100644 --- a/test/unit-testing/TestPricing.sol +++ b/test/unit-testing/TestPricing.sol @@ -61,7 +61,8 @@ contract TestSimpleInterestPricing is StarportTest, DeepEq { assertEq(repayConsideration.length, 1); assertEq(repayConsideration[0].token, address(erc20s[0])); - assertEq(repayConsideration[0].amount, 100); + // minimum interest accrual is 1 wei + assertEq(repayConsideration[0].amount, 101); assertEq(repayConsideration[0].identifier, 0); assertEq(repayCarryConsideration.length, 1);