-
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
fix: Enable Runtime-Apis to update nav with estimates #1791
Conversation
We can also think about removing the |
|
pallets/pool-system/src/impls.rs
Outdated
.then(|| { | ||
NotedChange::<T>::remove(pool_id, change_id); | ||
change | ||
}) | ||
.ok_or(Error::<T>::ChangeNotReady.into()) | ||
.ok_or(Error::<T>::ChangeNotReady.into())?; |
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.
This is already notified in the consumer side of released()
: https://github.com/centrifuge/centrifuge-chain/blob/main/pallets/oracle-collection/src/lib.rs#L244
Not sure if we want another event here.
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.
AFAICS, we are not emitting such an event for pool fees or for loans. IMO, it makes sense to add this here.
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.
Also the Events are quite confusing without showing that this came from a change that was released:
And if we are noting a change we are also emitting an event. I would keep it.
runtime/common/src/apis/loans.rs
Outdated
@@ -32,3 +34,17 @@ decl_runtime_apis! { | |||
fn portfolio_valuation(pool_id: PoolId, input_prices: PriceCollectionInput) -> Result<Balance, DispatchError>; | |||
} | |||
} | |||
|
|||
pub fn update_nav_api_call<T: pallet_loans::Config>( |
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.
NIT. We're using this for the API, but it seems like a common method that can be used for other purposes. I would move to runtime/common/src/lib.rs
instead.
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.
Same name?
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.
No strong opinion. Maybe infallible_update_nav()
or similar?
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.
Changes seem reasonable to me, thanks for the quick fix!
@lemunozm Could you elaborate on the the difference between older_value_timestamp
and last_updated
entries of a CachedCollection
? On Centrifuge chain, both values are the same right now. IIUC, now - older_value_timestamp
needs to be less than the value_lifetime
entry of the CollectionInfo
, correct?
pallets/pool-system/src/impls.rs
Outdated
.then(|| { | ||
NotedChange::<T>::remove(pool_id, change_id); | ||
change | ||
}) | ||
.ok_or(Error::<T>::ChangeNotReady.into()) | ||
.ok_or(Error::<T>::ChangeNotReady.into())?; |
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.
AFAICS, we are not emitting such an event for pool fees or for loans. IMO, it makes sense to add this here.
Yes:
Note in the code that |
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! Just some lines that can be removed because they do not affect to the computation
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!
Thanks for this
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
See slack threads
Changes and Descriptions
Allows to call the runtime apis with either the latest prices or if outdated using estimates with linear accrual based on the latest settlement price.
Checklist: