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

Use arb compatible USDC token implementation #88

Merged
merged 23 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 112 additions & 2 deletions contracts/tokenbridge/libraries/IFiatToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,122 @@ pragma solidity >0.6.0 <0.9.0;

/**
* @title IFiatToken
* @dev Part of the interface that is used in Circle's referent implementation of the USDC
* @dev Interface contains functions from Circle's referent implementation of the USDC
* Ref: https://github.com/circlefin/stablecoin-evm
*
* This interface is used in the L1USDCGateway, L1OrbitUSDCGateway and L2USDCGateway contracts.
*/
interface IFiatToken {
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function authorizationState(address authorizer, bytes32 nonce) external view returns (bool);
function balanceOf(address account) external view returns (uint256);
function blacklist(address _account) external;
function blacklister() external view returns (address);
function burn(uint256 _amount) external;
function mint(address _to, uint256 _amount) external;
function cancelAuthorization(address authorizer, bytes32 nonce, uint8 v, bytes32 r, bytes32 s)
external;
function cancelAuthorization(address authorizer, bytes32 nonce, bytes memory signature)
external;
function configureMinter(address minter, uint256 minterAllowedAmount) external returns (bool);
function currency() external view returns (string memory);
function decimals() external view returns (uint8);
function decreaseAllowance(address spender, uint256 decrement) external returns (bool);
function increaseAllowance(address spender, uint256 increment) external returns (bool);
function initialize(
string memory tokenName,
string memory tokenSymbol,
string memory tokenCurrency,
uint8 tokenDecimals,
address newMasterMinter,
address newPauser,
address newBlacklister,
address newOwner
) external;
function initializeV2(string memory newName) external;
function initializeV2_1(address lostAndFound) external;
function initializeV2_2(address[] memory accountsToBlacklist, string memory newSymbol)
external;
function isBlacklisted(address _account) external view returns (bool);
function isMinter(address account) external view returns (bool);
function masterMinter() external view returns (address);
function mint(address _to, uint256 _amount) external returns (bool);
function minterAllowance(address minter) external view returns (uint256);
function name() external view returns (string memory);
function nonces(address owner) external view returns (uint256);
function owner() external view returns (address);
function pause() external;
function paused() external view returns (bool);
function pauser() external view returns (address);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
bytes memory signature
) external;
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function receiveWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
bytes memory signature
) external;
function receiveWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external;
function removeMinter(address minter) external returns (bool);
function rescueERC20(address tokenContract, address to, uint256 amount) external;
function rescuer() external view returns (address);
function symbol() external view returns (string memory);
function totalSupply() external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function transferOwnership(address newOwner) external;
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
bytes memory signature
) external;
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external;
function unBlacklist(address _account) external;
function unpause() external;
function updateBlacklister(address _newBlacklister) external;
function updateMasterMinter(address _newMasterMinter) external;
function updatePauser(address _newPauser) external;
function updateRescuer(address newRescuer) external;
function version() external pure returns (string memory);
}
26 changes: 0 additions & 26 deletions contracts/tokenbridge/test/BridgedUsdcCustomToken.sol

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@openzeppelin/contracts-upgradeable": "4.8.3"
},
"devDependencies": {
"@arbitrum/sdk": "^3.1.3",
"@arbitrum/sdk": "^3.5.1",
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
Expand Down
154 changes: 103 additions & 51 deletions scripts/local-deployment/localDeploymentLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
getEstimateForDeployingFactory,
registerGateway,
} from '../atomicTokenBridgeDeployer'
import { l2Networks } from '@arbitrum/sdk/dist/lib/dataEntities/networks'
import { IOwnable__factory, TestWETH9__factory } from '../../build/types'

const LOCALHOST_L2_RPC = 'http://localhost:8547'
Expand Down Expand Up @@ -71,39 +70,29 @@ export const setupTokenBridgeInLocalEnv = async () => {
new ethers.providers.JsonRpcProvider(childRpc)
)

/// register networks
const { l1Network, l2Network: coreL2Network } = await getLocalNetworks(
parentRpc,
childRpc,
rollupAddress
)

// register - needed for retryables
const existingL2Network = l2Networks[coreL2Network.chainID.toString()]
if (!existingL2Network) {
addCustomNetwork({
customL1Network: l1Network,
customL2Network: {
...coreL2Network,
tokenBridge: {
l1CustomGateway: '',
l1ERC20Gateway: '',
l1GatewayRouter: '',
l1MultiCall: '',
l1ProxyAdmin: '',
l1Weth: '',
l1WethGateway: '',

l2CustomGateway: '',
l2ERC20Gateway: '',
l2GatewayRouter: '',
l2Multicall: '',
l2ProxyAdmin: '',
l2Weth: '',
l2WethGateway: '',
},
},
})
const _l1Network = l1Network as L2Network
const ethLocal: L1Network = {
blockTime: 10,
chainID: _l1Network.partnerChainID,
explorerUrl: '',
isCustom: true,
name: 'EthLocal',
partnerChainIDs: [_l1Network.chainID],
isArbitrum: false,
}
addCustomNetwork({
customL1Network: ethLocal,
customL2Network: _l1Network,
})
addCustomNetwork({
customL2Network: coreL2Network,
})

// prerequisite - deploy L1 creator and set templates
console.log('Deploying L1TokenBridgeCreator')
Expand Down Expand Up @@ -203,13 +192,73 @@ export const getLocalNetworks = async (
l2Url: string,
rollupAddress?: string
): Promise<{
l1Network: L1Network
l2Network: Omit<L2Network, 'tokenBridge'>
l1Network: L1Network | L2Network
l2Network: L2Network
}> => {
const l1Provider = new JsonRpcProvider(l1Url)
const l2Provider = new JsonRpcProvider(l2Url)
let deploymentData: string

const l1NetworkInfo = await l1Provider.getNetwork()
const l2NetworkInfo = await l2Provider.getNetwork()

/// get parent chain info
const container = execSync(
'docker ps --filter "name=sequencer" --format "{{.Names}}"'
)
.toString()
.trim()
const l2DeploymentData = execSync(
`docker exec ${container} cat /config/deployment.json`
).toString()
const l2Data = JSON.parse(l2DeploymentData) as {
bridge: string
inbox: string
['sequencer-inbox']: string
rollup: string
}

const l1Network: L1Network | L2Network = {
partnerChainID: 1337,
partnerChainIDs: [l2NetworkInfo.chainId],
isArbitrum: true,
confirmPeriodBlocks: 20,
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
depositTimeout: 900000,
chainID: 412346,
explorerUrl: '',
isCustom: true,
name: 'ArbLocal',
blockTime: 0.25,
ethBridge: {
bridge: l2Data.bridge,
inbox: l2Data.inbox,
outbox: '',
rollup: l2Data.rollup,
sequencerInbox: l2Data['sequencer-inbox'],
},
tokenBridge: {
l1CustomGateway: '',
l1ERC20Gateway: '',
l1GatewayRouter: '',
l1MultiCall: '',
l1ProxyAdmin: '',
l1Weth: '',
l1WethGateway: '',

l2CustomGateway: '',
l2ERC20Gateway: '',
l2GatewayRouter: '',
l2Multicall: '',
l2ProxyAdmin: '',
l2Weth: '',
l2WethGateway: '',
},
}

/// get L3 info
let deploymentData: string
let data = {
bridge: '',
inbox: '',
Expand Down Expand Up @@ -242,28 +291,14 @@ export const getLocalNetworks = async (
data.rollup = rollupAddress!
}

const rollup = RollupAdminLogic__factory.connect(data.rollup, l1Provider)
const confirmPeriodBlocks = await rollup.confirmPeriodBlocks()

const bridge = Bridge__factory.connect(data.bridge, l1Provider)
const outboxAddr = await bridge.allowedOutboxList(0)

const l1NetworkInfo = await l1Provider.getNetwork()
const l2NetworkInfo = await l2Provider.getNetwork()

const l1Network: L1Network = {
blockTime: 10,
chainID: l1NetworkInfo.chainId,
explorerUrl: '',
isCustom: true,
name: 'EthLocal',
partnerChainIDs: [l2NetworkInfo.chainId],
isArbitrum: false,
}

const l2Network: Omit<L2Network, 'tokenBridge'> = {
const l2Network: L2Network = {
partnerChainID: l1NetworkInfo.chainId,
partnerChainIDs: [],
chainID: l2NetworkInfo.chainId,
confirmPeriodBlocks: confirmPeriodBlocks.toNumber(),
confirmPeriodBlocks: 20,
ethBridge: {
bridge: data.bridge,
inbox: data.inbox,
Expand All @@ -274,12 +309,29 @@ export const getLocalNetworks = async (
explorerUrl: '',
isArbitrum: true,
isCustom: true,
name: 'ArbLocal',
partnerChainID: l1NetworkInfo.chainId,
blockTime: 0.25,
name: 'OrbitLocal',
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
depositTimeout: 900000,
tokenBridge: {
l1CustomGateway: '',
l1ERC20Gateway: '',
l1GatewayRouter: '',
l1MultiCall: '',
l1ProxyAdmin: '',
l1Weth: '',
l1WethGateway: '',

l2CustomGateway: '',
l2ERC20Gateway: '',
l2GatewayRouter: '',
l2Multicall: '',
l2ProxyAdmin: '',
l2Weth: '',
l2WethGateway: '',
},
}
return {
l1Network,
Expand Down
Loading
Loading