Skip to content

Commit f80e074

Browse files
committed
fix(explorer): preserve unrelated propAMM transfers
1 parent e75a2db commit f80e074

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

apps/explorer/src/lib/domain/known-events.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,13 +2533,15 @@ export function parseKnownEvents(
25332533
// settlement transfers so the receipt shows one swap summary instead.
25342534
for (const trade of dedupedEvents) {
25352535
if (trade.topics[0]?.toLowerCase() !== propAmmTradeSelector) continue
2536-
const { taker, tokenIn, tokenOut, amountIn, amountOut } = trade.args as {
2537-
taker: Address.Address
2538-
tokenIn: Address.Address
2539-
tokenOut: Address.Address
2540-
amountIn: bigint
2541-
amountOut: bigint
2542-
}
2536+
const { taker, recipient, tokenIn, tokenOut, amountIn, amountOut } =
2537+
trade.args as {
2538+
taker: Address.Address
2539+
recipient: Address.Address
2540+
tokenIn: Address.Address
2541+
tokenOut: Address.Address
2542+
amountIn: bigint
2543+
amountOut: bigint
2544+
}
25432545
for (const { event, index } of transferEvents) {
25442546
const { from, to, amount } = event.args
25452547
const isInput =
@@ -2550,6 +2552,7 @@ export function parseKnownEvents(
25502552
const isOutput =
25512553
Address.isEqual(event.address, tokenOut) &&
25522554
Address.isEqual(from, trade.address) &&
2555+
Address.isEqual(to, recipient) &&
25532556
amount === amountOut
25542557
if (isInput || isOutput) swapIndices.add(index)
25552558
}

apps/explorer/test/known-events.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const ZONE_E_PORTAL = '0x59831A17340EE14FE136d751EfbeA8b630470fD2' as const
4040
const UNKNOWN_ZONE_PORTAL = `0x${'8'.repeat(40)}` as const
4141
const PROP_AMM_POOL = `0x${'7'.repeat(40)}` as const
4242
const PROP_AMM_OUTPUT_TOKEN = `0x${'6'.repeat(40)}` as const
43+
const UNRELATED_RECIPIENT = `0x${'4'.repeat(40)}` as const
4344

4445
const bounceBackAbi = [
4546
{
@@ -852,7 +853,7 @@ describe('parseKnownEvents', () => {
852853
}
853854
})
854855

855-
it('composes a propAMM swap and hides its settlement transfers', () => {
856+
it('composes a propAMM swap and hides only its settlement transfers', () => {
856857
const hash = `0x${'5'.repeat(64)}` as const
857858
const amountIn = 10_000n
858859
const amountOut = 11_449n
@@ -899,14 +900,25 @@ describe('parseKnownEvents', () => {
899900
recipientAddress,
900901
amountOut,
901902
),
903+
transferLog(
904+
PROP_AMM_OUTPUT_TOKEN,
905+
PROP_AMM_POOL,
906+
UNRELATED_RECIPIENT,
907+
amountOut,
908+
),
902909
tradeLog,
903910
],
904911
accountAddress,
905912
hash,
906913
),
907914
)
908915

909-
expect(events).toEqual([
916+
expect(events).toHaveLength(2)
917+
expect(events[0]).toMatchObject({
918+
type: 'send',
919+
meta: { from: PROP_AMM_POOL, to: UNRELATED_RECIPIENT },
920+
})
921+
expect(events.slice(-1)).toEqual([
910922
{
911923
type: 'propamm swap',
912924
parts: [

0 commit comments

Comments
 (0)