Skip to content

Commit

Permalink
fix rate type used in runtime api for pools
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Sep 12, 2023
1 parent 90837d9 commit f5a9d27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ impl_runtime_apis! {
}
}

impl runtime_common::apis::PoolsApi<Block, PoolId, TrancheId, Balance, CurrencyId, Rate, MaxTranches> for Runtime {
impl runtime_common::apis::PoolsApi<Block, PoolId, TrancheId, Balance, CurrencyId, Quantity, MaxTranches> for Runtime {
fn currency(pool_id: PoolId) -> Option<CurrencyId>{
pallet_pool_system::Pool::<Runtime>::get(pool_id).map(|details| details.currency)
}
Expand All @@ -2138,7 +2138,7 @@ impl_runtime_apis! {
).ok()
}

fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Rate>{
fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Quantity>{
let now = <Timestamp as UnixTime>::now().as_secs();
let mut pool = PoolSystem::pool(pool_id)?;
let nav = Loans::update_nav(pool_id).ok()?;
Expand All @@ -2151,14 +2151,14 @@ impl_runtime_apis! {
prices.get(index).cloned()
}

fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Rate>>{
fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Quantity>>{
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
.calculate_prices::<Rate, OrmlTokens, AccountId>(total_assets, now)
.calculate_prices::<_, OrmlTokens, AccountId>(total_assets, now)
.ok()
}

Expand Down
8 changes: 4 additions & 4 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ impl_runtime_apis! {
}

// PoolsApi
impl runtime_common::apis::PoolsApi<Block, PoolId, TrancheId, Balance, CurrencyId, Rate, MaxTranches> for Runtime {
impl runtime_common::apis::PoolsApi<Block, PoolId, TrancheId, Balance, CurrencyId, Quantity, MaxTranches> for Runtime {
fn currency(pool_id: PoolId) -> Option<CurrencyId>{
pallet_pool_system::Pool::<Runtime>::get(pool_id).map(|details| details.currency)
}
Expand All @@ -2204,7 +2204,7 @@ impl_runtime_apis! {
).ok()
}

fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Rate>{
fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Quantity>{
let now = <Timestamp as UnixTime>::now().as_secs();
let mut pool = PoolSystem::pool(pool_id)?;
let nav = Loans::update_nav(pool_id).ok()?;
Expand All @@ -2217,14 +2217,14 @@ impl_runtime_apis! {
prices.get(index).cloned()
}

fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Rate>>{
fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Quantity>>{
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
.calculate_prices::<Rate, Tokens, AccountId>(total_assets, now)
.calculate_prices::<_, Tokens, AccountId>(total_assets, now)
.ok()
}

Expand Down
8 changes: 4 additions & 4 deletions runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ impl_runtime_apis! {
}

// PoolsApi
impl runtime_common::apis::PoolsApi<Block, PoolId, TrancheId, Balance, CurrencyId, Rate, MaxTranches> for Runtime {
impl runtime_common::apis::PoolsApi<Block, PoolId, TrancheId, Balance, CurrencyId, Quantity, MaxTranches> for Runtime {
fn currency(pool_id: PoolId) -> Option<CurrencyId>{
pallet_pool_system::Pool::<Runtime>::get(pool_id).map(|details| details.currency)
}
Expand All @@ -2224,7 +2224,7 @@ impl_runtime_apis! {
).ok()
}

fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Rate>{
fn tranche_token_price(pool_id: PoolId, tranche: TrancheLoc<TrancheId>) -> Option<Quantity>{
let now = <Timestamp as UnixTime>::now().as_secs();
let mut pool = PoolSystem::pool(pool_id)?;
let nav = Loans::update_nav(pool_id).ok()?;
Expand All @@ -2237,14 +2237,14 @@ impl_runtime_apis! {
prices.get(index).cloned()
}

fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Rate>>{
fn tranche_token_prices(pool_id: PoolId) -> Option<Vec<Quantity>>{
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
.calculate_prices::<Rate, OrmlTokens, AccountId>(total_assets, now)
.calculate_prices::<_, OrmlTokens, AccountId>(total_assets, now)
.ok()
}

Expand Down

0 comments on commit f5a9d27

Please sign in to comment.