So, it rather depends on your "benefits" and how you give them out. There should be a strict plan to see what needs to be done and how.
I think whatever you would need, is kind of link to registration process, which then will save a "referral" cookie with the inviter's ID and that way it will be stored in database. But then, you will need a special statistics script, which would show, who was inviting whom, possibly other analyzing script.
All in all, it's a thing requiring lots of time to implement, discuss and test, and we have no such add-on by now.
It could programmed only on the
premium support basis, as it appears very customized and specific to your ideas only (as any referral program should be kind of specific - else what kind of sense would it make..).