Skip to main content

VaultBooster

Git Source

Allows someone to liquidate arbitrary tokens for a vault and improve the vault's chance of winning

Events

SetBoost

event SetBoost(contract IERC20 token, address liquidationPair, UD2x18 multiplierOfTotalSupplyPerSecond, uint96 tokensPerSecond, uint144 initialAvailable, uint48 lastAccruedAt)

Emitted when a boost is set

Parameters

NameTypeDescription
tokencontract IERC20The token to liquidate to boost the Vault's chances
liquidationPairaddressThe pair that will act as the liquidator
multiplierOfTotalSupplyPerSecondUD2x18The multiplier of the total supply per second. Can be used to simulate APR. Can be combined with tokensPerSecond
tokensPerSeconduint96The number of tokens to accrue per second. Is a simple straight time*amount allocation. Can be combiend with the multiplier.
initialAvailableuint144The initial available balance
lastAccruedAtuint48The timestamp at which the boost was set

Deposited

event Deposited(contract IERC20 token, address from, uint256 amount)

Emitted when someone deposits tokens

Parameters

NameTypeDescription
tokencontract IERC20The token that they deposited
fromaddressThe account that deposited the tokens
amountuint256The amount that was deposited.

Withdrawn

event Withdrawn(contract IERC20 token, address from, uint256 amount)

Emitted when tokens are withdrawn by the owner

Parameters

NameTypeDescription
tokencontract IERC20The token that was withdrawn
fromaddressThe account that withdraw the tokens
amountuint256The amount of tokens that were withdrawn

Liquidated

event Liquidated(contract IERC20 token, address from, uint256 amountIn, uint256 amountOut, uint256 availableBoostBalance)

Emitted when tokens are liquidated

Parameters

NameTypeDescription
tokencontract IERC20The token that was sold
fromaddressThe account that is receiving the tokens
amountInuint256The amount of tokens that were contributed to the prize pool
amountOutuint256The amount of tokens that were sold
availableBoostBalanceuint256The remaining available boost balance for the token

BoostAccrued

event BoostAccrued(contract IERC20 token, uint256 availableBoostBalance)

Emitted when boost tokens are accrued

Parameters

NameTypeDescription
tokencontract IERC20The token that accrued
availableBoostBalanceuint256The new available balance

Variables

prizePool

contract PrizePool prizePool

The prize pool that this booster will contribute to

twabController

contract TwabController twabController

The prize pool's twab controller; copied here to save gas

vault

address vault

The vault that the VaultBooster is boosting

Functions

constructor

constructor(contract PrizePool _prizePool, address _vault, address _owner) public

Constructs a new VaultBooster

Parameters

NameTypeDescription
_prizePoolcontract PrizePoolThe prize pool to contribute to
_vaultaddressThe vault to boost
_owneraddressThe owner of the VaultBooster contract

getBoost

function getBoost(contract IERC20 _token) external returns (struct Boost)

Retrieves boost details for a token

Parameters

NameTypeDescription
_tokencontract IERC20The token whose boost details to retrieve

Return Values

NameTypeDescription
[0]struct BoostThe boost details

setBoost

function setBoost(contract IERC20 _token, address _liquidationPair, UD2x18 _multiplierOfTotalSupplyPerSecond, uint96 _tokensPerSecond, uint144 _initialAvailable) external

Allows the owner to configure a boost for a token

Parameters

NameTypeDescription
_tokencontract IERC20The token that will be liquidated to boost the chances of the vault
_liquidationPairaddressThe liquidation pair that will facilitate liquidations
_multiplierOfTotalSupplyPerSecondUD2x18The multiplier of the total supply per second, useful for simulating APR. Can be combined with tokensPerSecond.
_tokensPerSeconduint96A simple tokensPerSecond*deltaTime accumulator. Can be combined with the multiplier.
_initialAvailableuint144The initial available balance. If this value is greater than this contract's current balance of the given token, the current balance will be used instead.

deposit

function deposit(contract IERC20 _token, uint256 _amount) external

