Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Update hyperdrivepy to v1.0.4, which updates to hyperdrive v1.0.3 #100

Merged
merged 4 commits into from
Apr 25, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/checkout@master
with:
repository: delvtech/hyperdrive
ref: "v1.0.2"
ref: "v1.0.3"
path: "./hyperdrive"
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }}

Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
uses: actions/checkout@master
with:
repository: delvtech/hyperdrive
ref: "v1.0.2"
ref: "v1.0.3"
path: "./hyperdrive"
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@master
with:
repository: delvtech/hyperdrive
ref: "v1.0.2"
ref: "v1.0.3"
path: "./hyperdrive"
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@master
with:
repository: delvtech/hyperdrive
ref: "v1.0.2"
ref: "v1.0.3"
path: "./hyperdrive"
ssh-key: ${{ secrets.HYPERDRIVE_ACCESS_KEY }}

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/hyperdrivepy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hyperdrivepy"
edition = "2021"
version = "1.0.3"
version = "1.0.4"
authors = [
"Dylan Paiton",
"Matt Brown",
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperdrivepy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hyperdrivepy"
version = "1.0.3"
version = "1.0.4"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
Expand Down
5 changes: 1 addition & 4 deletions crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def calculate_open_short(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
short_amount: str,
spot_price: str,
open_vault_share_price: str | None = None,
) -> str:
"""Gets the amount of base the trader will need to deposit for a short of a given size.
Expand All @@ -268,8 +267,6 @@ def calculate_open_short(
Includes attributes like reserve levels and share prices.
short_amount: str (FixedPoint)
The amount to of bonds to short.
spot_price: str (FixedPoint)
The pool's current price for bonds.
open_vault_share_price: str (FixedPoint) | None, optional
Optionally provide the open share price for the short.
If this is not provided or is None, then we will use the pool's current share price.
Expand All @@ -283,7 +280,7 @@ def calculate_open_short(
# the underlying rust code uses current market share price if this is 0
# zero value is used because the smart contract will return 0 if the checkpoint hasn't been minted
open_vault_share_price = "0"
return _get_interface(pool_config, pool_info).calculate_open_short(short_amount, spot_price, open_vault_share_price)
return _get_interface(pool_config, pool_info).calculate_open_short(short_amount, open_vault_share_price)


def calculate_close_short(
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperdrivepy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="hyperdrivepy",
version="1.0.3",
version="1.0.4",
packages=["hyperdrivepy"],
package_dir={"": "python"},
rust_extensions=[
Expand Down
6 changes: 1 addition & 5 deletions crates/hyperdrivepy/src/hyperdrive_state_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,11 @@ impl HyperdriveState {
pub fn calculate_open_short(
&self,
short_amount: &str,
spot_price: &str,
open_vault_share_price: &str,
) -> PyResult<String> {
let short_amount_fp = FixedPoint::from(U256::from_dec_str(short_amount).map_err(|_| {
PyErr::new::<PyValueError, _>("Failed to convert short_amount string to U256")
})?);
let spot_price_fp = FixedPoint::from(U256::from_dec_str(spot_price).map_err(|_| {
PyErr::new::<PyValueError, _>("Failed to convert spot_price string to U256")
})?);
let open_vault_share_price_fp =
FixedPoint::from(U256::from_dec_str(open_vault_share_price).map_err(|_| {
PyErr::new::<PyValueError, _>(
Expand All @@ -172,7 +168,7 @@ impl HyperdriveState {
})?);
let result_fp = self
.state
.calculate_open_short(short_amount_fp, spot_price_fp, open_vault_share_price_fp)
.calculate_open_short(short_amount_fp, open_vault_share_price_fp)
.unwrap();
let result = U256::from(result_fp).to_string();
return Ok(result);
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hyperdrivepy"
version = "1.0.3"
version = "1.0.4"
authors = [
{ name = "Dylan Paiton", email = "dylan@delv.tech" },
{ name = "Matthew Brown", email = "matt@delv.tech" },
Expand Down
9 changes: 3 additions & 6 deletions system_tests/wrapper_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,15 @@ def test_calculate_close_long():
def test_calculate_open_short():
"""Test for calculate_open_short."""
short_amount = str(50 * 10**18)
spot_price = hyperdrivepy.calculate_spot_price(POOL_CONFIG, POOL_INFO)
open_vault_share_price = str(9 * 10**17)
base_required = hyperdrivepy.calculate_open_short(
POOL_CONFIG, POOL_INFO, short_amount, spot_price, open_vault_share_price
)
base_required = hyperdrivepy.calculate_open_short(POOL_CONFIG, POOL_INFO, short_amount, open_vault_share_price)
assert int(base_required) > 0
base_required_default_vault_share_price = hyperdrivepy.calculate_open_short(
POOL_CONFIG, POOL_INFO, short_amount, spot_price, None
POOL_CONFIG, POOL_INFO, short_amount, None
)
assert int(base_required_default_vault_share_price) > 0
assert base_required_default_vault_share_price == hyperdrivepy.calculate_open_short(
POOL_CONFIG, POOL_INFO, short_amount, spot_price, "0"
POOL_CONFIG, POOL_INFO, short_amount, "0"
)


Expand Down
Loading