Skip to content

Commit

Permalink
Merge pull request #45 from mendesfabio/balancer-v3
Browse files Browse the repository at this point in the history
integrate balancer v3
  • Loading branch information
ElliotWood13 authored Jan 10, 2025
2 parents 7e0fcec + bb70ed8 commit 1bb3340
Show file tree
Hide file tree
Showing 10 changed files with 2,476 additions and 297 deletions.
File renamed without changes.
2,031 changes: 2,031 additions & 0 deletions abi/balancer_v3_vault.json

Large diffs are not rendered by default.

150 changes: 3 additions & 147 deletions constants/balancer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from enum import Enum
from dataclasses import dataclass
from typing import Dict, Optional

from constants.chains import Chain
from integrations.integration_ids import IntegrationID

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


# Addresses for Ethena tokens are the same across L2 chains (except ZKsync)
Expand All @@ -17,147 +10,10 @@ class Token(Enum):
ENA = "0x58538e6A46E07434d7E7375Bc268D3cb839C0133"


@dataclass
class IntegrationConfig:
chain: Chain
start_block: int
incentivized_token: str
incentivized_token_decimals: int
pool_id: str
gauge_address: str
aura_address: str
has_preminted_bpts: bool = (
False # CSPs have a different function for getting the BPT supply
)


INTEGRATION_CONFIGS: Dict[IntegrationID, IntegrationConfig] = {
IntegrationID.BALANCER_FRAXTAL_FRAX_USDE: IntegrationConfig(
chain=Chain.FRAXTAL,
start_block=5931687,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0xa0af0b88796c1aa67e93db89fead2ab7aa3d6747000000000000000000000007",
gauge_address="0xf99d875Dd868277cf3780f51D69c6E1F8522a1e9",
aura_address="0x56bA1E88340fD53968f686490519Fb0fBB692a39",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ARBITRUM_GHO_USDE: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=225688025,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0x2b783cd37774bb77d387d35683e8388937712f0a00020000000000000000056b",
gauge_address="0xf2d151c40C18d8097AAa5157eE8f447CBe217269",
aura_address="0x106398c0a78AE85F501FEE16d53A81401469b9B8",
),
IntegrationID.BALANCER_ARBITRUM_WAGHO_USDE: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=245277323,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0x38161e9efb8de52d00a1eb0f773223fd28fdd7c20002000000000000000005a0",
gauge_address="0xcfab2efef3affdd158568dc896115eac26b3c498",
aura_address="0x8f2c4c4ad0b45a3c740e7f7fbc5a106659adeee7",
),
IntegrationID.BALANCER_ARBITRUM_GYD_SUSDE: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=240466292,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0xdeeaf8b0a8cf26217261b813e085418c7dd8f1ee00020000000000000000058f",
gauge_address="0xdEC026525FE4FEF54857bCF551aEA97aBc24A673",
aura_address="0x2d7cFe43BcDf10137924a20445B763Fb40E5871c",
),
IntegrationID.BALANCER_ARBITRUM_SUSDE_SFRAX: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=197330091,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x59743f1812bb85db83e9e4ee061d124aaa64290000000000000000000000052b",
gauge_address="0x4b8858a8E42f406B4dC2eCB8D48B5cf0021035c8",
aura_address="0x0a6a427867a3274909A04276cB5589AE8Cc2dfc7",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ARBITRUM_SUSDE_USDC: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=197316005,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x2f0cdf8596be980ef24924ca7bf54e630ca526b2000000000000000000000529",
gauge_address="0xe9801a0fa08acf9140ba3a347a8c6048ff9eab7c",
aura_address="0x043A59D13884DddCa18b99C3C184C29aAd973b35",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ETHEREUM_WSTETH_SUSDE: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=20005052,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0xa8210885430aaa333c9f0d66ab5d0c312bed5e43000200000000000000000692",
gauge_address="0xbd00c7cbe59dddbd784c899ac173b7ba514b9997",
aura_address="0x99d9e4d3078f7c9c5b792999749290a54fb87257",
),
IntegrationID.BALANCER_ETHEREUM_BAOUSD_SUSDE: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=20169334,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x79af734562f741946566d5126bbded4cb699e35500000000000000000000069f",
gauge_address="0xf91ba601c53f831869da4aceaaec11c479413972",
aura_address="0xd34793bf42d922b04e7e53253f7195725a4a7e9d",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ETHEREUM_SUSDE_USDC: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=19663564,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0xb819feef8f0fcdc268afe14162983a69f6bf179e000000000000000000000689",
gauge_address="0x84f7f5cd2218f31b750e7009bb6fd34e0b945dac",
aura_address="0x4b87dcff2f45535775a9564229119dca5e697a10",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ETHEREUM_SUSDE_GYD: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=20569775,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x8d93b853849b9884e2bb413444ec23eb5366ee910002000000000000000006b3",
gauge_address="0x146b6030E6d6a6398B918E9854652a71C9537180",
aura_address="0x1f2b312c30b08c1957bd3ada616e77bc7bff51ff",
),
IntegrationID.BALANCER_FRAXTAL_SFRAX_SDAI_SUSDE: IntegrationConfig(
chain=Chain.FRAXTAL,
start_block=5931675,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x33251abecb0364df98a27a8d5d7b5ccddc774c42000000000000000000000008",
gauge_address="0x275e8514b83479f526673327b279753abc666a05",
aura_address="0x8bb2303ab3ff8bcb1833b71ca14fde75cb88d0b8",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_FRAXTAL_FRAX_USDE_DAI_USDT_USDC: IntegrationConfig(
chain=Chain.FRAXTAL,
start_block=6859850,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0x760b30eb4be3ccd840e91183e33e2953c6a31253000000000000000000000005",
gauge_address="0x982653b874b059871a46f66120c69503fe391979",
aura_address="0x5a1e521e700d684323886346a2c782febcc0ea4b",
has_preminted_bpts=True,
),
}


