Impermanent Loss (IL) is a concept in decentralized finance (DeFi) that occurs when providing liquidity to automated market maker (AMM) pools. It refers to the temporary loss of funds experienced by liquidity providers (LPs) due to price volatility of the assets in the pool. This loss is “impermanent” because it only materializes if the LP withdraws their funds when the asset prices have changed. If the prices return to their original state, the loss disappears.
How Impermanent Loss Occurs
In an AMM pool, liquidity providers deposit pairs of tokens (e.g., ETH and USDT) into a pool. The pool uses a constant product formula (e.g. x x y = k to determine the price of the assets. When the price of one asset changes relative to the other, arbitrageurs trade in the pool to restore equilibrium, which shifts the ratio of the two assets in the pool. This shift causes LPs to end up with a different value of assets than if they had simply held the tokens.
Example of Impermanent Loss
Let’s assume a liquidity pool with two assets: ETH and USDT. The pool follows the constant product formula x x y = k , where:
x = amount of ETH in the pool
y = amount of USDT in the pool
k = constant product
Initial Conditions
– Initial price of ETH: $1,000
– You deposit 1 ETH and 1,000 USDT into the pool.
– Total value of your deposit: $2,000 (1 ETH × $1,000 + 1,000 USDT × $1).
– The pool has:
– 10 ETH
– 10,000 USDT
– Constant product k = 10 x10,000 = 100,000 .
Your share of the pool: 10% (you deposited 1 ETH and 1,000 USDT out of 10 ETH and 10,000 USDT).
—
Scenario: Price of ETH Increases to $2,000
1. Arbitrageurs Trade in the Pool:
– When the external price of ETH rises to $2,000, arbitrageurs buy ETH from the pool until the pool price matches the external price.
– The new ratio of ETH to USDT in the pool will adjust to reflect the new price.
2. New Pool Balances:
– Let the new amount of ETH in the pool be x’ and USDT be y’ .
– The constant product formula x’ x y’ = 100,000 must hold.
– The new price of ETH in the pool is y’/x’ =2,000 (since 1 ETH = 2,000 USDT).
Solving the equations:
x’ x y’ = 100,000
y’/x’ =2,000 implies y’ = 2,000x’
Substituting y’ = 2,000x’ into the constant product formula:
Canister is a fundamental computational unit that combines both code and state. It is essentially a smart contract or a container that runs on the Internet Computer blockchain. Canisters are designed to be autonomous, scalable, and interoperable, enabling developers to build decentralized applications (dApps) and services.
Key Features of a Canister:
Code and State:
Autonomous:
Canisters operate independently and can interact with other canisters or external systems via messages.
Scalable:
The Internet Computer allows canisters to scale horizontally by distributing their workload across multiple nodes in the network.
Interoperable:
Canisters can communicate with each other through message passing, enabling complex decentralized applications to be built by composing multiple canisters.
Upgradable:
Developers can update the code of a canister without losing its state, making it easier to maintain and improve applications over time.
Cycle
n the Internet Computer (ICP), a Cycle is a computational unit used to pay for the execution of smart contracts (called canisters). It functions similarly to “gas” in Ethereum but is designed to be more predictable and cost-efficient.
Key Features of Cycles in ICP:
Resource-Based Pricing – The cost of computation, storage, and network usage is measured in cycles.
Stable Pricing Model – Unlike Ethereum’s gas, the cost of cycles is tied to real-world resources (compute and storage) rather than being market-driven.
Conversion from ICP Tokens – ICP tokens can be converted into cycles to fund canister execution. The conversion rate is adjusted to maintain price stability. XDR (Special Drawing Rights) is used as a reference unit to determine the cost of converting ICP tokens to cycles in a stable manner.(1T Cycle = 1 XDR ~ USD1.321)
Canister Management – Cycles are stored within canisters and consumed as operations are performed. When a canister runs out of cycles, it stops executing until refueled.
Cycle Usage in ICP:
Computation – Each instruction executed by a canister consumes cycles.
Storage – Data stored in the canister costs cycles over time.
Inter-canister Calls – Messaging between canisters also consumes cycles.
Network Operations – Data transmission to and from the Internet Computer incurs cycle costs.
Creation of a Cycle Wallet in Local Network
To create a cycle wallet in the local network, you start the local network in a clean mode using the following command:
dfx start –background –clean
Running the following command first time to create a cycle wallet automatically with 100T cycles in local network, otherwise it will return the cycle wallet id only.
dfx identity get-wallet
The following command will return the balance in the wallet:
dfx wallet balance
Motoko-The native programming language of ICP
Motoko is a programming language specifically designed for the Internet Computer (ICP) blockchain. It is optimized for writing smart contracts (called canisters) that run directly on the ICP network.
Key Features of Motoko
Actor-Based Model – Uses the actor model to handle concurrency and asynchronous execution efficiently.
Type-Safe & Memory-Safe – Strongly typed language that prevents common programming errors.
Designed for Web3 – Integrates directly with the Internet Computer, supporting scalability, persistence, and seamless upgrades.
WebAssembly Compilation – Runs as WebAssembly (Wasm) for efficient execution on the ICP blockchain.
Interoperability – Can interact with Rust, JavaScript, and other WebAssembly languages.
Create and Deploy Canisters
Creating a canister on the Internet Computer (ICP) involves a few simple steps. Below is a basic guide:
Start local network in background
dfx start –background
Create hello world project
dfx new hello
Select a backend language, you may choose Motoko, Rust, Python or Typescript, as shown below. We choose Motoko for our illustration.
Then select a Frontend language as follows. We choose React for illustration.
Then add extra features as follows, we choose Intenet Identity:
Pressing enter to confirm will create all necessary files and install dependencies, and arrive at the start up screen as shown below. A project with the folder name hello will be created.
The project architecture is as shown below:
Deploying Canister on Local Network
To deploy the hello project you have just created on a local network, use the following command:
dfx deploy
The following screen shows successful deployment, otherwise there will be errors:
You may access the frontend URL via the link generated.
The frontend UI is as illustrated below:
Deploying Canister on the IC Mainnet
The command to deploy the canister on the IC mainnet is
dfx deploy –network ic
If the deployment on the IC blockchain is successful, the output will display the URLs of both the frontend and backend, as shown below:
The frontend URL can be accessed on the desktop browser and the browser of the mobile devices. It does not need to register a domain nor a central server to host the web app, it is fully on chain.
In this example, accessing the frontend URL with the link will display a certificate generator app, as shown below:
Obtaining Cycles
You need cycles to deploy your ICP app on the mainnet. There are two ways to obtain the cycles, one way is to redeem the coupon codes if you are given some free coupons, the other way is to buy icp tokens and convert them to cycles.
Method 1: Redeeming cycles from coupon codes
The command to redeem the cycles with coupon code is as follows:
dfx cycles redeem-faucet-coupon –network ic <COUPON_CODE>
Example: dfx cycles redeem-faucet-coupon –network ic CE3A9-BA578-CD44B
To check cycles balance in the wallet, use the following command:
dfx cycles –network ic balance
Method 2: Converting ICP tokens to cycles
First of all you must create an empty canister using ICP token using the following command:
In the previous post, you learned about the fundamental concepts of the Internet Computer Protocol (ICP), a third-generation blockchain designed to power the next evolution of the internet. At its core, ICP functions as a decentralized cloud, enabling developers to build and deploy applications entirely on-chain without relying on traditional centralized servers like AWS or Google Cloud.
You might be wondering—how is this even possible? To clear up any doubts, I will walk you through the process of creating and deploying an application on the Internet Computer. Unlike conventional web hosting, ICP allows you to launch apps without registering a domain name or provisioning a cloud server, leveraging blockchain-native web hosting for a truly decentralized experience.
Prerequisite
To start coding in IC(Internet Computer) , there are some prerequisites you need to set up or install before you can jump into developing your first app. Following are the prerequisites:
Ensure you have the supporting operating system-
Windows 10 or 11 with WSL2 installed with Ubuntu Linux v20.04
Mac OSX 12 or above
Ubuntu Linux v20.04
NodeJs v20
GitHub Account
IC SDK
Visual Studio Code IDE
Basic programming knowledge- JavaScript, CSS, HTML
Here are the references to install the or set up the prerequisites:
After installation, check its version using the command dfx –version, you should see something like dfx 0.24.3
*·If you are using a machine running Apple silicon, you will need to have Rosetta installed. You can install Rosetta by running softwareupdate –install-rosetta in your terminal.
The next step is to create an account in IC. In ICP, authentication requires a key pair consisting of a private and a public key, while the account itself is identified by a unique principal ID. Additionally, a ledger is needed to store accounts and transactions. This ledger is a smart contract known as a system canister. Each user will have a ledger account identifier, also called an account ID, which is used to hold ICP tokens. Furthermore, a wallet must be created to store cycles and facilitate sending cycles to and from canisters.
Creating ICP Account
To create an account in IC, using the following command:
dfx identity new <identity_name>
·💡Identity names must use alphanumeric characters comprising uppercase and lower letters, numbers and special characters. Example: My_chatb@t
·ℹ️Most importantly, REMEMBER to back up the 24-word account/identity seed phrase. This is essential for restoring your account if you forget your password or need to access it from another device. Additionally, you can create multiple accounts on your device.
Principal ID
Having created your account, you can obtain your principal id using the following commands:
In case you have changed your device and need to use the same account to develop ICP apps, you may import the 24-word seed phrase you have saved as a plaintext into your new development environment using the following command:
Follow the prompts to register your device . For Windows 10 user, require to use your mobile phone to scan the QR Code to store the credential information in the mobile phone. For Android device, recommend to use Google Lens to perform Passkey QR code scanning.
Note down your Internet Identity number (e.g., 12345).
ICP Account Address
To receive ICP tokens, you need an ICP account address associated with your Internet Identity. Here’s how to get it:
Once logged in, navigate to the “Accounts” section.
Plug Wallet
You may also use the Plug Wallet to store your ICP tokens. Plug wallet can be installed as a browser extension on a laptop or can be installed as a mobile app on your phone. You can download Plug Wallet using the link below.
The Network Nervous System (NNS) is the decentralized governance system aka DAO that controls and manages the Internet Computer (ICP), a blockchain-based computing platform developed by the DFINITY Foundation. The NNS is one of the most critical components of the Internet Computer, as it enables the network to operate autonomously and evolve over time through community participation.
Key Functions of the NNS
Governance:
The NNS allows ICP token holders to participate in the governance of the Internet Computer by submitting and voting on proposals.
Proposals can cover a wide range of topics, such as upgrading the protocol, adjusting network parameters, or funding ecosystem projects.
Token Economics:
The NNS manages the ICP utility token, including its minting, burning, and distribution.
It also handles the creation of cycles, which are used to pay for computation and storage on the Internet Computer.
Node Management:
The NNS oversees the addition, removal, and configuration of node machines that power the Internet Computer.
It ensures the network remains secure, scalable, and efficient.
Canister Management:
The NNS manages the lifecycle of canisters (smart contracts) on the Internet Computer, including their creation, upgrading, and deletion.
Network Upgrades:
The NNS facilitates seamless upgrades to the Internet Computer protocol without requiring hard forks or downtime.
This is achieved through a decentralized voting process.