Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: penalty remainder #111

Merged
merged 2 commits into from
Sep 26, 2024
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
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.