Skip to content

Commit 9af83c8

Browse files
committed
use conservative price fn
1 parent d59683e commit 9af83c8

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

crates/hyperdrive-math/src/test_utils/preamble.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,10 @@ pub fn get_max_short(
134134
maybe_max_num_tries: Option<usize>,
135135
) -> Result<FixedPoint<U256>> {
136136
let max_num_tries = maybe_max_num_tries.unwrap_or(10);
137-
138137
// We linearly interpolate between the current spot price and the minimum
139138
// price that the pool can support. This is a conservative estimate of
140139
// the short's realized price.
141-
let conservative_price = {
142-
// We estimate the minimum price that short will pay by a
143-
// weighted average of the spot price and the minimum possible
144-
// spot price the pool can quote. We choose the weights so that this
145-
// is an underestimate of the worst case realized price.
146-
let spot_price = state.calculate_spot_price()?;
147-
let min_price = state.calculate_min_spot_price()?;
148-
149-
// Calculate the linear interpolation.
150-
let weight = fixed!(1e18).pow(fixed!(1e18) - state.time_stretch())?;
151-
spot_price * (fixed!(1e18) - weight) + min_price * weight
152-
};
153-
140+
let conservative_price = state.calculate_conservative_short_price(fixed!(1e18))?;
154141
// Compute the max short.
155142
let mut max_short = match panic::catch_unwind(|| {
156143
state.calculate_max_short(

0 commit comments

Comments
 (0)