# On-Chain Data Collection Algorithm

At DeFi Teller, we have developed a comprehensive and robust algorithm to collect and analyze on-chain data. This process is at the core of our services, ensuring that you get the most accurate and up-to-date information on your due diligence journey.&#x20;

#### The Problem

Currently, a few major platforms are offering aggregated on-chain metrics such as TVL, Users, Volume, and Transaction count. However, all of these platforms rely on custom connectors, often utilizing The Graph, where connectors are implemented by third-party entities, including the project teams themselves. This reliance on The Graph and its third-party connectors can lead to non-objective data, which might intentionally or unintentionally distort the actual scenario.  Since each project aims to present itself in the best light, the logic behind these custom connectors is often focused solely on maximizing these statistics.&#x20;

DeFi Teller introduces a distinctive approach that diverges from the standard use of The Graph and its third-party connectors. We standardize projects, placing them under consistent initial conditions for a fair comparison. Projects need only to submit a list of their associated smart contracts. Following this, our unique algorithm calculates various quantitative metrics, including less apparent ones like internal transactions. These metrics are used to assess key aspects of each project, including User Count, Transaction Volume, Total Value Locked (TVL), and overall trading volume.

#### Here's how our system works:

**1. Comprehensive Transaction Collection**

Every transaction on the blockchain involving token movements is captured. This ensures a complete picture of the blockchain's activity.

**2. Daily Token Data Aggregation**

We gather daily details on all tokens, including their addresses and current value in USD. Our analysis filters these tokens, adding only those that meet our stringent criteria to our whitelist. This list is extensive, featuring over 12,000 tokens for Ethereum alone.

**3. Continuous DApp Contact Address Integration**

Our database is updated daily with contact addresses linked to specific decentralized applications (DApps). We automatically gather new contracts for liquidity pools in DEX projects like Uniswap v2 and Uniswap v3 and manually update our database for other DApp types.

**4. Transaction Analysis**

Our algorithm analyses every transaction each day to determine if there was any interaction with contracts in our database. Important details, including the user's address, the volume of token movement denominated in USD, and the DApps involved, are accurately recorded.

**5. Aggregated Data Insights**

We aggregate and analyze data concerning users, transaction volumes, and Total Value Locked (TVL) for specific DApps. These insights are categorized over various timeframes: 1 day, 7 days, 30 days, and 180 days, offering a comprehensive view of DApp interactions.

#### Calculating Transactions

When calculating a specific DApp's transaction count, we account for both direct transactions (those where the “to” field matches one of the DApp's contract addresses) and indirect interactions. Indirect interactions include transactions that are part of a composite process, such as those executed by an MEV bot or via aggregators like 1inch and Paraswap.

For example, consider an MEV bot conducting a swap transaction involving both Sushiswap and Curve. While it's a single transaction on the blockchain, in our database, we record it as:

• +1 transaction for Sushiswap

• +1 transaction for Curve

#### Calculating TVL

To determine the Total Value Locked (TVL) in the smart contracts we are monitoring, we query the balances of all whitelisted by us tokens and aggregate their equivalent in USD.

#### Calculating Users

We define “Users” as unique wallet addresses that have initiated a transaction, during which there was an interaction with a DApps’s smart contract.&#x20;

For instance, if a user executed a swap through 1inch, and 1inch split the swap between Uniswap and Balancer, we would record in our database:

• +1 user for 1inch

• +1 user for Uniswap

• +1 user for Balancer

We track the number of unique users over various periods, including 24-hour, 7-day, and 30-day intervals.

Consider a scenario where a user conducts a swap on Uniswap daily for 30 consecutive days. In this case, our database records would reflect:

• +1 user in the 7-day timeframe

• +1 user in the 30-day timeframe

#### Calculating Volume

For volume calculation, we scrutinize each transaction to account for movement of tokens. If whitelisted tokens are involved in the transaction, we calculate their combined value in USD.

Take, for instance, our analysis of [this](https://arbiscan.io/tx/0x155ce6da7075a789082bf2822a7879a7070a367f09470874832b38abd07af554) transaction. Based on it, we updated our database with the following Volume data (as of the transaction time):

• Beefy: +$101.5

• Adamant: +$98

• Uniswap: +$62.7

• Balancer: +$23

• Sushiswap: +$31

Through this detailed analysis, we ensure our database reflects the dynamic nature of on-chain activity, providing users with precise and actionable insights.
