hoprnet / hopr-devrel

Projects related to support our users, node runners and developers
hopr-prompt.vercel.app
GNU General Public License v3.0
1 stars 12 forks source link

Participation pyramid #95

Closed QYuQianchen closed 2 years ago

QYuQianchen commented 2 years ago

Base layer: Accounts that are eligible for voting in DAO v0.2

Note that

  1. Accounts may at the same time be HPOR/xHOPR/wxHOPR holders/staking participant
  2. Use erc20."ERC20_evt_Transfer" table on ethereum and xdai chain. "contract_address" are listed above.

Middle layer: Accounts that are likely to vote

Top layer: Accounts that actually did vote

Get the value, aggregate in python and draw a funnel chart

QYuQianchen commented 2 years ago

DAO v0.2 vote happend on xDAI chain at block 18650367 (timestamp 1634644345), which corresponds to the block 13448027 (timestamp 1634644343) on Ethereum blockchain

Value extracted from 1hive/xdai-blocks subgraph

{
  blocks(where: {number: 18650367}) {
    id
    number
    timestamp
  }
}

and blocklytics/ethereum-blocks subgraph

{
  blocks(first: 1, orderBy: number, orderDirection: desc, where: {timestamp_lte: 1634644345}) {
    id
    number
    timestamp
  }
}
QYuQianchen commented 2 years ago
WITH accounting_base AS (
    SELECT "from", "to", "value" FROM erc20."ERC20_evt_Transfer"
    WHERE "contract_address" = '\xf5581dfefd8fb0e4aec526be659cfab1f8c781da'
    AND "evt_block_number" <= 13448027 -- Cut-off block number for snapshot voting Oct-19-2021 11:52:23 AM +UTC
), accounting_result AS (
    SELECT account, sum(amount) AS balance FROM (
        -- view from sender
        SELECT "from" AS account, -1 * "value" AS amount FROM accounting_base
        UNION ALL
        -- view from recipient
        SELECT "to" AS account, 1 * "value" AS amount FROM accounting_base
    ) AS t
    GROUP BY account
    ORDER BY balance DESC
)

SELECT * FROM accounting_result
WHERE balance > 0