Yield Reserve
Inherits: ReentrancyGuard, Ownable
Author: Sperax Foundation
This contract allows users to swap supported stable-coins for yield earned by the USDs protocol. It sends USDs to the Dripper contract for rebase and to the Buyback Contract for buyback.
State Variables
vault
oracle
buyback
dripper
buybackPercentage
tokenData
Functions
constructor
Constructor of the YieldReserve contract.
Parameters
Name | Type | Description |
---|---|---|
_buyback | address | Address of the Buyback contract. |
_vault | address | Address of the Vault. |
_oracle | address | Address of the Oracle. |
_dripper | address | Address of the Dripper contract. |
swap
Swap function to be called by frontend users.
Parameters
Name | Type | Description |
---|---|---|
_srcToken | address | Source/Input token. |
_dstToken | address | Destination/Output token. |
_amountIn | uint256 | Input token amount. |
_minAmountOut | uint256 | Minimum output tokens expected. |
toggleSrcTokenPermission
Allow or disallow a specific token
for use as a source/input token.
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of the token to be allowed or disallowed. |
_isAllowed | bool | If set to true, the token will be allowed as a source/input token; otherwise, it will be disallowed. |
toggleDstTokenPermission
Allow or disallow a specific token
for use as a destination/output token.
Reverts if caller is not owner.
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of the token to be allowed or disallowed. |
_isAllowed | bool | If set to true, the token will be allowed as a destination/output token; otherwise, it will be disallowed. |
withdraw
Emergency withdrawal function for unexpected situations.
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of the asset to be withdrawn. |
_receiver | address | Address of the receiver of tokens. |
_amount | uint256 | Amount of tokens to be withdrawn. |
updateBuybackPercentage
Set the percentage of newly minted USDs to be sent to the Buyback contract.
Reverts if caller is not owner.
The remaining USDs are sent to VaultCore for rebase.
Parameters
Name | Type | Description |
---|---|---|
_toBuyback | uint256 | The percentage of USDs sent to Buyback (e.g., 3000 for 30%). |
updateBuyback
Update the address of the Buyback contract.
Reverts if caller is not owner.
Parameters
Name | Type | Description |
---|---|---|
_newBuyBack | address | New address of the Buyback contract. |
updateOracle
Update the address of the Oracle contract.
Reverts if caller is not owner.
Parameters
Name | Type | Description |
---|---|---|
_newOracle | address | New address of the Oracle contract. |
updateDripper
Update the address of the Dripper contract.
Reverts if caller is not owner.
Parameters
Name | Type | Description |
---|---|---|
_newDripper | address | New address of the Dripper contract. |
updateVault
Update the address of the VaultCore contract.
Reverts if caller is not owner.
Parameters
Name | Type | Description |
---|---|---|
_newVault | address | New address of the VaultCore contract. |
swap
Swap allowed source token for allowed destination token.
Parameters
Name | Type | Description |
---|---|---|
_srcToken | address | Source/Input token. |
_dstToken | address | Destination/Output token. |
_amountIn | uint256 | Input token amount. |
_minAmountOut | uint256 | Minimum output tokens expected. |
_receiver | address | Receiver of the tokens. |
mintUSDs
Mints USDs directly with the allowed collaterals for USDs.
Only collaterals configured in USDs vault are allowed to be used for minting.
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of token to mint USDs with |
getTokenBForTokenA
Get an estimate of the output token amount for a given input token amount.
Parameters
Name | Type | Description |
---|---|---|
_srcToken | address | Input token address. |
_dstToken | address | Output token address. |
_amountIn | uint256 | Input amount of _srcToken. |
Returns
Name | Type | Description |
---|---|---|
uint256 | Estimated output token amount. |
_sendUSDs
Distributes USDs to the Buyback and Dripper contracts based on buybackPercentage.
Sends a portion of the USDs balance to the Buyback contract and the remaining to the Dripper contract for rebase.