Skip to content

Commit

Permalink
chore: return atomic and human readable amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
bvotteler committed Nov 22, 2023
1 parent e8fe7bd commit 9ef64aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/tvl_dex.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ const tvlDex = async (request, response) => {
);

const pools = await interbtcApi.amm.getLiquidityPools();
const currencies = pools.flatMap((pool) => pool.pooledCurrencies);
const amounts = pools.flatMap((pool) => pool.pooledCurrencies)
.map((monetaryAmount) => ({
currency: monetaryAmount.currency,
atomicAmount: monetaryAmount.toHuman(0),
amount: monetaryAmount.toHuman()
}));

return response.status(200)
.setHeader("content-type", "application/json")
.setHeader("cache-control", "public, maxage=0, s-maxage=300")
.json(currencies);
.json(amounts);
} else {
return response.status(400).send('Bad Request');
}
Expand Down

0 comments on commit 9ef64aa

Please sign in to comment.