Skip to content

feat: identify eth deposits - #405

Open
amateima wants to merge 2 commits into
masterfrom
amatei/acx-2136-identify-eth-weth-swap
Open

feat: identify eth deposits#405
amateima wants to merge 2 commits into
masterfrom
amatei/acx-2136-identify-eth-weth-swap

Conversation

@amateima

Copy link
Copy Markdown
Collaborator

No description provided.

@linear

linear Bot commented May 13, 2024

Copy link
Copy Markdown

@amateima
amateima requested a review from dohaki May 13, 2024 11:59

@dohaki dohaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few questions and remarks

Comment on lines +1 to +37
import { BigNumber, Event } from "ethers";

export interface WethDepositEvent extends Event {
args: [string, BigNumber] & {
dst: string;
wad: BigNumber;
};
}

export interface WethDepositEventOptimism extends Event {
args: [string, BigNumber] & {
dst: string;
wad: BigNumber;
};
}

export interface WethDepositEventLinea extends Event {
args: [string, BigNumber] & {
dst: string;
wad: BigNumber;
};
}

export interface WethDepositEventBase extends Event {
args: [string, BigNumber] & {
dst: string;
wad: BigNumber;
};
}

export interface WethTransfetEventArbitrum extends Event {
args: [string, string, BigNumber] & {
from: string;
to: string;
value: BigNumber;
};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we need duplicated events for different chains? AFAICT only on Arbitrum the respective event is different. But can't we just reuse the Deposit event signature for every other chain? This would also decrease the number of else if cases in the code

Comment thread src/modules/web3/model/weth-events.ts Outdated
};
}

export interface WethTransfetEventArbitrum extends Event {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface WethTransfetEventArbitrum extends Event {
export interface WethTransferEventArbitrum extends Event {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a different ABI file for every chain if they are the same, no?

@amateima amateima May 13, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the ABIs are not the same and I didn't want to spend time putting together a common ABI file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm okay, got you.. Maybe we could also just reduce the ABI to the minimal interfaces with need / care about, i.e.

  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "name": "dst",
        "type": "address"
      },
      {
        "indexed": false,
        "name": "wad",
        "type": "uint256"
      }
    ],
    "name": "Deposit",
    "type": "event"
  },

Comment on lines +291 to +295
return (
e.logIndex < depositEvent.logIndex &&
typedEvent.args.value.eq(depositEvent.args.inputAmount) &&
spokePoolAddresses.includes(typedEvent.args.to)
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to also add the check

typedEvent.args.from === ZERO_ADDRESS

? So that we don't consider a normal WETH transfer but rather a "deposit", i.e. mint.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spokePoolAddresses.includes(typedEvent.args.to) checks if the recipient of WETH is the SpokePool contract. Do you think it's necessary to also check from address? I cannot see a case when someone sends WETH intentionally to the SpokePool followed by a deposit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, you are right. Should be very unlikely

@amateima
amateima force-pushed the amatei/acx-2136-identify-eth-weth-swap branch from e653e79 to 32954f0 Compare May 13, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants