pub fn calculate_rate_given_fixed_price(
price: FixedPoint<U256>,
position_duration: FixedPoint<U256>,
) -> FixedPoint<U256>Expand description
Calculate the rate assuming a given price is constant for some annualized duration.
We calculate the rate for a fixed length of time as:
r = \frac{(1 - p)}{p \cdot t}where $p$ is the price and $t$ is the length of time that this price is
assumed to be constant, in units of years. For example, if the price is
constant for 6 months, then $t=0.5$.
In our case, $t = \text{position_duration} / (60*60*24*365)$.