Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build merkl airdrop csv based on user pool shares #1575

Merged
merged 26 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3b288f0
chore: bal addresses needs updated bal tools
gosuto-inzasheru Dec 11, 2024
9bb8453
feat: query v3 subgraph for user balances
gosuto-inzasheru Dec 11, 2024
fb6e70a
feat: consolidate multiple snapshots into an airdrop file
gosuto-inzasheru Dec 17, 2024
4c29d9c
fix: prevent division by zero
gosuto-inzasheru Jan 6, 2025
f060366
feat: get user shares from gauge similar to from pool
gosuto-inzasheru Jan 9, 2025
287176a
feat: consider both pool and gauge shares
gosuto-inzasheru Jan 9, 2025
af401a1
feat: add checksums based on total supply onchain
gosuto-inzasheru Jan 9, 2025
38ec5ae
chore: add v3 stable pool abi
gosuto-inzasheru Jan 9, 2025
3da824e
feat: for loop over multiple reward tokens and pools
gosuto-inzasheru Jan 10, 2025
882e8c0
feat: move watchlist to json file
gosuto-inzasheru Jan 10, 2025
8fef05f
fix: dev branch has been merged and deleted
gosuto-inzasheru Jan 10, 2025
dcc720e
feat: use latest version of bal_addresses by default
gosuto-inzasheru Jan 10, 2025
95f5fdc
feat: retrieve pref gauge from subgraph
gosuto-inzasheru Jan 14, 2025
88312a5
feat: add airdrop checksum
gosuto-inzasheru Feb 3, 2025
63d5f10
feat: automatic epoch ts calc
gosuto-inzasheru Feb 3, 2025
7c29616
fix: determine start before loop
gosuto-inzasheru Feb 3, 2025
c1d4e32
fix: morpho fee need multiplication
gosuto-inzasheru Feb 3, 2025
2341c27
chore: update morpho reward wei with real amount
gosuto-inzasheru Feb 3, 2025
8e75bfa
chore: upload airdrop artifact
gosuto-inzasheru Feb 3, 2025
94f693d
Automated processing of Payload PR (validations, transformations, and…
gosuto-inzasheru Feb 3, 2025
d311294
chore: add payload for epoch 0
gosuto-inzasheru Feb 3, 2025
ba30b4c
Automated processing of Payload PR (validations, transformations, and…
gosuto-inzasheru Feb 3, 2025
42cc31e
docs: add instructions for running script
gosuto-inzasheru Feb 3, 2025
40adbfa
Automated processing of Payload PR (validations, transformations, and…
gosuto-inzasheru Feb 3, 2025
9606694
perf: let bal tools determine blocks subgraph url
gosuto-inzasheru Feb 4, 2025
8786900
Automated processing of Payload PR (validations, transformations, and…
gosuto-inzasheru Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: consider both pool and gauge shares
  • Loading branch information
gosuto-inzasheru committed Jan 9, 2025
commit 287176a9cdc79acba9adc03edf7f072b1061ef89
32 changes: 27 additions & 5 deletions tools/python/gen_morpho_airdrop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from datetime import datetime
from decimal import Decimal

import numpy as np
import pandas as pd
@@ -37,7 +38,7 @@ def get_user_shares_pool(pool, block):
params,
url="https://api.studio.thegraph.com/query/75376/balancer-v3/version/latest",
)
return dict([(x["user"]["id"], x["balance"]) for x in raw["poolShares"]])
return dict([(x["user"]["id"], Decimal(x["balance"])) for x in raw["poolShares"]])


def get_user_shares_gauge(gauge, block):
@@ -57,7 +58,7 @@ def get_user_shares_gauge(gauge, block):
"block": {"number": block},
}
raw = SUBGRAPH.fetch_graphql_data("gauges", query, params)
return dict([(x["user"]["id"], x["balance"]) for x in raw["gaugeShares"]])
return dict([(x["user"]["id"], Decimal(x["balance"])) for x in raw["gaugeShares"]])


def get_block_from_timestamp(ts):
@@ -83,12 +84,29 @@ def build_snapshot_df(
n=7, # amount of snapshots
step_size=60 * 60 * 24, # amount of seconds between snapshots
):
shares = {}
gauge = GAUGE # TODO: lookup gauge from pool
pool_shares = {}
gauge_shares = {}
total_shares = {}
for _ in range(n):
block = get_block_from_timestamp(end)
shares[block] = get_user_shares_pool(pool=pool, block=block)
pool_shares[block] = get_user_shares_pool(pool=pool, block=block)
gauge_shares[block] = get_user_shares_gauge(gauge=gauge, block=block)
end -= step_size
return pd.DataFrame(shares, dtype=float).fillna(0)
for block in pool_shares:
total_shares[block] = {}
for user_id in pool_shares[block]:
if user_id == gauge:
# we do not want to count the gauge as a user
continue
total_shares[block][user_id] = pool_shares[block][user_id]
for user_id in gauge_shares[block]:
if user_id not in total_shares[block]:
total_shares[block][user_id] = gauge_shares[block][user_id]
else:
total_shares[block][user_id] += gauge_shares[block][user_id]
# TODO: checksum balances
return pd.DataFrame(total_shares, dtype=float).fillna(0)


def consolidate_shares(df):
@@ -118,8 +136,12 @@ def build_airdrop(reward_token, reward_total_wei, df):
if __name__ == "__main__":
# get bpt balances for a pool at different timestamps
df = build_snapshot_df(pool=POOL, end=LATEST_TS)
df.to_csv("tools/python/df_snapshot.csv")

# consolidate user pool shares
df = consolidate_shares(df)
df.to_csv("tools/python/df_consolidated.csv")

# build airdrop object and dump to json file
airdrop = build_airdrop(reward_token=MORPHO, reward_total_wei=1e18, df=df)
json.dump(airdrop, open("airdrop.json", "w"), indent=2)
Loading