Badger DAO Referral Program (Gitcoin GR10 Bounty)
Demo deployment (web app): https://badger-demo.uwevoelker.com/
- allows affiliates (referrals, influencers) to register -> they get a token (UUID)
- users confirm this token by a signature
- all this is stored in a database (MySQL)
- start:
script/ref_man daemon
- or better see
Dockerfile
(needs linked MySQL)
- Deposits (and withdrawals) from confirmed users are added together for each affiliate
- at the end of the month each affiliate gets a share of the DAO profits (configurable per vault)
- Data sources:
- Dune (daily profits in USD)
- Subgraph (deposits and withdrawals)
- small node.js script to verify a signature (using
ethers
) - used by
verify_signatures
command
All commands are started by perl cli.pl COMMAND
.
Distributes a share of the DAO profits to affiliates (per vault per day). For each affiliate its user balances are summed up and the profits (percentage is configurable via vaults
database table) are shared by ratio in regards to total supply. All calculations use numbers from the beginning of the day.
(This is the final step and has to run last.)
Takes the output of this Dune query and stores it into the blocks
database table.
Takes the output of this Dune query and stores it into the vault_fees
database table.
Queries the total supply for each vault (and day) and stores it into the vault_shares
database table.
Verifies the user signatures and stores valid confirmations in user_affiliates
database table.
End result of the calculations, profit per vault per day for each affiliate.
Registered affiliates, stores Ethereum address and referral token.
First Ethereum block of each day, used to transform days into blocks (and vice versa).
User confirmations, still unvalidated. Stores the referral token (-> affiliate), block, address and signature.
Balance per user per affiliate per vault per block.
Validated confirmations (from table signatures
), produced by command verify_signatures
. If an user confirms a new affiliate, then the older confirmation is terminated (till_block
column).
Balance per user per vault per block.
Ethereum addresses of users. (Used to produce smaller tables.)
Daily USD income for each vault. Source: Dune query.
Daily total supply for each vault. Source: Subgraph (queried with first Ethereum block per day).
Vault configuration (and mapping between Dune field name), stores address and profit share percentage.