-
Notifications
You must be signed in to change notification settings - Fork 4
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
[BOOST-5224] feat(evm): add topup functionality to core #367
Changes from all commits
08985f6
38b78f9
b96a0aa
ea04f4c
572ddb0
3129342
aafd0be
50695db
3b8b8e0
eba78d8
8a5ddbf
bc9b693
903b370
9e33fad
761912b
7d6fbac
64174f7
2fca309
0777286
39c5743
7103cea
626ee6e
6073558
bf1a8da
fcd9d88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,9 @@ import {AERC20PeggedIncentive} from "contracts/incentives/AERC20PeggedIncentive. | |
import {AIncentive} from "contracts/incentives/AIncentive.sol"; | ||
import {ABudget} from "contracts/budgets/ABudget.sol"; | ||
import {RBAC} from "contracts/shared/RBAC.sol"; | ||
import {IToppable} from "contracts/shared/IToppable.sol"; | ||
|
||
contract ERC20PeggedIncentive is RBAC, AERC20PeggedIncentive { | ||
contract ERC20PeggedIncentive is RBAC, AERC20PeggedIncentive, IToppable { | ||
using SafeTransferLib for address; | ||
|
||
event ERC20PeggedIncentiveInitialized( | ||
|
@@ -126,6 +127,23 @@ contract ERC20PeggedIncentive is RBAC, AERC20PeggedIncentive { | |
return (amount, asset); | ||
} | ||
|
||
/// @notice Top up the incentive with more ERC20 tokens | ||
/// @dev Uses `msg.sender` as the token source, and uses `asset` to identify which token. | ||
/// Caller must approve this contract to spend at least `amount` prior to calling. | ||
/// @param amount The number of tokens to top up | ||
function topup(uint256 amount) external virtual override onlyOwnerOrRoles(MANAGER_ROLE) { | ||
if (amount == 0) { | ||
revert BoostError.InvalidInitialization(); | ||
} | ||
Comment on lines
+135
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why have this check? spam avoidance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably remove it - the check exists in the SDK and I'm generally in favor of less in-contract checks for 'enough rope' type problems |
||
// Transfer tokens from the caller into this contract | ||
asset.safeTransferFrom(msg.sender, address(this), amount); | ||
|
||
// Increase the total incentive limit | ||
limit += amount; | ||
|
||
emit ToppedUp(msg.sender, amount); | ||
} | ||
|
||
/// @notice Check if an incentive is claimable | ||
/// @param claimTarget the address that could receive the claim | ||
/// @return True if the incentive is claimable based on the data payload | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.24; | ||
|
||
interface IToppable { | ||
event ToppedUp(address sender, uint256 amount); | ||
/** | ||
* @notice Tops up the contract with the specified amount. Should modify all local variables accordingly. | ||
* @param amount The amount to top up, in wei. | ||
*/ | ||
|
||
function topup(uint256 amount) external; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit of a bikeshedding question: should this interface be added to
AIncentive
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I specifically avoided that cause it'd change all the component interfaces and we're not calling into it from the helpers but I could add it. Would just require more thought around the component interface change for existing incentive modules.