Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ethereumdegen committed Oct 22, 2024
2 parents c457fbd + 93ec658 commit e13ad8e
Show file tree
Hide file tree
Showing 39 changed files with 6,493 additions and 973 deletions.
3,749 changes: 3,742 additions & 7 deletions packages/contracts/.openzeppelin/polygon.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions packages/contracts/contracts/CollateralManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradea
import "./interfaces/ICollateralManager.sol";
import { Collateral, CollateralType, ICollateralEscrowV1 } from "./interfaces/escrow/ICollateralEscrowV1.sol";
import "./interfaces/ITellerV2.sol";

import "./interfaces/IProtocolPausingManager.sol";
import "./interfaces/IHasProtocolPausingManager.sol";
contract CollateralManager is OwnableUpgradeable, ICollateralManager {
/* Storage */
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
Expand Down Expand Up @@ -78,8 +79,10 @@ contract CollateralManager is OwnableUpgradeable, ICollateralManager {
_;
}

modifier whenProtocolNotPaused() {
require( PausableUpgradeable(address(tellerV2)).paused() == false , "Protocol is paused");
modifier whenProtocolNotPaused() {
address pausingManager = IHasProtocolPausingManager( address(tellerV2) ).getProtocolPausingManager();

require( IProtocolPausingManager(address(pausingManager)).protocolPaused() == false , "Protocol is paused");
_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,31 @@ import "../interfaces/ILenderCommitmentForwarder.sol";
import "../interfaces/ISmartCommitmentForwarder.sol";
import "./LenderCommitmentForwarder_G1.sol";

import "../interfaces/IPausableTimestamp.sol";

import "../interfaces/IHasProtocolPausingManager.sol";

import "../interfaces/IProtocolPausingManager.sol";

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";


import { CommitmentCollateralType, ISmartCommitment } from "../interfaces/ISmartCommitment.sol";


contract SmartCommitmentForwarder is
ExtensionsContextUpgradeable, //this should always be first for upgradeability
TellerV2MarketForwarder_G3,
PausableUpgradeable, //this does add some storage but AFTER all other storage
ISmartCommitmentForwarder
ISmartCommitmentForwarder,
IPausableTimestamp
{

using MathUpgradeable for uint256;

event ExercisedSmartCommitment(
address indexed smartCommitmentAddress,
address borrower,
Expand All @@ -31,7 +44,9 @@ contract SmartCommitmentForwarder is


modifier onlyProtocolPauser() {
require( ITellerV2( _tellerV2 ).isPauser(_msgSender()) , "Sender not authorized");

address pausingManager = IHasProtocolPausingManager( _tellerV2 ).getProtocolPausingManager();
require( IProtocolPausingManager( pausingManager ).isPauser(_msgSender()) , "Sender not authorized");
_;
}

Expand All @@ -42,6 +57,7 @@ contract SmartCommitmentForwarder is
}

uint256 public liquidationProtocolFeePercent;
uint256 internal lastUnpausedAt;


constructor(address _protocolAddress, address _marketRegistry)
Expand Down Expand Up @@ -209,10 +225,33 @@ contract SmartCommitmentForwarder is
* @notice Lets the DAO/owner of the protocol undo a previously implemented emergency stop.
*/
function unpause() public virtual onlyProtocolPauser whenPaused {
setLastUnpausedAt();
_unpause();
}


function getLastUnpausedAt()
public view
returns (uint256) {


address pausingManager = IHasProtocolPausingManager( _tellerV2 ).getProtocolPausingManager();

return MathUpgradeable.max(
lastUnpausedAt,
IPausableTimestamp(pausingManager).getLastUnpausedAt()
)
;


}


function setLastUnpausedAt() internal {
lastUnpausedAt = block.timestamp;
}


// -----

//Overrides
Expand Down
Loading

0 comments on commit e13ad8e

Please sign in to comment.