releaseV1TokensOf
Contract: JBV1TokenPaymentTerminal
Interface: IJBPaymentTerminal
- Step by step
- Code
- Errors
- Events
- Bug bounty
Allows a project owner to gain custody of all the v1 tokens that have been paid, after they have finalized the ability for v1 token holders to convert to v2 tokens via this contract.
Definition
function releaseV1TokensOf(uint256 _v1ProjectId, address _beneficiary) external override { ... }
- Arguments:
_v1ProjectId
is the ID of the v1 project whose tokens are being released._beneficiary
is the address that the tokens are being sent to.
- The function can be accessed externally by anyone.
- The resulting function overrides a function definition from the
IJBV1TokenPaymentTerminal
interface. - The function doesn't return anything.
Body
-
Make sure the message sender is the owner of the v1 project.
// Make sure only the v1 project owner can retrieve the tokens.
if (msg.sender != ticketBooth.projects().ownerOf(_v1ProjectId)) revert NOT_ALLOWED();Internal references:
External references:
-
Make sure the v1 project has not yet been finalized.
// Make sure v1 token conversion has not yet finalized.
if (finalized[_v1ProjectId]) revert MIGRATION_TERMINATED();Internal references:
-
Get a reference to the v1 ERC20 token being used by the project.
// Get a reference to the v1 project's ERC20 tokens.
ITickets _v1Token = ticketBooth.ticketsOf(_v1ProjectId);Internal references:
External references:
-
Get a reference to the v1 unclaimed token balance currently being held by this contract.
// Get a reference to this terminal's unclaimed balance.
uint256 _unclaimedBalance = ticketBooth.stakedBalanceOf(address(this), _v1ProjectId);Internal references:
External references:
-
Get a reference to the v1 ERC20 token balance currently being held by this contract.
// Get a reference to this terminal's ERC20 balance.
uint256 _erc20Balance = _v1Token == ITickets(address(0))
? 0
: _v1Token.balanceOf(address(this));External references:
-
Mark this v1 project as finalized so that this terminal no longer accepts this v1 token in exchange for any v2 token.
// Store the finalized state.
finalized[_v1ProjectId] = true;Internal references:
-
Transfer ERC20 token balance held by this contract to the specified beneficiary.
// Transfer ERC20 v1 tokens to the beneficiary.
if (_erc20Balance != 0) _v1Token.transfer(_beneficiary, _erc20Balance);External references:
-
Transfer the unclaimed token balance held by this contract to the specified beneficiary.
// Transfer unclaimed v1 tokens to the beneficiary.
if (_unclaimedBalance != 0)
ticketBooth.transfer(address(this), _v1ProjectId, _unclaimedBalance, _beneficiary);Internal references:
External references:
-
Emit a
ReleaseV1Tokens
event with the relevant parameters.emit ReleaseV1Tokens(_v1ProjectId, _beneficiary, _unclaimedBalance, _erc20Balance, msg.sender);
Event references:
/**
@notice
Allows a project owner to gain custody of all the v1 tokens that have been paid, after they have finalized the ability for v1 token holders to convert to v2 tokens via this contract.
@param _v1ProjectId The ID of the v1 project whose tokens are being released.
@param _beneficiary The address that the tokens are being sent to.
*/
function releaseV1TokensOf(uint256 _v1ProjectId, address _beneficiary) external override {
// Make sure only the v1 project owner can retrieve the tokens.
if (msg.sender != ticketBooth.projects().ownerOf(_v1ProjectId)) revert NOT_ALLOWED();
// Make sure v1 token conversion has not yet finalized.
if (finalized[_v1ProjectId]) revert MIGRATION_TERMINATED();
// Get a reference to the v1 project's ERC20 tokens.
ITickets _v1Token = ticketBooth.ticketsOf(_v1ProjectId);
// Get a reference to this terminal's unclaimed balance.
uint256 _unclaimedBalance = ticketBooth.stakedBalanceOf(address(this), _v1ProjectId);
// Get a reference to this terminal's ERC20 balance.
uint256 _erc20Balance = _v1Token == ITickets(address(0))
? 0
: _v1Token.balanceOf(address(this));
// Store the finalized state.
finalized[_v1ProjectId] = true;
// Transfer ERC20 v1 tokens to the beneficiary.
if (_erc20Balance != 0) _v1Token.transfer(_beneficiary, _erc20Balance);
// Transfer unclaimed v1 tokens to the beneficiary.
if (_unclaimedBalance != 0)
ticketBooth.transfer(address(this), _v1ProjectId, _unclaimedBalance, _beneficiary);
emit ReleaseV1Tokens(_v1ProjectId, _beneficiary, _unclaimedBalance, _erc20Balance, msg.sender);
}
String | Description |
---|---|
NOT_ALLOWED | Thrown if an address other than the v1 project's owner is attempting to release the v1 token. |
MIGRATION_TERMINATED | Thrown if the specified v1 project has already been finalized. |
Name | Data |
---|---|
ReleaseV1Tokens |
|
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |