Skip to content

Commit

Permalink
feat: change premium calculation formula to linear (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
realnimish committed Jul 19, 2024
1 parent baa6db8 commit 64a1730
Showing 1 changed file with 3 additions and 6 deletions.
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

0 comments on commit 64a1730

Please sign in to comment.