Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Uniswap v3 Origin update - all tests passing #91

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions protocol/ethereum/uniswapv3/wrapper/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### How to add network support

In the common case, adding support for a new chain is easy.
You will need the address of the chain's WETH contract.
1. Add network to ChainId enum in `src/schema.graphql`
2. Update `_getWeth` in `src/token/utils.ts`
3. If chain has its own native token, update `_getNative`, `_isNative`, and `_wrapToken` in `src/token/utils.ts`
4. Update tests in `src/__tests__/unit/utils/tokenUtils.spec.ts`

# The Uniswap v3 Wrapper

Reference documentation for the Uniswap v3 wrapper is located at https://docs.polywrap.io/uniswapv3/intro.
Expand All @@ -8,6 +17,7 @@ Polywrap wrappers are user-friendly, secure, scalable, and infinitely composable

While the first Polywrap Client is written in JavaScript, future clients will be written for languages like Rust, Python, and Kotlin. Once written, a wrapper can be used with any Polywrap Client.


## The Polywrap Toolchain

Polywrap's core toolchain consists of a development environment for writing API's and a Client to interface with them.
Expand Down
18 changes: 0 additions & 18 deletions protocol/ethereum/uniswapv3/wrapper/meta/queries/approve.graphql

This file was deleted.

8 changes: 0 additions & 8 deletions protocol/ethereum/uniswapv3/wrapper/meta/queries/approve.json

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions protocol/ethereum/uniswapv3/wrapper/meta/queries/swap.graphql

This file was deleted.

15 changes: 0 additions & 15 deletions protocol/ethereum/uniswapv3/wrapper/meta/queries/swap.json

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions protocol/ethereum/uniswapv3/wrapper/meta/queries/toHex.json

This file was deleted.

24 changes: 9 additions & 15 deletions protocol/ethereum/uniswapv3/wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
{
"name": "uniswap-v3-wrapper",
"description": "Polywrap Uniswap V3 API",
"name": "@polywrap/uniswap-v3",
"description": "Polywrap Uniswap V3 Wasm Wrapper",
"private": true,
"version": "0.0.3",
"version": "0.3.0",
"scripts": {
"reset": "yarn clean && yarn && yarn build",
"clean": "rimraf ./node_modules ./build ./coverage ./.polywrap ./**/wrap",
"build": "polywrap build",
"deploy": "polywrap deploy",
"codegen": "polywrap codegen",
"codegen:meta": "polywrap codegen -s ./scripts/meta.ts",
"test:e2e": "jest --passWithNoTests --runInBand --verbose",
"test:unit": "asp --verbose",
"test": "yarn test:unit && yarn test:e2e",
"test:ci": "yarn test:unit && yarn test:e2e",
"lint": "yarn eslint src",
"lint:fix": "yarn eslint src --fix"
},
"dependencies": {
"as-bigfloat": "0.0.5"
},
"devDependencies": {
"@as-pect/cli": "6.2.4",
"@types/jest": "26.0.24",
Expand All @@ -29,17 +25,16 @@
"@uniswap/v3-core": "1.0.0",
"@uniswap/v3-periphery": "1.3.0",
"@uniswap/v3-sdk": "3.6.2",
"polywrap": "0.2.0",
"@polywrap/client-js": "0.2.0",
"@polywrap/test-env-js": "0.2.0",
"@polywrap/wasm-as": "0.2.0",
"assemblyscript": "0.19.20",
"polywrap": "0.3.0",
"@polywrap/client-js": "0.3.0",
"@polywrap/test-env-js": "0.3.0",
"@polywrap/wasm-as": "0.3.0",
"assemblyscript": "0.19.23",
"eslint": "7.16.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-prettier": "3.3.0",
"ethers": "5.0.7",
"ethers-solidity-plugin-js": "0.0.2",
"graphql": "16.2.0",
"graphql-request": "3.7.0",
"jest": "26.6.3",
Expand All @@ -48,7 +43,6 @@
"solc": "0.8.3",
"ts-jest": "26.5.6",
"ts-node": "8.10.2",
"typescript": "4.0.7",
"@nerfzael/wrappers": "0.2.2"
"typescript": "4.0.7"
}
}
20 changes: 0 additions & 20 deletions protocol/ethereum/uniswapv3/wrapper/scripts/meta-manifest.mustache

This file was deleted.

93 changes: 0 additions & 93 deletions protocol/ethereum/uniswapv3/wrapper/scripts/meta.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {buildWrapper} from "@polywrap/test-env-js";
import { PolywrapClient } from "@polywrap/client-js";
import {
ChainIdEnum,
Expand Down Expand Up @@ -33,9 +32,8 @@ describe("Call (mainnet fork)", () => {
// get client
const config = getPlugins();
client = new PolywrapClient(config);
// deploy api
// get uri
const wrapperAbsPath: string = path.resolve(__dirname + "/../../../");
await buildWrapper(wrapperAbsPath);
fsUri = "fs/" + wrapperAbsPath + '/build';
// set up ethers provider
ethersProvider = new ethers.providers.JsonRpcProvider("http://localhost:8546");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { buildWrapper } from "@polywrap/test-env-js";
import { PolywrapClient } from "@polywrap/client-js";
import {
ChainIdEnum, Ethereum_TxResponse, FeeAmountEnum, Token, Pool,
Expand All @@ -24,8 +23,8 @@ describe("Deploy pool (mainnet fork)", () => {
// get client
const config = getPlugins();
client = new PolywrapClient(config);
// get uri
const wrapperAbsPath: string = path.resolve(__dirname + "/../../../");
await buildWrapper(wrapperAbsPath);
fsUri = "fs/" + wrapperAbsPath + '/build';
// set up ethers provider
ethersProvider = new ethers.providers.JsonRpcProvider("http://localhost:8546");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { PolywrapClient } from "@polywrap/client-js";
import {
ChainIdEnum, FeeAmountEnum, Pool, Route, Token,
createPool, encodeSqrtRatioX96, createRoute, encodeRouteToPath,
ChainIdEnum,
FeeAmountEnum,
Pool,
Route,
Token,
createPool,
encodeSqrtRatioX96,
createRoute,
encodeRouteToPath,
getFakeTestToken,
getPlugins, initInfra, stopInfra
} from "./helpers";
import {buildWrapper} from "@polywrap/test-env-js";
import path from "path";

jest.setTimeout(120000);
Expand Down Expand Up @@ -48,12 +53,10 @@ describe('encodeRouteToPath (SDK test replication)', () => {
let fsUri: string;

beforeAll(async () => {
await initInfra();
// get client
const config = getPlugins();
client = new PolywrapClient(config);
client = new PolywrapClient();
// get uri
const wrapperAbsPath: string = path.resolve(__dirname + "/../../../");
await buildWrapper(wrapperAbsPath);
fsUri = "fs/" + wrapperAbsPath + '/build';
// set up test case data
token0 = getFakeTestToken(0);
Expand All @@ -71,10 +74,6 @@ describe('encodeRouteToPath (SDK test replication)', () => {
route_weth_0_1 = await createRoute(client, fsUri, [pool_0_weth, pool_0_1_medium], ETHER, token1);
});

afterAll(async () => {
await stopInfra();
});

it('packs them for exact input single hop', async () => {
expect(await encodeRouteToPath(client, fsUri, route_0_1, false)).toEqual(
'0x0000000000000000000000000000000000000001000bb80000000000000000000000000000000000000002'
Expand Down
Loading