Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions runtime/centrifuge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pallet-fees = { path = "../../pallets/fees", default-features = false }
pallet-interest-accrual = { path = "../../pallets/interest-accrual", default-features = false }
pallet-investments = { path = "../../pallets/investments", default-features = false }
pallet-keystore = { path = "../../pallets/keystore", default-features = false }
pallet-loans = { path = "../../pallets/loans", default-features = false }
pallet-loans-ref = { path = "../../pallets/loans-ref", default-features = false }
pallet-migration-manager = { path = "../../pallets/migration", default-features = false }
pallet-nft = { path = "../../pallets/nft", default-features = false }
pallet-permissions = { path = "../../pallets/permissions", default-features = false }
Expand Down Expand Up @@ -162,7 +162,7 @@ std = [
"pallet-identity/std",
"pallet-interest-accrual/std",
"pallet-investments/std",
"pallet-loans/std",
"pallet-loans-ref/std",
"pallet-keystore/std",
"pallet-migration-manager/std",
"pallet-multisig/std",
Expand Down Expand Up @@ -236,7 +236,7 @@ runtime-benchmarks = [
"pallet-identity/runtime-benchmarks",
"pallet-interest-accrual/runtime-benchmarks",
"pallet-investments/runtime-benchmarks",
"pallet-loans/runtime-benchmarks",
"pallet-loans-ref/runtime-benchmarks",
"pallet-keystore/runtime-benchmarks",
"pallet-migration-manager/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
Expand Down Expand Up @@ -297,7 +297,7 @@ try-runtime = [
"pallet-identity/try-runtime",
"pallet-interest-accrual/try-runtime",
"pallet-investments/try-runtime",
"pallet-loans/try-runtime",
"pallet-loans-ref/try-runtime",
"pallet-keystore/try-runtime",
"pallet-migration-manager/try-runtime",
"pallet-multisig/try-runtime",
Expand Down
65 changes: 26 additions & 39 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

pub use cfg_primitives::{constants::*, types::*};
use cfg_traits::{
OrderManager, Permissions as PermissionsT, PoolUpdateGuard, PreConditions, TrancheCurrency as _,
OrderManager, Permissions as PermissionsT, PoolNAV, PoolUpdateGuard, PreConditions,
TrancheCurrency as _,
};
use cfg_types::{
consts::pools::{MaxTrancheNameLengthBytes, MaxTrancheSymbolLengthBytes},
Expand Down Expand Up @@ -551,7 +552,6 @@ pub enum ProxyType {
_Staking,
NonProxy,
Borrow,
Price,
Invest,
ProxyManagement,
KeystoreManagement,
Expand Down Expand Up @@ -623,21 +623,20 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
}
ProxyType::Borrow => matches!(
c,
RuntimeCall::Loans(pallet_loans::Call::create{..}) |
RuntimeCall::Loans(pallet_loans::Call::borrow{..}) |
RuntimeCall::Loans(pallet_loans::Call::repay{..}) |
RuntimeCall::Loans(pallet_loans::Call::write_off{..}) |
RuntimeCall::Loans(pallet_loans::Call::close{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::create{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::borrow{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::repay{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::write_off{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::close{..}) |
// Borrowers should be able to close and execute an epoch
// in order to get liquidity from repayments in previous epochs.
RuntimeCall::Loans(pallet_loans::Call::update_nav{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::update_portfolio_valuation{..}) |
RuntimeCall::PoolSystem(pallet_pool_system::Call::close_epoch{..}) |
RuntimeCall::PoolSystem(pallet_pool_system::Call::submit_solution{..}) |
RuntimeCall::PoolSystem(pallet_pool_system::Call::execute_epoch{..}) |
RuntimeCall::Utility(pallet_utility::Call::batch_all{..}) |
RuntimeCall::Utility(pallet_utility::Call::batch{..})
),
ProxyType::Price => matches!(c, RuntimeCall::Loans(pallet_loans::Call::price { .. })),
ProxyType::Invest => matches!(
c,
RuntimeCall::Investments(pallet_investments::Call::update_invest_order{..}) |
Expand All @@ -646,7 +645,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Investments(pallet_investments::Call::collect_redemptions{..}) |
// Investors should be able to close and execute an epoch
// in order to get their orders fulfilled.
RuntimeCall::Loans(pallet_loans::Call::update_nav{..}) |
RuntimeCall::Loans(pallet_loans_ref::Call::update_portfolio_valuation{..}) |
RuntimeCall::PoolSystem(pallet_pool_system::Call::close_epoch{..}) |
RuntimeCall::PoolSystem(pallet_pool_system::Call::submit_solution{..}) |
RuntimeCall::PoolSystem(pallet_pool_system::Call::execute_epoch{..}) |
Expand Down Expand Up @@ -1467,26 +1466,25 @@ impl pallet_interest_accrual::Config for Runtime {
parameter_types! {
pub const LoansPalletId: PalletId = cfg_types::ids::LOANS_PALLET_ID;
pub const MaxActiveLoansPerPool: u32 = 1000;
pub const MaxWriteOffGroups: u32 = 100;
pub const MaxWriteOffPolicySize: u32 = 100;
}

impl pallet_loans::Config for Runtime {
impl pallet_loans_ref::Config for Runtime {
type Balance = Balance;
type BlockNumberProvider = System;
type ClassId = CollectionId;
type CollectionId = CollectionId;
type CurrencyId = CurrencyId;
type InterestAccrual = InterestAccrual;
type LoanId = ItemId;
type LoansPalletId = LoansPalletId;
type ItemId = ItemId;
type LoanId = LoanId;
type MaxActiveLoansPerPool = MaxActiveLoansPerPool;
type MaxWriteOffGroups = MaxWriteOffGroups;
type MaxWriteOffPolicySize = MaxWriteOffPolicySize;
type NonFungible = Uniques;
type Permission = Permissions;
type Permissions = Permissions;
type Pool = PoolSystem;
type Rate = Rate;
type RuntimeEvent = RuntimeEvent;
type Time = Timestamp;
type WeightInfo = weights::pallet_loans::WeightInfo<Runtime>;
type WeightInfo = weights::pallet_loans_ref::WeightInfo<Self>;
}

parameter_types! {
Expand Down Expand Up @@ -1619,7 +1617,7 @@ construct_runtime!(
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>, Config<T>} = 184,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 185,
Keystore: pallet_keystore::{Pallet, Call, Storage, Event<T>} = 186,
Loans: pallet_loans::{Pallet, Call, Storage, Event<T>} = 187,
Loans: pallet_loans_ref::{Pallet, Call, Storage, Event<T>} = 187,
}
);

Expand Down Expand Up @@ -1786,11 +1784,9 @@ impl_runtime_apis! {
}

fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Rate>{
let now = <pallet_timestamp::Pallet::<Runtime> as UnixTime>::now().as_secs();
let mut pool = pallet_pool_system::Pool::<Runtime>::get(pool_id)?;
let nav: Balance = pallet_loans::Pallet::<Runtime>::update_nav_of_pool(pool_id)
.ok()
.map(|(latest, _)| latest.into())?;
let now = <Timestamp as UnixTime>::now().as_secs();
let mut pool = PoolSystem::pool(pool_id)?;
let nav = Loans::update_nav(pool_id).ok()?;
let total_assets = pool.reserve.total.saturating_add(nav);
let index: usize = pool.tranches.tranche_index(&tranche)?.try_into().ok()?;
let prices = pool
Expand All @@ -1801,11 +1797,9 @@ impl_runtime_apis! {
}

fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Rate>>{
let now = <pallet_timestamp::Pallet::<Runtime> as UnixTime>::now().as_secs();
let mut pool = pallet_pool_system::Pool::<Runtime>::get(pool_id)?;
let nav: Balance = pallet_loans::Pallet::<Runtime>::update_nav_of_pool(pool_id)
.ok()
.map(|(latest, _)| latest.into())?;
let now = <Timestamp as UnixTime>::now().as_secs();
let mut pool = PoolSystem::pool(pool_id)?;
let nav = Loans::update_nav(pool_id).ok()?;
let total_assets = pool.reserve.total.saturating_add(nav);
pool
.tranches
Expand Down Expand Up @@ -1840,7 +1834,6 @@ impl_runtime_apis! {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench;
use pallet_loans::benchmarking::Pallet as LoansPallet;

let mut list = Vec::<BenchmarkList>::new();

Expand Down Expand Up @@ -1869,9 +1862,8 @@ impl_runtime_apis! {
list_benchmark!(list, extra, pallet_interest_accrual, InterestAccrual);
list_benchmark!(list, extra, pallet_uniques, Uniques);
list_benchmark!(list, extra, pallet_keystore, Keystore);
list_benchmark!(list, extra, pallet_loans, LoansPallet::<Runtime>);
list_benchmark!(list, extra, pallet_restricted_tokens, Tokens);

list_benchmark!(list, extra, pallet_loans_ref, Loans);

let storage_info = AllPalletsWithSystem::storage_info();

Expand Down Expand Up @@ -1903,11 +1895,6 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

use pallet_loans::benchmarking::Pallet as LoansPallet;
impl pallet_loans::benchmarking::Config for Runtime {
type IM = Investments;
}

// It should be called Anchors to make the runtime_benchmarks.sh script works
type Anchors = Anchor;

Expand Down Expand Up @@ -1936,8 +1923,8 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_interest_accrual, InterestAccrual);
add_benchmark!(params, batches, pallet_uniques, Uniques);
add_benchmark!(params, batches, pallet_keystore, Keystore);
add_benchmark!(params, batches, pallet_loans, LoansPallet::<Runtime>);
add_benchmark!(params, batches, pallet_restricted_tokens, Tokens);
add_benchmark!(params, batches, pallet_loans_ref, Loans);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down
2 changes: 1 addition & 1 deletion runtime/centrifuge/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod pallet_fees;
pub mod pallet_identity;
pub mod pallet_interest_accrual;
pub mod pallet_keystore;
pub mod pallet_loans;
pub mod pallet_loans_ref;
pub mod pallet_migration_manager;
pub mod pallet_multisig;
pub mod pallet_permissions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-03-09, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `MBP-de-Luis.home`, CPU: `<UNKNOWN>`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("development"), DB CACHE: 1024
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("centrifuge"), DB CACHE: 1024

// Executed Command:
// target/release/centrifuge-chain
// benchmark
// pallet
// --pallet=pallet-loans
// --chain
// development
// centrifuge
// --extrinsic=*
// --output=runtime/development/src/weights/pallet_loans_ref.rs
// --output=runtime/centrifuge/src/weights/pallet_loans_ref.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand Down