Frontrun

Share this post

Ethereum essentials: How to onboard to layer 2 roll-ups and measure transaction fees

www.frontruncrypto.com

Ethereum essentials: How to onboard to layer 2 roll-ups and measure transaction fees

Part 2 of the Ethereum essential series: what are roll ups, how to read an L2 transaction, fees and the role of roll-ups in DeFi wealth creation using Arbitrum

John Cook
Sep 7, 2022
1
Share this post

Ethereum essentials: How to onboard to layer 2 roll-ups and measure transaction fees

www.frontruncrypto.com

Dear frontrunners,

Our journey to wealth in crypto is measured in knowledge (learning) and conviction (doing). Conviction without knowledge is arrogance (YOLO) and knowledge without conviction is insecurity: think of all the people who are smarter than you but have not realized their full potential. Is this you? Why does this happen?

Our goal is to avoid this mental trap, our goal is to frontrun - to have high knowledge and high conviction. We do this by rejecting participation inequality, we do this through hands-on experience in the defi ecosystem.

This guide is part 2 of 3 in the Frontrun Ethereum-essentials handbook:

  • Guide 1 - Gas fees, etherscan, and centralized exchanges

  • Guide 2 - layer 2 roll-ups and corresponding fees - 👈👈 you are here

  • Guide 3 - Lend, borrow and borrow again: an introduction to leverage

These guides will collectively serve as your foundation for mastering the future of decentralized finance and the next generation of wealth creation.

Level up your crypto knowledge & master the future of decentralized finance.

📚 This guide will cover

  • Why you should care about roll-ups

  • Why roll-ups are the foundation for all retail decentralized finance activities

  • How to interact with roll-ups

  • Why transaction costs are the single most important reason to use a layer 2

🧰 Tools you will need

  • A spreadsheet - I use google sheets

  • Hop exchange - Cross chain bridge to transfer tokens

  • aave - A borrow/lending platform on Ethereum

  • Arbitrum - Our layer 2 of choice for this guide

  • Etherscan - blockchain explorer to assess fees and contract interactions on mainnet

  • Arbiscan - blockchain explorer to assess fees and contract interaction on Arbitrum

  • Hop exchange - to move Ethereum from mainnet to Arbitrum

  • A web wallet like metamask

  • The web wallet needs to have eth in it

    • if this is not your case you will need to purchase Ethereum on a centralized like coinbase and move the eth to your web wallet

  • A basic understanding of eth gas fees (gwei, base, max, tip) and how they are all interconnected

🛑 If the last two bullet point sounds unfamiliar, stop reading this guide and complete all activities outlined in ‘Ethereum fundamentals - gas fees, etherscan and coinbase’ first. We will be here when you’re ready, promise.

❓Fees are the reason you should care about roll-ups

We frame this guide by outlining why you should care about layer-2s before explaining what it actually is because humans are more inclined to pay attention if framed in a ‘whats-in-it-for-me’ type of answer. There are many technical benefits to layer-2s like speed, security, and application-specific use cases (chains built for minting NFTs, chains built for social media, chains built for defi, etc) but the reason we, frontrunners, care about layer-2s is that transaction fees are between 3x and 100x cheaper than the Ethereum layer-1.

Image 2 - Ethereum transaction fees. source - l2fees.info

At the time of this writing, trading tokens yields a transaction fee of $4.99USD on Ethereum vs $0.22USD on Arbitrum. We can see the very real implications in transaction fee variance by performing identical transactions on AAVE with Ethereum vs AAVE Arbitrum. Below we are lending .02 eth on AVE to be used as collateral which generates yield.

Image 3 - Same transaction, 100x more expensive.

We acknowledge that this transaction is a web wallet executing a smart contract that lends eth to an AAVE protocol. Not just a simple ‘person-to-person’ transaction, but we reject the idea that it should cost $25 to lend $31.

There was a time when it was financially neutral to buy, sell, lend, borrow and trade on Ethereum layer-1 but that was pre-2020, not 2022….

Image 4 - average gas fees on Ethereum - source messari

…and low fees were a byproduct of low user adoption as measured by transaction volume. In Q12020 aggregate daily transaction volume on layer 1 was approximately ~$168M. Even post-2022 bull-run, layer-1 is transacting north of $3 billion per day. An increase of 30x, as depicted below.

Image 5 - average transaction volume on Ethereum. Transaction fees run in parallel with transaction volume - source messari

The Ethereum foundation does have a vision for the future which includes increased throughput via scalability and data compression through proposals like:

  • EIP-4844 Proto danksharding - introduction of BLOB data types to increase storage

  • EIP-4444 Danksharding- Decoupling of historical data from the EVM to reduce required storage and improve network utilization

Image 5 - Ethereum scalability post-merge source: EDCON San Francisco 2022

…all of which could lead to reduced transaction costs, but the reality is that retail users will never realize optimal transaction fees on layer 1. The future of layer 1 is as the settlement layer through which institutional players and layer 2 protocols submit batches of transactions to be validated by stakers while concurrently benefitting from the security provided via ethereum’s virtual machine.

✍️ Side bar - Ethereum virtual machine vs java virtual machine?

For those uncertain about the ‘Ethereum virtual machine’, a popular comparison that draws parity to a legacy web2 technology is the ‘Java virtual machine’. In the 90s a company called Sun Microsystem (acquired by Oracle) developed a development framework called the ‘Java Virtual Machine’ which served as the execution layer through which developers could build ‘Java applications’ leveraging a set of pre-built libraries which inherit the security and interoperability of the most popular programming language of the early web2 era - Java. Developers would code apps in java which the compiler would convert to ‘java bytecode’ that would run on the JVM.

I see parallels to the Ethereum virtual machine in that developers build ‘applications’ on the EVM which leverage a set of pre-built libraries to inherit the security (stakers verifying blocks) and interoperability (moving tokens across the Ethereum ecosystem) of the most used platform in the web3 era.

Share

A very brief speed-run on layer 2s

Layer 2s, also called ‘rollups’, are protocols built on top of Ethereum layer 1 which aggregate transactions such that transaction volume increases while cost decreases…as depicted below.

Image 6 - rollup conceptual diagram derived from vitalik “an incomplete guide to rollups’

Ethereum is constrained in that it can only process ~15 transactions per second or 1 million transactions per day, with the cost of transacting (gas) increasing as blockchain utilization increases.

  • L2s like optimism increase throughput from 15 transactions per second to > 500 transactions per second

  • L2’s like zksync push 50x faster by providing infrastructure to process > 20,000 transactions per second

L2 comparison
image 7 - scalability of layer 2 technologies source - zkEVM

Layer 2 technologies like optimistic and zksync provide the infrastructure for us to ‘buy, sell, trade, borrow, lend and leverage’ with lower transaction costs. For frontrunners, we believe Ethereum is the ecosystem for a decentralized finance future, and our goal is to actively engage in this technology while reducing associated transaction fees. That is why we need rollups.

Now that we understand the purpose of L2s (increase transaction volume and reduce transaction costs) and how L2s work (by rolling up transactions into batches), it’s time to enter the rollup ecosystem.

🛗 Transacting on layer 2 using AAVE + Arbitrum

Step 1 - Deploy the spreadsheets and take note of existing token balances

  • Navigate to aave

  • Switch the ‘market’ to version 3 - arbitrum

  • Open Arbiscan

  • Open Etherscan

  • Open your spreadsheet

In your first 100 days, every transaction you perform should be accompanied by a spreadsheet that outlines the transaction to be performed, the wallet balance before transaction execution, and the estimated wallet balance after the transaction execution. We must learn to love the details as it will enable us to become hyper-aware of fee implications and the movement of money across the blockchain.

Yes - we can start by reviewing the AAVE market UI to see a ‘dashboard’ of available tokens…

Image 8 -- aave’s borrow/lending platform - always cross-check against the actual blockchain explorer

..but let’s be sure.

Review the arbiscan blockchain explorer and create a table that outlines all of the tokens in your web wallet. Take note of the actual tokens and how AAVE delineates between supplied eth “aArbWETH’ vs borrowed eth ‘variableDebtArbWETH’, if you’ve already supplied collateral.

Table 1 - balance in AAVE web wallet before we start

🛑 STOP - Does the balance of your arbiscan blockchain wallet explorer match the balance in AAVE? It should. Do not proceed until you’ve documented the tokens used to derive the AAVE dashboard.

Note at its core, the value of AAVE’s borrow/lending platform is measured with the ‘aToken’ . The aToken tokenomics (how tokens are created and how they accurate value) burns (destroys) and mints (creates) tokens relative to the underlying asset:

  1. When you lend Ethereum on AAVE mainnet you receive ‘AAVE wrapped Ethereum’ tokens

  2. When you lend Ethereum on AAVE Arbitrum you receive ‘AAVE Arbitrum wrapped Ethereum’ tokens

  3. When you borrow variable debt eth against your collateral using AAVE Arbitrum you receive ‘Variable Debt Arbitrum wrapped Ethereum’ tokens

These tokens and their underlying asset are pegged to the value of the collateral you deposit.

Using table 1 as an example:

  1. AAVE minted an ‘aArbWBTC’ of .00487135 which denotes the amount of wrapped bitcoin I supplied in a previous transaction

  2. AAVE minted a ‘variableDebtArbWETH’ token of 0.0300117328003628 which denotes the amount of eth I borrowed at AAVE’s prevailing variable interest rate

The aToken supplied/borrowed tokens are not actually exposed in the UI (you just see a screen that says you supplied some ETH and borrowed some in return) but should be noted and understood on the backdrop of a larger discussion related to how lending/borrow platforms work under the hood. We will cover AAVE’s tokenomics and how mint/burning works in parts 3 and part 4.

Action - before moving onto step 2, re-create table 1 using your web wallet balance.

Share

Step 2 - Migrate eth from mainnet to arbitrum and analyze blockchain results

  • Open hop exchange

Only after you’ve created a spreadsheet to track pre-transfer balances, are you ready to start the trade. We are using hop exchange as the token bridge from layer 1 Ethereum mainnet to layer 2 Arbitrum.

Hop exchange is one of many bridge technologies we can use to move eth from l1 to l2 but is by far the most popular. During Arbitrum’s odyssey summer 2022 event (which was paused due to over-participation), hop exchange was used for almost 8,000 transactions, it 2x’ed its closest competitor, across.to .

Image 9 - Hop exchange utilization on arbitrum during the summer 2022 odyssey event - source dune analytics

DeFi portfolio managers like Zerion and Zapper also offer bridging technology that automatically routes the trade to the cheapest exchange. As frontrunners, we need to make sure to understand that we are moving eth tokens from ‘layer 1’ (mainnet) to layer 2’ (Arbitrum) using bridge technology and our goal is to always leverage the bridge which offers the lowest transaction fee.

🛑 STOP - Take note of the nominal eth amounts referenced in hop and cross-check against your web wallet in etherscan and arbiscan. The numbers must match.

In the example below we are moving .09 eth from the mainnet web wallet to the arbitrum layer 2 web wallet.

Image 10 - cross-check layer 1 and layer 2 balances against each blockchain explorer before moving forward.

Since you’re documenting token balances in your spreadsheet, you will be able to estimate the starting and ending balances of each wallet (the wallet associated with mainnet and the wallet associated with arbitrum, both will have the same address) as well as the implications to the Ethereum balance when taking into account transaction fees.

🚀 Starting with the mainnet wallet:

Using etherscan and your spreadsheet can answer all of these questions: How much eth moves from Ethereum L1 wallet to the Arbitrum L2 wallet? (.09 eth) What are the starting and ending balances of the Arbitrum wallet? (.018, .096) Do the transfer amount from L1 and Arbitrum reconcile against the balance? (yes, row4, row 7) How much did this transaction cost? ($2.37) All answerable below.

Table 3 - By documenting the changes in balance amount and cross-checking against the transfer amount, you’ll understand how much eth was actually sent and how much it cost

Moving .09 eth from mainnet to arbitrum cost ~.0014 eth or $2.37usd on layer 1. This is not magic. Transaction fees aka gas are the amount burned, amount tipped, and the amount returned and are all derived from the base (9.84 gwei) , priority (1.5 gwei) , and max amount (14.2 gwei) multiplied by the gas limit:

transaction fee = base(max + priority)* limit * 1 gwei/eth & price per coin = (9.84(14.2+1.5)*132,086)*(10^-9)*$1,585.35 = $2.37 USD

The image below outlines the reconciliation of L1 transaction fees depicted against the etherscan blockchain explorer.

Action - Calculate burned, tipped, and the actual gas used on your transaction

Image 11 - transaction fee calculation from using hop exchange to move .09 eth from mainnet to arbitrum - using etherscan

🚀 Calculating transaction fees on arbitrum