def get_integration_config(
integration_id: IntegrationID,
) -> Optional[IntegrationConfig]:
return INTEGRATION_CONFIGS.get(integration_id)


AURA_VOTER_PROXY = {
Chain.ETHEREUM: "0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2",
Chain.FRAXTAL: "0xC181Edc719480bd089b94647c2Dc504e2700a2B0",
}

BALANCER_VAULT = "0xBA12222222228d8Ba445958a75a0704d566BF2C8"
BALANCER_V2_VAULT = "0xBA12222222228d8Ba445958a75a0704d566BF2C8"
BALANCER_V3_VAULT = "0xbA1333333333a1BA1108E8412f11850A5C319bA9"
149 changes: 149 additions & 0 deletions constants/balancer_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
from dataclasses import dataclass
from typing import Dict, Optional

from constants.chains import Chain
from constants.balancer import Token
from integrations.integration_ids import IntegrationID

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


@dataclass
class IntegrationConfig:
chain: Chain
start_block: int
incentivized_token: str
incentivized_token_decimals: int
pool_id: str
gauge_address: str
aura_address: str
has_preminted_bpts: bool = (
False # CSPs have a different function for getting the BPT supply
)


INTEGRATION_CONFIGS: Dict[IntegrationID, IntegrationConfig] = {
IntegrationID.BALANCER_FRAXTAL_FRAX_USDE: IntegrationConfig(
chain=Chain.FRAXTAL,
start_block=5931687,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0xa0af0b88796c1aa67e93db89fead2ab7aa3d6747000000000000000000000007",
gauge_address="0xf99d875Dd868277cf3780f51D69c6E1F8522a1e9",
aura_address="0x56bA1E88340fD53968f686490519Fb0fBB692a39",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ARBITRUM_GHO_USDE: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=225688025,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0x2b783cd37774bb77d387d35683e8388937712f0a00020000000000000000056b",
gauge_address="0xf2d151c40C18d8097AAa5157eE8f447CBe217269",
aura_address="0x106398c0a78AE85F501FEE16d53A81401469b9B8",
),
IntegrationID.BALANCER_ARBITRUM_WAGHO_USDE: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=245277323,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0x38161e9efb8de52d00a1eb0f773223fd28fdd7c20002000000000000000005a0",
gauge_address="0xcfab2efef3affdd158568dc896115eac26b3c498",
aura_address="0x8f2c4c4ad0b45a3c740e7f7fbc5a106659adeee7",
),
IntegrationID.BALANCER_ARBITRUM_GYD_SUSDE: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=240466292,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0xdeeaf8b0a8cf26217261b813e085418c7dd8f1ee00020000000000000000058f",
gauge_address="0xdEC026525FE4FEF54857bCF551aEA97aBc24A673",
aura_address="0x2d7cFe43BcDf10137924a20445B763Fb40E5871c",
),
IntegrationID.BALANCER_ARBITRUM_SUSDE_SFRAX: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=197330091,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x59743f1812bb85db83e9e4ee061d124aaa64290000000000000000000000052b",
gauge_address="0x4b8858a8E42f406B4dC2eCB8D48B5cf0021035c8",
aura_address="0x0a6a427867a3274909A04276cB5589AE8Cc2dfc7",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ARBITRUM_SUSDE_USDC: IntegrationConfig(
chain=Chain.ARBITRUM,
start_block=197316005,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x2f0cdf8596be980ef24924ca7bf54e630ca526b2000000000000000000000529",
gauge_address="0xe9801a0fa08acf9140ba3a347a8c6048ff9eab7c",
aura_address="0x043A59D13884DddCa18b99C3C184C29aAd973b35",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ETHEREUM_WSTETH_SUSDE: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=20005052,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0xa8210885430aaa333c9f0d66ab5d0c312bed5e43000200000000000000000692",
gauge_address="0xbd00c7cbe59dddbd784c899ac173b7ba514b9997",
aura_address="0x99d9e4d3078f7c9c5b792999749290a54fb87257",
),
IntegrationID.BALANCER_ETHEREUM_BAOUSD_SUSDE: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=20169334,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x79af734562f741946566d5126bbded4cb699e35500000000000000000000069f",
gauge_address="0xf91ba601c53f831869da4aceaaec11c479413972",
aura_address="0xd34793bf42d922b04e7e53253f7195725a4a7e9d",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ETHEREUM_SUSDE_USDC: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=19663564,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0xb819feef8f0fcdc268afe14162983a69f6bf179e000000000000000000000689",
gauge_address="0x84f7f5cd2218f31b750e7009bb6fd34e0b945dac",
aura_address="0x4b87dcff2f45535775a9564229119dca5e697a10",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_ETHEREUM_SUSDE_GYD: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=20569775,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x8d93b853849b9884e2bb413444ec23eb5366ee910002000000000000000006b3",
gauge_address="0x146b6030E6d6a6398B918E9854652a71C9537180",
aura_address="0x1f2b312c30b08c1957bd3ada616e77bc7bff51ff",
),
IntegrationID.BALANCER_FRAXTAL_SFRAX_SDAI_SUSDE: IntegrationConfig(
chain=Chain.FRAXTAL,
start_block=5931675,
incentivized_token=Token.SUSDE.value,
incentivized_token_decimals=18,
pool_id="0x33251abecb0364df98a27a8d5d7b5ccddc774c42000000000000000000000008",
gauge_address="0x275e8514b83479f526673327b279753abc666a05",
aura_address="0x8bb2303ab3ff8bcb1833b71ca14fde75cb88d0b8",
has_preminted_bpts=True,
),
IntegrationID.BALANCER_FRAXTAL_FRAX_USDE_DAI_USDT_USDC: IntegrationConfig(
chain=Chain.FRAXTAL,
start_block=6859850,
incentivized_token=Token.USDE.value,
incentivized_token_decimals=18,
pool_id="0x760b30eb4be3ccd840e91183e33e2953c6a31253000000000000000000000005",
gauge_address="0x982653b874b059871a46f66120c69503fe391979",
aura_address="0x5a1e521e700d684323886346a2c782febcc0ea4b",
has_preminted_bpts=True,
),
}


