Closed JanOwiesniak closed 2 years ago
Could this be related to your RPC provider value in the config? Which one did you put in the env file?
using this provider
RPC_ENDPOINT="https://rpc-mainnet.matic.network"
tested those RPC endpoints as well and ran into the same issue:
Maybe related to the patch?
IDE tells me that property POLYGON
is missing:
Which is not the case. I ran postinstall
manually after npm install
and patch seems to be applied:
Very weird—I'll add an extra step to manually run postinstall
anyways. Thank you for flagging!
@Anish-Agnihotri please reopen. This did not fixed my initial issue :)
UniswapError: chainId can not be found on the provider
Ah, damn sorry. Thought that had resolved the issue. Reopening, will diagnose shortly.
@Anish-Agnihotri i added a purchase
function to test submitPurchaseTx
in isolation from PairCreated
and purchase DAI with USDC. Maybe something is just wrong with my test setup?
.env
TOKEN_ADDRESS=0x8f3cf7ad23cd3cadbd9735aff958023239c6a063
FACTORY_ADDRESS=0xc35dadb65012ec5796536bd9864ed8773abc74c4
RPC_ENDPOINT="https://rpc-mainnet.matic.network"
sniper.ts
async purchase(): Promise<void> {
const USDC_TOKEN_ADDRESS: string="0x2791bca1f2de4661ed88a30c99a7a9449aa84174";
const DAI_TOKEN_ADDRESS: string="0x8f3cf7ad23cd3cadbd9735aff958023239c6a063";
const token0 = DAI_TOKEN_ADDRESS;
const token1 = USDC_TOKEN_ADDRESS;
logger.info(`Purchase token: ${token0} with ${token1}`);
await this.submitPurchaseTx(token0, token1);
process.exit(0);
}
app.ts
await sniper.purchase();
Tried testing a few more times today and I can't seem to duplicate across either Node 14 or 16. Very weird.
Hey I’m the author of simple-uniswap-sdk I’m happy to support polygon natively so you don’t need this patch. Will take a look this week (tomorrow probably) for you guys, this could remove any need to do the patch script!
Also the sdk is about to support any custom network with config so that can cover any other custom networks in future.
Super open to support any networks in the sdk so please raise any issues if you want any others supported!
ahh i see your using SushiSwap contracts on here ok this will be one for the custom network logic which will be in this lib very soon! will post a guide on here when it's done 👍
PR for pool sniper with the new sdk > https://github.com/Anish-Agnihotri/pool-sniper/pull/4
@Anish-Agnihotri Did this approach work for Klima ? We could build a simple webapp that uses a DAO model to allow everybody to do this.
Closing kudos to @joshstevens19's help on native support for Polygon!
@MohitKumar1991 the approach did work—please feel free to use the code in any way.
node version v14.18.0
npm version v6.14.15
issue running
npm run-script dev
results in