Skip to content

Commit f28f8aa

Browse files
committed
feat: ETH bridge
1 parent 5296a77 commit f28f8aa

13 files changed

+10271
-10
lines changed

constants/tokenConfig.js

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ module.exports = {
5454
symbol: "COBE",
5555
withFee: true,
5656
},
57+
EthereumOFT: {
58+
name: "Ethereum",
59+
symbol: "ETH",
60+
withFee: true,
61+
},
5762
},
5863
"beam-testnet": {
5964
BeamNativeOFT: {
@@ -129,6 +134,12 @@ module.exports = {
129134
address: "0xc61eDB127f58f42F47a8bE8aeBe83cF602A53878",
130135
withFee: true,
131136
},
137+
EthereumNativeOFT: {
138+
name: "LayerZero Ethereum",
139+
symbol: "LZETH",
140+
withFee: true,
141+
isNative: true,
142+
},
132143
},
133144
goerli: {
134145
UsdcProxyOFT: {

contracts/contracts-upgradable/examples/AvaxOFT.sol

-10
This file was deleted.

contracts/contracts-upgradable/examples/BeamBridge.sol renamed to contracts/contracts-upgradable/examples/NativeOFTWithFee.sol

+9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ pragma solidity ^0.8.18;
55
import "../token/oft/v2/fee/NativeOFTWithFeeUpgradeable.sol";
66
import "../token/oft/v2/fee/ProxyOFTWithFeeUpgradeable.sol";
77
import "../token/oft/v2/fee/OFTWithFeeUpgradeable.sol";
8+
import "../token/oft/v2/fee/OFTWithFeePermitUpgradeable.sol";
89

910
contract BeamProxyOFT is ProxyOFTWithFeeUpgradeable {}
1011

1112
contract BeamNativeOFT is NativeOFTWithFeeUpgradeable {}
1213

1314
contract BeamOFT is OFTWithFeeUpgradeable {}
15+
16+
contract AvaxOFT is OFTWithFeeUpgradeable {}
17+
18+
contract AvaxNativeOFT is NativeOFTWithFeeUpgradeable {}
19+
20+
contract EthereumOFT is OFTWithFeePermitUpgradeable {}
21+
22+
contract EthereumNativeOFT is NativeOFTWithFeeUpgradeable {}

deploy/EthereumNativeOFT.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const LZ_ENDPOINTS = require("../constants/layerzeroEndpoints.json")
2+
const TOKEN_CONFIG = require("../constants/tokenConfig")
3+
4+
const CONTRACT_NAME = "EthereumNativeOFT"
5+
6+
module.exports = async function ({ deployments, getNamedAccounts }) {
7+
const { deploy } = deployments
8+
const { deployer, proxyOwner } = await getNamedAccounts()
9+
10+
let lzEndpointAddress, lzEndpoint, LZEndpointMock
11+
if (hre.network.name === "hardhat") {
12+
LZEndpointMock = await ethers.getContractFactory("LZEndpointMock")
13+
lzEndpoint = await LZEndpointMock.deploy(1)
14+
lzEndpointAddress = lzEndpoint.address
15+
} else {
16+
lzEndpointAddress = LZ_ENDPOINTS[hre.network.name]
17+
}
18+
19+
const tokenConfig = TOKEN_CONFIG[hre.network.name][CONTRACT_NAME]
20+
if (!tokenConfig.name || !tokenConfig.symbol) {
21+
console.error("No configuration found for target network.")
22+
return
23+
}
24+
25+
await deploy(CONTRACT_NAME, {
26+
from: deployer,
27+
log: true,
28+
waitConfirmations: 1,
29+
proxy: {
30+
owner: proxyOwner,
31+
proxyContract: "OptimizedTransparentProxy",
32+
execute: {
33+
init: {
34+
methodName: "initialize",
35+
args: [
36+
tokenConfig.name,
37+
tokenConfig.symbol,
38+
tokenConfig.sharedDecimals != null ? tokenConfig.sharedDecimals : 6,
39+
lzEndpointAddress,
40+
],
41+
},
42+
},
43+
},
44+
})
45+
}
46+
47+
module.exports.tags = [CONTRACT_NAME]

deploy/EthereumOFT.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const LZ_ENDPOINTS = require("../constants/layerzeroEndpoints.json")
2+
const TOKEN_CONFIG = require("../constants/tokenConfig")
3+
4+
const CONTRACT_NAME = "EthereumOFT"
5+
6+
module.exports = async function ({ deployments, getNamedAccounts }) {
7+
const { deploy } = deployments
8+
const { deployer, proxyOwner } = await getNamedAccounts()
9+
10+
let lzEndpointAddress, lzEndpoint, LZEndpointMock
11+
if (hre.network.name === "hardhat") {
12+
LZEndpointMock = await ethers.getContractFactory("LZEndpointMock")
13+
lzEndpoint = await LZEndpointMock.deploy(1)
14+
lzEndpointAddress = lzEndpoint.address
15+
} else {
16+
lzEndpointAddress = LZ_ENDPOINTS[hre.network.name]
17+
}
18+
19+
const tokenConfig = TOKEN_CONFIG[hre.network.name][CONTRACT_NAME]
20+
if (!tokenConfig.name || !tokenConfig.symbol) {
21+
console.error("No configuration found for target network.")
22+
return
23+
}
24+
25+
await deploy(CONTRACT_NAME, {
26+
from: deployer,
27+
log: true,
28+
waitConfirmations: 1,
29+
proxy: {
30+
owner: proxyOwner,
31+
proxyContract: "OptimizedTransparentProxy",
32+
execute: {
33+
init: {
34+
methodName: "initialize",
35+
args: [
36+
tokenConfig.name,
37+
tokenConfig.symbol,
38+
tokenConfig.sharedDecimals != null ? tokenConfig.sharedDecimals : 6,
39+
lzEndpointAddress,
40+
],
41+
},
42+
},
43+
},
44+
})
45+
}
46+
47+
module.exports.tags = [CONTRACT_NAME]

0 commit comments

Comments
 (0)