YieldSource
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
Name | Type | Description |
---|---|---|
_tokenAmount | uint256 | Amount of tokens to be converted to shares |
_currentTotalShares | uint256 | Current total share value within the yield source contract |
_currentTotalExternalShares | uint256 | The total share value of external tokens (specific to underlying YieldSource) |
Returns
Name | Type | Description |
---|---|---|
_equivalentShares | uint256 | Equivalent 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
Name | Type | Description |
---|---|---|
_shares | uint256 | Amount of shares to be converted to tokens |
_currentTotalShares | uint256 | Current total share value within the yield source contract |
_currentTotalExternalShares | uint256 | The total share value of external tokens (specific to underlying YieldSource) |
Returns
Name | Type | Description |
---|---|---|
_equivalentTokens | uint256 | Equivalent amount of tokens for the given share value |
receive
Fallback function to receive WAVAX rewards when rewards are recompounded.
receive() external payable;