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

SIP-2036 fix reward distributor to bubble failures #2160

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Changes from 3 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
10 changes: 7 additions & 3 deletions contracts/RewardsDistribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed in a chat.
This will require any future recipient of rewards distribution to be a contract and implement the notifyRewardAmount(uint256) function in order to not revert the whole distribution.
Is not an issue for this solution, but a requirement for future recipients.

uint len = result.length;
assembly {
revert(add(result, 0x20), len)
}
}
}
}
Expand Down
Loading