Comment on page
Ticket
The Ticket extends the standard ERC20 and ControlledToken interfaces with time-weighted average balance functionality. The average balance held by a user between two timestamps can be calculated, as well as the historic balance. The historic total supply is available as well as the average total supply between two timestamps. A user may
delegate
their balance increasing another user's historic balance while retaining their tokens.Allows to initialize the contract during the deployment. Constructs Ticket with passed parameters.
Parameters:
Name | Type | Description |
---|---|---|
_name | string | ERC20 ticket token name. |
_symbol | string | ERC20 ticket token symbol. |
_decimals | uint8 | ERC20 ticket token decimals. |
_controller | address | ERC20 ticket controller address (ie. PrizePool address). |
Standard ERC20 approve of the ticket token. Sets
_amount
as the allowance of _spender
over the caller's tokens.Return:
Name | Type | Description |
---|---|---|
_approved | bool | true if the operation was successful. |
Allows the controller to burn tokens from a user account. May be overridden to provide more granular control over burning.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the holder account to burn tokens from. |
_amount | uint256 | Amount of tokens to burn. |
Allows an operator via the controller to burn tokens on behalf of a user account. May be overridden to provide more granular control over operator-burning.
Parameters:
Name | Type | Description |
---|---|---|
_operator | address | Address of the operator performing the burn action via the controller contract. |
_user | address | Address of the holder account to burn tokens from. |
_amount | uint256 | Amount of tokens to burn. |
Allows the controller to mint tokens for a user account. May be overridden to provide more granular control over minting.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the receiver of the minted tokens. |
_amount | uint256 | Amount of tokens to mint. |
Standard ERC20
decreaseAllowance
function, atomically decreases the allowance granted to _spender
by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.Parameters:
Name | Type | Description |
---|---|---|
_spender | address | Address from where to subtract the allowance. |
_subtractedValue | uint256 | The amount to subtract. |
Return:
Name | Type | Description |
---|---|---|
_success | bool | true if operation was successful. |
Delegate time-weighted average balances to an alternative address. Transfers (including mints) trigger the storage of a TWAB in the delegate(s) account, instead of the targeted sender and/or recipient address(s). To reset the delegate, pass the zero address (0x000) as
_to
parameter. The current delegate address should be different from the new delegate address _to
.Parameters:
Name | Type | Description |
---|---|---|
_to | address | Recipient of delegated TWAB. |
Allows a user to delegate via signature.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | The user who is delegating. |
_delegate | address | The new delegate. |
_deadline | uint256 | The timestamp by which this must be submitted. |
_v | uint8 | The v portion of the ECDSA sig. |
_r | bytes32 | The r portion of the ECDSA sig. |
_s | bytes32 | The s portion of the ECDSA sig. |
Standard ERC20
increaseAllowance
function, atomically increases the allowance granted to _spender
by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.Sets
_value
as the allowance of _spender
over _owner
's tokens, given _owner
's signed approval.Standard ERC20
transfer
function, moves _amount
tokens from the caller's account to _to
. Returns a boolean value indicating whether the operation succeeded.Standard ERC20
transferFrom
function, moves _amount
tokens from _from
to _to
using the allowance mechanism. _amount
is then deducted from the caller's allowance.Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
Returns the remaining number of tokens that
_spender
will be allowed to spend on behalf of _owner
through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.Returns the amount of tokens owned by
_account
.Interface to the contract responsible for controlling mint/burn.
ERC20 controlled token decimals.
Retrieves the address of the delegate to whom
_user
has delegated their tickets. The address of the delegate will be the zero address if _user
has not delegated their tickets.Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the delegator. |
Gets a user's TWAB context. This is a struct with their balance, next TWAB index, and cardinality.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | The user for whom to fetch the TWAB context. |
Retrieves the average balance held by a user for a given time frame.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | The user whose balance is checked. |
_startTime | uint64 | The start time of the time frame. |
_endTime | uint64 | The end time of the time frame. |
Return:
Name | Type | Description |
---|---|---|
_balance | uint256 | The average balance that the user held during the time frame. |
Retrieves the average balances held by a user for a given time frames.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | The user whose balances are checked. |
_startTimes | uint64[] | The start time of the time frames. |
_endTimes | uint64[] | The end time of the time frames. |
Return:
Name | Type | Description |
---|---|---|
_balances | uint256[] | The average balances that the user held during the time frame. |
Retrieves the average total supply balances for a set of given time frames.
Parameters:
Name | Type | Description |
---|---|---|
_startTimes | uint64[] | Array of start times. |
_endTimes | uint64[] | Array of end times. |
Return:
Name | Type | Description |
---|---|---|
_totalSupplies | uint256[] | The average total supplies held during the time frame. |
Retrieves the user's TWAB balance.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user whose TWAB is being fetched. |
_timestamp | uint64 | Timestamp at which we want to retrieve the TWAB balance. |
Return:
Name | Type | Description |
---|---|---|
_balance | uint256 | The TWAB balance at the given timestamp. |
Retrieves the user’s TWAB balances.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user whose TWABs are being fetched. |
_timestamps | uint64[] | Timestamps range at which we want to retrieve the TWAB balances. |
Return:
Name | Type | Description |
---|---|---|
_balances | uint256[] | The user’s TWAB balances. |
Retrieves the total supply TWAB balances between the given timestamps range.
Parameters:
Name | Type | Description |
---|---|---|
_timestamps | uint64[] | Timestamps range at which we want to retrieve the total supply TWAB balances. |
Return:
Name | Type | Description |
---|---|---|
_balances | uint256[] | Total supply TWAB balances. |
Retrieves the total supply TWAB balance at the given timestamp.
Parameters:
Name | Type | Description |
---|---|---|
_timestamp | uint64 | Timestamp at which we want to retrieve the total supply TWAB balance. |
Return:
Name | Type | Description |
---|---|---|
_balance | uint256 | The total supply TWAB balance at the given timestamp. |
Gets the TWAB at a specific index for a user.
Parameters:
Name | Type | Description |
---|---|---|
_user | address | The user for whom to fetch the TWAB. |
_index | uint16 | The index of the TWAB to fetch. |
Return:
Name | Type | Description |
---|---|---|
_twab | TWAB | The TWAB, which includes the TWAB amount and the timestamp. |
Ticket token name.
Returns the current nonce for the owner. This value must be included whenever a signature is generated for {permit}. Every successful call to {permit} increases
owner
's nonce by one. This prevents a signature from being used multiple times.Ticket token symbol.
Returns the amount of tokens in existence.
Last modified 6mo ago