Giter VIP home page Giter VIP logo

Comments (4)

vshvsh avatar vshvsh commented on August 10, 2024 1

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%

from lido-dao.

vshvsh avatar vshvsh commented on August 10, 2024

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

from lido-dao.

ongrid avatar ongrid commented on August 10, 2024

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

from lido-dao.

ongrid avatar ongrid commented on August 10, 2024

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

from lido-dao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.