Skip to content

Commit

Permalink
chore: fully migrate to new atomic depositor (#2087)
Browse files Browse the repository at this point in the history
* chore: fully migrate to new atomic depositor

Signed-off-by: bennett <[email protected]>

* remove abi

Signed-off-by: bennett <[email protected]>

---------

Signed-off-by: bennett <[email protected]>
  • Loading branch information
bmzig authored Feb 17, 2025
1 parent ed44a28 commit 54571d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 108 deletions.
47 changes: 13 additions & 34 deletions src/adapter/bridges/OpStackWethBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import WETH_ABI from "../../common/abi/Weth.json";
export class OpStackWethBridge extends BaseBridgeAdapter {
protected atomicDepositor: Contract;
protected l2Weth: Contract;
private useLegacyAtomicDepositor: boolean;
private readonly hubPoolAddress: string;

private readonly l2Gas = 200000;
Expand All @@ -33,17 +32,13 @@ export class OpStackWethBridge extends BaseBridgeAdapter {
) {
// Lint Appeasement
_l1Token;
const useLegacyAtomicDepositor = (process.env.LEGACY_ATOMIC_DEPOSITOR_CHAINS ?? []).includes(String(l2chainId));
const gateway = useLegacyAtomicDepositor
? CONTRACT_ADDRESSES[hubChainId].legacyAtomicDepositor.address
: CONTRACT_ADDRESSES[hubChainId].atomicDepositor.address;
super(
l2chainId,
hubChainId,
l1Signer,
l2SignerOrProvider,
// To keep existing logic, we should use atomic depositor as the l1 bridge
[gateway]
[CONTRACT_ADDRESSES[hubChainId].atomicDepositor.address]
);

const { address: l1Address, abi: l1Abi } = CONTRACT_ADDRESSES[hubChainId][`ovmStandardBridge_${l2chainId}`];
Expand All @@ -52,19 +47,11 @@ export class OpStackWethBridge extends BaseBridgeAdapter {
const { address: l2Address, abi: l2Abi } = CONTRACT_ADDRESSES[l2chainId].ovmStandardBridge;
this.l2Bridge = new Contract(l2Address, l2Abi, l2SignerOrProvider);

if (useLegacyAtomicDepositor) {
const { address: atomicDepositorAddress, abi: atomicDepositorAbi } =
CONTRACT_ADDRESSES[hubChainId].legacyAtomicDepositor;
this.atomicDepositor = new Contract(atomicDepositorAddress, atomicDepositorAbi, l1Signer);
} else {
const { address: atomicDepositorAddress, abi: atomicDepositorAbi } =
CONTRACT_ADDRESSES[hubChainId].atomicDepositor;
this.atomicDepositor = new Contract(atomicDepositorAddress, atomicDepositorAbi, l1Signer);
}
const { address: atomicDepositorAddress, abi: atomicDepositorAbi } = CONTRACT_ADDRESSES[hubChainId].atomicDepositor;
this.atomicDepositor = new Contract(atomicDepositorAddress, atomicDepositorAbi, l1Signer);

this.l2Weth = new Contract(TOKEN_SYMBOLS_MAP.WETH.addresses[l2chainId], WETH_ABI, l2SignerOrProvider);
this.hubPoolAddress = CONTRACT_ADDRESSES[this.hubChainId]?.hubPool?.address;
this.useLegacyAtomicDepositor = useLegacyAtomicDepositor;
}

async constructL1ToL2Txn(
Expand All @@ -73,24 +60,16 @@ export class OpStackWethBridge extends BaseBridgeAdapter {
l2Token: string,
amount: BigNumber
): Promise<BridgeTransactionDetails> {
if (this.useLegacyAtomicDepositor) {
return Promise.resolve({
contract: this.atomicDepositor,
method: "bridgeWethToOvm",
args: [toAddress, amount, this.l2Gas, this.l2chainId],
});
} else {
const bridgeCalldata = this.getL1Bridge().interface.encodeFunctionData("depositETHTo", [
toAddress,
this.l2Gas,
"0x",
]);
return Promise.resolve({
contract: this.atomicDepositor,
method: "bridgeWeth",
args: [this.l2chainId, amount, amount, bnZero, bridgeCalldata],
});
}
const bridgeCalldata = this.getL1Bridge().interface.encodeFunctionData("depositETHTo", [
toAddress,
this.l2Gas,
"0x",
]);
return Promise.resolve({
contract: this.atomicDepositor,
method: "bridgeWeth",
args: [this.l2chainId, amount, amount, bnZero, bridgeCalldata],
});
}

private convertEventListToBridgeEvents(events: Log[]): BridgeEvents {
Expand Down
5 changes: 0 additions & 5 deletions src/common/ContractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CHAIN_IDs } from "../utils";
import CCTP_MESSAGE_TRANSMITTER_ABI from "./abi/CctpMessageTransmitter.json";
import CCTP_TOKEN_MESSENGER_ABI from "./abi/CctpTokenMessenger.json";
import ATOMIC_DEPOSITOR_ABI from "./abi/AtomicDepositor.json";
import LEGACY_ATOMIC_DEPOSITOR_ABI from "./abi/LegacyAtomicDepositor.json";
import WETH_ABI from "./abi/Weth.json";
import HUB_POOL_ABI from "./abi/HubPool.json";
import VOTING_V2_ABI from "./abi/VotingV2.json";
Expand Down Expand Up @@ -80,10 +79,6 @@ export const CONTRACT_ADDRESSES: {
address: "0x64668fbD18b967b46DD22dc8675134D91efeDd8d",
abi: ATOMIC_DEPOSITOR_ABI,
},
legacyAtomicDepositor: {
address: "0xD59d70d887F34669BA695Fe9ABb8848b70de6171",
abi: LEGACY_ATOMIC_DEPOSITOR_ABI,
},
opUSDCBridge_480: {
address: "0x153A69e4bb6fEDBbAaF463CB982416316c84B2dB",
abi: OP_USDC_BRIDGE_ABI,
Expand Down
69 changes: 0 additions & 69 deletions src/common/abi/LegacyAtomicDepositor.json

This file was deleted.

0 comments on commit 54571d8

Please sign in to comment.