def get_integration_config(
integration_id: IntegrationID,
) -> Optional[IntegrationConfig]:
return INTEGRATION_CONFIGS.get(integration_id)
45 changes: 45 additions & 0 deletions constants/balancer_v3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from enum import Enum
from dataclasses import dataclass
from typing import Dict, Optional

from constants.chains import Chain
from integrations.integration_ids import IntegrationID

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


class Token(Enum): # Ensure address is checksummed
WA_ETH_USDE = (
"0x5F9D59db355b4A60501544637b00e94082cA575b" # Wrapped Aave Ethereum USDe
)


@dataclass
class IntegrationConfig:
chain: Chain
start_block: int
incentivized_token: str
incentivized_token_decimals: int
pool_address: str
gauge_address: str | None = None
aura_address: str | None = None


INTEGRATION_CONFIGS: Dict[IntegrationID, IntegrationConfig] = {
IntegrationID.BALANCER_V3_ETHEREUM_USDE_USDT: IntegrationConfig(
chain=Chain.ETHEREUM,
start_block=21467086,
incentivized_token=Token.WA_ETH_USDE.value,
incentivized_token_decimals=18,
pool_address="0xc1D48bB722a22Cc6Abf19faCbE27470F08B3dB8c",
gauge_address="0x95d260ac86B58D458187C819f87aAd2c7c4203eF",
),
}


def get_integration_config(
integration_id: IntegrationID,
) -> Optional[IntegrationConfig]:
return INTEGRATION_CONFIGS.get(integration_id)
Loading

0 comments on commit 1bb3340

Please sign in to comment.