-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1938 from amching/pixelswap-volume
feat: pixelswap totalVolume and dailyVolume
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |