Skip to content

Commit

Permalink
Update dailyVolume methodolgy
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinay Sagar authored and Vinay Sagar committed Sep 19, 2024
1 parent b935018 commit edc72ea
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion dexs/wefi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const address: any = {
[CHAIN.BOBA]: '0x7E0DA0DECCAc2E7B9AD06E378ee09c15B5BDeefa'
}

const stableToken: string[] = [
"0x49d3f7543335cf38fa10889ccff10207e22110b5", // xdc:FXD
"0x1ebb2c8a71a9ec59bf558886a8adf8f4a565814f", // xdc:EURS
"0x66a2a913e447d6b4bf33efbec43aaef87890fbbc", // boba:USDC
"0x176211869ca2b568f2a7d4ee941e073a821ee1ff", // linea:USDC
"0xc2132d05d31c914a87c6611c10748aeb04b58e8f", // polygon:USDT
"0x2791bca1f2de4661ed88a30c99a7a9449aa84174", // polygon:USDC
]

const fetchVolume: FetchV2 = async (options: FetchOptions) => {
const logs = await options.getLogs({
target: address[options.chain],
Expand All @@ -16,10 +25,17 @@ const fetchVolume: FetchV2 = async (options: FetchOptions) => {
const dailyVolume = options.createBalances();
logs.forEach((log: any) => {
const data = log.data.replace('0x', '')
const amountIn = Number('0x' + data.slice(5 * 64, 6 * 64))
const amountOut = Number('0x' + data.slice(6 * 64, 7 * 64))
const address = data.slice(4 * 64, 5 * 64);
const tokenInAddress = data.slice(3 * 64, 4 * 64);
const tokenIn = '0x' + tokenInAddress.slice(24, address.length);
const tokenOut = '0x' + address.slice(24, address.length);
dailyVolume.add(tokenOut, amountOut)
if(stableToken.includes(tokenOut)) {
dailyVolume.add(tokenOut, amountOut)
} else {
dailyVolume.add(tokenIn, amountIn)
}
});
return {
dailyVolume: dailyVolume,
Expand Down

0 comments on commit edc72ea

Please sign in to comment.