Returns a LATERAL subquery fragment that resolves the latest balance for
an address column on the outer query, scoped to the given token. Pass as
the first argument to .leftJoin(..., sql\TRUE`)so each outer row gets its own balance lookup in a single round trip — no in-memory LUT, no separategetMultiple` call.
The subquery is aliased latest_balance and projects a single numeric
column post_balance. Read it from the outer SELECT via postBalance.
One call per outer query. Both the subquery alias (latest_balance)
and the projected column name (post_balance) are literal strings — a
second latestBalanceJoin() in the same query would alias-collide and
Postgres would reject it. If you need two balances (e.g. different tokens
or snapshot times) on the same row, this helper needs to grow an alias
parameter — don't reach for two joins.
Project the latest_balance.post_balance column from a latestBalanceJoin
as a BigNumber, defaulting to 0 when the join produced no row.
Pair with .as("postBalance") (or whichever alias the caller wants) on
the outer SELECT.
OptionaltimeZone?: stringIANA timezone (e.g. "America/Chicago"). Aligns day boundaries and localDate output to this timezone. Defaults to "UTC".
If this is provided it provides the balance at this point in time, otherwise it defaults to the latest balance