@gnosis.pm/dex-pricegraph
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @gnosis.pm/dex-pricegraph

Weekly Downloads

1

Version

0.0.1-alpha.3

License

none

Unpacked Size

110 kB

Total Files

6

Last publish

Collaborators

  • gnosisdex
  • fedgiac
  • alfetopito
  • anxolin
  • bh2smith
  • fleupold
  • josojo
  • nlordell
  • w3stside