Skip to content

fix(insurance): fix duplicate function and u128/u32 type mismatch in premium_engine.rs #434

@nanaf6203-bit

Description

@nanaf6203-bit

Problem

contracts/insurance/src/premium_engine.rs had multiple compilation errors:

  1. Duplicate function namecalculate_adjustment_amount was defined twice with different arities. Rust does not support function overloading.

  2. u128 / u32 divisionBASIS_POINTS_DENOMINATOR was declared as u32 but used as a divisor for u128 expressions throughout the file. Rust requires matching types for division.

  3. Ambiguous integer typebase_deductible_rate and risk_adjustment were untyped integer literals, causing E0689 when calling .saturating_add().

  4. Wrong argument count — call sites passed 4 or 6 args to calculate_adjustment_amount which expected 5.

  5. Option<ActuarialModel> vs Option<&ActuarialModel>calculate_dynamic_premium expects a reference but was passed an owned Option.

Fix

  • Renamed the two overloaded functions to calculate_coverage_adjustment_amount, calculate_pool_adjustment_amount, calculate_time_adjustment_amount.
  • Changed BASIS_POINTS_DENOMINATOR from u32 to u128.
  • Added explicit u128 type annotations to ambiguous literals.
  • Updated all call sites.
  • Added .as_ref() at the call site in lib.rs.

Affected files

  • contracts/insurance/src/premium_engine.rs
  • contracts/insurance/src/lib.rs

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions