Skip to content

Commit 8238d52

Browse files
committed
2 parents 18816f1 + d56e95b commit 8238d52

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

pallets/loans/src/interest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ impl<T: Config> Pallet<T> {
151151
Ok(Ratio::from_rational(borrows, total))
152152
}
153153

154-
/// The exchange rate should be greater than 0.02 and less than 1
154+
/// The exchange rate should be greater than 0.015 and less than 1
155155
pub(crate) fn ensure_valid_exchange_rate(exchange_rate: Rate) -> DispatchResult {
156156
ensure!(
157-
exchange_rate >= Rate::from_inner(MIN_EXCHANGE_RATE)
157+
exchange_rate >= Rate::from_inner(MIN_VALID_EXCHANGE_RATE)
158158
&& exchange_rate < Rate::from_inner(MAX_EXCHANGE_RATE),
159159
Error::<T>::InvalidExchangeRate
160160
);

pallets/loans/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub const MIN_INTEREST_CALCULATING_INTERVAL: u64 = 100; // 100 seconds
8080

8181
pub const MAX_EXCHANGE_RATE: u128 = 1_000_000_000_000_000_000; // 1
8282
pub const MIN_EXCHANGE_RATE: u128 = 20_000_000_000_000_000; // 0.02
83+
pub const MIN_VALID_EXCHANGE_RATE: u128 = 15_000_000_000_000_000; // 0.015
8384

8485
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
8586
type AssetIdOf<T> =
@@ -1470,7 +1471,7 @@ impl<T: Config> Pallet<T> {
14701471
Self::update_reward_supply_index(asset_id)?;
14711472
Self::distribute_supplier_reward(asset_id, who)?;
14721473

1473-
let exchange_rate = Self::exchange_rate_stored(asset_id)?;
1474+
let exchange_rate: FixedU128 = Self::exchange_rate_stored(asset_id)?;
14741475
let redeem_amount = Self::calc_underlying_amount(voucher_amount, exchange_rate)?;
14751476

14761477
AccountDeposits::<T>::try_mutate_exists(asset_id, who, |deposits| -> DispatchResult {
@@ -1583,11 +1584,16 @@ impl<T: Config> Pallet<T> {
15831584
) -> DispatchResult {
15841585
let deposits = AccountDeposits::<T>::get(asset_id, who);
15851586
let account_earned = AccountEarned::<T>::get(asset_id, who);
1586-
let total_earned_prior_new = exchange_rate
1587-
.checked_sub(&account_earned.exchange_rate_prior)
1588-
.and_then(|r| r.checked_mul_int(deposits.voucher_balance))
1589-
.and_then(|r| r.checked_add(account_earned.total_earned_prior))
1590-
.ok_or(ArithmeticError::Overflow)?;
1587+
1588+
let total_earned_prior_new = if exchange_rate >= account_earned.exchange_rate_prior {
1589+
exchange_rate
1590+
.checked_sub(&account_earned.exchange_rate_prior)
1591+
.and_then(|delta| delta.checked_mul_int(deposits.voucher_balance))
1592+
.and_then(|result| result.checked_add(account_earned.total_earned_prior))
1593+
.ok_or(ArithmeticError::Overflow)?
1594+
} else {
1595+
account_earned.total_earned_prior
1596+
};
15911597

15921598
AccountEarned::<T>::insert(
15931599
asset_id,

runtime/heiko/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
180180
spec_name: create_runtime_str!("heiko"),
181181
impl_name: create_runtime_str!("heiko"),
182182
authoring_version: 1,
183-
spec_version: 207,
183+
spec_version: 210,
184184
impl_version: 33,
185185
apis: RUNTIME_API_VERSIONS,
186186
transaction_version: 17,

runtime/kerria/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
180180
spec_name: create_runtime_str!("kerria"),
181181
impl_name: create_runtime_str!("kerria"),
182182
authoring_version: 1,
183-
spec_version: 207,
183+
spec_version: 210,
184184
impl_version: 33,
185185
apis: RUNTIME_API_VERSIONS,
186186
transaction_version: 17,

runtime/parallel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
185185
spec_name: create_runtime_str!("parallel"),
186186
impl_name: create_runtime_str!("parallel"),
187187
authoring_version: 1,
188-
spec_version: 207,
188+
spec_version: 210,
189189
impl_version: 33,
190190
apis: RUNTIME_API_VERSIONS,
191191
transaction_version: 17,

runtime/vanilla/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
180180
spec_name: create_runtime_str!("vanilla"),
181181
impl_name: create_runtime_str!("vanilla"),
182182
authoring_version: 1,
183-
spec_version: 207,
183+
spec_version: 210,
184184
impl_version: 33,
185185
apis: RUNTIME_API_VERSIONS,
186186
transaction_version: 17,

scripts/collator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ VOLUME="chains"
2020
NODE_KEY="$1"
2121
KEYSTORE_PATH="$2"
2222
NODE_NAME="$3"
23-
DOCKER_IMAGE="parallelfinance/parallel:v2.0.7"
23+
DOCKER_IMAGE="parallelfinance/parallel:v2.1.0"
2424
BASE_PATH="/data"
2525

2626
if [ $# -lt 3 ]; then

0 commit comments

Comments
 (0)