Skip to content

Instantly share code, notes, and snippets.

@banteg
Last active November 9, 2020 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banteg/546720079b63dd44ff149f2dfe4b9c34 to your computer and use it in GitHub Desktop.
Save banteg/546720079b63dd44ff149f2dfe4b9c34 to your computer and use it in GitHub Desktop.
from brownie import Contract, web3
from itertools import chain
def main():
curve_registry = Contract("0x7D86446dDb609eD0F5f8684AcF30380a356b2B4c")
yearn_registry = Contract(web3.ens.resolve("registry.ychad.eth"))
gauge_controller = Contract('0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB')
uniquote = Contract("0xCA2E2df6A7a7Cf5bd19D112E8568910a6C2D3885")
voter = "0xF147b8125d2ef93FB6965Db97D6746952a133934"
wbtc = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
btc_gauges = {"0x705350c4BcD35c9441419DdD5d2f097d7a55410F"}
# yearn vaults
vaults = list(zip(yearn_registry.getVaults(), *yearn_registry.getVaultsInfo()))
fields = ["vault", "controller", "token", "strategy"]
vaults = [dict(zip(fields, vault)) for vault in vaults]
# curve gauges
pools = [curve_registry.pool_list(i) for i in range(curve_registry.pool_count())]
gauges = set(
chain.from_iterable(curve_registry.get_gauges(pool)[0] for pool in pools)
)
gauges.discard("0x0000000000000000000000000000000000000000")
# yoracle
granularity = 86400 // uniquote.periodSize()
btc_eth = uniquote.quote(wbtc, 1e8, weth, granularity) / 1e18
eth_usd = uniquote.quote(weth, 1e18, usdc, granularity) / 1e6
btc_usd = btc_eth * eth_usd
print("btc/usd", btc_usd)
# gauge balances
balances = {gauge: Contract(gauge).balanceOf(voter) / 1e18 for gauge in gauges}
balances = {
gauge: balance * btc_usd if gauge in btc_gauges else balance
for gauge, balance in balances.items()
if balance
}
print("\ngauge balances")
for gauge, balance in balances.items():
print(f"{gauge} {balance:,.0f}")
# vote allocations
votes = {
gauge: int(balance / sum(balances.values()) * 10000)
for gauge, balance in balances.items()
}
print("\ngauge weight vote allocation")
for gauge, vote in votes.items():
print(gauge, vote)
print('\ntxs for multisig')
print(f"voter = {voter}")
for gauge, vote in votes.items():
data = gauge_controller.vote_for_gauge_weights.encode_input(gauge, vote)
print(f'voter.execute("{gauge_controller}", 0, "{data}")')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment