Hi @shoom3301 and @Sov,
I’ve been looking at the bridging package in cow-sdk and wanted to check scope before writing up a full application.
packages/bridging/src/providers/across/getDepositParams.ts matches CoW Trade events to Across FundsDeposited events by position: the i-th trade is paired with the i-th deposit event. The FIXME comment added in #560 already flags this as a known risk (“There might be different count of cowTradeEvents and depositEvents… might not find a depositEvent”), and it’s still unresolved as of the current main branch.
I built a small repro with mocked events to see what happens when the counts diverge: trades [A, B, C] with deposits [dB=100, dC=200] resolves order B to 200 (wrong, should be 100) and order C to null (should be 200). So it’s not just a missing-match case it can silently return the wrong deposit for a different order.
I also checked a real settlement on Arbitrum to see if this divergence happens in production, not just in theory: a transaction with 2 CoW Trade events had only 1 decodable deposit-style event in the same tx. I didn’t fully decode that event so I can’t say for certain it’s an Across FundsDeposited, but the event count mismatch itself is real and matches exactly what the FIXME warns about.
I saw #810 and #847 already attempted a fix in this area and were closed without merging; #847’s own notes say Across’s proposed approach (setting swapTokenAmount to 0) doesn’t fully work and leaves surplus stuck in the proxy. I also checked the currently open Across PRs (#992, #983, #1000) to make sure I wasn’t about to duplicate something; none of them touch getDepositParams.ts, so this specific pairing bug looks untouched.
Before I scope a full application: is this something you’d want fixed as an external contribution? My instinct for a minimal fix is to match deposits to trades by content (depositor/recipient/amount) instead of position, or at minimum fail closed (return null instead of a wrong deposit) when the counts don’t line up safely, rather than redoing #847’s swapTokenAmount approach. Open to whatever direction you’d actually want here.
Thanks,
Naina
GitHub: Naina9760