Skip to content

Commit

Permalink
Address #881
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBugsy committed Nov 8, 2023
1 parent b429742 commit e715c21
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/RootPort.sol
Original file line number Diff line number Diff line change
Expand Up @@ -481,17 +481,24 @@ contract RootPort is Ownable, IRootPort {

/// @inheritdoc IRootPort
function addEcosystemToken(address _ecoTokenGlobalAddress) external override onlyOwner {
// Check if token already added
// Check if token already added as ecosystem token
if (isGlobalAddress[_ecoTokenGlobalAddress]) revert AlreadyAddedEcosystemToken();

// Check if token is already a underlying token in current chain
// Check if token is an hToken
if (getUnderlyingTokenFromLocal[_ecoTokenGlobalAddress][localChainId] != address(0)) {
revert AlreadyAddedEcosystemToken();
}

// Check if token is already a local branch token in current chain
if (getLocalTokenFromUnderlying[_ecoTokenGlobalAddress][localChainId] != address(0)) {
revert AlreadyAddedEcosystemToken();
// Check if token already added as underlying token
address localTokenAddress = getLocalTokenFromUnderlying[_ecoTokenGlobalAddress][localChainId];
if (localTokenAddress != address(0)) {
// If there is a deposit of the underlying token, revert
if (ERC20hTokenRoot(localTokenAddress).totalSupply() > 0) {
revert AlreadyAddedEcosystemToken();
} else {
getUnderlyingTokenFromLocal[localTokenAddress][localChainId] = address(0);
getLocalTokenFromUnderlying[_ecoTokenGlobalAddress][localChainId] = address(0);
}
}

// Update State
Expand Down

0 comments on commit e715c21

Please sign in to comment.