[BUG] Uniswap can not work with 256bit unsigned int tokens
Ive been playing around with some tokens and tried making a token where the total supply is 1 with 76 decimal places. (The maxium amount that can be stored in a 256 uint)
10000000000000000000000000000000000000000000000000000000000000000000000000000
Upon attempting to create a pool on uniswap for this, it would not work, kept giving invalid price errors, price out of range or just unknown error.
I did some further investigating and found 38 decimal places worked find, this convineantly is the maximum amount in a 128 bit uint.
100000000000000000000000000000000000000
As smart contracts and the ERC20 token standard uses the 256uint, uniswap should fully support 256bit uints. But it looks like you guys decided to only support 128bit uints.
I checked V2 and V3 both cant handle a full 256bit uint token.
Update:
Manually creating the pool and depositing works however doing so completelty breaks the interface and renders uniswap unusable.

Error
s@https://app.uniswap.org/static/js/8211.d609fc21.js:2:1137984 t@https://app.uniswap.org/static/js/8211.d609fc21.js:2:1158675 97404/t.fromFractionalAmount@https://app.uniswap.org/static/js/8211.d609fc21.js:2:1158869 97404/n.quote@https://app.uniswap.org/static/js/8211.d609fc21.js:2:1161842 _@https://app.uniswap.org/static/js/main.d3bf6694.js:4261:12334 16584/I/<@https://app.uniswap.org/static/js/main.d3bf6694.js:4261:5692 iu@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2051538 Ac@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2071662 6333/Ec/<@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2070402 Ec@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2070467 cc@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2064223 qi@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2004949 6333/ic/<@https://app.uniswap.org/static/js/8211.d609fc21.js:2:2061628
Closing the pools restores functionality.
@JABirchall thanks for the report, can you provide a contract for testing?
@JABirchall thanks for the report, can you provide a contract for testing?
Sure, here is a 77-digit pi ERC20 contract i was going to do which requires the full 265bit UINT space.
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.22;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
contract PI77Coin is ERC20, ERC20Permit, ERC20Burnable {
constructor()
ERC20("PI", "PI")
ERC20Permit("PI77DIGITS") {
_mint(msg.sender, 31415926535897932384626433832795028841971693993751058209749445923078164062862);
}
function decimals() public override virtual pure returns(uint8) {
return 76;
}
}
Do you have one already deployed?