跳到主要内容

JBSingleTokenPaymentTerminalStore3_1

Manages all bookkeeping for inflows and outflows of funds from any IJBSingleTokenPaymentTerminal.

Git Source

Mainnet: 0x77b0A81AeB61d08C0b23c739969d22c5C9950336

Goerli: 0x101cA528F6c2E35664529eB8aa0419Ae1f724b49

Inherits: ReentrancyGuard, IJBSingleTokenPaymentTerminalStore

Adheres to:

Inherits from:

  • ReentrancyGuard: Contract module that helps prevent reentrant calls to a function.

This Store expects a project's controller to be an IJBController3_1. This is the only difference between this version and the original.

State Variables

_MAX_FIXED_POINT_FIDELITY

Ensures a maximum number of decimal points of persisted fidelity on mulDiv operations of fixed point numbers.

uint256 private constant _MAX_FIXED_POINT_FIDELITY = 18;

directory

The directory of terminals and controllers for projects.

IJBDirectory public immutable override directory;

fundingCycleStore

The contract storing all funding cycle configurations.

IJBFundingCycleStore public immutable override fundingCycleStore;

prices

The contract that exposes price feeds.

IJBPrices public immutable override prices;

balanceOf

The amount of tokens that each project has for each terminal, in terms of the terminal's token.

The used distribution limit is represented as a fixed point number with the same amount of decimals as its relative terminal.

  • _terminal The terminal to which the balance applies.
  • _projectId The ID of the project to get the balance of.
mapping(IJBSingleTokenPaymentTerminal => mapping(uint256 => uint256)) public override balanceOf;

usedDistributionLimitOf

The amount of funds that a project has distributed from its limit during the current funding cycle for each terminal, in terms of the distribution limit's currency.

Increases as projects use their preconfigured distribution limits.

The used distribution limit is represented as a fixed point number with the same amount of decimals as its relative terminal.

  • _terminal The terminal to which the used distribution limit applies.
  • _projectId The ID of the project to get the used distribution limit of.
  • _fundingCycleNumber The number of the funding cycle during which the distribution limit was used.
mapping(IJBSingleTokenPaymentTerminal => mapping(uint256 => mapping(uint256 => uint256))) public override
usedDistributionLimitOf;

usedOverflowAllowanceOf

The amount of funds that a project has used from its allowance during the current funding cycle configuration for each terminal, in terms of the overflow allowance's currency.

Increases as projects use their allowance.

The used allowance is represented as a fixed point number with the same amount of decimals as its relative terminal.

  • _terminal The terminal to which the overflow allowance applies.
  • _projectId The ID of the project to get the used overflow allowance of.
  • _configuration The configuration of the during which the allowance was used.
mapping(IJBSingleTokenPaymentTerminal => mapping(uint256 => mapping(uint256 => uint256))) public override
usedOverflowAllowanceOf;

Functions

currentOverflowOf

Gets the current overflowed amount in a terminal for a specified project.

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

function currentOverflowOf(IJBSingleTokenPaymentTerminal _terminal, uint256 _projectId)
external
view
override
returns (uint256);

Parameters

NameTypeDescription
_terminalIJBSingleTokenPaymentTerminalThe terminal for which the overflow is being calculated.
_projectIduint256The ID of the project to get overflow for.

Returns

NameTypeDescription
<none>uint256The current amount of overflow that project has in the specified terminal.

currentTotalOverflowOf

Gets the current overflowed amount for a specified project across all terminals.

function currentTotalOverflowOf(uint256 _projectId, uint256 _decimals, uint256 _currency)
external
view
override
returns (uint256);

Parameters

NameTypeDescription
_projectIduint256The ID of the project to get total overflow for.
_decimalsuint256The number of decimals that the fixed point overflow should include.
_currencyuint256The currency that the total overflow should be in terms of.

Returns

NameTypeDescription
<none>uint256The current total amount of overflow that project has across all terminals.

currentReclaimableOverflowOf

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.

function currentReclaimableOverflowOf(
IJBSingleTokenPaymentTerminal _terminal,
uint256 _projectId,
uint256 _tokenCount,
bool _useTotalOverflow
) external view override returns (uint256);

Parameters

NameTypeDescription
_terminalIJBSingleTokenPaymentTerminalThe terminal from which the reclaimable amount would come.
_projectIduint256The ID of the project to get the reclaimable overflow amount for.
_tokenCountuint256The number of tokens to make the calculation with, as a fixed point number with 18 decimals.
_useTotalOverflowboolA 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.

Returns

NameTypeDescription
<none>uint256The amount of overflowed tokens that can be reclaimed, as a fixed point number with the same number of decimals as the provided _terminal.

currentReclaimableOverflowOf

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

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

function currentReclaimableOverflowOf(uint256 _projectId, uint256 _tokenCount, uint256 _totalSupply, uint256 _overflow)
external
view
override
returns (uint256);

Parameters

NameTypeDescription
_projectIduint256The ID of the project to get the reclaimable overflow amount for.
_tokenCountuint256The number of tokens to make the calculation with, as a fixed point number with 18 decimals.
_totalSupplyuint256The total number of tokens to make the calculation with, as a fixed point number with 18 decimals.
_overflowuint256The amount of overflow to make the calculation with, as a fixed point number.

