NexusMutual / cover-router

Computes optimal capacity allocation per Nexus Mutual staking pool on cover purchase
MIT License
1 stars 1 forks source link

Change the way that max premium is calculated #81

Closed MilGard91 closed 3 months ago

MilGard91 commented 3 months ago

Context

Issue: #79

Changes proposed in this pull request

Test plan

Please describe the tests cases that you ran to verify your changes. Add further instructions on how to run them if needed (i.e. migration / deployment scripts, env vars, etc).

Checklist

Review

When reviewing a PR, please indicate intention in comments using the following emojis:

MilGard91 commented 3 months ago

Fixed the max premium calculation by extracting the productData reducer and using it to calculate the product data for next five tranches (4 - tranches 364 days, and max premium is 365 so just in case added one more iteration). Finding the max premium while iterating and also the capacity data for the requested period. All of this is skipped if the product has fixed price and calculating everything just for a requested period.