Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fees not calculated for first account to provide liquidity on a pair #365

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/utils/returns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,16 @@ export function getMetricsForPositionWindow(positionT0: Position, positionT1: Po
positionT1 = formatPricesForEarlyTimestamps(positionT1)

// calculate ownership at ends of window, for end of window we need original LP token balance / new total supply
const t0Ownership = positionT0.liquidityTokenBalance / positionT0.liquidityTokenTotalSupply
const t1Ownership = positionT0.liquidityTokenBalance / positionT1.liquidityTokenTotalSupply
// eslint-disable-next-line eqeqeq
const t0Ownership =
positionT0.liquidityTokenTotalSupply != 0
? positionT0.liquidityTokenBalance / positionT0.liquidityTokenTotalSupply
: 0
// eslint-disable-next-line eqeqeq
const t1Ownership =
positionT1.liquidityTokenTotalSupply != 0
? positionT0.liquidityTokenBalance / positionT1.liquidityTokenTotalSupply
: 0

// get starting amounts of token0 and token1 deposited by LP
const token0_amount_t0 = t0Ownership * positionT0.reserve0
Expand Down