Skip to main content

YieldSourcePrizePool

The Yield Source Prize Pool uses a yield source contract to generate prizes. Funds that are deposited into the prize pool are then deposited into a yield source. (i.e. Aave, Compound, etc...)

Functions

constructor

  function constructor(
address _owner,
contract IYieldSource _yieldSource
) public

Deploy the Prize Pool and Yield Service with the required contract connections

Parameters:

NameTypeDescription
_owneraddressAddress of the Yield Source Prize Pool owner
_yieldSourcecontract IYieldSourceAddress of the yield source

sweep

  function sweep(
) external

Sweeps any stray balance of deposit tokens into the yield source.

This becomes prize money

balance

  function balance(
) external returns (uint256)

Return Values:

TypeDescription
uint256The underlying balance of assets

awardBalance

  function awardBalance(
) external returns (uint256)

Returns the balance that is available to award.

captureAwardBalance() should be called first

Return Values:

TypeDescription
uint256The total amount of assets to be awarded for the current prize

canAwardExternal

  function canAwardExternal(
address externalToken
) external returns (bool)

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

Parameters:

NameTypeDescription
externalTokenaddressThe address of the token to check

Return Values:

TypeDescription
boolTrue if the token may be awarded, false otherwise

isControlled

  function isControlled(
contract ITicket controlledToken
) external returns (bool)

Checks if a specific token is controlled by the Prize Pool

Parameters:

NameTypeDescription
controlledTokencontract ITicketThe address of the token to check

Return Values:

TypeDescription
boolTrue if the token is a controlled token, false otherwise

getAccountedBalance

  function getAccountedBalance(
) external returns (uint256)

Read internal Ticket accounted balance.

Return Values:

TypeDescription
uint256uint256 accountBalance

getBalanceCap

  function getBalanceCap(
) external returns (uint256)

Read internal balanceCap variable

getLiquidityCap

  function getLiquidityCap(
) external returns (uint256)

Read internal liquidityCap variable

getTicket

  function getTicket(
) external returns (contract ITicket)

Read ticket variable

getPrizeStrategy

  function getPrizeStrategy(
) external returns (address)

Read prizeStrategy variable

getToken

  function getToken(
) external returns (address)

Read token variable

captureAwardBalance

  function captureAwardBalance(
) external returns (uint256)

Captures any available interest as award balance.

This function also captures the reserve fees.

Return Values:

TypeDescription
uint256The total amount of assets to be awarded for the current prize

depositTo

  function depositTo(
address to,
uint256 amount
) external

Deposit assets into the Prize Pool in exchange for tokens

Parameters:

NameTypeDescription
toaddressThe address receiving the newly minted tokens
amountuint256The amount of assets to deposit

depositToAndDelegate

  function depositToAndDelegate(
address to,
uint256 amount,
address delegate
) external

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

Parameters:

NameTypeDescription
toaddressThe address receiving the newly minted tokens
amountuint256The amount of assets to deposit
delegateaddressThe address to delegate to for the caller

withdrawFrom

  function withdrawFrom(
address from,
uint256 amount
) external returns (uint256)

Withdraw assets from the Prize Pool instantly. A fairness fee may be charged for an early exit.

Parameters:

NameTypeDescription
fromaddressThe address to redeem tokens from.
amountuint256The amount of tokens to redeem for assets.

Return Values:

TypeDescription
uint256The actual amount withdrawn

award

  function award(
address to,
uint256 amount
) external

Called by the prize strategy to award prizes.

The amount awarded must be less than the awardBalance()

Parameters:

NameTypeDescription
toaddressThe address of the winner that receives the award
amountuint256The amount of assets to be awarded

transferExternalERC20

  function transferExternalERC20(
address to,
address externalToken,
uint256 amount
) external

Called by the Prize-Strategy to transfer out external ERC20 tokens

Used to transfer out tokens held by the Prize Pool. Could be liquidated, or anything.

Parameters:

NameTypeDescription
toaddressThe address of the winner that receives the award
externalTokenaddressThe address of the external asset token being awarded
amountuint256The amount of external assets to be awarded

awardExternalERC20

  function awardExternalERC20(
address to,
address amount,
uint256 externalToken
) external

Called by the Prize-Strategy to award external ERC20 prizes

Used to award any arbitrary tokens held by the Prize Pool

Parameters:

NameTypeDescription
toaddressThe address of the winner that receives the award
amountaddressThe amount of external assets to be awarded
externalTokenuint256The address of the external asset token being awarded

awardExternalERC721

  function awardExternalERC721(
address to,
address externalToken,
uint256[] tokenIds
) external

