Skip to content

Commit 3e0c90d

Browse files
authored
Merge pull request #115 from mendesfabio/balancer-v3-plasma
add balancer v3 plasma
2 parents a6b8e14 + 612cae1 commit 3e0c90d

File tree

7 files changed

+51
-11
lines changed

7 files changed

+51
-11
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ SWELL_NODE_URL='https://rpc.ankr.com/swell'
1010
SOLANA_NODE_URL='https://api.mainnet-beta.solana.com'
1111
BASE_NODE_URL="https://mainnet.base.org"
1212
HYPEREVM_NODE_URL="https://rpc.hyperlend.finance/archive"
13-
13+
PLASMA_NODE_URL="https://rpc.plasma.to"
1414
DERIVE_SUBGRAPH_API_KEY=''

constants/balancer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Token(Enum):
1313
AURA_VOTER_PROXY = {
1414
Chain.ETHEREUM: "0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2",
1515
Chain.FRAXTAL: "0xC181Edc719480bd089b94647c2Dc504e2700a2B0",
16+
Chain.PLASMA: "0x0000000000000000000000000000000000000000",
1617
}
1718

1819
BALANCER_V2_VAULT = "0xBA12222222228d8Ba445958a75a0704d566BF2C8"

constants/balancer_v3.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
from typing import Dict, Optional
44

55
from constants.chains import Chain
6+
from constants.balancer import Token
67
from integrations.integration_ids import IntegrationID
78

89
## If you want to integrate another Balancer Pool, first add it to the IntegrationID enum in integration_ids.py
910
## Then, add a new entry to the INTEGRATION_CONFIGS dictionary below. Aura integration is optional.
1011
## If the chain is not yet supported, add it to the Chain enum in chains.py and add RPCs to web3_utils.py.
1112

1213

13-
class Token(Enum): # Ensure address is checksummed
14+
class WrappedToken(Enum): # Ensure address is checksummed
1415
WA_ETH_USDE = (
1516
"0x5F9D59db355b4A60501544637b00e94082cA575b" # Wrapped Aave Ethereum USDe
1617
)
18+
WA_PLA_USDE = (
19+
"0xC63F1a8c0cD4493E18f6f3371182BE01Ce0BeF02" # Wrapped Aave Plasma USDe
20+
)
1721

1822

1923
@dataclass
@@ -31,11 +35,27 @@ class IntegrationConfig:
3135
IntegrationID.BALANCER_V3_ETHEREUM_USDE_USDT: IntegrationConfig(
3236
chain=Chain.ETHEREUM,
3337
start_block=21467086,
34-
incentivized_token=Token.WA_ETH_USDE.value,
38+
incentivized_token=WrappedToken.WA_ETH_USDE.value,
3539
incentivized_token_decimals=18,
3640
pool_address="0xc1D48bB722a22Cc6Abf19faCbE27470F08B3dB8c",
3741
gauge_address="0x95d260ac86B58D458187C819f87aAd2c7c4203eF",
3842
),
43+
IntegrationID.BALANCER_V3_PLASMA_USDE_USDT: IntegrationConfig(
44+
chain=Chain.PLASMA,
45+
start_block=1727318,
46+
incentivized_token=WrappedToken.WA_PLA_USDE.value,
47+
incentivized_token_decimals=18,
48+
pool_address="0x6a74BE33B5393D8A3EbA4D69B78f9D9da947C48c",
49+
gauge_address=None,
50+
),
51+
IntegrationID.BALANCER_V3_PLASMA_SUSDE_USDT: IntegrationConfig(
52+
chain=Chain.PLASMA,
53+
start_block=1726616,
54+
incentivized_token=Token.SUSDE.value,
55+
incentivized_token_decimals=18,
56+
pool_address="0xd9c4e277c93374a9f8C877a9D06707a88092E8F0",
57+
gauge_address=None,
58+
),
3959
}
4060

4161

constants/chains.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ class Chain(Enum):
1818
SEPOLIA = "Sepolia"
1919
TON = "Ton"
2020
HYPEREVM = "HyperEVM"
21+
PLASMA = "Plasma"