Deposits tokens into this contract.

Useful because it ensures accrue is called before depositing

Parameters

NameTypeDescription
_tokencontract IERC20The token to deposit
_amountuint256The amount to deposit

accrue

function accrue(contract IERC20 _token) external returns (uint256)

Accrues the boost for the given token

Parameters

NameTypeDescription
_tokencontract IERC20The token whose boost should be updated

Return Values

NameTypeDescription
[0]uint256The new available balance of the boost

withdraw

function withdraw(contract IERC20 _token, uint256 _amount) external

allows the owner to withdraw tokens

Parameters

NameTypeDescription
_tokencontract IERC20The token to withdraw
_amountuint256The amount of tokens to withdraw

liquidatableBalanceOf

function liquidatableBalanceOf(address _tokenOut) external returns (uint256)

Get the available amount of tokens that can be swapped.

Parameters

NameTypeDescription
_tokenOutaddress

Return Values

NameTypeDescription
[0]uint256uint256 Available amount of token

transferTokensOut

function transferTokensOut(address, address receiver, address tokenOut, uint256 amountOut) external returns (bytes)

Transfers tokens to the receiver

Parameters

NameTypeDescription
address
receiveraddressAddress of the account that will receive tokenOut
tokenOutaddressAddress of the token being bought
amountOutuint256Amount of token being bought

verifyTokensIn

function verifyTokensIn(address tokenIn, uint256 amountIn, bytes transferTokensOutData) external

Verifies that tokens have been transferred in.

Parameters

NameTypeDescription
tokenInaddressAddress of the token being sold
amountInuint256Amount of token being sold
transferTokensOutDatabytesData returned by the corresponding transferTokensOut call

isLiquidationPair

function isLiquidationPair(address tokenOut, address liquidationPair) external view returns (bool)

Checks if a liquidation pair can be used to liquidate the given tokenOut from this source.

Parameters

NameTypeDescription
tokenOutaddressThe address of the token to liquidate
liquidationPairaddressThe address of the liquidation pair that is being checked

Return Values

NameTypeDescription
[0]boolbool True if the liquidation pair can be used, false otherwise

targetOf

function targetOf(address _tokenIn) external view returns (address)

Get the address that will receive tokenIn.

Reverts if _tokenIn isn't the prize token. Always returns the prize pool address.

Parameters

NameTypeDescription
_tokenInaddress

Return Values

NameTypeDescription
[0]addressaddress Address of the target

Structs

Boost

struct Boost {
address liquidationPair;
UD2x18 multiplierOfTotalSupplyPerSecond;
uint96 tokensPerSecond;
uint144 available;
uint48 lastAccruedAt;
}

Errors

OnlyLiquidationPair

error OnlyLiquidationPair()

Emitted when someone tries to call liquidate and isn't the liquidation pair

InsufficientAvailableBalance

error InsufficientAvailableBalance(uint256 amountOut, uint256 available)

Emitted when the liquidator attempts to liquidate more than the available balance

UnsupportedTokenIn

error UnsupportedTokenIn()

Emitted when the liquidator attempts to liquidate for a token other than the prize token

ZeroAmountWithdraw

error ZeroAmountWithdraw()

Emitted when a withdraw of zero amount is initiated.

ZeroAmountDeposit

error ZeroAmountDeposit()

Emitted when a deposit of zero amount is initiated.

VaultZeroAddress

error VaultZeroAddress()

Emitted when the vault is set to the zero address.

OwnerZeroAddress

error OwnerZeroAddress()

Emitted when the owner is set to the zero address.

CannotDepositWithoutBoost

error CannotDepositWithoutBoost(contract IERC20 token)

Emitted when someone tries to deposit when no boost has been set for a token

Parameters

NameTypeDescription
tokencontract IERC20The token that was attempted to be deposited

TokenZeroAddress

error TokenZeroAddress()

Emitted when the token is set to the zero address.

LiquidationPairZeroAddress

error LiquidationPairZeroAddress()

Emitted when the liquidation pair param is the zero address.