Skip to content

Commit

Permalink
Merge branch 'main' into issue/399
Browse files Browse the repository at this point in the history
  • Loading branch information
gosuto-inzasheru committed Sep 26, 2024
2 parents c43752b + 0cbf4a5 commit a19c98e
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DEPLOYMENTS_REPO_ROOT_URL=./balancer-deployments
ALCHEMY_KEY=
INFURA_KEY=
DRPC_KEY=
GRAPH_API_KEY=
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
[![Generate Addressbooks Deployments](https://github.com/BalancerMaxis/bal_addresses/actions/workflows/generate_addressbooks.yaml/badge.svg)](https://github.com/BalancerMaxis/bal_addresses/actions/workflows/generate_addressbooks.yaml)
[![Generate Core Pools JSON](https://github.com/BalancerMaxis/bal_addresses/actions/workflows/generate_core_pools.yaml/badge.svg)](https://github.com/BalancerMaxis/bal_addresses/actions/workflows/generate_core_pools.yaml)
[![Generate Active Permissions](https://github.com/BalancerMaxis/bal_addresses/actions/workflows/generate_permissions.yaml/badge.svg)](https://github.com/BalancerMaxis/bal_addresses/actions/workflows/generate_permissions.yaml)

# Monorepo Addresses

This repo is setup to make it easy to find up to date addresses at balancer.

## Outputs - structured data

The [outputs](./outputs) directory has a number of different address books that you can use in code or with your eyeballs.

### [chain].json Files
Have keys of deployment/contract as well as some other extra stuff all with / notation. It includes multisigs and signers known to the maxis as well as other addresses we have touched sorted by protocol.
### [chain].json Files

Have keys of deployment/contract as well as some other extra stuff all with / notation. It includes multisigs and signers known to the maxis as well as other addresses we have touched sorted by protocol.

### addressbook.json
Has all the addresses sorted into 2 dicts (active, and old). Each dict is then mapped like `{chain:{deployment:{contract: address}}}`

Has all the addresses sorted into 2 dicts (active, and old). Each dict is then mapped like `{chain:{deployment:{contract: address}}}`

## Python helpers

You can import this into python scripts by adding the following into your requirements.txt `git+https://github.com/BalancerMaxis/bal_addresses`.

once imported like `from bal_addresses import AddrBook`.
Expand All @@ -22,21 +29,24 @@ Then you can invoke the Address Book on a chain like so
`a = AddrBook(chain_name)` where chain_name is one of the chains listed in `AddrBook.CHAIN_IDS_BY_NAME.keys()`

Then you can do this with the flatbook:

```
>>> a.flatbook["20230320-composable-stable-pool-v4/ComposableStablePoolFactory"]
'0xfADa0f4547AB2de89D1304A668C39B3E09Aa7c76'
>>> a.flatbook["multisigs/lm"]
'0xc38c5f97B34E175FFd35407fc91a937300E33860'
>>>
>>>
```

This with the reversebook:

```text
>>> a.reversebook["0xfADa0f4547AB2de89D1304A668C39B3E09Aa7c76"]
'20230320-composable-stable-pool-v4/ComposableStablePoolFactory'
```

You can also use the structured data as follows

```
>>> r = a.dotmap
>>> r.multisigs
Expand All @@ -45,13 +55,13 @@ DotMap(lm='0xc38c5f97B34E175FFd35407fc91a937300E33860', dao='0x10A19e7eE7d7F8a52
'0x10A19e7eE7d7F8a52822f6817de8ea18204F2e4f'
```

Note that for the deployments the dotmap has a problem with digit starting members. For this reason you have to use it like this
Note that for the deployments the dotmap has a problem with digit starting members. For this reason you have to use it like this

```text
>>> r["20230320-composable-stable-pool-v4"]["ComposableStablePoolFactory"]
'0xfADa0f4547AB2de89D1304A668C39B3E09Aa7c76'
```


As you can see from the examples above, the dotmap works like a dict, so you can easily loop over any part of the structure.

```python
Expand All @@ -61,13 +71,16 @@ r = a.dotmap
for contract, address in r["20230320-composable-stable-pool-v4"].items():
print(f"{contract} has {address}")
```

Returns

```text
ComposableStablePoolFactory has 0xfADa0f4547AB2de89D1304A668C39B3E09Aa7c76
MockComposableStablePool has 0x5537f945D8c3FCFDc1b8DECEEBD220FAD26aFdA8
```

There is also search and lookup commands

```text
>>> a.search_many("Composable")
{'20230320-composable-stable-pool-v4/ComposableStablePoolFactory': '0xfADa0f4547AB2de89D1304A668C39B3E09Aa7c76', '20230320-composable-stable-pool-v4/MockComposableStablePool': '0x5537f945D8c3FCFDc1b8DECEEBD220FAD26aFdA8', '20230206-composable-stable-pool-v3/ComposableStablePoolFactory': '0xdba127fBc23fb20F5929C546af220A991b5C6e01', '20230206-composable-stable-pool-v3/MockComposableStablePool': '0x222bc81C6F3C17e9e9Aba47a12f55a1Dea42f163', '20220906-composable-stable-pool/ComposableStablePoolFactory': '0xf9ac7B9dF2b3454E841110CcE5550bD5AC6f875F', '20221122-composable-stable-pool-v2/ComposableStablePoolFactory': '0x85a80afee867aDf27B50BdB7b76DA70f1E853062', '20221122-composable-stable-pool-v2/MockComposableStablePool': '0x373b347bc87998b151A5E9B6bB6ca692b766648a'}
Expand All @@ -79,16 +92,19 @@ There is also search and lookup commands
'0xBA12222222228d8Ba445958a75a0704d566BF2C8'
>>> a.reversebook[a.latest_contract("ComposableStablePoolFactory")]
'20230320-composable-stable-pool-v4/ComposableStablePoolFactory'
>>>
>>>
```
Most of the other functions are used by a github action which regenerates files read in by those 2 functions on a weekly basis. You can explore them if you would like.

Most of the other functions are used by a github action which regenerates files read in by those 2 functions on a weekly basis. You can explore them if you would like.

## Using deployments:

`.deployments` attribute is an object that is lazy loaded on first access.
It has first class support in IDEs, so you can use it as a normal object.

To use deployments information you can do the following:

```python
from bal_addresses.addresses import AddrBook

Expand All @@ -98,6 +114,7 @@ a.deployments
```

Now you can extract information:

```
>>> a.deployments.vault.contracts.Vault.address
'0xBA12222222228d8Ba445958a75a0704d566BF2C8'
Expand Down
2 changes: 1 addition & 1 deletion bal_addresses/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pathlib>=1.0
git+https://github.com/BalancerMaxis/bal_tools.git@e63151cc5a61455e9dd87a39f3760c926cbeec0a
git+https://github.com/BalancerMaxis/bal_tools.git@v0.1.10
requests
pandas
web3
Expand Down
5 changes: 4 additions & 1 deletion extras/gnosis.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
"gaugeRewardsInjectors": {
"usdc_rewards_injector": "0x87c921be1fd8ee7E5eda4394aDB849DB72847aE9"
}
}
},
"stakewise": {
"SWISE_Distributor_SAFE": "0x5d1acdd0867d6F1FBe11ad8F1f48C87f19C0801E"
}
}
3 changes: 2 additions & 1 deletion extras/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
},
"cow": {
"vault_relayer": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",
"settlement": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41"
"settlement": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
"airdrop_merkle_distributor": "0x64646f112FfD6F1B7533359CFaAF7998F23C8c40"
},
"one_inch":{
"settlement": "0xad3b67bca8935cb510c8d18bd45f0b94f54a968f"
Expand Down
3 changes: 3 additions & 0 deletions outputs/permissions/active/gnosis.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
"0xf139842955587e7816c90b6d72792f2b7e6014d560464517094450df28164bc8": [
"0x955556b002d05c7B31a9394c10897c1DA19eAEab"
],
"0x9d575f62420250ec382e1e8e262ddae46d0d6817fab9fde48f9c6efd068e5844": [
"0x14969B55a675d13a1700F71A37511bc22D90155a"
],
"0x1ff8dca7a9af725b8fde69703b657ae58c04e9a7153ef1025379deb0dda4f926": [
"0x14969B55a675d13a1700F71A37511bc22D90155a"
],
Expand Down
3 changes: 3 additions & 0 deletions outputs/permissions/active/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
"0x10A19e7eE7d7F8a52822f6817de8ea18204F2e4f",
"0xA29F61256e948F3FB707b4b3B138C5cCb9EF9888"
],
"0xd0090a09f425bba74e6c801fba7c6d15b44147ab0bd319e40076ce07e95168b6": [
"0xc38c5f97B34E175FFd35407fc91a937300E33860"
],
"0xac0fcdc4520d7bde1c58bbefd7c8dd39aaf382a20c27991134c14fe63d2c96f3": [
"0x10A19e7eE7d7F8a52822f6817de8ea18204F2e4f"
],
Expand Down
3 changes: 3 additions & 0 deletions outputs/permissions/active/polygon.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"0xf51a91e622462fd20895f082afda26cd4c20640d7492e8ce2840c1e7ee1b437f": [
"0xf9D6BdE5c2eef334AC88204CB2eEc07111DCBA97"
],
"0x363cf2bd771efe16bd206d33a549d4698c4ad202ea6b5bf693722fbe151140a6": [
"0xc38c5f97B34E175FFd35407fc91a937300E33860"
],
"0xde944634152f598012cd1450bbe9e21e2e88a57fc7e578a54e47cbc6ccdf1c54": [
"0x3c58668054c299bE836a0bBB028Bee3aD4724846"
],
Expand Down
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
install_requires=[
"setuptools>=42",
"wheel",
"munch==4.0.0",
"pathlib>=1.0",
"bal_tools @ git+https://github.com/BalancerMaxis/[email protected]",
"requests",
"pandas",
"web3",
"dotmap",
"munch==4.0.0",
"gql[requests]",
"requests",
"bal_tools @ git+https://github.com/BalancerMaxis/bal_tools.git@e63151cc5a61455e9dd87a39f3760c926cbeec0a",
"json-fix",
],
keywords=["python", "first package"],
classifiers=[
Expand Down

0 comments on commit a19c98e

Please sign in to comment.