Skip to content

Commit

Permalink
fix type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mendesfabio committed Dec 13, 2024
1 parent f7ae7de commit d18d91f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
5 changes: 3 additions & 2 deletions constants/balancer_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ class IntegrationConfig:
incentivized_token: str
incentivized_token_decimals: int
pool_address: str
gauge_address: str | None
aura_address: str | None
gauge_address: str | None = None
aura_address: str | None = None


INTEGRATION_CONFIGS: Dict[IntegrationID, IntegrationConfig] = {
IntegrationID.BALANCER_V3_ETHEREUM_TESTING: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=21374757,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_address="0xc4Ce391d82D164c166dF9c8336DDF84206b2F812",
gauge_address="0x4B891340b51889f438a03DC0e8aAAFB0Bc89e7A6",
),
Expand Down
6 changes: 3 additions & 3 deletions integrations/balancer_v2_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
get_v2_bpt_supply,
get_user_balance,
)
from constants.balancer import INTEGRATION_CONFIGS
from constants.balancer_v2 import INTEGRATION_CONFIGS


class BalancerV2Integration(Integration):
Expand Down Expand Up @@ -87,5 +87,5 @@ def get_participants(

if __name__ == "__main__":
balancer = BalancerV2Integration(IntegrationID.BALANCER_FRAXTAL_FRAX_USDE)
participants = balancer.get_participants()
balances = balancer.get_balance(participants)
participants = balancer.get_participants(None)
balances = balancer.get_balance(list(participants)[0])
31 changes: 24 additions & 7 deletions integrations/balancer_v3_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@ def get_balance(self, user: str, block: int | str = "latest") -> float:
This method calculates the user's token balance based on the share of Balancer Pool Tokens (BPTs)
staked either directly in Balancer gauges or via Aura Finance.
"""
gauge_balance = get_user_balance(self.chain, user, self.gauge_address, block)
aura_balance = get_user_balance(self.chain, user, self.aura_address, block)
gauge_balance = (
0
if self.gauge_address is None
else get_user_balance(self.chain, user, self.gauge_address, block)
)
aura_balance = (
0
if self.aura_address is None
else get_user_balance(self.chain, user, self.aura_address, block)
)

bpt_supply = get_token_supply(self.chain, self.pool_address, block)

Expand Down Expand Up @@ -71,11 +79,20 @@ def get_participants(
This method identifies all addresses that have staked their BPT either directly
in Balancer gauges or via Aura Finance. Non-staked BPT holders are not included.
"""
gauge_holders = get_potential_token_holders(
self.chain, self.gauge_address, self.start_block
gauge_holders = (
[]
if self.gauge_address is None
else get_potential_token_holders(
self.chain, self.gauge_address, self.start_block
)
)
aura_holders = get_potential_token_holders(
self.chain, self.aura_address, self.start_block

aura_holders = (
[]
if self.aura_address is None
else get_potential_token_holders(
self.chain, self.aura_address, self.start_block
)
)

return set(aura_holders + gauge_holders)
Expand All @@ -84,4 +101,4 @@ def get_participants(
if __name__ == "__main__":
balancer = BalancerV3Integration(IntegrationID.BALANCER_V3_ETHEREUM_TESTING)
participants = balancer.get_participants(None)
balances = balancer.get_balance(participants)
balances = balancer.get_balance(list(participants)[0])

0 comments on commit d18d91f

Please sign in to comment.