Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reentrancy guard #38

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading