An affiliate code system allows people who refer buyers to receive a portion of the coins sold.
They will not receive a portion of the coins taken in (BTC, ETH etc) because this makes the system much more complex (will need user accounts, a hot wallet or manual processing of withdrawals, etc).
Requirements:
Affiliate Portal
A webpage "Affiliate Portal" allows a user to do the following:
Provide a skycoin address and receive a URL to the "buy skycoin" page with an affiliate tracking code and a URL to the "join affiliate program" page with an affiliate tracking code
If there is an affiliate code in the url of the portal page, save this affiliate code too. This is the original referrer.
On the affiliate portal backend,
Payouts will be to the skycoin address received when generating the code. Save the skycoin address with the tracking code in the database.
The tracking code format should be defined, possibly derived from the skycoin address irreversibly, such as a hash
Using only the skycoin address for this is simpler, but has other limitations. It does not work as a username or password, since addresses become public on the blockchain. Therefore the user can't do things such as check their pending rewards (if we send rewards on a time interval). Instead we will try to send their rewards immediately. Sending immediately has problems too, because some rewards may be too small to send. So, a compromise will need to be found, unless we want to implement a full user system.
In the teller service, add a new component for sending affiliate payouts:
Reads from an channel exposed by Exchanger
Exchanger writes to this channel when it sends coins
This component saves a record of the coins sent, and determines the affiliate rewards
This component has a processing loop that sends the affiliate rewards
Use a separate wallet for the affiliate rewards
Use a separate database for affiliate rewards
Affiliate reward calculation:
When the affiliate signed up, they may have been referred by another. We kept track of this in the affiliate portal, to calculate tiered referral rewards.
Add a configuration for how many referral layers to give rewards to, and the percent at each layer
If the layer is 1, this is a simple, typical referral system.
When processing the deposit, look up the original referring affiliate for this deposit
Then, following each affiliate, find who referred who, up to N layers deep
Calculate rewards per affiliate level, based on configuration
Create a "send" event for each affiliate and write it to a channel
In another goroutine, process the send events
There is a problem with this; if the affiliate reward is too small it can't be sent. Instead, this might be changed to calculate cumulative affiliate rewards on a fixed time interval, and if the cumulative reward is above a threshold, then send it.
An affiliate code system allows people who refer buyers to receive a portion of the coins sold.
They will not receive a portion of the coins taken in (BTC, ETH etc) because this makes the system much more complex (will need user accounts, a hot wallet or manual processing of withdrawals, etc).
Requirements:
A webpage "Affiliate Portal" allows a user to do the following:
On the affiliate portal backend,
Using only the skycoin address for this is simpler, but has other limitations. It does not work as a username or password, since addresses become public on the blockchain. Therefore the user can't do things such as check their pending rewards (if we send rewards on a time interval). Instead we will try to send their rewards immediately. Sending immediately has problems too, because some rewards may be too small to send. So, a compromise will need to be found, unless we want to implement a full user system.
In the teller service, add a new component for sending affiliate payouts:
Exchanger
Exchanger
writes to this channel when it sends coinsAffiliate reward calculation:
There is a problem with this; if the affiliate reward is too small it can't be sent. Instead, this might be changed to calculate cumulative affiliate rewards on a fixed time interval, and if the cumulative reward is above a threshold, then send it.