Skip to main content

Uniswap v2 Polywrap Documentation

Overview#

Welcome to the Uniswap v2 Polywrap documentation!

If you haven't seen our demo yet, please take a look at it first!

Uniswap v2 Polywrapper Demo

The Uniswap Polywrap is written in AssemblyScript, and like the official Uniswap SDK, it has a robust test suite, performs arbitrary precision arithmetic, and supports rounding to significant digits or fixed decimal places. The Uniswap Polywrap business logic will be deployed on a decentralized endpoint, like IPFS.

Our first Polywrap client is for JavaScript(@web3api/client-js) and it can run in any environment that can execute JavaScript. In the future, we'll have Polywrap clients for other environments (Python, Go, and more).

Developers integrating the Uniswap Polywrap into their app would use GraphQL queries to execute functions provided by the Uniswap Polywrap. This documentation shows you which query and mutation functions are made available by the Uniswap Polywrap and how to use them.

Uniswap Polywrap vs. Existing SDK#

The Uniswap Polywrap aims to be a substantial improvement over Uniswap v2โ€™s existing SDK.

While the official SDK bundles all classes (e.g. Token), necessary data fields, and helper functions into the application, the Uniswap Polywrap does not. Instead, all business logic is deployed on a decentralized endpoint, like IPFS, and is downloaded at runtime when the client application launches.

You can learn more about the benefits of using Polywrap here.

Usage#

We've created an interactive tutorial that can help you get started using the Uniswap wrapper here.

In general, to use any Polywrap in your dapp, all you need is the Polywrap Client.

npm install --save @web3api/client-js

The Polywrap JavaScript Client works in both Node.js and browser applications.

Then, initialize the client.

import { Web3ApiClient } from '@web3api/client-js';
const client = new Web3ApiClient();

Now, you're able to send queries to the Uniswap v2 Polywrap!

client.query({
uri: 'ens/v2.uniswap.web3api.eth',
query: `{
tokenEquals(
token: ${token}
other: ${other}
)
}`,
});

Take a look at more sophisticated tooling, such as our useWeb3ApiQuery hook, in our Create a JS dApp guide.

Code#

The Pre-alpha source code is available on GitHub.