Funding is collected hourly based on the ratio between longs and shorts, with a daily funding period. It is calculated using a difference between an hourly TWAP of mark price divided by a normalization factor n and an hourly TWAP of the index price divided by n raised to the power P of the market, over 24 hours.