Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/astroport-fi/astroport-math

A collection of math functions extracted from Astroport smart contracts to be used with WASM in TypeScript/NodeJS.
https://github.com/astroport-fi/astroport-math

Last synced: 3 months ago
JSON representation

A collection of math functions extracted from Astroport smart contracts to be used with WASM in TypeScript/NodeJS.

Awesome Lists containing this project

README

        

# Astroport Math

[![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.

## Generate WASM

```bash
make build
```

## Run tests

```bash
make run-tests
```

## Usage

```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"
// }
```

[npm-url]: https://www.npmjs.com/package/@astroport/math
[npm-image]: https://img.shields.io/npm/v/@astroport/math
[npm-typescript]: https://img.shields.io/npm/types/@astroport/math
[github-license]: https://img.shields.io/github/license/astroport-fi/astroport-math
[github-license-url]: https://github.com/astroport-fi/astroport-math/blob/main/LICENSE
[github-build]: https://github.com/astroport-fi/astroport-math/actions/workflows/publish.yml/badge.svg
[github-build-url]: https://github.com/astroport-fi/astroport-math/actions/workflows/publish.yml