Created
May 11, 2023 10:55
-
-
Save diewland/fead3d3a024abee71ec610e6df8f303e to your computer and use it in GitHub Desktop.
Query unclaim fee from UniswapV3 pool
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
aiohttp==3.8.3 | |
aiosignal==1.3.1 | |
async-timeout==4.0.2 | |
attrs==22.2.0 | |
base58==2.1.1 | |
bitarray==2.6.2 | |
certifi==2022.12.7 | |
charset-normalizer==2.1.1 | |
cytoolz==0.12.1 | |
eth-abi==2.2.0 | |
eth-account==0.5.9 | |
eth-hash==0.5.1 | |
eth-keyfile==0.5.1 | |
eth-keys==0.3.4 | |
eth-rlp==0.2.1 | |
eth-typing==2.3.0 | |
eth-utils==1.9.5 | |
frozenlist==1.3.3 | |
hexbytes==0.3.0 | |
idna==3.4 | |
ipfshttpclient==0.8.0a2 | |
jsonschema==4.17.3 | |
lru-dict==1.1.8 | |
multiaddr==0.0.9 | |
multidict==6.0.4 | |
netaddr==0.8.0 | |
parsimonious==0.8.1 | |
protobuf==3.19.5 | |
pycryptodome==3.16.0 | |
pyrsistent==0.19.3 | |
requests==2.28.1 | |
rlp==2.0.1 | |
six==1.16.0 | |
toolz==0.12.0 | |
urllib3==1.26.13 | |
varint==1.0.2 | |
web3==5.31.3 | |
websockets==9.1 | |
yarl==1.8.2 |
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
from web3 import Web3 | |
from web3.middleware import geth_poa_middleware | |
from pprint import pprint as pp | |
# update: your pool | |
rpc_url = "https://endpoints.omniatech.io/v1/bsc/mainnet/public" # BSC | |
from_addr = "0xb6621cbF70E95d6C90BE651C719534d08e7E42ca" | |
pool_addr = "0x7b8A01B39D58278b5DE7e48c8449c9f4F5170613" | |
pool_id = 10000 | |
# init w3 | |
w3 = Web3(Web3.HTTPProvider(rpc_url)) | |
w3.middleware_onion.inject(geth_poa_middleware, layer=0) | |
# init pool contract | |
c = w3.eth.contract( | |
abi=[{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"}],"internalType":"struct INonfungiblePositionManager.CollectParams","name":"params","type":"tuple"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"}], | |
address=pool_addr | |
) | |
amt_max = 340282366920938463463374607431768211455 # (2^128)-1 | |
payload = ( | |
pool_id, # tokenId | |
from_addr, # recipient | |
amt_max, # amount0Max | |
amt_max, # amount1Max | |
) | |
[fee0, fee1] = c.functions.collect(payload).call() | |
pp(fee0/1_000_000_000_000_000_000) #18 | |
pp(fee1/1_000_000_000_000_000_000) #18 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment