
Positions in Uniswap v3
Positions in Uniswap v3 Adding liquidity to an AMM means depositing tokens into the AMM pool. Liquidity providers do this in the hope of earning fees from users who swap…

NTT Algorithm By Hand
NTT Algorithm By Hand The NTT (Number Theoretic Transform) algorithm converts a polynomial in a finite field from coefficient form to point form. If a polynomial has degree $d$ then…

Roots of Unity raised to the k/2 power equals 1 or -1
Roots of Unity raised to the k/2 power equals 1 or -1 Any $k$-th root of unity with even $k$ raised to the $k/2$ power will result in 1 or…

Evaluating multivalued functions by square root expansion
Evaluating multivalued functions by square root expansion In the previous chapter on Image Preservation of Multivalued Functions we saw that instead of evaluating $f(x)$ on the $k$-th roots of unity,…

The Image Preservation Theorem for Multivalued Functions
The Image Preservation Theorem for Multivalued Functions We’ll start this chapter on an unusual note — the NTT algorithm is quite simple and can be implemented in less than 20…

Square Roots of Roots of Unity
Square Roots of Roots of Unity The square root of a number $x$ is $y$ such that $y^2=x$. When $x$ is of the form $x^m$ and $m$ is even, then…

The square of a k-th root of unity is a k/2-th root of unity
The square of a k-th root of unity is a k/2-th root of unity If we take the set of $k$-th roots of unity (with $k$ even) and square each…

Visual representation of the roots of unity
Visual representation of the roots of unity The property that if $\omega$ is a $k$-th root of unity, then $\omega^i$ and $\omega^{i+k/2}$ are additive inverses may seem a little abstract…

Roots of unity ω have the property ω^(k/2) ≡ −1
Roots of unity ω have the property ω^(k/2) ≡ −1 In previous articles, we established that in the finite field $\mathbb{F}_q$, if $k$ divides $q-1$: There exists a unique subgroup…

Vandermonde Matrices
Vandermonde Matrices A Vandermonde matrix is a matrix that converts a polynomial from its coefficient representation into its value representation at a set of points. For a polynomial $f(x) = a_0 +a_1x + a_2x^2+\dots+a_{k-1}x^{k-1}$ with its…

Roots of Unity in Finite Fields
Roots of Unity in Finite Fields This article explains what Roots of Unity in a Finite Field are and how they are intertwined with multiplicative subgroups. The reader is expected…

Interest Bearing Token Part 2
Interest Bearing Token Part 2The interest-bearing extension adds the ability for a token mint to accrue interest over time. In our previous discussion of Token-2022, we introduced the interest-bearing extension…

Interest Bearing Token Part 1
Interest Bearing Token Part 1The Token-2022 interest-bearing extension enables a token mint to automatically accrue interest on all token accounts for that specific mint. It uses an annual rate defined…

Ed25519 Signature Verification in Solana
Ed25519 Signature Verification in Solana Verifying Ed25519 Signatures in Solana Anchor Programs This tutorial shows how to verify an off-chain Ed25519 signature in a Solana program. In Solana, custom programs…

Solana Instruction Introspection
Solana Instruction Introspection Instruction introspection enables a Solana program to read an instruction other than its own within the same transaction. Normally, a program can only read the instruction targeted…

Multiplication of Polynomials in Point Form
Multiplication of Polynomials in Point Form Polynomial multiplication is widely used in zero-knowledge proofs and mathematical cryptography. But the brute force or traditional approach for multiplying polynomials runs in $\mathcal{O}(n^2)$,…

The Solana Token 2022 Specification
The Solana Token 2022 Specification Token-2022 is a new backward-compatible version of the SPL Token program that supports additional features in the form of extensions. The bytecode for these extensions…

Time Travel Testing with LiteSVM
Time Travel Testing with LiteSVM In Solana, writing test cases that depend on the passing of time is tricky. We might want to test that something happens in our code…

Implementing Token Metadata with Metaplex
Implementing Token Metadata with Metaplex We introduced the Metaplex metadata standard in the previous tutorial. In this one, we’ll create an SPL token and attach metadata to it using the…

How Metaplex Metadata for Tokens Works
How Metaplex Metadata for Tokens Works We have deployed and interacted with SPL tokens, but none of them had a name, symbol, or any metadata attached. Instead, we identified each…

Basic Bank Tutorial
Basic Bank Tutorial with SPL Tokens and Anchor In this tutorial, we’ll build a simple bank program on Solana with the basic features you’d expect from a regular bank. Users…

Token Sale with Total Supply Tutorial
Token Sale with Total Supply Tutorial A token sale program is a smart contract that sells a specific token, usually in exchange for a native token like SOL, at a…

Transferring SPL Tokens with Anchor and Web3.js
Transferring SPL Tokens with Anchor and Web3.js In the previous tutorial, we learned how SPL tokens work. In this tutorial, we’ll implement a full SPL token lifecycle: create, mint, transfer,…

How the SPL Token Works
How the SPL Token Works Solana Program Library Token (SPL Token) is Solana’s standard for tokens: how to create tokens and how they should behave. It is Solana’s equivalent to…

Calculating the real reserves between two prices in the Uniswap V3 codebase
Calculating the real reserves between two prices in the Uniswap V3 codebase In previous chapters, we derived formulas to calculate the real reserves of tokens X and Y between two…

The Fundamental Theorem of Finite Cyclic Groups
The Fundamental Theorem of Finite Cyclic Groups The Fundamental Theorem of Cyclic Groups provides guarantees about the existence of cyclic subgroups within a cyclic group. In the context of the…

The constant product formula in Uniswap v3
The constant product formula in Uniswap v3 Our goal is to derive the constant product formula based on real reserves for a segment, given by $$ L^2 = (x_r+\frac{L}{\sqrt{p_u}})(y_r+L\sqrt{p_l})$$ and…














