TWABDelegator
Delegate chances to win to multiple accounts. This contract allows accounts to easily delegate a portion of their tickets to multiple delegatees. The delegatees chance of winning prizes is increased by the delegated amount.
Write methods description
initialize()
Allows to initialize the contract during the deployment. Creates a new TWAB Delegator that is bound to the given ticket contract.
Parameters:
Name | Type | Description |
---|---|---|
_ticket | address | Address of the ticket contract. |
_minLockDuration | uint96 | Minimum lock duration. |
_maxLockDuration | uint96 | Maximum lock duration. |
createDelegation()
This will create a new Delegation contract for the given slot and have it delegate its tickets to the given delegatee. If a non-zero lock duration is passed, then the delegatee cannot be changed, nor funding withdrawn, until the lock has expired. The _delegator
and _slot
params are used to compute the salt of the delegation.
Parameters:
Name | Type | Description |
---|---|---|
_delegator | address | Address of the delegator that will be able to handle the delegation. |
_slot | uint256 | Slot of the delegation. |
_delegatee | address | Address of the delegatee. |
_lockDuration | uint96 | Duration of time for which the delegation is locked. |
Return:
Name | Type | Description |
---|---|---|
_delegation | address | Returns the address of the Delegation contract that will hold the tickets. |
fundDelegation()
Fund a delegation by transferring tickets from the caller to the delegation. Callable by anyone. Will revert if delegation does not exist.
Parameters:
Name | Type | Description |
---|---|---|
_delegator | address | Address of the delegator. |
_slot | uint256 | Slot of the delegation. |
_amount | uint256 | Amount of tickets to transfer. |
Return:
Name | Type | Description |
---|---|---|
_delegation | address | The address of the Delegation. |
transferDelegationTo()
Withdraw an _amount
of tickets from a delegation. The delegator is assumed to be the caller. Tickets are sent directly to the passed _to
address. Will revert if delegation is still locked.
Parameters:
Name | Type | Description |
---|---|---|
_slot | uint256 | Slot of the delegation. |
_amount | uint256 | Amount to withdraw. |
_to | address | Account to transfer the withdrawn tickets to. |
Return:
Name | Type | Description |
---|---|---|
_delegation | address | The address of the Delegation. |
multicall()
Allows a user to call multiple functions on the same contract. Useful for EOA who wants to batch transactions.
Parameters:
Name | Type | Description |
---|---|---|
_data | bytes[] | An array of encoded function calls. The calls must be abi-encoded calls to this contract. |
Return:
Name | Type | Description |
---|---|---|
_data | bytes[] | The results from each function call. |
permitAndMulticall()
Allow a user to approve a ticket and run various calls in one transaction.
Parameters:
Name | Type | Description |
---|---|---|
_amount | uint256 | Amount of tickets to approve. |
_permitSignature | Signature | Permit signature. |
_data | bytes[] | Data to call with |
setMaxLockDuration()
Sets a new maximum lock duration. Only callable by the owner.
Parameters:
Name | Type | Description |
---|---|---|
_maxLockDuration | uint96 | New maximum lock duration in seconds. |
setMinLockDuration()
Sets a new minimum lock duration. Only callable by the owner.
Parameters:
Name | Type | Description |
---|---|---|
_minLockDuration | uint96 | New minimum lock duration in seconds. |
updateDelegatee()
Updates the delegatee and lock duration for a delegation slot. Only callable by the _delegator
. Will revert if delegation is still locked.
Parameters:
Name | Type | Description |
---|---|---|
_delegator | address | Address of the delegator. |
_slot | uint256 | Slot of the delegation. |
_delegatee | address | Address of the delegatee. |
_lockDuration | uint96 | Duration of time during which the delegatee cannot be changed nor withdrawn. |
Return:
Name | Type | Description |
---|---|---|
_delegation | address | The address of the Delegation. |
withdrawDelegation()
Withdraw tickets from a delegation. Only callable by the _delegator
. Will send the tickets to this contract and increase the _delegator
staked amount. Will revert if delegation is still locked.
Parameters:
Name | Type | Description |
---|---|---|
_delegator | address | Address of the delegator. |
_slot | uint256 | Slot of the delegation. |
_amount | uint256 | Amount of tickets to withdraw. |
Return:
Name | Type | Description |
---|---|---|
_delegation | address | The address of the Delegation. |
renounceOwnership()
Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
transferOwnership()
Transfers ownership of the contract to a _pendingOwner
. Can only be called by the current owner.
Parameters:
Name | Type | Description |
---|---|---|
_newOwner | address | An account that will become the |
Read methods description
computeDelegationAddress()
Computes the address of the delegation for the delegator + slot combination.
Parameters:
Name | Type | Description |
---|---|---|
_delegator | address | The user who is delegating tickets. |
_slot | uint256 | The delegation slot. |
Return:
Name | Type | Description |
---|---|---|
_delegation | address | The address of the delegation. This is the address that holds the balance of tickets. |
delegationInstance()
Address of the delegation instance to which all proxies will point.
getDelegation()
Allows the caller to easily get the details for a delegation.
Parameters:
Name | Type | Description |
---|---|---|
_delegator | address | The delegator address. |
_slot | uint256 | The delegation slot they are using. |
Return:
Name | Type | |
---|---|---|
_delegation | address | The address that holds tickets for the delegation. |
_delegatee | address | The address that tickets are being delegated to. |
_balance | uint256 | The balance of tickets in the delegation. |
_lockUntil | uint256 | The timestamp at which the delegation unlocks. |
_wasCreated | bool | Whether or not the delegation has been created. |
maxLockDuration()
Max lock time during which a delegation cannot be updated.
minLockDuration()
Min lock time during which a delegation cannot be updated.
owner()
Address of the owner role, it is granted with exclusive access to specific functions that use the modifier onlyOwner
.
ticket()
Address of the prize pool ticket to which this contract is tied to.
Last updated