Skip to main content

AaveV3YieldSource

Yield Source for a PoolTogether prize pool that generates yield by depositing into Aave V3. This contract inherits from the ERC20 implementation to keep track of users deposits.

Functions

constructor

  function constructor(
contract IAToken _aToken,
contract IRewardsController _rewardsController,
contract IPoolAddressesProviderRegistry _poolAddressesProviderRegistry,
string _name,
string _symbol,
uint8 decimals_,
address _owner
) public

Initializes the yield source with Aave aToken.

Parameters:

NameTypeDescription
_aTokencontract IATokenAave aToken address
_rewardsControllercontract IRewardsControllerAave rewardsController address
_poolAddressesProviderRegistrycontract IPoolAddressesProviderRegistryAave poolAddressesProviderRegistry address
_namestringToken name for the underlying ERC20 shares
_symbolstringToken symbol for the underlying ERC20 shares
decimals_uint8Number of decimals the shares (inhereted ERC20) will have. Same as underlying asset to ensure sane exchange rates for shares.
_owneraddressOwner of this contract

balanceOfToken

  function balanceOfToken(
address _user
) external returns (uint256)

Returns user total balance (in asset tokens). This includes their deposit and interest.

Parameters:

NameTypeDescription
_useraddressAddress of the user to get balance of token for

Return Values:

TypeDescription
uint256The underlying balance of asset tokens.

depositToken

  function depositToken(
) public returns (address)

Returns the ERC20 asset token used for deposits.

Return Values:

TypeDescription
addressThe ERC20 asset token address.

decimals

  function decimals(
) public returns (uint8)

Returns the Yield Source ERC20 token decimals.

This value should be equal to the decimals of the token used to deposit into the pool.

Return Values:

TypeDescription
uint8The number of decimals.

supplyTokenTo

  function supplyTokenTo(
uint256 _depositAmount,
address _to
) external

Supplies asset tokens to the yield source.

Shares corresponding to the number of tokens supplied are minted to the user's balance. Asset tokens are supplied to the yield source, then deposited into Aave.

Parameters:

NameTypeDescription
_depositAmountuint256The amount of asset tokens to be supplied
_toaddressThe user whose balance will receive the tokens

redeemToken

  function redeemToken(
uint256 _redeemAmount
) external returns (uint256)

Redeems asset tokens from the yield source.

Shares corresponding to the number of tokens withdrawn are burnt from the user's balance. Asset tokens are withdrawn from Aave, then transferred from the yield source to the user's wallet.

Parameters:

NameTypeDescription
_redeemAmountuint256The amount of asset tokens to be redeemed

Return Values:

TypeDescription
uint256The actual amount of asset tokens that were redeemed.

claimRewards

  function claimRewards(
address _to
) external returns (bool)

Claims the accrued rewards for the aToken, accumulating any pending rewards.

Only callable by the owner or manager.

Parameters:

NameTypeDescription
_toaddressAddress where the claimed rewards will be sent

Return Values:

TypeDescription
boolTrue if operation was successful.

decreaseERC20Allowance

  function decreaseERC20Allowance(
contract IERC20 _token,
address _spender,
uint256 _amount
) external

Decrease allowance of ERC20 tokens other than the aTokens held by this contract.

This function is only callable by the owner or asset manager. Current allowance should be computed off-chain to avoid any underflow.

Parameters:

NameTypeDescription
_tokencontract IERC20Address of the ERC20 token to decrease allowance for
_spenderaddressAddress of the spender of the tokens
_amountuint256Amount of tokens to decrease allowance by

increaseERC20Allowance

  function increaseERC20Allowance(
contract IERC20 _token,
address _spender,
uint256 _amount
) external

Increase allowance of ERC20 tokens other than the aTokens held by this contract.

This function is only callable by the owner or asset manager. Allows another contract or address to withdraw funds from the yield source. Current allowance should be computed off-chain to avoid any overflow.

Parameters:

NameTypeDescription
_tokencontract IERC20Address of the ERC20 token to increase allowance for
_spenderaddressAddress of the spender of the tokens
_amountuint256Amount of tokens to increase allowance by

transferERC20

  function transferERC20(
contract IERC20 _token,
address _to,
uint256 _amount
) external

Transfer ERC20 tokens other than the aTokens held by this contract to the recipient address.

This function is only callable by the owner or asset manager.

Parameters:

NameTypeDescription
_tokencontract IERC20Address of the ERC20 token to transfer
_toaddressAddress of the recipient of the tokens
_amountuint256Amount of tokens to transfer

manager

  function manager(
) public returns (address)

Gets current _manager.

Return Values:

TypeDescription
addressCurrent _manager address.

setManager

  function setManager(
address _newManager
) external returns (bool)

Set or change of manager.

Throws if called by any account other than the owner.

Parameters:

NameTypeDescription
_newManageraddressNew _manager address.

Return Values:

TypeDescription
boolBoolean to indicate if the operation was successful or not.

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.

name

  function name(
) public returns (string)

Returns the name of the token.

