Skip to content

Lowered approval check - #305

Closed
alb2001 wants to merge 6 commits into
uniswap-python:masterfrom
alb2001:master
Closed

alb2001 wants to merge 6 commits into
uniswap-python:masterfrom
alb2001:master

Conversation

@alb2001

@alb2001 alb2001 commented Dec 15, 2022

Copy link
Copy Markdown

More of a workaround than a solution

Some tokens store the allowance as uint96, instead of uint256. So even if you approve the max, the allowance will return 79228162514264337593543950335 (the highest value for uint96) instead of 115792089237316195423570985008687907853269984665640564039457584007913129639935 (highest value for uint256)

The new max approval check would be 1208925819614629174706175

This can be seen on some tokens, such as UNI on Goerli
https://goerli.etherscan.io/address/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984#readContract

CVP on mainnet:
https://etherscan.io/address/0x38e4adb44ef08f22f5b5b76a8f0c2d0dcbe7dca1#readContract

INST on mainnet:
https://etherscan.io/token/0x6f40d4a6237c257fff2db00fa0510deeecd303eb#readProxyContract

Here's a table with the max value for each type
https://velvetshark.com/articles/max-int-values-in-solidity

Some tokens store the allowance as uint96, instead of uint256. So even if you approve the max, the allowance will return 79228162514264337593543950335 (the highest value for uint96) instead of 115792089237316195423570985008687907853269984665640564039457584007913129639935 (highest value for uint256)
Some tokens store the allowance as uint96, instead of uint256. So even if you approve the max, the allowance will return 79228162514264337593543950335 (the highest value for uint96) instead of 115792089237316195423570985008687907853269984665640564039457584007913129639935 (highest value for uint256)
@alb2001 alb2001 mentioned this pull request Dec 16, 2022
@codecov

codecov Bot commented Dec 16, 2022 •

Copy link
Copy Markdown

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.29 ⚠️

Comparison is base (47ae05d) 84.35% compared to head (677fffa) 84.06%.

❗ Current head 677fffa differs from pull request most recent head c51ccf1. Consider uploading reports for the commit c51ccf1 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #305      +/-   ##
==========================================
- Coverage   84.35%   84.06%   -0.29%     
==========================================
  Files          10       10              
  Lines        1042     1042              
==========================================
- Hits          879      876       -3     
- Misses        163      166       +3     
Impacted Files Coverage Δ
uniswap/uniswap.py 82.30% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alb2001 alb2001 closed this Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant