Withdraw Reward
To withdraw the earned reward for a position, the withdrawReward
function is used. It requires, as input:
positionId
-> id corresponding to the position to be transferred
withdrawReward
can be called at any time to withdraw the amount of reward tokens accumulated thus far by a position. It internally calls the _withdrawReward
method, the helper function used to calculate and send the reward to the position owner.
If there is a claimable reward amount, the function transfers the amount to the position owner's address:
The withdrawn reward amount is added to the rewardPaid
of the position; rewardPaid
represents the total amount of reward already claimed for the position:
Aside from being called directly in this function, withdrawReward
will also be called internally when the withdrawLiquidity
function is used.
When a farmer claims his reward, as explained in the NFT Management section, he also withdraws all of the trading fees earned by his particular NFT. _withdrawReward
carries this out by calling the _retrieveGen2LiquidityAndFees
method.
Then, the feeAmount0
and feeAmount1
amounts are withdrawn from the NFT position using the _collect
method, which internally calls the collect method of INonfungiblePositionManager
:
At this stage, if a fee for the Covenants DFO is to be taken, it is calculated, subtracted from the fee amounts and sent to the Covenants DFO wallet. The rest is sent to the address of the position owner:
Otherwise, if the fees are 0, the whole share of the position fees is sent directly to the user.
(This differs from the Covenant Farming Generation 1 setup system, in which the fee for the Covenants DFO is taken as a percentage of the user's LP tokens at the moment of liquidity withdrawal).
Last updated