-
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
Changes from 5 commits
8f09fc0
75732fa
64585d6
58b6176
6e89bd3
87d0ba5
b877c13
b5a9bb8
c3592a8
dec3d95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
use cfg_traits::data::DataRegistry; | ||
use pallet_loans::entities::input::PriceCollectionInput; | ||
use parity_scale_codec::Codec; | ||
use sp_api::decl_runtime_apis; | ||
use sp_runtime::DispatchError; | ||
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. No strong opinion. Maybe |
||
pool: T::PoolId, | ||
) -> Result<T::Balance, DispatchError> { | ||
let price_input = | ||
if let Ok(prices) = <T as pallet_loans::Config>::PriceRegistry::collection(pool) { | ||
PriceCollectionInput::Custom(prices) | ||
} else { | ||
PriceCollectionInput::Empty | ||
}; | ||
|
||
pallet_loans::Pallet::<T>::update_portfolio_valuation_for_pool(pool, price_input) | ||
.map(|(nav, _)| 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.
This is already notified in the consumer side of
released()
: https://github.com/centrifuge/centrifuge-chain/blob/main/pallets/oracle-collection/src/lib.rs#L244Not 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.