Skip to content

Commit

Permalink
Add reentrancy guard
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun-io committed Jul 22, 2023
1 parent dda73fb commit d41431b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/perennial/contracts/Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
pragma solidity 0.8.19;

import "@equilibria/root/attribute/Instance.sol";
import "@equilibria/root/attribute/ReentrancyGuard.sol";
import "./interfaces/IMarket.sol";
import "./interfaces/IMarketFactory.sol";
import "hardhat/console.sol";

/// @title Market
/// @notice Manages logic and state for a single market.
/// @dev Cloned by the Factory contract to launch new markets.
contract Market is IMarket, Instance {
contract Market is IMarket, Instance, ReentrancyGuard {
bool private constant GAS_PROFILE = false;
bool private constant LOG_REVERTS = false;

Expand Down Expand Up @@ -62,6 +63,7 @@ contract Market is IMarket, Instance {
/// @param definition_ The market definition
function initialize(IMarket.MarketDefinition calldata definition_) external initializer(1) {
__Instance__initialize();
__UReentrancyGuard__initialize();

token = definition_.token;
oracle = definition_.oracle;
Expand All @@ -82,7 +84,7 @@ contract Market is IMarket, Instance {
UFixed6 newShort,
Fixed6 collateral,
bool protect
) external whenNotPaused {
) external nonReentrant whenNotPaused {
Context memory context = _loadContext(account);
_settle(context, account);
_update(context, account, newMaker, newLong, newShort, collateral, protect);
Expand Down

0 comments on commit d41431b

Please sign in to comment.