diff --git a/packages/contracts/contracts/CollateralManager.sol b/packages/contracts/contracts/CollateralManager.sol index 5b0a68fe..5d1b5a83 100644 --- a/packages/contracts/contracts/CollateralManager.sol +++ b/packages/contracts/contracts/CollateralManager.sol @@ -7,7 +7,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; // Libraries import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; - +import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; // Interfaces import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; @@ -70,7 +70,7 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { _; } - modifier onlyProtocolOwner() { + modifier onlyProtocolOwner() { address protocolOwner = OwnableUpgradeable(address(tellerV2)).owner(); @@ -78,6 +78,11 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { _; } + modifier whenProtocolNotPaused() { + require( PausableUpgradeable(address(tellerV2)).paused() == false , "Protocol is paused"); + _; + } + /* External Functions */ /** @@ -262,7 +267,7 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { * @notice Withdraws deposited collateral from the created escrow of a bid that has been successfully repaid. * @param _bidId The id of the bid to withdraw collateral for. */ - function withdraw(uint256 _bidId) external { + function withdraw(uint256 _bidId) external whenProtocolNotPaused { BidState bidState = tellerV2.getBidState(_bidId); require(bidState == BidState.PAID, "collateral cannot be withdrawn"); @@ -277,7 +282,7 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { address _tokenAddress, uint256 _amount, address _recipientAddress - ) external onlyProtocolOwner { + ) external onlyProtocolOwner whenProtocolNotPaused { ICollateralEscrowV1(_escrows[_bidId]).withdrawDustTokens( _tokenAddress, @@ -290,7 +295,7 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { * @notice Withdraws deposited collateral from the created escrow of a bid that has been CLOSED after being defaulted. * @param _bidId The id of the bid to withdraw collateral for. */ - function lenderClaimCollateral(uint256 _bidId) external onlyTellerV2 { + function lenderClaimCollateral(uint256 _bidId) external onlyTellerV2 whenProtocolNotPaused { if (isBidCollateralBacked(_bidId)) { BidState bidState = tellerV2.getBidState(_bidId); @@ -308,7 +313,7 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { * @notice Withdraws deposited collateral from the created escrow of a bid that has been CLOSED after being defaulted. * @param _bidId The id of the bid to withdraw collateral for. */ - function lenderClaimCollateralWithRecipient(uint256 _bidId, address _collateralRecipient) external onlyTellerV2 { + function lenderClaimCollateralWithRecipient(uint256 _bidId, address _collateralRecipient) external onlyTellerV2 whenProtocolNotPaused { if (isBidCollateralBacked(_bidId)) { BidState bidState = tellerV2.getBidState(_bidId); @@ -331,6 +336,7 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager { function liquidateCollateral(uint256 _bidId, address _liquidatorAddress) external onlyTellerV2 + whenProtocolNotPaused { if (isBidCollateralBacked(_bidId)) { BidState bidState = tellerV2.getBidState(_bidId); diff --git a/packages/contracts/contracts/LenderCommitmentForwarder/SmartCommitmentForwarder.sol b/packages/contracts/contracts/LenderCommitmentForwarder/SmartCommitmentForwarder.sol index d7867cf1..de1a39c1 100644 --- a/packages/contracts/contracts/LenderCommitmentForwarder/SmartCommitmentForwarder.sol +++ b/packages/contracts/contracts/LenderCommitmentForwarder/SmartCommitmentForwarder.sol @@ -7,12 +7,15 @@ import "../interfaces/ILenderCommitmentForwarder.sol"; import "../interfaces/ISmartCommitmentForwarder.sol"; import "./LenderCommitmentForwarder_G1.sol"; +import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; + import { CommitmentCollateralType, ISmartCommitment } from "../interfaces/ISmartCommitment.sol"; contract SmartCommitmentForwarder is - ExtensionsContextUpgradeable, //this should always be first for upgradeability + ExtensionsContextUpgradeable, //this should always be first for upgradeability TellerV2MarketForwarder_G3, + PausableUpgradeable, //this does add some storage but AFTER all other storage ISmartCommitmentForwarder { event ExercisedSmartCommitment( @@ -24,9 +27,23 @@ contract SmartCommitmentForwarder is error InsufficientBorrowerCollateral(uint256 required, uint256 actual); + + + modifier onlyProtocolPauser() { + require( ITellerV2( _tellerV2 ).isPauser(_msgSender()) , "Sender not authorized"); + _; + } + + + constructor(address _protocolAddress, address _marketRegistry) TellerV2MarketForwarder_G3(_protocolAddress, _marketRegistry) - {} + { } + + function initialize() public initializer { + __Pausable_init(); + } + /** * @notice Accept the commitment to submitBid and acceptBid using the funds @@ -50,7 +67,7 @@ contract SmartCommitmentForwarder is address _recipient, uint16 _interestRate, uint32 _loanDuration - ) public returns (uint256 bidId) { + ) public whenNotPaused returns (uint256 bidId) { require( ISmartCommitment(_smartCommitmentAddress) .getCollateralTokenType() <= @@ -162,6 +179,23 @@ contract SmartCommitmentForwarder is + /** + * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism. + */ + function pause() public virtual onlyProtocolPauser whenNotPaused { + _pause(); + } + + /** + * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop. + */ + function unpause() public virtual onlyProtocolPauser whenPaused { + _unpause(); + } + + + // ----- + //Overrides function _msgSender() internal diff --git a/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Factory.sol b/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Factory.sol new file mode 100644 index 00000000..61b827d4 --- /dev/null +++ b/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Factory.sol @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +// Contracts +import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +// Interfaces +import "../../../interfaces/ITellerV2.sol"; +import "../../../interfaces/IProtocolFee.sol"; +import "../../../interfaces/ITellerV2Storage.sol"; +//import "../../../interfaces/ILenderCommitmentForwarder.sol"; +import "../../../libraries/NumbersLib.sol"; + +import "./LenderCommitmentGroup_Smart.sol"; +//import {CreateCommitmentArgs} from "../../interfaces/ILenderCommitmentGroup.sol"; + +import { ILenderCommitmentGroup } from "../../../interfaces/ILenderCommitmentGroup.sol"; + +contract LenderCommitmentGroupFactory { + using AddressUpgradeable for address; + using NumbersLib for uint256; + + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable + ITellerV2 public immutable TELLER_V2; + /// @custom:oz-upgrades-unsafe-allow state-variable-immutable + address public immutable SMART_COMMITMENT_FORWARDER; + address public immutable UNISWAP_V3_FACTORY; + + mapping(address => uint256) public deployedLenderGroupContracts; + + event DeployedLenderGroupContract(address indexed groupContract); + + /// @custom:oz-upgrades-unsafe-allow constructor + constructor( + address _tellerV2, + address _smartCommitmentForwarder, + address _uniswapV3Factory + ) { + TELLER_V2 = ITellerV2(_tellerV2); + SMART_COMMITMENT_FORWARDER = _smartCommitmentForwarder; + UNISWAP_V3_FACTORY = _uniswapV3Factory; + } + + /* + This should deploy a new lender commitment group pool contract. + It will use create commitment args in order to define the pool contracts parameters such as its primary principal token. + Shares will be distributed at a 1:1 ratio of the primary principal token so if 1e18 raw WETH are deposited, the depositor gets 1e18 shares for the group pool. + */ + function deployLenderCommitmentGroupPool( + uint256 _initialPrincipalAmount, + address _principalTokenAddress, + address _collateralTokenAddress, + uint256 _marketId, + uint32 _maxLoanDuration, + uint16 _interestRateLowerBound, + uint16 _interestRateUpperBound, + uint16 _liquidityThresholdPercent, + uint16 _loanToValuePercent, + uint24 _uniswapPoolFee, + uint32 _twapInterval + ) external returns (address newGroupContract_) { + //these should be upgradeable proxies ??? + newGroupContract_ = address( + new LenderCommitmentGroup_Smart( + address(TELLER_V2), + address(SMART_COMMITMENT_FORWARDER), + address(UNISWAP_V3_FACTORY) + ) + ); + + deployedLenderGroupContracts[newGroupContract_] = block.number; //consider changing this ? + emit DeployedLenderGroupContract(newGroupContract_); + + /* + The max principal should be a very high number! higher than usual + The expiration time should be far in the future! farther than usual + */ + ILenderCommitmentGroup(newGroupContract_).initialize( + _principalTokenAddress, + _collateralTokenAddress, + _marketId, + _maxLoanDuration, + _interestRateLowerBound, + _interestRateUpperBound, + _liquidityThresholdPercent, + _loanToValuePercent, + _uniswapPoolFee, + _twapInterval + ); + + //it is not absolutely necessary to have this call here but it allows the user to potentially save a tx step so it is nice to have . + if (_initialPrincipalAmount > 0) { + //should pull in the creators initial committed principal tokens . + + //send the initial principal tokens to _newgroupcontract here ! + // so it will have them for addPrincipalToCommitmentGroup which will pull them from here + + IERC20(_principalTokenAddress).transferFrom( + msg.sender, + address(this), + _initialPrincipalAmount + ); + IERC20(_principalTokenAddress).approve( + address(newGroupContract_), + _initialPrincipalAmount + ); + + address sharesRecipient = msg.sender; + + + + uint256 sharesAmount_ = ILenderCommitmentGroup(newGroupContract_) + .addPrincipalToCommitmentGroup( + _initialPrincipalAmount, + sharesRecipient, + 0 //_minShares + ); + } + } +} diff --git a/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol b/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol index 72481fbd..6afa9311 100644 --- a/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol +++ b/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol @@ -117,7 +117,7 @@ contract LenderCommitmentGroup_Smart is mapping(address => uint256) public poolSharesPreparedToWithdrawForLender; mapping(address => uint256) public poolSharesPreparedTimestamp; - uint256 immutable public WITHDRAW_DELAY_TIME_SECONDS = 300; + uint256 immutable public DEFAULT_WITHDRAWL_DELAY_TIME_SECONDS = 300; //mapping(address => uint256) public principalTokensCommittedByLender; @@ -128,6 +128,7 @@ contract LenderCommitmentGroup_Smart is int256 tokenDifferenceFromLiquidations; bool public firstDepositMade; + uint256 public withdrawlDelayTimeSeconds; @@ -187,6 +188,13 @@ contract LenderCommitmentGroup_Smart is uint256 totalInterestCollected ); + event PoolSharesPrepared( + address lender, + uint256 sharesAmount, + uint256 preparedAt + + ); + modifier onlySmartCommitmentForwarder() { require( @@ -204,12 +212,28 @@ contract LenderCommitmentGroup_Smart is _; } + + modifier onlyProtocolOwner() { + require( + msg.sender == Ownable(address(TELLER_V2)).owner(), + "Can only be called by TellerV2" + ); + _; + } + modifier bidIsActiveForGroup(uint256 _bidId) { require(activeBids[_bidId] == true, "Bid is not active for group"); _; } + modifier whenForwarderNotPaused() { + require( PausableUpgradeable(address(SMART_COMMITMENT_FORWARDER)).paused() == false , "Protocol is paused"); + _; + } + + + /// @custom:oz-upgrades-unsafe-allow constructor constructor( address _tellerV2, @@ -219,6 +243,7 @@ contract LenderCommitmentGroup_Smart is TELLER_V2 = _tellerV2; SMART_COMMITMENT_FORWARDER = _smartCommitmentForwarder; UNISWAP_V3_FACTORY = _uniswapV3Factory; + } /* @@ -257,6 +282,8 @@ contract LenderCommitmentGroup_Smart is marketId = _marketId; + withdrawlDelayTimeSeconds = DEFAULT_WITHDRAWL_DELAY_TIME_SECONDS; + //in order for this to succeed, first, that SmartCommitmentForwarder needs to be THE trusted forwarder for the market @@ -299,6 +326,14 @@ contract LenderCommitmentGroup_Smart is ); } + + function setWithdrawlDelayTime(uint256 _seconds) + external + onlyProtocolOwner { + + withdrawlDelayTimeSeconds = _seconds; + } + function _deployPoolSharesToken() internal onlyInitializing @@ -374,7 +409,7 @@ contract LenderCommitmentGroup_Smart is uint256 _amount, address _sharesRecipient, uint256 _minSharesAmountOut - ) external returns (uint256 sharesAmount_) { + ) external whenForwarderNotPaused returns (uint256 sharesAmount_) { //transfers the primary principal token from msg.sender into this contract escrow @@ -400,10 +435,13 @@ contract LenderCommitmentGroup_Smart is //mint shares equal to _amount and give them to the shares recipient !!! poolSharesToken.mint(_sharesRecipient, sharesAmount_); + + + // prepare current balance + uint256 sharesBalance = poolSharesToken.balanceOf(address(_sharesRecipient)); + _prepareSharesForWithdraw(_sharesRecipient,sharesBalance); - //reset prepared amount - poolSharesPreparedToWithdrawForLender[msg.sender] = 0; emit LenderAddedPrincipal( @@ -445,7 +483,7 @@ contract LenderCommitmentGroup_Smart is uint256 _collateralTokenId, uint32 _loanDuration, uint16 _interestRate - ) external onlySmartCommitmentForwarder whenNotPaused { + ) external onlySmartCommitmentForwarder whenForwarderNotPaused { require( _collateralTokenAddress == address(collateralToken), @@ -505,12 +543,30 @@ contract LenderCommitmentGroup_Smart is function prepareSharesForWithdraw( uint256 _amountPoolSharesTokens - ) external returns (bool) { - require( poolSharesToken.balanceOf(msg.sender) >= _amountPoolSharesTokens ); + ) external whenForwarderNotPaused returns (bool) { + return _prepareSharesForWithdraw(msg.sender,_amountPoolSharesTokens); + } + + function _prepareSharesForWithdraw( + address _recipient, + uint256 _amountPoolSharesTokens + ) internal returns (bool) { + + require( poolSharesToken.balanceOf(_recipient) >= _amountPoolSharesTokens ); + + poolSharesPreparedToWithdrawForLender[_recipient] = _amountPoolSharesTokens; + poolSharesPreparedTimestamp[_recipient] = block.timestamp; + + + + emit PoolSharesPrepared( + + _recipient, + _amountPoolSharesTokens, + block.timestamp + + ); - poolSharesPreparedToWithdrawForLender[msg.sender] = _amountPoolSharesTokens; - poolSharesPreparedTimestamp[msg.sender] = block.timestamp; - return true; } @@ -523,14 +579,14 @@ contract LenderCommitmentGroup_Smart is uint256 _amountPoolSharesTokens, address _recipient, uint256 _minAmountOut - ) external returns (uint256) { + ) external whenForwarderNotPaused returns (uint256) { require(poolSharesPreparedToWithdrawForLender[msg.sender] >= _amountPoolSharesTokens,"Shares not prepared for withdraw"); - require(poolSharesPreparedTimestamp[msg.sender] <= block.timestamp - WITHDRAW_DELAY_TIME_SECONDS,"Shares not prepared for withdraw"); + require(poolSharesPreparedTimestamp[msg.sender] <= block.timestamp - withdrawlDelayTimeSeconds,"Shares not prepared for withdraw"); poolSharesPreparedToWithdrawForLender[msg.sender] = 0; - poolSharesPreparedTimestamp[msg.sender] = 0; + poolSharesPreparedTimestamp[msg.sender] = block.timestamp; //this should compute BEFORE shares burn @@ -566,7 +622,7 @@ contract LenderCommitmentGroup_Smart is function liquidateDefaultedLoanWithIncentive( uint256 _bidId, int256 _tokenAmountDifference - ) public bidIsActiveForGroup(_bidId) { + ) public whenForwarderNotPaused bidIsActiveForGroup(_bidId) { //use original principal amount as amountDue @@ -863,7 +919,7 @@ contract LenderCommitmentGroup_Smart is address repayer, uint256 principalAmount, uint256 interestAmount - ) external onlyTellerV2 { + ) external onlyTellerV2 whenForwarderNotPaused { //can use principal amt to increment amt paid back!! nice for math . totalPrincipalTokensRepaid += principalAmount; totalInterestCollected += interestAmount; @@ -883,7 +939,7 @@ contract LenderCommitmentGroup_Smart is If principaltokens get stuck in the escrow vault for any reason, anyone may call this function to move them from that vault in to this contract */ - function withdrawFromEscrowVault ( uint256 _amount ) public { + function withdrawFromEscrowVault ( uint256 _amount ) public whenForwarderNotPaused { address _escrowVault = ITellerV2(TELLER_V2).getEscrowVault(); diff --git a/packages/contracts/contracts/TellerV2.sol b/packages/contracts/contracts/TellerV2.sol index 31c03fbe..d219a239 100644 --- a/packages/contracts/contracts/TellerV2.sol +++ b/packages/contracts/contracts/TellerV2.sol @@ -164,6 +164,24 @@ contract TellerV2 is _; } + + modifier onlyPauser() { + + require( pauserRoleBearer[_msgSender()] || owner() == _msgSender(), "Requires role: Pauser"); + + + _; + } + + + modifier whenLiquidationsNotPaused() { + require(!liquidationsPaused, "Liquidations are paused"); + + _; + } + + + /** Constant Variables **/ uint8 public constant CURRENT_CODE_VERSION = 10; @@ -247,29 +265,7 @@ contract TellerV2 is escrowVault = IEscrowVault(_escrowVault); } - /** - * @notice Gets the metadataURI for a bidId. - * @param _bidId The id of the bid to return the metadataURI for - * @return metadataURI_ The metadataURI for the bid, as a string. - */ - function getMetadataURI(uint256 _bidId) - public - view - returns (string memory metadataURI_) - { - // Check uri mapping first - metadataURI_ = uris[_bidId]; - // If the URI is not present in the mapping - if ( - keccak256(abi.encodePacked(metadataURI_)) == - 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 // hardcoded constant of keccak256('') - ) { - // Return deprecated bytes32 uri as a string - uint256 convertedURI = uint256(bids[_bidId]._metadataURI); - metadataURI_ = StringsUpgradeable.toHexString(convertedURI, 32); - } - } - + /** * @notice Function for a borrower to create a bid for a loan without Collateral. * @param _lendingToken The lending token asset requested to be borrowed. @@ -708,21 +704,53 @@ contract TellerV2 is } /** - * @notice Lets the DAO/owner of the protocol implement an emergency stop mechanism. + * @notice Lets a pauser of the protocol implement an emergency stop mechanism. */ - function pauseProtocol() public virtual onlyOwner whenNotPaused { + function pauseProtocol() public virtual onlyPauser whenNotPaused { _pause(); } /** - * @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop. + * @notice Lets a pauser of the protocol undo a previously implemented emergency stop. */ - function unpauseProtocol() public virtual onlyOwner whenPaused { + function unpauseProtocol() public virtual onlyPauser whenPaused { _unpause(); } + + /** + * @notice Lets a pauser of the protocol implement an emergency stop mechanism. + */ + function pauseLiquidations() public virtual onlyPauser { + liquidationsPaused = true; + } + + /** + * @notice Lets a pauser of the protocol undo a previously implemented emergency stop. + */ + function unpauseLiquidations() public virtual onlyPauser { + liquidationsPaused = false; + } + + + + function addPauser(address _pauser) public virtual onlyOwner { + pauserRoleBearer[_pauser] = true; + } + + + function removePauser(address _pauser) public virtual onlyOwner { + pauserRoleBearer[_pauser] = false; + } + + + function isPauser(address _account) public view returns(bool){ + return pauserRoleBearer[_account] ; + } + + function lenderCloseLoan(uint256 _bidId) - external + external whenNotPaused whenLiquidationsNotPaused acceptedLoan(_bidId, "lenderClaimCollateral") { Bid storage bid = bids[_bidId]; @@ -738,7 +766,7 @@ contract TellerV2 is function lenderCloseLoanWithRecipient( uint256 _bidId, address _collateralRecipient - ) external { + ) external whenNotPaused whenLiquidationsNotPaused { _lenderCloseLoanWithRecipient(_bidId, _collateralRecipient); } @@ -765,7 +793,7 @@ contract TellerV2 is * @param _bidId The id of the loan to make the payment towards. */ function liquidateLoanFull(uint256 _bidId) - external + external whenNotPaused whenLiquidationsNotPaused acceptedLoan(_bidId, "liquidateLoan") { Bid storage bid = bids[_bidId]; @@ -777,7 +805,7 @@ contract TellerV2 is } function liquidateLoanFullWithRecipient(uint256 _bidId, address _recipient) - external + external whenNotPaused whenLiquidationsNotPaused acceptedLoan(_bidId, "liquidateLoan") { _liquidateLoanFull(_bidId, _recipient); @@ -861,7 +889,8 @@ contract TellerV2 is _borrowerBidsActive[bid.borrower].remove(_bidId); // If loan is is being liquidated and backed by collateral, withdraw and send to borrower - if (_shouldWithdrawCollateral) { + if (_shouldWithdrawCollateral) { + // _getCollateralManagerForBid(_bidId).withdraw(_bidId); collateralManager.withdraw(_bidId); } diff --git a/packages/contracts/contracts/TellerV2Storage.sol b/packages/contracts/contracts/TellerV2Storage.sol index c79e3933..bbbe8852 100644 --- a/packages/contracts/contracts/TellerV2Storage.sol +++ b/packages/contracts/contracts/TellerV2Storage.sol @@ -162,4 +162,9 @@ abstract contract TellerV2Storage_G6 is TellerV2Storage_G5 { mapping(uint256 => address) public repaymentListenerForBid; } -abstract contract TellerV2Storage is TellerV2Storage_G6 {} +abstract contract TellerV2Storage_G7 is TellerV2Storage_G6 { + mapping(address => bool) public pauserRoleBearer; + bool public liquidationsPaused; +} + +abstract contract TellerV2Storage is TellerV2Storage_G7 {} diff --git a/packages/contracts/contracts/interfaces/ITellerV2.sol b/packages/contracts/contracts/interfaces/ITellerV2.sol index 9837d6da..a930167a 100644 --- a/packages/contracts/contracts/interfaces/ITellerV2.sol +++ b/packages/contracts/contracts/interfaces/ITellerV2.sol @@ -171,4 +171,7 @@ interface ITellerV2 { function getEscrowVault() external view returns(address); + + + function isPauser(address _account) external view returns(bool); } diff --git a/packages/contracts/contracts/mock/TellerV2SolMock.sol b/packages/contracts/contracts/mock/TellerV2SolMock.sol index bea8c4ef..341a5b71 100644 --- a/packages/contracts/contracts/mock/TellerV2SolMock.sol +++ b/packages/contracts/contracts/mock/TellerV2SolMock.sol @@ -19,6 +19,7 @@ contract TellerV2SolMock is ITellerV2, IProtocolFee, TellerV2Storage , ILoanRepa uint256 public amountOwedMockPrincipal; uint256 public amountOwedMockInterest; address public approvedForwarder; + bool public isPausedMock; PaymentCycleType globalBidPaymentCycleType = PaymentCycleType.Seconds; @@ -45,6 +46,15 @@ contract TellerV2SolMock is ITellerV2, IProtocolFee, TellerV2Storage , ILoanRepa } + function paused() external view returns(bool){ + return isPausedMock; + } + + + function isPauser(address _account) public view returns(bool){ + return false; //for now + } + function approveMarketForwarder(uint256 _marketId, address _forwarder) external { diff --git a/packages/contracts/tests/GetMetaDataURI_Test.sol b/packages/contracts/tests/GetMetaDataURI_Test.sol index da24125d..4b449410 100644 --- a/packages/contracts/tests/GetMetaDataURI_Test.sol +++ b/packages/contracts/tests/GetMetaDataURI_Test.sol @@ -15,6 +15,7 @@ contract GetMetaDataURI_Test is Testable, TellerV2 { uris[59] = "ipfs://QmMyDataHash"; } + /* function test_getMetaDataURI() public { string memory oldURI = getMetadataURI(0); assertEq( @@ -28,5 +29,5 @@ contract GetMetaDataURI_Test is Testable, TellerV2 { "ipfs://QmMyDataHash", "Expected URI does not match new value in uri mapping" ); - } + } */ } diff --git a/packages/contracts/tests/LenderCommitmentForwarder/extensions/SmartCommitments/LenderCommitmentGroup_Smart_Test.sol b/packages/contracts/tests/LenderCommitmentForwarder/extensions/SmartCommitments/LenderCommitmentGroup_Smart_Test.sol index e61c6e93..4af1e40e 100644 --- a/packages/contracts/tests/LenderCommitmentForwarder/extensions/SmartCommitments/LenderCommitmentGroup_Smart_Test.sol +++ b/packages/contracts/tests/LenderCommitmentForwarder/extensions/SmartCommitments/LenderCommitmentGroup_Smart_Test.sol @@ -59,6 +59,7 @@ contract LenderCommitmentGroup_Smart_Test is Testable { _tellerV2 = new TellerV2SolMock(); _smartCommitmentForwarder = new SmartCommitmentForwarder(); + _uniswapV3Pool = new UniswapV3PoolMock(); _uniswapV3Factory = new UniswapV3FactoryMock(); @@ -1080,4 +1081,10 @@ function test_liquidateDefaultedLoanWithIncentive_does_not_double_count_repaid() contract User {} -contract SmartCommitmentForwarder {} \ No newline at end of file +contract SmartCommitmentForwarder { + + function paused() external returns (bool){ + return false; + } + +} \ No newline at end of file diff --git a/packages/contracts/tests/TellerV2/TellerV2_getData.sol b/packages/contracts/tests/TellerV2/TellerV2_getData.sol index 84f1f621..efd7e9a6 100644 --- a/packages/contracts/tests/TellerV2/TellerV2_getData.sol +++ b/packages/contracts/tests/TellerV2/TellerV2_getData.sol @@ -90,6 +90,7 @@ contract TellerV2_initialize is Testable { ); } +/* function test_getMetadataURI_without_mapping() public { uint256 bidId = 1; setMockBid(1); @@ -112,7 +113,7 @@ contract TellerV2_initialize is Testable { string memory uri = tellerV2.getMetadataURI(bidId); assertEq(uri, "0x1234"); - } + }*/ function test_isLoanLiquidateable_with_valid_bid() public { uint256 bidId = 1; diff --git a/packages/contracts/tests/TellerV2/TellerV2_pause.sol b/packages/contracts/tests/TellerV2/TellerV2_pause.sol index fcbb9c6a..88f06a3e 100644 --- a/packages/contracts/tests/TellerV2/TellerV2_pause.sol +++ b/packages/contracts/tests/TellerV2/TellerV2_pause.sol @@ -26,7 +26,7 @@ contract TellerV2_pause_test is Testable { } function test_pauseProtocol_invalid_if_not_owner() public { - vm.expectRevert("Ownable: caller is not the owner"); + vm.expectRevert("Requires role: Pauser"); tellerV2.pauseProtocol(); }