# StakePrizePool

The Stake Prize Pool is a prize pool in which users can deposit an ERC-20 token. These tokens are simply held by the Stake Prize Pool and become eligible for prizes. Prizes are added manually by anyone (in our case they are added by the Lido protocol every 24 hours (at 12AM UTC)) and are distributed to users at the end of the prize period.

## Write methods description

### initialize()

Allows to initialize the contract during the deployment.

Parameters:

<table><thead><tr><th width="268.3333333333333">Name</th><th width="98">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_owner</strong></td><td>address</td><td>An address of the Stake Prize Pool owner.</td></tr><tr><td><strong>_stakeToken</strong></td><td>address</td><td>An address of the stake token.</td></tr><tr><td><strong>_rewardToken</strong></td><td>address</td><td>The ASX token address.</td></tr><tr><td><strong>_rewardPerSecond</strong></td><td>uint256</td><td>The reward per second that will be used in time of distribution of ASX tokens. Can be updated by the admin after deployment of smart-contract.</td></tr><tr><td><strong>_claimInterval</strong></td><td>uint32</td><td>The reward claim interval, in seconds. Can be updated by the admin after deployment of smart-contract.</td></tr><tr><td><strong>_freeExitDuration</strong></td><td>uint32</td><td>A duration (in seconds) that will take place after each finished draw when all users are able to withdraw their stETH without paying an exit fee. An exit fee is calculated using Lido APR. Can be updated by the admin after deployment of smart-contract.</td></tr><tr><td><strong>_firstLidoRebaseTimestamp</strong></td><td>uint32</td><td>The closest 12 PM UTC timestamp in the future from now.</td></tr><tr><td><strong>_lidoAPR</strong></td><td>uint16</td><td>Annual percentage rate of Lido protocol. Should be specified with 2 decimal places (ex. 500 - 5.00%, 6000 - 60.00%). Maximum possible value is equal to 10000 - 100.00%. Can be updated by the admin after deployment of smart-contract.</td></tr></tbody></table>

### award()

Called by the prize flush to award prizes. The amount awarded must be less than the `awardBalance()`.

Parameters:

<table><thead><tr><th width="143.33333333333331">Name</th><th width="123">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_to</strong></td><td>address</td><td>The address of the winner that receives the award.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>The amount of assets to be awarded.</td></tr></tbody></table>

### awardExternalERC20()

Called by the Prize Flush to award external ERC-20 prizes. Used to award any arbitrary tokens held by the Prize Pool.

Parameters:

<table><thead><tr><th width="168.33333333333331">Name</th><th width="102">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_to</strong></td><td>address</td><td>The address of the winner that receives the award.</td></tr><tr><td><strong>_externalToken</strong></td><td>address</td><td>The address of the external asset token being awarded.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>The amount of external assets to be awarded.</td></tr></tbody></table>

### awardExternalERC721()

Called by the Prize Flush to award external ERC-721 prizes. Used to award any arbitrary NFTs held by the Prize Pool.

Parameters:

<table><thead><tr><th width="168.33333333333331">Name</th><th width="104">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_to</strong></td><td>address</td><td>The address of the winner that receives the award.</td></tr><tr><td><strong>_externalToken</strong></td><td>address</td><td>The address of the external NFT token being awarded.</td></tr><tr><td><strong>_tokenIds</strong></td><td>uint256[]</td><td>An array of NFT token IDs to be transferred.</td></tr></tbody></table>

### balance()

Returns the total underlying balance of all assets. This includes both principal and interest.

### captureAwardBalance()

Captures any available interest as reward balance. This function also captures the reserve fees.

### claim()

Claims reward in ASX tokens that distributes on users’ deposits.

Parameters:

<table><thead><tr><th width="164.33333333333331">Name</th><th width="164">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_user</strong></td><td>address</td><td>The user for whom to claim reward.</td></tr></tbody></table>

### compLikeDelegate()

Delegate the votes for a Compound COMP-like token held by the prize pool.

Parameters:

<table><thead><tr><th width="135.33333333333331">Name</th><th width="102">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_compLike</strong></td><td>address</td><td>The COMP-like token held by the prize pool that should be delegated.</td></tr><tr><td><strong>_to</strong></td><td>address</td><td>The address to delegate to.</td></tr></tbody></table>

### depositTo()

Deposit assets into the Prize Pool in exchange for tokens.

Parameters:

<table><thead><tr><th width="118">Name</th><th width="135.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_to</strong></td><td>address</td><td>The address receiving the newly minted tokens.</td></tr><tr><td><strong>_amount</strong></td><td>uin256</td><td>The amount of assets to deposit.</td></tr></tbody></table>

### depositToAndDelegate()

Deposit assets into the Prize Pool in exchange for tokens, then sets the delegate on behalf of the caller.

Parameters:

<table><thead><tr><th width="134.33333333333331">Name</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_to</strong></td><td>address</td><td>The address receiving the newly minted tokens.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>The amount of assets to deposit.</td></tr><tr><td><strong>_delegate</strong></td><td>address</td><td>The address to delegate to for the caller.</td></tr></tbody></table>

### setBalanceCap()

Allows the owner to set a balance cap per `token` for the pool. If a user wins, his balance can go over the cap. He will be able to withdraw the excess but not deposit. Needs to be called after deploying a prize pool to be able to deposit into it.

Parameters:

<table><thead><tr><th width="194.33333333333331">Name</th><th width="145">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_balanceCap</strong></td><td>uint256</td><td>New balance cap.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="127.33333333333331">Name</th><th width="80">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_success</strong></td><td>bool</td><td><code>true</code> if the new balance cap has been successfully set.</td></tr></tbody></table>

### setClaimInterval()

Sets the claim interval for the prize pool that will be used in time of claiming of ASX tokens. Only callable by the owner.

Parameters:

<table><thead><tr><th width="182.33333333333331">Name</th><th width="118">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_claimInterval</strong></td><td>uint32</td><td>The new claim interval, in seconds.</td></tr></tbody></table>

### setFreeExitDuration()

Sets a new duration (in seconds) that will take place after each finished draw when all users are able to withdraw their stETH without paying an exit fee. Only callable by the owner.

Parameters:

<table><thead><tr><th width="196.33333333333331">Name</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_freeExitDuration</strong></td><td>uint32</td><td>A new free exit duration (in seconds).</td></tr></tbody></table>

### setLidoAPR()

Sets a new annual percentage rate of Lido protocol. Should be specified with 2 decimal places (ex. 500 - 5.00%, 6000 - 60.00%). Maximum possible value is equal to 10000 - 100.00%. Only callable by the owner.

Parameters:

<table><thead><tr><th width="193.33333333333331">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_lidoAPR</strong></td><td>uint16</td><td>A new Lido APR.</td></tr></tbody></table>

### setDrawBeacon()

Sets the DrawBeacon contract address. Only callable by the owner.

Parameters:

<table><thead><tr><th width="207">Name</th><th width="123.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_drawBeacon</strong></td><td>address</td><td>DrawBeacon contract address to set.</td></tr></tbody></table>

### setLiquidityCap()

Allows the Governor to set a cap on the amount of liquidity that the pool can hold. Only callable by the owner.

Parameters:

<table><thead><tr><th width="184.33333333333331">Name</th><th width="145">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_liquidityCap</strong></td><td>uint256</td><td>The new liquidity cap for the prize pool.</td></tr></tbody></table>

### setPrizeFlush()

Sets the PrizeFlush contract address. Only callable by the owner.

Parameters:

<table><thead><tr><th width="194.33333333333331">Name</th><th width="147">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_prizeFlush</strong></td><td>address</td><td>PrizeFlush contract address to set.</td></tr></tbody></table>

### setRewardPerSecond()

Sets the reward per second for the prize pool that will be used for ASX tokens distribution. Only callable by the owner.

Parameters:

<table><thead><tr><th width="236.33333333333331">Name</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_rewardPerSecond</strong></td><td>uint256</td><td>The new reward per second.</td></tr></tbody></table>

### setTicket()

Sets the prize pool Ticket contract address. Only callable by the owner.

Parameters:

<table><thead><tr><th width="180.33333333333331">Name</th><th width="136">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_ticket</strong></td><td>address</td><td>Address of the Ticket to set.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="143.33333333333331">Name</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_success</strong></td><td>bool</td><td><code>true</code> if the ticket has been successfully set.</td></tr></tbody></table>

### transferExternalERC20()

Called by the PrizeFlush to transfer out external ERC-20 tokens. Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything.

Parameters:

<table><thead><tr><th width="172.33333333333331">Name</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_to</strong></td><td>address</td><td>The address of the winner that receives the award.</td></tr><tr><td><strong>_externalToken</strong></td><td>address</td><td>The address of the external asset token being awarded.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>The amount of external assets to be awarded.</td></tr></tbody></table>

### updateUserRewardAndFormer()

Called by the ticket to update the user's reward and former in time of transfer.

Parameters:

