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

Change premium calculation formula to linear pricing #116

Merged
merged 1 commit into from
Jul 19, 2024
Merged
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
9 changes: 3 additions & 6 deletions src/azns_fee_calculator/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ mod azns_fee_calculator {
.get(name.len() as Length)
.unwrap_or(self.common_price);

let mut premium = 0;
for year in 2..=duration {
premium += (year as u128) * base_price;
}
let premium = (duration as u128 - 1) * base_price;

Ok((base_price, premium))
}
Expand Down Expand Up @@ -228,13 +225,13 @@ mod azns_fee_calculator {
// Duration: 2
assert_eq!(
contract.get_name_price(name.clone(), 2),
Ok((6_u128 * 10_u128.pow(12), 12_u128 * 10_u128.pow(12)))
Ok((6_u128 * 10_u128.pow(12), 6_u128 * 10_u128.pow(12)))
);

// Duration: 3
assert_eq!(
contract.get_name_price(name.clone(), 3),
Ok((6_u128 * 10_u128.pow(12), 30_u128 * 10_u128.pow(12)))
Ok((6_u128 * 10_u128.pow(12), 12_u128 * 10_u128.pow(12)))
);

// Duration: 4
Expand Down
Loading