Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TokenPrice RuntimeApi and RPC Method #749

Closed
Tracked by #747
mustermeiszer opened this issue Apr 1, 2022 · 0 comments · Fixed by #796
Closed
Tracked by #747

TokenPrice RuntimeApi and RPC Method #749

mustermeiszer opened this issue Apr 1, 2022 · 0 comments · Fixed by #796
Assignees
Labels
crcl-runtime Circle runtime related. I8-enhancement An additional feature. P2-nice-to-have Issue is worth doing.

Comments

@mustermeiszer
Copy link
Collaborator

mustermeiszer commented Apr 1, 2022

The api should provide the possibilities to call a node to retrieve the latest available token-price. This is a little tricky as calculating token-prices generally involves a "more" complex calculation.
It would be nice to have this anyways and this feature will most likely need us to provide a separate method for the pools pallet to achieve it.

  • Should NOT fail when NAV is too old

Implementation Proposal

#[rpc]
pub trait TokenTranchePriceApi {
	#[rpc(name = "pools_tokenPrice")]
	fn tranche_token_price(&self, id: T::PoolId, tranche: TrancheLoc<T::TrancheId>) 
	    -> Result<BalanceRatio>;
}

decl_runtime_apis! {
    pub trait TokenTranchePriceApi {
	 fn tranche_token_price(id: T::PoolId, tranche: TrancheLoc<T::TrancheId>) -> Option<BalanceRatio>;
    }
}
@mustermeiszer mustermeiszer added P2-nice-to-have Issue is worth doing. I8-enhancement An additional feature. crcl-runtime Circle runtime related. labels Apr 1, 2022
@branan branan self-assigned this Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crcl-runtime Circle runtime related. I8-enhancement An additional feature. P2-nice-to-have Issue is worth doing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants