I have a program that listens for new events coming from the uniswap factory contracts to detect when a new factory is created. It seems about 50% of the time it misses actual events and does not receive an event when a factory is created. As mentioned this only happens roughly 50% of the time.
To compare the results of my program I’m using this twitter account which tweets out when new pairs are created as a baseline. The last pair created that was detected by my bot is this one however all pairs created since then have been missed by my bot.
Here is a snippet of my code that I’m using
// this uses contract bindings generated by abigen to create a factory contract
factory, err := c.uc.Factory()
if err != nil {
return err
}
ch := make(chan *uniswapv2factory.Uniswapv2factoryPairCreated, 100)
sub, err := factory.WatchPairCreated(nil, ch, nil, nil)
if err != nil {
return err
}
defer func() {
sub.Unsubscribe()
close(ch)
}()
logger := c.l.Named("uniswap.factory")
logger.Info("starting uniswap factory pair creation monitor")
for {
select {
case <-c.ctx.Done():
return nil
case err := <-sub.Err():
logger.Error("encountered error watching uniswap factory", zap.Error(err))
return err
case evLog := <-ch:
// do stuff
}
}
I’m running this bot from a digital ocean droplet in the cloud