From 814058bb369c7f4fb8e762737f1c11f56822fc5b Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 13 Dec 2024 12:53:11 -0800 Subject: [PATCH] remove prints --- crates/hyperdrive-math/src/short/max.rs | 35 +++---------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/crates/hyperdrive-math/src/short/max.rs b/crates/hyperdrive-math/src/short/max.rs index ecc95aeb..c9cdfd36 100644 --- a/crates/hyperdrive-math/src/short/max.rs +++ b/crates/hyperdrive-math/src/short/max.rs @@ -538,19 +538,11 @@ impl State { )? .change_type::()?; let mut last_good_bond_amount = self.absolute_max_short_guess(checkpoint_exposure)?; - println!("max short guess {:#?}", last_good_bond_amount); - for iter in 0..max_iterations { - println!(""); - println!("iter {:#?}", iter); - println!("last_good_bond_amount {:#?}", last_good_bond_amount); + for _ in 0..max_iterations { // Return if we are within tolerance bonds of insolvency. let solvency_within_tolerance = self .solvency_after_short(last_good_bond_amount + bond_tolerance, checkpoint_exposure); if solvency_within_tolerance.is_err() { - println!( - "RETURNING bonds {:#?}; solvency {:#?}", - last_good_bond_amount, solvency_within_tolerance - ); return Ok(last_good_bond_amount); } @@ -559,21 +551,12 @@ impl State { - self .calculate_pool_share_delta_after_open_short(last_good_bond_amount)? .change_type::()?; - println!( - "target_pool_shares {:#?}; current_pool_shares {:#?}", - target_pool_shares, current_pool_shares - ); // The loss function is z_t - z, and its derivative is -dz/dy. let loss = target_pool_shares - current_pool_shares; let loss_derivative = -self.calculate_pool_delta_shares_after_short_derivative(last_good_bond_amount)?; let dy = loss.div_up(loss_derivative); - println!( - "loss {:#?}; loss_derivative {:#?}; dy {:#?}", - loss, loss_derivative, dy - ); - // Bond amount must increase. // Negative dy indicates that the bond amount would go up with a // proper step of Newton's Method. @@ -594,14 +577,10 @@ impl State { // Calculate the current solvency & iterate w/ a good bond amount. last_good_bond_amount = match self.solvency_after_short(new_bond_amount, checkpoint_exposure) { - Ok(solvency) => { - println!("iterating; solvency {:#?}", solvency); - new_bond_amount - } + Ok(solvency) => new_bond_amount, // New bond amount is too large. Use a binary search to find a // new starting point. Err(_) => { - println!("new_bond_amount={:#?} is not solvent", new_bond_amount); // Start from halfway between the new bond amount and the // last good bond amount. let mut return_amount = new_bond_amount @@ -612,10 +591,6 @@ impl State { .solvency_after_short(return_amount, checkpoint_exposure) .is_ok() { - println!( - "BINARY SEARCH: return_amount {:#?} in {:#?} iterations", - return_amount, num_tries - ); break return_amount; } // Return amount is still too large, try again. @@ -625,7 +600,6 @@ impl State { // Avoid running forever by returning a guaranteed good // bond amount. if num_tries >= 100_000 { - println!("GIVE UP BINARY SEARCH after {:#?} iterations", num_tries); break last_good_bond_amount * fixed!(0.99e18); } } @@ -1174,10 +1148,7 @@ mod tests { let max_iterations = 100; // Run the fuzz tests let mut rng = thread_rng(); - for iter in 0..*FAST_FUZZ_RUNS { - println!(""); - println!("-----"); - println!("iter {:#?}", iter); + for _ in 0..*FAST_FUZZ_RUNS { let state = rng.gen::(); let checkpoint_exposure = { let value = rng.gen_range(fixed!(0)..=FixedPoint::from(U256::from(U128::MAX)));