Hello guys I need some help!
Could someone explain me how to set the token order (token0 / token1) of a liquidity pair?
I’m using UniswapsV2 - Factory contract.
Currently when i create a pool with tokenA & tokenB. I expect tokenA to become token0, and tokenB to become token1. But this is not the case..
The function I use to create pair:
function createPair(address tokenA, address tokenB) external returns (address pair);
I did some digging in the code of the contract, and the problem i see is: the contract sorts the token order by itself. Take a look at this code: https://github.com/Uniswap/v2-core/blob/4dd59067c76dea4a0e8e4bfdda41877a6b16dedc/contracts/UniswapV2Factory.sol#L25
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
So basically it sorts the token by a lower / higher value address ..
But what if tokenB has a higher value then tokenA but i still want tokenA to be token0 and tokenB to become token1.
How can i achieve this?
My liquidity pair should be:
But now it becomes:
I really hope someone could help me with this!
Thanks in advance