0.0.1-alpha.3 • Published 4 years ago

@gnosis.pm/dex-pricegraph v0.0.1-alpha.3

Weekly downloads
6
License
-
Repository
-
Last release
4 years ago

Pricegraph Wasm Bindings

This crate provides WebAssembly bindings to the pricegraph crate so that it can be used from JS environments.

Usage

The Wasm bindings can be used from JavaScript or TypeScript by importing the generated NodeJS module:

import { PriceEstimator } from "@gnosis.pm/dex-pricegraph";

const estimator = new PriceEstimator(encodedOrders);
const [WETH, DAI] = [1, 7];
console.log(
    "WETH/DAI price estimate:",
    estimator.estimatePrice(WETH, DAI, 100 * 10e18),
);
esimator.free();

Building

This crate and the resulting npm package are created using wasm-pack.

To run integration tests inside a NodeJS environment:

cd pricegraph/wasm
wasm-pack test --node

To generate the pkg/ directory containing the npm package:

cd pricegraph/wasm
wasm-pack build --scope gnosis.pm --target nodejs