Skip to content

Commit 57b3da1

Browse files
committed
fix(activity): require pool recipient when resolving lending deposit token from logs
The post-confirmation receipt-log fallback matched the first outgoing ERC-20 Transfer sent from the user, which could pick an unrelated transfer (e.g. a gas-fee token) earlier in the log. Also require the recipient to be the pool (txParams.to) so it matches the actual deposit transfer. Addresses Cursor Bugbot review. TMCU-1082
1 parent 4f3bfab commit 57b3da1

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

app/util/activity-adapters/adapters/local-transaction.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,25 @@ export function mapLocalTransaction(
299299
});
300300
}
301301

302-
// Post-confirmation fallback: the outgoing Transfer log (token sent FROM the
303-
// user). Mirrors getLendingWithdrawalDestinationToken but matches on the
304-
// sender (topics[1]) instead of the recipient (topics[2]).
302+
// Post-confirmation fallback: the outgoing Transfer log for the deposit —
303+
// sent FROM the user (topics[1]) TO the pool (topics[2] === txParams.to).
304+
// Requiring the pool recipient avoids matching an unrelated outgoing
305+
// transfer from the same account (e.g. a gas-fee token) earlier in the log.
305306
const fromAddress = from.toLowerCase();
307+
const poolAddress = to.toLowerCase();
306308
const sentTokenLog = (initialTransaction.txReceipt?.logs ?? []).find(
307-
({ topics: [eventTopic, logFrom] = [] }) => {
309+
({ topics: [eventTopic, logFrom, logTo] = [] }) => {
308310
const senderAddress = logFrom
309311
? `0x${logFrom.slice(-40)}`.toLowerCase()
310312
: undefined;
313+
const recipientAddress = logTo
314+
? `0x${logTo.slice(-40)}`.toLowerCase()
315+
: undefined;
311316

312317
return (
313318
eventTopic?.toLowerCase() === environment.tokenTransferLogTopicHash &&
314-
senderAddress === fromAddress
319+
senderAddress === fromAddress &&
320+
recipientAddress === poolAddress
315321
);
316322
},
317323
);

0 commit comments

Comments
 (0)