RareSkills Blog

10 February 2024
7 minutes

Solana Anchor Program IDL

Solana Anchor Program IDL The IDL (Interface Definition Language) is a JSON file that describes how to interact with a Solana program. It is automatically generated by the Anchor framework.…

Read Article
09 February 2024
9 minutes

Arithmetic and Basic Types in Solana and Rust

Arithmetic and Basic Types in Solana and Rust Today we will learn how to create a Solana program that accomplishes the same things as the Solidity contract below. We will…

Read Article
08 February 2024
8 minutes

Solana Hello World (Installation and Troubleshooting)

Solana Hello World (Installation and Troubleshooting) This is a Solana hello world tutorial. We will walk you through the steps to install Solana and troubleshoot issues that may arise. If…

Read Article
30 January 2024
9 minutes

Layer 2 Calldata Gas Optimization

Layer 2 Calldata Gas Optimization Update for mid 2024 As of the Dencun upgrade, calldata optimization doesn’t have as much of an impact since the transactions on most L2s are…

Read Article
11 January 2024
4 minutes

How Chainlink Price Feeds Work

How Chainlink Price Feeds Work Chainlink price oracles are smart contracts with public view functions that return the price of a particular asset denominated in USD. Off-chain nodes collect the…

Read Article
10 January 2024
7 minutes

How Compound V3 Allocates COMP Rewards

How Compound V3 Allocates COMP Rewards Compound issues rewards in COMP tokens to lenders and borrowers in proportion to their share of a market’s lending and borrowing. The algorithm is…

Read Article
09 January 2024
4 minutes

Bulkers in Compound V3

Bulkers in Compound V3 The bulker contracts in Compound V3 are multicall-like contracts for batching several transactions. For example, if we wanted to supply Ether, LINK, and wBTC as collateral…

Read Article
08 January 2024
11 minutes

Understanding Collateral, Liquidations, and Reserves in Compound V3

Understanding Collateral, Liquidations, and Reserves in Compound V3 In this chapter we will examine the following topics about Compound V3: collateral valuation absorbing insufficiently collateralized loans (liquidations) selling absorbed collateral…

Read Article
07 January 2024
6 minutes

cUSDC V3 (Compound V3) as a non-standard Rebasing Token, CometExt.sol

cUSDC V3 (Compound V3) as a non-standard Rebasing Token, CometExt.sol The Compound V3 contract behaves like a rebasing ERC-20 token. A rebasing token is a token which has an algorithmically…

Read Article
05 January 2024
7 minutes

DeFi Interest Rate Indexes: Principal value and Present Value in Compound V3

DeFi Interest Rate Indexes: Principal value and Present Value in Compound V3 The intuitive way to track lender deposits is to record the amount of USDC they deposited and the…

Read Article
04 January 2024
6 minutes

Compound V3 Interest Per Second

Compound V3 Interest Per Second The Compound V3 protocol measures interest on the scale of seconds. The Compound V3 frontend scales the number up to years for human friendliness. When we check…

Read Article
03 January 2024
10 minutes

The Architecture of the Compound V3 Smart Contract

The Architecture of the Compound V3 Smart Contract Introduction and prerequisites Compound is one of the most significant lending protocols in DeFi, having inspired the design of nearly every lending…

Read Article
30 December 2023
11 minutes

DeFi Lending: Liquidations and Collateral

DeFi Lending: Liquidations and Collateral In TradFi, when someone defaults on a loan, the creditor has the right to seize assets or garnish wages. In DeFi, when someone defaults on…

Read Article
28 December 2023
3 minutes

The Fallback Extension Pattern

The Fallback Extension Pattern The fallback-extension pattern is a simple way to circumvent the 24kb smart contract size limit. Suppose we have functions foo() and bar() in our primary contract…

Read Article
20 December 2023
6 minutes

EIP 1967 Storage Slots for Proxies

EIP 1967 Storage Slots for Proxies EIP 1967 is a standard for where to store information that proxy contracts need to execute. Both the UUPS (Universal Upgradeable Proxy Standard) and…

Read Article
01 December 2023
7 minutes

The interest rate model of AAVE V3 and Compound V2

The interest rate model of Aave V3 and Compound V2 Interest rates in TradFi (traditional finance) are largely determined by central banks and influenced by market factors. In contrast, DeFi…

Read Article
24 November 2023
5 minutes

The second preimage attack for Merkle Trees in Solidity

The second preimage attack for Merkle Trees in Solidity The second preimage attack in Merkle trees can happen when an intermediate node in a merkle tree is presented as a…

Read Article
21 November 2023
11 minutes

The staking algorithm of Sushiswap MasterChef and Synthetix

The staking algorithm of Sushiswap MasterChef and Synthetix The MasterChef and Synthetix staking algorithms distribute a fixed reward pool among stakers according to their time-weighted contributions to a pool. To…

Read Article
14 November 2023
6 minutes

How Uniswap V2 computes the mintFee

How Uniswap V2 computes the mintFee Uniswap V2 was designed to collect 1/6th of the swap fees to the protocol. Since a swap fee is 0.3%, 1/6th of that is…

Read Article
10 November 2023
9 minutes

Uniswap v2 router code walkthrough

Uniswap v2 router code walkthrough The Router contracts provide a user-facing smart contract for safely minting and burning LP tokens (adding and removing liquidity) safely swapping pair tokens They add…

Read Article
08 November 2023
15 minutes

A comprehensive guide to the ERC 721 standard and related security issues

A comprehensive guide to the ERC 721 standard and related security issues ERC721 (or ERC-721) is the most widely used Ethereum standard for nonfungible tokens. It associates a unique number…

Read Article
07 November 2023
13 minutes

Flash Loans and how to hack them: a walk through of ERC 3156

Flash Loans and how to hack them: a walk through of ERC 3156Flash loans are loans between smart contracts that must be repaid in the same transaction. This article describes…

Read Article
06 November 2023
4 minutes

Uniswap V2 Library Code Walkthrough

Uniswap V2 Library Code Walkthrough Uniswap V2 Library The Uniswap V2 Library simplifies some interactions with pair contracts and is used heavily by the Router contracts. It contains eight functions…

Read Article
03 November 2023
10 minutes

How the TWAP Oracle in Uniswap v2 Works

  How the TWAP Oracle in Uniswap v2 Works What exactly is “price” in Uniswap? Suppose we have 1 Ether and 2,000 USDC in a pool. This implies that the…

Read Article
01 November 2023
3 minutes

Checklist for building a Uniswap V2 clone

Checklist for building a Uniswap V2 clone It’s very educational to rebuild Uniswap v2 from scratch using modern Solidity (or Huff if you really want to do it in hard…

Read Article
30 October 2023
8 minutes

Uniswap V2 Mint and Burn Functions Explained

Uniswap V2 Mint and Burn Functions Explained The lifecycle of Uniswap V2 is someone mints LP tokens (supplies liquidity, i.e. tokens to the pool) for the first time, then a…

Read Article
28 October 2023
8 minutes

Breaking Down the Uniswap V2 Swap Function

Breaking Down the Uniswap V2 Swap Function Uniswap V2’s swap function is cleverly designed, but many devs find its logic counterintuitive the first time they encounter it. This article explains…

Read Article
Load More Articles