|
7 | 7 | "outputs": [], |
8 | 8 | "source": [ |
9 | 9 | "REALTIME_ESTIMATOR = False\n", |
10 | | - "WEEK = 57" |
| 10 | + "WEEK = 58" |
11 | 11 | ] |
12 | 12 | }, |
13 | 13 | { |
|
46 | 46 | " 1: 'ethereum',\n", |
47 | 47 | " 137: 'polygon'\n", |
48 | 48 | "}\n", |
49 | | - "CLAIM_PRECISION = 18 # leave out of results addresses that mined less than CLAIM_THRESHOLD\n", |
| 49 | + "CLAIM_PRECISION = 12 # leave out of results addresses that mined less than CLAIM_THRESHOLD\n", |
50 | 50 | "CLAIM_THRESHOLD = 10**(-CLAIM_PRECISION)\n", |
51 | 51 | "reports_dir = f'reports/{WEEK}'\n", |
52 | 52 | "if not os.path.exists(reports_dir):\n", |
|
132 | 132 | " '{0}'\n", |
133 | 133 | " ];\n", |
134 | 134 | "\n", |
135 | | - " SELECT block_number, token_address, SUM(balance) AS supply\n", |
| 135 | + " SELECT block_number, token_address, SUM(balance)/1e18 AS supply\n", |
136 | 136 | " FROM `{1}`\n", |
137 | 137 | " WHERE token_address IN UNNEST(pool_addresses)\n", |
138 | 138 | " AND address <> '0x0000000000000000000000000000000000000000'\n", |
|
163 | 163 | "outputs": [], |
164 | 164 | "source": [ |
165 | 165 | "def get_bpt_supply_subgraph(pools_addresses,\n", |
| 166 | + " time_travel_block,\n", |
166 | 167 | " network):\n", |
167 | 168 | "\n", |
168 | 169 | " endpoint = {\n", |
|
173 | 174 | " query = '''\n", |
174 | 175 | " {\n", |
175 | 176 | " pools(\n", |
176 | | - " where:{address_in:\n", |
| 177 | + " block: {number: {}},\n", |
| 178 | + " where:{address_in:\n", |
177 | 179 | " [\"{}\"]\n", |
178 | 180 | " }\n", |
179 | 181 | " ) {\n", |
|
182 | 184 | " }\n", |
183 | 185 | " }\n", |
184 | 186 | " '''.replace('{','{{').replace('}','}}').replace('{{}}','{}').format(\n", |
| 187 | + " time_travel_block,\n", |
185 | 188 | " '\",\"'.join(pools_addresses)\n", |
186 | 189 | " )\n", |
187 | 190 | " r = requests.post(endpoint[network], json = {'query':query})\n", |
|
303 | 306 | " supply_gbq = get_bpt_supply_gbq(df.index, chain['chainId'])\n", |
304 | 307 | " supply_gbq.set_index('token_address', inplace=True)\n", |
305 | 308 | " supply_gbq.index.name = 'pool_address'\n", |
306 | | - " supply_subgraph = get_bpt_supply_subgraph(df.index, chain['chainId'])\n", |
| 309 | + " gbq_block_number = int(supply_gbq.iloc[0]['block_number'])\n", |
| 310 | + " supply_subgraph = get_bpt_supply_subgraph(df.index, gbq_block_number, chain['chainId'])\n", |
307 | 311 | " supply_subgraph.set_index('address', inplace=True)\n", |
308 | 312 | " supply_subgraph.index.name = 'pool_address'\n", |
309 | 313 | " all_good = True\n", |
310 | 314 | " for i,r in supply_subgraph.join(supply_gbq).iterrows():\n", |
311 | | - " error = (r.supply/1e18 / r.totalShares)\n", |
| 315 | + " error = (r.supply / r.totalShares)\n", |
312 | 316 | " if abs(error-1) > 1e-3:\n", |
313 | 317 | " all_good = False\n", |
314 | 318 | " print(f'{i} : {error:.3f}')\n", |
315 | 319 | " if all_good:\n", |
316 | | - " print(' All good')\n", |
| 320 | + " print(' All good\\n')\n", |
317 | 321 | " else:\n", |
318 | | - " print('other than that, all good') \n", |
| 322 | + " print('other than that, all good\\n') \n", |
319 | 323 | " \n", |
320 | 324 | " chain_export = v2_liquidity_mining(WEEK, df, chain['chainId'])\n", |
321 | 325 | " chain_export['chain_id'] = chain['chainId']\n", |
|
423 | 427 | " full_export['timestamp'] = week_end_timestamp\n", |
424 | 428 | " full_export['week'] = WEEK\n", |
425 | 429 | " full_export.reset_index(inplace=True)\n", |
426 | | - "# full_export.dropna(inplace=True)\n", |
427 | | - "# full_export.to_gbq('bal_mining_estimates.lp_estimates_multitoken', \n", |
428 | | - "# project_id=os.environ['GCP_PROJECT'], \n", |
429 | | - "# if_exists='replace')\n", |
430 | 430 | " full_export.to_gbq('bal_mining_estimates.lp_estimates_multitoken_staging', \n", |
431 | 431 | " project_id=os.environ['GCP_PROJECT'], \n", |
432 | 432 | " if_exists='replace')\n", |
|
453 | 453 | " query.result()" |
454 | 454 | ] |
455 | 455 | }, |
456 | | - { |
457 | | - "cell_type": "code", |
458 | | - "execution_count": null, |
459 | | - "metadata": {}, |
460 | | - "outputs": [], |
461 | | - "source": [ |
462 | | - "pd.read_json(\n", |
463 | | - " f'https://raw.githubusercontent.com/balancer-labs/assets/master/lists/ui-not-eligible.json', \n", |
464 | | - " orient='index').loc['homestead'].values.tolist()" |
465 | | - ] |
466 | | - }, |
467 | 456 | { |
468 | 457 | "cell_type": "markdown", |
469 | 458 | "metadata": {}, |
|
0 commit comments