Hi,
I have read you asked about a library that reads rotary encoders with MCP23017 ic.
I have been working on the same type of project, and had the same problem, and took a lot of time to solve that problem. I made a topic for that which you can find here.
https://forum.arduino.cc/index.php?topic=465225.msg3232864#msg3232864
I am using MCP23S17 in my project which is almost the same, but uses SPI instead of I2C which is a quicker interface.
Sorry, at the moment i don't have time to read the whole topic, so this problem for you might have already been solved, but if not, i hope my post will help you a little bit.
Best wishes,
Agoston