October 22, 2020

Case Study: Uniswap (UNI Tokens Distribution)

Zainab Hasan

This case study focuses on the newly introduced UNI tokens and their process of distribution.

Uniswap:

Uniswap is a decentralize liquidity providing protocol, which operates using the liquidity pools model. A liquidity provider provides or increases the liquidity of a pool.
Liquidity pools consist of pairs of tokens, the liquidity provider provides equal amounts of both tokens on the creation of liquidity pools. Future liquidity providers do the same.
The constant market maker algorithm makes sure that the product of the pair of tokens in the liquidity pool remains constant. Uniswap uses this algorithm on its liquidity pools.

Earlier in Uniswap V1, all the liquidity pools require ETH as the base currency. To explain it briefly, If a user wants to swap currency A with currency B, users will first swap A with ETH and then ETH with currency B.
Later on, Uniswap V2 provided direct ERC20 token for ERC20 token pairings. The most popular base ERC20 tokens include DAI, USDC, WETH, and USDT.
The ratio of tokens present in the liquidity pools dictates the price of tokens.

SushiSwap:

Since its existence, Uniswap has been the most recognized Decentralized exchange for a duration of almost 18 months. Then a new entrance, named SushiSwap proved a threat to them. Although, the SushiSwap project is a forked version of Uniswap. SushiSwap gained an advantage over Uniswap by introducing protocol tokens, SUSHI.
On one hand, Uniswap provides Liquidity providers 0.30% of the fee as the reward.
On the other hand, SushiSwap provides 0.25% of the fee as a reward and the remaining 0.05% converts into SUSHI tokens. The more a liquidity provider provided liquidity, the more tokens they earned. This enabled the Liquidity providers to cast governance votes. With SUSHI tokens, a liquidity provider can still have income even after withdrawing all his tokens and/or ETH from the pools.

UNI Tokens Distribution:

Uniswap introduced its own protocol tokens called UNI tokens on the 16th of September. This announcement of UNI tokens is a response to SushiSwap. The distribution of these tokens was unique. Uniswap had the snapshot taken on the 1st of September and every address on that snapshot was eligible to claim 400 UNI tokens including the 1200 addresses that submitted failed transactions. Upon entering the market Uniswap quickly developed a price of $3 per token which held the worth of $1200 at that time.
A few days later a single UNI token reached the price of $8, making the initial 400 UNI tokens worth $3200. UNI tokens were one of the largest distributed tokens as they were distributed to around 50,000 wallets.

Distribution Ratio:

The initial supply of UNI tokens is 1 Billion. A 4-year plan will make these tokens accessible.
Uniswap UNI tokens were distributed in the ratio of

  • Community: Community members have a share of 60.00% of the UNI tokens.
  • Team: Uniswap’s team members will obtain a total of 21.51% of the UNI tokens.
  • Investors: Investors will own 17.80% of the UNI tokens.
  • Advisers: The total share of advisors will be 0.69% of the UNI tokens.

After 4 years an inflation rate of 2% per year will ensure the continued participation in place of passive UNI holders.
Historically liquidity providers, users, and SOCKS holders or redeemers can claim 15% of UNI tokens immediately by based on the snapshot. The historical liquidity providers claimed 4.9166%. 251,534 historical user addresses distributed 10.06136% evenly. 1000 UNI were claimable by each address that has either owned SOCKS or redeemed SOCKS tokens for physical socks. 0.022% is split among 220 SOCKS holders/redeemers.

Distribution Process:

The smart contract used to distribute UNI tokens among the community members is indeed smart.

Merkle Root:

The smart contracts in ethereum use the Merkle tree as the data structure. This data structure has the hash of transactions or data blocks as the leaf node. The non-leaf nodes are a hash of its own children. Starting from the bottom, every two pairs of nodes combine to form an upper node. The Merkle tree ends with a single node on top also known as the root node which is the hash of the last two remaining non-leaf nodes.

Uniswap’s Intellectual Way To Distribute UNI Tokens:

Hashes of data are easy to calculate. Uniswap had the snapshot of the data of its users i.e the wallet addresses and the swaps each address took part in. This was done using the Ethereum ETL. Uniswap configured its own node to fetch the data from the blockchain using Ethereum ETL. Uniswap collected the data of the users using the snapshot node. This enabled them to calculate the hashes ahead of the transaction. They then used these hashes to form a Merkle tree. The root node enables the accessing of all the data of the Merkle tree.

This Merkle root is entered in the MerkleDistributer smart contract of Uniswap.
When a transaction takes place, it’s hash is calculated, let’s call this hash “leaf”.

When the user claims UNI tokens, the claim function runs.

function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override {
        require(!isClaimed(index), 'MerkleDistributor: Drop already claimed.');

        // Verify the merkle proof.
        bytes32 node = keccak256(abi.encodePacked(index, account, amount));
        require(MerkleProof.verify(merkleProof, merkleRoot, node), 'MerkleDistributor: Invalid proof.');

        // Mark it claimed and send the token.
        _setClaimed(index);
        require(IERC20(token).transfer(account, amount), 'MerkleDistributor: Transfer failed.');

        emit Claimed(index, account, amount);
    }

The function above utilized the account, index, and amount of the user to first check whether the UNI tokens are claimed beforehand or not. This is done with the help of isClaimed function.

function isClaimed(uint256 index) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}

If the function returns false, the smart contract verifies whether the leaf exists in the Merkle tree or not by calling the verify function. This function returns true if the leaf is part of the Merkle tree. Then the contract sends UNI tokens and sets the value as claimed with the help of the _setClaimed function.

function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
    bytes32 computedHash = leaf;
    for (uint256 i = 0; i < proof.length; i++) { 
        bytes32 proofElement = proof[i];
        if (computedHash <= proofElement) { 
            // Hash(current computed hash + current element of the proof)
            computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
        } else { 
            // Hash(current element of the proof + current computed hash)
            computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); 
       }
    } 
    // Check if the computed hash (root) is equal to the provided root 
    return computedHash == root; 
}

The user pays the gas fee since the user is already going through with a transaction and UNI swaps give UNI tokens in the same transaction.

How did Uniswap benefit?

The intellectual way of coding the smart contract saved Uniswap from paying the amount they might have, in case they decided to separately make a transaction just to distribute tokens.
Uniswap killed two birds with one stone. Uniswap took over SushiSwap quickly. As of 30th September, with $2.13Billion locked in the protocol, Uniswap is dominating the DeFi market by holding 19.35% of the market.

Also read our Case Study: CryptoDelivery

Xord is a Blockchain development company providing Blockchain solutions to your business processes. Connect with us for your projects and free Blockchain consultation at https://xord.solutions/contact/

Share:

We develop cutting-edge products for the Web3 ecosystem supported by our extensive research on blockchain core and infrastructure.

Write-Ups
About Xord
Companies
Community
© 2023 | All Rights Reserved
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram