Withdraw from the SFS
In this section you will learn different ways of withdrawing from the SFS.
/// @notice Withdraws earned fees to `_recipient` address. Only callable by NFT owner.
/// @param _tokenId token Id
/// @param _recipient recipient of fees
/// @param _amount amount of fees to withdraw
/// @return amount of fees withdrawn
function withdraw(uint256 _tokenId, address payable _recipient, uint256 _amount)
public
onlyNftOwner(_tokenId)
returns (uint256)
{
uint256 earnedFees = balances[_tokenId];
if (earnedFees == 0 || _amount == 0) revert NothingToWithdraw();
if (_amount > earnedFees) _amount = earnedFees;
balances[_tokenId] = earnedFees - _amount;
emit Withdraw(_tokenId, _recipient, _amount);
Address.sendValue(_recipient, _amount);
return _amount;
}Last updated
Was this helpful?