Skip to main content

currentReclaimableOverflowOf

Contract: JBSingleTokenPaymentTerminalStore​‌

Interface: IJBSingleTokenPaymentTerminalStore

The current amount of overflowed tokens from a terminal that can be reclaimed by the specified number of tokens, using the total token supply and overflow in the ecosystem.

If the project has an active funding cycle reconfiguration ballot, the project's ballot redemption rate is used.

The current reclaimable overflow is returned in terms of the specified terminal's currency.

The reclaimable overflow is represented as a fixed point number with the same amount of decimals as the specified terminal.

Definition

function currentReclaimableOverflowOf(
IJBSingleTokenPaymentTerminal _terminal,
uint256 _projectId,
uint256 _tokenCount,
bool _useTotalOverflow
) external view override returns (uint256) { ... }
  • Arguments:
    • _terminal is the terminal from which the reclaimable amount would come.
    • _projectId is the ID of the project to get the reclaimable overflow amount for.
    • _tokenCount is the number of tokens to make the calculation with, as a fixed point number with 18 decimals.
    • _useTotalOverflow is a flag indicating whether the overflow used in the calculation should be summed from all of the project's terminals. If false, overflow should be limited to the amount in the specified _terminal.
  • The view function can be accessed externally by anyone.
  • The view function does not alter state on the blockchain.
  • The resulting function overrides a function definition from the JBSingleTokenPaymentTerminalStore interface.
  • The function returns the amount of overflowed tokens that can be reclaimed, as a fixed point number with the same number of decimals as the provided _terminal.

Body

  1. Get a reference to the project's current funding cycle.

    // Get a reference to the project's current funding cycle.
    JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);

    External references:

  2. Get the amount of overflow to make the calculation with. Use the total overflow of all of the project's terminals if total overflow should be used, otherwise use the overflow of the provided terminal.

    // Get the amount of current overflow.
    // Use the project's total overflow across all of its terminals if the flag species specifies so. Otherwise, use the overflow local to the specified terminal.
    uint256 _currentOverflow = _useTotalOverflow
    ? _currentTotalOverflowOf(_projectId, _terminal.decimals(), _terminal.currency())
    : _overflowDuring(
    _terminal,
    _projectId,
    _fundingCycle,
    _terminal.currency()
    );

    Internal references:

    External references:

  3. If there's no overflow, there's nothing reclaimable.

    // If there's no overflow, there's no reclaimable overflow.
    if (_currentOverflow == 0) return 0;
  4. Get a reference to the total outstanding supply of project tokens that should be used in the calculation.

    // Get the number of outstanding tokens the project has.
    uint256 _totalSupply = IJBController(directory.controllerOf(_projectId))
    .totalOutstandingTokensOf(_projectId, _fundingCycle.reservedRate());

    Library references:

    Internal references:

    External references:

  5. Make sure the provided token count is within the bounds of the total supply.

    // Can't redeem more tokens that is in the supply.
    if (_tokenCount > _totalSupply) return 0;
  6. Return the reclaimable overflow using the project's current funding cycle and the derived current overflow.

    // Return the reclaimable overflow amount.
    return
    _reclaimableOverflowDuring(
    _projectId,
    _fundingCycle,
    _tokenCount,
    _totalSupply,
    _currentOverflow
    );

    Internal references: