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

Add / Pending balance delta threshold #1100

Open
wants to merge 3 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
15 changes: 14 additions & 1 deletion src/libs/portfolio/pendingAmountsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ export const calculatePendingAmounts = (
activityNonce?: bigint,
portfolioNonce?: bigint
): PendingAmounts | null => {
const latestPendingDelta = pendingAmount - latestAmount
let latestPendingDelta = pendingAmount - latestAmount

// Check if the change in latestPendingDelta is significant (>= 10000n or <= -10000n).
// This helps to avoid processing insignificant changes in the pending balance.
// This is important for handling tokens with pending balances, such as those deposited into AAVE.
// With AAVE each block generates a small amount of interest or rewards,
// which is constantly displaying on dashboard as pending to be confirmed.
// The percentage change helps determine if the change in pending balance is significant enough to consider.
const significantChange = latestPendingDelta >= 10000n || latestPendingDelta <= -10000n

// Ignore changes without significant difference
if (!significantChange) {
latestPendingDelta = 0n
}

// There is no Pending state changes
if (latestPendingDelta === 0n && !simulationDelta) return null
Expand Down
Loading