Chainsight platform demo to use it as an HHI oracle.
This is the first PoC of Chainsight platform to demonstrate how to use it as an multi-chain oracle
.
With Chainsight, you can easily aggregate ERC20 transfer events, restore the token holder's balance, and calculate the HHI of the token holder's distribution, and put them into other chains.
In this demo, we use the Chainsight platform to calculate the HHI of the top 10 DAI holders on the Ethereum and Optimism network.
Event indexer is triggered by timer, indexes transfer events from EVM-compatible chains and store as a hashmap of block number and events. Event indexers have pub-sub model and publish transfer events to subscribers.
Algorithm indexer subscribes to the transfer events from the event indexer, use them to calculate the balance of token holders and store them as a hashmap of address and balance.
Lens is a view-only canister that provides the HHI of the token holder's distribution. It uses Algorithm indexer to get the token holder's balance.
Snapshot Indexer is triggered by timer, takes a snapshot of HHI. It uses Lens to get the current HHI and store it as a hashmap of current timestamp and HHI.
Relayer is triggered by timer, relays the current HHI to other chains. It uses Snapshot Indexer to get the current HHI. It calls Oracle Contract in other chains to put them, using Chain-key signatures.
- Deploy the Oracle Contract to the target chain.
- Deploy canisters by
dfx deploy
- Sync transfer events to current block by
npx ts-node indexer/src/update_indexer_events/index.ts
The Herfindahl-Hirschman Index (HHI) is a measure of market concentration and competition among market participants. The HHI is calculated by squaring the market share of each firm competing in the market and then summing the resulting numbers. For example, for a market consisting of four firms with shares of 30, 30, 20, and 20 percent, the HHI is 2,600 (30^2 + 30^2 + 20^2 + 20^2 = 2,600). The HHI takes into account the relative size distribution of the firms in a market and approaches zero when a market consists of a large number of firms of relatively equal size. The HHI increases both as the number of firms in the market decreases and as the disparity in size between those firms increases.
- About Chainsight