diff --git a/.gitignore b/.gitignore index 209674337..4823e9893 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ **/node_modules packages/contracts/generated +packages/contracts/lib/forge-std packages/contracts/deployments/hardhat packages/contracts/deployments/tenderly packages/contracts/deployments/localhost diff --git a/packages/contracts/contracts/LenderCommitmentForwarder.sol b/packages/contracts/contracts/LenderCommitmentForwarder.sol index afe1ffc2a..56a2ecdaa 100644 --- a/packages/contracts/contracts/LenderCommitmentForwarder.sol +++ b/packages/contracts/contracts/LenderCommitmentForwarder.sol @@ -6,6 +6,12 @@ import "./TellerV2MarketForwarder.sol"; // Interfaces import "./interfaces/ICollateralManager.sol"; + +import "./interfaces/allowlist/IAllowlistManager.sol"; +import "./interfaces/allowlist/IEnumerableSetAllowlist.sol"; + +import "./interfaces/ILenderCommitmentForwarder.sol"; + import { Collateral, CollateralType } from "./interfaces/escrow/ICollateralEscrowV1.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; @@ -14,8 +20,11 @@ import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeab import { MathUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; -contract LenderCommitmentForwarder is TellerV2MarketForwarder { - using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; + + + +contract LenderCommitmentForwarder is TellerV2MarketForwarder, ILenderCommitmentForwarder { + using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; enum CommitmentCollateralType { NONE, // no collateral required @@ -59,7 +68,9 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { uint256 commitmentCount; mapping(uint256 => EnumerableSetUpgradeable.AddressSet) - internal commitmentBorrowersList; + internal __commitmentBorrowersList; //DEPRECATED -> moved to manager + + mapping(uint256 => address) public commitmentAllowListManagers; /** * @notice This event is emitted when a lender's commitment is created. @@ -92,6 +103,11 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { uint256 tokenAmount ); + event UpdatedAllowlistManager( + uint256 indexed commitmentId, + address manager + ); + /** * @notice This event is emitted when the allowed borrowers for a commitment is updated. * @param commitmentId The id of the commitment that was updated. @@ -134,6 +150,11 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { _; } + + function getCommitmentLender(uint256 _commitmentId) public returns (address lender_){ + lender_ = commitments[_commitmentId].lender; + } + function validateCommitment(Commitment storage _commitment) internal { require( _commitment.expiration > uint32(block.timestamp), @@ -171,12 +192,12 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { /** * @notice Creates a loan commitment from a lender for a market. * @param _commitment The new commitment data expressed as a struct - * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment + * @param borrowerAllowlistManager The address of the allowlist contract * @return commitmentId_ returns the commitmentId for the created commitment */ function createCommitment( Commitment calldata _commitment, - address[] calldata _borrowerAddressList + address borrowerAllowlistManager ) public returns (uint256 commitmentId_) { commitmentId_ = commitmentCount++; @@ -186,10 +207,11 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { ); commitments[commitmentId_] = _commitment; + commitmentAllowListManagers[commitmentId_] = borrowerAllowlistManager; validateCommitment(commitments[commitmentId_]); - _addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList); + //_addBorrowersToCommitmentAllowlist(commitmentId_, _borrowerAddressList); emit CreatedCommitment( commitmentId_, @@ -198,6 +220,11 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { _commitment.principalTokenAddress, _commitment.maxPrincipal ); + + emit UpdatedAllowlistManager( + commitmentId_, + borrowerAllowlistManager + ); } /** @@ -232,33 +259,16 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { ); } - /** - * @notice Updates the borrowers allowed to accept a commitment - * @param _commitmentId The Id of the commitment to update. - * @param _borrowerAddressList The array of borrowers that are allowed to accept loans using this commitment - */ - function updateCommitmentBorrowers( + function updateAllowlistManager( uint256 _commitmentId, - address[] calldata _borrowerAddressList + address _allowlistManager ) public commitmentLender(_commitmentId) { - delete commitmentBorrowersList[_commitmentId]; - _addBorrowersToCommitmentAllowlist(_commitmentId, _borrowerAddressList); - } + + commitmentAllowListManagers[_commitmentId] = _allowlistManager; - /** - * @notice Adds a borrower to the allowlist for a commmitment. - * @param _commitmentId The id of the commitment that will allow the new borrower - * @param _borrowerArray the address array of the borrowers that will be allowed to accept loans using the commitment - */ - function _addBorrowersToCommitmentAllowlist( - uint256 _commitmentId, - address[] calldata _borrowerArray - ) internal { - for (uint256 i = 0; i < _borrowerArray.length; i++) { - commitmentBorrowersList[_commitmentId].add(_borrowerArray[i]); - } - emit UpdatedCommitmentBorrowers(_commitmentId); + emit UpdatedAllowlistManager(_commitmentId,_allowlistManager); } + /** * @notice Removes the commitment of a lender to a market. @@ -269,7 +279,7 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { commitmentLender(_commitmentId) { delete commitments[_commitmentId]; - delete commitmentBorrowersList[_commitmentId]; + //delete commitmentBorrowersList[_commitmentId]; emit DeletedCommitment(_commitmentId); } @@ -326,10 +336,19 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { ); require( - commitmentBorrowersList[_commitmentId].length() == 0 || - commitmentBorrowersList[_commitmentId].contains(borrower), - "unauthorized commitment borrower" + __commitmentBorrowersList[_commitmentId].length() == 0 || + commitmentAllowListManagers[_commitmentId] != address(0), + "Commitments with legacy borrower list must now set an allow list manager" + ); + + + require(commitmentAllowListManagers[_commitmentId] == address(0) || + IAllowlistManager(commitmentAllowListManagers[_commitmentId]).addressIsAllowed( + _commitmentId, borrower + ), + "Borrower not allowlisted" ); + if (_principalAmount > commitment.maxPrincipal) { revert InsufficientCommitmentAllocation({ @@ -398,6 +417,8 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { ); } + + /** * @notice Calculate the amount of collateral required to borrow a loan with _principalAmount of principal * @param _principalAmount The amount of currency to borrow for the loan. @@ -446,13 +467,13 @@ contract LenderCommitmentForwarder is TellerV2MarketForwarder { * @param _commitmentId The commitment id for the commitment to query. * @return borrowers_ An array of addresses restricted to accept the commitment. Empty array means unrestricted. */ - function getCommitmentBorrowers(uint256 _commitmentId) + /* function getCommitmentBorrowers(uint256 _commitmentId) external view returns (address[] memory borrowers_) { borrowers_ = commitmentBorrowersList[_commitmentId].values(); - } + }*/ /** * @notice Internal function to submit a bid to the lending protocol using a commitment diff --git a/packages/contracts/contracts/allowlist/ERC721Allowlist.sol b/packages/contracts/contracts/allowlist/ERC721Allowlist.sol new file mode 100644 index 000000000..a30ab3868 --- /dev/null +++ b/packages/contracts/contracts/allowlist/ERC721Allowlist.sol @@ -0,0 +1,36 @@ + +pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: MIT +import "../interfaces/allowlist/IAllowlistManager.sol"; + +import "../interfaces/allowlist/IERC721Allowlist.sol"; + + import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; + +contract ERC721Allowlist is IAllowlistManager,IERC721Allowlist { + + event UpdatedAllowList(uint256 commitmentId); + + + IERC721Upgradeable public immutable accessToken; //IERC721 + + + + constructor(address _accessToken){ + accessToken = IERC721Upgradeable(_accessToken); + } + + function addressIsAllowed(uint256 _commitmentId, address _account) public virtual returns (bool) { + return accessToken.balanceOf(_account) >= 1; + } + + /* + function getAllowedAddresses(uint256 _commitmentId) + public + view + returns (address[] memory borrowers_) + { + borrowers_ = allowList[_commitmentId].values(); + }*/ + +} \ No newline at end of file diff --git a/packages/contracts/contracts/allowlist/EnumerableSetAllowlist.sol b/packages/contracts/contracts/allowlist/EnumerableSetAllowlist.sol new file mode 100644 index 000000000..487fa2a35 --- /dev/null +++ b/packages/contracts/contracts/allowlist/EnumerableSetAllowlist.sol @@ -0,0 +1,72 @@ +pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: MIT + +import "../interfaces/allowlist/IAllowlistManager.sol"; +import "../interfaces/allowlist/IEnumerableSetAllowlist.sol"; + +import "../interfaces/ILenderCommitmentForwarder.sol"; + +import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; + + +contract EnumerableSetAllowlist is IAllowlistManager,IEnumerableSetAllowlist { + using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; + + event UpdatedAllowList(uint256 commitmentId); + + address public immutable commitmentManager; + + mapping(uint256 => EnumerableSetUpgradeable.AddressSet) internal allowList; + + modifier onlyCommitmentOwner(uint256 _commitmentId){ + require(msg.sender == ILenderCommitmentForwarder(commitmentManager).getCommitmentLender(_commitmentId),"Must be the lender of the commitment."); + _; + } + + constructor(address _commitmentManager){ + commitmentManager = _commitmentManager; + } + + + function setAllowlist( + uint256 _commitmentId, + address[] calldata _addressList + ) public + onlyCommitmentOwner(_commitmentId) + { + + delete allowList[_commitmentId]; + _addToAllowlist(_commitmentId, _addressList); + } + + + /** + * @notice Adds a addresses to the allowlist for a commmitment. + * @param _commitmentId The id of the commitment that will allow the new borrower + * @param _addressList the address array that will be allowed to accept loans using the commitment + */ + function _addToAllowlist( + uint256 _commitmentId, + address[] calldata _addressList + ) internal virtual { + + for (uint256 i = 0; i < _addressList.length; i++) { + allowList[_commitmentId].add(_addressList[i]); + } + emit UpdatedAllowList(_commitmentId); + } + + + function addressIsAllowed(uint256 _commitmentId, address _account) public virtual returns (bool) { + return allowList[_commitmentId].contains(_account); + } + + function getAllowedAddresses(uint256 _commitmentId) + public + view + returns (address[] memory borrowers_) + { + borrowers_ = allowList[_commitmentId].values(); + } + +} \ No newline at end of file diff --git a/packages/contracts/contracts/allowlist/OpenAllowlist.sol b/packages/contracts/contracts/allowlist/OpenAllowlist.sol new file mode 100644 index 000000000..04a18a504 --- /dev/null +++ b/packages/contracts/contracts/allowlist/OpenAllowlist.sol @@ -0,0 +1,20 @@ + +pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: MIT +import "../interfaces/allowlist/IAllowlistManager.sol"; + + +contract OpenAllowlist is IAllowlistManager { + + event UpdatedAllowList(uint256 commitmentId); + + constructor( ){ + + } + + function addressIsAllowed(uint256, address) public virtual returns (bool) { + return true; + } + + +} \ No newline at end of file diff --git a/packages/contracts/contracts/interfaces/ILenderCommitmentForwarder.sol b/packages/contracts/contracts/interfaces/ILenderCommitmentForwarder.sol new file mode 100644 index 000000000..562131e1f --- /dev/null +++ b/packages/contracts/contracts/interfaces/ILenderCommitmentForwarder.sol @@ -0,0 +1,9 @@ +// SPDX-Licence-Identifier: MIT +pragma solidity >=0.8.0 <0.9.0; + + +interface ILenderCommitmentForwarder { + + function getCommitmentLender(uint256 _commitmentId) external returns (address lender_); + +} diff --git a/packages/contracts/contracts/interfaces/allowlist/IAllowlistManager.sol b/packages/contracts/contracts/interfaces/allowlist/IAllowlistManager.sol new file mode 100644 index 000000000..61e058cd9 --- /dev/null +++ b/packages/contracts/contracts/interfaces/allowlist/IAllowlistManager.sol @@ -0,0 +1,9 @@ + + + +interface IAllowlistManager { + + + function addressIsAllowed(uint256 _commitmentId,address _account) external returns (bool allowed_) ; + +} \ No newline at end of file diff --git a/packages/contracts/contracts/interfaces/allowlist/IERC721Allowlist.sol b/packages/contracts/contracts/interfaces/allowlist/IERC721Allowlist.sol new file mode 100644 index 000000000..8bf56c350 --- /dev/null +++ b/packages/contracts/contracts/interfaces/allowlist/IERC721Allowlist.sol @@ -0,0 +1,6 @@ + + +interface IERC721Allowlist { + + +} \ No newline at end of file diff --git a/packages/contracts/contracts/interfaces/allowlist/IEnumerableSetAllowlist.sol b/packages/contracts/contracts/interfaces/allowlist/IEnumerableSetAllowlist.sol new file mode 100644 index 000000000..ecf4ed37d --- /dev/null +++ b/packages/contracts/contracts/interfaces/allowlist/IEnumerableSetAllowlist.sol @@ -0,0 +1,11 @@ + + + +interface IEnumerableSetAllowlist { + + function setAllowlist( + uint256 _commitmentId, + address[] calldata _addressList + ) external; + +} \ No newline at end of file diff --git a/packages/contracts/contracts/mock/AllowlistManagerMock.sol b/packages/contracts/contracts/mock/AllowlistManagerMock.sol new file mode 100644 index 000000000..cc312a2c8 --- /dev/null +++ b/packages/contracts/contracts/mock/AllowlistManagerMock.sol @@ -0,0 +1,11 @@ + +import "../interfaces/allowlist/IAllowlistManager.sol"; +contract AllowlistManagerMock is IAllowlistManager { + + + function addressIsAllowed(uint256 _commitmentId, address _account) public returns (bool _allowed) { + return true; + } + + +} diff --git a/packages/contracts/contracts/mock/LenderCommitmentForwarderMock.sol b/packages/contracts/contracts/mock/LenderCommitmentForwarderMock.sol new file mode 100644 index 000000000..e545f4f9e --- /dev/null +++ b/packages/contracts/contracts/mock/LenderCommitmentForwarderMock.sol @@ -0,0 +1,24 @@ +pragma solidity ^0.8.0; + +// SPDX-License-Identifier: MIT + +import "../interfaces/ILenderCommitmentForwarder.sol"; + +contract LenderCommitmentForwarderMock is ILenderCommitmentForwarder { + + address lender; + + function setLender(address _lender) public { + lender = _lender; + } + + function getCommitmentLender(uint256 _commitmentId) external returns (address){ + + return lender; + + } + + + + +} diff --git a/packages/contracts/deploy/00_deploy_commitment_allowlists.ts b/packages/contracts/deploy/00_deploy_commitment_allowlists.ts new file mode 100644 index 000000000..e61778465 --- /dev/null +++ b/packages/contracts/deploy/00_deploy_commitment_allowlists.ts @@ -0,0 +1,38 @@ +import { DeployFunction } from 'hardhat-deploy/dist/types' +import { deploy } from 'helpers/deploy-helpers' + +const deployFn: DeployFunction = async (hre) => { + + + // const tellerV2 = await hre.contracts.get('TellerV2') + const lenderCommitmentForwarder = await hre.contracts.get('LenderCommitmentForwarder') + + + + await deploy({ + contract: 'EnumerableSetAllowlist', + args: [ lenderCommitmentForwarder.address ], + proxy: { + proxyContract: 'OpenZeppelinTransparentProxy', + + }, + skipIfAlreadyDeployed: true, + hre, + }) + + await deploy({ + contract: 'OpenAllowlist', + args: [ ], + proxy: { + proxyContract: 'OpenZeppelinTransparentProxy', + + }, + skipIfAlreadyDeployed: true, + hre, + }) +} + +// tags and deployment +deployFn.tags = ['commitment-allowlists'] +deployFn.dependencies = ['teller-v2'] +export default deployFn diff --git a/packages/contracts/tests/ERC721Allowlist_Test.sol b/packages/contracts/tests/ERC721Allowlist_Test.sol new file mode 100644 index 000000000..b06183055 --- /dev/null +++ b/packages/contracts/tests/ERC721Allowlist_Test.sol @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/utils/Address.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; + +import "forge-std/console.sol"; + +import { Testable } from "./Testable.sol"; +import { LenderCommitmentForwarder } from "../contracts/LenderCommitmentForwarder.sol"; + + +import "./tokens/TestERC721Token.sol"; + +import { User } from "./Test_Helpers.sol"; + +import "../contracts/allowlist/ERC721Allowlist.sol"; + +contract EnumerableSetAllowlist_Test is Testable, ERC721Allowlist { + + + + AllowlistUser private lender; + AllowlistUser private borrower; + + + constructor() + ERC721Allowlist(address(new TestERC721Token("TEST","TST")) ) + {} + + function setUp() public { + + borrower = new AllowlistUser(address(this)); + + + } + + function test_addressIsAllowed() public { + + bool allowedBefore = super.addressIsAllowed(0,address(borrower)); + + assertEq( + allowedBefore, + false, + "Expected borrower to be disallowed" + ); + + uint256 tokenId = TestERC721Token(address(accessToken)).mint(address(borrower)); + + + bool allowedAfter = super.addressIsAllowed(0,address(borrower)); + + assertEq( + allowedAfter, + true, + "Expected borrower to be allowed" + ); + } + + +} + + +contract AllowlistUser { + + address allowlistManager; + + constructor( address _allowlistManager ){ + allowlistManager = _allowlistManager; + } + + + + +} \ No newline at end of file diff --git a/packages/contracts/tests/EnumerableSetAllowlist_Test.sol b/packages/contracts/tests/EnumerableSetAllowlist_Test.sol new file mode 100644 index 000000000..e6d268169 --- /dev/null +++ b/packages/contracts/tests/EnumerableSetAllowlist_Test.sol @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/utils/Address.sol"; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +import "./tokens/TestERC20Token.sol"; + +import "forge-std/console.sol"; + +import { Testable } from "./Testable.sol"; +import { LenderCommitmentForwarder } from "../contracts/LenderCommitmentForwarder.sol"; + + +import { User } from "./Test_Helpers.sol"; + +import "../contracts/allowlist/EnumerableSetAllowlist.sol"; +import "../contracts/mock/LenderCommitmentForwarderMock.sol"; + +contract EnumerableSetAllowlist_Test is Testable, EnumerableSetAllowlist { + + + address[] emptyArray; + address[] borrowersArray; + + + AllowlistUser private lender; + AllowlistUser private borrower; + + bool addToAllowlistCalled; + + LenderCommitmentForwarderMock lenderCommitmentForwarderMock; + + + constructor() + EnumerableSetAllowlist(address( new LenderCommitmentForwarderMock() )) + {} + + function setUp() public { + borrower = new AllowlistUser(address(this)); + lender = new AllowlistUser(address(this)); + + + borrowersArray = new address[](1); + borrowersArray[0] = address(borrower); + + LenderCommitmentForwarderMock( commitmentManager ).setLender(address(lender)); + + + addToAllowlistCalled = false; + } + + function test_setAllowlist() public { + + + bool isAllowedBefore = addressIsAllowed(0,address(borrower)); + + assertEq( + isAllowedBefore, + false, + "Expected borrower to be disallowed" + ); + + LenderCommitmentForwarderMock( commitmentManager ).setLender(address(lender)); + + + AllowlistUser(lender).call_setAllowList( + 0, + borrowersArray + ); + + address[] memory allowedBorrowers = super.getAllowedAddresses(0); + + + bool isAllowedAfter = addressIsAllowed(0,address(borrower)); + + assertEq( + isAllowedAfter, + true, + "Expected borrower to be allowed" + ); + + + } + + + +} + + +contract AllowlistUser { + + address allowlistManager; + + constructor( address _allowlistManager ){ + allowlistManager = _allowlistManager; + } + + function call_setAllowList( + uint256 commitmentId, + address[] memory borrowersArray + ) public { + + EnumerableSetAllowlist(allowlistManager).setAllowlist( 0, borrowersArray ); + + } + + +} \ No newline at end of file diff --git a/packages/contracts/tests/LenderCommitmentForwarder_Test.sol b/packages/contracts/tests/LenderCommitmentForwarder_Test.sol index 64cf1008d..a282c56ee 100644 --- a/packages/contracts/tests/LenderCommitmentForwarder_Test.sol +++ b/packages/contracts/tests/LenderCommitmentForwarder_Test.sol @@ -5,7 +5,7 @@ import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "../contracts/TellerV2MarketForwarder.sol"; -import "./resolvers/TestERC20Token.sol"; +import "./tokens/TestERC20Token.sol"; import "../contracts/TellerV2Context.sol"; import { Testable } from "./Testable.sol"; @@ -16,6 +16,7 @@ import { Collateral, CollateralType } from "../contracts/interfaces/escrow/IColl import { User } from "./Test_Helpers.sol"; import "../contracts/mock/MarketRegistryMock.sol"; +import "../contracts/mock/AllowlistManagerMock.sol"; contract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder { LenderCommitmentForwarderTest_TellerV2Mock private tellerV2Mock; @@ -40,6 +41,8 @@ contract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder { bool submitBidWasCalled; bool submitBidWithCollateralWasCalled; + AllowlistManagerMock allowlistManager; + TestERC20Token principalToken; uint8 constant principalTokenDecimals = 18; @@ -59,12 +62,15 @@ contract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder { ); mockMarketRegistry = MarketRegistryMock(address(getMarketRegistry())); - marketOwner = new LenderCommitmentUser(address(tellerV2Mock), (this)); - borrower = new LenderCommitmentUser(address(tellerV2Mock), (this)); - lender = new LenderCommitmentUser(address(tellerV2Mock), (this)); + allowlistManager = new AllowlistManagerMock(); + + marketOwner = new LenderCommitmentUser(address(tellerV2Mock), (this), address(allowlistManager)); + borrower = new LenderCommitmentUser(address(tellerV2Mock), (this), address(allowlistManager)); + lender = new LenderCommitmentUser(address(tellerV2Mock), (this), address(allowlistManager)); tellerV2Mock.__setMarketOwner(marketOwner); mockMarketRegistry.setMarketOwner(address(marketOwner)); + //tokenAddress = address(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174); marketId = 2; @@ -252,7 +258,7 @@ contract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder { ); } - function test_acceptCommitmentWithBorrowersArray_valid() public { + /* function test_acceptCommitmentWithBorrowersArray_valid() public { uint256 commitmentId = 0; Commitment storage commitment = _createCommitment( @@ -359,7 +365,7 @@ contract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder { true, "Expect accept bid called after exercise" ); - } + }*/ function test_acceptCommitmentFailsWithInsufficientCollateral() public { uint256 commitmentId = 0; @@ -850,12 +856,15 @@ contract LenderCommitmentForwarder_Test is Testable, LenderCommitmentForwarder { contract LenderCommitmentUser is User { LenderCommitmentForwarder public immutable commitmentForwarder; + AllowlistManagerMock allowlistManager; constructor( address _tellerV2, - LenderCommitmentForwarder _commitmentForwarder + LenderCommitmentForwarder _commitmentForwarder, + address _allowlistManager ) User(_tellerV2) { commitmentForwarder = _commitmentForwarder; + allowlistManager = AllowlistManagerMock(_allowlistManager); } function _createCommitment( @@ -865,7 +874,7 @@ contract LenderCommitmentUser is User { return commitmentForwarder.createCommitment( _commitment, - borrowerAddressList + address(allowlistManager) ); } @@ -876,16 +885,6 @@ contract LenderCommitmentUser is User { commitmentForwarder.updateCommitment(commitmentId, _commitment); } - function _updateCommitmentBorrowers( - uint256 commitmentId, - address[] calldata borrowerAddressList - ) public { - commitmentForwarder.updateCommitmentBorrowers( - commitmentId, - borrowerAddressList - ); - } - function _acceptCommitment( uint256 commitmentId, uint256 principal, diff --git a/packages/contracts/tests/MarketLiquidityRewards_Test.sol b/packages/contracts/tests/MarketLiquidityRewards_Test.sol index 3641b86c0..9ebf3c2dc 100644 --- a/packages/contracts/tests/MarketLiquidityRewards_Test.sol +++ b/packages/contracts/tests/MarketLiquidityRewards_Test.sol @@ -5,7 +5,7 @@ import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "../contracts/TellerV2MarketForwarder.sol"; -import "./resolvers/TestERC20Token.sol"; +import "./tokens/TestERC20Token.sol"; import "../contracts/TellerV2Context.sol"; import { Testable } from "./Testable.sol"; diff --git a/packages/contracts/tests/TellerV2_Test.sol b/packages/contracts/tests/TellerV2_Test.sol index 4b69b4af1..6d9553d40 100644 --- a/packages/contracts/tests/TellerV2_Test.sol +++ b/packages/contracts/tests/TellerV2_Test.sol @@ -20,7 +20,7 @@ import { User } from "./Test_Helpers.sol"; import "../contracts/escrow/CollateralEscrowV1.sol"; import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import "../contracts/LenderCommitmentForwarder.sol"; -import "./resolvers/TestERC20Token.sol"; +import "./tokens/TestERC20Token.sol"; import "../contracts/CollateralManager.sol"; import { Collateral } from "../contracts/interfaces/escrow/ICollateralEscrowV1.sol"; diff --git a/packages/contracts/tests/resolvers/TestERC20Token.sol b/packages/contracts/tests/tokens/TestERC20Token.sol similarity index 100% rename from packages/contracts/tests/resolvers/TestERC20Token.sol rename to packages/contracts/tests/tokens/TestERC20Token.sol diff --git a/packages/contracts/tests/tokens/TestERC721Token.sol b/packages/contracts/tests/tokens/TestERC721Token.sol new file mode 100644 index 000000000..4a62a29aa --- /dev/null +++ b/packages/contracts/tests/tokens/TestERC721Token.sol @@ -0,0 +1,19 @@ +pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: MIT + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; + +contract TestERC721Token is ERC721 { + + uint256 public _totalSupply; + constructor( + string memory _name, + string memory _symbol + ) ERC721(_name, _symbol) { } + + function mint(address recipient) public returns (uint256) { + uint256 tokenId = _totalSupply++; + _mint(recipient, tokenId); + return tokenId; + } +}