Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update token #10

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
MNEMONIC="test test test test test test test test test test test test"
MNEMONIC="test test test test test test test test test test test test"
DESTINATION_BRIDGE_ADDRESS=""
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ package-lock.json
cache/
artifacts/
.openzeppelin/
typechain-types/


72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
<div align="center">
<img alt="LayerZero" src="resources/LayerZeroLogo.png"/>
</div>

---

# Wrapped Asset Bridge

Wrapped asset bridge allows bridging `ERC20` tokens and native gas tokens (e.g. `ETH`) from existing EVM chains (e.g. Ethereum, Avalanche, BSC, etc.) to subnets or brand new EVM chains where those assets do not exist natively. It supports mapping the same wrapped token to multiple tokens on other chains. E.g. moving native USDC from Ethereum or Avalanche to NewChainX will result in the same wrapped asset on NewChainX.
# Fuse V2 Bridge


<br>


[badge-warning]: https://github.com/Mqxx/GitHub-Markdown/blob/main/blockquotes/badge/dark-theme/warning.svg 'Warning'

> ![badge-warning][badge-warning]<br>
> The bridge is not intended for bridging between existing L1 EVM chains (e.g. between Ethereum and Avalanche)
Wrapped asset bridge allows bridging `ERC20` tokens and native gas tokens (e.g. `ETH`) from existing EVM chains (e.g. Ethereum, Avalanche, BSC, etc.) to subnets or brand new EVM chains where those assets do not exist natively. It supports mapping the same wrapped token to multiple tokens on other chains. E.g. moving native USDC from Ethereum or Avalanche to NewChainX will result in the same wrapped asset on NewChainX.

<br>

Expand Down Expand Up @@ -61,6 +47,60 @@ Get the coverage report.
1. Call `estimateBridgeFee(uint16 remoteChainId, bool useZro, bytes calldata adapterParams)` in `WrappedTokenBridge`.
2. Call `bridge(address localToken, uint16 remoteChainId, uint amount, address to, bool unwrapWeth, LzLib.CallParams calldata callParams, bytes memory adapterParams)` supplying `nativeFee` obtained earlier as a value. This will burn wrapped tokens and send a LayerZero message to `OriginalTokenBridge` contract on another chain to unlock original tokens.

## Using Scripts

To deploy fresh contracts plese delete the contents of the `deployments` folder.

Populate the env MNENOIC in the env file and run the following commands in order.


1. `npx hardhat deployBridges --original-networks "polygon,gnosis" --wrapped-network "fuse"`

Now populate the Bridge address on Fuse in the env file and proceed.

2. `npx hardhat deployTokens --original-networks "fuse"`
3. `npx hardhat setTrustedRemote --original-networks "gnosis" --wrapped-network "fuse"`
4. `npx hardhat registerTokens --original-networks "gnosis" --wrapped-network "fuse" --tokens "USDC,USDT,WETH"`

New tokens can be added by adding them in constants and updating the list in `deploy/WrappedERC20.js`

To see the whole process of deploying a bridge, please check the `scrips/deployments` folders

## Deployed Contracts

### Polygon
OriginalTokenBridge: `0x8f5D6332eD11338D2dA4fAAC6675e9A6757BeC8b`- locks erc20 from Polygon to Fuse<br>
WrappedTokenBridge: `0xe453d6649643F1F460C371dC3D1da98F7922fe51` - mints and burns Fuse tokens<br>

### Gnosis
OriginalTokenBridge: `0xb0F9cE8598c623Ff42e52388F9b452B7CDc409a1`- locks erc20 from Arbitrum to Fuse<br>
WrappedTokenBridge: `0x4014115fB4816Bc8343d8e69d2708Fa738dCaa15`- mints and burns Fuse tokens<br>

### Optimism
OriginalTokenBridge: `0x081dF5af5d022D4A4a4520D4D0D336B8432fDBBb` - locks erc20 from Optimism to Fuse<br>
WrappedTokenBridge: `0xEEd9154F63f6F0044E6b00dDdEFD895b5B4ED580`- mints and burns Fuse tokens<br>

### Arbitrum
OriginalTokenBridge: `0x081dF5af5d022D4A4a4520D4D0D336B8432fDBBb` - locks erc20 from Arbitrum to Fuse<br>
WrappedTokenBridge: `0xEEd9154F63f6F0044E6b00dDdEFD895b5B4ED580`- mints and burns Fuse tokens<br>

### BSC
OriginalTokenBridge: `0x081dF5af5d022D4A4a4520D4D0D336B8432fDBBb` - locks erc20 from BSC to Fuse<br>
WrappedTokenBridge: `0xADef29442A11ad9308aC5D012965c887Cf2A53D3` - mints and burns Fuse tokens<br>

### Fuse
OriginalTokenBridge(to Polygon): `0x36207130CF22d8C54842569A32a0Cd5D711f3580`- Fuse (holds WUFSE) <br>
OriginalTokenBridge(to Gnosis): `0xc465107230c21f154627e017b6727A3C18984B02` - Fuse (holds WUFSE) <br>
OriginalTokenBridge(to Optimism): `0xeC3FD32cd5389FbC581427A648d6dc1bc5cfFE3B`- Fuse (holds WUFSE) <br>
OriginalTokenBridge(to Arbitrum): `0x56dF61E9f39C75e2d84C05753557bEBB9841Eb5B`- Fuse (holds WUFSE) <br>
OriginalTokenBridge(to BSC): `0x6bd341B6C7d6123D28d3DDee6A65d441DbAC1E90`- Fuse (holds WUFSE) <br>
WrappedTokenBridge: `0x353af4878d7452e974538706273887F7ED90Da47` - mints and burns erc20 from all the networks
<br>

## Deployed Contracts - Testnet

### BSC-testnet
WrappedTokenBridge: `0x6C460c18459907c5b743188eeA35896BAFe9fd74`<br>

### Spark
OriginalTokenBridge(to BSC): `0xd616e2825dC094460cfEfc3d54ed75A6d34a7065`<br>
6 changes: 5 additions & 1 deletion constants/blockExplorerApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"ethereum": "https://api.etherscan.io/api",
"bsc": "https://api.bscscan.com/api",
"polygon": "https://api.polygonscan.com/api",
"coredao": "https://openapi.coredao.org/api"
"coredao": "https://openapi.coredao.org/api",
"fuse": "https://explorer.fuse.io/api",
"spark": "https://explorer.fusespark.io/api",
"gnosis": "https://api.gnosisscan.io/api",
"bsc-testnet": "https://testnet.bscscan.com/api"
}
16 changes: 16 additions & 0 deletions constants/bridges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fuse": {
"OriginalTokenBridgeUpgradable": "0x6bd341B6C7d6123D28d3DDee6A65d441DbAC1E90"
},
"bsc": {
"WrappedTokenBridgeUpgradable": "0xADef29442A11ad9308aC5D012965c887Cf2A53D3",
"WrappedERC20": "0x5857c96DaE9cF8511B08Cb07f85753C472D36Ea3"
},
"bsc-testnet": {
"WrappedTokenBridgeUpgradable": "0x6C460c18459907c5b743188eeA35896BAFe9fd74",
"WrappedERC20": "0x58C70f0e6777801edB1bB66f33D3456df4F6F051"
},
"spark": {
"OriginalTokenBridgeUpgradable": "0xd616e2825dC094460cfEfc3d54ed75A6d34a7065"
}
}
16 changes: 4 additions & 12 deletions constants/chainIds.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
{
"ethereum": 101,
"bsc": 102,
"avalanche": 106,
"polygon": 109,
"arbitrum": 110,
"optimism": 111,
"fantom": 112,
"coredao": 153,

"goerli": 10121,
"bsc-testnet": 10102,
"fuji": 10106,
"mumbai": 10109,
"arbitrum-goerli": 10143,
"optimism-goerli": 10132,
"fantom-testnet": 10112,
"coredao-testnet": 10153
"fuse": 138,
"gnosis": 145,
"spark": 10138,
"bsc-testnet": 10102
}
16 changes: 4 additions & 12 deletions constants/layerzeroEndpoints.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
{
"ethereum": "0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675",
"bsc": "0x3c2269811836af69497E5F486A85D7316753cf62",
"avalanche": "0x3c2269811836af69497E5F486A85D7316753cf62",
"polygon": "0x3c2269811836af69497E5F486A85D7316753cf62",
"arbitrum": "0x3c2269811836af69497E5F486A85D7316753cf62",
"optimism": "0x3c2269811836af69497E5F486A85D7316753cf62",
"fantom": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7",
"coredao": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4",

"goerli": "0xbfD2135BFfbb0B5378b56643c2Df8a87552Bfa23",
"bsc-testnet": "0x6Fcb97553D41516Cb228ac03FdC8B9a0a9df04A1",
"fuji": "0x93f54D755A063cE7bB9e6Ac47Eccc8e33411d706",
"mumbai": "0xf69186dfBa60DdB133E91E9A4B5673624293d8F8",
"arbitrum-goerli": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab",
"optimism-goerli": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1",
"fantom-testnet": "0x7dcAD72640F835B0FA36EFD3D6d3ec902C7E5acf",
"coredao-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1"
"fuse":"0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4",
"gnosis":"0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4",
"spark": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1",
"bsc-testnet": "0x6Fcb97553D41516Cb228ac03FdC8B9a0a9df04A1"
}
10 changes: 5 additions & 5 deletions constants/remoteChainIds.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"ethereum": 153,
"bsc": 153,
"polygon": 153,

