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

Commit

Permalink
Hyperdrive v0.13.0 (#88)
Browse files Browse the repository at this point in the history
Includes version bump of hyperdrivepy to v0.13.0
  • Loading branch information
slundqui authored Apr 8, 2024
1 parent 7c0ec7e commit 19c5701
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 149 deletions.
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: "v0.11.0"
ref: "v0.13.0"
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: "v0.11.0"
ref: "v0.13.0"
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: "v0.11.0"
ref: "v0.13.0"
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: "v0.11.0"
ref: "v0.13.0"
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 = "0.11.0"
version = "0.13.0"
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 = "0.11.0"
version = "0.13.0"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
Expand Down
44 changes: 24 additions & 20 deletions crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# pylint: disable=too-many-arguments


def get_max_spot_price(
def calculate_max_spot_price(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
) -> str:
Expand All @@ -29,10 +29,10 @@ def get_max_spot_price(
str (FixedPoint)
max_spot_price = 1/1 + curve_fee * (1 / (spot_price - 1))
"""
return _get_interface(pool_config, pool_info).get_max_spot_price()
return _get_interface(pool_config, pool_info).calculate_max_spot_price()


def get_spot_price_after_long(
def calculate_spot_price_after_long(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
long_amount: str,
Expand All @@ -56,10 +56,10 @@ def get_spot_price_after_long(
str (FixedPoint)
The spot price after opening the long.
"""
return _get_interface(pool_config, pool_info).get_spot_price_after_long(long_amount)
return _get_interface(pool_config, pool_info).calculate_spot_price_after_long(long_amount)


def get_solvency(
def calculate_solvency(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
) -> str:
Expand All @@ -79,10 +79,10 @@ def get_solvency(
str (FixedPoint)
solvency = share_reserves - long_exposure / vault_share_price - minimum_share_reserves
"""
return _get_interface(pool_config, pool_info).get_solvency()
return _get_interface(pool_config, pool_info).calculate_solvency()


def get_spot_rate(
def calculate_spot_rate(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
) -> str:
Expand All @@ -102,10 +102,10 @@ def get_spot_rate(
str (FixedPoint)
The pool's spot rate.
"""
return _get_interface(pool_config, pool_info).get_spot_rate()
return _get_interface(pool_config, pool_info).calculate_spot_rate()


def get_spot_price(
def calculate_spot_price(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
) -> str:
Expand All @@ -125,7 +125,7 @@ def get_spot_price(
str (FixedPoint)
The pool's spot price.
"""
return _get_interface(pool_config, pool_info).get_spot_price()
return _get_interface(pool_config, pool_info).calculate_spot_price()


def calculate_open_long(
Expand Down Expand Up @@ -158,7 +158,8 @@ def calculate_close_long(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
bond_amount: str,
normalized_time_remaining: str,
maturity_time: str,
current_time: str,
) -> str:
"""Calculates the amount of shares that will be returned after fees for closing a long.
Expand All @@ -172,15 +173,17 @@ def calculate_close_long(
Includes attributes like reserve levels and share prices.
bond_amount: str (FixedPoint)
The amount of bonds to sell.
normalized_time_remaining: str (FixedPoint)
The time remaining before the long reaches maturity, normalized such that 1 is at opening and 0 is at maturity.
maturity_time: str (FixedPoint)
The maturity time of the long.
current_time: str (FixedPoint)
The current block time.
Returns
-------
str (FixedPoint)
The amount of shares returned.
"""
return _get_interface(pool_config, pool_info).calculate_close_long(bond_amount, normalized_time_remaining)
return _get_interface(pool_config, pool_info).calculate_close_long(bond_amount, maturity_time, current_time)


def calculate_open_short(
Expand Down Expand Up @@ -226,7 +229,8 @@ def calculate_close_short(
bond_amount: str,
open_vault_share_price: str,
close_vault_share_price: str,
normalized_time_remaining: str,
maturity_time: str,
current_time: str,
) -> str:
"""Gets the amount of shares the trader will receive from closing a short.
Expand All @@ -253,7 +257,7 @@ def calculate_close_short(
The amount of shares the trader will receive for closing the short.
"""
return _get_interface(pool_config, pool_info).calculate_close_short(
bond_amount, open_vault_share_price, close_vault_share_price, normalized_time_remaining
bond_amount, open_vault_share_price, close_vault_share_price, maturity_time, current_time
)


Expand Down Expand Up @@ -283,7 +287,7 @@ def to_checkpoint(
return _get_interface(pool_config, pool_info).to_checkpoint(time)


def get_max_long(
def calculate_max_long(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
budget: str,
Expand Down Expand Up @@ -312,10 +316,10 @@ def get_max_long(
str (FixedPoint)
The maximum long the pool and user's wallet can support.
"""
return _get_interface(pool_config, pool_info).get_max_long(budget, checkpoint_exposure, maybe_max_iterations)
return _get_interface(pool_config, pool_info).calculate_max_long(budget, checkpoint_exposure, maybe_max_iterations)


def get_max_short(
def calculate_max_short(
pool_config: types.PoolConfigType,
pool_info: types.PoolInfoType,
budget: str,
Expand Down Expand Up @@ -350,7 +354,7 @@ def get_max_short(
str (FixedPoint)
The maximum short the pool and user's wallet can handle.
"""
return _get_interface(pool_config, pool_info).get_max_short(
return _get_interface(pool_config, pool_info).calculate_max_short(
budget,
open_vault_share_price,
checkpoint_exposure,
Expand Down
8 changes: 4 additions & 4 deletions crates/hyperdrivepy/python/hyperdrivepy/hyperdrive_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from . import hyperdrivepy as rust_module # type: ignore


def get_time_stretch(rate: str, position_duration: str) -> str:
def calculate_time_stretch(rate: str, position_duration: str) -> str:
"""Calculate the time stretch parameter given a pool's spot rate.
..math::
Expand All @@ -24,10 +24,10 @@ def get_time_stretch(rate: str, position_duration: str) -> str:
time_stretch: str (FixedPoint)
The time stretch parameter (tau).
"""
return rust_module.get_time_stretch(rate, position_duration)
return rust_module.calculate_time_stretch(rate, position_duration)


def get_effective_share_reserves(
def calculate_effective_share_reserves(
share_reserves: str,
share_adjustment: str,
) -> str:
Expand All @@ -48,7 +48,7 @@ def get_effective_share_reserves(
effective_share_reserves: str (FixedPoint)
The adjusted share reserves, accounting for the zeta factor.
"""
return rust_module.get_effective_share_reserves(share_reserves, share_adjustment)
return rust_module.calculate_effective_share_reserves(share_reserves, share_adjustment)


def calculate_initial_bond_reserves(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def call(
class IHyperdriveCheckpointContractFunction(ContractFunction):
"""ContractFunction for the checkpoint method."""

def __call__(self, checkpointTime: int) -> IHyperdriveCheckpointContractFunction: # type: ignore
clone = super().__call__(dataclass_to_tuple(checkpointTime))
def __call__(self, checkpointTime: int, maxIterations: int) -> IHyperdriveCheckpointContractFunction: # type: ignore
clone = super().__call__(dataclass_to_tuple(checkpointTime), dataclass_to_tuple(maxIterations))
self.kwargs = clone.kwargs
self.args = clone.args
return self
Expand Down Expand Up @@ -3912,8 +3912,8 @@ class IHyperdriveInsufficientLiquidityContractError:
def __init__(
self: "IHyperdriveInsufficientLiquidityContractError",
) -> None:
self.selector = "0x780daf16"
self.signature = "InsufficientLiquidity(uint8)"
self.selector = "0xbb55fd27"
self.signature = "InsufficientLiquidity()"

def decode_error_data( # type: ignore
self: "IHyperdriveInsufficientLiquidityContractError",
Expand Down Expand Up @@ -5716,7 +5716,10 @@ def decode_custom_error(self, data: str) -> tuple[Any, ...]:
{
"type": "function",
"name": "checkpoint",
"inputs": [{"name": "_checkpointTime", "type": "uint256", "internalType": "uint256"}],
"inputs": [
{"name": "_checkpointTime", "type": "uint256", "internalType": "uint256"},
{"name": "_maxIterations", "type": "uint256", "internalType": "uint256"},
],
"outputs": [],
"stateMutability": "nonpayable",
},
Expand Down Expand Up @@ -6350,6 +6353,7 @@ def decode_custom_error(self, data: str) -> tuple[Any, ...]:
"name": "CreateCheckpoint",
"inputs": [
{"name": "checkpointTime", "type": "uint256", "indexed": True, "internalType": "uint256"},
{"name": "checkpointVaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"},
{"name": "vaultSharePrice", "type": "uint256", "indexed": False, "internalType": "uint256"},
{"name": "maturedShorts", "type": "uint256", "indexed": False, "internalType": "uint256"},
{"name": "maturedLongs", "type": "uint256", "indexed": False, "internalType": "uint256"},
Expand Down Expand Up @@ -6488,13 +6492,7 @@ def decode_custom_error(self, data: str) -> tuple[Any, ...]:
{"type": "error", "name": "ExpInvalidExponent", "inputs": []},
{"type": "error", "name": "ExpiredDeadline", "inputs": []},
{"type": "error", "name": "InsufficientBalance", "inputs": []},
{
"type": "error",
"name": "InsufficientLiquidity",
"inputs": [
{"name": "reason", "type": "uint8", "internalType": "enum IHyperdrive.InsufficientLiquidityReason"}
],
},
{"type": "error", "name": "InsufficientLiquidity", "inputs": []},
{"type": "error", "name": "InvalidApr", "inputs": []},
{"type": "error", "name": "InvalidCheckpointTime", "inputs": []},
{"type": "error", "name": "InvalidERC20Bridge", "inputs": []},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class WithdrawPool:
anonymous=False,
inputs=[
ABIEventParams(indexed=True, name="checkpointTime", type="uint256"),
ABIEventParams(indexed=False, name="checkpointVaultSharePrice", type="uint256"),
ABIEventParams(indexed=False, name="vaultSharePrice", type="uint256"),
ABIEventParams(indexed=False, name="maturedShorts", type="uint256"),
ABIEventParams(indexed=False, name="maturedLongs", type="uint256"),
Expand Down Expand Up @@ -422,12 +423,10 @@ class ErrorParams:
)

InsufficientLiquidityError = ErrorInfo(
inputs=[
ErrorParams(name="reason", python_type="int", solidity_type="uint8"),
],
inputs=[],
name="InsufficientLiquidity",
selector="0x780daf16",
signature="InsufficientLiquidity(uint8)",
selector="0xbb55fd27",
signature="InsufficientLiquidity()",
)

InvalidAprError = ErrorInfo(
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="0.11.0",
version="0.13.0",
packages=["hyperdrivepy"],
package_dir={"": "python"},
rust_extensions=[
Expand Down
Loading

0 comments on commit 19c5701

Please sign in to comment.