Skip to content

Commit 385f212

Browse files
committed
Allow non-incremental farming rewards
1 parent 7663d7f commit 385f212

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

pallets/loans/src/lib.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ impl<T: Config> Pallet<T> {
14251425
Self::update_reward_supply_index(asset_id)?;
14261426
Self::distribute_supplier_reward(asset_id, who)?;
14271427

1428-
let exchange_rate = Self::exchange_rate_stored(asset_id)?;
1428+
let exchange_rate: FixedU128 = Self::exchange_rate_stored(asset_id)?;
14291429
let redeem_amount = Self::calc_underlying_amount(voucher_amount, exchange_rate)?;
14301430

14311431
AccountDeposits::<T>::try_mutate_exists(asset_id, who, |deposits| -> DispatchResult {
@@ -1538,11 +1538,16 @@ impl<T: Config> Pallet<T> {
15381538
) -> DispatchResult {
15391539
let deposits = AccountDeposits::<T>::get(asset_id, who);
15401540
let account_earned = AccountEarned::<T>::get(asset_id, who);
1541-
let total_earned_prior_new = exchange_rate
1542-
.checked_sub(&account_earned.exchange_rate_prior)
1543-
.and_then(|r| r.checked_mul_int(deposits.voucher_balance))
1544-
.and_then(|r| r.checked_add(account_earned.total_earned_prior))
1545-
.ok_or(ArithmeticError::Overflow)?;
1541+
1542+
let total_earned_prior_new = if exchange_rate >= account_earned.exchange_rate_prior {
1543+
exchange_rate
1544+
.checked_sub(&account_earned.exchange_rate_prior)
1545+
.and_then(|delta| delta.checked_mul_int(deposits.voucher_balance))
1546+
.and_then(|result| result.checked_add(account_earned.total_earned_prior))
1547+
.ok_or(ArithmeticError::Overflow)?
1548+
} else {
1549+
account_earned.total_earned_prior
1550+
};
15461551

15471552
AccountEarned::<T>::insert(
15481553
asset_id,

runtime/heiko/src/lib.rs

+1-1
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: 208,
184184
impl_version: 33,
185185
apis: RUNTIME_API_VERSIONS,
186186
transaction_version: 17,

runtime/kerria/src/lib.rs

+1-1
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: 208,
184184
impl_version: 33,
185185
apis: RUNTIME_API_VERSIONS,
186186
transaction_version: 17,

runtime/parallel/src/lib.rs

+1-1
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: 208,
189189
impl_version: 33,
190190
apis: RUNTIME_API_VERSIONS,
191191
transaction_version: 17,

runtime/vanilla/src/lib.rs

+1-1
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: 208,
184184
impl_version: 33,
185185
apis: RUNTIME_API_VERSIONS,
186186
transaction_version: 17,

scripts/collator.sh

+1-1
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.0.8"
2424
BASE_PATH="/data"
2525

2626
if [ $# -lt 3 ]; then

0 commit comments

Comments
 (0)