npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hexcrypto/exchange-wrappers

v0.6.0

Published

Uniswap Exchange Wrapper and order mapper for use with the hex-dex exchange

Downloads

5

Readme

Uniswap Exchange Wrapper

Exchange wrapper for connecting hYhX contracts to Uniswap Exchange on-chain.

Testing

Tests fork mainnet contracts for use locally. This makes testing already deployed contracts and infrastructure against new contracts locally incredibly easy.

Setup for this is done in the test/helpers/setup.ts file.

Tests use jest and ethers along with the local blockchain setup in the setup.ts file. Typescript preprocessing for tests is done using ts-jest.

To run tests simply run yarn test

For development, yarn test:watch will watch contract and tests for changes and rerun the tests.

Test configuration files can be found at:

  • jest.config.js (basic configuration for jest and typescript)
  • jest.setup.js (adds a longer timeout to tests)

Linting

Relevant linting files can be found at the following locations:

  • .eslintrs.js
  • .pretierrc.js
  • tsconfig.json

Smart Contracts

Linting is done using ethlint.

Run yarn lint:sol to lint the contracts.

Typescript

Linting is performed through eslint along with prettier. Typescript is linted though plugins for eslint. See package.json for more info on plugins.

Building the Contracts

Contract compilation is done using waffle. Waffle is not used for tests.

To compile, simply run yarn compile:sol.

For a nice development flow, yarn compile:sol:watch can be used for automatic recompiling.

Deploying Contracts

Ensure that the correct .env variables are set before deploying. See .env.example for details.

Deployed contracts are saved to deployments.json at the root of the repo. This is committed to source.

The GAS_PRICE_GWEI .env variable is optional. If it is not supplied, an estimate will be fetched from the network. This is NOT recommended when deploying to mainnet.

For a list of already deployed contracts, see deployments.json at the root of the repo.

Private Network (dev AKA ganache)

For testing migrations locally, a local blockchain forked off of mainnet can be used:

yarn start:devchain

Deployment can then be run using:

yarn deploy:contracts

Public Networks (mainnet, kovan, etc.)

Simply run:

yarn deploy:contracts

Everything should work fine as long as .env vars were set correctly.

Contract Layout

Contract directory is as follows:

contracts
├── exchange-wrappers
│   ├── TestExchangeWrapper.sol
│   └── UniswapV2ExchangeWrapper.sol
├── external
│   ├── README.md
│   └── uniswap
│       ├── IUniswapV2Factory.sol
│       ├── IUniswapV2Pair.sol
│       ├── IUniswapV2Router01.sol
│       └── UniswapV2Library.sol
├── interfaces
│   ├── ExchangeReader.sol
│   └── ExchangeWrapper.sol
└── lib
    ├── GeneralERC20.sol
    └── TokenInteract.sol

base

The main contract is UniswapV2ExchangeWrapper.sol. This is the contract which acts as the connector between the hYhX contracts and Uniswap. A test exchange wrapper named TestExchangeWrapper.sol has been included for later testing purposes.

external

This directory contains libraries and interfaces relating to external projects (namely Uniswap). These are used for interaction with Uniswap from the exchange wrapper named UniswapV2ExchangeWrapper.sol.

interfaces

These contracts are contracts specifically relating to interfacing with hYhX contracts.

lib

These are miscellaneous libraries which are used by UniswapV2ExchangeWrapper at some point in its dependency graph.

Javascript package

This is used in order to convert orderData specific to either TestExchangeWrapper or UniswapV2ExchangeWrapper into bytes which can be used with the smart contract.

It makes creating this bytes orderData a more straightforward ordeal.

Legal

All Rights Reserved