Sushiswap Gas Efficiency
timeframe_months
= The number of months to the current date to be included in the charts.- Default:
12
- Default:
granularity
= The date unit by which the statistics will be aggregated.- Default:
week
- Default:
Methodology
The term gas
refers to the amount of computational power needed to execute a transaction on the Ethereum blockchain.
The amount of gas used
for a transaction can be obtained using the ethereum.core.fact_transactions
table. But before doing so, we need to properly identify the transactions we're after. In particular we're interested in the actions associated with two services offered by Sushiswap:
- Swaps
- Provide Liquidity:
Mint LP
- Remove Liquidity:
Burn LP
- Make a trade:
Swap
- Provide Liquidity:
- Lending
Add Collateral
Remove Collateral
Borrow
Repay
Over time we can see the Burn and Mint actions ranging closely together, with a lot of day-to-day variation. During the last couple of months however, the Mint actions have had more frequent and bigger spikes in the gas cost while Burns maintained a similar range to the previous period.
Swaps have generally been less expensive than the other two actions, only rarely surpassing the amount of gas needed to Burn or Mint an LP token.
All three currently follow a slightly upward trend.
In the case of Lending actions, they've all had a steady increase in variation and it seems to continue. This points not only to an increase in complexity in the case of some lending pools, but also to how much complexity variation there is between active lending pools, which presents both an opportunity and a challenge to further optimize contracts.
For more of the time it's been slightly more expensive to Borrow and to Add Collateral than to Repay and Remove Collateral. From a user perspective, it also means the end of the cycle is less expensive, making it easier to exit the Lending protocol than it is to enter it.
Results
Below we can see the average gas used per transaction when one of the actions is executed.
The two most gas-expensive transactions are those Minting and Burning LP tokens. This is to be expected since one of the main gas factors is the complexity of the trade. As both actions involve the transfer of at least two tokens to/from the LP plus the mint or burn of the LP token, complexity quickly adds up and increases the amount of gas required by the network.
On the other end of the stack sits the third action of the same group, Swaps. Over the observed period swaps on Sushiswap required an average of 189k Gas.
Conclusions
- The two most expensive actions are Minting and Burning LP tokens. The least expensive actions are Swaps.
- Actions in the Swaps category follow a slightly upward trajectory, becoming a bit more gas-intensive since early 2022.
- In the case of Lending actions, they require an increasingly variating amount of gas. Generally Borrow and Add Collateral actions require more gas than Repay and Remove Collateral actions.
In the case of swaps, we will leverage the neatly curated data in the ethereum.sushi.ez_swaps
table to get the associated tx hashes
. For all other actions, a corresponding event is registered in the logs of the transaction. Therefore, we can select the tx hash
by filtering for the event name using the ethereum.core.fact_event_logs
table.