Skip to content

Commit

Permalink
add nonreentrant to supplyTokenTo and redeemToken function
Browse files Browse the repository at this point in the history
  • Loading branch information
kamescg authored and Aodhgan committed Jul 2, 2021
1 parent eecf6f6 commit 850fba6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contracts/SushiYieldSource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ pragma solidity 0.6.12;

import { IYieldSource } from "@pooltogether/yield-source-interface/contracts/IYieldSource.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "./ISushiBar.sol";
import "./ISushi.sol";

/// @title A pooltogether yield source for sushi token
/// @author Steffel Fenix
contract SushiYieldSource is IYieldSource {
contract SushiYieldSource is IYieldSource, ReentrancyGuard {

using SafeMath for uint256;

Expand Down Expand Up @@ -44,7 +45,7 @@ contract SushiYieldSource is IYieldSource {
/// @notice Allows assets to be supplied on other user's behalf using the `to` param.
/// @param amount The amount of `token()` to be supplied
/// @param to The user whose balance will receive the tokens
function supplyTokenTo(uint256 amount, address to) public override {
function supplyTokenTo(uint256 amount, address to) public override nonReentrant {
sushiAddr.transferFrom(msg.sender, address(this), amount);
sushiAddr.approve(address(sushiBar), amount);

Expand All @@ -63,7 +64,7 @@ contract SushiYieldSource is IYieldSource {
/// @param amount The amount of `token()` to withdraw. Denominated in `token()` as above.
/// @dev The maxiumum that can be called for token() is calculated by balanceOfToken() above.
/// @return The actual amount of tokens that were redeemed. This may be different from the amount passed due to the fractional math involved.
function redeemToken(uint256 amount) public override returns (uint256) {
function redeemToken(uint256 amount) public override nonReentrant returns (uint256) {
ISushiBar bar = sushiBar;
ISushi sushi = sushiAddr;

Expand Down

0 comments on commit 850fba6

Please sign in to comment.