Skip to content

Commit

Permalink
test more
Browse files Browse the repository at this point in the history
  • Loading branch information
wakamex committed Oct 24, 2024
1 parent 00fbc61 commit 3c69bf0
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions integrations/hyperdrive.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import itertools
from decimal import Decimal
from constants.chains import Chain
from models.integration import Integration
from constants.integration_ids import IntegrationID
from constants.hyperdrive import HYPERDRIVE_SUSDE_POOL_ADDRESS, HYPERDRIVE_SUSDE_POOL_DEPLOYMENT_BLOCK, HYPERDRIVE_MORPHO_ABI
from utils.hyperdrive import get_hyperdrive_participants, get_pool_details, get_pool_positions
from utils.hyperdrive import get_hyperdrive_participants, get_pool_details, get_pool_positions, get_trade_details
from utils.web3_utils import w3

class Hyperdrive(Integration):
Expand Down Expand Up @@ -53,16 +54,13 @@ def get_balance(self, user: str, block: int) -> float:
return rewardable_tvl / 1e18

def test_hyperdrive(self):
pool_users, pool_ids = get_hyperdrive_participants(
pool=HYPERDRIVE_SUSDE_POOL_ADDRESS,
start_block=HYPERDRIVE_SUSDE_POOL_DEPLOYMENT_BLOCK,
)
self.update_participants()
pool_contract = w3.eth.contract(address=w3.to_checksum_address(HYPERDRIVE_SUSDE_POOL_ADDRESS), abi=HYPERDRIVE_MORPHO_ABI)
vault_shares_balance, lp_rewardable_tvl, short_rewardable_tvl = get_pool_details(pool_contract)
pool_positions = get_pool_positions(
pool_contract=pool_contract,
pool_users=pool_users,
pool_ids=pool_ids,
pool_users=self.pool_users,
pool_ids=self.pool_ids,
lp_rewardable_tvl=lp_rewardable_tvl,
short_rewardable_tvl=short_rewardable_tvl,
)
Expand All @@ -82,3 +80,15 @@ def test_hyperdrive(self):
print(f"vault_shares_balance == total_rewardable ({vault_shares_balance} == {total_rewardable}) ✅")
else:
print(f"vault_shares_balance != total_rewardable ({vault_shares_balance} != {total_rewardable}) ❌")

for user, id in itertools.product(self.pool_users, self.pool_ids):
trade_type, _, _ = get_trade_details(int(id))
if trade_type == 0:
if pool_contract.functions.balanceOf(int(id), user).call() == Decimal(0):
print(f"balanceOf({id}, {user}) == 0 ({pool_contract.functions.balanceOf(int(id), user).call()} == 0) ✅")
else:
print(f"balanceOf({id}, {user}) != 0 ({pool_contract.functions.balanceOf(int(id), user).call()} != 0) ❌")

if __name__ == "__main__":
hyperdrive = Hyperdrive()
hyperdrive.test_hyperdrive()

0 comments on commit 3c69bf0

Please sign in to comment.