Last active
September 29, 2021 04:34
-
-
Save mariorz/bf005b6ec8c9838b805e1dba60a593aa 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
import requests | |
from brownie import * | |
## set vars | |
pool_address = "0x4e68ccd3e89f51c3074ca5072bbac773960dfa36" | |
tick = "-195660" | |
block_number = 13010089 | |
query = """ | |
query { | |
ticks(where:{pool_contains:"%s",tickIdx:%s} | |
block:{number:%s}) | |
{ | |
tickIdx | |
feeGrowthOutside0X128 | |
feeGrowthOutside1X128 | |
} | |
} | |
""" % (pool_address, tick, block_number) | |
def run_query(q): | |
request = requests.post('https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3', | |
'', | |
json={'query': query}) | |
return request.json() | |
web3.eth.defaultBlock = block_number | |
pool = Contract.from_explorer(pool_address) | |
tick_values = pool.ticks(tick) | |
graph_resp = run_query(query) | |
print("-----------------------------") | |
print(f"Testing contract calls vs the graph values for\npool:%s\ntick:%s\nblock:%s" % | |
(pool_address, tick, block_number)) | |
print(f"feeGrowthOutside0X128 from the blockchain: %s" % | |
tick_values['feeGrowthOutside0X128']) | |
print(f"feeGrowthOutside0X128 from the graph : %s" % | |
graph_resp['data']['ticks'][0]['feeGrowthOutside0X128']) | |
if graph_resp['data']['ticks'][0]['feeGrowthOutside0X128'] == tick_values['feeGrowthOutside0X128']: | |
print("Match ✓") | |
else: | |
print("Mismatch ✘") | |
def main(): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment