Gas Efficiency

    Q88. Which one of the sushi services consumes the most gas per transaction? The services to include in your comparison are : -Adding liquidity -Removing liquidity -Adding an asset for lending -Borrowing -Removing an asset from lending -Repaying a loan -Swapping Hint: each of these activities have a special event that only appears for that activity. For instance repaying a loan generates the “LogRepay” event.

    Goal:

    find the sushi services consume the most gas.

    Question:

    Which one of the sushi services consumes the most gas per transaction?

    The services to include in your comparison are :

    • Adding liquidity
    • Removing liquidity
    • Adding an asset for lending
    • Borrowing
    • Removing an asset from lending
    • Repaying a loan
    • Swapping

    Solution:

    This dashboard is about all services provided by Kashi pools on the SushiSwap platform. So the first step is to find all Kashi Pools.

    the next step is to find all event_name asked us in the question.

    The last question is to find gas_used per transaction for each service.

    Now telling you step by step what I am doing.

    1. finding all Kashi pools from ethereum_core.dim_contracts. The symbol of our Intended pools must be like %km% and the name must be like %Kashi%. Now we have all contract addresses we want.

    2. Use Contract addresses to found transactions related to Kashi pools services from ethereum_core.fact_event_logs table.

      I used below event_name for each service:

      • event_name = 'LogAddCollateral' for Adding liquidity
      • event_name = 'LogRemoveCollateral' for Removing liquidity
      • event_name = 'LogAddAsset' for Adding asset
      • event_name = 'LogRemoveAsset' for Removing asset
      • event_name = 'LogRepay' for Repaying loan
      • event_name = 'LogBorrow' for Borrowing

      In addition, I used ethereum.core.ez_dex_swaps table for Swappng.

    3. Now we need gas_used. But there isn't the gas column on the table we used in the previous step. So we used all tx_hash obtain from the previous step and find them from ethereum.core.fact_transactions table.

    4. All we need is ready. So calculate the average of gas_used for each event_name.

    Loading...
    Loading...
    Loading...

    In the first chart, I show the gas_used per transaction for all event_name that there are in Kashi pools. In fact, in this section, I did not separate the events in question.

    In the above chart, you see all events in Kashi pools on SushiSwap platform. According to this, the most gas per transaction is generated by ExchangeRate. The next rank belongs to Borrowing and Transfer, respectively.

    In addition, the least gas per transaction is generated by Approval.

    But now, Lets compare just services asked us in the question.

    Among these services, Borrowing generated the most gas per transaction with 230K gas_used. The next rank belongs to Adding Liquidity, Removing Liquidity and Swapping, respectively.

    Adding asset and Removing Asset generated the least gas among others.

    The above chart show all I said, clearly.