IAsset
The IAsset interface makes it easy for developers to build custom support for any asset token protocol.
All asset adapters must inherit from and adhere to the IAsset
interface.
interface IAsset {
function hold(uint256 amount) external returns (uint256);
function getCostOfAsset(uint256 amount) external returns (uint256);
function withdraw(uint256 amount) external returns (uint256);
function withdrawReward() external returns (uint256);
function getRewardsBalance() external returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount)
external returns (bool);
}
hold
hold
Gets the interest-bearing, asset tokens
function hold(uint256 amount) external returns (uint256)
parameter:
amount
, the number underlying tokens to lend in order to receive and hold corresponding asset tokensreturns: the number of asset tokens received
getCostOfAsset
getCostOfAsset
Calculates the amount of underlying tokens needed to receive and hold a certain amount
of asset tokens
function getCostOfAsset(uint256 amount) external returns (uint256)
parameter:
amount
, the number of asset tokens for which the underlying token cost will be calculatedreturns: the number of underlying tokens needed to receive and hold a certain
amount
of asset tokens
withdraw
withdraw
Withdraws underlying tokens in exchange for the asset tokens.
function withdraw(uint256 amount) external returns (uint256)
parameter:
amount
, the number of asset tokens to redeem in exchange for the underlying tokensreturns: the amount of underlying tokens withdrawn
withdrawReward
withdrawReward
Withdraws rewards or governance tokens that have been yielded from the adapter's lending protocol (e.g., COMP
tokens yielded from lending to the Compound protocol via the CompoundAdapter
).
function withdrawReward() external returns (uint256)
returns: the number of rewards or governance tokens withdrawn
getRewardsBalance
getRewardsBalance
Returns the balance of rewards or governance tokens that have been yielded from the adapter's lending protocol (e.g., COMP
tokens yielded from lending to the Compound protocol via the CompoundAdapter
).
function getRewardsBalance() external returns (uint256)
returns: the balance of rewards or governance tokens that have accrued
transfer
transfer
Handles transferring the asset tokens from a rewards farmer proxy to a recipient's rewards farmer proxy in the event a SaveToken holder wishes to transfer
their SaveTokens.
function transfer(address recipient, uint256 amount) external returns (bool)
parameter:
recipient
, The address receiving the asset tokens in their rewards farmer proxyparameter:
amount
, The number of asset tokens to transferreturns: true if executed successfully
transferFrom
transferFrom
Handles transferring the asset tokens from a rewards farmer proxy to a recipient's rewards farmer proxy in the event a SaveToken holder wishes to transferFrom
their SaveTokens
function transferFrom(address sender, address recipient, uint256 amount)
external returns (bool)
parameter:
sender
, The address sending the asset tokens from their rewards farmer proxyparameter:
recipient
, The address receiving the asset tokens in their rewards farmer proxyparameter:
amount
, The number of asset tokens to transferreturns: true if executed successfully
Last updated