Skip to content

Commit

Permalink
Use output token for volume on single token liquidity removals
Browse files Browse the repository at this point in the history
  • Loading branch information
cujowolf committed Sep 25, 2023
1 parent 4e28af2 commit b2660b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions projects/subgraph-basin/src/utils/Well.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export function updateWellVolumes(

let usdVolume = toDecimal(amountIn, swapToken.decimals).times(swapToken.lastPriceUSD);

// Remove liquidity one token has no input token amount to calculate volume.
if (amountIn == ZERO_BI) {
swapToken = loadToken(toToken);
usdVolume = toDecimal(amountOut.div(BigInt.fromI32(2)), swapToken.decimals).times(swapToken.lastPriceUSD);
}

// Update fromToken amounts

let volumeReserves = well.cumulativeVolumeReserves;
Expand Down

0 comments on commit b2660b1

Please sign in to comment.