Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [

[workspace.package]
name = "hyperdrive-rs"
version = "0.20.0"
version = "0.20.1"
authors = [
"Alex Towle <alex@delv.tech>",
"Dylan Paiton <dylan@delv.tech>",
Expand All @@ -29,9 +29,9 @@ repository = "https://github.com/delvtech/hyperdrive-rs"
description = "API for simulating Hyperdrive smart contract transactions."

[workspace.dependencies]
fixedpointmath = { version = "0.20.0", path="crates/fixedpointmath" }
hyperdrive-wrappers = { version = "0.20.0", path="crates/hyperdrive-wrappers" }
hyperdrive-math = { version = "0.20.0", path="crates/hyperdrive-math" }
fixedpointmath = { version = "0.20.1", path="crates/fixedpointmath" }
hyperdrive-wrappers = { version = "0.20.1", path="crates/hyperdrive-wrappers" }
hyperdrive-math = { version = "0.20.1", path="crates/hyperdrive-math" }

[workspace.lints.clippy]
comparison_chain = "allow"
Expand Down
4 changes: 0 additions & 4 deletions bindings/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ def calculate_max_short(
pool_info: types.PoolInfoType,
budget: str,
open_vault_share_price: str,
checkpoint_exposure: str,
maybe_conservative_price: str | None,
maybe_max_iterations: int | None,
) -> str:
Expand All @@ -575,8 +574,6 @@ def calculate_max_short(
The account budget in base for making a short.
open_vault_share_price: str (FixedPoint)
The share price of underlying vault.
checkpoint_exposure: str (FixedPoint)
The net exposure for the given checkpoint.
maybe_conservative_price: str (FixedPoint), optional
A lower bound on the realized price that the short will pay.
maybe_max_iterations: int, optional
Expand All @@ -590,7 +587,6 @@ def calculate_max_short(
return _get_interface(pool_config, pool_info).calculate_max_short(
budget,
open_vault_share_price,
checkpoint_exposure,
maybe_conservative_price,
maybe_max_iterations,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ impl HyperdriveState {
&self,
budget: &str,
open_vault_share_price: &str,
checkpoint_exposure: &str,
maybe_conservative_price: Option<&str>,
maybe_max_iterations: Option<usize>,
) -> PyResult<String> {
Expand All @@ -27,12 +26,6 @@ impl HyperdriveState {
open_vault_share_price, err
))
})?);
let checkpoint_exposure_i = I256::from_dec_str(checkpoint_exposure).map_err(|err| {
PyErr::new::<PyValueError, _>(format!(
"Failed to convert checkpoint_exposure string {} to I256: {}",
checkpoint_exposure, err
))
})?;
let maybe_conservative_price_fp = if let Some(conservative_price) = maybe_conservative_price
{
Some(FixedPoint::from(
Expand All @@ -51,7 +44,6 @@ impl HyperdriveState {
.calculate_max_short(
budget_fp,
open_vault_share_price_fp,
checkpoint_exposure_i,
maybe_conservative_price_fp,
maybe_max_iterations,
)
Expand Down
6 changes: 0 additions & 6 deletions bindings/hyperdrivepy/tests/wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,13 @@ def test_max_short():
# test using the state directly
budget = str(int(10 * 10**18)) # 10k base
open_vault_share_price = str(int(1 * 10**18)) # 1 base
checkpoint_exposure = str(0)
conservative_price = None
max_iterations = 20
max_short = hyperdrivepy.calculate_max_short(
POOL_CONFIG,
POOL_INFO,
budget,
open_vault_share_price,
checkpoint_exposure,
conservative_price,
max_iterations,
)
Expand All @@ -347,7 +345,6 @@ def test_max_short():
def test_max_short_fail_conversion():
"""Test calculate_max_short."""
open_vault_share_price = str(int(1 * 10**18)) # 1 base
checkpoint_exposure = str(0)
conservative_price = None
max_iterations = 20
# bad string inputs
Expand All @@ -358,7 +355,6 @@ def test_max_short_fail_conversion():
POOL_INFO,
budget,
open_vault_share_price,
checkpoint_exposure,
conservative_price,
max_iterations,
)
Expand All @@ -369,7 +365,6 @@ def test_max_short_fail_conversion():
POOL_INFO,
budget,
open_vault_share_price,
checkpoint_exposure,
conservative_price,
max_iterations,
)
Expand All @@ -381,7 +376,6 @@ def test_max_short_fail_conversion():
POOL_INFO,
budget,
open_vault_share_price,
checkpoint_exposure,
conservative_price,
max_iterations,
)
Expand Down
8 changes: 8 additions & 0 deletions crates/hyperdrive-math/src/long/max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ impl State {
}
let share_reserves = (self.share_reserves() + share_amount) - governance_fee_shares;
let exposure = self.long_exposure() + bond_amount;
// Netting allows us to remove any negative checkpoint exposure from the
// long exposure.
let checkpoint_exposure = FixedPoint::try_from(-checkpoint_exposure.min(int256!(0)))?;
if share_reserves + checkpoint_exposure / self.vault_share_price()
>= exposure / self.vault_share_price() + self.minimum_share_reserves()
Expand Down Expand Up @@ -619,6 +621,12 @@ mod tests {
// Bob opens a max long.
let max_spot_price = bob.get_state().await?.calculate_max_spot_price()?;
let max_long = bob.calculate_max_long(None).await?;
let state = alice.get_state().await?;
// Ensure max long is valid.
if state.calculate_open_long(max_long).is_err() {
continue;
}
// Get the andicipated spot price & open the log.
let spot_price_after_long = bob
.get_state()
.await?
Expand Down
Loading
Loading