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 for public functions #3

Merged
merged 2 commits into from
Dec 17, 2024
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
7 changes: 4 additions & 3 deletions src/token/SonicBeetsMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
pragma solidity ^0.8.0;

import "openzeppelin-contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "openzeppelin-contracts/utils/ReentrancyGuard.sol";

contract SonicBeetsMigrator {
contract SonicBeetsMigrator is ReentrancyGuard {
IERC20 public immutable OPERABEETS;
IERC20 public immutable SONICBEETS;
address public immutable TREASURY;
Expand All @@ -26,15 +27,15 @@ contract SonicBeetsMigrator {
admin = msg.sender;
}

function exchangeOperaToSonic(uint256 amount) external {
function exchangeOperaToSonic(uint256 amount) external nonReentrant {
require(operaToSonicEnabled, MigrationDisabled());
require(OPERABEETS.balanceOf(msg.sender) >= amount, UserBalanceInsufficient());
require(SONICBEETS.balanceOf(address(this)) >= amount, MigratorBalanceInsufficient());
OPERABEETS.transferFrom(msg.sender, address(this), amount);
SONICBEETS.transfer(msg.sender, amount);
}

function exchangeSonicToOpera(uint256 amount) external {
function exchangeSonicToOpera(uint256 amount) external nonReentrant {
require(sonicToOperaEnabled, MigrationDisabled());
require(SONICBEETS.balanceOf(msg.sender) >= amount, UserBalanceInsufficient());
require(OPERABEETS.balanceOf(address(this)) >= amount, MigratorBalanceInsufficient());
Expand Down
Loading