integrations/balancer_v3_integration.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def get_balance(self, user: str, block: int | str = "latest") -> float:
4040
Retrieve the balance of the user in the incentivized Ethena token.
4141
4242
This method calculates the user's token balance based on the share of Balancer Pool Tokens (BPTs)
43-
staked either directly in Balancer gauges or via Aura Finance.
4443
"""
44+
bpt_balance = get_user_balance(self.chain, user, self.pool_address, block)
4545
gauge_balance = (
4646
0
4747
if self.gauge_address is None
@@ -55,7 +55,7 @@ def get_balance(self, user: str, block: int | str = "latest") -> float:
5555

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

58-
user_balance = gauge_balance + aura_balance
58+
user_balance = bpt_balance + gauge_balance + aura_balance
5959

6060
incentivized_token_balance = get_vault_v3_pool_token_balance(
6161
self.chain, self.pool_address, self.incentivized_token, block
@@ -74,11 +74,12 @@ def get_participants(
7474
blocks: Optional[List[int]],
7575
) -> Set[str]:
7676
"""
77-
Retrieve the set of all unique participants who might have staked Balancer Pool Tokens (BPTs).
78-
79-
This method identifies all addresses that have staked their BPT either directly
80-
in Balancer gauges or via Aura Finance. Non-staked BPT holders are not included.
77+
Retrieve the set of all unique participants who might have Balancer Pool Tokens (BPTs).
8178
"""
79+
bpt_holders = get_potential_token_holders(
80+
self.chain, self.pool_address, self.start_block
81+
)
82+
8283
gauge_holders = (
8384
[]
8485
if self.gauge_address is None
@@ -95,10 +96,10 @@ def get_participants(
9596
)
9697
)
9798

98-
return set(aura_holders + gauge_holders)
99+
return set(bpt_holders + aura_holders + gauge_holders)
99100

100101

101102
if __name__ == "__main__":
102-
balancer = BalancerV3Integration(IntegrationID.BALANCER_V3_ETHEREUM_USDE_USDT)
103+
balancer = BalancerV3Integration(IntegrationID.BALANCER_V3_PLASMA_USDE_USDT)
103104
participants = balancer.get_participants(None)
104105
balances = balancer.get_balance(list(participants)[0])

integrations/integration_ids.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,18 @@ class IntegrationID(Enum):
343343
Token.USDE,
344344
)
345345

346+
BALANCER_V3_PLASMA_USDE_USDT = (
347+
"balancer_v3_plasma_usde_usdt",
348+
"Balancer V3 Plasma USDe/USDT",
349+
Token.USDE,
350+
)
351+
352+
BALANCER_V3_PLASMA_SUSDE_USDT = (
353+
"balancer_v3_plasma_susde_usdt",
354+
"Balancer V3 Plasma sUSDe/USDT",
355+
Token.SUSDE,
356+
)
357+
346358
# Nuri
347359
NURI_USDE_LP = ("nuri_usde_lp_bal", "Nuri USDe LP", Token.USDE)
348360

utils/web3_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
w3_sepolia = Web3(Web3.HTTPProvider(SEPOLIA_NODE_URL))
4141
HYPEREVM_NODE_URL = os.getenv("HYPEREVM_NODE_URL")
4242
w3_hyperevm = Web3(Web3.HTTPProvider(HYPEREVM_NODE_URL))
43+
PLASMA_NODE_URL = os.getenv("PLASMA_NODE_URL")
44+
w3_plasma = Web3(Web3.HTTPProvider(PLASMA_NODE_URL))
4345

4446
W3_BY_CHAIN = {
4547
Chain.ETHEREUM: {
@@ -84,6 +86,9 @@
8486
Chain.HYPEREVM: {
8587
"w3": w3_hyperevm,
8688
},
89+
Chain.PLASMA: {
90+
"w3": w3_plasma,
91+
},
8792
}
8893

8994
MULTICALL_ABI = [

0 commit comments

Comments
 (0)