Closed vladikopl01 closed 1 year ago
Hi @vladikopl01
The SDK does not allow passing in a custom FACTORY_ADDRESS
or INIT_CODE_HASH
. Looking at the code, it seems that both are only used to compute the address of pairs:
https://github.com/Uniswap/v2-sdk/blob/main/src/entities/pair.ts#L10
I have seen a couple of Uniswap forks that just forked the SDK and replaced the hard-coded values in constants. If you don't want to have duplicate code in your project you could fork this repository and amend the getAddress function in the Pair class. Passing the factory address and init code hash there: https://github.com/Uniswap/v2-sdk/blob/main/src/entities/pair.ts#L30 and in the compute function: https://github.com/Uniswap/v2-sdk/blob/main/src/entities/pair.ts#L10 should do the trick.
I guess the values are hard coded to make the sdk easier to use. After all it's primarily meant to be used for Uniswap and not forks.
Is there any way to pass custom
FACTORY_ADDRESS
andINIT_CODE_HASH
to SDK to work with different forks of UniswapV2 dexes? Or the way how to overwrite them for each dex?