BancorX utility
Collection of useful Javascript (Typescript) methods used for BancorX.
Install
Using Yarn:
yarn add bancorx
or using NPM:
npm install --save bancorx
Import Module
CommonJS
const bancorx = require("bancorx");
Typescript (ES6)
import * as bancorx from "bancorx";
BancorX Formula
token balance of EOS (eosio.token) in the relay: 77814.0638 EOS
token balance of BNT (bntbntbntbnt) in the relay: 429519.5539120331 BNT
The Formula:
10.0000 / (77814.0638 + 10.0000) * 429519.5539120331
55.19109809221157
const source_balance = 77814.0638
const target_balance = 429519.5539120331
const source_amount = 10
bancorx.bancorFormula(source_balance, target_balance, source_amount)
Parse Memo
const memo = bancorx.parseMemo("bnt2eoscnvrt BNT bancorc11144 CUSD", "3.17", "b1")
Relays
bancorx.relays.CUSD
Get Relay Balances
const {code, account, symbol} = bancorx.relays.CUSD;
const balance = await rpc.get_currency_balance(code, account, symbol);