<table><thead><tr><th width="179.33333333333331">Name</th><th width="109">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_user</strong></td><td>address</td><td>The user where need to update reward and former.</td></tr><tr><td><strong>_beforeBalance</strong></td><td>uint256</td><td>The balance of the user before transfer.</td></tr><tr><td><strong>_afterBalance</strong></td><td>uint256</td><td>The balance of the user after transfer.</td></tr></tbody></table>

### withdrawFrom()

Withdraw assets from the PrizePool instantly. The withdrawn amount can be less than specified in the parameters. This is due to the fact that if the user withdraws funds after the free exit window, a fee is deducted from him, which is equal to the amount that the Lido protocol would distribute for this user during the rebasing operation.

Parameters:

<table><thead><tr><th width="151.33333333333331">Name</th><th width="125">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_from</strong></td><td>address</td><td>The address to redeem tokens from.</td></tr><tr><td><strong>_amount</strong></td><td>uint256</td><td>The amount of tokens to redeem for assets.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="180.33333333333331">Name</th><th width="159">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_amount</strong></td><td>uint256</td><td>The actual amount withdrawn.</td></tr></tbody></table>

### claimOwnership()

Allows the `pendingOwner` address to claim the owner role. This function is only callable by the `pendingOwner`.

### 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="153.33333333333331">Name</th><th width="132">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

### VERSION()

Semver version.

### awardBalance()

Called by the Prize Flush to award prizes. The amount awarded must be less than the `awardBalance()`.

### canAwardExternal()

Checks with the Prize Pool if a specific token type may be awarded as an external prize.

Parameters:&#x20;

<table><thead><tr><th width="202.33333333333331">Name</th><th width="137">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_externalToken</strong></td><td>address</td><td>The address of the token to check.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="140.33333333333331">Name</th><th width="103">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_canAward</strong></td><td>bool</td><td><code>true</code> if the token may be awarded, <code>false</code> otherwise.</td></tr></tbody></table>

### getAccountedBalance()

Read internal Ticket accounted balance.

### getBalanceCap()

Read internal `balanceCap` variable.

### getClaimInterval()

Read `claimInterval` variable.

### getFreeExitDuration()

Read `freeExitDuration` variable.

### getDeploymentTimestamp()

Read `deploymentTimestamp` variable.

### getFirstLidoRebaseTimestamp()

Read `firstLidoRebaseTimestamp` variable.

### getLidoAPR()

Read `lidoAPR` variable.

### getClaimableReward()

Calculates actual claimable amount of ASX tokens for the user.

### getDistributionEnd()

Read `distributionEnd` variable.

### getLastUpdated()

Read `lastUpdated` variable.

### getLiquidityCap()

Read internal `liquidityCap` variable.

### getPrizeFlush()

Read `prizeFlush` variable.

### getRewardPerSecond()

Read `rewardPerSecond` variable.

### getRewardPerShare()

Read `rewardPerShare` variable.

### getRewardToken()

Read `rewardToken` variable.

### getTicket()

Read `ticket` variable.

### getDrawBeacon()

Read `drawBeacon` variable.

### getToken()

Read `token` variable.

### getUserStakelnfo()

Read `userStakeInfo` variable.

Parameters:

<table><thead><tr><th width="125.33333333333331">Name</th><th width="152">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_user</strong></td><td>address</td><td>The address of the user to retrieve stake info about.</td></tr></tbody></table>

### isControlled()

Checks if a specific token is controlled by the Prize Pool.

Parameters:

<table><thead><tr><th width="213.33333333333331">Name</th><th width="133">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_controlledToken</strong></td><td>address</td><td>The address of the token to check.</td></tr></tbody></table>

Return:

<table><thead><tr><th width="162.33333333333331">Name</th><th width="87">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_isControlled</strong></td><td>bool</td><td><code>true</code> if the token is a controlled token, <code>false</code> otherwise.</td></tr></tbody></table>

### onERC721Received()

Whenever an {IERC721} `_tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} by `_operator` from `_from`, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.

Parameters:

<table><thead><tr><th width="201.33333333333331">Name</th><th width="151">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>_operator</strong></td><td>address</td><td>An operator.</td></tr><tr><td><strong>_from</strong></td><td>address</td><td>An address from where token was transferred.</td></tr><tr><td><strong>_tokenId</strong></td><td>uint256</td><td>Token ID.</td></tr><tr><td><strong>_data</strong></td><td>bytes</td><td>Additional data.</td></tr></tbody></table>

### owner()

Role that can be granted exclusive access to specific functions with the modifier `onlyOwner`.

### pendingOwner()

Address that can claim the owner role. It is used to transfer the owner.


---

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