diff --git a/lib/forge-std b/lib/forge-std index bdea49f..f73c73d 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit bdea49f9bb3c58c8c35850c3bdc17eaeea756e9a +Subproject commit f73c73d2018eb6a111f35e4dae7b4f27401e9421 diff --git a/lib/starport b/lib/starport index 664b5b4..a4cd30b 160000 --- a/lib/starport +++ b/lib/starport @@ -1 +1 @@ -Subproject commit 664b5b4b711aab1ae9108ad4e73860ed59f700f8 +Subproject commit a4cd30b5cc8bbb8fdc7c96040f292ca417a5b574 diff --git a/test/AstariaV1Test.sol b/test/AstariaV1Test.sol index 5d1699c..0d8a9fb 100644 --- a/test/AstariaV1Test.sol +++ b/test/AstariaV1Test.sol @@ -71,12 +71,18 @@ contract AstariaV1Test is StarportTest { (SpentItem[] memory considerationPayment, SpentItem[] memory carryPayment,) = Pricing(loan.terms.pricing).getRefinanceConsideration(loan, pricingData, transactor); - loan = SP.applyRefinanceConsiderationToLoan(loan, considerationPayment, carryPayment, pricingData); - loan.issuer = transactor; - loan.start = 0; - loan.originator = address(0); - - return LenderEnforcer.Details({loan: loan}); + Starport.Loan memory refiLoan = loanCopy(loan); + console.log("carryPayment.length", carryPayment.length); + console.log("considerationPayment.amount", considerationPayment[0].amount); + console.log("carryPayment.amount", carryPayment[0].amount); + + refiLoan.debt = SP.applyRefinanceConsiderationToLoan(considerationPayment, carryPayment); + refiLoan.terms.pricingData = pricingData; + refiLoan.issuer = transactor; + refiLoan.start = 0; + refiLoan.originator = address(0); + + return LenderEnforcer.Details({loan: refiLoan}); } // loan.borrower and signer.addr could be mismatched diff --git a/test/fuzz-testing/TestFuzzV1.sol b/test/fuzz-testing/TestFuzzV1.sol index 209523b..501fabd 100644 --- a/test/fuzz-testing/TestFuzzV1.sol +++ b/test/fuzz-testing/TestFuzzV1.sol @@ -144,6 +144,17 @@ contract TestFuzzV1 is AstariaV1Test, TestFuzzStarport { amount: _boundMax(params.debtAmount, type(uint112).max), token: address(erc20s[1]) }); + BasePricing.Details memory pDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + while (true) { + try AstariaV1Pricing(loan.terms.pricing).calculateInterest( + 1, debt[0].amount, pDetails.rate, pDetails.decimals + ) returns (uint256 interest) { + break; + } catch { + debt[0].amount += 100 ** pDetails.decimals; + continue; + } + } loan.debt = debt; loan.borrower = borrower.addr; loan.custodian = SP.defaultCustodian();