Skip to content

Commit

Permalink
fix(balancewk): find converted balance
Browse files Browse the repository at this point in the history
  • Loading branch information
guimroque committed Feb 23, 2024
1 parent b95fc9f commit c382eb6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/modules/workspace/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,18 @@ export class WorkspaceController {
return _balance;
});

const convert = `ETH-USD`;

const priceUSD: number = await axios
.get(
'https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=BTC,USD,EUR',
)
.get(`https://economia.awesomeapi.com.br/last/${convert}`)
.then(({ data }) => {
console.log('[WORKSPACE_REQUEST_BALANCE]: ', data, data.USD);
return data.USD;
return data[convert.replace('-', '')].bid ?? 0.0;
})
.catch(e => {
console.log('[WORKSPACE_REQUEST_BALANCE_ERROR]: ', e);
return 0.0;
});

console.log('[BALANCE]: ', {
balance: balance.format().toString(),
balanceUSD: balance.mul(bn(priceUSD)).format().toString(),
});

return successful(
{
balance: balance.format().toString(),
Expand Down

0 comments on commit c382eb6

Please sign in to comment.