Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
add BUFF
Browse files Browse the repository at this point in the history
  • Loading branch information
krboktv committed Feb 17, 2019
1 parent 90baa9d commit b2536ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docker rm -f $(docker ps -a -q)
docker pull neojt/mredis

docker run -p 8080:8080 -d rhombus
docker run -p 9090:9090 -d erage/buffdai

docker run -d -p 6379:6379 neojt/mredis

Expand Down
8 changes: 6 additions & 2 deletions telegram/handlers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ async function getBalances(ctx) {
const tokensTickers = Object.keys(token.supportedTokens);
const tokenAddresses = Object.values(token.supportedTokens);
const tokenBalances = await rp.getTokenBalance(tokenAddresses, user.ethereumAddress);
// const buffBalance = await rp.getTokenBalance(tokenAddresses, user.ethereumAddress);
const buffBalance = await rp.getBuffBalance(user.ethereumAddress);
const btcBalance = await rp.getBTCBalance(user.bitcoinAddress);
console.log(tokenBalances);
let msg = `*Mainnet Ethereum:* ${balanceETHMain/1e18} or ${(Number(await utils.course.convert("ETH", "USD", balanceETHMain/1e18)))}$ \n\n*Ropsten Ethereum:* ${balanceETHRopsten/1e18} or ${(Number(await utils.course.convert("ETH", "USD", balanceETHRopsten/1e18)))}$\n\n*BTC:* ${btcBalance} or ${(Number(await utils.course.convert("BTC", "USD", btcBalance)))}$\n\n*xDAI:* ${balanceXDai/1e18} or ${(Number(await utils.course.convert("XDAI", "USD", balanceXDai/1e18)))}$\n\n`;
let msg = `*Mainnet Ethereum:* ${balanceETHMain/1e18} or ${(Number(await utils.course.convert("ETH", "USD", balanceETHMain/1e18)))}$ \n\n
*Ropsten Ethereum:* ${balanceETHRopsten/1e18} or ${(Number(await utils.course.convert("ETH", "USD", balanceETHRopsten/1e18)))}$\n\n
*BTC:* ${btcBalance} or ${(Number(await utils.course.convert("BTC", "USD", btcBalance)))}$\n\n
*xDAI:* ${balanceXDai/1e18} or ${(Number(await utils.course.convert("XDAI", "USD", balanceXDai/1e18)))}$\n\n
*BUFF:* ${buffBalance} or ${Number(buffBalance)}$\n\\n`;
let counter = 0;
for (let i in tokensTickers) {
msg += `*${tokensTickers[i]}:* ${Number(tokenBalances[counter])/1e18}\n\n`;
Expand Down
7 changes: 6 additions & 1 deletion telegram/request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ async function getRhombusExchangeRate(firstCurrency, secondCurrency) {
return JSON.parse(await rp.get(`http://ethergram.tk:8080/rate/${tickers[secondCurrency][firstCurrency]}`)).rate;
}

async function getBuffBalance(userAddress) {
return JSON.parse(await rp.get(`http://localhost:9090/balance/${userAddress}`));
}

async function getBTCBalance(userAddress) {
return JSON.parse(await rp.get(`https://insight.bitpay.com/api/addr/${userAddress}`)).balance;
}

module.exports = {
getTokenBalance: getTokenBalance,
getBTCBalance: getBTCBalance,
getRhombusExchangeRate: getRhombusExchangeRate
getRhombusExchangeRate: getRhombusExchangeRate,
getBuffBalance: getBuffBalance
};

0 comments on commit b2536ed

Please sign in to comment.