diff --git a/tutorials/FundingMetrics.ipynb b/tutorials/FundingMetrics.ipynb new file mode 100644 index 00000000..d64c4876 --- /dev/null +++ b/tutorials/FundingMetrics.ipynb @@ -0,0 +1,1192 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "41b714c9-c749-4d0d-ad59-71e0c035d325", + "metadata": {}, + "outputs": [], + "source": [ + "# ! pip install pyoso" + ] + }, + { + "cell_type": "markdown", + "id": "413d143d-4494-4812-8cae-d28f47cc397e", + "metadata": {}, + "source": [ + "## Setup\n", + "\n", + "Load environment variables, import necessary libraries, and initialize the OSO client" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "988cd219-8b29-469d-9e7a-46f7a965ddc7", + "metadata": {}, + "outputs": [], + "source": [ + "from dotenv import load_dotenv\n", + "import os\n", + "import pandas as pd\n", + "from pyoso import Client\n", + "\n", + "load_dotenv()\n", + "\n", + "OSO_API_KEY = os.environ['OSO_API_KEY']\n", + "client = Client(api_key=OSO_API_KEY)" + ] + }, + { + "cell_type": "markdown", + "id": "4231b926-89ab-48de-8746-b0d10f44c470", + "metadata": {}, + "source": [ + "## Testing\n", + "\n", + "Query the metrics table for all metric names containing '_funding_' and display them in alphabetical order" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "77fe6763-7d49-47a5-b5c6-68264034ab0c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
metric_name
0GITCOIN_DONATIONS_funding_awarded_biannually
1GITCOIN_DONATIONS_funding_awarded_daily
2GITCOIN_DONATIONS_funding_awarded_monthly
3GITCOIN_DONATIONS_funding_awarded_over_all_time
4GITCOIN_DONATIONS_funding_awarded_quarterly
5GITCOIN_DONATIONS_funding_awarded_weekly
6GITCOIN_DONATIONS_funding_awarded_yearly
7GITCOIN_MATCHING_funding_awarded_biannually
8GITCOIN_MATCHING_funding_awarded_daily
9GITCOIN_MATCHING_funding_awarded_monthly
10GITCOIN_MATCHING_funding_awarded_over_all_time
11GITCOIN_MATCHING_funding_awarded_quarterly
12GITCOIN_MATCHING_funding_awarded_weekly
13GITCOIN_MATCHING_funding_awarded_yearly
14OPEN_COLLECTIVE_funding_received_biannually
15OPEN_COLLECTIVE_funding_received_daily
16OPEN_COLLECTIVE_funding_received_monthly
17OPEN_COLLECTIVE_funding_received_over_all_time
18OPEN_COLLECTIVE_funding_received_quarterly
19OPEN_COLLECTIVE_funding_received_weekly
20OPEN_COLLECTIVE_funding_received_yearly
21OSS_FUNDING_funding_awarded_biannually
22OSS_FUNDING_funding_awarded_daily
23OSS_FUNDING_funding_awarded_monthly
24OSS_FUNDING_funding_awarded_over_all_time
25OSS_FUNDING_funding_awarded_quarterly
26OSS_FUNDING_funding_awarded_weekly
27OSS_FUNDING_funding_awarded_yearly
\n", + "
" + ], + "text/plain": [ + " metric_name\n", + "0 GITCOIN_DONATIONS_funding_awarded_biannually\n", + "1 GITCOIN_DONATIONS_funding_awarded_daily\n", + "2 GITCOIN_DONATIONS_funding_awarded_monthly\n", + "3 GITCOIN_DONATIONS_funding_awarded_over_all_time\n", + "4 GITCOIN_DONATIONS_funding_awarded_quarterly\n", + "5 GITCOIN_DONATIONS_funding_awarded_weekly\n", + "6 GITCOIN_DONATIONS_funding_awarded_yearly\n", + "7 GITCOIN_MATCHING_funding_awarded_biannually\n", + "8 GITCOIN_MATCHING_funding_awarded_daily\n", + "9 GITCOIN_MATCHING_funding_awarded_monthly\n", + "10 GITCOIN_MATCHING_funding_awarded_over_all_time\n", + "11 GITCOIN_MATCHING_funding_awarded_quarterly\n", + "12 GITCOIN_MATCHING_funding_awarded_weekly\n", + "13 GITCOIN_MATCHING_funding_awarded_yearly\n", + "14 OPEN_COLLECTIVE_funding_received_biannually\n", + "15 OPEN_COLLECTIVE_funding_received_daily\n", + "16 OPEN_COLLECTIVE_funding_received_monthly\n", + "17 OPEN_COLLECTIVE_funding_received_over_all_time\n", + "18 OPEN_COLLECTIVE_funding_received_quarterly\n", + "19 OPEN_COLLECTIVE_funding_received_weekly\n", + "20 OPEN_COLLECTIVE_funding_received_yearly\n", + "21 OSS_FUNDING_funding_awarded_biannually\n", + "22 OSS_FUNDING_funding_awarded_daily\n", + "23 OSS_FUNDING_funding_awarded_monthly\n", + "24 OSS_FUNDING_funding_awarded_over_all_time\n", + "25 OSS_FUNDING_funding_awarded_quarterly\n", + "26 OSS_FUNDING_funding_awarded_weekly\n", + "27 OSS_FUNDING_funding_awarded_yearly" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + "SELECT metric_name\n", + "FROM metrics_v0\n", + "WHERE metric_name LIKE '%_funding_%'\n", + "ORDER BY 1\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "e85f23d4-3605-40f6-8228-ce175de20f30", + "metadata": {}, + "source": [ + "## Aggregate funding metrics\n", + "\n", + "### By source\n", + "\n", + "We currently support CSV data uploads via [oss-funding](https://github.com/opensource-observer/oss-funding) and Gitcoin Grants. We also have Open Collective deposits, but they don't show up here (yet)." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "aa31b0d1-2117-4fb0-8b6e-f206500602d2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
metric_nametotal_amount_in_usd
0OSS_FUNDING_funding_awarded_over_all_time364887873.600968
1GITCOIN_MATCHING_funding_awarded_over_all_time13305117.158144
2GITCOIN_DONATIONS_funding_awarded_over_all_time11666103.711711
\n", + "
" + ], + "text/plain": [ + " metric_name total_amount_in_usd\n", + "0 OSS_FUNDING_funding_awarded_over_all_time 364887873.600968\n", + "1 GITCOIN_MATCHING_funding_awarded_over_all_time 13305117.158144\n", + "2 GITCOIN_DONATIONS_funding_awarded_over_all_time 11666103.711711" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + "SELECT\n", + " m.metric_name,\n", + " SUM(km.amount) AS total_amount_in_usd\n", + "FROM key_metrics_by_project_v0 AS km\n", + "JOIN metrics_v0 AS m ON km.metric_id = m.metric_id\n", + "WHERE m.metric_name LIKE '%_funding_%'\n", + "GROUP BY 1\n", + "ORDER BY 2 DESC\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "0d2902b8-468b-44ae-bae9-d797ec18de0d", + "metadata": {}, + "source": [ + "### To projects\n", + "\n", + "We can also see the largest project recipients with this query." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "c9edc7a4-19d1-443c-bc01-ced2c6ffda65", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
project_display_nametotal_amount_in_usd
0GMX21000000.0
1MUX Protocol10876479.0
2Synthetix10022628.074157
3Perpetual Protocol9287212.140718
4Gains Network7898396.135
5Velodrome7895037.76024
6Camelot5407500.0
7Stargate Finance5289458.865658
8Vertex Protocol5250000.0
9Radiant4991077.0
\n", + "
" + ], + "text/plain": [ + " project_display_name total_amount_in_usd\n", + "0 GMX 21000000.0\n", + "1 MUX Protocol 10876479.0\n", + "2 Synthetix 10022628.074157\n", + "3 Perpetual Protocol 9287212.140718\n", + "4 Gains Network 7898396.135\n", + "5 Velodrome 7895037.76024\n", + "6 Camelot 5407500.0\n", + "7 Stargate Finance 5289458.865658\n", + "8 Vertex Protocol 5250000.0\n", + "9 Radiant 4991077.0" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + "SELECT\n", + " p.display_name AS project_display_name,\n", + " SUM(km.amount) AS total_amount_in_usd\n", + "FROM key_metrics_by_project_v0 AS km\n", + "JOIN metrics_v0 AS m ON km.metric_id = m.metric_id\n", + "JOIN projects_v1 AS p ON km.project_id = p.project_id\n", + "WHERE m.metric_name LIKE '%_funding_awarded_over_all_time'\n", + "GROUP BY 1\n", + "ORDER BY 2 DESC\n", + "LIMIT 10\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "0841ca11-505d-47bc-acdc-5ca8314af991", + "metadata": {}, + "source": [ + "### To projects from a specific source" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "9783c7e0-c2e0-4f1c-9dda-42d458cb39ce", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
project_display_nametotal_amount_in_usd
0Gitcoin1099895.038376
1Revoke748859.365745
2DefiLlama429924.507285
3Hey360529.24178
4JediSwap333277.670918
5Dark Forest332205.420888
6ZigZag Exchange210175.931949
7ethers.js190702.539836
8rotki174990.340416
9Taho170854.869607
\n", + "
" + ], + "text/plain": [ + " project_display_name total_amount_in_usd\n", + "0 Gitcoin 1099895.038376\n", + "1 Revoke 748859.365745\n", + "2 DefiLlama 429924.507285\n", + "3 Hey 360529.24178\n", + "4 JediSwap 333277.670918\n", + "5 Dark Forest 332205.420888\n", + "6 ZigZag Exchange 210175.931949\n", + "7 ethers.js 190702.539836\n", + "8 rotki 174990.340416\n", + "9 Taho 170854.869607" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + "SELECT\n", + " p.display_name AS project_display_name,\n", + " SUM(km.amount) AS total_amount_in_usd\n", + "FROM key_metrics_by_project_v0 AS km\n", + "JOIN metrics_v0 AS m ON km.metric_id = m.metric_id\n", + "JOIN projects_v1 AS p ON km.project_id = p.project_id\n", + "WHERE m.metric_name = 'GITCOIN_DONATIONS_funding_awarded_over_all_time'\n", + "GROUP BY 1\n", + "ORDER BY 2 DESC\n", + "LIMIT 10\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "807ac8df-5c90-4c14-821b-d29ebab1089c", + "metadata": {}, + "source": [ + "### To projects from a specific source and time frame" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "69f8d8ff-f902-4cce-bc3f-d23182f84de3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
project_display_nametotal_amount_in_usd
0Gitcoin797206.330376
1Dark Forest297517.115925
2ZigZag Exchange199746.433382
3ethers.js129500.966707
4Prysm Ethereum Client128522.705766
5rotki122666.927997
6ZeroPool116795.642612
7Lighthouse by Sigma Prime114759.839844
8The Tor Project110669.738113
9Hardhat110539.758225
\n", + "
" + ], + "text/plain": [ + " project_display_name total_amount_in_usd\n", + "0 Gitcoin 797206.330376\n", + "1 Dark Forest 297517.115925\n", + "2 ZigZag Exchange 199746.433382\n", + "3 ethers.js 129500.966707\n", + "4 Prysm Ethereum Client 128522.705766\n", + "5 rotki 122666.927997\n", + "6 ZeroPool 116795.642612\n", + "7 Lighthouse by Sigma Prime 114759.839844\n", + "8 The Tor Project 110669.738113\n", + "9 Hardhat 110539.758225" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + "SELECT\n", + " p.display_name AS project_display_name,\n", + " SUM(tm.amount) AS total_amount_in_usd\n", + "FROM timeseries_metrics_by_project_v0 AS tm\n", + "JOIN metrics_v0 AS m ON tm.metric_id = m.metric_id\n", + "JOIN projects_v1 AS p ON tm.project_id = p.project_id\n", + "WHERE m.metric_name = 'GITCOIN_DONATIONS_funding_awarded_yearly'\n", + "AND tm.sample_date < DATE '2022-01-01'\n", + "GROUP BY 1\n", + "ORDER BY 2 DESC\n", + "LIMIT 10\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "fe5ad20c-7772-4e94-83ec-77baea215d00", + "metadata": {}, + "source": [ + "## More granular analysis\n", + "\n", + "### Gitcoin\n", + "\n", + "Deep dive on Gitcoin grants to a specific project" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "60aa05c7-098f-4e6f-8183-a01fc5ed9652", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
timeround_numberround_nameevent_sourcedonor_addressamount_in_usd
02023-02-09 15:58:07.078<NA>Gitcoin GrantsGITCOIN_DONATIONS0x386ea3171dcc9405311fd75b316cc2a87ecadeca617893.575
12023-08-29 08:32:57.00018Web3 Open Source SoftwareGITCOIN_MATCHING<NA>15001.1375
22024-11-25 14:26:59.00022GG22 OSS - dApps and AppsGITCOIN_MATCHING<NA>14984.28125
32024-05-31 14:35:02.00020dApps & AppsGITCOIN_MATCHING<NA>14979.978125
42023-11-29 20:18:47.00019Web3 Open Source SoftwareGITCOIN_MATCHING<NA>14849.591509
52022-08-24 00:00:00.00015<NA>GITCOIN_MATCHING<NA>12500.0
62024-08-26 15:19:00.00021GG21: Thriving Arbitrum SummerGITCOIN_MATCHING<NA>9839.680095
72022-08-24 00:00:00.00015<NA>GITCOIN_MATCHING<NA>7410.488854
82024-05-07 10:04:49.00020dApps & AppsGITCOIN_DONATIONS0xe2a26d5174b133abc4b338df1b07295f03a4c85e1000.42865
92024-05-06 17:29:47.00020dApps & AppsGITCOIN_DONATIONS0x60a06b2eee871e349331143ef173ecefd7a8ce01537.338562
\n", + "
" + ], + "text/plain": [ + " time round_number round_name \\\n", + "0 2023-02-09 15:58:07.078 Gitcoin Grants \n", + "1 2023-08-29 08:32:57.000 18 Web3 Open Source Software \n", + "2 2024-11-25 14:26:59.000 22 GG22 OSS - dApps and Apps \n", + "3 2024-05-31 14:35:02.000 20 dApps & Apps \n", + "4 2023-11-29 20:18:47.000 19 Web3 Open Source Software \n", + "5 2022-08-24 00:00:00.000 15 \n", + "6 2024-08-26 15:19:00.000 21 GG21: Thriving Arbitrum Summer \n", + "7 2022-08-24 00:00:00.000 15 \n", + "8 2024-05-07 10:04:49.000 20 dApps & Apps \n", + "9 2024-05-06 17:29:47.000 20 dApps & Apps \n", + "\n", + " event_source donor_address \\\n", + "0 GITCOIN_DONATIONS 0x386ea3171dcc9405311fd75b316cc2a87ecadeca \n", + "1 GITCOIN_MATCHING \n", + "2 GITCOIN_MATCHING \n", + "3 GITCOIN_MATCHING \n", + "4 GITCOIN_MATCHING \n", + "5 GITCOIN_MATCHING \n", + "6 GITCOIN_MATCHING \n", + "7 GITCOIN_MATCHING \n", + "8 GITCOIN_DONATIONS 0xe2a26d5174b133abc4b338df1b07295f03a4c85e \n", + "9 GITCOIN_DONATIONS 0x60a06b2eee871e349331143ef173ecefd7a8ce01 \n", + "\n", + " amount_in_usd \n", + "0 617893.575 \n", + "1 15001.1375 \n", + "2 14984.28125 \n", + "3 14979.978125 \n", + "4 14849.591509 \n", + "5 12500.0 \n", + "6 9839.680095 \n", + "7 7410.488854 \n", + "8 1000.42865 \n", + "9 537.338562 " + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + " SELECT\n", + " time,\n", + " round_number,\n", + " round_name,\n", + " event_source,\n", + " donor_address,\n", + " amount_in_usd\n", + " FROM int_events__gitcoin_funding\n", + " WHERE gitcoin_group_project_name = 'revokecash'\n", + " ORDER BY amount_in_usd DESC\n", + " LIMIT 10\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "144e833e-cf24-4659-a43b-35505d95501a", + "metadata": {}, + "source": [ + "## OSS Funding\n", + "\n", + "Overview of specific funders and grant pools in oss-funding data" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "fa50c103-7c3c-4fb2-bcb1-ff754a8b53f6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
from_funder_namegrant_poolsamount_in_usd
0optimism12240450291.744
1arbitrumfoundation1122850952.0
2stellar2932989032.98
3octant-golemfoundation53965429.51329
4dao-drops-dorgtech1250001.0
5clrfund183028.740386
\n", + "
" + ], + "text/plain": [ + " from_funder_name grant_pools amount_in_usd\n", + "0 optimism 12 240450291.744\n", + "1 arbitrumfoundation 1 122850952.0\n", + "2 stellar 29 32989032.98\n", + "3 octant-golemfoundation 5 3965429.51329\n", + "4 dao-drops-dorgtech 1 250001.0\n", + "5 clrfund 1 83028.740386" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.to_pandas(\"\"\"\n", + "SELECT\n", + " from_funder_name,\n", + " COUNT(DISTINCT grant_pool_name) AS grant_pools,\n", + " SUM(amount) AS amount_in_usd\n", + "FROM stg_ossd__current_funding\n", + "GROUP BY 1\n", + "ORDER BY 3 DESC\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "id": "f7aaf46c-45b8-444e-a6f1-27286085a463", + "metadata": {}, + "source": [ + "## Funding flows\n", + "\n", + "We can use this to construct a simple sankey diagram of funding flows" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "1bd3a7a8-8cac-420e-9e7b-5259ff0e3b2d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
from_project_idto_project_idfunderprojectamount
2142Qgbm336fY9862LN2Czg3UX04A3p7I/79Bv2M4D61DAI=8IKXraxq1pDuQD1xaDI20cjFrel55TZ/zf6LmP69qEg=Gitcoinefdevcon13.531599
2143Qgbm336fY9862LN2Czg3UX04A3p7I/79Bv2M4D61DAI=79HQoZtyZftibazh6Yz63aU06XODWs7b/9h4JAqPa1s=GitcoinLexDAO86499.728685
21445Fgf9xv3CxTV+YbSShdY9XCJs7tgW8KNwQWq9rHUEsQ=79HQoZtyZftibazh6Yz63aU06XODWs7b/9h4JAqPa1s=clr.fundLexDAO193.952856
2145Qgbm336fY9862LN2Czg3UX04A3p7I/79Bv2M4D61DAI=yEebFy4M1iAdb9+YQmdssSx9Qf+ZXfSVguL/JyidngI=GitcoinDeFiEye224058.115245
21465Fgf9xv3CxTV+YbSShdY9XCJs7tgW8KNwQWq9rHUEsQ=JQtLQErRk0u41xS292Cg+s3cRr8LaD5lQ2kME/Syp2Q=clr.fundAsilo Digital703.639308
\n", + "
" + ], + "text/plain": [ + " from_project_id \\\n", + "2142 Qgbm336fY9862LN2Czg3UX04A3p7I/79Bv2M4D61DAI= \n", + "2143 Qgbm336fY9862LN2Czg3UX04A3p7I/79Bv2M4D61DAI= \n", + "2144 5Fgf9xv3CxTV+YbSShdY9XCJs7tgW8KNwQWq9rHUEsQ= \n", + "2145 Qgbm336fY9862LN2Czg3UX04A3p7I/79Bv2M4D61DAI= \n", + "2146 5Fgf9xv3CxTV+YbSShdY9XCJs7tgW8KNwQWq9rHUEsQ= \n", + "\n", + " to_project_id funder project \\\n", + "2142 8IKXraxq1pDuQD1xaDI20cjFrel55TZ/zf6LmP69qEg= Gitcoin efdevcon \n", + "2143 79HQoZtyZftibazh6Yz63aU06XODWs7b/9h4JAqPa1s= Gitcoin LexDAO \n", + "2144 79HQoZtyZftibazh6Yz63aU06XODWs7b/9h4JAqPa1s= clr.fund LexDAO \n", + "2145 yEebFy4M1iAdb9+YQmdssSx9Qf+ZXfSVguL/JyidngI= Gitcoin DeFiEye \n", + "2146 JQtLQErRk0u41xS292Cg+s3cRr8LaD5lQ2kME/Syp2Q= clr.fund Asilo Digital \n", + "\n", + " amount \n", + "2142 13.531599 \n", + "2143 86499.728685 \n", + "2144 193.952856 \n", + "2145 224058.115245 \n", + "2146 703.639308 " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"\n", + "SELECT\n", + " fp.project_id AS from_project_id,\n", + " tp.project_id AS to_project_id,\n", + " fp.display_name AS funder,\n", + " tp.display_name AS project,\n", + " SUM(e.amount) AS amount\n", + "FROM int_events_daily__funding AS e\n", + "JOIN artifacts_by_project_v1 AS fa\n", + " ON e.from_artifact_id = fa.artifact_id\n", + "JOIN artifacts_by_project_v1 AS ta\n", + " ON e.to_artifact_id = ta.artifact_id\n", + "JOIN projects_v1 AS fp\n", + " ON fa.project_id = fp.project_id\n", + "JOIN projects_v1 AS tp\n", + " ON ta.project_id = tp.project_id\n", + "GROUP BY 1,2,3,4\n", + "\"\"\"\n", + "df = client.to_pandas(query)\n", + "df.tail()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}