We are happy to announce the release of our API for the Uniswap decentralized exchange platform. Developers and analysts use the Blocklytics Uniswap API to quickly fetch all exchange activity, including the latest Uniswap exchange prices and historical trading data.

Demo

CoinGecko uses the Blocklytics Uniswap API to power their cryptocurrency price aggregator. Go there

Docs

How Uniswap works

Uniswap is a decentralized exchange platform where users trade ether for ERC-20 tokens. Uniswap is unique because its users trade with smart contracts instead of other users.

The smart contracts hold a balance of tokens and ether to facilitate trading. This balance is supplied by Liquidity Providers, who own a portion of the exchange and its trading fees in exchange for providing the smart contract with its balance.

Factories and Exchanges

New exchanges can be created by anyone. Exchanges are created through Uniswap factories. Different factories produce exchanges with different configurations (for example, different trading fee structures).

Each exchange facilitates trades for a single, specific token. Once a factory has created an exchange for a specific token, there is no need for additional exchanges to be created for that token.

However, a token may have multiple exchanges created by multiple factories. For example, an exchange creator who wishes to deploy an exchange with a different fee structure than the exchanges already available for a given token.

Price

The price of a given token on a given exchange can be calculated as the exchange contract's token_balance divided by its ether_balance.

Prices are determined by bonding curves, meaning that prices will slip depending on the size of an order relative to the exchange's balance. For more information, read Cyrus Younessi's blog post.

Liquidity and Liquidity Tokens

Liquidity can be added and removed in return for ownership of the exchange.

When liquidity is added or removed, the exchanges price cannot change. This requires that a specific amount of ether and tokens are added or removed such that the exchange's current price is maintained.

After adding liquidity, liquidity tokens are granted to the Liquidity Provider. These tokens represent ownership of the exchange and can be redeemed for the relevant portion of the exchange's balance (at which time liquidity is removed and liquidity tokens are burned).