SRC-6 improvement: View function to retrieve underlying asset AssetId
mattiaslightstone opened this issue · 3 comments
Motivation
Description
Add underlying_asset to the SRC-6 specification. This would return the AssetId of the underlying asset for a vault or sub-vault.
Motivation
A standard way to get the underlying token address from a vault. Asset ID is used to retrieve information in the existing read functions and is critical for the context of a vault.
This standard used ERC4626 as a reference, which has the asset
function.
Specification
fn underlying_asset(vault_sub_id: SubId) -> Option<AssetId>
The function returns the AssetId of the underlying asset for a vault. The function takes vault_sub_id as an argument and returns the ID of the asset deposited in the vault.
- The function MUST return Some if the vault_sub_id exists
- The function MUST return None if the vault_sub_id does not exist
After messaging with @dmihal, I realize now that this does limit implementations that this standard currently supports.
Only implementations that store underlying assets indexed by vault_share_asset_id would be possible.
Without including it, however, I don't see how applications like wallets can show the following without relying on an indexer:
- <Share_asset> <Amount> : <underlying_asset> <equivalent value>
If this isn't a concern, I will close this and implement it in my contracts when needed.
I dont expect wallets to show the live underlying amount, or even the asset, and if they do they will likely use the indexer. To reduce storage costs as much as possible we have not made the mentioned method mandatory. However ofcourse if your usecase needs it you are free to implement it for your contract