You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have just encountered some very strange bug/issue? While playing with NonfungiblePositionManager contract. I have wrote solidity code that creates new ERC20 contract and then calling function dexCoin() from another my contract that takes this newly created ERC20 contract address and calls below:
I have then wrote some simple test using foundry to check if everything works and indeed it was until I ran same code on forked Ethereum Mainnet. So the problem occurs on every single forked mainnet I tested (Ethereum Mainnet, Polygon, Avalanche), there is no issue on testnets like Sepolia.
This is contract code I'm using to start calls chain:
So to sum up the only thing that changed is that ERC20 contract address. I have noticed that createAndInitializePoolIfNecessary has problem with some certain addresses and only while testing on mainnets. I have even reproduced this error using different private key and creating additional unnecessary coin as above but it didnt solve issue, so i guess address generated was incorrect for some reason. Solution I showed works only for some private keys and if it pass on ethereum mainnet it will also pass on any other mainnet and testnet. Am I missing some additional requirements to create and initialize pool? Maybe it is just foundry bug and it is creating some corrupted addresses (I highly doubt)? Or it just needs some specific ERC20 address format.
If anyone has any idea how this can be fixed or can explain to me where is the problem I will be very grateful!
The text was updated successfully, but these errors were encountered:
Hello,
I have just encountered some very strange bug/issue? While playing with NonfungiblePositionManager contract. I have wrote solidity code that creates new ERC20 contract and then calling function
dexCoin()
from another my contract that takes this newly created ERC20 contract address and calls below:I have then wrote some simple test using
foundry
to check if everything works and indeed it was until I ran same code on forked Ethereum Mainnet. So the problem occurs on every single forked mainnet I tested (Ethereum Mainnet, Polygon, Avalanche), there is no issue on testnets like Sepolia.This is contract code I'm using to start calls chain:
If i run my test on forked mainnet I'm getting those logs:
emit DexRequestReceived(token: Coin: [0xc3B785939FE923f3EA338Ae6793C99de2671b2cB]) │ │ │ ├─ [23974] WETH9::deposit{value: 11000000000000000000}() │ │ │ │ ├─ emit Deposit(dst: CoinDexer: [0xaBC27F4fa9dae4829575A3DF7958b9d80872c8a8], wad: 11000000000000000000 [1.1e19]) │ │ │ │ └─ ← [Stop] │ │ │ ├─ [534] WETH9::balanceOf(CoinDexer: [0xaBC27F4fa9dae4829575A3DF7958b9d80872c8a8]) [staticcall] │ │ │ │ └─ ← [Return] 11000000000000000000 [1.1e19] │ │ │ ├─ emit Swapped_ETH_For_WETH(amount: 11000000000000000000 [1.1e19]) │ │ │ ├─ [674] NonfungiblePositionManager::createAndInitializePoolIfNecessary(Coin: [0xc3B785939FE923f3EA338Ae6793C99de2671b2cB], WETH9: [0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2], 3000, 7922816251426433759354395 [7.922e24]) │ │ │ │ └─ ← [Revert] EvmError: Revert
But if i do this in contract above:
so i just added this line
new Coin(params);
and i run same test without changing anything else in code it works perfectly fine:So to sum up the only thing that changed is that ERC20 contract address. I have noticed that
createAndInitializePoolIfNecessary
has problem with some certain addresses and only while testing on mainnets. I have even reproduced this error using different private key and creating additional unnecessary coin as above but it didnt solve issue, so i guess address generated was incorrect for some reason. Solution I showed works only for some private keys and if it pass on ethereum mainnet it will also pass on any other mainnet and testnet. Am I missing some additional requirements to create and initialize pool? Maybe it is justfoundry
bug and it is creating some corrupted addresses (I highly doubt)? Or it just needs some specific ERC20 address format.If anyone has any idea how this can be fixed or can explain to me where is the problem I will be very grateful!
The text was updated successfully, but these errors were encountered: