[BOOST-5224] feat(evm): add topup functionality to core#367
Conversation
|
|
1 similar comment
|
|
93adba2 to
8d0633b
Compare
|
8d0633b to
b5ee7b5
Compare
|
|
|
|
@Quazia just a heads-up I've closed #363 and redirected this pr to main. It still contains changes for BOOST-5200 but no PR is open for that feature branch |
|
ad8d258 to
3e33311
Compare
|
|
59b095d to
a6a1ee4
Compare
|
this was a configuration issue in hardhat where the compiler config was located in the wrong part of the config
Now that we're supporting topups, this bug should be fixed, where we increment the maxFee by the disbursemd fee calculation instead of setting it for each individual deposit. This correctly accumulates the max fee payout for managers.
1c9d8a2 to
bf1a8da
Compare
|
|
topocount
left a comment
There was a problem hiding this comment.
Looks good to me, a few small questions
| /// @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) { |
There was a problem hiding this comment.
bit of a bikeshedding question: should this interface be added to AIncentive?
There was a problem hiding this comment.
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.
| if (amount == 0) { | ||
| revert BoostError.InvalidInitialization(); | ||
| } |
There was a problem hiding this comment.
why have this check? spam avoidance?
There was a problem hiding this comment.
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
| ) { | ||
| const feeBps = await this.protocolFee(params); | ||
| const topupAmount = | ||
| (totalAmount * FEE_DENOMINATOR) / (FEE_DENOMINATOR + feeBps); |
There was a problem hiding this comment.
nice!
it might be worth reconstituting this and validating the diff isn't greater than the available budget
There was a problem hiding this comment.
Yeah we could add some sort of additional check here - we'd probably want it for all four though. WDYT is it worth it?
There was a problem hiding this comment.
I think its better than relying on a relatively terse revert
| * @param {?WriteParams} [params] Additional transaction overrides | ||
| * @returns {Promise<{ hash: Hex; result: void }>} | ||
| */ | ||
| public async topupIncentiveFromBudgetPostFee( |
There was a problem hiding this comment.
soft nit:
| public async topupIncentiveFromBudgetPostFee( | |
| public async topupIncentiveFromBudgetIncludingFee( |
| * @param {?WriteParams} [params] Additional transaction overrides | ||
| * @returns {Promise<{ hash: Hex; result: void }>} The transaction hash and simulation result | ||
| */ | ||
| public async topupIncentiveFromBudgetPreFee( |
There was a problem hiding this comment.
| public async topupIncentiveFromBudgetPreFee( | |
| public async topupIncentiveFromBudgetWithoutFee( |
There was a problem hiding this comment.
This sort of implies that there won't be a fee which there very much will be.
There was a problem hiding this comment.
Yeah pre-fee probably works fine
Description
This PR introduces a new top-up flow in
BoostCorethat routes additional tokens into existing incentives, addingtopupIncentiveFromBudget(for budget-based tokens) andtopupIncentiveFromSender(for user-supplied tokens). Both flows gather all tokens inBoostCore, compute and record protocol fees, and temporarily approve the incentive contract to pull the remainder via itstopupfunction. We remove approval after the transfers. Two things to watch out for in review are that funds can't be pulled out of core if there was a malicious incentive and that all permissions on the budget are respected. Basically we want to avoid loss of funds.Assumptions:
BoostCorefor ERC20 tokens or setApprovalForAll for ERC1155 tokens .bytes data_argument decodes based on the incentivesInitPayloadstruct an example of which is shown below.BoostCore, and may be transferred or settled at a later time.New Function Signatures
Example of Relevant Struct for
_datapayloadThis param (
_data) should be the InitPayload for the incentive being topped up.