Skip to content

Remove calls to require() and do not throw exceptions, only emit events #19

@EGreg

Description

@EGreg

Rewards hook may revert for any number of reasons. In our standard Rewards contract, it would revert if the balance is too low to transfer the rewards token.

As a result, no one will be able to unstake the token!

To do:

Please redeploy RewardsContract on all chains, with a new prefix.

Please remove all calls to require() -- during claim() and onUnstake() and transfer.

Instead, emit an event indicating the reason for the failure. Such as:

emit NotEnoughBalance();
emit TransferFailed();

To NOT do: (this will require redeploying too many contracts)

Please change this line in PoolStakesLib

IRewards(hooks[i]).onUnstake(pool, account, instanceInfo.duration, affectedAmount, rewardsRateFraction);        

to a low-level call which fires an event on error, but doesn't revert.

(bool success, bytes memory data) = address.call(bytes memory data);
if (!success) {
    emit RewardsFailed();
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions