Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Collection of useful Javascript (Typescript) methods used for BancorX.
Wallet (Lynx/Scatter, etc...)
transfer
actions are not included.
Using Yarn:
yarn add bancorx
or using NPM:
npm install --save bancorx
CommonJS
const bancorx = require("bancorx");
Typescript (ES6)
import * as bancorx from "bancorx";
symbol | code | account | precision |
---|---|---|---|
EOS | eosio.token | bnt2eoscnvrt | 4 |
BNT | bntbntbntbnt | bnt2eoscnvrt | 10 |
ZOS | zosdiscounts | bancorc11151 | 4 |
IQ | everipediaiq | bancorc11123 | 3 |
PGL | prospectorsg | bancorc11113 | 4 |
CUSD | stablecarbon | bancorc11144 | 2 |
DICE | betdicetoken | bancorc11125 | 2 |
BLACK | eosblackteam | bancorc11111 | 4 |
CET | eosiochaince | bancorc11114 | 4 |
EPRA | epraofficial | bancorc11124 | 4 |
MEETONE | eosiomeetone | bancorc11122 | 4 |
ZKS | zkstokensr4u | bancorc11142 | 0 |
OCT | octtothemoon | bancorc11132 | 4 |
KARMA | therealkarma | bancorc11112 | 4 |
HVT | hirevibeshvt | bancorc11131 | 4 |
HORUS | horustokenio | bancorc11121 | 4 |
MEV | eosvegascoin | bancorc11134 | 4 |
SENSE | sensegenesis | bnr512553153 | 4 |
USDT | tethertether | bancorc11232 | 4 |
eosjs
is required to use get_currency_balance
method.
const {code, account, symbol} = bancorx.relays.CUSD;
const balance = await rpc.get_currency_balance(code, account, symbol);
// => [ '24874.22 CUSD' ]
Bancor Formula
Formula:
1.0000 / (77814.0638 + 1.0000) * 429519.5539120331
// => 5.519748143058556
balanceFrom
Asset from token balance in the relaybalanceTo
Asset to token balance in the relayamount
Asset amount to convertconst balanceFrom = split(`77814.0638 EOS`)
const balanceTo = split(`429519.5539120331 BNT`)
const amount = split(`1.0000 EOS`)
bancorx.calculateReturn(balanceFrom, balanceTo, amount)
// => 5.519748143058556
Returns Asset computed amount
Bancor Inverse Formula
Inverse Formula:
77814.0638 / (1.0 - 1 / 429519.5539120331) - 77814.0638
// => 0.18116577989712823
balanceFrom
Asset from token balance in the relaybalanceTo
Asset to token balance in the relayamountDesired
Asset amount to desiredconst balanceFrom = split(`77814.0638 EOS`)
const balanceTo = split(`429519.5539120331 BNT`)
const amountDesired = split(`1.0000 EOS`)
bancorx.calculateCost(balanceFrom, balanceTo, amountDesired)
// => 0.18116577989712823
Returns Asset computed desired amount
Parse Memo
converters
Array<Converter> relay convertersminReturn
number minimum returndestAccount
string destination acccountversion
number bancor protocol version (optional, default 1
)const CUSD = bancorx.relays.CUSD;
const BNT = bancorx.relays.BNT;
// Single converter (BNT => CUSD)
bancorx.composeMemo([CUSD], "3.17", "<account>")
// => "1,bancorc11144 CUSD,3.17,<account>"
// Multi converter (EOS => BNT => CUSD)
bancorx.composeMemo([BNT, CUSD], "3.17", "<account>")
// => "1,bnt2eoscnvrt BNT bancorc11144 CUSD,3.17,<account>"
Returns string computed memo
Parse Balance
bancorx.parseBalance("10.0000 EOS") // => {quantity: 10.0, symbol: "EOS"}
bancorx.parseBalance(10.0) // => {quantity: 10.0}
Returns Object parsed balance
Relays
bancorx.relays.BNT
// => { code: "bntbntbntbnt", account: "bnt2eoscnvrt", symbol: "BNT", precision: 10 }
bancorx.relays.CUSD
// => { code: "stablecarbon", account: "bancorc11144", symbol: "CUSD", precision: 2 }
FAQs
BancorX Utility
The npm package bancorx receives a total of 24 weekly downloads. As such, bancorx popularity was classified as not popular.
We found that bancorx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.