Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

referral #5

Closed
vshvsh opened this issue Sep 9, 2020 · 4 comments
Closed

referral #5

vshvsh opened this issue Sep 9, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@vshvsh
Copy link
Contributor

vshvsh commented Sep 9, 2020

There should be an optional parameter in deposit function that takes a referral eth address eg
deposit_with_referral(uint256 referral) payable
That parameter is either unused or emits an event with referral address. I'd prefer a calldata referral bc it's cheaper, but event's okay too

There should be a script to collect referral data in the following format, given block1 and block2.
between block1 and block2 (both included) there have been referalls:

0x123...890 1000.8249240020934eth   10.008249240020934% 
0xabc...def 200eth                  2%

The easiest and most useful way to make that is probably thegraph subgraph, but something simpler might work too

@vshvsh
Copy link
Contributor Author

vshvsh commented Sep 10, 2020

Example:

block_number    deposit_size    referral
99              1eth            0xb8baa0e4287890a5f79863ab62b7f175cecbd433
100             10eth           0x2cffa6e8b85028952be77c0ae2c2c319499c6eff
101             70eth           0xb8baa0e4287890a5f79863ab62b7f175cecbd433
101             10eth           0x2cffa6e8b85028952be77c0ae2c2c319499c6eff
199             20eth           0x0
200             10eth           0xb8baa0e4287890a5f79863ab62b7f175cecbd433
201             100eth          0xb8baa0e4287890a5f79863ab62b7f175cecbd433

there's been 120eth worth of deposits between blocks 100 and 200 but only 100 with referral

count referrals (100,200) will output

0xb8baa0e4287890a5f79863ab62b7f175cecbd433  80eth   80%
0x2cffa6e8b85028952be77c0ae2c2c319499c6eff  20eth   20%

total                                       100eth  100%

@vshvsh
Copy link
Contributor Author

vshvsh commented Sep 10, 2020

Neither caller address nor EOA who sent the transaction doesn't matter for referrals

@vshvsh vshvsh added the enhancement New feature or request label Sep 10, 2020
@ongrid
Copy link
Contributor

ongrid commented Sep 11, 2020

Contract

add referral's address to existing method submit as optional argument
https://github.com/depools/depool-dao/blob/274f7b857d37399501c1c08aa92ddf1de3fd9a0b/apps/depool/contracts/DePool.sol#L96
submit(uint256 referral) payable
If referral missing, it would be called by the client with 0x00 value (zero cost)

the event Submitted should include referral address (0x00 if not set)
https://github.com/depools/depool-dao/blob/274f7b857d37399501c1c08aa92ddf1de3fd9a0b/apps/depool/contracts/DePool.sol#L488
emit Submitted(_sender, _value, _referral);

Scanner

pure python3 stateless script running from CLI with block range passed via ARGV
python3 count_referrals.py <start block> <end block>
The algorithm:

1. connects to given web3 endpoint
2. polls the blocks by number (sequentially, synchronously, incrementally)
3. filters receipts with destination (DEPOOL_CONTRACT) AND event Submitted
4. parse event fields, group by referrals and summarize deposited amounts
5. calculate the referral percentages
5. print the result to stdout

File location: depool-dao/apps/depool/scripts/count_referrals.py

@ongrid
Copy link
Contributor

ongrid commented Sep 15, 2020

count_referrals.py scanner and test helper are to be implemented in pythonic repo https://github.com/depools/py-oracle. See lidofinance/lido-oracle#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants