Skip to content

Commit

Permalink
Merge pull request #1938 from amching/pixelswap-volume
Browse files Browse the repository at this point in the history
feat: pixelswap totalVolume and dailyVolume
  • Loading branch information
dtmkeng authored Oct 11, 2024
2 parents ecb79f3 + 15b8438 commit 1e5a204
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions dexs/pixelswap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import fetchURL from '../../utils/fetchURL'

const fetch = async () => {
const swapVolumeApiResult = await fetchURL(
'https://api.pixelswap.io/apis/pairs',
);
const depositAndWithdrawVolumeResult = await fetchURL(
'https://api.pixelswap.io/apis/tokens',
);
const swapvolumeResult = swapVolumeApiResult.data.pairs;
const depositAndWithdrawVolume = depositAndWithdrawVolumeResult.data.tokens;
let dailyVolumeResult = 0;
let totalVolumeResult = 0;
swapvolumeResult.forEach(pairs => {
dailyVolumeResult += Number(pairs.volume.dailyVolume / (Math.pow(10, Number(pairs.token1.decimals))) * pairs.token1.usdPrice);
totalVolumeResult += Number(pairs.volume.totalVolume / (Math.pow(10, Number(pairs.token1.decimals))) * pairs.token1.usdPrice);
});

depositAndWithdrawVolume.forEach(token => {
dailyVolumeResult += Number(token.volume.dailyVolume / (Math.pow(10, Number(token.decimals))) * token.usdPrice);
totalVolumeResult += Number(token.volume.totalVolume / (Math.pow(10, Number(token.decimals))) * token.usdPrice);
});

return {
dailyVolume: dailyVolumeResult,
totalVolume: totalVolumeResult,
}
}

const adapter = {
adapter: {
ton: {
fetch,
start: 1726034340,
},
},
}

export default adapter

0 comments on commit 1e5a204

Please sign in to comment.