Called by the prize strategy to award external ERC721 prizes

Used to award any arbitrary NFTs held by the Prize Pool

Parameters:

NameTypeDescription
toaddressThe address of the winner that receives the award
externalTokenaddressThe address of the external NFT token being awarded
tokenIdsuint256[]An array of NFT Token IDs to be transferred

setBalanceCap

  function setBalanceCap(
uint256 balanceCap
) external returns (bool)

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:

NameTypeDescription
balanceCapuint256New balance cap.

Return Values:

TypeDescription
boolTrue if new balance cap has been successfully set.

setLiquidityCap

  function setLiquidityCap(
uint256 liquidityCap
) external

Allows the Governor to set a cap on the amount of liquidity that he pool can hold

Parameters:

NameTypeDescription
liquidityCapuint256The new liquidity cap for the prize pool

setTicket

  function setTicket(
contract ITicket ticket
) external returns (bool)

Set prize pool ticket.

Parameters:

NameTypeDescription
ticketcontract ITicketAddress of the ticket to set.

Return Values:

TypeDescription
boolTrue if ticket has been successfully set.

setPrizeStrategy

  function setPrizeStrategy(
address _prizeStrategy
) external

Sets the prize strategy of the prize pool. Only callable by the owner.

Parameters:

NameTypeDescription
_prizeStrategyaddressThe new prize strategy.

compLikeDelegate

  function compLikeDelegate(
contract ICompLike compLike,
address to
) external

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

Parameters:

NameTypeDescription
compLikecontract ICompLikeThe COMP-like token held by the prize pool that should be delegated
toaddressThe address to delegate to

onERC721Received

  function onERC721Received(
) external returns (bytes4)

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 IERC721.onERC721Received.selector.

owner

  function owner(
) public returns (address)

Returns the address of the current owner.

pendingOwner

  function pendingOwner(
) external returns (address)

Gets current _pendingOwner.

Return Values:

TypeDescription
addressCurrent _pendingOwner address.

renounceOwnership

  function renounceOwnership(
) external

Renounce ownership of the contract.

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership

  function transferOwnership(
address _newOwner
) external

Allows current owner to set the _pendingOwner address.

Parameters:

NameTypeDescription
_newOwneraddressAddress to transfer ownership to.

claimOwnership

  function claimOwnership(
) external

Allows the _pendingOwner address to finalize the transfer.

This function is only callable by the _pendingOwner.

Events

Deployed

  event Deployed(
address yieldSource
)

Emitted when yield source prize pool is deployed.

Parameters:

NameTypeDescription
yieldSourceaddressAddress of the yield source.

Swept

  event Swept(
uint256 amount
)

Emitted when stray deposit token balance in this contract is swept

Parameters:

NameTypeDescription
amountuint256The amount that was swept

OwnershipOffered

  event OwnershipOffered(
address pendingOwner
)

Emitted when _pendingOwner has been changed.

Parameters:

NameTypeDescription
pendingOwneraddressnew _pendingOwner address.

OwnershipTransferred

  event OwnershipTransferred(
address previousOwner,
address newOwner
)

Emitted when _owner has been changed.

Parameters:

NameTypeDescription
previousOwneraddressprevious _owner address.
newOwneraddressnew _owner address.

ControlledTokenAdded

  event ControlledTokenAdded(
)

Event emitted when controlled token is added

AwardCaptured

  event AwardCaptured(
)

Deposited

  event Deposited(
)

Event emitted when assets are deposited

Awarded

  event Awarded(
)

Event emitted when interest is awarded to a winner

AwardedExternalERC20

  event AwardedExternalERC20(
)

Event emitted when external ERC20s are awarded to a winner

TransferredExternalERC20

  event TransferredExternalERC20(
)

Event emitted when external ERC20s are transferred out

AwardedExternalERC721

  event AwardedExternalERC721(
)

Event emitted when external ERC721s are awarded to a winner

Withdrawal

  event Withdrawal(
)

Event emitted when assets are withdrawn

BalanceCapSet

  event BalanceCapSet(
)

Event emitted when the Balance Cap is set

LiquidityCapSet

  event LiquidityCapSet(
)

Event emitted when the Liquidity Cap is set

PrizeStrategySet

  event PrizeStrategySet(
)

Event emitted when the Prize Strategy is set

TicketSet

  event TicketSet(
)

Event emitted when the Ticket is set

ErrorAwardingExternalERC721

  event ErrorAwardingExternalERC721(
)

Emitted when there was an error thrown awarding an External ERC721