Created
May 17, 2023 18:44
-
-
Save Evan-Kim2028/85df8b9e760629bcb4cb10989adfe8fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from subgrounds import Subgrounds\n", | |
"from subgrounds.schema import TypeRef\n", | |
"from subgrounds.subgraph import SyntheticField" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sg = Subgrounds()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"univ3 = sg.load_subgraph('https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum') # returns a subgraph" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"my_fp =sg.subgraphs[list(sg.subgraphs.keys())[0]].Query.swaps" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"my_qp = my_fp(\n", | |
" orderBy=my_fp._select('tokenIn')._select('symbol'), # Disable this and the query works\n", | |
" # orderBy=my_fp.tokenIn.symbol,\n", | |
" # orderDirection='desc',\n", | |
" # where = {\n", | |
" # 'pool_': {'id': '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640'},\n", | |
" # 'timestamp_lt': 1682458079,\n", | |
" # 'timestamp_gt': 1682458079 - 1000,\n", | |
" # },\n", | |
" first=500\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"query_paths_all = [\n", | |
" 'id', \n", | |
" 'hash', \n", | |
" 'nonce', \n", | |
" 'logIndex', \n", | |
" 'gasLimit', \n", | |
" 'gasUsed', \n", | |
" 'gasPrice', \n", | |
" # 'protocol', # protocol object\n", | |
" # 'account', # account object\n", | |
" # 'pool', # pool object\n", | |
" 'blockNumber', \n", | |
" 'timestamp', \n", | |
" 'tick', 'tokenIn', 'amountIn', 'amountInUSD', 'tokenOut', 'amountOut', 'amountOutUSD']\n", | |
"\n", | |
"query_paths_conv = [my_qp._select(path) for path in query_paths_all]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "KeyError", | |
"evalue": "'TypeMeta.InputObjectMeta.type_of_input_field: no input field named swaps for input object Swap_filter'", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mStopIteration\u001b[0m Traceback (most recent call last)", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/schema.py:309\u001b[0m, in \u001b[0;36mTypeMeta.InputObjectMeta.type_of_input_field\u001b[0;34m(self, fname)\u001b[0m\n\u001b[1;32m 308\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 309\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mnext\u001b[39;49m(\n\u001b[1;32m 310\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49minput_fields\n\u001b[1;32m 311\u001b[0m \u001b[39m|\u001b[39;49m where(\u001b[39mlambda\u001b[39;49;00m infield: infield\u001b[39m.\u001b[39;49mname \u001b[39m==\u001b[39;49m fname)\n\u001b[1;32m 312\u001b[0m \u001b[39m|\u001b[39;49m \u001b[39mmap\u001b[39;49m(\u001b[39mlambda\u001b[39;49;00m infield: infield\u001b[39m.\u001b[39;49mtype_)\n\u001b[1;32m 313\u001b[0m )\n\u001b[1;32m 314\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mStopIteration\u001b[39;00m:\n", | |
"\u001b[0;31mStopIteration\u001b[0m: ", | |
"\nDuring handling of the above exception, another exception occurred:\n", | |
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", | |
"Cell \u001b[0;32mIn[14], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[39m# get all liquidity pools with their tokens\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m df \u001b[39m=\u001b[39m sg\u001b[39m.\u001b[39;49mquery_df([query_paths_conv])\n\u001b[1;32m 4\u001b[0m \u001b[39m# sg.query_df([my_qp.protocol]) # default behavior for objects is to gather all fields in the object. \u001b[39;00m\n\u001b[1;32m 5\u001b[0m \u001b[39m# sg.query_df(query_paths_conv) #\u001b[39;00m\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:414\u001b[0m, in \u001b[0;36mSubgrounds.query_df\u001b[0;34m(self, fpaths, columns, concat, pagination_strategy)\u001b[0m\n\u001b[1;32m 347\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Same as :func:`Subgrounds.query` but formats the response data into a\u001b[39;00m\n\u001b[1;32m 348\u001b[0m \u001b[39mPandas DataFrame. If the response data cannot be flattened to a single query\u001b[39;00m\n\u001b[1;32m 349\u001b[0m \u001b[39m(e.g.: when querying multiple list fields that return different entities),\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 410\u001b[0m \u001b[39m 9 1643213196 2610.686563\u001b[39;00m\n\u001b[1;32m 411\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 413\u001b[0m fpaths \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m([fpaths] \u001b[39m|\u001b[39m traverse \u001b[39m|\u001b[39m \u001b[39mmap\u001b[39m(FieldPath\u001b[39m.\u001b[39m_auto_select) \u001b[39m|\u001b[39m traverse)\n\u001b[0;32m--> 414\u001b[0m json_data \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mquery_json(fpaths, pagination_strategy\u001b[39m=\u001b[39;49mpagination_strategy)\n\u001b[1;32m 415\u001b[0m \u001b[39mreturn\u001b[39;00m df_of_json(json_data, fpaths, columns, concat)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:316\u001b[0m, in \u001b[0;36mSubgrounds.query_json\u001b[0;34m(self, fpaths, pagination_strategy)\u001b[0m\n\u001b[1;32m 314\u001b[0m fpaths \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m([fpaths] \u001b[39m|\u001b[39m traverse \u001b[39m|\u001b[39m \u001b[39mmap\u001b[39m(FieldPath\u001b[39m.\u001b[39m_auto_select) \u001b[39m|\u001b[39m traverse)\n\u001b[1;32m 315\u001b[0m req \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mmk_request(fpaths)\n\u001b[0;32m--> 316\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mexecute(req, pagination_strategy\u001b[39m=\u001b[39;49mpagination_strategy)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:229\u001b[0m, in \u001b[0;36mSubgrounds.execute\u001b[0;34m(self, req, pagination_strategy)\u001b[0m\n\u001b[1;32m 225\u001b[0m \u001b[39mreturn\u001b[39;00m transform\u001b[39m.\u001b[39mtransform_response(req, data)\n\u001b[1;32m 227\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mFalse\u001b[39;00m \u001b[39m# Suppress mypy missing return statement warning\u001b[39;00m\n\u001b[0;32m--> 229\u001b[0m \u001b[39mreturn\u001b[39;00m transform_req(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mglobal_transforms, req)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:214\u001b[0m, in \u001b[0;36mSubgrounds.execute.<locals>.transform_req\u001b[0;34m(transforms, req)\u001b[0m\n\u001b[1;32m 212\u001b[0m \u001b[39mmatch\u001b[39;00m transforms:\n\u001b[1;32m 213\u001b[0m \u001b[39mcase\u001b[39;00m []:\n\u001b[0;32m--> 214\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mlist\u001b[39;49m(\n\u001b[1;32m 215\u001b[0m req\u001b[39m.\u001b[39;49mdocuments\n\u001b[1;32m 216\u001b[0m \u001b[39m|\u001b[39;49m \u001b[39mmap\u001b[39;49m(\n\u001b[1;32m 217\u001b[0m \u001b[39mlambda\u001b[39;49;00m doc: transform_doc(\n\u001b[1;32m 218\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49msubgraphs[doc\u001b[39m.\u001b[39;49murl]\u001b[39m.\u001b[39;49m_transforms, doc\n\u001b[1;32m 219\u001b[0m )\n\u001b[1;32m 220\u001b[0m )\n\u001b[1;32m 221\u001b[0m )\n\u001b[1;32m 222\u001b[0m \u001b[39mcase\u001b[39;00m [transform, \u001b[39m*\u001b[39mrest]:\n\u001b[1;32m 223\u001b[0m new_req \u001b[39m=\u001b[39m transform\u001b[39m.\u001b[39mtransform_request(req)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:217\u001b[0m, in \u001b[0;36mSubgrounds.execute.<locals>.transform_req.<locals>.<lambda>\u001b[0;34m(doc)\u001b[0m\n\u001b[1;32m 212\u001b[0m \u001b[39mmatch\u001b[39;00m transforms:\n\u001b[1;32m 213\u001b[0m \u001b[39mcase\u001b[39;00m []:\n\u001b[1;32m 214\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mlist\u001b[39m(\n\u001b[1;32m 215\u001b[0m req\u001b[39m.\u001b[39mdocuments\n\u001b[1;32m 216\u001b[0m \u001b[39m|\u001b[39m \u001b[39mmap\u001b[39m(\n\u001b[0;32m--> 217\u001b[0m \u001b[39mlambda\u001b[39;00m doc: transform_doc(\n\u001b[1;32m 218\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49msubgraphs[doc\u001b[39m.\u001b[39;49murl]\u001b[39m.\u001b[39;49m_transforms, doc\n\u001b[1;32m 219\u001b[0m )\n\u001b[1;32m 220\u001b[0m )\n\u001b[1;32m 221\u001b[0m )\n\u001b[1;32m 222\u001b[0m \u001b[39mcase\u001b[39;00m [transform, \u001b[39m*\u001b[39mrest]:\n\u001b[1;32m 223\u001b[0m new_req \u001b[39m=\u001b[39m transform\u001b[39m.\u001b[39mtransform_request(req)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:204\u001b[0m, in \u001b[0;36mSubgrounds.execute.<locals>.transform_doc\u001b[0;34m(transforms, doc)\u001b[0m\n\u001b[1;32m 202\u001b[0m \u001b[39mcase\u001b[39;00m [transform, \u001b[39m*\u001b[39mrest]:\n\u001b[1;32m 203\u001b[0m new_doc \u001b[39m=\u001b[39m transform\u001b[39m.\u001b[39mtransform_document(doc)\n\u001b[0;32m--> 204\u001b[0m data \u001b[39m=\u001b[39m transform_doc(rest, new_doc)\n\u001b[1;32m 205\u001b[0m \u001b[39mreturn\u001b[39;00m transform\u001b[39m.\u001b[39mtransform_response(doc, data)\n\u001b[1;32m 207\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mFalse\u001b[39;00m\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:204\u001b[0m, in \u001b[0;36mSubgrounds.execute.<locals>.transform_doc\u001b[0;34m(transforms, doc)\u001b[0m\n\u001b[1;32m 202\u001b[0m \u001b[39mcase\u001b[39;00m [transform, \u001b[39m*\u001b[39mrest]:\n\u001b[1;32m 203\u001b[0m new_doc \u001b[39m=\u001b[39m transform\u001b[39m.\u001b[39mtransform_document(doc)\n\u001b[0;32m--> 204\u001b[0m data \u001b[39m=\u001b[39m transform_doc(rest, new_doc)\n\u001b[1;32m 205\u001b[0m \u001b[39mreturn\u001b[39;00m transform\u001b[39m.\u001b[39mtransform_response(doc, data)\n\u001b[1;32m 207\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mFalse\u001b[39;00m\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:201\u001b[0m, in \u001b[0;36mSubgrounds.execute.<locals>.transform_doc\u001b[0;34m(transforms, doc)\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[39mmatch\u001b[39;00m transforms:\n\u001b[1;32m 200\u001b[0m \u001b[39mcase\u001b[39;00m []:\n\u001b[0;32m--> 201\u001b[0m \u001b[39mreturn\u001b[39;00m execute_document(doc)\n\u001b[1;32m 202\u001b[0m \u001b[39mcase\u001b[39;00m [transform, \u001b[39m*\u001b[39mrest]:\n\u001b[1;32m 203\u001b[0m new_doc \u001b[39m=\u001b[39m transform\u001b[39m.\u001b[39mtransform_document(doc)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/subgrounds.py:186\u001b[0m, in \u001b[0;36mSubgrounds.execute.<locals>.execute_document\u001b[0;34m(doc)\u001b[0m\n\u001b[1;32m 182\u001b[0m subgraph: Subgraph \u001b[39m=\u001b[39m \u001b[39mnext\u001b[39m(\n\u001b[1;32m 183\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39msubgraphs\u001b[39m.\u001b[39mvalues() \u001b[39m|\u001b[39m where(\u001b[39mlambda\u001b[39;00m sg: sg\u001b[39m.\u001b[39m_url \u001b[39m==\u001b[39m doc\u001b[39m.\u001b[39murl)\n\u001b[1;32m 184\u001b[0m )\n\u001b[1;32m 185\u001b[0m \u001b[39mif\u001b[39;00m pagination_strategy \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m subgraph\u001b[39m.\u001b[39m_is_subgraph:\n\u001b[0;32m--> 186\u001b[0m \u001b[39mreturn\u001b[39;00m paginate(\n\u001b[1;32m 187\u001b[0m subgraph\u001b[39m.\u001b[39;49m_schema,\n\u001b[1;32m 188\u001b[0m doc,\n\u001b[1;32m 189\u001b[0m pagination_strategy\u001b[39m=\u001b[39;49mpagination_strategy,\n\u001b[1;32m 190\u001b[0m headers\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mheaders,\n\u001b[1;32m 191\u001b[0m )\n\u001b[1;32m 192\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 193\u001b[0m \u001b[39mreturn\u001b[39;00m client\u001b[39m.\u001b[39mquery(\n\u001b[1;32m 194\u001b[0m doc\u001b[39m.\u001b[39murl, doc\u001b[39m.\u001b[39mgraphql, variables\u001b[39m=\u001b[39mdoc\u001b[39m.\u001b[39mvariables, headers\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mheaders\n\u001b[1;32m 195\u001b[0m )\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/pagination/pagination.py:74\u001b[0m, in \u001b[0;36mpaginate\u001b[0;34m(schema, doc, pagination_strategy, headers)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Executes the request document `doc` based on the GraphQL schema `schema` and returns\u001b[39;00m\n\u001b[1;32m 63\u001b[0m \u001b[39mthe response as a JSON dictionary.\u001b[39;00m\n\u001b[1;32m 64\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 70\u001b[0m \u001b[39m dict[str, Any]: The response data as a JSON dictionary\u001b[39;00m\n\u001b[1;32m 71\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 73\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m---> 74\u001b[0m strategy \u001b[39m=\u001b[39m pagination_strategy(schema, doc)\n\u001b[1;32m 76\u001b[0m data: \u001b[39mdict\u001b[39m[\u001b[39mstr\u001b[39m, Any] \u001b[39m=\u001b[39m {}\n\u001b[1;32m 77\u001b[0m doc, args \u001b[39m=\u001b[39m strategy\u001b[39m.\u001b[39mstep()\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/pagination/strategies.py:255\u001b[0m, in \u001b[0;36mLegacyStrategy.__init__\u001b[0;34m(self, schema, document)\u001b[0m\n\u001b[1;32m 252\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__init__\u001b[39m(\u001b[39mself\u001b[39m, schema: SchemaMeta, document: Document) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 253\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mschema \u001b[39m=\u001b[39m schema\n\u001b[0;32m--> 255\u001b[0m pagination_nodes \u001b[39m=\u001b[39m generate_pagination_nodes(schema, document)\n\u001b[1;32m 257\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mlen\u001b[39m(pagination_nodes) \u001b[39m==\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[1;32m 258\u001b[0m \u001b[39mraise\u001b[39;00m SkipPagination\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/pagination/preprocess.py:192\u001b[0m, in \u001b[0;36mgenerate_pagination_nodes\u001b[0;34m(schema, document)\u001b[0m\n\u001b[1;32m 165\u001b[0m filtering_arg_type: TypeRef\u001b[39m.\u001b[39mT \u001b[39m=\u001b[39m schema\u001b[39m.\u001b[39mtype_of_input_object_meta(\n\u001b[1;32m 166\u001b[0m where_arg_type, filtering_args\n\u001b[1;32m 167\u001b[0m )\n\u001b[1;32m 169\u001b[0m \u001b[39mreturn\u001b[39;00m PaginationNode(\n\u001b[1;32m 170\u001b[0m node_idx\u001b[39m=\u001b[39midx,\n\u001b[1;32m 171\u001b[0m filter_field\u001b[39m=\u001b[39morderBy_val,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 189\u001b[0m inner\u001b[39m=\u001b[39mchildren,\n\u001b[1;32m 190\u001b[0m )\n\u001b[0;32m--> 192\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mlist\u001b[39m(document\u001b[39m.\u001b[39;49mquery\u001b[39m.\u001b[39;49mfold(fold_f) \u001b[39m|\u001b[39m traverse)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/query.py:1332\u001b[0m, in \u001b[0;36mQuery.fold\u001b[0;34m(self, fold_f)\u001b[0m\n\u001b[1;32m 1328\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mfold\u001b[39m(\n\u001b[1;32m 1329\u001b[0m \u001b[39mself\u001b[39m,\n\u001b[1;32m 1330\u001b[0m fold_f: Callable[[Selection, \u001b[39mlist\u001b[39m[Selection], \u001b[39mlist\u001b[39m[T]], T \u001b[39m|\u001b[39m \u001b[39mlist\u001b[39m[T]],\n\u001b[1;32m 1331\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mlist\u001b[39m[T]:\n\u001b[0;32m-> 1332\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mlist\u001b[39;49m(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mselection \u001b[39m|\u001b[39;49m \u001b[39mmap\u001b[39;49m(partial(Selection\u001b[39m.\u001b[39;49mfold, fold_f\u001b[39m=\u001b[39;49mfold_f)))\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/query.py:696\u001b[0m, in \u001b[0;36mSelection.fold\u001b[0;34m(self, fold_f, parents)\u001b[0m\n\u001b[1;32m 686\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mfold\u001b[39m(\n\u001b[1;32m 687\u001b[0m \u001b[39mself\u001b[39m,\n\u001b[1;32m 688\u001b[0m fold_f: Callable[[Selection, \u001b[39mlist\u001b[39m[Selection], \u001b[39mlist\u001b[39m[T]], T \u001b[39m|\u001b[39m \u001b[39mlist\u001b[39m[T]],\n\u001b[1;32m 689\u001b[0m parents: \u001b[39mlist\u001b[39m[Selection] \u001b[39m=\u001b[39m [],\n\u001b[1;32m 690\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m T \u001b[39m|\u001b[39m \u001b[39mlist\u001b[39m[T]:\n\u001b[1;32m 691\u001b[0m inner \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m(\n\u001b[1;32m 692\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mselection\n\u001b[1;32m 693\u001b[0m \u001b[39m|\u001b[39m \u001b[39mmap\u001b[39m(partial(Selection\u001b[39m.\u001b[39mfold, fold_f\u001b[39m=\u001b[39mfold_f, parents\u001b[39m=\u001b[39m[\u001b[39m*\u001b[39mparents, \u001b[39mself\u001b[39m]))\n\u001b[1;32m 694\u001b[0m \u001b[39m|\u001b[39m traverse\n\u001b[1;32m 695\u001b[0m )\n\u001b[0;32m--> 696\u001b[0m \u001b[39mreturn\u001b[39;00m fold_f(\u001b[39mself\u001b[39;49m, parents, inner)\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/pagination/preprocess.py:165\u001b[0m, in \u001b[0;36mgenerate_pagination_nodes.<locals>.fold_f\u001b[0;34m(current, parents, children)\u001b[0m\n\u001b[1;32m 163\u001b[0m t: TypeRef\u001b[39m.\u001b[39mT \u001b[39m=\u001b[39m current\u001b[39m.\u001b[39mfmeta\u001b[39m.\u001b[39mtype_of_arg(\u001b[39m\"\u001b[39m\u001b[39mwhere\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 164\u001b[0m where_arg_type: TypeMeta\u001b[39m.\u001b[39mInputObjectMeta \u001b[39m=\u001b[39m schema\u001b[39m.\u001b[39mtype_of_typeref(t)\n\u001b[0;32m--> 165\u001b[0m filtering_arg_type: TypeRef\u001b[39m.\u001b[39mT \u001b[39m=\u001b[39m schema\u001b[39m.\u001b[39;49mtype_of_input_object_meta(\n\u001b[1;32m 166\u001b[0m where_arg_type, filtering_args\n\u001b[1;32m 167\u001b[0m )\n\u001b[1;32m 169\u001b[0m \u001b[39mreturn\u001b[39;00m PaginationNode(\n\u001b[1;32m 170\u001b[0m node_idx\u001b[39m=\u001b[39midx,\n\u001b[1;32m 171\u001b[0m filter_field\u001b[39m=\u001b[39morderBy_val,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 189\u001b[0m inner\u001b[39m=\u001b[39mchildren,\n\u001b[1;32m 190\u001b[0m )\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/schema.py:422\u001b[0m, in \u001b[0;36mSchemaMeta.type_of_input_object_meta\u001b[0;34m(self, tmeta, args)\u001b[0m\n\u001b[1;32m 419\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mlen\u001b[39m(args) \u001b[39m<\u001b[39m \u001b[39m1\u001b[39m:\n\u001b[1;32m 420\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mException\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mtype_of_input_object_meta: TODO\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m--> 422\u001b[0m type_ref \u001b[39m=\u001b[39m tmeta\u001b[39m.\u001b[39;49mtype_of_input_field(args\u001b[39m.\u001b[39;49mpop(\u001b[39m0\u001b[39;49m))\n\u001b[1;32m 423\u001b[0m \u001b[39mmatch\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtype_of_typeref(type_ref):\n\u001b[1;32m 424\u001b[0m \u001b[39mcase\u001b[39;00m TypeMeta\u001b[39m.\u001b[39mInputObjectMeta() \u001b[39mas\u001b[39;00m tmeta:\n", | |
"File \u001b[0;32m~/Documents/github/subgraph-query-portal/.venv/lib/python3.10/site-packages/subgrounds/schema.py:315\u001b[0m, in \u001b[0;36mTypeMeta.InputObjectMeta.type_of_input_field\u001b[0;34m(self, fname)\u001b[0m\n\u001b[1;32m 309\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mnext\u001b[39m(\n\u001b[1;32m 310\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39minput_fields\n\u001b[1;32m 311\u001b[0m \u001b[39m|\u001b[39m where(\u001b[39mlambda\u001b[39;00m infield: infield\u001b[39m.\u001b[39mname \u001b[39m==\u001b[39m fname)\n\u001b[1;32m 312\u001b[0m \u001b[39m|\u001b[39m \u001b[39mmap\u001b[39m(\u001b[39mlambda\u001b[39;00m infield: infield\u001b[39m.\u001b[39mtype_)\n\u001b[1;32m 313\u001b[0m )\n\u001b[1;32m 314\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mStopIteration\u001b[39;00m:\n\u001b[0;32m--> 315\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mKeyError\u001b[39;00m(\n\u001b[1;32m 316\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mTypeMeta.InputObjectMeta.type_of_input_field: no input field named \u001b[39m\u001b[39m{\u001b[39;00mfname\u001b[39m}\u001b[39;00m\u001b[39m for input object \u001b[39m\u001b[39m{\u001b[39;00m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mname\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\n\u001b[1;32m 317\u001b[0m )\n", | |
"\u001b[0;31mKeyError\u001b[0m: 'TypeMeta.InputObjectMeta.type_of_input_field: no input field named swaps for input object Swap_filter'" | |
] | |
} | |
], | |
"source": [ | |
"# get all liquidity pools with their tokens\n", | |
"df = sg.query_df([query_paths_conv])\n", | |
"\n", | |
"# sg.query_df([my_qp.protocol]) # default behavior for objects is to gather all fields in the object. \n", | |
"# sg.query_df(query_paths_conv) #" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"where_dict1 = {\n", | |
" # This doesn't work\n", | |
" # swaps_entity.tokenIn_in : ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'] \n", | |
" # swaps_entity.tokenOut_in : ['0xdAC17F958D2ee523a2206206994597C13D831ec7']\n", | |
" \n", | |
" # This works\n", | |
" \"tokenIn_in\": ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'],\n", | |
" \"tokenOut_in\": ['0xdAC17F958D2ee523a2206206994597C13D831ec7']\n", | |
" }\n", | |
"\n", | |
"# Note there is also a tokenIn_: Token_filter value in the swap_filter entity ...is there an equivalent to do `swap_filter_example._select('pool')._select('id')` but with filters?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"where_dict1 = {\n", | |
" \"tokenIn_\": {\"symbol_in\": ['WETH']}\n", | |
" }\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "NameError", | |
"evalue": "name 'univ3_sg' is not defined", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", | |
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m swap_filter_example \u001b[39m=\u001b[39m univ3_sg\u001b[39m.\u001b[39mQuery\u001b[39m.\u001b[39mswaps(\n\u001b[1;32m 2\u001b[0m orderBy\u001b[39m=\u001b[39muniv3_sg\u001b[39m.\u001b[39mQuery\u001b[39m.\u001b[39mswaps\u001b[39m.\u001b[39mtimestamp,\n\u001b[1;32m 3\u001b[0m orderDirection\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mdesc\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[1;32m 4\u001b[0m where\u001b[39m=\u001b[39m where_dict1\n\u001b[1;32m 5\u001b[0m )\n", | |
"\u001b[0;31mNameError\u001b[0m: name 'univ3_sg' is not defined" | |
] | |
} | |
], | |
"source": [ | |
"swap_filter_example = univ3_sg.Query.swaps(\n", | |
" orderBy=univ3_sg.Query.swaps.timestamp,\n", | |
" orderDirection='desc',\n", | |
" where= where_dict1\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>swaps_pool_id</th>\n", | |
" <th>swaps_tokenIn_symbol</th>\n", | |
" <th>swaps_tokenOut_symbol</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>0x3ee301ed8f42d106def4f9d9730ea3367880b771</td>\n", | |
" <td>WETH</td>\n", | |
" <td>ASH</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDC</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0x3782a3425cd093d5cd0c5b684be72641e199029c</td>\n", | |
" <td>WETH</td>\n", | |
" <td>BYTES</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDC</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>95</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>96</th>\n", | |
" <td>0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDC</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>97</th>\n", | |
" <td>0x24ee2c6b9597f035088cda8575e9d5e15a84b9df</td>\n", | |
" <td>WETH</td>\n", | |
" <td>QNT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>98</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>99</th>\n", | |
" <td>0xf8a95b2409c27678a6d18d950c5d913d5c38ab03</td>\n", | |
" <td>WETH</td>\n", | |
" <td>GALA</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>100 rows × 3 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" swaps_pool_id swaps_tokenIn_symbol \\\n", | |
"0 0x3ee301ed8f42d106def4f9d9730ea3367880b771 WETH \n", | |
"1 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640 WETH \n", | |
"2 0x3782a3425cd093d5cd0c5b684be72641e199029c WETH \n", | |
"3 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640 WETH \n", | |
"4 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
".. ... ... \n", | |
"95 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"96 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640 WETH \n", | |
"97 0x24ee2c6b9597f035088cda8575e9d5e15a84b9df WETH \n", | |
"98 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"99 0xf8a95b2409c27678a6d18d950c5d913d5c38ab03 WETH \n", | |
"\n", | |
" swaps_tokenOut_symbol \n", | |
"0 ASH \n", | |
"1 USDC \n", | |
"2 BYTES \n", | |
"3 USDC \n", | |
"4 USDT \n", | |
".. ... \n", | |
"95 USDT \n", | |
"96 USDC \n", | |
"97 QNT \n", | |
"98 USDT \n", | |
"99 GALA \n", | |
"\n", | |
"[100 rows x 3 columns]" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# get all liquidity pools with their tokens\n", | |
"sg.query_df([\n", | |
" swap_filter_example._select('pool')._select('id'),\n", | |
" swap_filter_example._select('tokenIn')._select('symbol'),\n", | |
" swap_filter_example._select('tokenOut')._select('symbol'),\n", | |
" ])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>swaps_pool_id</th>\n", | |
" <th>swaps_tokenIn_symbol</th>\n", | |
" <th>swaps_tokenOut_symbol</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>0x0318170609141bfdb38d20d1f1c5b5197670ecee</td>\n", | |
" <td>WETH</td>\n", | |
" <td>SOV</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0x666ed8c2151f00e7e58b4d941f65a9df68d2245b</td>\n", | |
" <td>WETH</td>\n", | |
" <td>WOOF</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0xaf9060d26826964c1b9329582e23b4adbf7679e3</td>\n", | |
" <td>WETH</td>\n", | |
" <td>JPEG</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0x9a772018fbd77fcd2d25657e5c547baff3fd7d16</td>\n", | |
" <td>WBTC</td>\n", | |
" <td>USDC</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>0x0434cbab59141b6fee54d6a3fd3e4bd47274a9f4</td>\n", | |
" <td>WETH</td>\n", | |
" <td>ePhiat</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>95</th>\n", | |
" <td>0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDC</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>96</th>\n", | |
" <td>0x60a6b23a7a87c5ce9e3f81c869691f784b18a704</td>\n", | |
" <td>MTO</td>\n", | |
" <td>WETH</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>97</th>\n", | |
" <td>0xe0f32e865248e333291fffd13efb4e9027551b2b</td>\n", | |
" <td>WETH</td>\n", | |
" <td>GPT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>98</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>USDT</td>\n", | |
" <td>WETH</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>99</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>100 rows × 3 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" swaps_pool_id swaps_tokenIn_symbol \\\n", | |
"0 0x0318170609141bfdb38d20d1f1c5b5197670ecee WETH \n", | |
"1 0x666ed8c2151f00e7e58b4d941f65a9df68d2245b WETH \n", | |
"2 0xaf9060d26826964c1b9329582e23b4adbf7679e3 WETH \n", | |
"3 0x9a772018fbd77fcd2d25657e5c547baff3fd7d16 WBTC \n", | |
"4 0x0434cbab59141b6fee54d6a3fd3e4bd47274a9f4 WETH \n", | |
".. ... ... \n", | |
"95 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640 WETH \n", | |
"96 0x60a6b23a7a87c5ce9e3f81c869691f784b18a704 MTO \n", | |
"97 0xe0f32e865248e333291fffd13efb4e9027551b2b WETH \n", | |
"98 0x11b815efb8f581194ae79006d24e0d814b7697f6 USDT \n", | |
"99 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"\n", | |
" swaps_tokenOut_symbol \n", | |
"0 SOV \n", | |
"1 WOOF \n", | |
"2 JPEG \n", | |
"3 USDC \n", | |
"4 ePhiat \n", | |
".. ... \n", | |
"95 USDC \n", | |
"96 WETH \n", | |
"97 GPT \n", | |
"98 WETH \n", | |
"99 USDT \n", | |
"\n", | |
"[100 rows x 3 columns]" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# get all liquidity pools with their tokens\n", | |
"sg.query_df([\n", | |
" swaps_qp._select('pool')._select('id'),\n", | |
" swaps_qp._select('tokenIn')._select('symbol'),\n", | |
" swaps_qp._select('tokenOut')._select('symbol'),\n", | |
" ])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"STOP" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'pool_id'" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# query_paths = ['id', 'timestamp']\n", | |
"query_paths = ['id', 'pool', 'timestamp']\n", | |
"\n", | |
"query_path_cols = [\n", | |
" swaps_qp._select(field) for field in query_paths\n", | |
"]\n", | |
"query_path_cols" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'id']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'positionCount']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'openPositionCount']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'closedPositionCount']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'depositCount']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'withdrawCount']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', 'swapCount']),\n", | |
" FieldPath(https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum, Query, ['swaps', 'account', '_newUser'])]" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"swaps_qp._select('account')._auto_select()" | |
] | |
}, | |
{ | |
"attachments": {}, | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Filters? How to obtain filters from a subgraph entity" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"\n", | |
"\n", | |
"tokens_entity = univ3_sg.Token\n", | |
"tokens_fp = univ3_sg.Query.tokens\n", | |
"\n", | |
"lp_entity = univ3_sg.LiquidityPool\n", | |
"lp_fp = univ3_sg.Query.liquidityPools" | |
] | |
}, | |
{ | |
"attachments": {}, | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Obtain column list" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# return a list of all of fields of an object\n", | |
"# col_list = list((field.name, TypeRef.graphql(field.type_)) for field in lp_entity._object.fields)\n", | |
"# col_list[:10]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"swaps_df = sg.query_df(swaps_qp)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>swaps_id</th>\n", | |
" <th>swaps_hash</th>\n", | |
" <th>swaps_nonce</th>\n", | |
" <th>swaps_logIndex</th>\n", | |
" <th>swaps_gasLimit</th>\n", | |
" <th>swaps_gasUsed</th>\n", | |
" <th>swaps_gasPrice</th>\n", | |
" <th>swaps_protocol_id</th>\n", | |
" <th>swaps_account_id</th>\n", | |
" <th>swaps_pool_id</th>\n", | |
" <th>...</th>\n", | |
" <th>swaps_timestamp</th>\n", | |
" <th>swaps_tick</th>\n", | |
" <th>swaps_tokenIn_id</th>\n", | |
" <th>swaps_amountIn</th>\n", | |
" <th>swaps_amountInUSD</th>\n", | |
" <th>swaps_tokenOut_id</th>\n", | |
" <th>swaps_amountOut</th>\n", | |
" <th>swaps_amountOutUSD</th>\n", | |
" <th>swaps_datetime</th>\n", | |
" <th>swaps_tokenIn_symbol</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>0xad05dd0b14fb1bf86e1aa3eda7c71ba40b09f5917fec...</td>\n", | |
" <td>0xad05dd0b14fb1bf86e1aa3eda7c71ba40b09f5917fec...</td>\n", | |
" <td>63</td>\n", | |
" <td>6</td>\n", | |
" <td>2245180</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0x090041db8e7826ddfba01812cf843ecef1d97312</td>\n", | |
" <td>0xa8bd646f72ea828ccbc40fa2976866884f883409</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704210</td>\n", | |
" <td>-76812</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>5067600322843545</td>\n", | |
" <td>9.621572</td>\n", | |
" <td>0x6694340fc020c5e6b96567843da2df01b2ce1eb6</td>\n", | |
" <td>10945285464953080943</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>2023-04-05 10:16:50</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0x4082bc799661734d9438d4e20a48d87915abacfe4798...</td>\n", | |
" <td>0x4082bc799661734d9438d4e20a48d87915abacfe4798...</td>\n", | |
" <td>196</td>\n", | |
" <td>14</td>\n", | |
" <td>2620412</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0x9dd11beda19bcbfdb011c3228093cae2f0266452</td>\n", | |
" <td>0x42161084d0672e1d3f26a9b53e653be2084ff19c</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704208</td>\n", | |
" <td>-200831</td>\n", | |
" <td>0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9</td>\n", | |
" <td>3741648</td>\n", | |
" <td>3.741648</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>1970334842315517</td>\n", | |
" <td>3.740966</td>\n", | |
" <td>2023-04-05 10:16:48</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0x4082bc799661734d9438d4e20a48d87915abacfe4798...</td>\n", | |
" <td>0x4082bc799661734d9438d4e20a48d87915abacfe4798...</td>\n", | |
" <td>196</td>\n", | |
" <td>11</td>\n", | |
" <td>2620412</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0x9dd11beda19bcbfdb011c3228093cae2f0266452</td>\n", | |
" <td>0xdb9f3540955b3c5df246dba83b96727fcb3424a1</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704208</td>\n", | |
" <td>-274136</td>\n", | |
" <td>0x912ce59144191c1204e64559fe8253a0e49e6548</td>\n", | |
" <td>3000000000000000000</td>\n", | |
" <td>3.722732</td>\n", | |
" <td>0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9</td>\n", | |
" <td>3741648</td>\n", | |
" <td>3.741648</td>\n", | |
" <td>2023-04-05 10:16:48</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0x3486af96954098627eef000fccaa9f3b69e956c1f3bd...</td>\n", | |
" <td>0x3486af96954098627eef000fccaa9f3b69e956c1f3bd...</td>\n", | |
" <td>7</td>\n", | |
" <td>10</td>\n", | |
" <td>2413537</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0x747aa78b708d95c47e2ba82f668cd383e46681f7</td>\n", | |
" <td>0xa8bd646f72ea828ccbc40fa2976866884f883409</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704208</td>\n", | |
" <td>-76812</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>23147953470446255</td>\n", | |
" <td>43.949738</td>\n", | |
" <td>0x6694340fc020c5e6b96567843da2df01b2ce1eb6</td>\n", | |
" <td>50000000000000000000</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>2023-04-05 10:16:48</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>0xcd6ddc41d22d37bfe2e99fa5f3a9eb38bb873b777430...</td>\n", | |
" <td>0xcd6ddc41d22d37bfe2e99fa5f3a9eb38bb873b777430...</td>\n", | |
" <td>63</td>\n", | |
" <td>6</td>\n", | |
" <td>4000000</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0x34986ea4707f9ca0d231308615de4cc61257c93c</td>\n", | |
" <td>0x0dcf98667c5400b7bc8de4ec2e4d03c5cd11fa85</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704205</td>\n", | |
" <td>93876</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>1452000000000000</td>\n", | |
" <td>2.757609</td>\n", | |
" <td>0xdd69db25f6d620a7bad3023c5d32761d353d3de9</td>\n", | |
" <td>17278357410424614698</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>2023-04-05 10:16:45</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>...</th>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" <td>...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>95</th>\n", | |
" <td>0xf1a7decb1a813a69e3393c0d0cfd5fcb1826e7b4dd91...</td>\n", | |
" <td>0xf1a7decb1a813a69e3393c0d0cfd5fcb1826e7b4dd91...</td>\n", | |
" <td>109779</td>\n", | |
" <td>153</td>\n", | |
" <td>2000000</td>\n", | |
" <td>None</td>\n", | |
" <td>502000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0xc9f32f110e68f7c371280db8a146edeb283700a5</td>\n", | |
" <td>0x2f5e87c9312fa29aed5c179e456625d79015299c</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704174</td>\n", | |
" <td>257277</td>\n", | |
" <td>0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f</td>\n", | |
" <td>33613230</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>5002320501152172938</td>\n", | |
" <td>9495.578606</td>\n", | |
" <td>2023-04-05 10:16:14</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>96</th>\n", | |
" <td>0xaed4091057b9e2d119dd3885d1a67eda4c6bc928b93d...</td>\n", | |
" <td>0xaed4091057b9e2d119dd3885d1a67eda4c6bc928b93d...</td>\n", | |
" <td>13</td>\n", | |
" <td>4</td>\n", | |
" <td>2221056</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0xa118552ffbb783e936235b4a7331134986a17ef0</td>\n", | |
" <td>0xc31e54c7a869b9fcbecc14363cf510d1c41fa443</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704174</td>\n", | |
" <td>-200834</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>40000000000000000</td>\n", | |
" <td>75.929390</td>\n", | |
" <td>0xff970a61a04b1ca14834a43f5de4533ebddb5cc8</td>\n", | |
" <td>75891408</td>\n", | |
" <td>75.891408</td>\n", | |
" <td>2023-04-05 10:16:14</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>97</th>\n", | |
" <td>0x957b4818c265afdb105ec9bb0af775078d1e7cdfa0b0...</td>\n", | |
" <td>0x957b4818c265afdb105ec9bb0af775078d1e7cdfa0b0...</td>\n", | |
" <td>35622</td>\n", | |
" <td>6</td>\n", | |
" <td>10000000</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0xaf780a3b858edc4e82bfdfab908c9de68c24f4d9</td>\n", | |
" <td>0x641c00a822e8b671738d32a431a4fb6074e5c79d</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704174</td>\n", | |
" <td>-200837</td>\n", | |
" <td>0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9</td>\n", | |
" <td>5087294949</td>\n", | |
" <td>5087.294949</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>2679522092846301240</td>\n", | |
" <td>5086.361950</td>\n", | |
" <td>2023-04-05 10:16:14</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>98</th>\n", | |
" <td>0x684cd208b881449dd57c8c2e97bb0088d1c41886410f...</td>\n", | |
" <td>0x684cd208b881449dd57c8c2e97bb0088d1c41886410f...</td>\n", | |
" <td>139062</td>\n", | |
" <td>18</td>\n", | |
" <td>6000000</td>\n", | |
" <td>None</td>\n", | |
" <td>321000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0xc6d973b31bb135caba83cf0574c0347bd763ecc5</td>\n", | |
" <td>0xc31e54c7a869b9fcbecc14363cf510d1c41fa443</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704174</td>\n", | |
" <td>-200833</td>\n", | |
" <td>0xff970a61a04b1ca14834a43f5de4533ebddb5cc8</td>\n", | |
" <td>9496177253</td>\n", | |
" <td>9496.177253</td>\n", | |
" <td>0x82af49447d8a07e3bd95bd0d56f35241523fbab1</td>\n", | |
" <td>5000000000000000000</td>\n", | |
" <td>9491.173750</td>\n", | |
" <td>2023-04-05 10:16:14</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>99</th>\n", | |
" <td>0x07eacd655850ca9ba4ff8a85b3b2cb7b102c87c68292...</td>\n", | |
" <td>0x07eacd655850ca9ba4ff8a85b3b2cb7b102c87c68292...</td>\n", | |
" <td>14</td>\n", | |
" <td>133</td>\n", | |
" <td>5795290</td>\n", | |
" <td>None</td>\n", | |
" <td>100000000</td>\n", | |
" <td>0x1f98431c8ad98523631ae4a59f267346ea31f984</td>\n", | |
" <td>0x00ce39fe5331cf91c5f8a4a02c4f648f6a7b4514</td>\n", | |
" <td>0xa74eceae9c7670b019e0890881598b4c398d1c01</td>\n", | |
" <td>...</td>\n", | |
" <td>1680704174</td>\n", | |
" <td>-275197</td>\n", | |
" <td>0xff970a61a04b1ca14834a43f5de4533ebddb5cc8</td>\n", | |
" <td>126079</td>\n", | |
" <td>0.126079</td>\n", | |
" <td>0x31c91d8fb96bff40955dd2dbc909b36e8b104dde</td>\n", | |
" <td>112293377133275855</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>2023-04-05 10:16:14</td>\n", | |
" <td>uknown</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>100 rows × 21 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" swaps_id \\\n", | |
"0 0xad05dd0b14fb1bf86e1aa3eda7c71ba40b09f5917fec... \n", | |
"1 0x4082bc799661734d9438d4e20a48d87915abacfe4798... \n", | |
"2 0x4082bc799661734d9438d4e20a48d87915abacfe4798... \n", | |
"3 0x3486af96954098627eef000fccaa9f3b69e956c1f3bd... \n", | |
"4 0xcd6ddc41d22d37bfe2e99fa5f3a9eb38bb873b777430... \n", | |
".. ... \n", | |
"95 0xf1a7decb1a813a69e3393c0d0cfd5fcb1826e7b4dd91... \n", | |
"96 0xaed4091057b9e2d119dd3885d1a67eda4c6bc928b93d... \n", | |
"97 0x957b4818c265afdb105ec9bb0af775078d1e7cdfa0b0... \n", | |
"98 0x684cd208b881449dd57c8c2e97bb0088d1c41886410f... \n", | |
"99 0x07eacd655850ca9ba4ff8a85b3b2cb7b102c87c68292... \n", | |
"\n", | |
" swaps_hash swaps_nonce \\\n", | |
"0 0xad05dd0b14fb1bf86e1aa3eda7c71ba40b09f5917fec... 63 \n", | |
"1 0x4082bc799661734d9438d4e20a48d87915abacfe4798... 196 \n", | |
"2 0x4082bc799661734d9438d4e20a48d87915abacfe4798... 196 \n", | |
"3 0x3486af96954098627eef000fccaa9f3b69e956c1f3bd... 7 \n", | |
"4 0xcd6ddc41d22d37bfe2e99fa5f3a9eb38bb873b777430... 63 \n", | |
".. ... ... \n", | |
"95 0xf1a7decb1a813a69e3393c0d0cfd5fcb1826e7b4dd91... 109779 \n", | |
"96 0xaed4091057b9e2d119dd3885d1a67eda4c6bc928b93d... 13 \n", | |
"97 0x957b4818c265afdb105ec9bb0af775078d1e7cdfa0b0... 35622 \n", | |
"98 0x684cd208b881449dd57c8c2e97bb0088d1c41886410f... 139062 \n", | |
"99 0x07eacd655850ca9ba4ff8a85b3b2cb7b102c87c68292... 14 \n", | |
"\n", | |
" swaps_logIndex swaps_gasLimit swaps_gasUsed swaps_gasPrice \\\n", | |
"0 6 2245180 None 100000000 \n", | |
"1 14 2620412 None 100000000 \n", | |
"2 11 2620412 None 100000000 \n", | |
"3 10 2413537 None 100000000 \n", | |
"4 6 4000000 None 100000000 \n", | |
".. ... ... ... ... \n", | |
"95 153 2000000 None 502000000 \n", | |
"96 4 2221056 None 100000000 \n", | |
"97 6 10000000 None 100000000 \n", | |
"98 18 6000000 None 321000000 \n", | |
"99 133 5795290 None 100000000 \n", | |
"\n", | |
" swaps_protocol_id \\\n", | |
"0 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"1 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"2 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"3 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"4 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
".. ... \n", | |
"95 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"96 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"97 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"98 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"99 0x1f98431c8ad98523631ae4a59f267346ea31f984 \n", | |
"\n", | |
" swaps_account_id \\\n", | |
"0 0x090041db8e7826ddfba01812cf843ecef1d97312 \n", | |
"1 0x9dd11beda19bcbfdb011c3228093cae2f0266452 \n", | |
"2 0x9dd11beda19bcbfdb011c3228093cae2f0266452 \n", | |
"3 0x747aa78b708d95c47e2ba82f668cd383e46681f7 \n", | |
"4 0x34986ea4707f9ca0d231308615de4cc61257c93c \n", | |
".. ... \n", | |
"95 0xc9f32f110e68f7c371280db8a146edeb283700a5 \n", | |
"96 0xa118552ffbb783e936235b4a7331134986a17ef0 \n", | |
"97 0xaf780a3b858edc4e82bfdfab908c9de68c24f4d9 \n", | |
"98 0xc6d973b31bb135caba83cf0574c0347bd763ecc5 \n", | |
"99 0x00ce39fe5331cf91c5f8a4a02c4f648f6a7b4514 \n", | |
"\n", | |
" swaps_pool_id ... swaps_timestamp \\\n", | |
"0 0xa8bd646f72ea828ccbc40fa2976866884f883409 ... 1680704210 \n", | |
"1 0x42161084d0672e1d3f26a9b53e653be2084ff19c ... 1680704208 \n", | |
"2 0xdb9f3540955b3c5df246dba83b96727fcb3424a1 ... 1680704208 \n", | |
"3 0xa8bd646f72ea828ccbc40fa2976866884f883409 ... 1680704208 \n", | |
"4 0x0dcf98667c5400b7bc8de4ec2e4d03c5cd11fa85 ... 1680704205 \n", | |
".. ... ... ... \n", | |
"95 0x2f5e87c9312fa29aed5c179e456625d79015299c ... 1680704174 \n", | |
"96 0xc31e54c7a869b9fcbecc14363cf510d1c41fa443 ... 1680704174 \n", | |
"97 0x641c00a822e8b671738d32a431a4fb6074e5c79d ... 1680704174 \n", | |
"98 0xc31e54c7a869b9fcbecc14363cf510d1c41fa443 ... 1680704174 \n", | |
"99 0xa74eceae9c7670b019e0890881598b4c398d1c01 ... 1680704174 \n", | |
"\n", | |
" swaps_tick swaps_tokenIn_id \\\n", | |
"0 -76812 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 \n", | |
"1 -200831 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 \n", | |
"2 -274136 0x912ce59144191c1204e64559fe8253a0e49e6548 \n", | |
"3 -76812 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 \n", | |
"4 93876 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 \n", | |
".. ... ... \n", | |
"95 257277 0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f \n", | |
"96 -200834 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 \n", | |
"97 -200837 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 \n", | |
"98 -200833 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 \n", | |
"99 -275197 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 \n", | |
"\n", | |
" swaps_amountIn swaps_amountInUSD \\\n", | |
"0 5067600322843545 9.621572 \n", | |
"1 3741648 3.741648 \n", | |
"2 3000000000000000000 3.722732 \n", | |
"3 23147953470446255 43.949738 \n", | |
"4 1452000000000000 2.757609 \n", | |
".. ... ... \n", | |
"95 33613230 0.000000 \n", | |
"96 40000000000000000 75.929390 \n", | |
"97 5087294949 5087.294949 \n", | |
"98 9496177253 9496.177253 \n", | |
"99 126079 0.126079 \n", | |
"\n", | |
" swaps_tokenOut_id swaps_amountOut \\\n", | |
"0 0x6694340fc020c5e6b96567843da2df01b2ce1eb6 10945285464953080943 \n", | |
"1 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 1970334842315517 \n", | |
"2 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 3741648 \n", | |
"3 0x6694340fc020c5e6b96567843da2df01b2ce1eb6 50000000000000000000 \n", | |
"4 0xdd69db25f6d620a7bad3023c5d32761d353d3de9 17278357410424614698 \n", | |
".. ... ... \n", | |
"95 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 5002320501152172938 \n", | |
"96 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8 75891408 \n", | |
"97 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 2679522092846301240 \n", | |
"98 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 5000000000000000000 \n", | |
"99 0x31c91d8fb96bff40955dd2dbc909b36e8b104dde 112293377133275855 \n", | |
"\n", | |
" swaps_amountOutUSD swaps_datetime swaps_tokenIn_symbol \n", | |
"0 0.000000 2023-04-05 10:16:50 uknown \n", | |
"1 3.740966 2023-04-05 10:16:48 uknown \n", | |
"2 3.741648 2023-04-05 10:16:48 uknown \n", | |
"3 0.000000 2023-04-05 10:16:48 uknown \n", | |
"4 0.000000 2023-04-05 10:16:45 uknown \n", | |
".. ... ... ... \n", | |
"95 9495.578606 2023-04-05 10:16:14 uknown \n", | |
"96 75.891408 2023-04-05 10:16:14 uknown \n", | |
"97 5086.361950 2023-04-05 10:16:14 uknown \n", | |
"98 9491.173750 2023-04-05 10:16:14 uknown \n", | |
"99 0.000000 2023-04-05 10:16:14 uknown \n", | |
"\n", | |
"[100 rows x 21 columns]" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"swaps_df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# create a dictionary of token ids and their symbols\n", | |
"token_dict = dict(zip(tokens_df['tokens_id'], tokens_df['tokens_symbol']))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# make new synthetic field on swaps entity\n", | |
"swaps_entity.tokenIn_symbol = SyntheticField.map(\n", | |
" token_dict,\n", | |
" SyntheticField.STRING,\n", | |
" swaps_entity.tokenIn.id,\n", | |
" 'UNKNOWN'\n", | |
" )" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"swaps_qp = uni_swaps_qp(\n", | |
" first= 125,\n", | |
" orderBy=uni_swaps_qp.timestamp,\n", | |
" orderDirection='desc',\n", | |
" where = {\n", | |
" swaps_entity.tokenIn_symbol: 'WETH'\n", | |
" }\n", | |
" )" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"swaps_df = sg.query_df(swaps_qp)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"swaps_id 0xfff3d2262aa12669fa128559d4d18eb4dfb37b0e30ce...\n", | |
"swaps_hash 0xfff3d2262aa12669fa128559d4d18eb4dfb37b0e30ce...\n", | |
"swaps_nonce 489214\n", | |
"swaps_logIndex 57\n", | |
"swaps_gasLimit 15000000\n", | |
"swaps_gasUsed None\n", | |
"swaps_gasPrice 25000000000\n", | |
"swaps_protocol_id 0x1f98431c8ad98523631ae4a59f267346ea31f984\n", | |
"swaps_account_id 0xfd01bfd397eaf3dcd8247f9793f36e9da2056650\n", | |
"swaps_pool_id 0xf2d315ff65d99f0ccd5c0f2b495796b330305810\n", | |
"swaps_blockNumber 75646048\n", | |
"swaps_timestamp 1680278883\n", | |
"swaps_tick 142380\n", | |
"swaps_tokenIn_id 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8\n", | |
"swaps_amountIn 15000000000000000000000\n", | |
"swaps_amountInUSD 20557.903262\n", | |
"swaps_tokenOut_id 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8\n", | |
"swaps_amountOut 12134267552637263157490\n", | |
"swaps_amountOutUSD 20513.371726\n", | |
"swaps_tokenIn_symbol wstETH\n", | |
"dtype: object" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# get max values for each column in swaps_df\n", | |
"swaps_df.max()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# convert nonce, gasLimit, gasUsed, gasPrice, tick, amountIn, amountOut to float\n", | |
"swaps_df['swaps_nonce'] = swaps_df['swaps_nonce'].astype('float')\n", | |
"swaps_df['swaps_gasLimit'] = swaps_df['swaps_gasLimit'].astype('float')\n", | |
"swaps_df['swaps_gasUsed'] = swaps_df['swaps_gasUsed'].astype('float')\n", | |
"swaps_df['swaps_gasPrice'] = swaps_df['swaps_gasPrice'].astype('float')\n", | |
"swaps_df['swaps_tick'] = swaps_df['swaps_tick'].astype('float')\n", | |
"swaps_df['swaps_amountIn'] = swaps_df['swaps_amountIn'].astype('float')\n", | |
"swaps_df['swaps_amountOut'] = swaps_df['swaps_amountOut'].astype('float')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"Index(['swaps_id', 'swaps_hash', 'swaps_nonce', 'swaps_logIndex',\n", | |
" 'swaps_gasLimit', 'swaps_gasUsed', 'swaps_gasPrice',\n", | |
" 'swaps_protocol_id', 'swaps_account_id', 'swaps_pool_id',\n", | |
" 'swaps_blockNumber', 'swaps_timestamp', 'swaps_tick',\n", | |
" 'swaps_tokenIn_id', 'swaps_amountIn', 'swaps_amountInUSD',\n", | |
" 'swaps_tokenOut_id', 'swaps_amountOut', 'swaps_amountOutUSD',\n", | |
" 'swaps_tokenIn_symbol'],\n", | |
" dtype='object')" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"swaps_df.columns" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# convert swaps_df into a polars dataframe\n", | |
"swaps_pl = pl.DataFrame(swaps_df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div><style>\n", | |
".dataframe > thead > tr > th,\n", | |
".dataframe > tbody > tr > td {\n", | |
" text-align: right;\n", | |
"}\n", | |
"</style>\n", | |
"<small>shape: (125, 20)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>swaps_id</th><th>swaps_hash</th><th>swaps_nonce</th><th>swaps_logIndex</th><th>swaps_gasLimit</th><th>swaps_gasUsed</th><th>swaps_gasPrice</th><th>swaps_protocol_id</th><th>swaps_account_id</th><th>swaps_pool_id</th><th>swaps_blockNumber</th><th>swaps_timestamp</th><th>swaps_tick</th><th>swaps_tokenIn_id</th><th>swaps_amountIn</th><th>swaps_amountInUSD</th><th>swaps_tokenOut_id</th><th>swaps_amountOut</th><th>swaps_amountOutUSD</th><th>swaps_tokenIn_symbol</th></tr><tr><td>str</td><td>str</td><td>f64</td><td>i64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>i64</td><td>i64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>str</td></tr></thead><tbody><tr><td>"0x792f89e92672...</td><td>"0x792f89e92672...</td><td>489214.0</td><td>9</td><td>8e6</td><td>null</td><td>1.2e8</td><td>"0x1f98431c8ad9...</td><td>"0x879c2a2f7e40...</td><td>"0x52f9d14bed8c...</td><td>75646048</td><td>1680278883</td><td>-66239.0</td><td>"0x13ad51ed4f1b...</td><td>2.7356e19</td><td>0.0</td><td>"0x82af49447d8a...</td><td>3.6247e16</td><td>66.360736</td><td>"LDO"</td></tr><tr><td>"0x6bedebcf8993...</td><td>"0x6bedebcf8993...</td><td>207.0</td><td>5</td><td>3.167689e6</td><td>null</td><td>1.25e8</td><td>"0x1f98431c8ad9...</td><td>"0x4c1318568dd2...</td><td>"0xc31e54c7a869...</td><td>75646036</td><td>1680278880</td><td>-201196.0</td><td>"0x82af49447d8a...</td><td>3.5667e17</td><td>652.972154</td><td>"0xff970a61a04b...</td><td>6.52665678e8</td><td>652.665678</td><td>"WETH"</td></tr><tr><td>"0x6bedebcf8993...</td><td>"0x6bedebcf8993...</td><td>207.0</td><td>2</td><td>3.167689e6</td><td>null</td><td>1.25e8</td><td>"0x1f98431c8ad9...</td><td>"0x4c1318568dd2...</td><td>"0x536a4a24bf31...</td><td>75646036</td><td>1680278880</td><td>-74748.0</td><td>"0x6048df2d0db4...</td><td>6.3150e20</td><td>0.0</td><td>"0x82af49447d8a...</td><td>3.5667e17</td><td>652.972154</td><td>"BV3A"</td></tr><tr><td>"0xfb3289a1d01c...</td><td>"0xfb3289a1d01c...</td><td>48.0</td><td>3</td><td>7.710371e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xb55d5418031e...</td><td>"0xc6f780497a95...</td><td>75646034</td><td>1680278879</td><td>71992.0</td><td>"0x912ce5914419...</td><td>2.1500e21</td><td>2945.000046</td><td>"0x82af49447d8a...</td><td>1.6061e18</td><td>2940.415822</td><td>"ARB"</td></tr><tr><td>"0xc89a796216db...</td><td>"0xc89a796216db...</td><td>1.0</td><td>7</td><td>3.452581e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0x196248e5a9d9...</td><td>"0xc31e54c7a869...</td><td>75646032</td><td>1680278879</td><td>-201196.0</td><td>"0xff970a61a04b...</td><td>9.9125e8</td><td>991.25</td><td>"0x82af49447d8a...</td><td>5.4118e17</td><td>990.752157</td><td>"USDC"</td></tr><tr><td>"0x0706fc4af2cd...</td><td>"0x0706fc4af2cd...</td><td>214.0</td><td>14</td><td>2.857687e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xcd435c1b112a...</td><td>"0xc31e54c7a869...</td><td>75646034</td><td>1680278879</td><td>-201196.0</td><td>"0xff970a61a04b...</td><td>6.1388e9</td><td>6138.805364</td><td>"0x82af49447d8a...</td><td>3.3514e18</td><td>6135.623667</td><td>"USDC"</td></tr><tr><td>"0x428078c190d2...</td><td>"0x428078c190d2...</td><td>10.0</td><td>8</td><td>2.306683e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xb2f56bb14714...</td><td>"0xc6f780497a95...</td><td>75646027</td><td>1680278878</td><td>71992.0</td><td>"0x82af49447d8a...</td><td>3.8886e15</td><td>7.118975</td><td>"0x912ce5914419...</td><td>5.2000e18</td><td>7.122791</td><td>"WETH"</td></tr><tr><td>"0xfcbaeea128af...</td><td>"0xfcbaeea128af...</td><td>46795.0</td><td>41</td><td>3.606325e6</td><td>null</td><td>5e8</td><td>"0x1f98431c8ad9...</td><td>"0x2345678b940e...</td><td>"0x52f9d14bed8c...</td><td>75646026</td><td>1680278877</td><td>-66235.0</td><td>"0x82af49447d8a...</td><td>1.5524e17</td><td>284.197</td><td>"0x13ad51ed4f1b...</td><td>1.1653e20</td><td>0.0</td><td>"WETH"</td></tr><tr><td>"0x9161b775b48f...</td><td>"0x9161b775b48f...</td><td>574.0</td><td>2</td><td>6.612308e6</td><td>null</td><td>3e8</td><td>"0x1f98431c8ad9...</td><td>"0x7b157008d469...</td><td>"0xc6f780497a95...</td><td>75646019</td><td>1680278876</td><td>71992.0</td><td>"0x912ce5914419...</td><td>4.2000e21</td><td>5753.594583</td><td>"0x82af49447d8a...</td><td>3.1378e18</td><td>5744.770581</td><td>"ARB"</td></tr><tr><td>"0x0e23391f2900...</td><td>"0x0e23391f2900...</td><td>84.0</td><td>4</td><td>2.150625e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xcdb545a4d5d3...</td><td>"0xc31e54c7a869...</td><td>75646021</td><td>1680278876</td><td>-201196.0</td><td>"0x82af49447d8a...</td><td>3.6000e16</td><td>65.910395</td><td>"0xff970a61a04b...</td><td>6.5873626e7</td><td>65.873626</td><td>"WETH"</td></tr><tr><td>"0x7227338b043a...</td><td>"0x7227338b043a...</td><td>152.0</td><td>6</td><td>3.12238e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0x2d86222e3397...</td><td>"0xa8bd646f72ea...</td><td>75646018</td><td>1680278875</td><td>-78537.0</td><td>"0x6694340fc020...</td><td>1.0000e20</td><td>0.0</td><td>"0x82af49447d8a...</td><td>3.8743e16</td><td>70.93169</td><td>"STG"</td></tr><tr><td>"0x5e417ba3ece9...</td><td>"0x5e417ba3ece9...</td><td>5530.0</td><td>12</td><td>1e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0x6a1edfcb8636...</td><td>"0x641c00a822e8...</td><td>75646015</td><td>1680278875</td><td>-201197.0</td><td>"0x82af49447d8a...</td><td>1.5000e18</td><td>2746.266465</td><td>"0xfd086bc7cd5c...</td><td>2.7447e9</td><td>2744.654586</td><td>"WETH"</td></tr><tr><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td></tr><tr><td>"0x8b3a695d9bbc...</td><td>"0x8b3a695d9bbc...</td><td>2651.0</td><td>41</td><td>6.607412e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0x4e29fa717fb6...</td><td>"0x641c00a822e8...</td><td>75645677</td><td>1680278790</td><td>-201193.0</td><td>"0xfd086bc7cd5c...</td><td>1.956206e7</td><td>19.56206</td><td>"0x82af49447d8a...</td><td>1.0677e16</td><td>19.557803</td><td>"USDT"</td></tr><tr><td>"0x4e54689c63c1...</td><td>"0x4e54689c63c1...</td><td>217.0</td><td>4</td><td>3.207533e6</td><td>null</td><td>2.2e8</td><td>"0x1f98431c8ad9...</td><td>"0xaca5d6261ad6...</td><td>"0xc6f780497a95...</td><td>75645679</td><td>1680278790</td><td>71997.0</td><td>"0x82af49447d8a...</td><td>1.3579e18</td><td>2487.383078</td><td>"0x912ce5914419...</td><td>1.8168e21</td><td>2489.953038</td><td>"WETH"</td></tr><tr><td>"0x4dbc638b6b58...</td><td>"0x4dbc638b6b58...</td><td>322.0</td><td>15</td><td>2.967853e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xe11a980ae04f...</td><td>"0xb93f8a075509...</td><td>75645663</td><td>1680278786</td><td>1099.0</td><td>"0x5979d7b546e3...</td><td>2.7435e16</td><td>0.0</td><td>"0x82af49447d8a...</td><td>3.0609e16</td><td>56.069535</td><td>"wstETH"</td></tr><tr><td>"0x4dbc638b6b58...</td><td>"0x4dbc638b6b58...</td><td>322.0</td><td>8</td><td>2.967853e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xe11a980ae04f...</td><td>"0xf04286174336...</td><td>75645663</td><td>1680278786</td><td>-276328.0</td><td>"0xda10009cbd5d...</td><td>5.6125e19</td><td>56.227299</td><td>"0xff970a61a04b...</td><td>5.6100009e7</td><td>56.100009</td><td>"DAI"</td></tr><tr><td>"0x97ab3c49708e...</td><td>"0x97ab3c49708e...</td><td>0.0</td><td>4</td><td>2.334258e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0x0ed5f5acb6ad...</td><td>"0xc6f780497a95...</td><td>75645659</td><td>1680278785</td><td>71997.0</td><td>"0x82af49447d8a...</td><td>1.4948e15</td><td>2.738224</td><td>"0x912ce5914419...</td><td>2.0000e18</td><td>2.741104</td><td>"WETH"</td></tr><tr><td>"0x80e58085f9c0...</td><td>"0x80e58085f9c0...</td><td>20526.0</td><td>3</td><td>1.988068e6</td><td>null</td><td>2e8</td><td>"0x1f98431c8ad9...</td><td>"0xb5c0acd627a8...</td><td>"0xcda53b1f6661...</td><td>75645658</td><td>1680278785</td><td>-273188.0</td><td>"0x912ce5914419...</td><td>1.0472e21</td><td>1435.242087</td><td>"0xff970a61a04b...</td><td>1.4323e9</td><td>1432.336572</td><td>"ARB"</td></tr><tr><td>"0x94365dd28c23...</td><td>"0x94365dd28c23...</td><td>20541.0</td><td>11</td><td>1.970128e6</td><td>null</td><td>2e8</td><td>"0x1f98431c8ad9...</td><td>"0xe51647f55a72...</td><td>"0xcda53b1f6661...</td><td>75645645</td><td>1680278782</td><td>-273187.0</td><td>"0x912ce5914419...</td><td>8.8320e20</td><td>1210.575665</td><td>"0xff970a61a04b...</td><td>1.2081e9</td><td>1208.105662</td><td>"ARB"</td></tr><tr><td>"0xe41212e370de...</td><td>"0xe41212e370de...</td><td>123569.0</td><td>23</td><td>6e6</td><td>null</td><td>3.21e8</td><td>"0x1f98431c8ad9...</td><td>"0xc6d973b31bb1...</td><td>"0xc31e54c7a869...</td><td>75645642</td><td>1680278781</td><td>-201190.0</td><td>"0x82af49447d8a...</td><td>5.0000e18</td><td>9159.72095</td><td>"0xff970a61a04b...</td><td>9.1549e9</td><td>9154.909529</td><td>"WETH"</td></tr><tr><td>"0xba97edda47ae...</td><td>"0xba97edda47ae...</td><td>27.0</td><td>29</td><td>2e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0xf4553a7a9658...</td><td>"0x0dcf98667c54...</td><td>75645642</td><td>1680278781</td><td>92501.0</td><td>"0x82af49447d8a...</td><td>1.0000e15</td><td>1.831944</td><td>"0xdd69db25f6d6...</td><td>1.0371e19</td><td>0.0</td><td>"WETH"</td></tr><tr><td>"0x9d45b74325ff...</td><td>"0x9d45b74325ff...</td><td>12391.0</td><td>19</td><td>7.069276e6</td><td>null</td><td>2e8</td><td>"0x1f98431c8ad9...</td><td>"0x940a7ed683a6...</td><td>"0xc31e54c7a869...</td><td>75645643</td><td>1680278781</td><td>-201190.0</td><td>"0x82af49447d8a...</td><td>3.5000e18</td><td>6411.804665</td><td>"0xff970a61a04b...</td><td>6.4082e9</td><td>6408.161106</td><td>"WETH"</td></tr><tr><td>"0x273e2a0e0198...</td><td>"0x273e2a0e0198...</td><td>6.0</td><td>14</td><td>2.288252e6</td><td>null</td><td>1e8</td><td>"0x1f98431c8ad9...</td><td>"0x5ac75cf84d96...</td><td>"0xd7c05938c43b...</td><td>75645643</td><td>1680278781</td><td>142380.0</td><td>"0x82af49447d8a...</td><td>7.6986e16</td><td>141.033591</td><td>"0x602eb0d99a5e...</td><td>5.0000e10</td><td>0.0</td><td>"WETH"</td></tr><tr><td>"0x203d8b72e010...</td><td>"0x203d8b72e010...</td><td>123568.0</td><td>10</td><td>6e6</td><td>null</td><td>3.21e8</td><td>"0x1f98431c8ad9...</td><td>"0xc6d973b31bb1...</td><td>"0xc31e54c7a869...</td><td>75645640</td><td>1680278781</td><td>-201189.0</td><td>"0x82af49447d8a...</td><td>5.0000e18</td><td>9160.64875</td><td>"0xff970a61a04b...</td><td>9.1554e9</td><td>9155.372693</td><td>"WETH"</td></tr></tbody></table></div>" | |
], | |
"text/plain": [ | |
"shape: (125, 20)\n", | |
"┌──────┬──────────┬───────────┬────────────┬───┬────────────┬────────────┬────────────┬────────────┐\n", | |
"│ swap ┆ swaps_ha ┆ swaps_non ┆ swaps_logI ┆ … ┆ swaps_toke ┆ swaps_amou ┆ swaps_amou ┆ swaps_toke │\n", | |
"│ s_id ┆ sh ┆ ce ┆ ndex ┆ ┆ nOut_id ┆ ntOut ┆ ntOutUSD ┆ nIn_symbol │\n", | |
"│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n", | |
"│ str ┆ str ┆ f64 ┆ i64 ┆ ┆ str ┆ f64 ┆ f64 ┆ str │\n", | |
"╞══════╪══════════╪═══════════╪════════════╪═══╪════════════╪════════════╪════════════╪════════════╡\n", | |
"│ 0x79 ┆ 0x792f89 ┆ 489214.0 ┆ 9 ┆ … ┆ 0x82af4944 ┆ 3.6247e16 ┆ 66.360736 ┆ LDO │\n", | |
"│ 2f89 ┆ e9267220 ┆ ┆ ┆ ┆ 7d8a07e3bd ┆ ┆ ┆ │\n", | |
"│ e926 ┆ 6550375f ┆ ┆ ┆ ┆ 95bd0d56f3 ┆ ┆ ┆ │\n", | |
"│ 7220 ┆ 710e710f ┆ ┆ ┆ ┆ 52… ┆ ┆ ┆ │\n", | |
"│ 6550 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 375f ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 710e ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 710f ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 0x6b ┆ 0x6bedeb ┆ 207.0 ┆ 5 ┆ … ┆ 0xff970a61 ┆ 6.52665678 ┆ 652.665678 ┆ WETH │\n", | |
"│ edeb ┆ cf8993e5 ┆ ┆ ┆ ┆ a04b1ca148 ┆ e8 ┆ ┆ │\n", | |
"│ cf89 ┆ 91a86109 ┆ ┆ ┆ ┆ 34a43f5de4 ┆ ┆ ┆ │\n", | |
"│ 93e5 ┆ c0a03aaf ┆ ┆ ┆ ┆ 53… ┆ ┆ ┆ │\n", | |
"│ 91a8 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 6109 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ c0a0 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 3aaf ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 0x6b ┆ 0x6bedeb ┆ 207.0 ┆ 2 ┆ … ┆ 0x82af4944 ┆ 3.5667e17 ┆ 652.972154 ┆ BV3A │\n", | |
"│ edeb ┆ cf8993e5 ┆ ┆ ┆ ┆ 7d8a07e3bd ┆ ┆ ┆ │\n", | |
"│ cf89 ┆ 91a86109 ┆ ┆ ┆ ┆ 95bd0d56f3 ┆ ┆ ┆ │\n", | |
"│ 93e5 ┆ c0a03aaf ┆ ┆ ┆ ┆ 52… ┆ ┆ ┆ │\n", | |
"│ 91a8 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 6109 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ c0a0 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 3aaf ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 0xfb ┆ 0xfb3289 ┆ 48.0 ┆ 3 ┆ … ┆ 0x82af4944 ┆ 1.6061e18 ┆ 2940.41582 ┆ ARB │\n", | |
"│ 3289 ┆ a1d01c0c ┆ ┆ ┆ ┆ 7d8a07e3bd ┆ ┆ 2 ┆ │\n", | |
"│ a1d0 ┆ b8a4ddb0 ┆ ┆ ┆ ┆ 95bd0d56f3 ┆ ┆ ┆ │\n", | |
"│ 1c0c ┆ 1b094bed ┆ ┆ ┆ ┆ 52… ┆ ┆ ┆ │\n", | |
"│ b8a4 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ ddb0 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 1b09 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 4bed ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", | |
"│ 0xba ┆ 0xba97ed ┆ 27.0 ┆ 29 ┆ … ┆ 0xdd69db25 ┆ 1.0371e19 ┆ 0.0 ┆ WETH │\n", | |
"│ 97ed ┆ da47ae88 ┆ ┆ ┆ ┆ f6d620a7ba ┆ ┆ ┆ │\n", | |
"│ da47 ┆ 88c56fb9 ┆ ┆ ┆ ┆ d3023c5d32 ┆ ┆ ┆ │\n", | |
"│ ae88 ┆ 275ff462 ┆ ┆ ┆ ┆ 76… ┆ ┆ ┆ │\n", | |
"│ 88c5 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 6fb9 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 275f ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ f462 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 0x9d ┆ 0x9d45b7 ┆ 12391.0 ┆ 19 ┆ … ┆ 0xff970a61 ┆ 6.4082e9 ┆ 6408.16110 ┆ WETH │\n", | |
"│ 45b7 ┆ 4325ffcc ┆ ┆ ┆ ┆ a04b1ca148 ┆ ┆ 6 ┆ │\n", | |
"│ 4325 ┆ f6d29a52 ┆ ┆ ┆ ┆ 34a43f5de4 ┆ ┆ ┆ │\n", | |
"│ ffcc ┆ 012dd07c ┆ ┆ ┆ ┆ 53… ┆ ┆ ┆ │\n", | |
"│ f6d2 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 9a52 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 012d ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ d07c ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 0x27 ┆ 0x273e2a ┆ 6.0 ┆ 14 ┆ … ┆ 0x602eb0d9 ┆ 5.0000e10 ┆ 0.0 ┆ WETH │\n", | |
"│ 3e2a ┆ 0e019878 ┆ ┆ ┆ ┆ 9a5e3e76d1 ┆ ┆ ┆ │\n", | |
"│ 0e01 ┆ fea69869 ┆ ┆ ┆ ┆ 510372c4d2 ┆ ┆ ┆ │\n", | |
"│ 9878 ┆ 3df519e4 ┆ ┆ ┆ ┆ 02… ┆ ┆ ┆ │\n", | |
"│ fea6 ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 9869 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 3df5 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 19e4 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 0x20 ┆ 0x203d8b ┆ 123568.0 ┆ 10 ┆ … ┆ 0xff970a61 ┆ 9.1554e9 ┆ 9155.37269 ┆ WETH │\n", | |
"│ 3d8b ┆ 72e0103e ┆ ┆ ┆ ┆ a04b1ca148 ┆ ┆ 3 ┆ │\n", | |
"│ 72e0 ┆ 6aba483b ┆ ┆ ┆ ┆ 34a43f5de4 ┆ ┆ ┆ │\n", | |
"│ 103e ┆ bffda60e ┆ ┆ ┆ ┆ 53… ┆ ┆ ┆ │\n", | |
"│ 6aba ┆ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ 483b ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ bffd ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ a60e ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"│ … ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", | |
"└──────┴──────────┴───────────┴────────────┴───┴────────────┴────────────┴────────────┴────────────┘" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"swaps_pl" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"swaps_id\n", | |
"swaps_hash\n", | |
"swaps_nonce\n", | |
"swaps_logIndex\n", | |
"swaps_gasLimit\n", | |
"swaps_gasUsed\n", | |
"swaps_gasPrice\n", | |
"swaps_protocol_id\n", | |
"swaps_account_id\n", | |
"swaps_pool_id\n", | |
"swaps_blockNumber\n", | |
"swaps_timestamp\n", | |
"swaps_tick\n", | |
"swaps_tokenIn_id\n", | |
"swaps_amountIn\n", | |
"swaps_amountInUSD\n", | |
"swaps_tokenOut_id\n", | |
"swaps_amountOut\n", | |
"swaps_amountOutUSD\n", | |
"swaps_tokenIn_symbol\n" | |
] | |
} | |
], | |
"source": [ | |
"# for every column in swaps_df, convert to polars\n", | |
"for col in swaps_df.columns:\n", | |
" print(col)\n", | |
" swaps_df[col] = pl.Series(swaps_df[col])\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": ".venv", | |
"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.10.6" | |
}, | |
"orig_nbformat": 4 | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment