Skip to content

Commit

Permalink
fix: penalty remainder (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
VladasZ authored Sep 26, 2024
1 parent 030d5bf commit 77d7650
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions contract/src/jar/model/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ impl JarLastVersion {
"Applying penalty is not supported for score based jars"
);

let current_interest = self.get_interest(&[], product, now).0;
let (interest, remainder) = self.get_interest(&[], product, now);

self.claim_remainder = remainder;

self.cache = Some(JarCache {
updated_at: now,
interest: current_interest,
interest,
});
self.is_penalty_applied = is_applied;
}
Expand Down
6 changes: 3 additions & 3 deletions contract/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn get_total_interest_for_premium_with_multiple_penalties_applied() {
context.set_block_timestamp_in_ms(3_700_000);

let interest = context.contract().get_total_interest(alice.clone()).amount.total.0;
assert_eq!(interest, 1_613_140_537_798_072_042);
assert_eq!(interest, 1_613_140_537_798_072_044);
}

#[test]
Expand Down Expand Up @@ -344,10 +344,10 @@ fn apply_penalty_in_batch() {
context.set_block_timestamp_in_days(365);

let interest = context.contract().get_total_interest(alice.clone()).amount.total.0;
assert_eq!(interest, 1_498_630_000);
assert_eq!(interest, 1_498_630_100);

let interest = context.contract().get_total_interest(bob.clone()).amount.total.0;
assert_eq!(interest, 749_315_000);
assert_eq!(interest, 749_315_050);

let alice_jars = context.contract().get_jars_for_account(alice);
let bob_jars = context.contract().get_jars_for_account(bob);
Expand Down
Binary file modified res/sweat_jar.wasm
Binary file not shown.

0 comments on commit 77d7650

Please sign in to comment.