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

<table><thead><tr><th width="227.33333333333331">Name</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_ticket</strong></td><td>address</td><td>Address of the ticket contract.</td></tr><tr><td><strong>_minLockDuration</strong></td><td>uint96</td><td>Minimum lock duration.</td></tr><tr><td><strong>_maxLockDuration</strong></td><td>uint96</td><td>Maximum lock duration.</td></tr></tbody></table>

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

<table><thead><tr><th width="185.33333333333331">Name</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegator</strong></td><td>address</td><td>Address of the delegator that will be able to handle the delegation.</td></tr><tr><td><strong>_slot</strong></td><td>uint256</td><td>Slot of the delegation.</td></tr><tr><td><strong>_delegatee</strong></td><td>address</td><td>Address of the delegatee.</td></tr><tr><td><strong>_lockDuration</strong></td><td>uint96</td><td>Duration of time for which the delegation is locked.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="145.33333333333331">Name</th><th width="114">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>Returns the address of the Delegation contract that will hold the tickets.</td></tr></tbody></table>

### fundDelegation()

Fund a delegation by transferring tickets from the caller to the delegation. Callable by anyone. Will revert if delegation does not exist.

Parameters:

<table><thead><tr><th width="202.33333333333331">Name</th><th width="215">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegator</strong></td><td>address</td><td>Address of the delegator.</td></tr><tr><td><strong>_slot</strong></td><td>uint256</td><td>Slot of the delegation.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>Amount of tickets to transfer.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="232.33333333333331">Name</th><th width="229">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>The address of the Delegation.</td></tr></tbody></table>

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

<table><thead><tr><th width="165">Name</th><th width="153.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_slot</strong></td><td>uint256</td><td>Slot of the delegation.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>Amount to withdraw.</td></tr><tr><td><strong>_to</strong></td><td>address</td><td>Account to transfer the withdrawn tickets to.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="195.33333333333331">Name</th><th width="191">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>The address of the Delegation.</td></tr></tbody></table>

### multicall()

Allows a user to call multiple functions on the same contract.  Useful for EOA who wants to batch transactions.

Parameters:&#x20;

<table><thead><tr><th width="154.33333333333331">Name</th><th width="144">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_data</strong></td><td>bytes[]</td><td>An array of encoded function calls.  The calls must be abi-encoded calls to this contract.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="157.33333333333331">Name</th><th width="146">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_data</strong></td><td>bytes[]</td><td>The results from each function call.</td></tr></tbody></table>

### permitAndMulticall()

Allow a user to approve a ticket and run various calls in one transaction.

Parameters:

<table><thead><tr><th width="204.33333333333331">Name</th><th width="141">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_amount</strong></td><td>uint256</td><td>Amount of tickets to approve.</td></tr><tr><td><strong>_permitSignature</strong></td><td>Signature</td><td>Permit signature.</td></tr><tr><td><strong>_data</strong></td><td>bytes[]</td><td>Data to call with <code>functionDelegateCall</code>.</td></tr></tbody></table>

### setMaxLockDuration()

Sets a new maximum lock duration. Only callable by the owner.

Parameters:

<table><thead><tr><th width="248">Name</th><th width="153.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_maxLockDuration</strong></td><td>uint96</td><td>New maximum lock duration in seconds.</td></tr></tbody></table>

### setMinLockDuration()

Sets a new minimum lock duration. Only callable by the owner.

Parameters:

<table><thead><tr><th width="258">Name</th><th width="144.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_minLockDuration</strong></td><td>uint96</td><td>New minimum lock duration in seconds.</td></tr></tbody></table>

### updateDelegatee()

Updates the delegatee and lock duration for a delegation slot. Only callable by the `_delegator`.  Will revert if delegation is still locked.

Parameters:

<table><thead><tr><th width="169.33333333333331">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegator</strong></td><td>address</td><td>Address of the delegator.</td></tr><tr><td><strong>_slot</strong></td><td>uint256</td><td>Slot of the delegation.</td></tr><tr><td><strong>_delegatee</strong></td><td>address</td><td>Address of the delegatee.</td></tr><tr><td><strong>_lockDuration</strong></td><td>uint96</td><td>Duration of time during which the delegatee cannot be changed nor withdrawn.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="201.33333333333331">Name</th><th width="155">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>The address of the Delegation.</td></tr></tbody></table>

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

<table><thead><tr><th width="209.33333333333331">Name</th><th width="200">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegator</strong></td><td>address</td><td>Address of the delegator.</td></tr><tr><td><strong>_slot</strong></td><td>uint256</td><td>Slot of the delegation.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>Amount of tickets to withdraw.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="207">Name</th><th width="180.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>The address of the Delegation.</td></tr></tbody></table>

### 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.&#x20;

Parameters:

<table><thead><tr><th width="165.33333333333331">Name</th><th width="117">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_newOwner</strong></td><td>address</td><td>An account that will become the <code>_pendingOwner</code>.</td></tr></tbody></table>

## Read methods description

### computeDelegationAddress()

Computes the address of the delegation for the delegator + slot combination.

Parameters:

<table><thead><tr><th width="192.33333333333331">Name</th><th width="178">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegator</strong></td><td>address</td><td>The user who is delegating tickets.</td></tr><tr><td><strong>_slot</strong></td><td>uint256</td><td>The delegation slot.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="143.33333333333331">Name</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>The address of the delegation. This is the address that holds the balance of tickets.</td></tr></tbody></table>

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

<table><thead><tr><th width="202.33333333333331">Name</th><th width="177">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_delegator</strong></td><td>address</td><td>The delegator address.</td></tr><tr><td><strong>_slot</strong></td><td>uint256</td><td>The delegation slot they are using.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="187.33333333333331">Name</th><th width="138">Type</th><th></th></tr></thead><tbody><tr><td><strong>_delegation</strong></td><td>address</td><td>The address that holds tickets for the delegation.</td></tr><tr><td><strong>_delegatee</strong></td><td>address</td><td>The address that tickets are being delegated to.</td></tr><tr><td><strong>_balance</strong></td><td>uint256</td><td>The balance of tickets in the delegation.</td></tr><tr><td><strong>_lockUntil</strong></td><td>uint256</td><td>The timestamp at which the delegation unlocks.</td></tr><tr><td><strong>_wasCreated</strong></td><td>bool</td><td>Whether or not the delegation has been created.</td></tr></tbody></table>

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.asymetrix.io/resources/developers-docs/twabdelegator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
