_redeemTokensOf
Contract: JBPayoutRedemptionPaymentTerminal
- Step by step
- Code
- Errors
- Events
- Bug bounty
Holders can redeem their tokens to claim the project's overflowed tokens, or to trigger rules determined by the project's current funding cycle's data source.
Only a token holder or a designated operator can redeem its tokens.
Definition
function _redeemTokensOf(
address _holder,
uint256 _projectId,
uint256 _tokenCount,
uint256 _minReturnedTokens,
address payable _beneficiary,
string memory _memo,
bytes memory _metadata
) private returns (uint256 reclaimAmount) { ... }
- Arguments:
_holder
is the account to redeem tokens for._projectId
is the ID of the project to which the tokens being redeemed belong._tokenCount
is the number of project tokens to redeem, as a fixed point number with 18 decimals._minReturnedTokens
is the minimum amount of terminal tokens expected in return, as a fixed point number with the same amount of decimals as this terminal._beneficiary
is the address to send the terminal tokens to._memo
is a memo to pass along to the emitted event._metadata
are bytes to send along to the data source, delegate, and emitted event, if provided.
- The function is private to this contract.
- The function returns the amount of terminal tokens that the tokens were redeemed for, as a fixed point number with the same amount of decimals as this terminal.
Body
-
Make sure the provided beneficiary of the claimed funds isn't the zero address.
// Can't send reclaimed funds to the zero address.
if (_beneficiary == address(0)) revert REDEEM_TO_ZERO_ADDRESS(); -
Define a reference to the project's funding cycle during which the redemption is being made.
// Define variables that will be needed outside the scoped section below.
// Keep a reference to the funding cycle during which the redemption is being made.
JBFundingCycle memory _fundingCycle;