Skip to main content

releaseV1TokensOf

Contract: JBV1TokenPaymentTerminal​‌

Interface: IJBPaymentTerminal

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

  1. 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:

  2. 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:

  3. 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:

  4. 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:

  5. 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:

  6. 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:

  7. 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:

  8. 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:

  1. Emit a ReleaseV1Tokens event with the relevant parameters.

    emit ReleaseV1Tokens(_v1ProjectId, _beneficiary, _unclaimedBalance, _erc20Balance, msg.sender);

    Event references: