@astroport/math
Version:
A collection of math functions extractde from Astroport smart contracts to be used with WASM in TypeScript/NodeJS.
47 lines (36 loc) • 1.21 kB
Markdown
[![NPM version][npm-image]][npm-url]
[![Build][github-build]][github-build-url]
![npm-typescript]
[![License][github-license]][github-license-url]
A collection of math functions extracted from Astroport smart contracts to be used with WASM in TypeScript/NodeJS.
```bash
make build
```
```bash
make run-tests
```
```typescript
import { xyk_swap } from '@astroport/math';
const swap = JSON.parse(xyk_swap(
"1000000",
"0",
JSON.stringify(["1000000000", "1000000000000"]),
"0.003"
));
// {
// "return_amount": "999999",
// "spread_amount": "1",
// "commission_amount": "32"
// }
```
[]: https://www.npmjs.com/package/@astroport/math
[]: https://img.shields.io/npm/v/@astroport/math
[]: https://img.shields.io/npm/types/@astroport/math
[]: https://img.shields.io/github/license/astroport-fi/astroport-math
[]: https://github.com/astroport-fi/astroport-math/blob/main/LICENSE
[]: https://github.com/astroport-fi/astroport-math/actions/workflows/publish.yml/badge.svg
[]: https://github.com/astroport-fi/astroport-math/actions/workflows/publish.yml