Perpetual-spot arbitrage, funding rate

I am trying to understand how the perpetual/spot + funding rate arbitrage works, and set up a bot, if possible. I could not find any reliable information about that, like a serious paper or even any report on that. I really will appreciate if anybody could help me with that, with any paper, or link. I am also open to share any finding that I could do if anybody is interested in this trade.
Many thanks.