Function: claim(address owner, address receiver)
This function is used to claim rewards from the smart vault. It is expected to be called from the smart vault manager.
Inputs
ownerControl: Fully controllable by the caller (
smartVaultManager).Constraints: None.
Impact: Address of the share owner.
receiverControl: Fully controllable by the caller (
smartVaultManager).Constraints: None.
Impact: Address of the receiver.
Branches and code coverage
Intended branches
Check if the current timestamp is within the claim time range.
Update the reward for the owner.
Update the pending rewards and transfer the rewards to the receiver, for each reward token, if the pending rewards is not zero.
Call the
transferAllocatedTokensfunction of the reward vault to transfer the rewards to the receiver.Emit the
Claimedevent.Invoke the
_manageDebtAndStakefunction.Skip when staking is disabled.
Calculate the underlying token value using the manager's
fetchPricefunction.Calculate the target staking amount using the staking factor.
If the target is greater than the minted, mint the debt token and adjust the staking amount.
If the target is less than the minted, burn the debt token and adjust the staking amount.
Negative behavior
Revert if the caller is not the manager.
Revert if the contract is paused.
Revert if the amount is zero.
Revert if the pending rewards are not zero.
Revert if minting/burning the debt token fails.
Function call analysis
this._claim(owner, receiver) -> this.rewardVault.transferAllocatedTokens(allocation)What is controllable?
allocationis set by the owner and receiver.If the return value is controllable, how is it used and how can it go wrong? The return value is not used.
What happens if it reverts, reenters or does other unusual control flow? A revert indicates no allocation for the receiver in the reward vault or when the reward vault does not have a sufficient balance.
Other external call flows are the same as the
depositERC20function's_manageDebtAndStakeflow ofSmartVault.