Skip to content

Commit

Permalink
working on all chains.
Browse files Browse the repository at this point in the history
  • Loading branch information
BIP Bot committed Apr 21, 2024
1 parent 7394fd8 commit eff632d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
28 changes: 25 additions & 3 deletions generate_ecosystem_deposits.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ def set_block_and_timestamp(chain: str, block=None, timestamp=None) -> (int, int
return (block, timestamp)


def get_tokens_per_bpt(chain:str, block: int, poolid: str):
queries = Subgraph(chain)
result = queries.fetch_graphql_data("core", "get_pool_details", {"id": poolid, "block": block})
result = result["pool"]
bpt_total_shares = result["totalShares"]
bpt_address = result["address"]
tokens_per_bpt = {}
for tokeninfo in result["tokens"]:
if tokeninfo["address"].lower() == bpt_address.lower():
continue
tokens_per_bpt[tokeninfo["address"]] = float(tokeninfo["balance"]) / float(bpt_total_shares)
return tokens_per_bpt

def get_ecosystem_balances_w_csv(pool_id: str, gauge_address: str, block: int, name: str, chain="mainnet") -> Dict[
str, int]:
gauges = BalPoolsGauges(chain)
Expand Down Expand Up @@ -135,20 +148,29 @@ def main():
for chain, poolinfos in POOLS_TO_RUN_ON_BY_CHAIN.items():
# Figure out the block and timestmap for this chain using env vars as inputs
block, timestamp = set_block_and_timestamp(chain, BLOCK, TIMESTAMP)
print(f"Using block {block} on chain {chain} derived from unixtime(UTC): {timestamp}")
print(f"Using block {block} on chain {chain} derived from unixtime(UTC): {timestamp}\n\n")
for poolinfo in poolinfos:
if POOL_ID and poolinfo["pool_id"] != POOL_ID:
continue
print(
f"\n\nRunning on {poolinfo['name']}, pool_id: {poolinfo['pool_id']}, gauge: {poolinfo['gauge']}, block: {BLOCK}\n\n")

f"\nRunning on {poolinfo['name']}, pool_id: {poolinfo['pool_id']}, gauge: {poolinfo['gauge']}, block: {block}\n")
get_ecosystem_balances_w_csv(
pool_id=poolinfo["pool_id"],
gauge_address=poolinfo["gauge"],
name=poolinfo["name"],
chain=chain,
block=block
)
# Dump Tokens per BPT json
print(block)
tokens_per_bpt = get_tokens_per_bpt(chain, block, poolinfo['pool_id'])
dir_name = poolinfo["name"].replace("/", "-") # /'s are path structure
output_file = f"out/{chain}/{dir_name}/{block}_{poolinfo['pool_id']}.tokens_per_bpt.json"

os.makedirs(os.path.dirname(output_file), exist_ok=True)
with open(output_file, 'w') as f:
json.dump(tokens_per_bpt, f)




Expand Down
32 changes: 26 additions & 6 deletions run_pools.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,32 @@
"gauge": "0xd955f46b110583e14644665c69e26cd8126070ec"
}
],
"arbitrum":[
"arbitrum":
[
{
"name": "wstETH/WETH",
"pool_id": "0x9791d590788598535278552eecd4b211bfc790cb000000000000000000000498",
"gauge": "0x260cbb867359a1084eC97de4157d06ca74e89415"
"name": "ezETH/wETH",
"pool_id": "0xb61371ab661b1acec81c699854d2f911070c059e000000000000000000000516",
"gauge": "0x7c4a6b0c16ca99e65822cc531403ce2f8a20a912"
}
],
"optimism":
[
{
"name": "weETH/wETH",
"pool_id": "0x250a1381f79593b96b462fb0d575c75795f8033200000000000000000000012f",
"gauge": "0x0290377d73c7cdf57e24945dfc4e2056434a8a11"
},
{
"name": "rETH/ankrETH",
"pool_id": "0x004700ba0a4f5f22e1e78a277fca55e36f47e09c000000000000000000000104",
"gauge": "0xc19055c2ff199ba6190505ef776573c8b7cc676a"
}
],
"base": [
{
"name": "rETH/ETH",
"pool_id": "0xc771c1a5905420daec317b154eb13e4198ba97d0000000000000000000000023",
"gauge": "0x8d118063b521e0cb9947a934be90f7e32d02b158"
}
],
"zkevm": [
Expand All @@ -52,5 +73,4 @@
"gauge": "0x7733650c7aaF2074FD1fCf98f70cbC09138E1Ea5"
}
]
}

}

0 comments on commit eff632d

Please sign in to comment.