From 0fae7dd370e9c5205c24fdca98b761bfb722585e Mon Sep 17 00:00:00 2001 From: GregTheDev <40359730+0xgregthedev@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:52:54 -0700 Subject: [PATCH] chore: move example implementations to mocks (#102) --- remappings.txt | 2 +- src/pricing/SimpleInterestPricing.sol | 94 ------------------- test/StarportTest.sol | 47 +++++----- test/fuzz-testing/TestFuzzStarport.sol | 15 +-- .../differential-fuzzing}/RefStarportLib.sol | 2 +- .../differential-fuzzing/TestStarPortLib.sol | 2 +- test/integration-testing/TestNewLoan.sol | 7 +- test/integration-testing/TestRepayLoan.sol | 18 ++-- {src => test/mocks}/BNPLHelper.sol | 6 +- .../mocks}/enforcers/BorrowerEnforcer.sol | 8 +- .../mocks}/enforcers/BorrowerEnforcerBNPL.sol | 6 +- .../mocks}/enforcers/LenderEnforcer.sol | 6 +- .../originators/StrategistOriginator.sol | 10 +- .../mocks/pricing/SimpleInterestPricing.sol | 83 ++++++++++------ .../settlement/DutchAuctionSettlement.sol | 13 +-- .../FixedTermDutchAuctionSettlement.sol | 10 +- .../mocks}/status/FixedTermStatus.sol | 6 +- test/unit-testing/ModuleTesting.t.sol | 12 +-- test/unit-testing/TestBorrowerEnforcer.sol | 31 +++++- test/unit-testing/TestCustodian.sol | 27 ++++++ test/unit-testing/TestLenderEnforcer.sol | 2 +- test/unit-testing/TestPricing.sol | 13 ++- test/unit-testing/TestStarport.sol | 57 +++++++++-- test/utils/Assertions.sol | 29 ++++++ test/utils/Bound.sol | 29 +++++- test/utils/Cast.sol | 27 ++++++ test/utils/DeepEq.sol | 29 ++++++ test/utils/Expect.sol | 29 ++++++ test/utils/FuzzStructs.sol | 27 ++++++ test/utils/MockCall.sol | 33 ++++++- 30 files changed, 458 insertions(+), 222 deletions(-) delete mode 100644 src/pricing/SimpleInterestPricing.sol rename {src/lib => test/fuzz-testing/differential-fuzzing}/RefStarportLib.sol (98%) rename {src => test/mocks}/BNPLHelper.sol (97%) rename {src => test/mocks}/enforcers/BorrowerEnforcer.sol (95%) rename {src => test/mocks}/enforcers/BorrowerEnforcerBNPL.sol (97%) rename {src => test/mocks}/enforcers/LenderEnforcer.sol (96%) rename {src => test/mocks}/originators/StrategistOriginator.sol (97%) rename src/pricing/BasePricing.sol => test/mocks/pricing/SimpleInterestPricing.sol (81%) rename {src => test/mocks}/settlement/DutchAuctionSettlement.sol (94%) rename {src => test/mocks}/settlement/FixedTermDutchAuctionSettlement.sol (92%) rename {src => test/mocks}/status/FixedTermStatus.sol (96%) diff --git a/remappings.txt b/remappings.txt index a5b2a78c..2d9c245b 100644 --- a/remappings.txt +++ b/remappings.txt @@ -13,4 +13,4 @@ solady/=lib/solady/ solarray/=lib/seaport/lib/solarray/src/ solmate/=lib/solmate/src/ starport-core/=src/ -starport-test/=test/ \ No newline at end of file +starport-test/=test/ diff --git a/src/pricing/SimpleInterestPricing.sol b/src/pricing/SimpleInterestPricing.sol deleted file mode 100644 index 9aa9f653..00000000 --- a/src/pricing/SimpleInterestPricing.sol +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// ↑↑↑↑ ↑↑ -// ↑↑↑↑ ↑↑↑↑↑ -// ↑↑↑↑ ↑ ↑ -// ↑↑↑↑ ↑↑↑↑↑ -// ↑ ↑↑↑↑ ↑ ↑ -// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ -// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ -// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ -// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ -// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ -// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ -// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ -// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ -// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ -// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ -// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ -// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel -// ↑ ↑↑↑↑ ↑↑↑↑↑ -// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc -// ↑↑↑↑ ↑ -// ↑↑↑↑ -// ↑↑↑↑ -// ↑↑↑↑ -// ↑↑↑↑ - -pragma solidity ^0.8.17; - -import {Starport} from "../Starport.sol"; -import {ReceivedItem, BasePricing} from "../pricing/BasePricing.sol"; -import {Pricing} from "../pricing/Pricing.sol"; -import {Validation} from "../lib/Validation.sol"; -import {StarportLib, AdditionalTransfer} from "../lib/StarportLib.sol"; - -import {SpentItem, ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; -import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; - -contract SimpleInterestPricing is BasePricing { - using FixedPointMathLib for uint256; - - /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ - /* CONSTRUCTOR */ - /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - - constructor(Starport SP_) Pricing(SP_) {} - - /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ - /* PUBLIC FUNCTIONS */ - /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - - // @inheritdoc BasePricing - function calculateInterest(uint256 delta_t, uint256 amount, uint256 rate, uint256 decimals) - public - pure - override - returns (uint256) - { - return StarportLib.calculateSimpleInterest(delta_t, amount, rate, decimals); - } - - /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ - /* EXTERNAL FUNCTIONS */ - /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - - // @inheritdoc Validation - function validate(Starport.Loan calldata loan) external pure override returns (bytes4) { - Details memory details = abi.decode(loan.terms.pricingData, (Details)); - return (details.decimals > 0) ? Validation.validate.selector : bytes4(0xFFFFFFFF); - } - - // @inheritdoc Pricing - function getRefinanceConsideration(Starport.Loan calldata loan, bytes memory newPricingData, address) - external - view - virtual - override - returns ( - SpentItem[] memory repayConsideration, - SpentItem[] memory carryConsideration, - AdditionalTransfer[] memory additionalConsideration - ) - { - (additionalConsideration); - Details memory oldDetails = abi.decode(loan.terms.pricingData, (Details)); - Details memory newDetails = abi.decode(newPricingData, (Details)); - - if (oldDetails.decimals == newDetails.decimals && (newDetails.rate < oldDetails.rate)) { - (repayConsideration, carryConsideration) = getPaymentConsideration(loan); - } else { - revert InvalidRefinance(); - } - } -} diff --git a/test/StarportTest.sol b/test/StarportTest.sol index 3c2410a2..e34640c2 100644 --- a/test/StarportTest.sol +++ b/test/StarportTest.sol @@ -4,7 +4,7 @@ import "forge-std/Test.sol"; import {Vm} from "forge-std/Vm.sol"; import {Starport, Stargate} from "starport-core/Starport.sol"; import {Pricing} from "starport-core/pricing/Pricing.sol"; -import {StrategistOriginator} from "starport-core/originators/StrategistOriginator.sol"; +import {StrategistOriginator} from "starport-test/mocks/originators/StrategistOriginator.sol"; import { ItemType, ReceivedItem, @@ -29,41 +29,38 @@ import {Consideration} from "seaport-core/src/lib/Consideration.sol"; //import { // ReferenceConsideration as Consideration //} from "seaport/reference/ReferenceConsideration.sol"; -import {StrategistOriginator} from "starport-core/originators/StrategistOriginator.sol"; - -import {SimpleInterestPricing} from "starport-core/pricing/SimpleInterestPricing.sol"; - -import {BasePricing} from "starport-core/pricing/BasePricing.sol"; - -import {FixedTermStatus} from "starport-core/status/FixedTermStatus.sol"; -import {FixedTermDutchAuctionSettlement} from "starport-core/settlement/FixedTermDutchAuctionSettlement.sol"; -import {DutchAuctionSettlement} from "starport-core/settlement/DutchAuctionSettlement.sol"; +import {Custodian} from "starport-core/Custodian.sol"; import {Starport} from "starport-core/Starport.sol"; +import {Actions} from "starport-core/lib/StarportLib.sol"; import {BaseOrderTest} from "seaport/test/foundry/utils/BaseOrderTest.sol"; -import {TestERC721} from "seaport/contracts/test/TestERC721.sol"; -import {TestERC1155} from "seaport/contracts/test/TestERC1155.sol"; -import {TestERC20} from "seaport/contracts/test/TestERC20.sol"; import {ConsiderationItemLib} from "seaport/lib/seaport-sol/src/lib/ConsiderationItemLib.sol"; -import {Custodian} from "starport-core/Custodian.sol"; import "seaport/lib/seaport-sol/src/lib/AdvancedOrderLib.sol"; import {Status} from "starport-core/status/Status.sol"; import {Settlement} from "starport-core/settlement/Settlement.sol"; +import {TestERC721} from "seaport/contracts/test/TestERC721.sol"; +import {TestERC1155} from "seaport/contracts/test/TestERC1155.sol"; +import {TestERC20} from "seaport/contracts/test/TestERC20.sol"; +import {TokenReceiverInterface} from "starport-core/interfaces/TokenReceiverInterface.sol"; import {Pricing} from "starport-core/pricing/Pricing.sol"; + +import {BorrowerEnforcerBNPL} from "starport-test/mocks/enforcers/BorrowerEnforcerBNPL.sol"; import {Cast} from "starport-test/utils/Cast.sol"; +import {DutchAuctionSettlement} from "starport-test/mocks/settlement/DutchAuctionSettlement.sol"; +import {FixedTermStatus} from "starport-test/mocks/status/FixedTermStatus.sol"; +import {FixedTermDutchAuctionSettlement} from "starport-test/mocks/settlement/FixedTermDutchAuctionSettlement.sol"; +import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol"; + import {ERC20} from "solady/src/tokens/ERC20.sol"; import {ERC721} from "solady/src/tokens/ERC721.sol"; import {ERC1155} from "solady/src/tokens/ERC1155.sol"; import {ContractOffererInterface} from "seaport-types/src/interfaces/ContractOffererInterface.sol"; -import {TokenReceiverInterface} from "starport-core/interfaces/TokenReceiverInterface.sol"; import {Actions} from "starport-core/lib/StarportLib.sol"; import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol"; -import {BorrowerEnforcer} from "starport-core/enforcers/BorrowerEnforcer.sol"; -import {BorrowerEnforcerBNPL} from "starport-core/enforcers/BorrowerEnforcerBNPL.sol"; - -import {LenderEnforcer} from "starport-core/enforcers/LenderEnforcer.sol"; +import {BorrowerEnforcer} from "starport-test/mocks/enforcers/BorrowerEnforcer.sol"; +import {LenderEnforcer} from "starport-test/mocks/enforcers/LenderEnforcer.sol"; import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; interface IWETH9 { @@ -117,8 +114,9 @@ contract StarportTest is BaseOrderTest, Stargate { uint256 defaultLoanDuration = 14 days; // 1% interest rate per second - bytes defaultPricingData = - abi.encode(BasePricing.Details({carryRate: (uint256(1e16) * 10), rate: uint256(1e16) * 150, decimals: 18})); + bytes defaultPricingData = abi.encode( + SimpleInterestPricing.Details({carryRate: (uint256(1e16) * 10), rate: uint256(1e16) * 150, decimals: 18}) + ); bytes defaultSettlementData = abi.encode( DutchAuctionSettlement.Details({startingPrice: uint256(500 ether), endingPrice: 100 wei, window: 7 days}) @@ -137,10 +135,10 @@ contract StarportTest is BaseOrderTest, Stargate { Custodian custodian; StrategistOriginator SO; - BorrowerEnforcer borrowerEnforcer; + CaveatEnforcer borrowerEnforcer; BorrowerEnforcerBNPL borrowerEnforcerBNPL; - LenderEnforcer lenderEnforcer; + CaveatEnforcer lenderEnforcer; //mock the test harness as stargate function getOwner(address) external view returns (address) { @@ -619,7 +617,8 @@ contract StarportTest is BaseOrderTest, Stargate { uint256 lenderBefore = erc20s[0].balanceOf(lender.addr); uint256 originatorBefore = erc20s[0].balanceOf(loan.originator); - BasePricing.Details memory details = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory details = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 interest = SimpleInterestPricing(loan.terms.pricing).calculateInterest( 10 days, loan.debt[0].amount, details.rate, details.decimals ); diff --git a/test/fuzz-testing/TestFuzzStarport.sol b/test/fuzz-testing/TestFuzzStarport.sol index ffec10b3..c5dd8594 100644 --- a/test/fuzz-testing/TestFuzzStarport.sol +++ b/test/fuzz-testing/TestFuzzStarport.sol @@ -109,7 +109,7 @@ contract TestFuzzStarport is StarportTest, Bound, DeepEq { function boundPricingData(bytes memory boundPricingData) internal view virtual returns (bytes memory pricingData) { uint256 min = abi.decode(boundPricingData, (uint256)); - BasePricing.Details memory details = BasePricing.Details({ + SimpleInterestPricing.Details memory details = SimpleInterestPricing.Details({ rate: _boundMax(min, (uint256(1e16) * 150)), carryRate: _boundMax(0, uint256((1e16 * 100))), decimals: _boundMax(0, 18) @@ -204,7 +204,8 @@ contract TestFuzzStarport is StarportTest, Bound, DeepEq { } loan.collateral = ret; SpentItem[] memory debt = new SpentItem[](1); - BasePricing.Details memory pricingDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory pricingDetails = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); if (pricingDetails.decimals == 18) { debt[0] = SpentItem({ itemType: ItemType.ERC20, @@ -230,8 +231,9 @@ contract TestFuzzStarport is StarportTest, Bound, DeepEq { } function willArithmeticOverflow(Starport.Loan memory loan) internal view virtual returns (bool) { - BasePricing.Details memory pricingDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details)); - try BasePricing(loan.terms.pricing).getPaymentConsideration(loan) returns ( + SimpleInterestPricing.Details memory pricingDetails = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); + try SimpleInterestPricing(loan.terms.pricing).getPaymentConsideration(loan) returns ( SpentItem[] memory repayConsideration, SpentItem[] memory carryConsideration ) { unchecked { @@ -593,10 +595,11 @@ contract TestFuzzStarport is StarportTest, Bound, DeepEq { function testFuzzRefinance(FuzzRefinanceLoan memory params) public virtual { Starport.Loan memory goodLoan = fuzzNewLoanOrigination(params.origination, abi.encode(LoanBounds(1))); - BasePricing.Details memory oldDetails = abi.decode(goodLoan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory oldDetails = + abi.decode(goodLoan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 newRate = _boundMax(oldDetails.rate - 1, (uint256(1e16) * 1000) / (365 * 1 days)); - BasePricing.Details memory newPricingDetails = BasePricing.Details({ + SimpleInterestPricing.Details memory newPricingDetails = SimpleInterestPricing.Details({ rate: newRate, carryRate: _boundMax(0, uint256((1e16 * 100))), decimals: oldDetails.decimals diff --git a/src/lib/RefStarportLib.sol b/test/fuzz-testing/differential-fuzzing/RefStarportLib.sol similarity index 98% rename from src/lib/RefStarportLib.sol rename to test/fuzz-testing/differential-fuzzing/RefStarportLib.sol index d1e989bb..45d5bb5a 100644 --- a/src/lib/RefStarportLib.sol +++ b/test/fuzz-testing/differential-fuzzing/RefStarportLib.sol @@ -27,7 +27,7 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; +import {Starport} from "starport-core/Starport.sol"; import {ItemType, ReceivedItem, SpentItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; diff --git a/test/fuzz-testing/differential-fuzzing/TestStarPortLib.sol b/test/fuzz-testing/differential-fuzzing/TestStarPortLib.sol index 5b2bb395..d882731c 100644 --- a/test/fuzz-testing/differential-fuzzing/TestStarPortLib.sol +++ b/test/fuzz-testing/differential-fuzzing/TestStarPortLib.sol @@ -13,7 +13,7 @@ import { import {Conduit} from "seaport-core/src/conduit/Conduit.sol"; import {ConduitController} from "seaport-core/src/conduit/ConduitController.sol"; import {StarportLib} from "starport-core/lib/StarportLib.sol"; -import {RefStarportLib} from "starport-core/lib/RefStarportLib.sol"; +import {RefStarportLib} from "starport-test/fuzz-testing/differential-fuzzing/RefStarportLib.sol"; import "starport-test/utils/FuzzStructs.sol" as Fuzz; import {Bound} from "starport-test/utils/Bound.sol"; import {DeepEq} from "starport-test/utils/DeepEq.sol"; diff --git a/test/integration-testing/TestNewLoan.sol b/test/integration-testing/TestNewLoan.sol index b91dbc30..f5ae61be 100644 --- a/test/integration-testing/TestNewLoan.sol +++ b/test/integration-testing/TestNewLoan.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.17; import "starport-test/StarportTest.sol"; import {StarportLib, Actions} from "starport-core/lib/StarportLib.sol"; -import {BNPLHelper, IFlashLoanRecipient} from "starport-core/BNPLHelper.sol"; +import {BNPLHelper, IFlashLoanRecipient} from "starport-test/mocks/BNPLHelper.sol"; import {Originator} from "starport-core/originators/Originator.sol"; import {SignatureCheckerLib} from "solady/src/utils/SignatureCheckerLib.sol"; @@ -105,8 +105,9 @@ contract TestNewLoan is StarportTest { function testNewLoanRefinance() public { Starport.Loan memory loan = testNewLoanERC721CollateralDefaultTerms2(); Starport.Loan memory refiLoan = loanCopy(loan); - bytes memory newPricingData = - abi.encode(BasePricing.Details({carryRate: (uint256(1e16) * 10), rate: uint256(1e16) * 100, decimals: 18})); + bytes memory newPricingData = abi.encode( + SimpleInterestPricing.Details({carryRate: (uint256(1e16) * 10), rate: uint256(1e16) * 100, decimals: 18}) + ); refiLoan.terms.pricingData = newPricingData; refiLoan.debt = SP.applyRefinanceConsiderationToLoan(loan.debt, new SpentItem[](0)); LenderEnforcer.Details memory details = LenderEnforcer.Details({loan: refiLoan}); diff --git a/test/integration-testing/TestRepayLoan.sol b/test/integration-testing/TestRepayLoan.sol index a19e6990..cc03cae0 100644 --- a/test/integration-testing/TestRepayLoan.sol +++ b/test/integration-testing/TestRepayLoan.sol @@ -1,8 +1,7 @@ pragma solidity ^0.8.17; import "starport-test/StarportTest.sol"; -import {SimpleInterestPricing} from "starport-core/pricing/SimpleInterestPricing.sol"; -import {BasePricing} from "starport-core/pricing/BasePricing.sol"; +import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol"; import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; import {ZoneInteractionErrors} from "seaport-types/src/interfaces/ZoneInteractionErrors.sol"; import "forge-std/console2.sol"; @@ -26,7 +25,8 @@ contract TestRepayLoan is StarportTest { vm.startPrank(borrower.addr); skip(10 days); - BasePricing.Details memory details = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory details = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 interest = SimpleInterestPricing(loan.terms.pricing).calculateInterest( 10 days, loan.debt[0].amount, details.rate, details.decimals ); @@ -51,7 +51,8 @@ contract TestRepayLoan is StarportTest { { skip(10 days); - BasePricing.Details memory details = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory details = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 interest = SimpleInterestPricing(loan.terms.pricing).calculateInterest( 10 days, loan.debt[0].amount, details.rate, details.decimals ); @@ -123,7 +124,8 @@ contract TestRepayLoan is StarportTest { vm.startPrank(borrower.addr); skip(10 days); - BasePricing.Details memory details = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory details = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 interest = SimpleInterestPricing(loan.terms.pricing).calculateInterest( 10 days, loan.debt[0].amount, details.rate, details.decimals ); @@ -177,7 +179,8 @@ contract TestRepayLoan is StarportTest { vm.startPrank(borrower.addr); skip(14 days + 1); - BasePricing.Details memory details = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory details = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 interest = SimpleInterestPricing(loan.terms.pricing).calculateInterest( 10 days, loan.debt[0].amount, details.rate, details.decimals ); @@ -246,7 +249,8 @@ contract TestRepayLoan is StarportTest { vm.startPrank(borrower.addr); skip(10 days); - BasePricing.Details memory details = abi.decode(loan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory details = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); uint256 interest = SimpleInterestPricing(loan.terms.pricing).calculateInterest( 10 days, loan.debt[0].amount, details.rate, details.decimals ); diff --git a/src/BNPLHelper.sol b/test/mocks/BNPLHelper.sol similarity index 97% rename from src/BNPLHelper.sol rename to test/mocks/BNPLHelper.sol index 8667642f..781bbf06 100644 --- a/src/BNPLHelper.sol +++ b/test/mocks/BNPLHelper.sol @@ -27,9 +27,9 @@ pragma solidity ^0.8.17; -import {Starport} from "./Starport.sol"; -import {CaveatEnforcer} from "./enforcers/CaveatEnforcer.sol"; -import {AdditionalTransfer} from "./lib/StarportLib.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol"; +import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; import {Ownable} from "solady/src/auth/Ownable.sol"; import {Seaport} from "seaport/contracts/Seaport.sol"; import { diff --git a/src/enforcers/BorrowerEnforcer.sol b/test/mocks/enforcers/BorrowerEnforcer.sol similarity index 95% rename from src/enforcers/BorrowerEnforcer.sol rename to test/mocks/enforcers/BorrowerEnforcer.sol index 939ddbca..cd59eeff 100644 --- a/src/enforcers/BorrowerEnforcer.sol +++ b/test/mocks/enforcers/BorrowerEnforcer.sol @@ -27,9 +27,9 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol"; -import {AdditionalTransfer} from "../lib/StarportLib.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol"; +import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; import {ConsiderationInterface} from "seaport-types/src/interfaces/ConsiderationInterface.sol"; @@ -57,7 +57,7 @@ contract BorrowerEnforcer is CaveatEnforcer { /** * @dev Enforces that the loan terms are identical except for the issuer * The issuer is allowed to be any address - * No additional transfers are permitted + * No additional transfers are permitted from the borrower * @param additionalTransfers The additional transfers to be made * @param loan The loan terms * @param caveatData The borrowers encoded details diff --git a/src/enforcers/BorrowerEnforcerBNPL.sol b/test/mocks/enforcers/BorrowerEnforcerBNPL.sol similarity index 97% rename from src/enforcers/BorrowerEnforcerBNPL.sol rename to test/mocks/enforcers/BorrowerEnforcerBNPL.sol index 23c90186..3d3a189c 100644 --- a/src/enforcers/BorrowerEnforcerBNPL.sol +++ b/test/mocks/enforcers/BorrowerEnforcerBNPL.sol @@ -27,9 +27,9 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol"; -import {AdditionalTransfer} from "../lib/StarportLib.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol"; +import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; import {ConsiderationInterface} from "seaport-types/src/interfaces/ConsiderationInterface.sol"; diff --git a/src/enforcers/LenderEnforcer.sol b/test/mocks/enforcers/LenderEnforcer.sol similarity index 96% rename from src/enforcers/LenderEnforcer.sol rename to test/mocks/enforcers/LenderEnforcer.sol index 9fb82edb..b4b1a9ba 100644 --- a/src/enforcers/LenderEnforcer.sol +++ b/test/mocks/enforcers/LenderEnforcer.sol @@ -27,9 +27,9 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol"; -import {AdditionalTransfer} from "../lib/StarportLib.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol"; +import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; contract LenderEnforcer is CaveatEnforcer { error InvalidLoanTerms(); diff --git a/src/originators/StrategistOriginator.sol b/test/mocks/originators/StrategistOriginator.sol similarity index 97% rename from src/originators/StrategistOriginator.sol rename to test/mocks/originators/StrategistOriginator.sol index 01cedbb4..81adb917 100644 --- a/src/originators/StrategistOriginator.sol +++ b/test/mocks/originators/StrategistOriginator.sol @@ -27,10 +27,10 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol"; -import {Originator} from "../originators/Originator.sol"; -import {AdditionalTransfer, StarportLib} from "../lib/StarportLib.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol"; +import {Originator} from "starport-core/originators/Originator.sol"; +import {AdditionalTransfer, StarportLib} from "starport-core/lib/StarportLib.sol"; import {ConduitControllerInterface} from "seaport-types/src/interfaces/ConduitControllerInterface.sol"; import {ConduitInterface} from "seaport-types/src/interfaces/ConduitInterface.sol"; @@ -38,7 +38,7 @@ import {ItemType, ReceivedItem, SpentItem} from "seaport-types/src/lib/Considera import {ECDSA} from "solady/src/utils/ECDSA.sol"; import {Ownable} from "solady/src/auth/Ownable.sol"; import {SignatureCheckerLib} from "solady/src/utils/SignatureCheckerLib.sol"; -import {TokenReceiverInterface} from "../interfaces/TokenReceiverInterface.sol"; +import {TokenReceiverInterface} from "starport-core/interfaces/TokenReceiverInterface.sol"; // Validator abstract contract that lays out the necessary structure and functions for the validator contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface { diff --git a/src/pricing/BasePricing.sol b/test/mocks/pricing/SimpleInterestPricing.sol similarity index 81% rename from src/pricing/BasePricing.sol rename to test/mocks/pricing/SimpleInterestPricing.sol index 2190d549..7ddb71c4 100644 --- a/src/pricing/BasePricing.sol +++ b/test/mocks/pricing/SimpleInterestPricing.sol @@ -27,19 +27,16 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {Pricing} from "../pricing/Pricing.sol"; -import {Status} from "../status/Status.sol"; -import {Validation} from "../lib/Validation.sol"; -import {StarportLib} from "../lib/StarportLib.sol"; - -import {ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; -import {SpentItem, ItemType} from "seaport-types/src/lib/ConsiderationStructs.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {Pricing} from "starport-core/pricing/Pricing.sol"; +import {Validation} from "starport-core/lib/Validation.sol"; +import {StarportLib, AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; + +import {SpentItem, ItemType, ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; -abstract contract BasePricing is Pricing { +contract SimpleInterestPricing is Pricing { using FixedPointMathLib for uint256; - using {StarportLib.getId} for Starport.Loan; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STRUCTS */ @@ -52,14 +49,10 @@ abstract contract BasePricing is Pricing { } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ - /* EXTERNAL FUNCTIONS */ + /* CONSTRUCTOR */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ - // @inheritdoc Validation - function validate(Starport.Loan calldata loan) external view virtual override returns (bytes4) { - Details memory details = abi.decode(loan.terms.pricingData, (Details)); - return (details.decimals > 0) ? Validation.validate.selector : bytes4(0xFFFFFFFF); - } + constructor(Starport SP_) Pricing(SP_) {} /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC FUNCTIONS */ @@ -112,6 +105,22 @@ abstract contract BasePricing is Pricing { } } + /** + * @dev Computes the interest + * @param delta_t The time delta + * @param amount The amount to compute the interest for + * @param rate The interest rate + * @param decimals The decimals of the base asset + */ + function calculateInterest(uint256 delta_t, uint256 amount, uint256 rate, uint256 decimals) + public + pure + virtual + returns (uint256) + { + return StarportLib.calculateSimpleInterest(delta_t, amount, rate, decimals); + } + /** * @dev Computes the interest for a given loan * @param loan The loan to compute the interest for @@ -133,16 +142,36 @@ abstract contract BasePricing is Pricing { return calculateInterest(delta_t, loan.debt[index].amount, rate, decimals); } - /** - * @dev Computes the interest - * @param delta_t The time delta - * @param amount The amount to compute the interest for - * @param rate The interest rate - * @param decimals The decimals of the base asset - */ - function calculateInterest(uint256 delta_t, uint256 amount, uint256 rate, uint256 decimals) - public - pure + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ + /* EXTERNAL FUNCTIONS */ + /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ + + // @inheritdoc Validation + function validate(Starport.Loan calldata loan) external pure override returns (bytes4) { + Details memory details = abi.decode(loan.terms.pricingData, (Details)); + return (details.decimals > 0) ? Validation.validate.selector : bytes4(0xFFFFFFFF); + } + + // @inheritdoc Pricing + function getRefinanceConsideration(Starport.Loan calldata loan, bytes memory newPricingData, address) + external + view virtual - returns (uint256); + override + returns ( + SpentItem[] memory repayConsideration, + SpentItem[] memory carryConsideration, + AdditionalTransfer[] memory additionalConsideration + ) + { + (additionalConsideration); + Details memory oldDetails = abi.decode(loan.terms.pricingData, (Details)); + Details memory newDetails = abi.decode(newPricingData, (Details)); + + if (oldDetails.decimals == newDetails.decimals && (newDetails.rate < oldDetails.rate)) { + (repayConsideration, carryConsideration) = getPaymentConsideration(loan); + } else { + revert InvalidRefinance(); + } + } } diff --git a/src/settlement/DutchAuctionSettlement.sol b/test/mocks/settlement/DutchAuctionSettlement.sol similarity index 94% rename from src/settlement/DutchAuctionSettlement.sol rename to test/mocks/settlement/DutchAuctionSettlement.sol index fd6ffe54..c35ba5e2 100644 --- a/src/settlement/DutchAuctionSettlement.sol +++ b/test/mocks/settlement/DutchAuctionSettlement.sol @@ -35,13 +35,13 @@ import { OrderParameters } from "seaport-types/src/lib/ConsiderationStructs.sol"; -import {Pricing} from "../pricing/Pricing.sol"; +import {Pricing} from "starport-core/pricing/Pricing.sol"; import {AmountDeriver} from "seaport-core/src/lib/AmountDeriver.sol"; import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; -import {Starport, Settlement} from "../settlement/Settlement.sol"; +import {Starport, Settlement} from "starport-core/settlement/Settlement.sol"; -import {BasePricing} from "../pricing/BasePricing.sol"; -import {Validation} from "../lib/Validation.sol"; +import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol"; +import {Validation} from "starport-core/lib/Validation.sol"; // DutchAuctionSettlement is not full compatible with all debt assets supported by Starport // DutchAuctionSettlement makes the assumption that the loan.debt consists on an array size 1 containing only ERC-20s @@ -136,8 +136,9 @@ abstract contract DutchAuctionSettlement is Settlement, AmountDeriver { roundUp: true }); - BasePricing.Details memory pricingDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details)); - uint256 interest = BasePricing(loan.terms.pricing).getInterest( + SimpleInterestPricing.Details memory pricingDetails = + abi.decode(loan.terms.pricingData, (SimpleInterestPricing.Details)); + uint256 interest = SimpleInterestPricing(loan.terms.pricing).getInterest( loan, pricingDetails.rate, loan.start, block.timestamp, 0, pricingDetails.decimals ); diff --git a/src/settlement/FixedTermDutchAuctionSettlement.sol b/test/mocks/settlement/FixedTermDutchAuctionSettlement.sol similarity index 92% rename from src/settlement/FixedTermDutchAuctionSettlement.sol rename to test/mocks/settlement/FixedTermDutchAuctionSettlement.sol index c73caf1b..546187a2 100644 --- a/src/settlement/FixedTermDutchAuctionSettlement.sol +++ b/test/mocks/settlement/FixedTermDutchAuctionSettlement.sol @@ -27,11 +27,11 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {DutchAuctionSettlement} from "../settlement/DutchAuctionSettlement.sol"; -import {FixedTermStatus} from "../status/FixedTermStatus.sol"; -import {Settlement} from "../settlement/Settlement.sol"; -import {StarportLib} from "../lib/StarportLib.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {DutchAuctionSettlement} from "starport-test/mocks/settlement/DutchAuctionSettlement.sol"; +import {FixedTermStatus} from "starport-test/mocks/status/FixedTermStatus.sol"; +import {Settlement} from "starport-core/settlement/Settlement.sol"; +import {StarportLib} from "starport-core/lib/StarportLib.sol"; import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol"; import {SpentItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; diff --git a/src/status/FixedTermStatus.sol b/test/mocks/status/FixedTermStatus.sol similarity index 96% rename from src/status/FixedTermStatus.sol rename to test/mocks/status/FixedTermStatus.sol index 8a0433e8..08373fe8 100644 --- a/src/status/FixedTermStatus.sol +++ b/test/mocks/status/FixedTermStatus.sol @@ -27,9 +27,9 @@ pragma solidity ^0.8.17; -import {Starport} from "../Starport.sol"; -import {Status} from "../status/Status.sol"; -import {Validation} from "../lib/Validation.sol"; +import {Starport} from "starport-core/Starport.sol"; +import {Status} from "starport-core/status/Status.sol"; +import {Validation} from "starport-core/lib/Validation.sol"; contract FixedTermStatus is Status { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ diff --git a/test/unit-testing/ModuleTesting.t.sol b/test/unit-testing/ModuleTesting.t.sol index d4c22ffd..35fd87d6 100644 --- a/test/unit-testing/ModuleTesting.t.sol +++ b/test/unit-testing/ModuleTesting.t.sol @@ -6,12 +6,12 @@ import {LibString} from "solady/src/utils/LibString.sol"; import {Validation} from "starport-core/lib/Validation.sol"; import "forge-std/console.sol"; import "../utils/DeepEq.sol"; -import {DutchAuctionSettlement} from "starport-core/settlement/DutchAuctionSettlement.sol"; -import {FixedTermStatus} from "starport-core/status/FixedTermStatus.sol"; -import {BasePricing} from "starport-core/pricing/BasePricing.sol"; +import {DutchAuctionSettlement} from "starport-test/mocks/settlement/DutchAuctionSettlement.sol"; +import {FixedTermStatus} from "starport-test/mocks/status/FixedTermStatus.sol"; +import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol"; -contract MockBasePricing is BasePricing { - constructor(Starport SP_) Pricing(SP_) {} +contract MockBasePricing is SimpleInterestPricing { + constructor(Starport SP_) SimpleInterestPricing(SP_) {} function calculateInterest(uint256 delta_t, uint256 amount, uint256 rate, uint256 decimals) public @@ -58,7 +58,7 @@ contract ModuleTesting is StarportTest, DeepEq { badLoan.terms.statusData = abi.encode(FixedTermStatus.Details({loanDuration: 0})); badLoan.terms.settlementData = abi.encode(DutchAuctionSettlement.Details({startingPrice: 0, endingPrice: 0, window: 0})); - badLoan.terms.pricingData = abi.encode(BasePricing.Details({rate: 0, carryRate: 0, decimals: 0})); + badLoan.terms.pricingData = abi.encode(SimpleInterestPricing.Details({rate: 0, carryRate: 0, decimals: 0})); assertEq( Validation(loan.terms.status).validate(loan), Validation.validate.selector, "Loan has invalid status data" ); diff --git a/test/unit-testing/TestBorrowerEnforcer.sol b/test/unit-testing/TestBorrowerEnforcer.sol index 21481f30..20725e43 100644 --- a/test/unit-testing/TestBorrowerEnforcer.sol +++ b/test/unit-testing/TestBorrowerEnforcer.sol @@ -1,5 +1,34 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + +pragma solidity ^0.8.17; + import "starport-test/StarportTest.sol"; -import {BorrowerEnforcer} from "starport-core/enforcers/BorrowerEnforcer.sol"; +import {BorrowerEnforcer} from "starport-test/mocks/enforcers/BorrowerEnforcer.sol"; import {AdditionalTransfer, ItemType} from "starport-core/lib/StarportLib.sol"; import "forge-std/console.sol"; diff --git a/test/unit-testing/TestCustodian.sol b/test/unit-testing/TestCustodian.sol index eb667b80..b40ecc38 100644 --- a/test/unit-testing/TestCustodian.sol +++ b/test/unit-testing/TestCustodian.sol @@ -1,3 +1,30 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + pragma solidity ^0.8.17; import "starport-test/StarportTest.sol"; diff --git a/test/unit-testing/TestLenderEnforcer.sol b/test/unit-testing/TestLenderEnforcer.sol index 34aceaf1..5687c9bf 100644 --- a/test/unit-testing/TestLenderEnforcer.sol +++ b/test/unit-testing/TestLenderEnforcer.sol @@ -1,5 +1,5 @@ import "starport-test/StarportTest.sol"; -import {LenderEnforcer} from "starport-core/enforcers/LenderEnforcer.sol"; +import {LenderEnforcer} from "starport-test/mocks/enforcers/LenderEnforcer.sol"; import {AdditionalTransfer, ItemType} from "starport-core/lib/StarportLib.sol"; import "forge-std/console.sol"; diff --git a/test/unit-testing/TestPricing.sol b/test/unit-testing/TestPricing.sol index 56e7211c..57ffe315 100644 --- a/test/unit-testing/TestPricing.sol +++ b/test/unit-testing/TestPricing.sol @@ -8,8 +8,7 @@ import {Originator} from "starport-core/originators/Originator.sol"; import {Starport} from "starport-core/Starport.sol"; import {ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; -import {BasePricing} from "starport-core/pricing/BasePricing.sol"; -import {SimpleInterestPricing} from "starport-core/pricing/SimpleInterestPricing.sol"; +import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol"; contract TestSimpleInterestPricing is StarportTest, DeepEq { using Cast for *; @@ -39,7 +38,7 @@ contract TestSimpleInterestPricing is StarportTest, DeepEq { settlement: address(settlement), pricing: address(pricing), pricingData: abi.encode( - BasePricing.Details({carryRate: (uint256(1e16) * 10), rate: (uint256(1e16) * 150), decimals: 18}) + SimpleInterestPricing.Details({carryRate: (uint256(1e16) * 10), rate: (uint256(1e16) * 150), decimals: 18}) ), settlementData: abi.encode( DutchAuctionSettlement.Details({startingPrice: uint256(500 ether), endingPrice: 100 wei, window: 7 days}) @@ -118,7 +117,9 @@ contract TestSimpleInterestPricing is StarportTest, DeepEq { simplePricing.getRefinanceConsideration( targetLoan, - abi.encode(BasePricing.Details({carryRate: (uint256(1e16) * 10), rate: baseRate / 2, decimals: 18})), + abi.encode( + SimpleInterestPricing.Details({carryRate: (uint256(1e16) * 10), rate: baseRate / 2, decimals: 18}) + ), address(0) ); @@ -126,7 +127,9 @@ contract TestSimpleInterestPricing is StarportTest, DeepEq { simplePricing.getRefinanceConsideration( targetLoan, - abi.encode(BasePricing.Details({carryRate: (uint256(1e16) * 10), rate: baseRate * 2, decimals: 18})), + abi.encode( + SimpleInterestPricing.Details({carryRate: (uint256(1e16) * 10), rate: baseRate * 2, decimals: 18}) + ), address(0) ); } diff --git a/test/unit-testing/TestStarport.sol b/test/unit-testing/TestStarport.sol index 0f4ca3c0..9aa39c43 100644 --- a/test/unit-testing/TestStarport.sol +++ b/test/unit-testing/TestStarport.sol @@ -1,3 +1,30 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + pragma solidity ^0.8.17; import "starport-test/StarportTest.sol"; @@ -983,10 +1010,14 @@ contract TestStarport is StarportTest, DeepEq { } function testAdditionalTransfersRefinance() public { - BasePricing.Details memory currentPricing = abi.decode(activeLoan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory currentPricing = + abi.decode(activeLoan.terms.pricingData, (SimpleInterestPricing.Details)); - BasePricing.Details memory newPricingDetails = - BasePricing.Details({rate: currentPricing.rate - 1, carryRate: currentPricing.carryRate, decimals: 18}); + SimpleInterestPricing.Details memory newPricingDetails = SimpleInterestPricing.Details({ + rate: currentPricing.rate - 1, + carryRate: currentPricing.carryRate, + decimals: 18 + }); bytes memory newPricingData = abi.encode(newPricingDetails); (SpentItem[] memory refinanceConsideration, SpentItem[] memory carryConsideration,) = Pricing(activeLoan.terms.pricing).getRefinanceConsideration(activeLoan, newPricingData, lender.addr); @@ -1012,10 +1043,14 @@ contract TestStarport is StarportTest, DeepEq { } function testRefinancePostRepaymentFails() public { - BasePricing.Details memory currentPricing = abi.decode(activeLoan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory currentPricing = + abi.decode(activeLoan.terms.pricingData, (SimpleInterestPricing.Details)); - BasePricing.Details memory newPricingDetails = - BasePricing.Details({rate: currentPricing.rate - 1, carryRate: currentPricing.carryRate, decimals: 18}); + SimpleInterestPricing.Details memory newPricingDetails = SimpleInterestPricing.Details({ + rate: currentPricing.rate - 1, + carryRate: currentPricing.carryRate, + decimals: 18 + }); bytes memory newPricingData = abi.encode(newPricingDetails); vm.mockCall( @@ -1030,10 +1065,14 @@ contract TestStarport is StarportTest, DeepEq { } function testInvalidAdditionalTransfersRefinance() public { - BasePricing.Details memory currentPricing = abi.decode(activeLoan.terms.pricingData, (BasePricing.Details)); + SimpleInterestPricing.Details memory currentPricing = + abi.decode(activeLoan.terms.pricingData, (SimpleInterestPricing.Details)); - BasePricing.Details memory newPricingDetails = - BasePricing.Details({rate: currentPricing.rate - 1, carryRate: currentPricing.carryRate, decimals: 18}); + SimpleInterestPricing.Details memory newPricingDetails = SimpleInterestPricing.Details({ + rate: currentPricing.rate - 1, + carryRate: currentPricing.carryRate, + decimals: 18 + }); bytes memory newPricingData = abi.encode(newPricingDetails); (SpentItem[] memory refinanceConsideration, SpentItem[] memory carryConsideration,) = Pricing(activeLoan.terms.pricing).getRefinanceConsideration(activeLoan, newPricingData, lender.addr); diff --git a/test/utils/Assertions.sol b/test/utils/Assertions.sol index a2420e5b..18f744e7 100644 --- a/test/utils/Assertions.sol +++ b/test/utils/Assertions.sol @@ -1,3 +1,32 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + +pragma solidity ^0.8.17; + abstract contract Assertions { //Assert balances are correct after new loan is created modifier newLoanAssertions() { diff --git a/test/utils/Bound.sol b/test/utils/Bound.sol index 8c557216..2b3f081b 100644 --- a/test/utils/Bound.sol +++ b/test/utils/Bound.sol @@ -1,4 +1,31 @@ -pragma solidity =0.8.17; +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + +pragma solidity ^0.8.17; import { ItemType, diff --git a/test/utils/Cast.sol b/test/utils/Cast.sol index 5945e3fd..59a96f99 100644 --- a/test/utils/Cast.sol +++ b/test/utils/Cast.sol @@ -1,3 +1,30 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + pragma solidity ^0.8.17; import {ItemType, SpentItem, ReceivedItem, ConsiderationItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; diff --git a/test/utils/DeepEq.sol b/test/utils/DeepEq.sol index 189efc2c..bfc79104 100644 --- a/test/utils/DeepEq.sol +++ b/test/utils/DeepEq.sol @@ -1,3 +1,32 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + +pragma solidity ^0.8.17; + import {ItemType, SpentItem, ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; import {Cast} from "starport-test/utils/Cast.sol"; diff --git a/test/utils/Expect.sol b/test/utils/Expect.sol index 43e98656..06a24cfb 100644 --- a/test/utils/Expect.sol +++ b/test/utils/Expect.sol @@ -1,3 +1,32 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + +pragma solidity ^0.8.17; + import {ItemType, SpentItem, ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; import "forge-std/Test.sol"; diff --git a/test/utils/FuzzStructs.sol b/test/utils/FuzzStructs.sol index 25c1c8b0..b9a4a7d8 100644 --- a/test/utils/FuzzStructs.sol +++ b/test/utils/FuzzStructs.sol @@ -1,3 +1,30 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + pragma solidity ^0.8.17; struct ReceivedItem { diff --git a/test/utils/MockCall.sol b/test/utils/MockCall.sol index c2c45a20..dfea0bdf 100644 --- a/test/utils/MockCall.sol +++ b/test/utils/MockCall.sol @@ -1,11 +1,38 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// ↑↑↑↑ ↑↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑ ↑ +// ↑↑↑↑ ↑↑↑↑↑ +// ↑ ↑↑↑↑ ↑ ↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ +// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel +// ↑ ↑↑↑↑ ↑↑↑↑↑ +// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc +// ↑↑↑↑ ↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ +// ↑↑↑↑ + pragma solidity ^0.8.17; import {ItemType, SpentItem, ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol"; import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol"; import {TestBase} from "forge-std/Test.sol"; -import {Status} from "src/status/Status.sol"; -import {Settlement} from "src/settlement/Settlement.sol"; -import {Pricing} from "src/pricing/Pricing.sol"; +import {Status} from "starport-core/status/Status.sol"; +import {Settlement} from "starport-core/settlement/Settlement.sol"; +import {Pricing} from "starport-core/pricing/Pricing.sol"; abstract contract MockCall is TestBase { function mockStatusCall(address hook, bool status) public {