Returns

NameTypeDescription
<none>uint256The amount of overflowed tokens that can be reclaimed, as a fixed point number with the same number of decimals as the provided _overflow.

constructor

constructor(IJBDirectory _directory, IJBFundingCycleStore _fundingCycleStore, IJBPrices _prices);

Parameters

NameTypeDescription
_directoryIJBDirectoryA contract storing directories of terminals and controllers for each project.
_fundingCycleStoreIJBFundingCycleStoreA contract storing all funding cycle configurations.
_pricesIJBPricesA contract that exposes price feeds.

recordPaymentFrom

Records newly contributed tokens to a project.

Mints the project's tokens according to values provided by a configured data source. If no data source is configured, mints tokens proportional to the amount of the contribution.

The msg.sender must be an IJBSingleTokenPaymentTerminal. The amount specified in the params is in terms of the msg.sender's tokens.

function recordPaymentFrom(
address _payer,
JBTokenAmount calldata _amount,
uint256 _projectId,
uint256 _baseWeightCurrency,
address _beneficiary,
string calldata _memo,
bytes memory _metadata
)
external
override
nonReentrant
returns (
JBFundingCycle memory fundingCycle,
uint256 tokenCount,
JBPayDelegateAllocation[] memory delegateAllocations,
string memory memo
);

Parameters

NameTypeDescription
_payeraddressThe original address that sent the payment to the terminal.
_amountJBTokenAmountThe amount of tokens being paid. Includes the token being paid, the value, the number of decimals included, and the currency of the amount.
_projectIduint256The ID of the project being paid.
_baseWeightCurrencyuint256The currency to base token issuance on.
_beneficiaryaddressThe specified address that should be the beneficiary of anything that results from the payment.
_memostringA memo to pass along to the emitted event, and passed along to the funding cycle's data source.
_metadatabytesBytes to send along to the data source, if one is provided.

Returns

NameTypeDescription
fundingCycleJBFundingCycleThe project's funding cycle during which payment was made.
tokenCountuint256The number of project tokens that were minted, as a fixed point number with 18 decimals.
delegateAllocationsJBPayDelegateAllocation[]The amount to send to delegates instead of adding to the local balance.
memostringA memo that should be passed along to the emitted event.

recordRedemptionFor

Records newly redeemed tokens of a project.

Redeems the project's tokens according to values provided by a configured data source. If no data source is configured, redeems tokens along a redemption bonding curve that is a function of the number of tokens being burned.

The msg.sender must be an IJBSingleTokenPaymentTerminal. The amount specified in the params is in terms of the msg.senders tokens.

function recordRedemptionFor(
address _holder,
uint256 _projectId,
uint256 _tokenCount,
string memory _memo,
bytes memory _metadata
)
external
override
nonReentrant
returns (
JBFundingCycle memory fundingCycle,
uint256 reclaimAmount,
JBRedemptionDelegateAllocation[] memory delegateAllocations,
string memory memo
);

Parameters

NameTypeDescription
_holderaddressThe account that is having its tokens redeemed.
_projectIduint256The ID of the project to which the tokens being redeemed belong.
_tokenCountuint256The number of project tokens to redeem, as a fixed point number with 18 decimals.
_memostringA memo to pass along to the emitted event.
_metadatabytesBytes to send along to the data source, if one is provided.

Returns

NameTypeDescription
fundingCycleJBFundingCycleThe funding cycle during which the redemption was made.
reclaimAmountuint256The amount of terminal tokens reclaimed, as a fixed point number with 18 decimals.
delegateAllocationsJBRedemptionDelegateAllocation[]The amount to send to delegates instead of sending to the beneficiary.
memostringA memo that should be passed along to the emitted event.

recordDistributionFor

Records newly distributed funds for a project.

The msg.sender must be an IJBSingleTokenPaymentTerminal.

function recordDistributionFor(uint256 _projectId, uint256 _amount, uint256 _currency)
external
override
nonReentrant
returns (JBFundingCycle memory fundingCycle, uint256 distributedAmount);

Parameters

NameTypeDescription
_projectIduint256The ID of the project that is having funds distributed.
_amountuint256The amount to use from the distribution limit, as a fixed point number.
_currencyuint256The currency of the _amount. This must match the project's current funding cycle's currency.

Returns

NameTypeDescription
fundingCycleJBFundingCycleThe funding cycle during which the distribution was made.
distributedAmountuint256The amount of terminal tokens distributed, as a fixed point number with the same amount of decimals as its relative terminal.

recordUsedAllowanceOf

Records newly used allowance funds of a project.

The msg.sender must be an IJBSingleTokenPaymentTerminal.

function recordUsedAllowanceOf(uint256 _projectId, uint256 _amount, uint256 _currency)
external
override
nonReentrant
returns (JBFundingCycle memory fundingCycle, uint256 usedAmount);

Parameters

