Skip to content

Commit

Permalink
fix: minimum interest accrual (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangerousfood authored Jan 25, 2024
1 parent e15b671 commit 9f3441b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
44 changes: 22 additions & 22 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -73,37 +73,37 @@ 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)
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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/seaport
Submodule seaport updated 30 files
+44 −70 README.md
+1 −3 contracts/conduit/Conduit.sol
+2 −6 contracts/conduit/ConduitController.sol
+3 −9 contracts/helpers/TransferHelper.sol
+17 −17 contracts/helpers/order-validator/lib/Murky.sol
+1 −3 contracts/helpers/order-validator/lib/SeaportValidatorHelper.sol
+1 −1 contracts/interfaces/ImmutableCreate2FactoryInterface.sol
+1 −3 contracts/test/ERC721ReceiverMock.sol
+1 −3 reference/conduit/ReferenceConduit.sol
+1 −3 reference/lib/ReferenceAssertions.sol
+2 −7 reference/lib/ReferenceConsiderationStructs.sol
+2 −6 reference/lib/ReferenceExecutor.sol
+16 −22 reference/lib/ReferenceOrderCombiner.sol
+1 −4 reference/lib/ReferenceOrderFulfiller.sol
+1 −4 reference/lib/ReferenceOrderValidator.sol
+1 −4 reference/lib/ReferenceZoneInteraction.sol
+1 −4 test/foundry/FulfillAdvancedOrder.t.sol
+1 −4 test/foundry/FulfillAvailableAdvancedOrder.t.sol
+1 −4 test/foundry/FullfillAvailableOrder.t.sol
+1 −4 test/foundry/MatchAdvancedOrder.t.sol
+1 −4 test/foundry/MatchOrders.t.sol
+2 −6 test/foundry/TransferHelperMultipleRecipientsTest.sol
+2 −6 test/foundry/TransferHelperSingleRecipientTest.sol
+3 −2 test/foundry/new/helpers/FuzzGenerators.sol
+1 −4 test/foundry/offerers/AdjustedAmountOfferer.t.sol
+1 −4 test/foundry/offerers/BadOfferer.t.sol
+3 −6 test/foundry/offerers/ContractOffersNativeTokenOfferItems.t.sol
+1 −3 test/foundry/utils/BaseConsiderationTest.sol
+1 −3 test/foundry/utils/EIP712MerkleTree.sol
+6 −6 yarn.lock
3 changes: 2 additions & 1 deletion src/pricing/BasePricing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion test/unit-testing/TestPricing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9f3441b

Please sign in to comment.