Created
April 9, 2023 14:42
-
-
Save Evan-Kim2028/d09ec698d896f4b400ada89be57a4661 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\n", | |
"\n", | |
"sg = Subgrounds()\n", | |
"\n", | |
"# Load\n", | |
"univ3_sg = sg.load_subgraph('https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum')\n", | |
"\n", | |
"swaps_entity = univ3_sg.Swap\n", | |
"swaps_fp = univ3_sg.Query.swaps\n", | |
"\n", | |
"swaps_qp = univ3_sg.Query.swaps(\n", | |
" orderBy=univ3_sg.Query.swaps.timestamp,\n", | |
" orderDirection='desc'\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 60, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"<class 'subgrounds.subgraph.object.Object'>\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"(None, subgrounds.subgraph.fieldpath.FieldPath)" | |
] | |
}, | |
"execution_count": 60, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"print(type(swaps_entity)), type(swaps_fp)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"name='Swap' description=None kind='OBJECT' fields=[FieldMeta(name='id', description=' { Transaction hash }-{ Log index } ', arguments=[], type_=NonNull(inner=Named(name_='Bytes', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='hash', description=' Transaction hash of the transaction that emitted this event ', arguments=[], type_=NonNull(inner=Named(name_='Bytes', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='nonce', description=' Nonce of the transaction that emitted this event ', arguments=[], type_=NonNull(inner=Named(name_='BigInt', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='logIndex', description=\" Event log index. For transactions that don't emit event, create arbitrary index starting from 0 \", arguments=[], type_=NonNull(inner=Named(name_='Int', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='gasLimit', description=' Gas limit of the transaction that emitted this event ', arguments=[], type_=Named(name_='BigInt', kind='SCALAR')), FieldMeta(name='gasUsed', description=' Gas used in this transaction. (Optional because not every chain will support this) ', arguments=[], type_=Named(name_='BigInt', kind='SCALAR')), FieldMeta(name='gasPrice', description=' Gas price of the transaction that emitted this event ', arguments=[], type_=Named(name_='BigInt', kind='SCALAR')), FieldMeta(name='protocol', description=' The protocol this transaction belongs to ', arguments=[], type_=NonNull(inner=Named(name_='DexAmmProtocol', kind='OBJECT'), kind='NON_NULL')), FieldMeta(name='account', description=' Account that emitted this event ', arguments=[], type_=NonNull(inner=Named(name_='Account', kind='OBJECT'), kind='NON_NULL')), FieldMeta(name='pool', description=' The pool involving this event ', arguments=[], type_=NonNull(inner=Named(name_='LiquidityPool', kind='OBJECT'), kind='NON_NULL')), FieldMeta(name='blockNumber', description=' Block number of this event ', arguments=[], type_=NonNull(inner=Named(name_='BigInt', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='timestamp', description=' Timestamp of this event ', arguments=[], type_=NonNull(inner=Named(name_='BigInt', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='tick', description=' the tick after the swap ', arguments=[], type_=Named(name_='BigInt', kind='SCALAR')), FieldMeta(name='tokenIn', description=' Token deposited into pool ', arguments=[], type_=NonNull(inner=Named(name_='Token', kind='OBJECT'), kind='NON_NULL')), FieldMeta(name='amountIn', description=' Amount of token deposited into pool in native units ', arguments=[], type_=NonNull(inner=Named(name_='BigInt', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='amountInUSD', description=' Amount of token deposited into pool in USD ', arguments=[], type_=NonNull(inner=Named(name_='BigDecimal', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='tokenOut', description=' Token withdrawn from pool ', arguments=[], type_=NonNull(inner=Named(name_='Token', kind='OBJECT'), kind='NON_NULL')), FieldMeta(name='amountOut', description=' Amount of token withdrawn from pool in native units ', arguments=[], type_=NonNull(inner=Named(name_='BigInt', kind='SCALAR'), kind='NON_NULL')), FieldMeta(name='amountOutUSD', description=' Amount of token withdrawn from pool in USD ', arguments=[], type_=NonNull(inner=Named(name_='BigDecimal', kind='SCALAR'), kind='NON_NULL'))] interfaces_=[]\n" | |
] | |
} | |
], | |
"source": [ | |
"print(swaps_entity._object)\n", | |
"\n", | |
"# dependency paths\n", | |
"# object -> _object (TypeMeta.ObjectMeta | TypeMeta.InterfaceMeta) -> Fields (FieldPath Info)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[('id', 'Bytes!'),\n", | |
" ('hash', 'Bytes!'),\n", | |
" ('nonce', 'BigInt!'),\n", | |
" ('logIndex', 'Int!'),\n", | |
" ('gasLimit', 'BigInt'),\n", | |
" ('gasUsed', 'BigInt'),\n", | |
" ('gasPrice', 'BigInt'),\n", | |
" ('protocol', 'DexAmmProtocol!'),\n", | |
" ('account', 'Account!'),\n", | |
" ('pool', 'LiquidityPool!'),\n", | |
" ('blockNumber', 'BigInt!'),\n", | |
" ('timestamp', 'BigInt!'),\n", | |
" ('tick', 'BigInt'),\n", | |
" ('tokenIn', 'Token!'),\n", | |
" ('amountIn', 'BigInt!'),\n", | |
" ('amountInUSD', 'BigDecimal!'),\n", | |
" ('tokenOut', 'Token!'),\n", | |
" ('amountOut', 'BigInt!'),\n", | |
" ('amountOutUSD', 'BigDecimal!')]" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# retrieve the names and types for each field path \n", | |
"col_list = list((field.name, TypeRef.graphql(field.type_)) for field in swaps_entity._object.fields)\n", | |
"col_list" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 70, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"ename": "TypeError", | |
"evalue": "unhashable type: 'FieldPath'", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", | |
"Cell \u001b[0;32mIn[70], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m where_dict1 \u001b[39m=\u001b[39m {\n\u001b[1;32m 2\u001b[0m \u001b[39m# This doesn't work\u001b[39;00m\n\u001b[1;32m 3\u001b[0m univ3_sg\u001b[39m.\u001b[39mQuery\u001b[39m.\u001b[39mswaps\u001b[39m.\u001b[39mtokenIn\u001b[39m.\u001b[39mid: [\u001b[39m'\u001b[39m\u001b[39m0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\u001b[39m\u001b[39m'\u001b[39m] \n\u001b[1;32m 4\u001b[0m \u001b[39m# swaps_entity.tokenIn_in : ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'] \u001b[39;00m\n\u001b[1;32m 5\u001b[0m \u001b[39m# swaps_entity.tokenOut_in : ['0xdAC17F958D2ee523a2206206994597C13D831ec7']\u001b[39;00m\n\u001b[1;32m 6\u001b[0m \n\u001b[1;32m 7\u001b[0m \n\u001b[1;32m 8\u001b[0m \u001b[39m# This works\u001b[39;00m\n\u001b[1;32m 9\u001b[0m \u001b[39m# \"tokenIn_in\": ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'],\u001b[39;00m\n\u001b[1;32m 10\u001b[0m \u001b[39m# \"tokenOut_in\": ['0xdAC17F958D2ee523a2206206994597C13D831ec7']\u001b[39;00m\n\u001b[1;32m 11\u001b[0m }\n\u001b[1;32m 13\u001b[0m \u001b[39m# Note there is also a tokenIn_: Token_filter value...is there an equivalent to do `swap_filter_example._select('pool')._select('id')` but with filters?\u001b[39;00m\n", | |
"\u001b[0;31mTypeError\u001b[0m: unhashable type: 'FieldPath'" | |
] | |
} | |
], | |
"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": 67, | |
"metadata": {}, | |
"outputs": [], | |
"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": 68, | |
"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>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0x4e68ccd3e89f51c3074ca5072bbac773960dfa36</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</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>0x4e68ccd3e89f51c3074ca5072bbac773960dfa36</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>97</th>\n", | |
" <td>0x11b815efb8f581194ae79006d24e0d814b7697f6</td>\n", | |
" <td>WETH</td>\n", | |
" <td>USDT</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>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 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"1 0x4e68ccd3e89f51c3074ca5072bbac773960dfa36 WETH \n", | |
"2 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"3 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"4 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
".. ... ... \n", | |
"95 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"96 0x4e68ccd3e89f51c3074ca5072bbac773960dfa36 WETH \n", | |
"97 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"98 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"99 0x11b815efb8f581194ae79006d24e0d814b7697f6 WETH \n", | |
"\n", | |
" swaps_tokenOut_symbol \n", | |
"0 USDT \n", | |
"1 USDT \n", | |
"2 USDT \n", | |
"3 USDT \n", | |
"4 USDT \n", | |
".. ... \n", | |
"95 USDT \n", | |
"96 USDT \n", | |
"97 USDT \n", | |
"98 USDT \n", | |
"99 USDT \n", | |
"\n", | |
"[100 rows x 3 columns]" | |
] | |
}, | |
"execution_count": 68, | |
"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": 16, | |
"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": 19, | |
"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": 19, | |
"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": 4, | |
"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": 7, | |
"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": 24, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"swaps_df = sg.query_df(swaps_qp)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"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