symbol

  function symbol(
) public returns (string)

Returns the symbol of the token, usually a shorter version of the name.

totalSupply

  function totalSupply(
) public returns (uint256)

See {IERC20-totalSupply}.

balanceOf

  function balanceOf(
) public returns (uint256)

See {IERC20-balanceOf}.

transfer

  function transfer(
) public returns (bool)

See {IERC20-transfer}. Requirements:

  • to cannot be the zero address.
  • the caller must have a balance of at least amount.

allowance

  function allowance(
) public returns (uint256)

See {IERC20-allowance}.

approve

  function approve(
) public returns (bool)

See {IERC20-approve}. NOTE: If amount is the maximum uint256, the allowance is not updated on transferFrom. This is semantically equivalent to an infinite approval. Requirements:

  • spender cannot be the zero address.

transferFrom

  function transferFrom(
) public returns (bool)

See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum uint256. Requirements:

  • from and to cannot be the zero address.
  • from must have a balance of at least amount.
  • the caller must have allowance for from's tokens of at least amount.

increaseAllowance

  function increaseAllowance(
) public returns (bool)

Atomically increases the allowance granted to spender by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.

decreaseAllowance

  function decreaseAllowance(
) public returns (bool)

Atomically decreases the allowance granted to spender by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.
  • spender must have allowance for the caller of at least subtractedValue.

Events

AaveV3YieldSourceInitialized

  event AaveV3YieldSourceInitialized(
contract IAToken aToken,
contract IRewardsController rewardsController,
contract IPoolAddressesProviderRegistry poolAddressesProviderRegistry,
string name,
string symbol,
uint8 decimals,
address owner
)

Emitted when the yield source is initialized.

Parameters:

NameTypeDescription
aTokencontract IATokenAave aToken address
rewardsControllercontract IRewardsControllerAave rewardsController address
poolAddressesProviderRegistrycontract IPoolAddressesProviderRegistryAave poolAddressesProviderRegistry address
namestringToken name for the underlying ERC20 shares
symbolstringToken symbol for the underlying ERC20 shares
decimalsuint8Number of decimals the shares (inhereted ERC20) will have. Same as underlying asset to ensure sane exchange rates for shares.
owneraddressOwner of this contract

SuppliedTokenTo

  event SuppliedTokenTo(
address from,
uint256 shares,
uint256 amount,
address to
)

Emitted when asset tokens are supplied to the yield source.

Parameters:

NameTypeDescription
fromaddressAddress that supplied the tokens
sharesuint256Amount of shares minted to the user
amountuint256Amount of tokens supplied
toaddressAddress that received the shares

RedeemedToken

  event RedeemedToken(
address from,
uint256 shares,
uint256 amount
)

Emitted when asset tokens are redeemed from the yield source.

Parameters:

NameTypeDescription
fromaddressAddress who redeemed the tokens
sharesuint256Amount of shares burnt
amountuint256Amount of tokens redeemed

Claimed

  event Claimed(
address from,
address to,
address[] rewardsList,
uint256[] claimedAmounts
)

Emitted when Aave rewards have been claimed.

Parameters:

NameTypeDescription
fromaddressAddress who claimed the rewards
toaddressAddress that received the rewards
rewardsListaddress[]List of addresses of the reward tokens
claimedAmountsuint256[]List that contains the claimed amount per reward token

DecreasedERC20Allowance

  event DecreasedERC20Allowance(
address from,
address spender,
uint256 amount,
contract IERC20 token
)

Emitted when decreasing allowance of ERC20 tokens other than yield source's aToken.

Parameters:

NameTypeDescription
fromaddressAddress of the caller
spenderaddressAddress of the spender
amountuint256Amount of token to decrease allowance by
tokencontract IERC20Address of the ERC20 token to decrease allowance for

IncreasedERC20Allowance

  event IncreasedERC20Allowance(
address from,
address spender,
uint256 amount,
contract IERC20 token
)

Emitted when increasing allowance of ERC20 tokens other than yield source's aToken.

Parameters:

NameTypeDescription
fromaddressAddress of the caller
spenderaddressAddress of the spender
amountuint256Amount of token to increase allowance by
tokencontract IERC20Address of the ERC20 token to increase allowance for

TransferredERC20

  event TransferredERC20(
address from,
address to,
uint256 amount,
contract IERC20 token
)

Emitted when ERC20 tokens other than yield source's aToken are withdrawn from the yield source.

Parameters:

NameTypeDescription
fromaddressAddress of the caller
toaddressAddress of the recipient
amountuint256Amount of token transferred
tokencontract IERC20Address of the ERC20 token transferred

ManagerTransferred

  event ManagerTransferred(
address previousManager,
address newManager
)

Emitted when _manager has been changed.

Parameters:

NameTypeDescription
previousManageraddressprevious _manager address.
newManageraddressnew _manager address.

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.

Transfer

  event Transfer(
)

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

Approval

  event Approval(
)

Emitted when the allowance of a spender for an owner is set by a call to {approve}. value is the new allowance.