diff --git a/contracts/RewardsDistribution.sol b/contracts/RewardsDistribution.sol index cf688eac5d..135c370be1 100644 --- a/contracts/RewardsDistribution.sol +++ b/contracts/RewardsDistribution.sol @@ -156,7 +156,7 @@ contract RewardsDistribution is Owned, IRewardsDistribution { // Iterate the array of distributions sending the configured amounts for (uint i = 0; i < distributions.length; i++) { - if (distributions[i].destination != address(0) || distributions[i].amount != 0) { + if (distributions[i].destination != address(0) && distributions[i].amount != 0) { remainder = remainder.sub(distributions[i].amount); // Transfer the SNX @@ -166,10 +166,14 @@ contract RewardsDistribution is Owned, IRewardsDistribution { bytes memory payload = abi.encodeWithSignature("notifyRewardAmount(uint256)", distributions[i].amount); // solhint-disable avoid-low-level-calls - (bool success, ) = distributions[i].destination.call(payload); + (bool success, bytes memory result) = distributions[i].destination.call(payload); if (!success) { - // Note: we're ignoring the return value as it will fail for contracts that do not implement RewardsDistributionRecipient.sol + // if the error was emitted by the destination contract, bubble + uint len = result.length; + assembly { + revert(add(result, 0x20), len) + } } } } diff --git a/contracts/TradingRewards.sol b/contracts/TradingRewards.sol index 2563d2abe2..dd32976553 100644 --- a/contracts/TradingRewards.sol +++ b/contracts/TradingRewards.sol @@ -4,6 +4,7 @@ pragma solidity ^0.5.16; import "./Pausable.sol"; import "./MixinResolver.sol"; import "./Owned.sol"; +import "./RewardsDistributionRecipient.sol"; // External dependencies. import "openzeppelin-solidity-2.3.0/contracts/token/ERC20/SafeERC20.sol"; @@ -17,7 +18,7 @@ import "./interfaces/ITradingRewards.sol"; import "./interfaces/IExchanger.sol"; // https://docs.synthetix.io/contracts/source/contracts/tradingrewards -contract TradingRewards is ITradingRewards, ReentrancyGuard, Owned, Pausable, MixinResolver { +contract TradingRewards is ITradingRewards, ReentrancyGuard, Owned, Pausable, MixinResolver, RewardsDistributionRecipient { using SafeMath for uint; using SafeDecimalMath for uint; using SafeERC20 for IERC20; @@ -256,6 +257,8 @@ contract TradingRewards is ITradingRewards, ReentrancyGuard, Owned, Pausable, Mi emit AssignedRewardTokensRecovered(recoverAddress, amount, periodID); } + function notifyRewardAmount(uint256 reward) external {} + function _validateRecoverAddress(address recoverAddress) internal view { if (recoverAddress == address(0) || recoverAddress == address(this)) { revert("Invalid recover address");