Skip to content

Commit

Permalink
Agent0 update for hyperdrive v0.6.0 (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheng Lundquist authored Jan 26, 2024
1 parent 35c684b commit 494faba
Show file tree
Hide file tree
Showing 80 changed files with 2,723 additions and 1,195 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ You then can update the generated `hypertypes` python package by running `pypech

```bash
pip install --upgrade pip && pip install --upgrade pypechain
pypechain packages/hyperdrive/src/abis/ --output_dir lib/hypertypes/hypertypes/
pypechain packages/hyperdrive/src/abis/ --output-dir lib/hypertypes/hypertypes/types/
```

# Additional useful applications
Expand Down
5 changes: 4 additions & 1 deletion lib/agent0/agent0/hyperdrive/exec/execute_agent_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ async def async_match_contract_call_to_trade(
assert min_apr, "min_apr is required for ADD_LIQUIDITY"
max_apr = trade.max_apr
assert max_apr, "max_apr is required for ADD_LIQUIDITY"
trade_result = await interface.async_add_liquidity(agent, trade.trade_amount, min_apr, max_apr, nonce=nonce)
# TODO implement slippage tolerance for add liquidity
trade_result = await interface.async_add_liquidity(
agent, trade.trade_amount, min_apr, max_apr, slippage_tolerance=None, nonce=nonce
)
wallet_deltas = HyperdriveWalletDeltas(
balance=Quantity(
amount=-trade_result.base_amount,
Expand Down
2 changes: 1 addition & 1 deletion lib/agent0/agent0/hyperdrive/exec/fund_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from ethpy.hyperdrive import HyperdriveAddresses
from hyperlogs import setup_logging
from hypertypes.types import ERC20MintableContract
from hypertypes import ERC20MintableContract
from web3.types import Nonce, TxReceipt

from agent0 import AccountKeyConfig
Expand Down
2 changes: 1 addition & 1 deletion lib/agent0/agent0/hyperdrive/exec/run_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import pandas as pd
from ethpy import EthConfig
from ethpy.hyperdrive import HyperdriveAddresses
from hypertypes.types import ERC20MintableContract
from hypertypes import ERC20MintableContract

from agent0 import AccountKeyConfig
from agent0.base.config import AgentConfig, EnvironmentConfig
Expand Down
32 changes: 16 additions & 16 deletions lib/agent0/agent0/hyperdrive/interactive/event_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OpenLong:
The maturity time for the opened long
base_amount: FixedPoint
The amount of longs opened in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The value of shares during the time of the trade.
bond_amount: FixedPoint
The amount of longs opened in units of bonds.
Expand All @@ -30,7 +30,7 @@ class OpenLong:
asset_id: int
maturity_time: int
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint
bond_amount: FixedPoint


Expand All @@ -48,7 +48,7 @@ class CloseLong:
The maturity time for the closed long
base_amount: FixedPoint
The amount of longs closed in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price for the long.
bond_amount: FixedPoint
The amount of longs closed in units of bonds.
Expand All @@ -58,7 +58,7 @@ class CloseLong:
asset_id: int
maturity_time: int
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint
bond_amount: FixedPoint


Expand All @@ -76,7 +76,7 @@ class OpenShort:
The maturity time for the opened short
base_amount: FixedPoint
The amount of shorts opened in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price for the short.
bond_amount: FixedPoint
The amount of shorts opened in units of bonds.
Expand All @@ -86,7 +86,7 @@ class OpenShort:
asset_id: int
maturity_time: int
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint
bond_amount: FixedPoint


Expand All @@ -104,7 +104,7 @@ class CloseShort:
The maturity time for the closed short
base_amount: FixedPoint
The amount of shorts closed in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price for the short.
bond_amount: FixedPoint
The amount of shorts closed in units of bonds.
Expand All @@ -114,7 +114,7 @@ class CloseShort:
asset_id: int
maturity_time: int
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint
bond_amount: FixedPoint


Expand All @@ -130,7 +130,7 @@ class AddLiquidity:
The amount of liquidity added in units of lp.
base_amount: FixedPoint
The amount of liquidity added in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price for this trade.
lp_share_price: FixedPoint
The lp share price for this trade.
Expand All @@ -139,7 +139,7 @@ class AddLiquidity:
provider: ChecksumAddress
lp_amount: FixedPoint
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint
lp_share_price: FixedPoint


Expand All @@ -155,7 +155,7 @@ class RemoveLiquidity:
The amount of liquidity removed in units of lp.
base_amount: FixedPoint
The amount of liquidity removed in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price for this trade.
withdrawal_share_amount: FixedPoint
The amount of withdrawal shares received from removing liquidity.
Expand All @@ -166,7 +166,7 @@ class RemoveLiquidity:
provider: ChecksumAddress
lp_amount: FixedPoint
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint
withdrawal_share_amount: FixedPoint
lp_share_price: FixedPoint

Expand All @@ -183,14 +183,14 @@ class RedeemWithdrawalShares:
The amount of withdrawal shares redeemed in units of shares.
base_amount: FixedPoint
The amount of withdrawal shares redeemed in units of base.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price for this trade.
"""

provider: ChecksumAddress
withdrawal_share_amount: FixedPoint
base_amount: FixedPoint
share_price: FixedPoint
vault_share_price: FixedPoint


@dataclass
Expand All @@ -201,7 +201,7 @@ class CreateCheckpoint:
----------
checkpoint_time: int
The seconds epoch time for this checkpoint.
share_price: FixedPoint
vault_share_price: FixedPoint
The share price at the checkpoint.
matured_shorts: FixedPoint
The amount of shorts that matured within this checkpoint
Expand All @@ -212,7 +212,7 @@ class CreateCheckpoint:
"""

checkpoint_time: int
share_price: FixedPoint
vault_share_price: FixedPoint
matured_shorts: FixedPoint
matured_longs: FixedPoint
lp_share_price: FixedPoint
Loading

0 comments on commit 494faba

Please sign in to comment.