NameTypeDescription
_projectIduint256The ID of the project to use the allowance of.
_amountuint256The amount to use from the allowance, as a fixed point number.
_currencyuint256The currency of the _amount. Must match the currency of the overflow allowance.

Returns

NameTypeDescription
fundingCycleJBFundingCycleThe funding cycle during which the overflow allowance is being used.
usedAmountuint256The amount of terminal tokens used, as a fixed point number with the same amount of decimals as its relative terminal.

recordAddedBalanceFor

Records newly added funds for the project.

The msg.sender must be an IJBSingleTokenPaymentTerminal.

function recordAddedBalanceFor(uint256 _projectId, uint256 _amount) external override;

Parameters

NameTypeDescription
_projectIduint256The ID of the project to which the funds being added belong.
_amountuint256The amount of terminal tokens added, as a fixed point number with the same amount of decimals as its relative terminal.

recordMigration

Records the migration of funds from this store.

The msg.sender must be an IJBSingleTokenPaymentTerminal. The amount returned is in terms of the msg.senders tokens.

function recordMigration(uint256 _projectId) external override nonReentrant returns (uint256 balance);

Parameters

NameTypeDescription
_projectIduint256The ID of the project being migrated.

Returns

NameTypeDescription
balanceuint256The project's migrated balance, as a fixed point number with the same amount of decimals as its relative terminal.

_reclaimableOverflowDuring

The amount of overflowed tokens from a terminal that can be reclaimed by the specified number of tokens when measured from the specified.

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

function _reclaimableOverflowDuring(
uint256 _projectId,
JBFundingCycle memory _fundingCycle,
uint256 _tokenCount,
uint256 _totalSupply,
uint256 _overflow
) private view returns (uint256);

Parameters

NameTypeDescription
_projectIduint256The ID of the project to get the reclaimable overflow amount for.
_fundingCycleJBFundingCycleThe funding cycle during which reclaimable overflow is being calculated.
_tokenCountuint256The number of tokens to make the calculation with, as a fixed point number with 18 decimals.
_totalSupplyuint256The total supply of tokens to make the calculation with, as a fixed point number with 18 decimals.
_overflowuint256The amount of overflow to make the calculation with.

Returns

NameTypeDescription
<none>uint256The amount of overflowed tokens that can be reclaimed.

_overflowDuring

Gets the amount that is overflowing when measured from the specified funding cycle.

This amount changes as the value of the balance changes in relation to the currency being used to measure the distribution limit.

function _overflowDuring(
IJBSingleTokenPaymentTerminal _terminal,
uint256 _projectId,
JBFundingCycle memory _fundingCycle,
uint256 _balanceCurrency
) private view returns (uint256);

Parameters

NameTypeDescription
_terminalIJBSingleTokenPaymentTerminalThe terminal for which the overflow is being calculated.
_projectIduint256The ID of the project to get overflow for.
_fundingCycleJBFundingCycleThe ID of the funding cycle to base the overflow on.
_balanceCurrencyuint256The currency that the stored balance is expected to be in terms of.

Returns

NameTypeDescription
<none>uint256overflow The overflow of funds, as a fixed point number with 18 decimals.

_currentTotalOverflowOf

Gets the amount that is currently overflowing across all of a project's terminals.

This amount changes as the value of the balances changes in relation to the currency being used to measure the project's distribution limits.

function _currentTotalOverflowOf(uint256 _projectId, uint256 _decimals, uint256 _currency)
private
view
returns (uint256);

Parameters

NameTypeDescription
_projectIduint256The ID of the project to get the total overflow for.
_decimalsuint256The number of decimals that the fixed point overflow should include.
_currencyuint256The currency that the overflow should be in terms of.

Returns

NameTypeDescription
<none>uint256overflow The total overflow of a project's funds.

Errors

INVALID_AMOUNT_TO_SEND_DELEGATE

error INVALID_AMOUNT_TO_SEND_DELEGATE();

CURRENCY_MISMATCH

error CURRENCY_MISMATCH();

DISTRIBUTION_AMOUNT_LIMIT_REACHED

error DISTRIBUTION_AMOUNT_LIMIT_REACHED();

FUNDING_CYCLE_PAYMENT_PAUSED

error FUNDING_CYCLE_PAYMENT_PAUSED();

FUNDING_CYCLE_DISTRIBUTION_PAUSED

error FUNDING_CYCLE_DISTRIBUTION_PAUSED();

FUNDING_CYCLE_REDEEM_PAUSED

error FUNDING_CYCLE_REDEEM_PAUSED();

INADEQUATE_CONTROLLER_ALLOWANCE

error INADEQUATE_CONTROLLER_ALLOWANCE();

INADEQUATE_PAYMENT_TERMINAL_STORE_BALANCE

error INADEQUATE_PAYMENT_TERMINAL_STORE_BALANCE();

INSUFFICIENT_TOKENS

error INSUFFICIENT_TOKENS();

INVALID_FUNDING_CYCLE

error INVALID_FUNDING_CYCLE();

PAYMENT_TERMINAL_MIGRATION_NOT_ALLOWED

error PAYMENT_TERMINAL_MIGRATION_NOT_ALLOWED();