-
Notifications
You must be signed in to change notification settings - Fork 86
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
feat: add NAV runtime API #1703
Conversation
runtime/common/src/apis/pools.rs
Outdated
@@ -46,5 +46,7 @@ decl_runtime_apis! { | |||
fn tranche_id(pool_id: PoolId, tranche_index: TrancheIndex) -> Option<TrancheId>; | |||
|
|||
fn tranche_currency(pool_id: PoolId, tranche_loc: TrancheLoc<TrancheId>) -> Option<Currency>; | |||
|
|||
fn nav(pool_id: PoolId) -> Option<(Balance, Nav<Balance>)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mustermeiszer Not sure if we would rather want to expose all data in a new type to be more explicit. Here we return (nav.total(pool.reserve), nav)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use a structured type for this? Just because it's quite opaque now what the data returned here is (hard to know that the first element is the reserve and the second element is the NAV)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at all. I wanted to propose the most simple version and then iterate on that based on the feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. @hieronx would the indexer be able to work with that?
|
||
fn nav(pool_id: PoolId) -> Option<(Balance, pallet_pool_system::Nav<Balance>)> { | ||
let pool = pallet_pool_system::Pool::<Runtime>::get(pool_id)?; | ||
let nav_loans = Loans::update_nav(pool_id).ok()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure about this. Do we want the NAV value used to compute the loan's portfolio, or the NAV value just for the moment we call the RuntimeAPI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not sure and asked @mustermeiszer who said that we want the current NAV, even if the onchain one is outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing the double check!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely current one, as the UI needs to have the latest data!
69d8d35
to
63f326f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
Checklist: