EIF 3.0 Week 3 & 4: Nosedive

Hey there,

It has been four weeks already; which means that it's time to nosedive from the learning phase into the building phase of the fellowship. Time flies so fast. A lot of learning happened in the past two weeks. Through the Speedrun Assignments, I read about a bunch of different applications built on top of Ethereum, how Layer 2 scaling works, how Zero Knowledge Proof systems work, and what AMM invariant curves are. We also had a session where each Wei track fellow had to explain a DeFi protocol to the other fellows. Does this qualify as the happening fortnight of 2023? I guess so.

To be honest, I like following a laid-out guided path for learning, so I'm a little nervous about whether I'd be able to do justice to the upcoming building phase. I have a gut feeling that it'll turn out pretty well, so let's trust that and LFG 🚀.

Speedrun Ethereum Challenges

My Speedrun Profile:

Challenge #5: Build a DEX Challenge

In this challenge, we had to build a Decentralized Exchange (DEX) with one token pair (an ERC20 $BAL token and ETH). Participants use this to convert one token into another on-chain. The DEX starts off with some initial Liquidity and has to maintain its exchange rate using the x*y=k equation where the k is an invariant. Infact, this is the same equation which is used in the Uniswap V2 contract. This invariant equation automatically adjusts the exchange rate of the reserves as the reserves move away from the equilibrium. This is precisely what an Automated Market maker (AMM) does.

Participants in this DEX can also become Liquidity Providers (LP) and contribute their assets to the $BAL-$ETH token pool to enjoy earning a portion of the trading fees on this. Increased liquidity means less slippage during swapping, so it's good for everyone.

Challenge #6: A State Channel Application Challenge

One of the major challenges of dApps on Ethereum is the low transaction throughput and expensive gas fees. This makes scaling traditional apps on Ethereum difficult. Now there are various methods to scale these applications, one of which is using a state-channel application.

Here, instead of handling each transaction on-chain, we open an off-chain state channel and handle the transactions there. We do this by first opening a state channel by locking some funds from each party through a single transaction on-chain. Then we do a bunch of transactions off-chain. Finally, when all the transactions are done, we do the final settlement through a second on-chain transaction.

In this assignment, we have done the same thing for Guru and Rube entities where they initiate their transaction on-chain and the Rube gets wisdom from the Guru off-chain. The Rube pays for each letter of wisdom received and when they are done wit, the transaction is finally settled on-chain.

Challenge #7: Multisig Wallet Challenge

This was a challenge that I was really impressed with. We had to create a smart contract wallet that can have multiple owners. Whenever a transaction is proposed, it is kept in an array, waiting for approvals from its owners. The transaction can go through only when enough owners vote on it. This is why it is called a 'multisig’ as it is owned and operated by multiple signatures. The recover() method of the ECDSA library is used to retrieve the address of the message's signers and verifies the signatures.

These multisig wallets can be particularly useful in DAOs where there are multiple participants and they collectively own the DAO's decisions and assets. So, any transaction for the DAO can only go through when enough of its members vote on it. And all of this can be done trustlessly without relying on any third party. How cool!

Challenge #8: SVG NFT Building Cohort Challenge

In this challenge, we developed Loogies NFTs that render SVGs using Solidity! The NFTs were unique through the different attributes of their colour hex and chubbiness value. The randomness in generating the colour and chubbiness properties ensured that no two NFTs were the same.

An NFT's metadata can be stored both off-chain or on-chain. For this Loogies NFT, we saved the metadata in the tokenURI. This is actually preferable because we can verify all the attributes of the NFT on the chain itself.

I also had some trouble passing all tests in the last week's challenges. So as I write, I am also trying to see what else can be improved in the codebase to pass everything. Nonetheless, these were great challenges and I highly recommend somebody new to Solidity to try out Scaffold-ETH to headstart into Ethereum development.

Reading

Here is some of the stuff I have been reading in the past two weeks:

L2s

AMM Invariant Curves

ZKML

Verkle Trees

DeFi Presentation: dYdX

At the start of Week 5, we had to do a presentation on a DeFI protocol to other fellows. My presentation was on the dYdX exchange. To be completely honest with you, I'd say that I enjoyed the research phase much, much more than the actual presentation itself! There was a lot to learn, right from the first announcement by the founders to the whitepapers to the recent developments and the future roadmaps.

I won't bore you with the details of everything that I've gone through but in short, dYdX is a decentralized exchange for trading crypto derivatives. Sounds fun? Treat yourself to the presentation and the additional resources below:

Parting Notes

If you've made it this far! Give yourself a pat on the back. I didn't realize we went through so much in the two weeks! This was intended to be written in two parts, but well, life happens, so here we are. I think I was especially intrigued by the AMM invariant curves and I wish to do a deeper dive into them in a separate blog post exploring why the curves are the way they are.

Four weeks into this program, I also have a newfound inquisitiveness about economics. As you already know, the blockchain space has been married to economics since we first knew about it. In fact, it's not just blockchain. Economics has been intertwined with mathematics and computer sciences for long. I'll be looking forward to exploring this in the blog post on AMM as well.

Until next time,

Pushkar

Subscribe to Pushkar Patel
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.