Day 67 of #100DaysOfDeFI 🚀 Today I continued creating a basic DEX 👩🏻💻 and focused on developing a Pair smart contract 👾 Pair represents the Liquidity Pool 🪙 it is in charge of swapping 💱 managing the liquidity pool and burning 🔥 #womenwhocode#100DaysOfCode
Summary 🧵
1/ In this example of the Pair smart contract I’ll implement the following methods:
🔶 getReservers - get quantities of each token;
🔶 updateReserves - update the tokens’ quantities;
🔶 swap - exchange two tokens;
🔶 withdrawTokens - send the tokens back to the LP.
2/ First, initialize the Pair contract. We’ll need to import some contracts from OpenZeppelin and a Tokens contract from the day 66 of the challenge. Initialize state variables and constructor, too👩🏻💻
3/ Function getReserves is a getter function that returns quantities of each token 👇
4/ updateReserves → when the amount of tokens changes in the pool because of withdrawing, swapping or adding the tokens, we have to update the token's quantities 💰
5/ swap function 👾 is the main functionality of the DEX 💱 as an input we have the amounts of tokens to swap and the address to transfer them. This address corresponds to the caller of the contract 🤖 Basically, swapping is transferring of the tokens 🪙
6/ withdrawTokens functions is executed when the caller wants to get their tokens back from the Liquidity Pool 💰 It is performed with the help of transferFrom function of ERC20 interface and is basically the transfer of tokens from the Pair’s to the caller’s addresses 🤖
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Day 68 of #100DaysOfDeFI 🚀 Today I worked on the Factory smart contract that is a part of the decentralized exchange architecture 💱 Factory creates and keeps track of all Pair contracts 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ The Factory will include:
🔷 createPair - create a Liquidity Pool;
🔷 adjustAmount - adjust a number of tokens using a formula;
🔷 getReserves - a getter function;
🔷 addLiquidity - add liquidity to the LP;
🔷 removeLiquidity - withdraw liquidity;
🔷 trade1for2 - swap tokens.
2/ First, initialize contract and define the state variables 👩🏻💻
Day 66 of #100DaysOfDeFI 🚀 Today and the following days I'll dive into DEXs implementation in #Solidity ⭐️ I’ll review the Uniswap smart contracts and create a decentralized exchange protocol 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ Uniswap smart contract architecture consists of Core and Periphery:
🔹 Core is used for storing and swapping the tokens, adding funds, getting rewards, etc;
🔹 Periphery interacts with the Core.
2/ Core stores the following smart contracts:
🔹 Pair - swaps, mints and burns tokens;
🔹 Factory - creates pairs of tokens;
🔹 ERC20 - keeps track of ownership of pool.
Periphery has only 1 smart contract:
🔹 Router - interacts with the Core.
Day 63 of #100DaysOfDeFI 🚀 Today I learned how to deploy an NFT collection on a testnet 🤖 and uploaded a collection of watermelon houses generated with AI on OpenSea 🐳 special thanks to @javilop for creating these cute houses! 🍉 #womenwhocode#100DaysOfCode
Summary 🧵
1/ First, upload a collection of images on Pinata, I described it in detail on day 56 of the challenge 🔙
2/ Now create json files for each image and add CID to “image” 👇
Day 62 of #100DaysOfDeFI 🚀 Today I continued deploying smart contracts on Ethereum testnet Rinkeby and uploaded a duck 🦆 NFT on OpenSea 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ First, prepare the jpeg file and metadata for the NFT. We’ll use Pinata platform for hosting files 🦙 A jpeg is an image we want to deploy as an NFT and a json file is the metadata. So, create an account in pinata.cloud and first upload the image.
2/ There will be a CID generated that we have to add to the json file. In name section add “gateway.pinata.cloud/ipfs/” and the image CID. Upload the json file too 👩🏻💻
Day 61 of #100DaysOfDeFI 🚀 Today I learned how to deploy tokens on Ethereum testnet 👾 for this I will use Rinkeby testnet and Remix IDE for developing smart contract 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ Use code from the day 57 of the challenge to create ERC20 tokens 👇
2/ Then, create 2 additional accounts on Rinkeby testnet on MetaMask 🦊 For that, just choose the Rinkeby testnet and click “Create account” 👾
Day 9 of #100DaysOfDeFI 🚀 today exploring Zapper.fi. Zapper is a decentralized finance tool ⚒️ It allows users to monitor their assets💰 debts, liquidity pools, yield-farming 👨🌾 NFTs 🖼️ etc. in one place. #100DaysOfWeb3#WomenInCrypto
Summary 🧵
1. Creating an account is simple - you just need to connect your wallet to @zapper_fi
2. You can gain rewards 🪙 by completing quests. There are daily, weekly and one-time quests 🧙♂️