"goerli": 10153,
"bsc-testnet": 10153,
"mumbai": 10153
"polygon": 138,
"fuse": 109,
"gnosis": 138,
"optimism": 111,
"spark": 10102
}
32 changes: 4 additions & 28 deletions constants/tokens.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
{
"ethereum": {
"WETH": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"USDT": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
},
"bsc": {
"USDC": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
"USDT": "0x55d398326f99059fF775485246999027B3197955"
},
"polygon": {
"USDC": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"USDT": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
},
"coredao":{
"WETH": "0xeAB3aC417c4d6dF6b143346a46fEe1B847B50296",
"USDC": "0xa4151B2B3e269645181dCcF2D426cE75fcbDeca9",
"USDT": "0x900101d06A7426441Ae63e9AB3B9b0F63Be145F1"
},
"goerli": {
"WETH": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"USDC": "0x122B8f9fAda7586072e76950c7a299523D1f3846"
},
"bsc-testnet": {
"USDC": "0x6795cbCF57760947b34eFf59E7465611B80A615b"
},
"mumbai": {
"USDC": "0x9ebF92a4b1615CcD5fd10E46adF509d6071345A9"
"WETH": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"
},
"coredao-testnet": {
"WETH": "0x2e3531Ad3C30d78e153e485FA5098ddF1524d79d",
"USDC": "0xE1B5004075CE96E5E59B3698BE29AF585e0F1c5C"
"gnosis":{
"WETH": "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1",
"USDC": "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83"
}
}
16 changes: 8 additions & 8 deletions constants/weths.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"ethereum": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"bsc": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"polygon": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
"goerli": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"bsc-testnet": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
"mumbai": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889"
}
"ethereum": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"bsc": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
"polygon": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
"gnosis": "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d",
"optimism": "0x4200000000000000000000000000000000000006",
"fuse": "0x0BE9e53fd7EDaC9F859882AfdDa116645287C629",
"spark": "0xE7fC46eCdDBd42b1934323ff7276D2e4F02B54E9"
}
Loading