Skip to main content

YieldSource

Git Source

Inherits: GACManaged, CustomReentrancyGuard

Author: Struct Finance

This is a base contract that must be inherited by the platform specific yieldsource contracts, such as AutoPoolYieldSource, etc.,

  • Used to supply, recompound rewards and withdraw tokens to and from a yield source.
  • Exposes interest to Product/Vault contract. Vaults accrue yield from this contract.
  • Each vault's shares will be calculated via within this contract.

State Variables

INITIAL_SHARES

This will be the shares allocated to the first product

Required to prevent share manipulation.

uint256 public constant INITIAL_SHARES = 1e8;

Functions

_tokenToShares

Calculates the share amount for the given token amount

function _tokenToShares(uint256 _tokenAmount, uint256 _currentTotalShares, uint256 _currentTotalExternalShares)
internal
pure
returns (uint256 _equivalentShares);

Parameters

NameTypeDescription
_tokenAmountuint256Amount of tokens to be converted to shares
_currentTotalSharesuint256Current total share value within the yield source contract
_currentTotalExternalSharesuint256The total share value of external tokens (specific to underlying YieldSource)

Returns

NameTypeDescription
_equivalentSharesuint256Equivalent amount of shares for the given amount of tokens

_sharesToTokens

Calculates the token amount for the given share value

function _sharesToTokens(uint256 _shares, uint256 _currentTotalShares, uint256 _currentTotalExternalShares)
internal
pure
returns (uint256 _equivalentTokens);

Parameters

NameTypeDescription
_sharesuint256Amount of shares to be converted to tokens
_currentTotalSharesuint256Current total share value within the yield source contract
_currentTotalExternalSharesuint256The total share value of external tokens (specific to underlying YieldSource)

Returns

NameTypeDescription
_equivalentTokensuint256Equivalent amount of tokens for the given share value

receive

Fallback function to receive WAVAX rewards when rewards are recompounded.

receive() external payable;