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

feat(protocol): add a script to use native USDC token as the bridged token #16812

Merged
merged 8 commits into from
Apr 23, 2024
46 changes: 46 additions & 0 deletions packages/protocol/script/SetupUSDCBridging.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "../test/DeployCapability.sol";
import "../contracts/tokenvault/ERC20Vault.sol";

/// @dev This script shall be run on Taiko chain to hook up a native USDC deployment and the USDC
/// deployed on EThereum.
dantaik marked this conversation as resolved.
Show resolved Hide resolved
/// To deploy a native USDC contract on Taiko, run:
/// https://github.com/taikoxyz/USDC/blob/main/script/DeployUSDC.s.sol
contract SetupUSDCBridging is DeployCapability {
address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
dantaik marked this conversation as resolved.
Show resolved Hide resolved

uint256 public privateKey = vm.envUint("PRIVATE_KEY");
address public erc20VaultOnL2 = vm.envAddress("ERC20_VAULT_ON_L2");
address public usdcOnL2 = vm.envAddress("USDC_ADDRESS_ON_L2");

function run() external {
require(erc20VaultOnL2 != address(0) && usdcOnL2 != address(0), "invalid params");

ERC20Vault vault = ERC20Vault(erc20VaultOnL2);

address currBridgedtoken = vault.canonicalToBridged(1, USDC);
console2.log("current btoken for usdc:", currBridgedtoken);

ERC20Vault.CanonicalERC20 memory ctoken = ERC20Vault.CanonicalERC20({
chainId: 1,
addr: USDC,
decimals: 6,
symbol: "USDC",
name: "USD Coin"
});

vm.startBroadcast(privateKey);
vault.changeBridgedToken(ctoken, usdcOnL2);
if (vault.paused()) {
vault.unpause();
}
vm.stopBroadcast();

address newBridgedToken = vault.canonicalToBridged(1, USDC);
console2.log("new btoken for usdc:", newBridgedToken);

require(usdcOnL2 == newBridgedToken, "unexpected result");
}
}
Loading