Skip to content

Commit 962690f

Browse files
committed
fix handling of insolvent accounts with maybeCriticalAtTimestamp already set to null
1 parent c10c0b0 commit 962690f

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

src/datafetcher.ts

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ class DataFetcher {
186186
{id_gt: "${lastId}"},
187187
${onlyNegativeNetFlowrate ? '{totalNetFlowRate_lt: 0,},' : ''}
188188
{token: "${_tokenLowerCase}"},
189-
{or: [{maybeCriticalAtTimestamp_lt: "${timestamp}"}, {balanceUntilUpdatedAt_lt: "0"}]}
189+
{or: [
190+
{maybeCriticalAtTimestamp_lt: "${timestamp}"},
191+
{and: [
192+
{balanceUntilUpdatedAt_lte: "0"},
193+
{activeOutgoingStreamCount_gt: 0}
194+
]}
195+
]}
190196
]
191197
}
192198
) {
@@ -207,38 +213,6 @@ class DataFetcher {
207213
);
208214
}
209215

210-
/**
211-
* Fetches critical accounts at a specific timestamp.
212-
* @param timestamp - The timestamp to fetch critical accounts at.
213-
* @returns A promise that resolves to an array of critical accounts.
214-
*/
215-
async getCriticalAccountsAt(timestamp: number): Promise<CriticalAccount[]> {
216-
return this._queryAllPages(
217-
(lastId: string) => `{
218-
accountTokenSnapshots (first: ${MAX_ITEMS},
219-
where: {
220-
and: [
221-
{id_gt: "${lastId}"},
222-
{or: [{maybeCriticalAtTimestamp_lt: "${timestamp}"}, {balanceUntilUpdatedAt_lt: "0"}]}
223-
]
224-
}
225-
){
226-
id
227-
totalNetFlowRate
228-
totalCFANetFlowRate
229-
token {
230-
id
231-
symbol
232-
}
233-
account {
234-
id
235-
}
236-
}
237-
}`,
238-
res => res.data.data.accountTokenSnapshots,
239-
i => i
240-
);
241-
}
242216
/**
243217
* Fetches all super tokens.
244218
* @param isListed - Whether to fetch listed tokens or not.

0 commit comments

Comments
 (0)