Using our same spreadsheet and arbiscan we perform a similar analysis to determine the associated transaction fees on layer 2. Yes, transaction fees are imposed on both layer 1 and layer 2….but do you see the order of magnitude difference?

The gas price for arbitrum is 0.1 gwei as opposed to 11 gwei on L1.

Much easier to understand, right? We can calculate the cost of gas by:

transaction fee = gas limit * gas price * 1 gwei/eth * price per coin = 250,933 * 0.1 x 10^(-9) * $1589.46 = $0.04 USD
Image 12 - Gas fees depicted on arbiscan

In aggregate moving .09 eth cost 0.001494124041 eth on mainnet and 0.0000250933 eth on arbitrum.

Action - before proceeding, perform this calculation using your specific transaction on both mainnet and arbitrum. Does your math match what’s in etherscan & arbiscan? It should. If you need more help review this guide.

Share

Now that we’ve assessed the impact on the L1 wallet and associated transfer fees on both L1 and Arbitrum L2, we’re now able to verify how the transfer of .09 eth impacted the Arbitrum wallet balance.

Doing this we notice something odd; the amount of eth received is greater than the amount of eth sent, even when accounting for gas fees.

  • We sent .09 eth from L1

  • We received .090002 eth on Arbitrum

Image 13 - the amount sent from mainnet (.09) vs the ending amount (.0904) vs the amount received on arbitrum (.090002)

…Yes, we can confirm that .09 eth was received by the Arbitrum wallet, but exploring the transaction details we actually received ~0.090002 eth. How? We see in the details:

  • the smart contract 0xDa7c0de432a9346bB6e96aC74e3B61A36d8a77eB which corresponds to hETH (hop exchange’s Ethereum token collateralized by Ethereum) transferred .09 eth to an address ending in ac6d97…then…

  • ..the smart contract which corresponds to wrapped ETH 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 (wrapped eth) sent 0.090002158788826273 eth from the ac6d97 address to my target web wallet

Although I acknowledge that the variance is negligible, and is due to the price variability of the hETH and wETH-denominated tokens, it is still a value greater than zero. Regardless, what can we conclude with 100% certainty?

The estimated amounts in our web wallet e.g. metamask and the hop-exchange UI are not accurate:

Image 14 - comparing metamask and hop exchange estimated gas fees vs the actual amount

You must always calculate the fees yourself. If you don’t start with small trades, you won’t have the conviction to do it with larger trades. You will get rekted.

Image 15 - the metamask and hop exchange fee estimators serve as a good estimate, but they are only estimates

Wow that was alot.

We transferred .09 eth from L1 to Arbitrum L2 and reviewed the resulting balance. Sound simple? It is. This was heavy because what we can summarize from this analysis is a core idea, that if ignored, will be your demise: It is very easy to transfer money across exchanges and protocols. The actual process is only one step: click the send button in the hop exchange. But you must be able to explain how the tokens move from layer to layer, what happens to your actual token balance, what tokens are being minted/created, and how much you’re paying in the process. This level of detail will force you to assess associated fees and give you insight into how a smart contract works.

This is how you build knowledge and conviction. This is how you frontrun.

🔔 Action for frontrunners:

  • Send eth from L1 to Arbitrum

  • Create two tables that document the associated transaction fees for each layer

  • Calculate the transaction fee and reconcile it against what you see in etherscan and arbiscan

  • Review the transaction details and assess what smart contacts were called and what tokens were used

You are the master of your destiny,

John Cook
September 6th, 2022
San Francisco, CA
www.frontruncrypto.com

Level up your crypto knowledge & master the future of decentralized finance.


Supporting content:

  • A primer on zkEVM roll ups

  • Ethereum Foundation - Optimistic rollups

  • AAVE aTokens

  • Arbiscan transaction details referenced in this guide

  • Etherscan transactions details referenced in this guide

  • Vitalik 2021 - an incomplete guide to roll-ups


tweet of the week - is there any limit to your ambition?

Twitter avatar for @dubzyxbt
dubzy ❁ @dubzyxbt
Ambition
9:30 AM ∙ Aug 28, 2022
294Likes41Retweets


Share this post

Ethereum essentials: How to onboard to layer 2 roll-ups and measure transaction fees

www.frontruncrypto.com
Previous
Next
Comments
TopNewCommunity

No posts

Ready for more?

© 2023 Frontrun
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing