Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/astroport-fi/astroport-math
- Owner: astroport-fi
- License: gpl-3.0
- Created: 2023-05-18T19:39:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-08T01:40:31.000Z (about 1 year ago)
- Last Synced: 2024-04-25T05:02:43.659Z (10 months ago)
- Language: Rust
- Homepage:
- Size: 267 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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