diff --git a/contracts/interchain-token-service/InterchainTokenService.sol b/contracts/interchain-token-service/InterchainTokenService.sol index 44a592b7..650e83be 100644 --- a/contracts/interchain-token-service/InterchainTokenService.sol +++ b/contracts/interchain-token-service/InterchainTokenService.sol @@ -126,10 +126,10 @@ contract InterchainTokenService is /** * @notice This modifier is used to ensure certain functions can only be called by TokenManagers. - * @param tokenId_ the `tokenId_` of the TokenManager trying to perform the call. + * @param tokenId the `tokenId` of the TokenManager trying to perform the call. */ - modifier onlyTokenManager(bytes32 tokenId_) { - address tokenManager = tokenManagerAddress(tokenId_); + modifier onlyTokenManager(bytes32 tokenId) { + address tokenManager = tokenManagerAddress(tokenId); if (msg.sender != tokenManager) revert NotTokenManager(msg.sender, tokenManager); _; @@ -147,54 +147,54 @@ contract InterchainTokenService is } /** - * @notice Calculates the address of a TokenManager from a specific tokenId_. The TokenManager does not need to exist already. - * @param tokenId_ the tokenId_. + * @notice Calculates the address of a TokenManager from a specific tokenId. The TokenManager does not need to exist already. + * @param tokenId the tokenId. * @return tokenManagerAddress_ deployment address of the TokenManager. */ - function tokenManagerAddress(bytes32 tokenId_) public view returns (address tokenManagerAddress_) { - tokenManagerAddress_ = _create3Address(tokenId_); + function tokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress_) { + tokenManagerAddress_ = _create3Address(tokenId); } /** - * @notice Returns the address of a TokenManager from a specific tokenId_. The TokenManager needs to exist already. - * @param tokenId_ the tokenId_. + * @notice Returns the address of a TokenManager from a specific tokenId. The TokenManager needs to exist already. + * @param tokenId the tokenId. * @return tokenManagerAddress_ deployment address of the TokenManager. */ - function validTokenManagerAddress(bytes32 tokenId_) public view returns (address tokenManagerAddress_) { - tokenManagerAddress_ = tokenManagerAddress(tokenId_); - if (tokenManagerAddress_.code.length == 0) revert TokenManagerDoesNotExist(tokenId_); + function validTokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress_) { + tokenManagerAddress_ = tokenManagerAddress(tokenId); + if (tokenManagerAddress_.code.length == 0) revert TokenManagerDoesNotExist(tokenId); } /** * @notice Returns the address of the token that an existing tokenManager points to. - * @param tokenId_ the tokenId_. + * @param tokenId the tokenId. * @return tokenAddress_ the address of the token. */ - function tokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_) { - address tokenManagerAddress_ = validTokenManagerAddress(tokenId_); + function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_) { + address tokenManagerAddress_ = validTokenManagerAddress(tokenId); tokenAddress_ = ITokenManager(tokenManagerAddress_).tokenAddress(); } /** - * @notice Returns the address of the interchain token that would be deployed with a given tokenId_. + * @notice Returns the address of the interchain token that would be deployed with a given tokenId. * The token does not need to exist. - * @param tokenId_ the tokenId_. + * @param tokenId the tokenId. * @return tokenAddress_ the address of the interchain token. */ - function interchainTokenAddress(bytes32 tokenId_) public view returns (address tokenAddress_) { - tokenId_ = _getInterchainTokenSalt(tokenId_); - tokenAddress_ = _create3Address(tokenId_); + function interchainTokenAddress(bytes32 tokenId) public view returns (address tokenAddress_) { + tokenId = _getInterchainTokenSalt(tokenId); + tokenAddress_ = _create3Address(tokenId); } /** - * @notice Calculates the tokenId_ that would correspond to a custom link for a given deployer with a specified salt. + * @notice Calculates the tokenId that would correspond to a custom link for a given deployer with a specified salt. * This will not depend on what chain it is called from, unlike canonical tokenIds. * @param sender the address of the TokenManager deployer. * @param salt the salt that the deployer uses for the deployment. - * @return tokenId_ the tokenId_ that the custom TokenManager would get (or has gotten). + * @return tokenId the tokenId that the custom TokenManager would get (or has gotten). */ - function interchainTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId_) { - tokenId_ = keccak256(abi.encode(PREFIX_TOKEN_ID, sender, salt)); + function interchainTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId) { + tokenId = keccak256(abi.encode(PREFIX_TOKEN_ID, sender, salt)); } /** @@ -216,31 +216,31 @@ contract InterchainTokenService is /** * @notice Getter function for the flow limit of an existing token manager with a give token ID. - * @param tokenId_ the token ID of the TokenManager. + * @param tokenId the token ID of the TokenManager. * @return flowLimit_ the flow limit. */ - function flowLimit(bytes32 tokenId_) external view returns (uint256 flowLimit_) { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); + function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_) { + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); flowLimit_ = tokenManager.flowLimit(); } /** * @notice Getter function for the flow out amount of an existing token manager with a give token ID. - * @param tokenId_ the token ID of the TokenManager. + * @param tokenId the token ID of the TokenManager. * @return flowOutAmount_ the flow out amount. */ - function flowOutAmount(bytes32 tokenId_) external view returns (uint256 flowOutAmount_) { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); + function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_) { + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); flowOutAmount_ = tokenManager.flowOutAmount(); } /** * @notice Getter function for the flow in amount of an existing token manager with a give token ID. - * @param tokenId_ the token ID of the TokenManager. + * @param tokenId the token ID of the TokenManager. * @return flowInAmount_ the flow in amount. */ - function flowInAmount(bytes32 tokenId_) external view returns (uint256 flowInAmount_) { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); + function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_) { + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); flowInAmount_ = tokenManager.flowInAmount(); } @@ -265,15 +265,15 @@ contract InterchainTokenService is TokenManagerType tokenManagerType, bytes calldata params, uint256 gasValue - ) external payable whenNotPaused returns (bytes32 tokenId_) { + ) external payable whenNotPaused returns (bytes32 tokenId) { address deployer_ = msg.sender; - tokenId_ = interchainTokenId(deployer_, salt); + tokenId = interchainTokenId(deployer_, salt); - emit CustomTokenIdClaimed(tokenId_, deployer_, salt); + emit CustomTokenIdClaimed(tokenId, deployer_, salt); if (bytes(destinationChain).length == 0) { - _deployTokenManager(tokenId_, tokenManagerType, params); + _deployTokenManager(tokenId, tokenManagerType, params); } else { - _deployRemoteTokenManager(tokenId_, destinationChain, gasValue, tokenManagerType, params); + _deployRemoteTokenManager(tokenId, destinationChain, gasValue, tokenManagerType, params); } } @@ -300,14 +300,14 @@ contract InterchainTokenService is bytes memory operator, uint256 gasValue ) external payable whenNotPaused { - bytes32 tokenId_ = interchainTokenId(msg.sender, salt); + bytes32 tokenId = interchainTokenId(msg.sender, salt); if (bytes(destinationChain).length == 0) { address tokenAddress_; - tokenAddress_ = _deployInterchainToken(tokenId_, distributor, name, symbol, decimals); - _deployTokenManager(tokenId_, TokenManagerType.MINT_BURN, abi.encode(operator, tokenAddress_)); + tokenAddress_ = _deployInterchainToken(tokenId, distributor, name, symbol, decimals); + _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(operator, tokenAddress_)); } else { - _deployRemoteInterchainToken(tokenId_, name, symbol, decimals, distributor, operator, destinationChain, gasValue); + _deployRemoteInterchainToken(tokenId, name, symbol, decimals, distributor, operator, destinationChain, gasValue); } } @@ -317,13 +317,13 @@ contract InterchainTokenService is string calldata sourceAddress, bytes calldata payload ) public view virtual onlyRemoteService(sourceChain, sourceAddress) whenNotPaused returns (address, uint256) { - (uint256 selector, bytes32 tokenId_, , uint256 amount) = abi.decode(payload, (uint256, bytes32, bytes, uint256)); + (uint256 selector, bytes32 tokenId, , uint256 amount) = abi.decode(payload, (uint256, bytes32, bytes, uint256)); if (selector != SELECTOR_RECEIVE_TOKEN && selector != SELECTOR_RECEIVE_TOKEN_WITH_DATA) { revert InvalidExpressSelector(selector); } - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); return (tokenManager.tokenAddress(), amount); } @@ -356,7 +356,7 @@ contract InterchainTokenService is * @param payload the payload of the receive token */ function _expressExecute(string calldata sourceChain, bytes calldata payload) internal { - (uint256 selector, bytes32 tokenId_, bytes memory sourceAddress, bytes memory destinationAddressBytes, uint256 amount) = abi.decode( + (uint256 selector, bytes32 tokenId, bytes memory sourceAddress, bytes memory destinationAddressBytes, uint256 amount) = abi.decode( payload, (uint256, bytes32, bytes, bytes, uint256) ); @@ -364,7 +364,7 @@ contract InterchainTokenService is IERC20 token; { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); token = IERC20(tokenManager.tokenAddress()); } @@ -377,7 +377,7 @@ contract InterchainTokenService is sourceChain, sourceAddress, data, - tokenId_, + tokenId, address(token), amount ); @@ -388,35 +388,35 @@ contract InterchainTokenService is /** * @notice Transfer a token interchain. - * @param tokenId_ the tokenId_ for the token link. + * @param tokenId the tokenId for the token link. * @param destinationChain the name of the chain to send the token to. * @param destinationAddress the recipient of the interchain transfer. * @param amount the amount of token to give. * @param metadata the data to be passed to the destination. If provided with a bytes4(0) prefix, it'll execute the destination contract. */ function interchainTransfer( - bytes32 tokenId_, + bytes32 tokenId, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, bytes calldata metadata ) external payable whenNotPaused { - ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId_)); + ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId)); amount = tokenManager.takeToken(msg.sender, amount); - _transmitSendToken(tokenId_, msg.sender, destinationChain, destinationAddress, amount, metadata); + _transmitSendToken(tokenId, msg.sender, destinationChain, destinationAddress, amount, metadata); } function sendTokenWithData( - bytes32 tokenId_, + bytes32 tokenId, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, bytes calldata data ) external payable whenNotPaused { - ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId_)); + ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId)); amount = tokenManager.takeToken(msg.sender, amount); uint32 prefix = 0; - _transmitSendToken(tokenId_, msg.sender, destinationChain, destinationAddress, amount, abi.encodePacked(prefix, data)); + _transmitSendToken(tokenId, msg.sender, destinationChain, destinationAddress, amount, abi.encodePacked(prefix, data)); } /*********************\ @@ -424,8 +424,8 @@ contract InterchainTokenService is \*********************/ /** - * @notice Transmit a sendTokenWithData for the given tokenId_. Only callable by a token manager. - * @param tokenId_ the tokenId_ of the TokenManager (which must be the msg.sender). + * @notice Transmit a sendTokenWithData for the given tokenId. Only callable by a token manager. + * @param tokenId the tokenId of the TokenManager (which must be the msg.sender). * @param sourceAddress the address where the token is coming from, which will also be used for reimbursement of gas. * @param destinationChain the name of the chain to send tokens to. * @param destinationAddress the destinationAddress for the interchainTransfer. @@ -433,14 +433,14 @@ contract InterchainTokenService is * @param metadata the data to be passed to the destination. */ function transmitSendToken( - bytes32 tokenId_, + bytes32 tokenId, address sourceAddress, string calldata destinationChain, bytes memory destinationAddress, uint256 amount, bytes calldata metadata - ) external payable onlyTokenManager(tokenId_) whenNotPaused { - _transmitSendToken(tokenId_, sourceAddress, destinationChain, destinationAddress, amount, metadata); + ) external payable onlyTokenManager(tokenId) whenNotPaused { + _transmitSendToken(tokenId, sourceAddress, destinationChain, destinationAddress, amount, metadata); } /*************\ @@ -565,17 +565,17 @@ contract InterchainTokenService is bytes calldata payload, uint256 selector ) internal { - bytes32 tokenId_; + bytes32 tokenId; bytes memory sourceAddress; address destinationAddress; uint256 amount; { bytes memory destinationAddressBytes; - (, tokenId_, sourceAddress, destinationAddressBytes, amount) = abi.decode(payload, (uint256, bytes32, bytes, bytes, uint256)); + (, tokenId, sourceAddress, destinationAddressBytes, amount) = abi.decode(payload, (uint256, bytes32, bytes, bytes, uint256)); destinationAddress = destinationAddressBytes.toAddress(); } - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); // Return token to the existing express caller if (expressExecutor != address(0)) { @@ -591,13 +591,13 @@ contract InterchainTokenService is (, , , , , data) = abi.decode(payload, (uint256, bytes32, bytes, bytes, uint256, bytes)); // slither-disable-next-line reentrancy-events - emit TokenReceivedWithData(tokenId_, sourceChain, sourceAddress, destinationAddress, amount); + emit TokenReceivedWithData(tokenId, sourceChain, sourceAddress, destinationAddress, amount); bytes32 result = IInterchainTokenExecutable(destinationAddress).executeWithInterchainToken( sourceChain, sourceAddress, data, - tokenId_, + tokenId, tokenManager.tokenAddress(), amount ); @@ -605,7 +605,7 @@ contract InterchainTokenService is if (result != EXECUTE_SUCCESS) revert ExecuteWithInterchainTokenFailed(destinationAddress); } else { // slither-disable-next-line reentrancy-events - emit TokenReceived(tokenId_, sourceChain, sourceAddress, destinationAddress, amount); + emit TokenReceived(tokenId, sourceChain, sourceAddress, destinationAddress, amount); } } @@ -614,12 +614,12 @@ contract InterchainTokenService is * @param payload The encoded data payload to be processed */ function _processDeployTokenManagerPayload(bytes calldata payload) internal { - (, bytes32 tokenId_, TokenManagerType tokenManagerType, bytes memory params) = abi.decode( + (, bytes32 tokenId, TokenManagerType tokenManagerType, bytes memory params) = abi.decode( payload, (uint256, bytes32, TokenManagerType, bytes) ); - _deployTokenManager(tokenId_, tokenManagerType, params); + _deployTokenManager(tokenId, tokenManagerType, params); } /** @@ -629,7 +629,7 @@ contract InterchainTokenService is function _processDeployInterchainTokenPayload(bytes calldata payload) internal { ( , - bytes32 tokenId_, + bytes32 tokenId, string memory name, string memory symbol, uint8 decimals, @@ -638,8 +638,8 @@ contract InterchainTokenService is ) = abi.decode(payload, (uint256, bytes32, string, string, uint8, bytes, bytes)); address tokenAddress_; - tokenAddress_ = _deployInterchainToken(tokenId_, distributorBytes, name, symbol, decimals); - _deployTokenManager(tokenId_, TokenManagerType.MINT_BURN, abi.encode(opeatorBytes, tokenAddress_)); + tokenAddress_ = _deployInterchainToken(tokenId, distributorBytes, name, symbol, decimals); + _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(opeatorBytes, tokenAddress_)); } /** @@ -672,30 +672,30 @@ contract InterchainTokenService is /** * @notice Deploys a token manager on a destination chain. - * @param tokenId_ The ID of the token + * @param tokenId The ID of the token * @param destinationChain The chain where the token manager will be deployed * @param gasValue The amount of gas to be paid for the transaction * @param tokenManagerType The type of token manager to be deployed * @param params Additional parameters for the token manager deployment */ function _deployRemoteTokenManager( - bytes32 tokenId_, + bytes32 tokenId, string calldata destinationChain, uint256 gasValue, TokenManagerType tokenManagerType, bytes memory params ) internal { // slither-disable-next-line unused-return - validTokenManagerAddress(tokenId_); - emit RemoteTokenManagerDeploymentInitialized(tokenId_, destinationChain, gasValue, tokenManagerType, params); + validTokenManagerAddress(tokenId); + emit RemoteTokenManagerDeploymentInitialized(tokenId, destinationChain, gasValue, tokenManagerType, params); - bytes memory payload = abi.encode(SELECTOR_DEPLOY_TOKEN_MANAGER, tokenId_, tokenManagerType, params); + bytes memory payload = abi.encode(SELECTOR_DEPLOY_TOKEN_MANAGER, tokenId, tokenManagerType, params); _callContract(destinationChain, payload, gasValue); } /** * @notice Deploys a interchain token on a destination chain. - * @param tokenId_ The ID of the token + * @param tokenId The ID of the token * @param name The name of the token * @param symbol The symbol of the token * @param decimals The number of decimals of the token @@ -704,7 +704,7 @@ contract InterchainTokenService is * @param gasValue The amount of gas to be paid for the transaction */ function _deployRemoteInterchainToken( - bytes32 tokenId_, + bytes32 tokenId, string memory name, string memory symbol, uint8 decimals, @@ -714,11 +714,11 @@ contract InterchainTokenService is uint256 gasValue ) internal { // slither-disable-next-line unused-return - validTokenManagerAddress(tokenId_); + validTokenManagerAddress(tokenId); // slither-disable-next-line reentrancy-events emit RemoteInterchainTokenDeploymentInitialized( - tokenId_, + tokenId, name, symbol, decimals, @@ -728,20 +728,20 @@ contract InterchainTokenService is gasValue ); - bytes memory payload = abi.encode(SELECTOR_DEPLOY_INTERCHAIN_TOKEN, tokenId_, name, symbol, decimals, distributor, operator); + bytes memory payload = abi.encode(SELECTOR_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, distributor, operator); _callContract(destinationChain, payload, gasValue); } /** * @notice Deploys a token manager - * @param tokenId_ The ID of the token + * @param tokenId The ID of the token * @param tokenManagerType The type of the token manager to be deployed * @param params Additional parameters for the token manager deployment */ - function _deployTokenManager(bytes32 tokenId_, TokenManagerType tokenManagerType, bytes memory params) internal { + function _deployTokenManager(bytes32 tokenId, TokenManagerType tokenManagerType, bytes memory params) internal { // slither-disable-next-line controlled-delegatecall (bool success, bytes memory returnData) = tokenManagerDeployer.delegatecall( - abi.encodeWithSelector(ITokenManagerDeployer.deployTokenManager.selector, tokenId_, tokenManagerType, params) + abi.encodeWithSelector(ITokenManagerDeployer.deployTokenManager.selector, tokenId, tokenManagerType, params) ); if (!success) revert TokenManagerDeploymentFailed(returnData); @@ -751,35 +751,35 @@ contract InterchainTokenService is } // slither-disable-next-line reentrancy-events - emit TokenManagerDeployed(tokenId_, tokenManager, tokenManagerType, params); + emit TokenManagerDeployed(tokenId, tokenManager, tokenManagerType, params); } /** * @notice Compute the salt for a interchain token deployment. - * @param tokenId_ The ID of the token + * @param tokenId The ID of the token * @return salt The computed salt for the token deployment */ - function _getInterchainTokenSalt(bytes32 tokenId_) internal pure returns (bytes32 salt) { - return keccak256(abi.encode(PREFIX_INTERCHAIN_TOKEN_SALT, tokenId_)); + function _getInterchainTokenSalt(bytes32 tokenId) internal pure returns (bytes32 salt) { + return keccak256(abi.encode(PREFIX_INTERCHAIN_TOKEN_SALT, tokenId)); } /** * @notice Deploys a interchain token. - * @param tokenId_ The ID of the token + * @param tokenId The ID of the token * @param distributorBytes The distributor address for the token * @param name The name of the token * @param symbol The symbol of the token * @param decimals The number of decimals of the token */ function _deployInterchainToken( - bytes32 tokenId_, + bytes32 tokenId, bytes memory distributorBytes, string memory name, string memory symbol, uint8 decimals ) internal returns (address tokenAddress_) { - bytes32 salt = _getInterchainTokenSalt(tokenId_); - address tokenManagerAddress_ = tokenManagerAddress(tokenId_); + bytes32 salt = _getInterchainTokenSalt(tokenId); + address tokenManagerAddress_ = tokenManagerAddress(tokenId); address distributor; if (bytes(distributorBytes).length != 0) distributor = distributorBytes.toAddress(); @@ -805,7 +805,7 @@ contract InterchainTokenService is } // slither-disable-next-line reentrancy-events - emit InterchainTokenDeployed(tokenId_, tokenAddress_, distributor, name, symbol, decimals); + emit InterchainTokenDeployed(tokenId, tokenAddress_, distributor, name, symbol, decimals); } function _decodeMetadata(bytes memory metadata) internal pure returns (uint32 version, bytes memory data) { @@ -823,8 +823,8 @@ contract InterchainTokenService is } /** - * @notice Transmit a sendTokenWithData for the given tokenId_. Only callable by a token manager. - * @param tokenId_ the tokenId_ of the TokenManager (which must be the msg.sender). + * @notice Transmit a sendTokenWithData for the given tokenId. Only callable by a token manager. + * @param tokenId the tokenId of the TokenManager (which must be the msg.sender). * @param sourceAddress the address where the token is coming from, which will also be used for reimburment of gas. * @param destinationChain the name of the chain to send tokens to. * @param destinationAddress the destinationAddress for the interchainTransfer. @@ -832,7 +832,7 @@ contract InterchainTokenService is * @param metadata the data to be passed to the destiantion. */ function _transmitSendToken( - bytes32 tokenId_, + bytes32 tokenId, address sourceAddress, string calldata destinationChain, bytes memory destinationAddress, @@ -842,9 +842,9 @@ contract InterchainTokenService is bytes memory payload; if (metadata.length < 4) { // slither-disable-next-line reentrancy-events - emit TokenSent(tokenId_, destinationChain, destinationAddress, amount); + emit TokenSent(tokenId, destinationChain, destinationAddress, amount); - payload = abi.encode(SELECTOR_RECEIVE_TOKEN, tokenId_, sourceAddress.toBytes(), destinationAddress, amount); + payload = abi.encode(SELECTOR_RECEIVE_TOKEN, tokenId, sourceAddress.toBytes(), destinationAddress, amount); _callContract(destinationChain, payload, msg.value); return; @@ -854,9 +854,9 @@ contract InterchainTokenService is if (version > 0) revert InvalidMetadataVersion(version); // slither-disable-next-line reentrancy-events - emit TokenSentWithData(tokenId_, destinationChain, destinationAddress, amount, sourceAddress, metadata); + emit TokenSentWithData(tokenId, destinationChain, destinationAddress, amount, sourceAddress, metadata); - payload = abi.encode(SELECTOR_RECEIVE_TOKEN_WITH_DATA, tokenId_, sourceAddress.toBytes(), destinationAddress, amount, metadata); + payload = abi.encode(SELECTOR_RECEIVE_TOKEN_WITH_DATA, tokenId, sourceAddress.toBytes(), destinationAddress, amount, metadata); _callContract(destinationChain, payload, msg.value); } diff --git a/contracts/interfaces/IInterchainTokenService.sol b/contracts/interfaces/IInterchainTokenService.sol index 57b74cf0..9f524ba7 100644 --- a/contracts/interfaces/IInterchainTokenService.sol +++ b/contracts/interfaces/IInterchainTokenService.sol @@ -15,7 +15,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec error LengthMismatch(); error InvalidTokenManagerImplementationType(address implementation); error NotRemoteService(); - error TokenManagerDoesNotExist(bytes32 tokenId_); + error TokenManagerDoesNotExist(bytes32 tokenId); error NotTokenManager(address caller, address tokenManager); error ExecuteWithInterchainTokenFailed(address contractAddress); error InvalidCanonicalTokenId(bytes32 expectedCanonicalTokenId); @@ -29,9 +29,9 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec error UntrustedChain(string chainName); error InvalidExpressSelector(uint256 selector); - event TokenSent(bytes32 indexed tokenId_, string destinationChain, bytes destinationAddress, uint256 indexed amount); + event TokenSent(bytes32 indexed tokenId, string destinationChain, bytes destinationAddress, uint256 indexed amount); event TokenSentWithData( - bytes32 indexed tokenId_, + bytes32 indexed tokenId, string destinationChain, bytes destinationAddress, uint256 indexed amount, @@ -39,28 +39,28 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec bytes data ); event TokenReceived( - bytes32 indexed tokenId_, + bytes32 indexed tokenId, string sourceChain, bytes sourceAddress, address indexed destinationAddress, uint256 indexed amount ); event TokenReceivedWithData( - bytes32 indexed tokenId_, + bytes32 indexed tokenId, string sourceChain, bytes sourceAddress, address indexed destinationAddress, uint256 indexed amount ); event RemoteTokenManagerDeploymentInitialized( - bytes32 indexed tokenId_, + bytes32 indexed tokenId, string destinationChain, uint256 indexed gasValue, TokenManagerType indexed tokenManagerType, bytes params ); event RemoteInterchainTokenDeploymentInitialized( - bytes32 indexed tokenId_, + bytes32 indexed tokenId, string tokenName, string tokenSymbol, uint8 tokenDecimals, @@ -69,16 +69,16 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec string destinationChain, uint256 indexed gasValue ); - event TokenManagerDeployed(bytes32 indexed tokenId_, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params); + event TokenManagerDeployed(bytes32 indexed tokenId, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params); event InterchainTokenDeployed( - bytes32 indexed tokenId_, + bytes32 indexed tokenId, address tokenAddress, address indexed distributor, string name, string symbol, uint8 decimals ); - event CustomTokenIdClaimed(bytes32 indexed tokenId_, address indexed deployer, bytes32 indexed salt); + event CustomTokenIdClaimed(bytes32 indexed tokenId, address indexed deployer, bytes32 indexed salt); event PausedSet(bool indexed paused, address indexed msgSender); /** @@ -100,40 +100,40 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec function interchainTokenDeployer() external view returns (address interchainTokenDeployerAddress); /** - * @notice Returns the address of the token manager associated with the given tokenId_. - * @param tokenId_ The tokenId_ of the token manager. + * @notice Returns the address of the token manager associated with the given tokenId. + * @param tokenId The tokenId of the token manager. * @return tokenManagerAddress_ The address of the token manager. */ - function tokenManagerAddress(bytes32 tokenId_) external view returns (address tokenManagerAddress_); + function tokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_); /** - * @notice Returns the address of the valid token manager associated with the given tokenId_. - * @param tokenId_ The tokenId_ of the token manager. + * @notice Returns the address of the valid token manager associated with the given tokenId. + * @param tokenId The tokenId of the token manager. * @return tokenManagerAddress_ The address of the valid token manager. */ - function validTokenManagerAddress(bytes32 tokenId_) external view returns (address tokenManagerAddress_); + function validTokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_); /** - * @notice Returns the address of the token associated with the given tokenId_. - * @param tokenId_ The tokenId_ of the token manager. + * @notice Returns the address of the token associated with the given tokenId. + * @param tokenId The tokenId of the token manager. * @return tokenAddress_ The address of the token. */ - function tokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_); + function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_); /** - * @notice Returns the address of the standardized token associated with the given tokenId_. - * @param tokenId_ The tokenId_ of the standardized token. + * @notice Returns the address of the standardized token associated with the given tokenId. + * @param tokenId The tokenId of the standardized token. * @return tokenAddress_ The address of the standardized token. */ - function interchainTokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_); + function interchainTokenAddress(bytes32 tokenId) external view returns (address tokenAddress_); /** - * @notice Returns the custom tokenId_ associated with the given operator and salt. + * @notice Returns the custom tokenId associated with the given operator and salt. * @param operator_ The operator address. * @param salt The salt used for token id calculation. - * @return tokenId_ The custom tokenId_ associated with the operator and salt. + * @return tokenId The custom tokenId associated with the operator and salt. */ - function interchainTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId_); + function interchainTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId); /** * @notice Deploys a custom token manager contract on a remote chain. @@ -149,7 +149,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec TokenManagerType tokenManagerType, bytes calldata params, uint256 gasValue - ) external payable returns (bytes32 tokenId_); + ) external payable returns (bytes32 tokenId); /** * @notice Deploys and registers a standardized token on a remote chain. @@ -180,7 +180,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress_); function interchainTransfer( - bytes32 tokenId_, + bytes32 tokenId, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, @@ -188,7 +188,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec ) external payable; function sendTokenWithData( - bytes32 tokenId_, + bytes32 tokenId, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, @@ -197,7 +197,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec /** * @notice Initiates an interchain token transfer. Only callable by TokenManagers - * @param tokenId_ The tokenId_ of the token to be transmitted. + * @param tokenId The tokenId of the token to be transmitted. * @param sourceAddress The source address of the token. * @param destinationChain The name of the destination chain. * @param destinationAddress The destination address on the destination chain. @@ -205,7 +205,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec * @param metadata The metadata associated with the transmission. */ function transmitSendToken( - bytes32 tokenId_, + bytes32 tokenId, address sourceAddress, string calldata destinationChain, bytes memory destinationAddress, @@ -222,24 +222,24 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec /** * @notice Returns the flow limit for a specific token. - * @param tokenId_ The tokenId_ of the token. + * @param tokenId The tokenId of the token. * @return flowLimit_ The flow limit for the token. */ - function flowLimit(bytes32 tokenId_) external view returns (uint256 flowLimit_); + function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_); /** * @notice Returns the total amount of outgoing flow for a specific token. - * @param tokenId_ The tokenId_ of the token. + * @param tokenId The tokenId of the token. * @return flowOutAmount_ The total amount of outgoing flow for the token. */ - function flowOutAmount(bytes32 tokenId_) external view returns (uint256 flowOutAmount_); + function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_); /** * @notice Returns the total amount of incoming flow for a specific token. - * @param tokenId_ The tokenId_ of the token. + * @param tokenId The tokenId of the token. * @return flowInAmount_ The total amount of incoming flow for the token. */ - function flowInAmount(bytes32 tokenId_) external view returns (uint256 flowInAmount_); + function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_); /** * @notice Sets the paused state of the contract. diff --git a/contracts/proxies/TokenManagerProxy.sol b/contracts/proxies/TokenManagerProxy.sol index 8008372f..8b531620 100644 --- a/contracts/proxies/TokenManagerProxy.sol +++ b/contracts/proxies/TokenManagerProxy.sol @@ -19,13 +19,13 @@ contract TokenManagerProxy is ITokenManagerProxy { * @dev Constructs the TokenManagerProxy contract. * @param interchainTokenServiceAddress_ The address of the interchain token service * @param implementationType_ The token manager type - * @param tokenId_ The identifier for the token + * @param tokenId The identifier for the token * @param params The initialization parameters for the token manager contract */ - constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId_, bytes memory params) { + constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId, bytes memory params) { interchainTokenService = IInterchainTokenService(interchainTokenServiceAddress_); implementationType = implementationType_; - interchainTokenId = tokenId_; + interchainTokenId = tokenId; address impl = _tokenManagerImplementation(IInterchainTokenService(interchainTokenServiceAddress_), implementationType_); (bool success, bytes memory returnData) = impl.delegatecall(abi.encodeWithSelector(TokenManagerProxy.setup.selector, params)); diff --git a/docs/index.md b/docs/index.md index d78ffe42..d32fd098 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,10 +19,22 @@ address implementationLockUnlock address implementationMintBurn ``` -### implementationLiquidityPool +### implementationMintBurnFrom ```solidity -address implementationLiquidityPool +address implementationMintBurnFrom +``` + +### implementationLockUnlockFee + +```solidity +address implementationLockUnlockFee +``` + +### gateway + +```solidity +contract IAxelarGateway gateway ``` ### gasService @@ -37,6 +49,13 @@ contract IAxelarGasService gasService contract IInterchainAddressTracker interchainAddressTracker ``` +Returns the address of the interchain router contract. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | + ### tokenManagerDeployer ```solidity @@ -63,61 +82,42 @@ Returns the address of the standardized token deployer contract. | Name | Type | Description | | ---- | ---- | ----------- | -### deployer - -```solidity -contract Create3Deployer deployer -``` - ### chainNameHash ```solidity bytes32 chainNameHash ``` -### chainName - -```solidity -bytes32 chainName -``` - -### PREFIX_CUSTOM_TOKEN_ID - -```solidity -bytes32 PREFIX_CUSTOM_TOKEN_ID -``` - -### PREFIX_STANDARDIZED_TOKEN_ID +### PREFIX_TOKEN_ID ```solidity -bytes32 PREFIX_STANDARDIZED_TOKEN_ID +bytes32 PREFIX_TOKEN_ID ``` -### PREFIX_STANDARDIZED_TOKEN_SALT +### PREFIX_INTERCHAIN_TOKEN_SALT ```solidity -bytes32 PREFIX_STANDARDIZED_TOKEN_SALT +bytes32 PREFIX_INTERCHAIN_TOKEN_SALT ``` ### constructor ```solidity -constructor(address tokenManagerDeployer_, address interchainTokenDeployer_, address gateway_, address gasService_, address remoteAddressValidator_, address[] tokenManagerImplementations, string chainName_) public +constructor(address tokenManagerDeployer_, address interchainTokenDeployer_, address gateway_, address gasService_, address interchainRouter_, address[] tokenManagerImplementations) public ``` _All of the variables passed here are stored as immutable variables._ #### Parameters -| Name | Type | Description | -| --------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------- | -| tokenManagerDeployer\_ | address | the address of the TokenManagerDeployer. | -| interchainTokenDeployer\_ | address | the address of the InterchainTokenDeployer. | -| gateway\_ | address | the address of the AxelarGateway. | -| gasService\_ | address | the address of the AxelarGasService. | -| interchainAddressTracker\_ | address | the address of the InterchainAddressTracker. | -| tokenManagerImplementations | address[] | this need to have exactly 3 implementations in the following order: Lock/Unlock, mint/burn and then liquidity pool. | -| chainName\_ | string | the name of the current chain. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerDeployer_ | address | the address of the TokenManagerDeployer. | +| interchainTokenDeployer_ | address | the address of the InterchainTokenDeployer. | +| gateway_ | address | the address of the AxelarGateway. | +| gasService_ | address | the address of the AxelarGasService. | +| interchainRouter_ | address | the address of the InterchainAddressTracker. | +| tokenManagerImplementations | address[] | this needs to have implementations in the order: Mint-burn, Mint-burn from, Lock-unlock, and Lock-unlock with fee. | ### onlyRemoteService @@ -125,13 +125,13 @@ _All of the variables passed here are stored as immutable variables._ modifier onlyRemoteService(string sourceChain, string sourceAddress) ``` -This modifier is used to ensure that only a remote InterchainTokenService can \_execute this one. +This modifier is used to ensure that only a remote InterchainTokenService can _execute this one. #### Parameters -| Name | Type | Description | -| ------------- | ------ | ------------------------------------ | -| sourceChain | string | the source of the contract call. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | the source of the contract call. | | sourceAddress | string | the address that the call came from. | ### onlyTokenManager @@ -144,8 +144,8 @@ This modifier is used to ensure certain functions can only be called by TokenMan #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the `tokenId` of the TokenManager trying to perform the call. | ### contractId @@ -156,123 +156,88 @@ function contractId() external pure returns (bytes32) Getter for the contract id. -### getChainName - -```solidity -function getChainName() public view returns (string name) -``` - -Getter for the chain name. - -#### Return Values - -| Name | Type | Description | -| ---- | ------ | --------------------- | -| name | string | the name of the chain | - ### tokenManagerAddress ```solidity -function tokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress) +function tokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress_) ``` Calculates the address of a TokenManager from a specific tokenId. The TokenManager does not need to exist already. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------ | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the tokenId. | #### Return Values -| Name | Type | Description | -| ------------------- | ------- | --------------------------------------- | -| tokenManagerAddress | address | deployment address of the TokenManager. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerAddress_ | address | deployment address of the TokenManager. | ### validTokenManagerAddress ```solidity -function validTokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress) +function validTokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress_) ``` Returns the address of a TokenManager from a specific tokenId. The TokenManager needs to exist already. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------ | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the tokenId. | #### Return Values -| Name | Type | Description | -| ------------------- | ------- | --------------------------------------- | -| tokenManagerAddress | address | deployment address of the TokenManager. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerAddress_ | address | deployment address of the TokenManager. | ### tokenAddress ```solidity -function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress) +function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_) ``` Returns the address of the token that an existing tokenManager points to. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------ | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the tokenId. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| tokenAddress | address | the address of the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress_ | address | the address of the token. | ### interchainTokenAddress ```solidity -function interchainTokenAddress(bytes32 tokenId) public view returns (address tokenAddress) +function interchainTokenAddress(bytes32 tokenId) public view returns (address tokenAddress_) ``` -Returns the address of the standardized token that would be deployed with a given tokenId. +Returns the address of the interchain token that would be deployed with a given tokenId. The token does not need to exist. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------ | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the tokenId. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | -------------------------------------- | -| tokenAddress | address | the address of the standardized token. | - -### canonicalTokenId - -```solidity -function canonicalinterchainTokenId(address tokenAddress) public view returns (bytes32 tokenId) -``` - -Calculates the tokenId that would correspond to a canonical link for a given token. -This will depend on what chain it is called from, unlike custom tokenIds. - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| tokenAddress | address | the address of the token. | - -#### Return Values - -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------------------------------------------ | -| tokenId | bytes32 | the tokenId that the canonical TokenManager would get (or has gotten) for the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress_ | address | the address of the interchain token. | -### tokenId +### interchainTokenId ```solidity function interchainTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId) @@ -283,21 +248,21 @@ This will not depend on what chain it is called from, unlike canonical tokenIds. #### Parameters -| Name | Type | Description | -| ------ | ------- | --------------------------------------------------- | -| sender | address | the address of the TokenManager deployer. | -| salt | bytes32 | the salt that the deployer uses for the deployment. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sender | address | the address of the TokenManager deployer. | +| salt | bytes32 | the salt that the deployer uses for the deployment. | #### Return Values -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the tokenId that the custom TokenManager would get (or has gotten). | ### tokenManagerImplementation ```solidity -function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress) +function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address) ``` Getter function for TokenManager implementations. This will mainly be called by TokenManagerProxies @@ -305,299 +270,203 @@ to figure out their implementations #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ----------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenManagerType | uint256 | the type of the TokenManager. | #### Return Values -| Name | Type | Description | -| ------------------- | ------- | ---------------------------------------------- | -| tokenManagerAddress | address | the address of the TokenManagerImplementation. | - -### paramsLockUnlock - -```solidity -function paramsLockUnlock(bytes operator, address tokenAddress) public pure returns (bytes params) -``` - -Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | --------------------------------- | -| operator | bytes | the operator of the TokenManager. | -| tokenAddress | address | the token to be managed. | - -#### Return Values - -| Name | Type | Description | -| ------ | ----- | --------------------------------------------------------------------- | -| params | bytes | the resulting params to be passed to custom TokenManager deployments. | - -### paramsMintBurn - -```solidity -function paramsMintBurn(bytes operator, address tokenAddress) public pure returns (bytes params) -``` - -Getter function for the parameters of a mint/burn TokenManager. Mainly to be used by frontends. - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | --------------------------------- | -| operator | bytes | the operator of the TokenManager. | -| tokenAddress | address | the token to be managed. | - -#### Return Values - -| Name | Type | Description | -| ------ | ----- | --------------------------------------------------------------------- | -| params | bytes | the resulting params to be passed to custom TokenManager deployments. | - -### paramsLiquidityPool - -```solidity -function paramsLiquidityPool(bytes operator, address tokenAddress, address liquidityPoolAddress) public pure returns (bytes params) -``` - -Getter function for the parameters of a liquidity pool TokenManager. Mainly to be used by frontends. - -#### Parameters - -| Name | Type | Description | -| -------------------- | ------- | ---------------------------------------------------------- | -| operator | bytes | the operator of the TokenManager. | -| tokenAddress | address | the token to be managed. | -| liquidityPoolAddress | address | the liquidity pool to be used to store the bridged tokens. | - -#### Return Values - -| Name | Type | Description | -| ------ | ----- | --------------------------------------------------------------------- | -| params | bytes | the resulting params to be passed to custom TokenManager deployments. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | address | tokenManagerAddress the address of the TokenManagerImplementation. | ### flowLimit ```solidity -function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit) +function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_) ``` Getter function for the flow limit of an existing token manager with a give token ID. #### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the token ID of the TokenManager. | #### Return Values -| Name | Type | Description | -| --------- | ------- | --------------- | -| flowLimit | uint256 | the flow limit. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | the flow limit. | ### flowOutAmount ```solidity -function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount) +function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_) ``` Getter function for the flow out amount of an existing token manager with a give token ID. #### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the token ID of the TokenManager. | #### Return Values -| Name | Type | Description | -| ------------- | ------- | -------------------- | -| flowOutAmount | uint256 | the flow out amount. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowOutAmount_ | uint256 | the flow out amount. | ### flowInAmount ```solidity -function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount) +function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_) ``` Getter function for the flow in amount of an existing token manager with a give token ID. #### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | the token ID of the TokenManager. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | ------------------- | -| flowInAmount | uint256 | the flow in amount. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowInAmount_ | uint256 | the flow in amount. | -### registerCanonicalToken +### deployTokenManager ```solidity -function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId) +function deployTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) ``` -Used to register canonical tokens. Caller does not matter. - -#### Parameters +Used to deploy remote custom TokenManagers. -| Name | Type | Description | -| ------------ | ------- | ------------------------ | -| tokenAddress | address | the token to be bridged. | +_`gasValue` exists because this function can be part of a multicall involving multiple functions +that could make remote contract calls._ -#### Return Values +#### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------------------------- | -| tokenId | bytes32 | the tokenId that was used for this canonical token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| salt | bytes32 | the salt to be used. | +| destinationChain | string | the name of the chain to deploy the TokenManager and interchain token to. | +| tokenManagerType | enum ITokenManagerType.TokenManagerType | the type of TokenManager to be deployed. | +| params | bytes | the params that will be used to initialize the TokenManager. | +| gasValue | uint256 | the amount of native tokens to be used to pay for gas for the remote deployment. At least the amount specified needs to be passed to the call | -### deployRemoteCanonicalToken +### deployInterchainToken ```solidity -function deployRemoteCanonicalToken(bytes32 tokenId, string destinationChain, uint256 gasValue) public payable +function deployInterchainToken(bytes32 salt, string destinationChain, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, uint256 gasValue) external payable ``` -Used to deploy remote TokenManagers and standardized tokens for a canonical token. This needs to be -called from the chain that registered the canonical token, and anyone can call it. +Used to deploy a interchain token alongside a TokenManager in another chain. If the `distributor` is empty +bytes then a mint/burn TokenManager is used. Otherwise a lock/unlock TokenManager is used. _`gasValue` exists because this function can be part of a multicall involving multiple functions that could make remote contract calls._ #### Parameters -| Name | Type | Description | -| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -| tokenId | bytes32 | the tokenId of the canonical token. | -| destinationChain | string | the name of the chain to deploy the TokenManager and standardized token to. | -| gasValue | uint256 | the amount of native tokens to be used to pay for gas for the remote deployment. At least the amount specified needs to be passed to the call | +| Name | Type | Description | +| ---- | ---- | ----------- | +| salt | bytes32 | the salt to be used. | +| destinationChain | string | the name of the destination chain to deploy to. | +| name | string | the name of the token to be deployed. | +| symbol | string | the symbol of the token to be deployed. | +| decimals | uint8 | the decimals of the token to be deployed. | +| distributor | bytes | the address that will be able to mint and burn the deployed token. | +| operator | bytes | | +| gasValue | uint256 | the amount of native tokens to be used to pay for gas for the remote deployment. At least the amount specified needs to be passed to the call | -### deployCustomTokenManager +### contractCallValue ```solidity -function deployCustomTokenManager(bytes32 salt, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params) public payable returns (bytes32 tokenId) +function contractCallValue(string sourceChain, string sourceAddress, bytes payload) public view virtual returns (address, uint256) ``` -Used to deploy custom TokenManagers with the specified salt. Different callers would result in different tokenIds. +_Returns the value (token address and amount) associated with a contract call_ #### Parameters -| Name | Type | Description | -| ---------------- | --------------------------------------- | ------------------------------------------------------------ | -| salt | bytes32 | the salt to be used. | -| tokenManagerType | enum ITokenManagerType.TokenManagerType | the type of TokenManager to be deployed. | -| params | bytes | the params that will be used to initialize the TokenManager. | - -### deployTokenManager - -```solidity -function deployTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) -``` - -Used to deploy remote custom TokenManagers. - -_`gasValue` exists because this function can be part of a multicall involving multiple functions -that could make remote contract calls._ +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | The source blockchain. | +| sourceAddress | string | The source address. | +| payload | bytes | The payload data. | -#### Parameters +#### Return Values -| Name | Type | Description | -| ---------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -| salt | bytes32 | the salt to be used. | -| destinationChain | string | the name of the chain to deploy the TokenManager and standardized token to. | -| tokenManagerType | enum ITokenManagerType.TokenManagerType | the type of TokenManager to be deployed. | -| params | bytes | the params that will be used to initialize the TokenManager. | -| gasValue | uint256 | the amount of native tokens to be used to pay for gas for the remote deployment. At least the amount specified needs to be passed to the call | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | address | | +| [1] | uint256 | | -### deployAndRegisterStandardizedToken +### expressExecute ```solidity -function deployAndRegisterStandardizedToken(bytes32 salt, string name, string symbol, uint8 decimals, uint256 mintAmount, address distributor) external payable +function expressExecute(bytes32 commandId, string sourceChain, string sourceAddress, bytes payload) external payable ``` -Used to deploy a standardized token alongside a TokenManager. If the `distributor` is the address of the TokenManager (which -can be calculated ahead of time) then a mint/burn TokenManager is used. Otherwise a lock/unlock TokenManager is used. +Express executes a contract call. #### Parameters -| Name | Type | Description | -| ----------- | ------- | ------------------------------------------------------------------ | -| salt | bytes32 | the salt to be used. | -| name | string | the name of the token to be deployed. | -| symbol | string | the symbol of the token to be deployed. | -| decimals | uint8 | the decimals of the token to be deployed. | -| mintAmount | uint256 | the amount of token to be mint during deployment to msg.sender. | -| distributor | address | the address that will be able to mint and burn the deployed token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| commandId | bytes32 | The commandId for the contractCall. | +| sourceChain | string | The source chain. | +| sourceAddress | string | The source address. | +| payload | bytes | The payload data. | -### deployInterchainToken +### _expressExecute ```solidity -function deployInterchainToken(bytes32 salt, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) external payable +function _expressExecute(string sourceChain, bytes payload) internal ``` -Used to deploy a standardized token alongside a TokenManager in another chain. If the `distributor` is empty -bytes then a mint/burn TokenManager is used. Otherwise a lock/unlock TokenManager is used. +Uses the caller's tokens to fullfill a sendCall ahead of time. Use this only if you have detected an outgoing +interchainTransfer that matches the parameters passed here. -_`gasValue` exists because this function can be part of a multicall involving multiple functions that could make remote contract calls._ +_This is not to be used with fee on transfer tokens as it will incur losses for the express caller._ #### Parameters -| Name | Type | Description | -| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -| salt | bytes32 | the salt to be used. | -| name | string | the name of the token to be deployed. | -| symbol | string | the symbol of the token to be deployed. | -| decimals | uint8 | the decimals of the token to be deployed. | -| distributor | bytes | the address that will be able to mint and burn the deployed token. | -| operator | bytes | | -| destinationChain | string | the name of the destination chain to deploy to. | -| gasValue | uint256 | the amount of native tokens to be used to pay for gas for the remote deployment. At least the amount specified needs to be passed to the call | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | the name of the chain where the interchainTransfer originated from. | +| payload | bytes | the payload of the receive token | -### expressReceiveToken +### interchainTransfer ```solidity -function expressReceiveToken(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId) external +function interchainTransfer(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable ``` -Uses the caller's tokens to fullfill a sendCall ahead of time. Use this only if you have detected an outgoing -interchainTransfer that matches the parameters passed here. +Transfer a token interchain. #### Parameters -| Name | Type | Description | -| ------------------ | ------- | -------------------------------------------------- | -| tokenId | bytes32 | the tokenId of the TokenManager used. | -| destinationAddress | address | the destinationAddress for the interchainTransfer. | -| amount | uint256 | the amount of token to give. | -| commandId | bytes32 | the sendHash detected at the sourceChain. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | the tokenId for the token link. | +| destinationChain | string | the name of the chain to send the token to. | +| destinationAddress | bytes | the recipient of the interchain transfer. | +| amount | uint256 | the amount of token to give. | +| metadata | bytes | the data to be passed to the destination. If provided with a bytes4(0) prefix, it'll execute the destination contract. | -### expressReceiveTokenWithData +### sendTokenWithData ```solidity -function expressReceiveTokenWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId) external +function sendTokenWithData(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, bytes data) external payable ``` -Uses the caller's tokens to fullfill a callContractWithInterchainToken ahead of time. Use this only if you have -detected an outgoing interchainTransfer that matches the parameters passed here. - -#### Parameters - -| Name | Type | Description | -| ------------------ | ------- | ----------------------------------------------------------------------------------- | -| tokenId | bytes32 | the tokenId of the TokenManager used. | -| sourceChain | string | the name of the chain where the call came from. | -| sourceAddress | bytes | the caller of callContractWithInterchainToken. | -| destinationAddress | address | the destinationAddress for the interchainTransfer. | -| amount | uint256 | the amount of token to give. | -| data | bytes | the data to be passed to destinationAddress after giving them the tokens specified. | -| commandId | bytes32 | the sendHash detected at the sourceChain. | - ### transmitSendToken ```solidity @@ -608,29 +477,29 @@ Transmit a sendTokenWithData for the given tokenId. Only callable by a token man #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------------------------------------------------------------- | -| tokenId | bytes32 | the tokenId of the TokenManager (which must be the msg.sender). | -| sourceAddress | address | the address where the token is coming from, which will also be used for reimbursement of gas. | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the destinationAddress for the interchainTransfer. | -| amount | uint256 | the amount of token to give. | -| metadata | bytes | the data to be passed to the destination. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | the tokenId of the TokenManager (which must be the msg.sender). | +| sourceAddress | address | the address where the token is coming from, which will also be used for reimbursement of gas. | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the destinationAddress for the interchainTransfer. | +| amount | uint256 | the amount of token to give. | +| metadata | bytes | the data to be passed to the destination. | -### setFlowLimit +### setFlowLimits ```solidity -function setFlowLimit(bytes32[] tokenIds, uint256[] flowLimits) external +function setFlowLimits(bytes32[] tokenIds, uint256[] flowLimits) external ``` Used to set a flow limit for a token manager that has the service as its operator. #### Parameters -| Name | Type | Description | -| ---------- | --------- | ------------------------------------------------------------------------ | -| tokenIds | bytes32[] | an array of the token Ids of the tokenManagers to set the flow limit of. | -| flowLimits | uint256[] | the flowLimits to set | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenIds | bytes32[] | an array of the token Ids of the tokenManagers to set the flow limit of. | +| flowLimits | uint256[] | the flowLimits to set | ### setPaused @@ -642,69 +511,75 @@ Used to pause the entire service. #### Parameters -| Name | Type | Description | -| ------ | ---- | ---------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | paused | bool | what value to set paused to. | -### \_setup +### _setup ```solidity function _setup(bytes params) internal ``` -### \_sanitizeTokenManagerImplementation +### _sanitizeTokenManagerImplementation ```solidity -function _sanitizeTokenManagerImplementation(address[] implementations, enum ITokenManagerType.TokenManagerType tokenManagerType) internal pure returns (address implementation) +function _sanitizeTokenManagerImplementation(address[] tokenManagerImplementations, enum ITokenManagerType.TokenManagerType tokenManagerType) internal pure returns (address implementation_) ``` -### \_execute +### execute ```solidity -function _execute(string sourceChain, string sourceAddress, bytes payload) internal +function execute(bytes32 commandId, string sourceChain, string sourceAddress, bytes payload) external ``` Executes operations based on the payload and selector. #### Parameters -| Name | Type | Description | -| ------------- | ------ | ------------------------------------------------- | -| sourceChain | string | The chain where the transaction originates from | -| sourceAddress | string | The address where the transaction originates from | -| payload | bytes | The encoded data payload for the transaction | +| Name | Type | Description | +| ---- | ---- | ----------- | +| commandId | bytes32 | | +| sourceChain | string | The chain where the transaction originates from | +| sourceAddress | string | The address of the remote ITS where the transaction originates from | +| payload | bytes | The encoded data payload for the transaction | -### \_processSendTokenPayload +### contractCallWithTokenValue ```solidity -function _processSendTokenPayload(string sourceChain, bytes payload) internal +function contractCallWithTokenValue(string, string, bytes, string, uint256) public view virtual returns (address, uint256) ``` -Processes the payload data for a send token call +### expressExecuteWithToken -#### Parameters +```solidity +function expressExecuteWithToken(bytes32, string, string, bytes, string, uint256) external payable +``` -| Name | Type | Description | -| ----------- | ------ | ----------------------------------------------- | -| sourceChain | string | The chain where the transaction originates from | -| payload | bytes | The encoded data payload to be processed | +### executeWithToken + +```solidity +function executeWithToken(bytes32, string, string, bytes, string, uint256) external pure +``` -### \_processSendTokenWithDataPayload +### _processReceiveTokenPayload ```solidity -function _processSendTokenWithDataPayload(string sourceChain, bytes payload) internal +function _processReceiveTokenPayload(address expressExecutor, string sourceChain, bytes payload, uint256 selector) internal ``` -Processes a send token with data payload. +Processes the payload data for a send token call #### Parameters -| Name | Type | Description | -| ----------- | ------ | ----------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | +| expressExecutor | address | | | sourceChain | string | The chain where the transaction originates from | -| payload | bytes | The encoded data payload to be processed | +| payload | bytes | The encoded data payload to be processed | +| selector | uint256 | | -### \_processDeployTokenManagerPayload +### _processDeployTokenManagerPayload ```solidity function _processDeployTokenManagerPayload(bytes payload) internal @@ -714,48 +589,47 @@ Processes a deploy token manager payload. #### Parameters -| Name | Type | Description | -| ------- | ----- | ---------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | payload | bytes | The encoded data payload to be processed | -### \_processDeployStandardizedTokenAndManagerPayload +### _processDeployInterchainTokenPayload ```solidity -function _processDeployStandardizedTokenAndManagerPayload(bytes payload) internal +function _processDeployInterchainTokenPayload(bytes payload) internal ``` -Process a deploy standardized token and manager payload. +Process a deploy interchain token and manager payload. #### Parameters -| Name | Type | Description | -| ------- | ----- | ---------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | payload | bytes | The encoded data payload to be processed | -### \_callContract +### _callContract ```solidity -function _callContract(string destinationChain, bytes payload, uint256 gasValue, address refundTo) internal +function _callContract(string destinationChain, bytes payload, uint256 gasValue) internal ``` Calls a contract on a specific destination chain with the given payload #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------------------------------- | -| destinationChain | string | The target chain where the contract will be called | -| payload | bytes | The data payload for the transaction | -| gasValue | uint256 | The amount of gas to be paid for the transaction | -| refundTo | address | The address where the unused gas amount should be refunded to | +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | The target chain where the contract will be called | +| payload | bytes | The data payload for the transaction | +| gasValue | uint256 | The amount of gas to be paid for the transaction | -### \_validateToken +### _validateToken ```solidity -function _validateToken(address tokenAddress) internal returns (string name, string symbol, uint8 decimals) +function _validateToken(address tokenAddress_) internal view returns (string name, string symbol, uint8 decimals) ``` -### \_deployRemoteTokenManager +### _deployRemoteTokenManager ```solidity function _deployRemoteTokenManager(bytes32 tokenId, string destinationChain, uint256 gasValue, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params) internal @@ -765,36 +639,36 @@ Deploys a token manager on a destination chain. #### Parameters -| Name | Type | Description | -| ---------------- | --------------------------------------- | ------------------------------------------------------ | -| tokenId | bytes32 | The ID of the token | -| destinationChain | string | The chain where the token manager will be deployed | -| gasValue | uint256 | The amount of gas to be paid for the transaction | -| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of token manager to be deployed | -| params | bytes | Additional parameters for the token manager deployment | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The ID of the token | +| destinationChain | string | The chain where the token manager will be deployed | +| gasValue | uint256 | The amount of gas to be paid for the transaction | +| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of token manager to be deployed | +| params | bytes | Additional parameters for the token manager deployment | -### \_deployRemoteStandardizedToken +### _deployRemoteInterchainToken ```solidity -function _deployRemoteStandardizedToken(bytes32 tokenId, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) internal +function _deployRemoteInterchainToken(bytes32 tokenId, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) internal ``` -Deploys a standardized token on a destination chain. +Deploys a interchain token on a destination chain. #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------------------------ | -| tokenId | bytes32 | The ID of the token | -| name | string | The name of the token | -| symbol | string | The symbol of the token | -| decimals | uint8 | The number of decimals of the token | -| distributor | bytes | The distributor address for the token | -| operator | bytes | | -| destinationChain | string | The destination chain where the token will be deployed | -| gasValue | uint256 | The amount of gas to be paid for the transaction | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The ID of the token | +| name | string | The name of the token | +| symbol | string | The symbol of the token | +| decimals | uint8 | The number of decimals of the token | +| distributor | bytes | The distributor address for the token | +| operator | bytes | | +| destinationChain | string | The destination chain where the token will be deployed | +| gasValue | uint256 | The amount of gas to be paid for the transaction | -### \_deployTokenManager +### _deployTokenManager ```solidity function _deployTokenManager(bytes32 tokenId, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params) internal @@ -804,228 +678,276 @@ Deploys a token manager #### Parameters -| Name | Type | Description | -| ---------------- | --------------------------------------- | ------------------------------------------------------ | -| tokenId | bytes32 | The ID of the token | -| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of the token manager to be deployed | -| params | bytes | Additional parameters for the token manager deployment | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The ID of the token | +| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of the token manager to be deployed | +| params | bytes | Additional parameters for the token manager deployment | -### \_getStandardizedTokenSalt +### _getInterchainTokenSalt ```solidity -function _getStandardizedTokenSalt(bytes32 tokenId) internal pure returns (bytes32 salt) +function _getInterchainTokenSalt(bytes32 tokenId) internal pure returns (bytes32 salt) ``` -Compute the salt for a standardized token deployment. +Compute the salt for a interchain token deployment. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The ID of the token | #### Return Values -| Name | Type | Description | -| ---- | ------- | ------------------------------------------ | +| Name | Type | Description | +| ---- | ---- | ----------- | | salt | bytes32 | The computed salt for the token deployment | -### \_deployInterchainToken +### _deployInterchainToken ```solidity -function _deployInterchainToken(bytes32 tokenId, address distributor, string name, string symbol, uint8 decimals, uint256 mintAmount, address mintTo) internal +function _deployInterchainToken(bytes32 tokenId, bytes distributorBytes, string name, string symbol, uint8 decimals) internal returns (address tokenAddress_) ``` -Deploys a standardized token. +Deploys a interchain token. #### Parameters -| Name | Type | Description | -| ----------- | ------- | ---------------------------------------------------------------- | -| tokenId | bytes32 | The ID of the token | -| distributor | address | The distributor address for the token | -| name | string | The name of the token | -| symbol | string | The symbol of the token | -| decimals | uint8 | The number of decimals of the token | -| mintAmount | uint256 | The amount of tokens to be minted upon deployment | -| mintTo | address | The address where the minted tokens will be sent upon deployment | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The ID of the token | +| distributorBytes | bytes | The distributor address for the token | +| name | string | The name of the token | +| symbol | string | The symbol of the token | +| decimals | uint8 | The number of decimals of the token | -### \_decodeMetadata +### _decodeMetadata ```solidity function _decodeMetadata(bytes metadata) internal pure returns (uint32 version, bytes data) ``` -### \_expressExecuteWithInterchainTokenToken +### _transmitSendToken ```solidity -function _expressExecuteWithInterchainTokenToken(bytes32 tokenId, address destinationAddress, string sourceChain, bytes sourceAddress, bytes data, uint256 amount) internal +function _transmitSendToken(bytes32 tokenId, address sourceAddress, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) internal ``` -## IERC20Named +Transmit a sendTokenWithData for the given tokenId. Only callable by a token manager. -_Interface of the ERC20 standard as defined in the EIP._ +#### Parameters -### name +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | the tokenId of the TokenManager (which must be the msg.sender). | +| sourceAddress | address | the address where the token is coming from, which will also be used for reimburment of gas. | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the destinationAddress for the interchainTransfer. | +| amount | uint256 | the amount of token to give. | +| metadata | bytes | the data to be passed to the destiantion. | + +## IDistributable + +### transferDistributorship ```solidity -function name() external returns (string) +function transferDistributorship(address distributor_) external ``` -Getter for the name of the token +Change the distributor of the contract -### symbol +_Can only be called by the current distributor_ -```solidity -function symbol() external returns (string) -``` +#### Parameters -Getter for the symbol of the token +| Name | Type | Description | +| ---- | ---- | ----------- | +| distributor_ | address | The address of the new distributor | -### decimals +### proposeDistributorship ```solidity -function decimals() external returns (uint8) +function proposeDistributorship(address distributor_) external ``` -Getter for the decimals of the token +Proposed a change of the distributor of the contract -## IExpressCallHandler +_Can only be called by the current distributor_ -### AlreadyExpressCalled +#### Parameters -```solidity -error AlreadyExpressCalled(address prevExpressCaller, address expressCaller) -``` +| Name | Type | Description | +| ---- | ---- | ----------- | +| distributor_ | address | The address of the new distributor | -### ExpressReceive +### acceptDistributorship ```solidity -event ExpressReceive(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 sendHash, address expressCaller) +function acceptDistributorship(address fromDistributor) external ``` -### ExpressExecutionFulfilled +Accept a change of the distributor of the contract -```solidity -event ExpressExecutionFulfilled(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 sendHash, address expressCaller) -``` +_Can only be called by the proposed distributor_ -### ExpressReceiveWithData +### isDistributor ```solidity -event ExpressReceiveWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 sendHash, address expressCaller) +function isDistributor(address addr) external view returns (bool) ``` -### ExpressExecutionWithDataFulfilled +Query if an address is a distributor -```solidity -event ExpressExecutionWithDataFulfilled(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 sendHash, address expressCaller) -``` +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| addr | address | the address to query for | + +## IERC20BurnableFrom + +_Interface of the ERC20 standard as defined in the EIP._ -### getExpressReceiveToken +### burnFrom ```solidity -function getExpressReceiveToken(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId) external view returns (address expressCaller) +function burnFrom(address from, uint256 amount) external ``` -Gets the address of the express caller for a specific token transfer +Function to burn tokens +Requires the caller to have allowance for `amount` on `from` + +_Can only be called by the distributor address._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| destinationAddress | address | The address of the recipient | -| amount | uint256 | The amount of tokens to be sent | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | The address that will have its tokens burnt | +| amount | uint256 | The amount of tokens to burn | -#### Return Values +## IERC20MintableBurnable -| Name | Type | Description | -| ------------- | ------- | --------------------------------------------------------- | -| expressCaller | address | The address of the express caller for this token transfer | +_Interface of the ERC20 standard as defined in the EIP._ -### getExpressReceiveTokenWithData +### mint ```solidity -function getExpressReceiveTokenWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId) external view returns (address expressCaller) +function mint(address to, uint256 amount) external ``` -Gets the address of the express caller for a specific token transfer with data +Function to mint new tokens + +_Can only be called by the distributor address._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | -------------------------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| sourceChain | string | The chain from which the token will be sent | -| sourceAddress | bytes | The originating address of the token on the source chain | -| destinationAddress | address | The address of the recipient on the destination chain | -| amount | uint256 | The amount of tokens to be sent | -| data | bytes | The data associated with the token transfer | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| to | address | The address that will receive the minted tokens | +| amount | uint256 | The amount of tokens to mint | + +### burn -#### Return Values +```solidity +function burn(address from, uint256 amount) external +``` + +Function to burn tokens + +_Can only be called by the distributor address._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | The address that will have its tokens burnt | +| amount | uint256 | The amount of tokens to burn | + +## IERC20Named + +_Interface of the ERC20 standard as defined in the EIP._ + +### name + +```solidity +function name() external view returns (string) +``` + +Getter for the name of the token + +### symbol + +```solidity +function symbol() external view returns (string) +``` + +Getter for the symbol of the token + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` -| Name | Type | Description | -| ------------- | ------- | --------------------------------------------------------- | -| expressCaller | address | The address of the express caller for this token transfer | +Getter for the decimals of the token ## IFlowLimit ### FlowLimitExceeded ```solidity -error FlowLimitExceeded(bytes32 tokenId, uint256 limit, uint256 flowAmount) +error FlowLimitExceeded(uint256 limit, uint256 flowAmount) ``` ### FlowLimitSet ```solidity -event FlowLimitSet(bytes32 indexed tokenId, address operator, uint256 flowLimit) +event FlowLimitSet(bytes32 tokenId, address operator, uint256 flowLimit_) ``` ### flowLimit ```solidity -function flowLimit() external view returns (uint256 flowLimit) +function flowLimit() external view returns (uint256 flowLimit_) ``` Returns the current flow limit #### Return Values -| Name | Type | Description | -| --------- | ------- | ---------------------------- | -| flowLimit | uint256 | The current flow limit value | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | The current flow limit value | ### flowOutAmount ```solidity -function flowOutAmount() external view returns (uint256 flowOutAmount) +function flowOutAmount() external view returns (uint256 flowOutAmount_) ``` Returns the current flow out amount #### Return Values -| Name | Type | Description | -| ------------- | ------- | --------------------------- | -| flowOutAmount | uint256 | The current flow out amount | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowOutAmount_ | uint256 | The current flow out amount | ### flowInAmount ```solidity -function flowInAmount() external view returns (uint256 flowInAmount) +function flowInAmount() external view returns (uint256 flowInAmount_) ``` Returns the current flow in amount #### Return Values -| Name | Type | Description | -| ------------ | ------- | -------------------------- | -| flowInAmount | uint256 | The current flow in amount | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowInAmount_ | uint256 | The current flow in amount | ## IImplementation @@ -1035,6 +957,146 @@ Returns the current flow in amount error NotProxy() ``` +### setup + +```solidity +function setup(bytes params) external +``` + +Called by the proxy to setup itself. + +_This should be hidden by the proxy._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params | bytes | the data to be used for the initialization. | + +## IInterchainToken + +_Interface of the ERC20 standard as defined in the EIP._ + +### tokenManager + +```solidity +function tokenManager() external view returns (contract ITokenManager tokenManager_) +``` + +Getter for the tokenManager used for this token. + +_Needs to be overwitten._ + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManager_ | contract ITokenManager | the TokenManager called to facilitate cross chain transfers. | + +### interchainTransfer + +```solidity +function interchainTransfer(string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable +``` + +Implementation of the interchainTransfer method + +_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. +A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | The destination chain identifier. | +| recipient | bytes | The bytes representation of the address of the recipient. | +| amount | uint256 | The amount of token to be transferred. | +| metadata | bytes | Either empty, to just facilitate an interchain transfer, or the data can be passed for an interchain contract call with transfer as per semantics defined by the token service. | + +### interchainTransferFrom + +```solidity +function interchainTransferFrom(address sender, string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable +``` + +Implementation of the interchainTransferFrom method + +_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. +A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| sender | address | the sender of the tokens. They need to have approved `msg.sender` before this is called. | +| destinationChain | string | the string representation of the destination chain. | +| recipient | bytes | the bytes representation of the address of the recipient. | +| amount | uint256 | the amount of token to be transferred. | +| metadata | bytes | either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer. | + +## IInterchainTokenDeployer + +This contract is used to deploy new instances of the StandardizedTokenProxy contract. + +### AddressZero + +```solidity +error AddressZero() +``` + +### TokenDeploymentFailed + +```solidity +error TokenDeploymentFailed() +``` + +### implementationAddress + +```solidity +function implementationAddress() external view returns (address) +``` + +Returns the standardized token implementation address + +### deployedAddress + +```solidity +function deployedAddress(bytes32 salt) external view returns (address tokenAddress) +``` + +Returns the standardized token deployment address. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress | address | the token address. | + +### deployInterchainToken + +```solidity +function deployInterchainToken(bytes32 salt, address tokenManager, address distributor, string name, string symbol, uint8 decimals) external payable returns (address tokenAddress) +``` + +Deploys a new instance of the StandardizedTokenProxy contract + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| salt | bytes32 | The salt used by Create3Deployer | +| tokenManager | address | Address of the token manager | +| distributor | address | Address of the distributor | +| name | string | Name of the token | +| symbol | string | Symbol of the token | +| decimals | uint8 | Decimals of the token | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress | address | Address of the deployed token | + ## IInterchainTokenExecutable Implement this to accept calls from the InterchainTokenService. @@ -1042,22 +1104,23 @@ Implement this to accept calls from the InterchainTokenService. ### executeWithInterchainToken ```solidity -function executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, uint256 amount) external +function executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) external returns (bytes32) ``` This will be called after the tokens arrive to this contract -_You are revert unless the msg.sender is the InterchainTokenService_ +_Executable should revert unless the msg.sender is the InterchainTokenService_ #### Parameters -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------------------------------------------------------- | -| sourceChain | string | the name of the source chain | -| sourceAddress | bytes | the address that sent the contract call | -| data | bytes | the data to be proccessed | -| tokenId | bytes32 | the tokenId of the token manager managing the token. You can access it's address by querying the service | -| amount | uint256 | the amount of token that was sent | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | the name of the source chain | +| sourceAddress | bytes | the address that sent the contract call | +| data | bytes | the data to be processed | +| tokenId | bytes32 | the tokenId of the token manager managing the token. | +| token | address | the address of the token. | +| amount | uint256 | the amount of token that was sent | ## IInterchainTokenExpressExecutable @@ -1066,22 +1129,23 @@ Implement this to accept express calls from the InterchainTokenService. ### expressExecuteWithInterchainToken ```solidity -function expressExecuteWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, uint256 amount) external +function expressExecuteWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) external returns (bytes32) ``` This will be called after the tokens arrive to this contract -_You are revert unless the msg.sender is the InterchainTokenService_ +_Executable should revert unless the msg.sender is the InterchainTokenService_ #### Parameters -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------------------------------------------------------- | -| sourceChain | string | the name of the source chain | -| sourceAddress | bytes | the address that sent the contract call | -| data | bytes | the data to be proccessed | -| tokenId | bytes32 | the tokenId of the token manager managing the token. You can access it's address by querying the service | -| amount | uint256 | the amount of token that was sent | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | the name of the source chain | +| sourceAddress | bytes | the address that sent the contract call | +| data | bytes | the data to be processed | +| tokenId | bytes32 | the token id of the token manager managing the token. | +| token | address | the address of the token. | +| amount | uint256 | the amount of token that was sent | ## IInterchainTokenService @@ -1118,7 +1182,7 @@ error TokenManagerDoesNotExist(bytes32 tokenId) ### NotTokenManager ```solidity -error NotTokenManager(address caller, address tokenManager); +error NotTokenManager(address caller, address tokenManager) ``` ### ExecuteWithInterchainTokenFailed @@ -1130,7 +1194,13 @@ error ExecuteWithInterchainTokenFailed(address contractAddress) ### InvalidCanonicalTokenId ```solidity -error InvalidCanonicalTokenId(bytes32 expectedCanonicalTokenId); +error InvalidCanonicalTokenId(bytes32 expectedCanonicalTokenId) +``` + +### ExpressExecuteWithInterchainTokenFailed + +```solidity +error ExpressExecuteWithInterchainTokenFailed(address contractAddress) ``` ### GatewayToken @@ -1163,10 +1233,22 @@ error SelectorUnknown(uint256 selector) error InvalidMetadataVersion(uint32 version) ``` -### AlreadyExecuted +### ExecuteWithTokenNotSupported + +```solidity +error ExecuteWithTokenNotSupported() +``` + +### UntrustedChain + +```solidity +error UntrustedChain(string chainName) +``` + +### InvalidExpressSelector ```solidity -error AlreadyExecuted(bytes32 commandId) +error InvalidExpressSelector(uint256 selector) ``` ### TokenSent @@ -1184,13 +1266,13 @@ event TokenSentWithData(bytes32 tokenId, string destinationChain, bytes destinat ### TokenReceived ```solidity -event TokenReceived(bytes32 tokenId, string sourceChain, address destinationAddress, uint256 amount) +event TokenReceived(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount) ``` ### TokenReceivedWithData ```solidity -event TokenReceivedWithData(bytes32 tokenId, string sourceChain, address destinationAddress, uint256 amount, bytes sourceAddress, bytes data) +event TokenReceivedWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount) ``` ### RemoteTokenManagerDeploymentInitialized @@ -1208,13 +1290,13 @@ event RemoteInterchainTokenDeploymentInitialized(bytes32 tokenId, string tokenNa ### TokenManagerDeployed ```solidity -event TokenManagerDeployed(bytes32 tokenId, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params) +event TokenManagerDeployed(bytes32 tokenId, address tokenManager, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params) ``` ### InterchainTokenDeployed ```solidity -event InterchainTokenDeployed(bytes32 indexed tokenId, address tokenAddress, address indexed distributor, string name, string symbol, uint8 decimals, uint256 indexed mintAmount, address mintTo) +event InterchainTokenDeployed(bytes32 tokenId, address tokenAddress, address distributor, string name, string symbol, uint8 decimals) ``` ### CustomTokenIdClaimed @@ -1223,369 +1305,226 @@ event InterchainTokenDeployed(bytes32 indexed tokenId, address tokenAddress, add event CustomTokenIdClaimed(bytes32 tokenId, address deployer, bytes32 salt) ``` -### tokenManagerDeployer +### PausedSet ```solidity -function tokenManagerDeployer() external view returns (address tokenManagerDeployerAddress) +event PausedSet(bool paused, address msgSender) ``` -Returns the address of the token manager deployer contract. +### interchainAddressTracker + +```solidity +function interchainAddressTracker() external view returns (contract IInterchainAddressTracker interchainAddressTracker_) +``` + +Returns the address of the interchain router contract. #### Return Values -| Name | Type | Description | -| --------------------------- | ------- | --------------------------------------------------- | -| tokenManagerDeployerAddress | address | The address of the token manager deployer contract. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainAddressTracker_ | contract IInterchainAddressTracker | The interchainAddressTracker. | -### interchainTokenDeployer +### tokenManagerDeployer ```solidity -function interchainTokenDeployer() external view returns (address interchainTokenDeployerAddress) +function tokenManagerDeployer() external view returns (address tokenManagerDeployerAddress) ``` -Returns the address of the standardized token deployer contract. +Returns the address of the token manager deployer contract. #### Return Values -| Name | Type | Description | -| -------------------------------- | ------- | -------------------------------------------------------- | -| interchainTokenDeployerAddress | address | The address of the standardized token deployer contract. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerDeployerAddress | address | The address of the token manager deployer contract. | -### getChainName +### interchainTokenDeployer ```solidity -function getChainName() external view returns (string name) +function interchainTokenDeployer() external view returns (address interchainTokenDeployerAddress) ``` -Returns the name of the current chain. +Returns the address of the standardized token deployer contract. #### Return Values -| Name | Type | Description | -| ---- | ------ | ------------------------------ | -| name | string | The name of the current chain. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenDeployerAddress | address | The address of the standardized token deployer contract. | ### tokenManagerAddress ```solidity -function tokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress) +function tokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_) ``` Returns the address of the token manager associated with the given tokenId. #### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the token manager. | #### Return Values -| Name | Type | Description | -| ------------------- | ------- | --------------------------------- | -| tokenManagerAddress | address | The address of the token manager. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerAddress_ | address | The address of the token manager. | ### validTokenManagerAddress ```solidity -function validTokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress) +function validTokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_) ``` Returns the address of the valid token manager associated with the given tokenId. #### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the token manager. | #### Return Values -| Name | Type | Description | -| ------------------- | ------- | --------------------------------------- | -| tokenManagerAddress | address | The address of the valid token manager. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerAddress_ | address | The address of the valid token manager. | ### tokenAddress ```solidity -function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress) +function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_) ``` Returns the address of the token associated with the given tokenId. #### Parameters -| Name | Type | Description | -| ------- | ------- | --------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the token manager. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| tokenAddress | address | The address of the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress_ | address | The address of the token. | ### interchainTokenAddress ```solidity -function interchainTokenAddress(bytes32 tokenId) external view returns (address tokenAddress) +function interchainTokenAddress(bytes32 tokenId) external view returns (address tokenAddress_) ``` Returns the address of the standardized token associated with the given tokenId. #### Parameters -| Name | Type | Description | -| ------- | ------- | -------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the standardized token. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | -------------------------------------- | -| tokenAddress | address | The address of the standardized token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress_ | address | The address of the standardized token. | -### canonicalTokenId +### interchainTokenId ```solidity -function canonicalinterchainTokenId(address tokenAddress) external view returns (bytes32 tokenId) +function interchainTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId) ``` -Returns the canonical tokenId associated with the given tokenAddress. +Returns the custom tokenId associated with the given operator and salt. #### Parameters -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| tokenAddress | address | The address of the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | address | The operator address. | +| salt | bytes32 | The salt used for token id calculation. | #### Return Values -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------------- | -| tokenId | bytes32 | The canonical tokenId associated with the tokenAddress. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The custom tokenId associated with the operator and salt. | -### tokenId +### deployTokenManager ```solidity -function interchainTokenId(address operator, bytes32 salt) external view returns (bytes32 tokenId) +function deployTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) ``` -Returns the custom tokenId associated with the given operator and salt. +Deploys a custom token manager contract on a remote chain. #### Parameters -| Name | Type | Description | -| -------- | ------- | --------------------------------------- | -| operator | address | The operator address. | -| salt | bytes32 | The salt used for token id calculation. | - -#### Return Values - -| Name | Type | Description | -| ------- | ------- | --------------------------------------------------------- | -| tokenId | bytes32 | The custom tokenId associated with the operator and salt. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| salt | bytes32 | The salt used for token manager deployment. | +| destinationChain | string | The name of the destination chain. | +| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of token manager. | +| params | bytes | The deployment parameters. | +| gasValue | uint256 | The gas value for deployment. | -### paramsLockUnlock +### deployInterchainToken ```solidity -function paramsLockUnlock(bytes operator, address tokenAddress) external pure returns (bytes params) +function deployInterchainToken(bytes32 salt, string destinationChain, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, uint256 gasValue) external payable ``` -Returns the parameters for the lock/unlock operation. - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| operator | bytes | The operator address. | -| tokenAddress | address | The address of the token. | - -#### Return Values - -| Name | Type | Description | -| ------ | ----- | --------------------------------------------- | -| params | bytes | The parameters for the lock/unlock operation. | - -### paramsMintBurn - -```solidity -function paramsMintBurn(bytes operator, address tokenAddress) external pure returns (bytes params) -``` - -Returns the parameters for the mint/burn operation. - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| operator | bytes | The operator address. | -| tokenAddress | address | The address of the token. | - -#### Return Values - -| Name | Type | Description | -| ------ | ----- | ------------------------------------------- | -| params | bytes | The parameters for the mint/burn operation. | - -### paramsLiquidityPool - -```solidity -function paramsLiquidityPool(bytes operator, address tokenAddress, address liquidityPoolAddress) external pure returns (bytes params) -``` - -Returns the parameters for the liquidity pool operation. - -#### Parameters - -| Name | Type | Description | -| -------------------- | ------- | ---------------------------------- | -| operator | bytes | The operator address. | -| tokenAddress | address | The address of the token. | -| liquidityPoolAddress | address | The address of the liquidity pool. | - -#### Return Values - -| Name | Type | Description | -| ------ | ----- | ------------------------------------------------ | -| params | bytes | The parameters for the liquidity pool operation. | - -### registerCanonicalToken - -```solidity -function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId) -``` - -Registers a canonical token and returns its associated tokenId. - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ----------------------------------- | -| tokenAddress | address | The address of the canonical token. | - -#### Return Values - -| Name | Type | Description | -| ------- | ------- | ----------------------------------------------------------- | -| tokenId | bytes32 | The tokenId associated with the registered canonical token. | - -### deployRemoteCanonicalToken - -```solidity -function deployRemoteCanonicalToken(bytes32 tokenId, string destinationChain, uint256 gasValue) external payable -``` - -Deploys a standardized canonical token on a remote chain. +Deploys and registers a standardized token on a remote chain. #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ----------------------------------- | -| tokenId | bytes32 | The tokenId of the canonical token. | -| destinationChain | string | The name of the destination chain. | -| gasValue | uint256 | The gas value for deployment. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| salt | bytes32 | The salt used for token deployment. | +| destinationChain | string | The name of the destination chain. Use '' for this chain. | +| name | string | The name of the standardized tokens. | +| symbol | string | The symbol of the standardized tokens. | +| decimals | uint8 | The number of decimals for the standardized tokens. | +| distributor | bytes | The distributor data for mint/burn operations. | +| operator | bytes | | +| gasValue | uint256 | The gas value for deployment. | -### deployCustomTokenManager +### tokenManagerImplementation ```solidity -function deployCustomTokenManager(bytes32 salt, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params) external payable returns (bytes32 tokenId) +function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress_) ``` -Deploys a custom token manager contract. +Returns the implementation address for a given token manager type. #### Parameters -| Name | Type | Description | -| ---------------- | --------------------------------------- | ------------------------------------------- | -| salt | bytes32 | The salt used for token manager deployment. | -| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of token manager. | -| params | bytes | The deployment parameters. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerType | uint256 | The type of token manager. | #### Return Values -| Name | Type | Description | -| ------- | ------- | ------------------------------------------ | -| tokenId | bytes32 | The tokenId of the deployed token manager. | - -### deployTokenManager - -```solidity -function deployTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) -``` - -Deploys a custom token manager contract on a remote chain. - -#### Parameters - -| Name | Type | Description | -| ---------------- | --------------------------------------- | ------------------------------------------- | -| salt | bytes32 | The salt used for token manager deployment. | -| destinationChain | string | The name of the destination chain. | -| tokenManagerType | enum ITokenManagerType.TokenManagerType | The type of token manager. | -| params | bytes | The deployment parameters. | -| gasValue | uint256 | The gas value for deployment. | - -### deployAndRegisterStandardizedToken - -```solidity -function deployAndRegisterStandardizedToken(bytes32 salt, string name, string symbol, uint8 decimals, uint256 mintAmount, address distributor) external payable -``` - -Deploys a standardized token and registers it. The token manager type will be lock/unlock unless the distributor matches its address, in which case it will be a mint/burn one. - -#### Parameters - -| Name | Type | Description | -| ----------- | ------- | -------------------------------------------------------- | -| salt | bytes32 | The salt used for token deployment. | -| name | string | The name of the standardized token. | -| symbol | string | The symbol of the standardized token. | -| decimals | uint8 | The number of decimals for the standardized token. | -| mintAmount | uint256 | The amount of tokens to mint to the deployer. | -| distributor | address | The address of the distributor for mint/burn operations. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManagerAddress_ | address | The address of the token manager implementation. | -### deployInterchainToken +### interchainTransfer ```solidity -function deployInterchainToken(bytes32 salt, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) external payable +function interchainTransfer(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable ``` -Deploys and registers a standardized token on a remote chain. - -#### Parameters - -| Name | Type | Description | -| ---------------- | ------- | --------------------------------------------------- | -| salt | bytes32 | The salt used for token deployment. | -| name | string | The name of the standardized tokens. | -| symbol | string | The symbol of the standardized tokens. | -| decimals | uint8 | The number of decimals for the standardized tokens. | -| distributor | bytes | The distributor data for mint/burn operations. | -| operator | bytes | The operator data for standardized tokens. | -| destinationChain | string | The name of the destination chain. | -| gasValue | uint256 | The gas value for deployment. | - -### tokenManagerImplementation +### sendTokenWithData ```solidity -function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress) +function sendTokenWithData(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, bytes data) external payable ``` -Returns the implementation address for a given token manager type. - -#### Parameters - -| Name | Type | Description | -| ---------------- | ------- | -------------------------- | -| tokenManagerType | uint256 | The type of token manager. | - -#### Return Values - -| Name | Type | Description | -| ------------------- | ------- | ------------------------------------------------ | -| tokenManagerAddress | address | The address of the token manager implementation. | - ### transmitSendToken ```solidity @@ -1596,89 +1535,89 @@ Initiates an interchain token transfer. Only callable by TokenManagers #### Parameters -| Name | Type | Description | -| ------------------ | ------- | ------------------------------------------------- | -| tokenId | bytes32 | The tokenId of the token to be transmitted. | -| sourceAddress | address | The source address of the token. | -| destinationChain | string | The name of the destination chain. | -| destinationAddress | bytes | The destination address on the destination chain. | -| amount | uint256 | The amount of tokens to transmit. | -| metadata | bytes | The metadata associated with the transmission. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The tokenId of the token to be transmitted. | +| sourceAddress | address | The source address of the token. | +| destinationChain | string | The name of the destination chain. | +| destinationAddress | bytes | The destination address on the destination chain. | +| amount | uint256 | The amount of tokens to transmit. | +| metadata | bytes | The metadata associated with the transmission. | -### setFlowLimit +### setFlowLimits ```solidity -function setFlowLimit(bytes32[] tokenIds, uint256[] flowLimits) external +function setFlowLimits(bytes32[] tokenIds, uint256[] flowLimits) external ``` Sets the flow limits for multiple tokens. #### Parameters -| Name | Type | Description | -| ---------- | --------- | ------------------------------------------------------ | -| tokenIds | bytes32[] | An array of tokenIds. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenIds | bytes32[] | An array of tokenIds. | | flowLimits | uint256[] | An array of flow limits corresponding to the tokenIds. | ### flowLimit ```solidity -function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit) +function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_) ``` Returns the flow limit for a specific token. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the token. | #### Return Values -| Name | Type | Description | -| --------- | ------- | ----------------------------- | -| flowLimit | uint256 | The flow limit for the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | The flow limit for the token. | ### flowOutAmount ```solidity -function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount) +function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_) ``` Returns the total amount of outgoing flow for a specific token. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the token. | #### Return Values -| Name | Type | Description | -| ------------- | ------- | ------------------------------------------------ | -| flowOutAmount | uint256 | The total amount of outgoing flow for the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowOutAmount_ | uint256 | The total amount of outgoing flow for the token. | ### flowInAmount ```solidity -function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount) +function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_) ``` Returns the total amount of incoming flow for a specific token. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | tokenId | bytes32 | The tokenId of the token. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | ------------------------------------------------ | -| flowInAmount | uint256 | The total amount of incoming flow for the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowInAmount_ | uint256 | The total amount of incoming flow for the token. | ### setPaused @@ -1690,153 +1629,150 @@ Sets the paused state of the contract. #### Parameters -| Name | Type | Description | -| ------ | ---- | ------------------------------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | paused | bool | The boolean value indicating whether the contract is paused or not. | -### expressReceiveToken +## IOperatable + +### transferOperatorship ```solidity -function expressReceiveToken(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId) external +function transferOperatorship(address operator_) external ``` -Uses the caller's tokens to fullfill a sendCall ahead of time. Use this only if you have detected an outgoing interchainTransfer that matches the parameters passed here. +Change the operator of the contract + +_Can only be called by the current operator_ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | ----------------------------------------------------------- | -| tokenId | bytes32 | the tokenId of the TokenManager used. | -| destinationAddress | address | the destinationAddress for the interchainTransfer. | -| amount | uint256 | the amount of token to give. | -| commandId | bytes32 | the commandId calculated from the event at the sourceChain. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | address | The address of the new operator | -### expressReceiveTokenWithData +### proposeOperatorship ```solidity -function expressReceiveTokenWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId) external +function proposeOperatorship(address operator_) external ``` -Uses the caller's tokens to fullfill a callContractWithInterchainToken ahead of time. Use this only if you have detected an outgoing interchainTransfer that matches the parameters passed here. +Proposed a change of the operator of the contract + +_Can only be called by the current operator_ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | ----------------------------------------------------------------------------------- | -| tokenId | bytes32 | the tokenId of the TokenManager used. | -| sourceChain | string | the name of the chain where the call came from. | -| sourceAddress | bytes | the caller of callContractWithInterchainToken. | -| destinationAddress | address | the destinationAddress for the interchainTransfer. | -| amount | uint256 | the amount of token to give. | -| data | bytes | the data to be passed to destinationAddress after giving them the tokens specified. | -| commandId | bytes32 | the commandId calculated from the event at the sourceChain. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | address | The address of the new operator | + +### acceptOperatorship + +```solidity +function acceptOperatorship(address fromOperator) external +``` -## IMulticall +Accept a proposed change of operatorship -This contract is a multi-functional smart contract which allows for multiple -contract calls in a single transaction. +_Can only be called by the proposed operator_ -### multicall +### isOperator ```solidity -function multicall(bytes[] data) external payable returns (bytes[] results) +function isOperator(address addr) external view returns (bool) ``` -Performs multiple delegate calls and returns the results of all calls as an array - -_This function requires that the contract has sufficient balance for the delegate calls. -If any of the calls fail, the function will revert with the failure message._ +Query if an address is a operator #### Parameters -| Name | Type | Description | -| ---- | ------- | ---------------------------------- | -| data | bytes[] | An array of encoded function calls | - -#### Return Values +| Name | Type | Description | +| ---- | ---- | ----------- | +| addr | address | the address to query for | -| Name | Type | Description | -| ------- | ------- | --------------------------------------------------------- | -| results | bytes[] | An bytes array with the return data of each function call | +## IStandardizedToken -## IOperatable +This contract implements a standardized token which extends InterchainToken functionality. +This contract also inherits Distributable and Implementation logic. -### NotOperator +### TokenManagerAddressZero ```solidity -error NotOperator(address caller) +error TokenManagerAddressZero() ``` -### OperatorshipTransferred +### TokenNameEmpty ```solidity -event OperatorshipTransferred(address operator) +error TokenNameEmpty() ``` -### operator +### setup ```solidity -function operator() external view returns (address operator_) +function setup(bytes params) external ``` -Get the address of the operator +Called by the proxy to setup itself. -#### Return Values +_This should be hidden by the proxy._ -| Name | Type | Description | -| ---------- | ------- | --------------- | -| operator\_ | address | of the operator | +#### Parameters -### transferOperatorship +| Name | Type | Description | +| ---- | ---- | ----------- | +| params | bytes | the data to be used for the initialization. | + +### tokenManager ```solidity -function transferOperatorship(address operator_) external +function tokenManager() external view returns (contract ITokenManager tokenManager_) ``` -Change the operator of the contract +Getter for the tokenManager used for this token. -_Can only be called by the current operator_ +_Needs to be overwitten._ -#### Parameters +#### Return Values -| Name | Type | Description | -| ---------- | ------- | ------------------------------- | -| operator\_ | address | The address of the new operator | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManager_ | contract ITokenManager | the TokenManager called to facilitate cross chain transfers. | -## IPausable +## ITokenManager -This contract provides a mechanism to halt the execution of specific functions -if a pause condition is activated. +This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. -### PausedSet +### TokenLinkerZeroAddress ```solidity -event PausedSet(bool paused) +error TokenLinkerZeroAddress() ``` -### Pause +### NotService ```solidity -error Pause() +error NotService(address caller) ``` -### isPaused +### TakeTokenFailed ```solidity -function isPaused() external view returns (bool) +error TakeTokenFailed() ``` -Check if the contract is paused - -#### Return Values +### GiveTokenFailed -| Name | Type | Description | -| ---- | ---- | -------------------------------------------------------------------------------- | -| [0] | bool | paused A boolean representing the pause status. True if paused, false otherwise. | +```solidity +error GiveTokenFailed() +``` -## IInterchainAddressTracker +### NotToken -_Manages and validates remote addresses, keeps track of addresses supported by the Axelar gateway contract_ +```solidity +error NotToken(address caller) +``` ### ZeroAddress @@ -1844,157 +1780,160 @@ _Manages and validates remote addresses, keeps track of addresses supported by t error ZeroAddress() ``` -### LengthMismatch +### AlreadyFlowLimiter ```solidity -error LengthMismatch() +error AlreadyFlowLimiter(address flowLimiter) ``` -### ZeroStringLength +### NotFlowLimiter ```solidity -error ZeroStringLength() +error NotFlowLimiter(address flowLimiter) ``` -### TrustedAddressAdded +### interchainTokenId ```solidity -event TrustedAddressAdded(string sourceChain, string sourceAddress) +function interchainTokenId() external view returns (bytes32) ``` -### TrustedAddressRemoved +A function that returns the token id. + +### tokenAddress ```solidity -event TrustedAddressRemoved(string sourceChain) +function tokenAddress() external view returns (address) ``` -### GatewaySupportedChainAdded +A function that should return the address of the token. +Must be overridden in the inheriting contract. + +#### Return Values -```solidity -event GatewaySupportedChainAdded(string chain) -``` +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | address | address address of the token. | -### GatewaySupportedChainRemoved +### implementationType ```solidity -event GatewaySupportedChainRemoved(string chain) +function implementationType() external pure returns (uint256) ``` -### validateSender +A function that should return the implementation type of the token manager. + +### interchainTransfer ```solidity -function validateSender(string sourceChain, string sourceAddress) external view returns (bool) +function interchainTransfer(string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable ``` -_Validates that the sender is a valid interchain token service address_ +Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. #### Parameters -| Name | Type | Description | -| ------------- | ------ | --------------------------------- | -| sourceChain | string | Source chain of the transaction | -| sourceAddress | string | Source address of the transaction | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ----------------------------------------------------- | -| [0] | bool | bool true if the sender is validated, false otherwise | +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the address of the user to send tokens to. | +| amount | uint256 | the amount of tokens to take from msg.sender. | +| metadata | bytes | any additional data to be sent with the transfer. | -### addTrustedAddress +### callContractWithInterchainToken ```solidity -function addTrustedAddress(string sourceChain, string sourceAddress) external +function callContractWithInterchainToken(string destinationChain, bytes destinationAddress, uint256 amount, bytes data) external payable ``` -_Adds a trusted interchain token service address for the specified chain_ +Calls the service to initiate a cross-chain transfer with data after taking the appropriate amount of tokens from the user. #### Parameters -| Name | Type | Description | -| ------------- | ------ | -------------------------------------------- | -| sourceChain | string | Chain name of the interchain token service | -| sourceAddress | string | Interchain token service address to be added | +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the address of the user to send tokens to. | +| amount | uint256 | the amount of tokens to take from msg.sender. | +| data | bytes | the data to pass to the destination contract. | -### removeTrustedAddress +### transmitInterchainTransfer ```solidity -function removeTrustedAddress(string sourceChain) external +function transmitInterchainTransfer(address sender, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable ``` -_Removes a trusted interchain token service address_ +Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. This can only be called by the token itself. #### Parameters -| Name | Type | Description | -| ----------- | ------ | -------------------------------------------------------- | -| sourceChain | string | Chain name of the interchain token service to be removed | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sender | address | the address of the user paying for the cross chain transfer. | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the address of the user to send tokens to. | +| amount | uint256 | the amount of tokens to take from msg.sender. | +| metadata | bytes | any additional data to be sent with the transfer. | -### getRemoteAddress +### giveToken ```solidity -function getRemoteAddress(string chainName) external view returns (string remoteAddress) +function giveToken(address destinationAddress, uint256 amount) external returns (uint256) ``` -_Fetches the interchain token service address for the specified chain_ +This function gives token to a specified address. Can only be called by the service. #### Parameters -| Name | Type | Description | -| --------- | ------ | ----------------- | -| chainName | string | Name of the chain | +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationAddress | address | the address to give tokens to. | +| amount | uint256 | the amount of token to give. | #### Return Values -| Name | Type | Description | -| ------------- | ------ | -------------------------------------------------------- | -| remoteAddress | string | Interchain token service address for the specified chain | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | the amount of token actually given, which will only be different than `amount` in cases where the token takes some on-transfer fee. | -### supportedByGateway +### takeToken ```solidity -function supportedByGateway(string chainName) external view returns (bool) +function takeToken(address sourceAddress, uint256 amount) external returns (uint256) ``` -Returns true if the gateway delivers token to this chain. +This function takes token to from a specified address. Can only be called by the service. #### Parameters -| Name | Type | Description | -| --------- | ------ | ----------------- | -| chainName | string | Name of the chain | - -### addGatewaySupportedChains - -```solidity -function addGatewaySupportedChains(string[] chainNames) external -``` - -_Adds chains that are supported by the Axelar gateway_ +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceAddress | address | the address to take tokens from. | +| amount | uint256 | the amount of token to take. | -#### Parameters +#### Return Values -| Name | Type | Description | -| ---------- | -------- | -------------------------------------------- | -| chainNames | string[] | List of chain names to be added as supported | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | the amount of token actually taken, which will onle be differen than `amount` in cases where the token takes some on-transfer fee. | -### removeGatewaySupportedChains +### setFlowLimit ```solidity -function removeGatewaySupportedChains(string[] chainNames) external +function setFlowLimit(uint256 flowLimit_) external ``` -_Removes chains that are no longer supported by the Axelar gateway_ +This function sets the flow limit for this TokenManager. Can only be called by the operator. #### Parameters -| Name | Type | Description | -| ---------- | -------- | ---------------------------------------------- | -| chainNames | string[] | List of chain names to be removed as supported | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | the maximum difference between the tokens flowing in and/or out at any given interval of time (6h) | -## IInterchainTokenDeployer +## ITokenManagerDeployer -This contract is used to deploy new instances of the StandardizedTokenProxy contract. +This contract is used to deploy new instances of the TokenManagerProxy contract. ### AddressZero @@ -2002,236 +1941,137 @@ This contract is used to deploy new instances of the StandardizedTokenProxy cont error AddressZero() ``` -### TokenDeploymentFailed +### TokenManagerDeploymentFailed ```solidity -error TokenDeploymentFailed() +error TokenManagerDeploymentFailed() ``` -### deployer +### deployTokenManager ```solidity -function deployer() external view returns (contract Create3Deployer) +function deployTokenManager(bytes32 tokenId, uint256 implementationType, bytes params) external payable returns (address tokenManager) ``` -Getter for the Create3Deployer. +Deploys a new instance of the TokenManagerProxy contract -### deployInterchainToken +#### Parameters -```solidity -function deployInterchainToken(bytes32 salt, address tokenManager, address distributor, string name, string symbol, uint8 decimals, uint256 mintAmount, address mintTo) external payable returns (address tokenAddress) -``` - -Deploys a new instance of the StandardizedTokenProxy contract - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ---------------------------------- | -| salt | bytes32 | The salt used by Create3Deployer | -| tokenManager | address | Address of the token manager | -| distributor | address | Address of the distributor | -| name | string | Name of the token | -| symbol | string | Symbol of the token | -| decimals | uint8 | Decimals of the token | -| mintAmount | uint256 | Amount of tokens to mint initially | -| mintTo | address | Address to mint initial tokens to | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The unique identifier for the token | +| implementationType | uint256 | Token manager implementation type | +| params | bytes | Additional parameters used in the setup of the token manager | #### Return Values -| Name | Type | Description | -| ------------ | ------- | --------------------- | -| tokenAddress | address | address of the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManager | address | Address of the deployed tokenManager | -## ITokenManager +## ITokenManagerLiquidityPool This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. -### TokenLinkerZeroAddress - -```solidity -error TokenLinkerZeroAddress() -``` - -### NotService - -```solidity -error NotService(address caller) -``` - -### TakeTokenFailed - -```solidity -error TakeTokenFailed() -``` - -### GiveTokenFailed - -```solidity -error GiveTokenFailed() -``` - -### NotToken +### params ```solidity -error NotToken(address caller) +function params(bytes operator_, address tokenAddress_, address liquidityPool_) external pure returns (bytes params_) ``` -### tokenAddress +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. -```solidity -function tokenAddress() external view returns (address) -``` +#### Parameters -A function that should return the address of the token. -Must be overridden in the inheriting contract. +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | +| liquidityPool_ | address | he address of the liquidity pool. | #### Return Values -| Name | Type | Description | -| ---- | ------- | ----------------------------- | -| [0] | address | address address of the token. | - -### implementationType - -```solidity -function implementationType() external pure returns (uint256) -``` - -A function that should return the implementation type of the token manager. +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | -### interchainTransfer +### liquidityPool ```solidity -function interchainTransfer(string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable +function liquidityPool() external view returns (address liquidityPool_) ``` -Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. +_Reads the stored liquidity pool address from the specified storage slot_ -#### Parameters +#### Return Values -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------------- | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the address of the user to send tokens to. | -| amount | uint256 | the amount of tokens to take from msg.sender. | -| metadata | bytes | | +| Name | Type | Description | +| ---- | ---- | ----------- | +| liquidityPool_ | address | The address of the liquidity pool | -### callContractWithInterchainToken +### setLiquidityPool ```solidity -function callContractWithInterchainToken(string destinationChain, bytes destinationAddress, uint256 amount, bytes data) external payable +function setLiquidityPool(address newLiquidityPool) external ``` -Calls the service to initiate a cross-chain transfer with data after taking the appropriate amount of tokens from the user. +_Updates the address of the liquidity pool. Can only be called by the operator._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------------- | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the address of the user to send tokens to. | -| amount | uint256 | the amount of tokens to take from msg.sender. | -| data | bytes | the data to pass to the destination contract. | - -### transmitInterchainTransfer - -```solidity -function transmitInterchainTransfer(address sender, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable -``` - -Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. This can only be called by the token itself. +| Name | Type | Description | +| ---- | ---- | ----------- | +| newLiquidityPool | address | The new address of the liquidity pool | -#### Parameters +## ITokenManagerLockUnlock -| Name | Type | Description | -| ------------------ | ------- | ------------------------------------------------------------ | -| sender | address | the address of the user paying for the cross chain transfer. | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the address of the user to send tokens to. | -| amount | uint256 | the amount of tokens to take from msg.sender. | -| metadata | bytes | | +This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. -### giveToken +### params ```solidity -function giveToken(address destinationAddress, uint256 amount) external returns (uint256) +function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_) ``` -This function gives token to a specified address. Can only be called by the service. +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. #### Parameters -| Name | Type | Description | -| ------------------ | ------- | ------------------------------ | -| destinationAddress | address | the address to give tokens to. | -| amount | uint256 | the amount of token to give. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | #### Return Values -| Name | Type | Description | -| ---- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| [0] | uint256 | the amount of token actually given, which will only be different than `amount` in cases where the token takes some on-transfer fee. | - -### setFlowLimit - -```solidity -function setFlowLimit(uint256 flowLimit) external -``` - -This function sets the flow limit for this TokenManager. Can only be called by the operator. - -#### Parameters - -| Name | Type | Description | -| --------- | ------- | -------------------------------------------------------------------------------------------------- | -| flowLimit | uint256 | the maximum difference between the tokens flowing in and/or out at any given interval of time (6h) | - -## ITokenManagerDeployer - -This contract is used to deploy new instances of the TokenManagerProxy contract. - -### AddressZero - -```solidity -error AddressZero() -``` - -### TokenManagerDeploymentFailed - -```solidity -error TokenManagerDeploymentFailed() -``` - -### deployer +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | -```solidity -function deployer() external view returns (contract Create3Deployer) -``` +## ITokenManagerMintBurn -Getter for the Create3Deployer. +This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. -### deployTokenManager +### params ```solidity -function deployTokenManager(bytes32 tokenId, uint256 implementationType, bytes params) external payable returns(address tokenManager) +function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_) ``` -Deploys a new instance of the TokenManagerProxy contract +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. #### Parameters -| Name | Type | Description | -| ------------------ | ------- | ------------------------------------------------------------ | -| tokenId | bytes32 | The unique identifier for the token | -| implementationType | uint256 | Token manager implementation type | -| params | bytes | Additional parameters used in the setup of the token manager | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | #### Return Values -| Name | Type | Description | -| ------------ | ------- | ---------------------------------------- | -| tokenManager | address | the address of the deployed tokenManager | +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | ## ITokenManagerProxy @@ -2247,7 +2087,13 @@ error ImplementationLookupFailed() ### SetupFailed ```solidity -error SetupFailed(bytes error) +error SetupFailed(bytes returnData) +``` + +### NativeTokenNotAccepted + +```solidity +error NativeTokenNotAccepted() ``` ### implementationType @@ -2268,11 +2114,11 @@ Returns the address of the current implementation. #### Return Values -| Name | Type | Description | -| ---- | ------- | ---------------------------------------------- | -| [0] | address | impl The address of the current implementation | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | address | impl The address of the current implementation | -### tokenId +### interchainTokenId ```solidity function interchainTokenId() external view returns (bytes32) @@ -2288,1103 +2134,1743 @@ A simple interface that defines all the token manager types ```solidity enum TokenManagerType { - LOCK_UNLOCK, - MINT_BURN, - LIQUIDITY_POOL + MINT_BURN, + MINT_BURN_FROM, + LOCK_UNLOCK, + LOCK_UNLOCK_FEE } ``` -## AddressBytesUtils - -_This library provides utility functions to convert between `address` and `bytes`._ +## ITokenRegistrar -### InvalidBytesLength +### ZeroAddress ```solidity -error InvalidBytesLength(bytes bytesAddress) +error ZeroAddress() ``` -### toAddress +### NotDistributor ```solidity -function toAddress(bytes bytesAddress) internal pure returns (address addr) +error NotDistributor(address distributor) ``` -_Converts a bytes address to an address type._ - -#### Parameters - -| Name | Type | Description | -| ------------ | ----- | -------------------------------------- | -| bytesAddress | bytes | The bytes representation of an address | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | --------------------- | -| addr | address | The converted address | - -### toBytes +### NotOperator ```solidity -function toBytes(address addr) internal pure returns (bytes bytesAddress) +error NotOperator(address operator) ``` -_Converts an address to bytes._ - -#### Parameters +### NonZeroMintAmount -| Name | Type | Description | -| ---- | ------- | --------------------------- | -| addr | address | The address to be converted | +```solidity +error NonZeroMintAmount() +``` -#### Return Values +### ApproveFailed -| Name | Type | Description | -| ------------ | ----- | --------------------------------------- | -| bytesAddress | bytes | The bytes representation of the address | +```solidity +error ApproveFailed() +``` -## InterchainAddressTracker +### chainNameHash -_Manages and validates remote addresses, keeps track of addresses supported by the Axelar gateway contract_ +```solidity +function chainNameHash() external view returns (bytes32) +``` -### remoteAddressHashes +### standardizedTokenSalt ```solidity -mapping(string => bytes32) remoteAddressHashes +function standardizedTokenSalt(bytes32 chainAddressHash_, address deployer, bytes32 salt) external view returns (bytes32) ``` -### remoteAddresses +### standardizedinterchainTokenId ```solidity -mapping(string => string) remoteAddresses +function standardizedinterchainTokenId(address deployer, bytes32 salt) external view returns (bytes32 tokenId) ``` -### interchainTokenServiceAddress +### interchainTokenAddress ```solidity -address interchainTokenServiceAddress +function interchainTokenAddress(address deployer, bytes32 salt) external view returns (address tokenAddress) ``` -### interchainTokenServiceAddressHash +### deployInterchainToken ```solidity -bytes32 interchainTokenServiceAddressHash +function deployInterchainToken(bytes32 salt, string name, string symbol, uint8 decimals, uint256 mintAmount, address distributor, address operator) external payable ``` -### supportedByGateway +### deployRemoteInterchainToken ```solidity -mapping(string => bool) supportedByGateway +function deployRemoteInterchainToken(string originalChainName, bytes32 salt, address additionalDistributor, address optionalOperator, string destinationChain, uint256 gasValue) external payable ``` -Returns true if the gateway delivers token to this chain. - -#### Parameters +### canonicalTokenSalt -| Name | Type | Description | -| ---- | ---- | ----------- | +```solidity +function canonicalTokenSalt(bytes32 chainAddressHash_, address tokenAddress) external view returns (bytes32 salt) +``` -### constructor +### canonicalinterchainTokenId ```solidity -constructor(address _interchainTokenServiceAddress) public +function canonicalinterchainTokenId(address tokenAddress) external view returns (bytes32 tokenId) ``` -_Constructs the InterchainAddressTracker contract, both array parameters must be equal in length_ - -#### Parameters +### registerCanonicalToken -| Name | Type | Description | -| ------------------------------- | ------- | --------------------------------------- | -| \_interchainTokenServiceAddress | address | Address of the interchain token service | +```solidity +function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId) +``` -### contractId +### deployRemoteCanonicalToken ```solidity -function contractId() external pure returns (bytes32) +function deployRemoteCanonicalToken(string originalChainName, address originalAddress, string destinationChain, uint256 gasValue) external payable ``` -Getter for the contract id. - -### \_setup +### interchainTransfer ```solidity -function _setup(bytes params) internal +function interchainTransfer(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, uint256 gasValue) external payable ``` -### \_lowerCase +### interchainTransferFrom ```solidity -function _lowerCase(string s) internal pure returns (string) +function interchainTransferFrom(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, uint256 gasValue) external payable ``` -_Converts a string to lower case_ +## TokenManagerProxy -#### Parameters +This contract is a proxy for token manager contracts. -| Name | Type | Description | -| ---- | ------ | ---------------------------- | -| s | string | Input string to be converted | +_It implements ITokenManagerProxy._ -#### Return Values +### interchainTokenService -| Name | Type | Description | -| ---- | ------ | -------------------------------------------- | -| [0] | string | string lowercase version of the input string | +```solidity +contract IInterchainTokenService interchainTokenService +``` -### validateSender +### implementationType ```solidity -function validateSender(string sourceChain, string sourceAddress) external view returns (bool) +uint256 implementationType ``` -_Validates that the sender is a valid interchain token service address_ - -#### Parameters +Returns implementation type of this token manager -| Name | Type | Description | -| ------------- | ------ | --------------------------------- | -| sourceChain | string | Source chain of the transaction | -| sourceAddress | string | Source address of the transaction | +### interchainTokenId -#### Return Values +```solidity +bytes32 interchainTokenId +``` -| Name | Type | Description | -| ---- | ---- | ----------------------------------------------------- | -| [0] | bool | bool true if the sender is validated, false otherwise | +Returns token ID of the token manager. -### addTrustedAddress +### constructor ```solidity -function addTrustedAddress(string chain, string addr) public +constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId, bytes params) public ``` -_Adds a trusted interchain token service address for the specified chain_ +_Constructs the TokenManagerProxy contract._ #### Parameters -| Name | Type | Description | -| ----- | ------ | -------------------------------------------- | -| chain | string | Chain name of the interchain token service | -| addr | string | Interchain token service address to be added | +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenServiceAddress_ | address | The address of the interchain token service | +| implementationType_ | uint256 | The token manager type | +| tokenId | bytes32 | The identifier for the token | +| params | bytes | The initialization parameters for the token manager contract | -### removeTrustedAddress +### implementation ```solidity -function removeTrustedAddress(string chain) external +function implementation() public view returns (address impl) ``` -_Removes a trusted interchain token service address_ +_Returns the address of the current implementation._ -#### Parameters +#### Return Values -| Name | Type | Description | -| ----- | ------ | -------------------------------------------------------- | -| chain | string | Chain name of the interchain token service to be removed | +| Name | Type | Description | +| ---- | ---- | ----------- | +| impl | address | The address of the current implementation | -### addGatewaySupportedChains +### _tokenManagerImplementation ```solidity -function addGatewaySupportedChains(string[] chainNames) external +function _tokenManagerImplementation(contract IInterchainTokenService interchainTokenServiceAddress_, uint256 implementationType_) internal view returns (address impl) ``` -_Adds chains that are supported by the Axelar gateway_ +_Returns the implementation address from the interchain token service for the provided type._ #### Parameters -| Name | Type | Description | -| ---------- | -------- | -------------------------------------------- | -| chainNames | string[] | List of chain names to be added as supported | +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenServiceAddress_ | contract IInterchainTokenService | The address of the interchain token service | +| implementationType_ | uint256 | The token manager type | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| impl | address | The address of the implementation | -### removeGatewaySupportedChains +### setup ```solidity -function removeGatewaySupportedChains(string[] chainNames) external +function setup(bytes setupParams) external ``` -_Removes chains that are no longer supported by the Axelar gateway_ +_Setup function. Empty in this contract._ #### Parameters -| Name | Type | Description | -| ---------- | -------- | ---------------------------------------------- | -| chainNames | string[] | List of chain names to be removed as supported | +| Name | Type | Description | +| ---- | ---- | ----------- | +| setupParams | bytes | Initialization parameters | -### getRemoteAddress +### receive ```solidity -function getRemoteAddress(string chainName) external view returns (string remoteAddress) +receive() external payable virtual ``` -_Fetches the interchain token service address for the specified chain_ +_Reverts if native token is sent._ -#### Parameters +### fallback -| Name | Type | Description | -| --------- | ------ | ----------------- | -| chainName | string | Name of the chain | +```solidity +fallback() external payable virtual +``` -#### Return Values +_Fallback function. Delegates the call to the token manager contract._ -| Name | Type | Description | -| ------------- | ------ | -------------------------------------------------------- | -| remoteAddress | string | Interchain token service address for the specified chain | +## Invalid -## InterchainAddressTrackerProxy +```solidity +error Invalid() +``` -_Proxy contract for the InterchainAddressTracker contract. Inherits from the Proxy contract._ +## TestTokenManager -### constructor +### NAME ```solidity -constructor(address implementationAddress, address owner, bytes params) public +string NAME ``` -_Constructs the InterchainAddressTrackerProxy contract._ +### constructor -#### Parameters +```solidity +constructor(address interchainTokenService_) public +``` -| Name | Type | Description | -| --------------------- | ------- | ---------------------------------------------------------------------- | -| implementationAddress | address | Address of the InterchainAddressTracker implementation | -| owner | address | Address of the owner of the proxy | -| params | bytes | The params to be passed to the \_setup function of the implementation. | +## TestDistributable -### contractId +### NAME ```solidity -function contractId() internal pure returns (bytes32) +string NAME ``` -_Override for the `contractId` function in Proxy. Returns a unique identifier for this contract._ +### constructor -#### Return Values +```solidity +constructor() public +``` -| Name | Type | Description | -| ---- | ------- | ------------------------------------- | -| [0] | bytes32 | bytes32 Identifier for this contract. | +## TestFlowLimit -## ExpressCallHandler +### NAME -_Integrates the interchain token service with the GMP express service by providing methods to handle express calls for -token transfers and token transfers with contract calls between chains. Implements the IExpressCallHandler interface._ +```solidity +string NAME +``` -### PREFIX_EXPRESS_RECEIVE_TOKEN +### constructor ```solidity -uint256 PREFIX_EXPRESS_RECEIVE_TOKEN +constructor() public ``` -### PREFIX_EXPRESS_RECEIVE_TOKEN_WITH_DATA +## TestOperatable + +### NAME ```solidity -uint256 PREFIX_EXPRESS_RECEIVE_TOKEN_WITH_DATA +string NAME ``` -### \_getExpressReceiveTokenSlot +### constructor ```solidity -function _getExpressReceiveTokenSlot(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId) internal pure returns (uint256 slot) +constructor() public ``` -Calculates the unique slot for a given express token transfer. +## TokenManager + +This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. + +### interchainTokenService + +```solidity +contract IInterchainTokenService interchainTokenService +``` + +### TOKEN_ADDRESS_SLOT + +```solidity +uint256 TOKEN_ADDRESS_SLOT +``` + +### constructor + +```solidity +constructor(address interchainTokenService_) internal +``` + +Constructs the TokenManager contract. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenService_ | address | The address of the interchain token service | + +### onlyService + +```solidity +modifier onlyService() +``` + +_A modifier that allows only the interchain token service to execute the function._ + +### onlyToken + +```solidity +modifier onlyToken() +``` + +_A modifier that allows only the token to execute the function._ + +### tokenAddress + +```solidity +function tokenAddress() public view virtual returns (address tokenAddress_) +``` + +_Reads the stored token address from the predetermined storage slot_ + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress_ | address | The address of the token | + +### interchainTokenId + +```solidity +function interchainTokenId() public view returns (bytes32) +``` + +A function that returns the token id. + +_This will only work when implementation is called by a proxy, which stores the tokenId as an immutable._ + +### setup + +```solidity +function setup(bytes params) external +``` + +_This function should only be called by the proxy, and only once from the proxy constructor_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params | bytes | the parameters to be used to initialize the TokenManager. The exact format depends on the type of TokenManager used but the first 32 bytes are reserved for the address of the operator, stored as bytes (to be compatible with non-EVM chains) | + +### interchainTransfer + +```solidity +function interchainTransfer(string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable virtual +``` + +Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the address of the user to send tokens to. | +| amount | uint256 | the amount of tokens to take from msg.sender. | +| metadata | bytes | any additional data to be sent with the transfer. | + +### callContractWithInterchainToken + +```solidity +function callContractWithInterchainToken(string destinationChain, bytes destinationAddress, uint256 amount, bytes data) external payable virtual +``` + +Calls the service to initiate a cross-chain transfer with data after taking the appropriate amount of tokens from the user. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the address of the user to send tokens to. | +| amount | uint256 | the amount of tokens to take from msg.sender. | +| data | bytes | the data to pass to the destination contract. | + +### transmitInterchainTransfer + +```solidity +function transmitInterchainTransfer(address sender, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable virtual +``` + +Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. This can only be called by the token itself. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| sender | address | the address of the user paying for the cross chain transfer. | +| destinationChain | string | the name of the chain to send tokens to. | +| destinationAddress | bytes | the address of the user to send tokens to. | +| amount | uint256 | the amount of tokens to take from msg.sender. | +| metadata | bytes | any additional data to be sent with the transfer | + +### giveToken + +```solidity +function giveToken(address destinationAddress, uint256 amount) external returns (uint256) +``` + +This function gives token to a specified address. Can only be called by the service. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationAddress | address | the address to give tokens to. | +| amount | uint256 | the amount of token to give. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | the amount of token actually given, which will only be different than `amount` in cases where the token takes some on-transfer fee. | + +### takeToken + +```solidity +function takeToken(address sourceAddress, uint256 amount) external returns (uint256) +``` + +This function gives token to a specified address. Can only be called by the service. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceAddress | address | the address to give tokens to. | +| amount | uint256 | the amount of token to give. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | the amount of token actually given, which will onle be differen than `amount` in cases where the token takes some on-transfer fee. | + +### addFlowLimiter + +```solidity +function addFlowLimiter(address flowLimiter) external +``` + +This function adds a flow limiter for this TokenManager. Can only be called by the operator. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimiter | address | the address of the new flow limiter. | + +### removeFlowLimiter + +```solidity +function removeFlowLimiter(address flowLimiter) external +``` + +This function adds a flow limiter for this TokenManager. Can only be called by the operator. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimiter | address | the address of the new flow limiter. | + +### setFlowLimit + +```solidity +function setFlowLimit(uint256 flowLimit_) external +``` + +This function sets the flow limit for this TokenManager. Can only be called by the flow limiters. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | the maximum difference between the tokens flowing in and/or out at any given interval of time (6h) | + +### _setTokenAddress + +```solidity +function _setTokenAddress(address tokenAddress_) internal +``` + +_Stores the token address in the predetermined storage slot_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress_ | address | The address of the token to store | + +### _takeToken + +```solidity +function _takeToken(address from, uint256 amount) internal virtual returns (uint256) +``` + +Transfers tokens from a specific address to this contract. +Must be overridden in the inheriting contract. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | The address from which the tokens will be sent | +| amount | uint256 | The amount of tokens to receive | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint amount of tokens received | + +### _giveToken + +```solidity +function _giveToken(address receiver, uint256 amount) internal virtual returns (uint256) +``` + +Transfers tokens from this contract to a specific address. +Must be overridden in the inheriting contract. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| receiver | address | The address to which the tokens will be sent | +| amount | uint256 | The amount of tokens to send | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint amount of tokens sent | + +### _setup + +```solidity +function _setup(bytes params) internal virtual +``` + +_Additional setup logic to perform +Must be overridden in the inheriting contract._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params | bytes | The setup parameters | + +## TokenManagerLiquidityPool + +This contract is a an implementation of TokenManager that stores all tokens in a separate liquity pool +rather than within itself. + +_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. +It uses the Axelar SDK to safely transfer tokens._ + +### NotSupported + +```solidity +error NotSupported() +``` + +### LIQUIDITY_POOL_SLOT + +```solidity +uint256 LIQUIDITY_POOL_SLOT +``` + +### constructor + +```solidity +constructor(address interchainTokenService_) public +``` + +_Constructs an instance of TokenManagerLiquidityPool. Calls the constructor +of TokenManagerAddressStorage which calls the constructor of TokenManager._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenService_ | address | The address of the interchain token service contract | + +### implementationType + +```solidity +function implementationType() external pure returns (uint256) +``` + +A function that should return the implementation type of the token manager. + +### _setup + +```solidity +function _setup(bytes params_) internal +``` + +_Sets up the token address and liquidity pool address._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | The setup parameters in bytes. Should be encoded with the token address and the liquidity pool address. | + +### _setLiquidityPool + +```solidity +function _setLiquidityPool(address liquidityPool_) internal +``` + +_Stores the liquidity pool address at a specific storage slot_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| liquidityPool_ | address | The address of the liquidity pool | + +### liquidityPool + +```solidity +function liquidityPool() public view returns (address liquidityPool_) +``` + +_Reads the stored liquidity pool address from the specified storage slot_ + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| liquidityPool_ | address | The address of the liquidity pool | + +### setLiquidityPool + +```solidity +function setLiquidityPool(address newLiquidityPool) external +``` + +_Updates the address of the liquidity pool. Can only be called by the operator._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| newLiquidityPool | address | The new address of the liquidity pool | + +### _takeToken + +```solidity +function _takeToken(address from, uint256 amount) internal returns (uint256) +``` + +_Transfers a specified amount of tokens from a specified address to the liquidity pool._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | The address to transfer tokens from | +| amount | uint256 | The amount of tokens to transfer | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint The actual amount of tokens transferred. This allows support for fee-on-transfer tokens. | + +### _giveToken + +```solidity +function _giveToken(address to, uint256 amount) internal returns (uint256) +``` + +_Transfers a specified amount of tokens from the liquidity pool to a specified address._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| to | address | The address to transfer tokens to | +| amount | uint256 | The amount of tokens to transfer | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint The actual amount of tokens transferred | + +### params + +```solidity +function params(bytes operator_, address tokenAddress_, address liquidityPoolAddress) external pure returns (bytes params_) +``` + +Getter function for the parameters of a liquidity pool TokenManager. Mainly to be used by frontends. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | +| liquidityPoolAddress | address | the liquidity pool to be used to store the bridged tokens. | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | + +## TokenManagerLockUnlock + +This contract is an implementation of TokenManager that locks and unlocks a specific token on behalf of the interchain token service. + +_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. +It uses the Axelar SDK to safely transfer tokens._ + +### constructor + +```solidity +constructor(address interchainTokenService_) public +``` + +_Constructs an instance of TokenManagerLockUnlock. Calls the constructor +of TokenManagerAddressStorage which calls the constructor of TokenManager._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenService_ | address | The address of the interchain token service contract | + +### implementationType + +```solidity +function implementationType() external pure returns (uint256) +``` + +A function that should return the implementation type of the token manager. + +### _setup + +```solidity +function _setup(bytes params_) internal +``` + +_Sets up the token address._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | The setup parameters in bytes. Should be encoded with the token address. | + +### _takeToken + +```solidity +function _takeToken(address from, uint256 amount) internal returns (uint256) +``` + +_Transfers a specified amount of tokens from a specified address to this contract._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | The address to transfer tokens from | +| amount | uint256 | The amount of tokens to transfer | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint The actual amount of tokens transferred. This allows support for fee-on-transfer tokens. | + +### _giveToken + +```solidity +function _giveToken(address to, uint256 amount) internal returns (uint256) +``` + +_Transfers a specified amount of tokens from this contract to a specified address._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| destinationAddress | address | The address of the recipient | -| amount | uint256 | The amount of tokens to be sent | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| to | address | The address to transfer tokens to | +| amount | uint256 | The amount of tokens to transfer | #### Return Values -| Name | Type | Description | -| ---- | ------- | ------------------------------------------- | -| slot | uint256 | The calculated slot for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint The actual amount of tokens transferred | -### \_getExpressReceiveTokenWithDataSlot +### params ```solidity -function _getExpressReceiveTokenWithDataSlot(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId) internal pure returns (uint256 slot) +function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_) ``` -Calculates the unique slot for a given token transfer with data +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. #### Parameters -| Name | Type | Description | -| ------------------ | ------- | -------------------------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| sourceChain | string | The chain from which the token will be sent | -| sourceAddress | bytes | The originating address of the token on the source chain | -| destinationAddress | address | The address of the recipient on the destination chain | -| amount | uint256 | The amount of tokens to be sent | -| data | bytes | The data associated with the token transfer | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | #### Return Values -| Name | Type | Description | -| ---- | ------- | ------------------------------------------- | -| slot | uint256 | The calculated slot for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | + +## TokenManagerLockUnlockFee + +This contract is an implementation of TokenManager that locks and unlocks a specific token on behalf of the interchain token service. + +_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. +It uses the Axelar SDK to safely transfer tokens._ -### \_setExpressReceiveToken +### constructor ```solidity -function _setExpressReceiveToken(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId, address expressCaller) internal +constructor(address interchainTokenService_) public ``` -Stores the address of the express caller at the storage slot determined by \_getExpressSendTokenSlot +_Constructs an instance of TokenManagerLockUnlock. Calls the constructor +of TokenManagerAddressStorage which calls the constructor of TokenManager._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| destinationAddress | address | The address of the recipient | -| amount | uint256 | The amount of tokens to be sent | -| commandId | bytes32 | The unique hash for this token transfer | -| expressCaller | address | The address of the express caller | +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenService_ | address | The address of the interchain token service contract | + +### implementationType + +```solidity +function implementationType() external pure returns (uint256) +``` -### \_setExpressReceiveTokenWithData +A function that should return the implementation type of the token manager. + +### _setup ```solidity -function _setExpressReceiveTokenWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId, address expressCaller) internal +function _setup(bytes params_) internal ``` -Stores the address of the express caller for a given token transfer with data at -the storage slot determined by \_getExpressSendTokenWithDataSlot +_Sets up the token address._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | -------------------------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| sourceChain | string | The chain from which the token will be sent | -| sourceAddress | bytes | The originating address of the token on the source chain | -| destinationAddress | address | The address of the recipient on the destination chain | -| amount | uint256 | The amount of tokens to be sent | -| data | bytes | The data associated with the token transfer | -| commandId | bytes32 | The unique hash for this token transfer | -| expressCaller | address | The address of the express caller | +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | The setup parameters in bytes. Should be encoded with the token address. | -### getExpressReceiveToken +### _takeToken ```solidity -function getExpressReceiveToken(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId) public view returns (address expressCaller) +function _takeToken(address from, uint256 amount) internal returns (uint256) ``` -Gets the address of the express caller for a specific token transfer +_Transfers a specified amount of tokens from a specified address to this contract._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| destinationAddress | address | The address of the recipient | -| amount | uint256 | The amount of tokens to be sent | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | The address to transfer tokens from | +| amount | uint256 | The amount of tokens to transfer | #### Return Values -| Name | Type | Description | -| ------------- | ------- | --------------------------------------------------------- | -| expressCaller | address | The address of the express caller for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint The actual amount of tokens transferred. This allows support for fee-on-transfer tokens. | -### getExpressReceiveTokenWithData +### _giveToken ```solidity -function getExpressReceiveTokenWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId) public view returns (address expressCaller) +function _giveToken(address to, uint256 amount) internal returns (uint256) ``` -Gets the address of the express caller for a specific token transfer with data +_Transfers a specified amount of tokens from this contract to a specified address._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | -------------------------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| sourceChain | string | The chain from which the token will be sent | -| sourceAddress | bytes | The originating address of the token on the source chain | -| destinationAddress | address | The address of the recipient on the destination chain | -| amount | uint256 | The amount of tokens to be sent | -| data | bytes | The data associated with the token transfer | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| to | address | The address to transfer tokens to | +| amount | uint256 | The amount of tokens to transfer | #### Return Values -| Name | Type | Description | -| ------------- | ------- | --------------------------------------------------------- | -| expressCaller | address | The address of the express caller for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint The actual amount of tokens transferred | -### \_popExpressReceiveToken +### params ```solidity -function _popExpressReceiveToken(bytes32 tokenId, address destinationAddress, uint256 amount, bytes32 commandId) internal returns (address expressCaller) +function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_) ``` -Removes the express caller from storage for a specific token transfer, if it exists. +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| destinationAddress | address | The address of the recipient | -| amount | uint256 | The amount of tokens to be sent | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | #### Return Values -| Name | Type | Description | -| ------------- | ------- | --------------------------------------------------------- | -| expressCaller | address | The address of the express caller for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | + +## TokenManagerMintBurn + +This contract is an implementation of TokenManager that mints and burns a specific token on behalf of the interchain token service. + +_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. +It uses the Axelar SDK to safely transfer tokens._ -### \_popExpressReceiveTokenWithData +### constructor ```solidity -function _popExpressReceiveTokenWithData(bytes32 tokenId, string sourceChain, bytes sourceAddress, address destinationAddress, uint256 amount, bytes data, bytes32 commandId) internal returns (address expressCaller) +constructor(address interchainTokenService_) public ``` -Removes the express caller from storage for a specific token transfer with data, if it exists. +_Constructs an instance of TokenManagerMintBurn. Calls the constructor +of TokenManagerAddressStorage which calls the constructor of TokenManager._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | -------------------------------------------------------- | -| tokenId | bytes32 | The ID of the token being sent | -| sourceChain | string | The chain from which the token will be sent | -| sourceAddress | bytes | The originating address of the token on the source chain | -| destinationAddress | address | The address of the recipient on the destination chain | -| amount | uint256 | The amount of tokens to be sent | -| data | bytes | The data associated with the token transfer | -| commandId | bytes32 | The unique hash for this token transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenService_ | address | The address of the interchain token service contract | -#### Return Values +### implementationType + +```solidity +function implementationType() external pure virtual returns (uint256) +``` -| Name | Type | Description | -| ------------- | ------- | --------------------------------------------------------- | -| expressCaller | address | The address of the express caller for this token transfer | +A function that should return the implementation type of the token manager. + +### _setup + +```solidity +function _setup(bytes params_) internal +``` + +_Sets up the token address._ -## Multicall +#### Parameters -This contract is a multi-functional smart contract which allows for multiple -contract calls in a single transaction. +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | The setup parameters in bytes. Should be encoded with the token address. | -### MulticallFailed +### _takeToken ```solidity -error MulticallFailed(bytes err) +function _takeToken(address from, uint256 amount) internal virtual returns (uint256) ``` -### multicall +_Burns the specified amount of tokens from a particular address._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | Address to burn tokens from | +| amount | uint256 | Amount of tokens to burn | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint Amount of tokens burned | + +### _giveToken ```solidity -function multicall(bytes[] data) public payable returns (bytes[] results) +function _giveToken(address to, uint256 amount) internal returns (uint256) ``` -Performs multiple delegate calls and returns the results of all calls as an array +_Mints the specified amount of tokens to a particular address_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| to | address | Address to mint tokens to | +| amount | uint256 | Amount of tokens to mint | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint Amount of tokens minted | + +### params -_This function requires that the contract has sufficient balance for the delegate calls. -If any of the calls fail, the function will revert with the failure message._ +```solidity +function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_) +``` + +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. #### Parameters -| Name | Type | Description | -| ---- | ------- | ---------------------------------- | -| data | bytes[] | An array of encoded function calls | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | #### Return Values -| Name | Type | Description | -| ------- | ------- | --------------------------------------------------------- | -| results | bytes[] | An bytes array with the return data of each function call | +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | -## Operatable +## TokenManagerMintBurnFrom -_A contract module which provides a basic access control mechanism, where -there is an account (an operator) that can be granted exclusive access to -specific functions. This module is used through inheritance._ +This contract is an implementation of TokenManager that mints and burns a specific token on behalf of the interchain token service. -### OPERATOR_SLOT +_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. +It uses the Axelar SDK to safely transfer tokens._ + +### constructor ```solidity -uint256 OPERATOR_SLOT +constructor(address interchainTokenService_) public ``` -### onlyOperator +_Constructs an instance of TokenManagerMintBurn. Calls the constructor +of TokenManagerAddressStorage which calls the constructor of TokenManager._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| interchainTokenService_ | address | The address of the interchain token service contract | + +### implementationType ```solidity -modifier onlyOperator() +function implementationType() external pure returns (uint256) ``` -_Throws a NotOperator custom error if called by any account other than the operator._ +A function that should return the implementation type of the token manager. -### operator +### _takeToken ```solidity -function operator() public view returns (address operator_) +function _takeToken(address from, uint256 amount) internal returns (uint256) ``` -Get the address of the operator +_Burns the specified amount of tokens from a particular address._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | Address to burn tokens from | +| amount | uint256 | Amount of tokens to burn | #### Return Values -| Name | Type | Description | -| ---------- | ------- | --------------- | -| operator\_ | address | of the operator | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | uint256 | uint Amount of tokens burned | + +## TokenRegistrar + +### NotApproved + +```solidity +error NotApproved(address tokenAddress) +``` + +### service + +```solidity +contract IInterchainTokenService service +``` + +### chainNameHash + +```solidity +bytes32 chainNameHash +``` + +### PREFIX_CANONICAL_TOKEN_SALT + +```solidity +bytes32 PREFIX_CANONICAL_TOKEN_SALT +``` + +### PREFIX_STANDARDIZED_TOKEN_SALT + +```solidity +bytes32 PREFIX_STANDARDIZED_TOKEN_SALT +``` + +### constructor + +```solidity +constructor(address interchainTokenServiceAddress) public +``` + +### contractId + +```solidity +function contractId() external pure returns (bytes32) +``` + +Getter for the contract id. + +### standardizedTokenSalt -### \_setOperator +```solidity +function standardizedTokenSalt(bytes32 chainNameHash_, address deployer, bytes32 salt) public pure returns (bytes32) +``` + +### standardizedinterchainTokenId + +```solidity +function standardizedinterchainTokenId(address deployer, bytes32 salt) public view returns (bytes32 tokenId) +``` + +### interchainTokenAddress + +```solidity +function interchainTokenAddress(address deployer, bytes32 salt) public view returns (address tokenAddress) +``` + +### deployInterchainToken + +```solidity +function deployInterchainToken(bytes32 salt, string name, string symbol, uint8 decimals, uint256 mintAmount, address distributor, address operator) external payable +``` + +### deployRemoteInterchainToken + +```solidity +function deployRemoteInterchainToken(string originalChainName, bytes32 salt, address additionalDistributor, address optionalOperator, string destinationChain, uint256 gasValue) external payable +``` + +### _deployInterchainToken + +```solidity +function _deployInterchainToken(bytes32 salt, string destinationChain, string tokenName, string tokenSymbol, uint8 tokenDecimals, bytes distributor, bytes operator, uint256 gasValue) internal +``` + +### canonicalTokenSalt + +```solidity +function canonicalTokenSalt(bytes32 chainNameHash_, address tokenAddress) public pure returns (bytes32 salt) +``` + +### canonicalinterchainTokenId + +```solidity +function canonicalinterchainTokenId(address tokenAddress) public view returns (bytes32 tokenId) +``` + +### registerCanonicalToken + +```solidity +function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId) +``` + +### deployRemoteCanonicalToken + +```solidity +function deployRemoteCanonicalToken(string originalChain, address originalTokenAddress, string destinationChain, uint256 gasValue) external payable +``` + +### interchainTransfer + +```solidity +function interchainTransfer(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, uint256 gasValue) external payable +``` + +### interchainTransferFrom + +```solidity +function interchainTransferFrom(bytes32 tokenId, string destinationChain, bytes destinationAddress, uint256 amount, uint256 gasValue) external payable +``` + +## Distributable + +_A contract module which provides a basic access control mechanism, where +there is an account (a distributor) that can be granted exclusive access to +specific functions. This module is used through inheritance._ + +### _addDistributor ```solidity -function _setOperator(address operator_) internal +function _addDistributor(address distributor_) internal ``` -_Internal function that stores the new operator address in the operator storage slot_ +_Internal function that stores the new distributor address in the correct storage slot_ #### Parameters -| Name | Type | Description | -| ---------- | ------- | ------------------------------- | -| operator\_ | address | The address of the new operator | +| Name | Type | Description | +| ---- | ---- | ----------- | +| distributor_ | address | The address of the new distributor | -### transferOperatorship +### transferDistributorship ```solidity -function transferOperatorship(address operator_) external +function transferDistributorship(address distributor_) external ``` -Change the operator of the contract +Change the distributor of the contract -_Can only be called by the current operator_ +_Can only be called by the current distributor_ #### Parameters -| Name | Type | Description | -| ---------- | ------- | ------------------------------- | -| operator\_ | address | The address of the new operator | - -## Pausable - -This contract provides a mechanism to halt the execution of specific functions -if a pause condition is activated. +| Name | Type | Description | +| ---- | ---- | ----------- | +| distributor_ | address | The address of the new distributor | -### PAUSE_SLOT +### proposeDistributorship ```solidity -uint256 PAUSE_SLOT +function proposeDistributorship(address distributor_) external ``` -### whenNotPaused +Proposed a change of the distributor of the contract -```solidity -modifier whenNotPaused() -``` +_Can only be called by the current distributor_ -A modifier that throws a Pause custom error if the contract is paused +#### Parameters -_This modifier should be used with functions that can be paused_ +| Name | Type | Description | +| ---- | ---- | ----------- | +| distributor_ | address | The address of the new distributor | -### isPaused +### acceptDistributorship ```solidity -function isPaused() public view returns (bool paused) +function acceptDistributorship(address fromDistributor) external ``` -Check if the contract is paused - -#### Return Values +Accept a change of the distributor of the contract -| Name | Type | Description | -| ------ | ---- | ------------------------------------------------------------------------- | -| paused | bool | A boolean representing the pause status. True if paused, false otherwise. | +_Can only be called by the proposed distributor_ -### \_setPaused +### isDistributor ```solidity -function _setPaused(bool paused) internal +function isDistributor(address addr) external view returns (bool) ``` -Sets the pause status of the contract - -_This is an internal function, meaning it can only be called from within the contract itself -or from derived contracts._ +Query if an address is a distributor #### Parameters -| Name | Type | Description | -| ------ | ---- | -------------------- | -| paused | bool | The new pause status | +| Name | Type | Description | +| ---- | ---- | ----------- | +| addr | address | the address to query for | -## InterchainTokenExecutable +## FlowLimit -### NotService +Implements flow limit logic for interchain token transfers. + +_This contract implements low-level assembly for optimization purposes._ + +### FLOW_LIMIT_SLOT ```solidity -error NotService(address caller) +uint256 FLOW_LIMIT_SLOT ``` -### interchainTokenService +### PREFIX_FLOW_OUT_AMOUNT ```solidity -address interchainTokenService +uint256 PREFIX_FLOW_OUT_AMOUNT ``` -### constructor +### PREFIX_FLOW_IN_AMOUNT ```solidity -constructor(address interchainTokenService_) internal +uint256 PREFIX_FLOW_IN_AMOUNT ``` -### onlyService +### EPOCH_TIME ```solidity -modifier onlyService() +uint256 EPOCH_TIME ``` -### executeWithInterchainToken +### flowLimit ```solidity -function executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, uint256 amount) external +function flowLimit() public view returns (uint256 flowLimit_) ``` -This will be called after the tokens arrive to this contract - -_You are revert unless the msg.sender is the InterchainTokenService_ +Returns the current flow limit -#### Parameters +#### Return Values -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------------------------------------------------------- | -| sourceChain | string | the name of the source chain | -| sourceAddress | bytes | the address that sent the contract call | -| data | bytes | the data to be proccessed | -| tokenId | bytes32 | the tokenId of the token manager managing the token. You can access it's address by querying the service | -| amount | uint256 | the amount of token that was sent | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | The current flow limit value | -### \_executeWithInterchainToken +### _setFlowLimit ```solidity -function _executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, uint256 amount) internal virtual +function _setFlowLimit(uint256 flowLimit_, bytes32 tokenId) internal ``` -## InterchainTokenExpressExecutable +_Internal function to set the flow limit_ -### constructor +#### Parameters -```solidity -constructor(address interchainTokenService_) internal -``` +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | The value to set the flow limit to | +| tokenId | bytes32 | | -### expressExecuteWithInterchainToken +### _getFlowOutSlot ```solidity -function expressExecuteWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, uint256 amount) external +function _getFlowOutSlot(uint256 epoch) internal pure returns (uint256 slot) ``` -This will be called after the tokens arrive to this contract - -_You are revert unless the msg.sender is the InterchainTokenService_ +_Returns the slot which is used to get the flow out amount for a specific epoch_ #### Parameters -| Name | Type | Description | -| ------------- | ------- | -------------------------------------------------------------------------------------------------------- | -| sourceChain | string | the name of the source chain | -| sourceAddress | bytes | the address that sent the contract call | -| data | bytes | the data to be proccessed | -| tokenId | bytes32 | the tokenId of the token manager managing the token. You can access it's address by querying the service | -| amount | uint256 | the amount of token that was sent | - -## InterchainToken +| Name | Type | Description | +| ---- | ---- | ----------- | +| epoch | uint256 | The epoch to get the flow out amount for | -The implementation ERC20 can be done in any way, however this example assumes that an \_approve internal function exists -that can be used to create approvals, and that `allowance` is a mapping. +#### Return Values -_You can skip the `tokenManagerRequiresApproval()` function altogether if you know what it should return for your token._ +| Name | Type | Description | +| ---- | ---- | ----------- | +| slot | uint256 | The slot to get the flow out amount from | -### getTokenManager +### _getFlowInSlot ```solidity -function getTokenManager() public view virtual returns (contract ITokenManager tokenManager) +function _getFlowInSlot(uint256 epoch) internal pure returns (uint256 slot) ``` -Getter for the tokenManager used for this token. +_Returns the slot which is used to get the flow in amount for a specific epoch_ -_Needs to be overwitten._ +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| epoch | uint256 | The epoch to get the flow in amount for | #### Return Values -| Name | Type | Description | -| ------------ | ---------------------- | ------------------------------------------------------------ | -| tokenManager | contract ITokenManager | the TokenManager called to facilitate cross chain transfers. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| slot | uint256 | The slot to get the flow in amount from | -### tokenManagerRequiresApproval +### flowOutAmount ```solidity -function tokenManagerRequiresApproval() public view virtual returns (bool) +function flowOutAmount() external view returns (uint256 flowOutAmount_) ``` -Getter function specifying if the tokenManager requires approval to facilitate cross-chain transfers. -Usually, only mint/burn tokenManagers do not need approval. - -_The return value depends on the implementation of ERC20. -In case of lock/unlock and liquidity pool TokenManagers it is possible to implement transferFrom to allow the -TokenManager specifically to do it permissionlessly. -On the other hand you can implement burn in a way that requires approval for a mint/burn TokenManager_ +Returns the current flow out amount #### Return Values -| Name | Type | Description | -| ---- | ---- | ------------------------------------------------------------------------- | -| [0] | bool | tokenManager the TokenManager called to facilitate cross chain transfers. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowOutAmount_ | uint256 | The current flow out amount | -### interchainTransfer +### flowInAmount ```solidity -function interchainTransfer(string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable +function flowInAmount() external view returns (uint256 flowInAmount_) ``` -Implementation of the interchainTransfer method - -_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. -A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ +Returns the current flow in amount -#### Parameters +#### Return Values -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| destinationChain | string | The destination chain identifier. | -| recipient | bytes | The bytes representation of the address of the recipient. | -| amount | uint256 | The amount of token to be transferred. | -| metadata | bytes | Either empty, to just facilitate an interchain transfer, or the data can be passed for an interchain contract call with transfer as per semantics defined by the token service. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowInAmount_ | uint256 | The current flow in amount | -### interchainTransferFrom +### _addFlow ```solidity -function interchainTransferFrom(address sender, string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable +function _addFlow(uint256 flowLimit_, uint256 slotToAdd, uint256 slotToCompare, uint256 flowAmount) internal ``` -Implementation of the interchainTransferFrom method - -_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. -A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ +_Adds a flow amount while ensuring it does not exceed the flow limit_ #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ | -| sender | address | the sender of the tokens. They need to have approved `msg.sender` before this is called. | -| destinationChain | string | the string representation of the destination chain. | -| recipient | bytes | the bytes representation of the address of the recipient. | -| amount | uint256 | the amount of token to be transferred. | -| metadata | bytes | either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer. | - -## IDistributable +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | The current flow limit value | +| slotToAdd | uint256 | The slot to add the flow to | +| slotToCompare | uint256 | The slot to compare the flow against | +| flowAmount | uint256 | The flow amount to add | -### NotDistributor +### _addFlowOut ```solidity -error NotDistributor(address caller) +function _addFlowOut(uint256 flowOutAmount_) internal ``` -### DistributorshipTransferred +_Adds a flow out amount_ -```solidity -event DistributorshipTransferred(address previousDistributor, address distributor) -``` +#### Parameters -### distributor +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowOutAmount_ | uint256 | The flow out amount to add | + +### _addFlowIn ```solidity -function distributor() external view returns (address distributor) +function _addFlowIn(uint256 flowInAmount_) internal ``` -Get the address of the distributor - -#### Return Values - -| Name | Type | Description | -| ----------- | ------- | ------------------ | -| distributor | address | of the distributor | +_Adds a flow in amount_ -### transferDistributorship +#### Parameters -```solidity -function transferDistributorship(address distributor) external -``` +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowInAmount_ | uint256 | The flow in amount to add | -Change the distributor of the contract +## Implementation -_Can only be called by the current distributor_ +This contract serves as a base for other contracts and enforces a proxy-first access restriction. -#### Parameters +_Derived contracts must implement the setup function._ -| Name | Type | Description | -| ----------- | ------- | ---------------------------------- | -| distributor | address | The address of the new distributor | +### constructor -## IERC20BurnableMintable +```solidity +constructor() internal +``` -_Interface of the ERC20 standard as defined in the EIP._ +_Contract constructor that sets the implementation address to the address of this contract._ -### mint +### onlyProxy ```solidity -function mint(address to, uint256 amount) external +modifier onlyProxy() ``` -Function to mint new tokens -Can only be called by the distributor address. +_Modifier to require the caller to be the proxy contract. +Reverts if the caller is the current contract (i.e., the implementation contract itself)._ -#### Parameters +## Operatable -| Name | Type | Description | -| ------ | ------- | ----------------------------------------------- | -| to | address | The address that will receive the minted tokens | -| amount | uint256 | The amount of tokens to mint | +_A contract module which provides a basic access control mechanism, where +there is an account (a operator) that can be granted exclusive access to +specific functions. This module is used through inheritance._ -### burn +### _addOperator ```solidity -function burn(address from, uint256 amount) external +function _addOperator(address operator_) internal ``` -Function to burn tokens -Can only be called by the distributor address. +_Internal function that stores the new operator address in the correct storage slot_ #### Parameters -| Name | Type | Description | -| ------ | ------- | ------------------------------------------- | -| from | address | The address that will have its tokens burnt | -| amount | uint256 | The amount of tokens to burn | - -## IInterchainToken - -_Interface of the ERC20 standard as defined in the EIP._ +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | address | The address of the new operator | -### interchainTransfer +### transferOperatorship ```solidity -function interchainTransfer(string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable +function transferOperatorship(address operator_) external ``` -Implementation of the interchainTransfer method +Change the operator of the contract -_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. -A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ +_Can only be called by the current operator_ #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| destinationChain | string | The destination chain identifier. | -| recipient | bytes | The bytes representation of the address of the recipient. | -| amount | uint256 | The amount of token to be transferred. | -| metadata | bytes | Either empty, to just facilitate an interchain transfer, or the data can be passed for an interchain contract call with transfer as per semantics defined by the token service. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | address | The address of the new operator | -### interchainTransferFrom +### proposeOperatorship ```solidity -function interchainTransferFrom(address sender, string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable +function proposeOperatorship(address operator_) external ``` -Implementation of the interchainTransferFrom method +Proposed a change of the operator of the contract -_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. -A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ +_Can only be called by the current operator_ #### Parameters -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ | -| sender | address | the sender of the tokens. They need to have approved `msg.sender` before this is called. | -| destinationChain | string | the string representation of the destination chain. | -| recipient | bytes | the bytes representation of the address of the recipient. | -| amount | uint256 | the amount of token to be transferred. | -| metadata | bytes | either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer. | - -## ILinkerRouter - -_Manages and validates remote addresses, keeps track of addresses supported by the Axelar gateway contract_ +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | address | The address of the new operator | -### ZeroAddress +### acceptOperatorship ```solidity -error ZeroAddress() +function acceptOperatorship(address fromOperator) external ``` -### LengthMismatch +Accept a change of the operator of the contract -```solidity -error LengthMismatch() -``` +_Can only be called by the proposed operator_ -### ZeroStringLength +### isOperator ```solidity -error ZeroStringLength() +function isOperator(address addr) external view returns (bool) ``` -### TrustedAddressAdded +Query if an address is an operator -```solidity -event TrustedAddressAdded(string sourceChain, string sourceAddress) -``` +#### Parameters -### TrustedAddressRemoved +| Name | Type | Description | +| ---- | ---- | ----------- | +| addr | address | the address to query for | -```solidity -event TrustedAddressRemoved(string sourceChain) -``` +## RolesConstants -### GatewaySupportedChainAdded +### Roles ```solidity -event GatewaySupportedChainAdded(string chain) +enum Roles { + DISTRIBUTOR, + OPERATOR, + FLOW_LIMITER +} ``` -### GatewaySupportedChainRemoved +## TokenManagerDeployer -```solidity -event GatewaySupportedChainRemoved(string chain) -``` +This contract is used to deploy new instances of the TokenManagerProxy contract. -### validateSender +### deployTokenManager ```solidity -function validateSender(string sourceChain, string sourceAddress) external view returns (bool) +function deployTokenManager(bytes32 tokenId, uint256 implementationType, bytes params) external payable returns (address tokenManager) ``` -_Validates that the sender is a valid interchain token service address_ +Deploys a new instance of the TokenManagerProxy contract #### Parameters -| Name | Type | Description | -| ------------- | ------ | --------------------------------- | -| sourceChain | string | Source chain of the transaction | -| sourceAddress | string | Source address of the transaction | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenId | bytes32 | The unique identifier for the token | +| implementationType | uint256 | Token manager implementation type | +| params | bytes | Additional parameters used in the setup of the token manager | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------------------------------------------------- | -| [0] | bool | bool true if the sender is validated, false otherwise | - -### addTrustedAddress - -```solidity -function addTrustedAddress(string sourceChain, string sourceAddress) external -``` - -_Adds a trusted interchain token service address for the specified chain_ +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManager | address | The address of the deployed tokenManager | -#### Parameters +## InterchainToken -| Name | Type | Description | -| ------------- | ------ | -------------------------------------------- | -| sourceChain | string | Chain name of the interchain token service | -| sourceAddress | string | Interchain token service address to be added | +The implementation ERC20 can be done in any way, however this example assumes that an _approve internal function exists +that can be used to create approvals, and that `allowance` is a mapping. -### removeTrustedAddress +### tokenManager ```solidity -function removeTrustedAddress(string sourceChain) external +function tokenManager() public view virtual returns (contract ITokenManager tokenManager_) ``` -_Removes a trusted interchain token service address_ +Getter for the tokenManager used for this token. -#### Parameters +_Needs to be overwritten._ -| Name | Type | Description | -| ----------- | ------ | -------------------------------------------------------- | -| sourceChain | string | Chain name of the interchain token service to be removed | +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenManager_ | contract ITokenManager | the TokenManager called to facilitate cross chain transfers. | -### getRemoteAddress +### interchainTransfer ```solidity -function getRemoteAddress(string chainName) external view returns (string remoteAddress) +function interchainTransfer(string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable ``` -_Fetches the interchain token service address for the specified chain_ - -#### Parameters +Implementation of the interchainTransfer method -| Name | Type | Description | -| --------- | ------ | ----------------- | -| chainName | string | Name of the chain | +_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. +A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ -#### Return Values +#### Parameters -| Name | Type | Description | -| ------------- | ------ | -------------------------------------------------------- | -| remoteAddress | string | Interchain token service address for the specified chain | +| Name | Type | Description | +| ---- | ---- | ----------- | +| destinationChain | string | The destination chain identifier. | +| recipient | bytes | The bytes representation of the address of the recipient. | +| amount | uint256 | The amount of token to be transferred. | +| metadata | bytes | Either empty, to just facilitate an interchain transfer, or the data can be passed for an interchain contract call with transfer as per semantics defined by the token service. | -### supportedByGateway +### interchainTransferFrom ```solidity -function supportedByGateway(string chainName) external view returns (bool) +function interchainTransferFrom(address sender, string destinationChain, bytes recipient, uint256 amount, bytes metadata) external payable ``` -Returns true if the gateway delivers token to this chain. +Implementation of the interchainTransferFrom method + +_We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer. +A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well._ #### Parameters -| Name | Type | Description | -| --------- | ------ | ----------------- | -| chainName | string | Name of the chain | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sender | address | the sender of the tokens. They need to have approved `msg.sender` before this is called. | +| destinationChain | string | the string representation of the destination chain. | +| recipient | bytes | the bytes representation of the address of the recipient. | +| amount | uint256 | the amount of token to be transferred. | +| metadata | bytes | either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer. | -### addGatewaySupportedChains +### _beforeInterchainTransfer ```solidity -function addGatewaySupportedChains(string[] chainNames) external +function _beforeInterchainTransfer(address from, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) internal virtual ``` -_Adds chains that are supported by the Axelar gateway_ +A method to be overwritten that will be called before an interchain transfer. You can approve the tokenManager here if you need and want to, to allow users for a 1-call transfer in case of a lock-unlock token manager. #### Parameters -| Name | Type | Description | -| ---------- | -------- | -------------------------------------------- | -| chainNames | string[] | List of chain names to be added as supported | +| Name | Type | Description | +| ---- | ---- | ----------- | +| from | address | the sender of the tokens. They need to have approved `msg.sender` before this is called. | +| destinationChain | string | the string representation of the destination chain. | +| destinationAddress | bytes | the bytes representation of the address of the recipient. | +| amount | uint256 | the amount of token to be transferred. | +| metadata | bytes | either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer. | + +## ITokenManagerLockUnlockFee + +This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. -### removeGatewaySupportedChains +### params ```solidity -function removeGatewaySupportedChains(string[] chainNames) external +function params(bytes operator_, address tokenAddress_) external pure returns (bytes params_) ``` -_Removes chains that are no longer supported by the Axelar gateway_ +Getter function for the parameters of a lock/unlock TokenManager. Mainly to be used by frontends. #### Parameters -| Name | Type | Description | -| ---------- | -------- | ---------------------------------------------- | -| chainNames | string[] | List of chain names to be removed as supported | +| Name | Type | Description | +| ---- | ---- | ----------- | +| operator_ | bytes | the operator of the TokenManager. | +| tokenAddress_ | address | the token to be managed. | -## InterchainTokenServiceProxy +#### Return Values -_Proxy contract for interchain token service contracts. Inherits from the FinalProxy contract._ +| Name | Type | Description | +| ---- | ---- | ----------- | +| params_ | bytes | the resulting params to be passed to custom TokenManager deployments. | + +## StandardizedTokenProxy + +_Proxy contract for StandardizedToken contracts. Inherits from FixedProxy._ ### constructor ```solidity -constructor(address implementationAddress, address owner, address operator) public +constructor(address implementationAddress, bytes params) public ``` -_Constructs the InterchainTokenServiceProxy contract._ +_Constructs the StandardizedTokenProxy contract._ #### Parameters -| Name | Type | Description | -| --------------------- | ------- | ------------------------------------------------------ | -| implementationAddress | address | Address of the interchain token service implementation | -| owner | address | Address of the owner of the proxy | -| operator | address | | +| Name | Type | Description | +| ---- | ---- | ----------- | +| implementationAddress | address | Address of the StandardizedToken implementation | +| params | bytes | Initialization parameters for the StandardizedToken contract | ### contractId @@ -3392,158 +3878,120 @@ _Constructs the InterchainTokenServiceProxy contract._ function contractId() internal pure returns (bytes32) ``` -_Override for the 'contractId' function in FinalProxy. Returns a unique identifier for this contract._ - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ------------------------------------ | -| [0] | bytes32 | bytes32 identifier for this contract | - -## TokenManagerProxy +Getter for the contract id. -_This contract is a proxy for token manager contracts. It implements ITokenManagerProxy and -inherits from FixedProxy from the gmp sdk repo_ +## FeeOnTransferTokenTest -### interchainTokenServiceAddress +### tokenManager_ ```solidity -contract IInterchainTokenService interchainTokenServiceAddress +contract ITokenManager tokenManager_ ``` -### implementationType +### tokenManagerRequiresApproval_ ```solidity -uint256 implementationType +bool tokenManagerRequiresApproval_ ``` -Returns implementation type of this token manager - -### tokenId +### name ```solidity -bytes32 tokenId +string name ``` -Returns token ID of the token manager. - -### constructor +### symbol ```solidity -constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId_, bytes params) public +string symbol ``` -_Constructs the TokenManagerProxy contract._ - -#### Parameters - -| Name | Type | Description | -| ------------------------------- | ------- | ------------------------------------------------------------ | -| interchainTokenServiceAddress\_ | address | The address of the interchain token service | -| implementationType\_ | uint256 | The token manager type | -| tokenId\_ | bytes32 | The identifier for the token | -| params | bytes | The initialization parameters for the token manager contract | - -### implementation +### decimals ```solidity -function implementation() public view returns (address impl) +uint8 decimals ``` -_Returns the address of the current implementation._ - -#### Return Values +### constructor -| Name | Type | Description | -| ---- | ------- | ----------------------------------------- | -| impl | address | The address of the current implementation | +```solidity +constructor(string name_, string symbol_, uint8 decimals_, address tokenManagerAddress) public +``` -### \_tokenManagerImplementation +### tokenManager ```solidity -function _tokenManagerImplementation(contract IInterchainTokenService interchainTokenServiceAddress_, uint256 implementationType_) internal view returns (address impl) +function tokenManager() public view returns (contract ITokenManager) ``` -_Returns the implementation address from the interchain token service for the provided type._ - -#### Parameters +Getter for the tokenManager used for this token. -| Name | Type | Description | -| ------------------------------- | -------------------------------- | ------------------------------------------- | -| interchainTokenServiceAddress\_ | contract IInterchainTokenService | The address of the interchain token service | -| implementationType\_ | uint256 | The token manager type | +_Needs to be overwritten._ #### Return Values -| Name | Type | Description | -| ---- | ------- | --------------------------------- | -| impl | address | The address of the implementation | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | contract ITokenManager | | -### setup +### _beforeInterchainTransfer ```solidity -function setup(bytes setupParams) external +function _beforeInterchainTransfer(address sender, string, bytes, uint256 amount, bytes) internal ``` -_Setup function. Empty in this contract._ - -#### Parameters - -| Name | Type | Description | -| ----------- | ----- | ------------------------- | -| setupParams | bytes | Initialization parameters | - -### fallback +### setTokenManagerRequiresApproval ```solidity -fallback() external payable virtual +function setTokenManagerRequiresApproval(bool requiresApproval) public ``` -_Fallback function. Delegates the call to the token manager contract._ - -### receive +### mint ```solidity -receive() external payable virtual +function mint(address account, uint256 amount) external ``` -_Receive function which allows this contract to receive ether._ - -## InterchainExecutableTest - -### MessageReceived +### burn ```solidity -event MessageReceived(string sourceChain, bytes sourceAddress, address receiver, string message, bytes32 tokenId, uint256 amount) +function burn(address account, uint256 amount) external ``` -### constructor +### setTokenManager ```solidity -constructor(address interchainTokenService_) public +function setTokenManager(contract ITokenManager tokenManagerAddress) external ``` -### lastMessage +### _transfer ```solidity -string lastMessage +function _transfer(address sender, address recipient, uint256 amount) internal ``` -### \_executeWithInterchainToken +_Moves tokens `amount` from `sender` to `recipient`. -```solidity -function _executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, uint256 amount) internal -``` +This is internal function is equivalent to {transfer}, and can be used to +e.g. implement automatic token fees, slashing mechanisms, etc. + +Emits a {Transfer} event. + +Requirements: + +- `sender` cannot be the zero address. +- `recipient` cannot be the zero address. +- `sender` must have a balance of at least `amount`._ ## InterchainTokenTest -### tokenManager +### tokenManager_ ```solidity -contract ITokenManager tokenManager +contract ITokenManager tokenManager_ ``` -### tokenManagerRequiresApproval\_ +### tokenManagerRequiresApproval_ ```solidity bool tokenManagerRequiresApproval_ @@ -3570,45 +4018,31 @@ uint8 decimals ### constructor ```solidity -constructor(string name_, string symbol_, uint8 decimals_, address tokenManager_) public +constructor(string name_, string symbol_, uint8 decimals_, address tokenManagerAddress) public ``` -### getTokenManager +### tokenManager ```solidity -function getTokenManager() public view returns (contract ITokenManager) +function tokenManager() public view returns (contract ITokenManager) ``` Getter for the tokenManager used for this token. -_Needs to be overwitten._ +_Needs to be overwritten._ #### Return Values -| Name | Type | Description | -| ---- | ---------------------- | ----------- | -| [0] | contract ITokenManager | | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | contract ITokenManager | | -### tokenManagerRequiresApproval +### _beforeInterchainTransfer ```solidity -function tokenManagerRequiresApproval() public view returns (bool) +function _beforeInterchainTransfer(address sender, string, bytes, uint256 amount, bytes) internal ``` -Getter function specifying if the tokenManager requires approval to facilitate cross-chain transfers. -Usually, only mint/burn tokenManagers do not need approval. - -_The return value depends on the implementation of ERC20. -In case of lock/unlock and liquidity pool TokenManagers it is possible to implement transferFrom to allow the -TokenManager specifically to do it permissionlessly. -On the other hand you can implement burn in a way that requires approval for a mint/burn TokenManager_ - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ------------------------------------------------------------------------- | -| [0] | bool | tokenManager the TokenManager called to facilitate cross chain transfers. | - ### setTokenManagerRequiresApproval ```solidity @@ -3630,35 +4064,109 @@ function burn(address account, uint256 amount) external ### setTokenManager ```solidity -function setTokenManager(contract ITokenManager tokenManager_) external +function setTokenManager(contract ITokenManager tokenManagerAddress) external ``` -## OperatorableTest +## InvalidStandardizedToken -### nonce +### name ```solidity -uint256 nonce +string name ``` -### constructor +### symbol ```solidity -constructor(address operator) public +string symbol ``` -### testOperatorable +### decimals ```solidity -function testOperatorable() external +uint8 decimals +``` + +### tokenManager_ + +```solidity +address tokenManager_ +``` + +### contractId + +```solidity +function contractId() external pure returns (bytes32) +``` + +Getter for the contract id. + +### tokenManager + +```solidity +function tokenManager() public view returns (contract ITokenManager) +``` + +Returns the token manager for this token + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | contract ITokenManager | ITokenManager The token manager contract | + +### setup + +```solidity +function setup(bytes params) external +``` + +Setup function to initialize contract parameters + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| params | bytes | The setup parameters in bytes The setup params include tokenManager, distributor, tokenName, symbol, decimals, mintAmount and mintTo | + +### mint + +```solidity +function mint(address account, uint256 amount) external +``` + +Function to mint new tokens +Can only be called by the distributor address. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| account | address | The address that will receive the minted tokens | +| amount | uint256 | The amount of tokens to mint | + +### burn + +```solidity +function burn(address account, uint256 amount) external ``` +Function to burn tokens +Can only be called by the distributor address. + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| account | address | The address that will have its tokens burnt | +| amount | uint256 | The amount of tokens to burn | + ## ERC20 -\_Implementation of the {IERC20} interface. +_Implementation of the {IERC20} interface. This implementation is agnostic to the way tokens are created. This means -that a supply mechanism has to be added in a derived contract using {\_mint}. +that a supply mechanism has to be added in a derived contract using {_mint}. For a generic mechanism see {ERC20PresetMinterPauser}. TIP: For a detailed writeup see our guide @@ -3676,7 +4184,7 @@ these events, as it isn't required by the specification. Finally, the non-standard {decreaseAllowance} and {increaseAllowance} functions have been added to mitigate the well-known issues around setting -allowances. See {IERC20-approve}.\_ +allowances. See {IERC20-approve}._ ### balanceOf @@ -3692,11 +4200,11 @@ _Returns the amount of tokens owned by `account`._ mapping(address => mapping(address => uint256)) allowance ``` -\_Returns the remaining number of tokens that `spender` will be +_Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. -This value changes when {approve} or {transferFrom} are called.\_ +This value changes when {approve} or {transferFrom} are called._ ### totalSupply @@ -3706,18 +4214,24 @@ uint256 totalSupply _Returns the amount of tokens in existence._ +### UINT256_MAX + +```solidity +uint256 UINT256_MAX +``` + ### transfer ```solidity function transfer(address recipient, uint256 amount) external virtual returns (bool) ``` -\_See {IERC20-transfer}. +_See {IERC20-transfer}. Requirements: -- `recipient` cannot be the zero address. -- the caller must have a balance of at least `amount`.\_ +- `recipient` cannot be the zero address. +- the caller must have a balance of at least `amount`._ ### approve @@ -3725,14 +4239,14 @@ Requirements: function approve(address spender, uint256 amount) external virtual returns (bool) ``` -\_See {IERC20-approve}. +_See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: -- `spender` cannot be the zero address.\_ +- `spender` cannot be the zero address._ ### transferFrom @@ -3740,17 +4254,17 @@ Requirements: function transferFrom(address sender, address recipient, uint256 amount) external virtual returns (bool) ``` -\_See {IERC20-transferFrom}. +_See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: -- `sender` and `recipient` cannot be the zero address. -- `sender` must have a balance of at least `amount`. -- the caller must have allowance for `sender`'s tokens of at least - `amount`.\_ +- `sender` and `recipient` cannot be the zero address. +- `sender` must have a balance of at least `amount`. +- the caller must have allowance for ``sender``'s tokens of at least +`amount`._ ### increaseAllowance @@ -3758,7 +4272,7 @@ Requirements: function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool) ``` -\_Atomically increases the allowance granted to `spender` by the caller. +_Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. @@ -3767,7 +4281,7 @@ Emits an {Approval} event indicating the updated allowance. Requirements: -- `spender` cannot be the zero address.\_ +- `spender` cannot be the zero address._ ### decreaseAllowance @@ -3775,7 +4289,7 @@ Requirements: function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) ``` -\_Atomically decreases the allowance granted to `spender` by the caller. +_Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. @@ -3784,17 +4298,17 @@ Emits an {Approval} event indicating the updated allowance. Requirements: -- `spender` cannot be the zero address. -- `spender` must have allowance for the caller of at least - `subtractedValue`.\_ +- `spender` cannot be the zero address. +- `spender` must have allowance for the caller of at least +`subtractedValue`._ -### \_transfer +### _transfer ```solidity function _transfer(address sender, address recipient, uint256 amount) internal virtual ``` -\_Moves tokens `amount` from `sender` to `recipient`. +_Moves tokens `amount` from `sender` to `recipient`. This is internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. @@ -3803,48 +4317,48 @@ Emits a {Transfer} event. Requirements: -- `sender` cannot be the zero address. -- `recipient` cannot be the zero address. -- `sender` must have a balance of at least `amount`.\_ +- `sender` cannot be the zero address. +- `recipient` cannot be the zero address. +- `sender` must have a balance of at least `amount`._ -### \_mint +### _mint ```solidity function _mint(address account, uint256 amount) internal virtual ``` -\_Creates `amount` tokens and assigns them to `account`, increasing +_Creates `amount` tokens and assigns them to `account`, increasing the total supply. Emits a {Transfer} event with `from` set to the zero address. Requirements: -- `to` cannot be the zero address.\_ +- `to` cannot be the zero address._ -### \_burn +### _burn ```solidity function _burn(address account, uint256 amount) internal virtual ``` -\_Destroys `amount` tokens from `account`, reducing the +_Destroys `amount` tokens from `account`, reducing the total supply. Emits a {Transfer} event with `to` set to the zero address. Requirements: -- `account` cannot be the zero address. -- `account` must have at least `amount` tokens.\_ +- `account` cannot be the zero address. +- `account` must have at least `amount` tokens._ -### \_approve +### _approve ```solidity function _approve(address owner, address spender, uint256 amount) internal virtual ``` -\_Sets `amount` as the allowance of `spender` over the `owner` s tokens. +_Sets `amount` as the allowance of `spender` over the `owner` s tokens. This internal function is equivalent to `approve`, and can be used to e.g. set automatic allowances for certain subsystems, etc. @@ -3853,8 +4367,8 @@ Emits an {Approval} event. Requirements: -- `owner` cannot be the zero address. -- `spender` cannot be the zero address.\_ +- `owner` cannot be the zero address. +- `spender` cannot be the zero address._ ## ERC20Permit @@ -3885,10 +4399,10 @@ error InvalidV() error InvalidSignature() ``` -### DOMAIN_SEPARATOR +### nameHash ```solidity -bytes32 DOMAIN_SEPARATOR +bytes32 nameHash ``` _Represents hash of the EIP-712 Domain Separator._ @@ -3901,20 +4415,30 @@ mapping(address => uint256) nonces _Mapping of nonces for each address._ -### \_setDomainTypeSignatureHash +### _setNameHash ```solidity -function _setDomainTypeSignatureHash(string name) internal +function _setNameHash(string name) internal ``` -Internal function to set the domain type signature hash +Internal function to set the token name hash #### Parameters -| Name | Type | Description | -| ---- | ------ | -------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | name | string | The token name | +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() public view returns (bytes32) +``` + +Calculates the domain separator. + +_This is not cached because chainid can change on chain forks._ + ### permit ```solidity @@ -3928,49 +4452,49 @@ to spend tokens on their behalf via a signed message._ #### Parameters -| Name | Type | Description | -| -------- | ------- | ------------------------------------------------- | -| issuer | address | The address of the token holder | -| spender | address | The address of the designated spender | -| value | uint256 | The number of tokens to be spent | +| Name | Type | Description | +| ---- | ---- | ----------- | +| issuer | address | The address of the token holder | +| spender | address | The address of the designated spender | +| value | uint256 | The number of tokens to be spent | | deadline | uint256 | The time at which the permission to spend expires | -| v | uint8 | The recovery id of the signature | -| r | bytes32 | Half of the ECDSA signature pair | -| s | bytes32 | Half of the ECDSA signature pair | +| v | uint8 | The recovery id of the signature | +| r | bytes32 | Half of the ECDSA signature pair | +| s | bytes32 | Half of the ECDSA signature pair | ## StandardizedToken This contract implements a standardized token which extends InterchainToken functionality. This contract also inherits Distributable and Implementation logic. -### tokenManager - -```solidity -address tokenManager -``` - ### name ```solidity string name ``` +Getter for the name of the token + ### symbol ```solidity string symbol ``` +Getter for the symbol of the token + ### decimals ```solidity uint8 decimals ``` -### CONTRACT_ID +Getter for the decimals of the token + +### tokenManager_ ```solidity -bytes32 CONTRACT_ID +address tokenManager_ ``` ### contractId @@ -3981,19 +4505,19 @@ function contractId() external pure returns (bytes32) Getter for the contract id. -### getTokenManager +### tokenManager ```solidity -function getTokenManager() public view returns (contract ITokenManager) +function tokenManager() public view returns (contract ITokenManager) ``` Returns the token manager for this token #### Return Values -| Name | Type | Description | -| ---- | ---------------------- | ---------------------------------------- | -| [0] | contract ITokenManager | ITokenManager The token manager contract | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | contract ITokenManager | ITokenManager The token manager contract | ### setup @@ -4005,8 +4529,8 @@ Setup function to initialize contract parameters #### Parameters -| Name | Type | Description | -| ------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------ | +| Name | Type | Description | +| ---- | ---- | ----------- | | params | bytes | The setup parameters in bytes The setup params include tokenManager, distributor, tokenName, symbol, decimals, mintAmount and mintTo | ### mint @@ -4020,10 +4544,10 @@ Can only be called by the distributor address. #### Parameters -| Name | Type | Description | -| ------- | ------- | ----------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | account | address | The address that will receive the minted tokens | -| amount | uint256 | The amount of tokens to mint | +| amount | uint256 | The amount of tokens to mint | ### burn @@ -4036,713 +4560,629 @@ Can only be called by the distributor address. #### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | account | address | The address that will have its tokens burnt | -| amount | uint256 | The amount of tokens to burn | - -## StandardizedTokenLockUnlock - -### tokenManagerRequiresApproval - -```solidity -function tokenManagerRequiresApproval() public pure returns (bool) -``` - -Getter function specifying if the tokenManager requires approval to facilitate cross-chain transfers. -Usually, only mint/burn tokenManagers do not need approval. - -_The return value depends on the implementation of ERC20. -In case of lock/unlock and liquidity pool TokenManagers it is possible to implement transferFrom to allow the -TokenManager specifically to do it permissionlessly. -On the other hand you can implement burn in a way that requires approval for a mint/burn TokenManager_ - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ------------------------------------------------------------------------- | -| [0] | bool | tokenManager the TokenManager called to facilitate cross chain transfers. | +| amount | uint256 | The amount of tokens to burn | -## StandardizedTokenMintBurn - -### tokenManagerRequiresApproval - -```solidity -function tokenManagerRequiresApproval() public pure returns (bool) -``` - -Getter function specifying if the tokenManager requires approval to facilitate cross-chain transfers. -Usually, only mint/burn tokenManagers do not need approval. - -_The return value depends on the implementation of ERC20. -In case of lock/unlock and liquidity pool TokenManagers it is possible to implement transferFrom to allow the -TokenManager specifically to do it permissionlessly. -On the other hand you can implement burn in a way that requires approval for a mint/burn TokenManager_ - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ------------------------------------------------------------------------- | -| [0] | bool | tokenManager the TokenManager called to facilitate cross chain transfers. | - -## TokenManager +## InterchainTokenDeployer -This contract is responsible for handling tokens before initiating a cross chain token transfer, or after receiving one. +This contract is used to deploy new instances of the StandardizedTokenProxy contract. -### interchainTokenService +### implementationAddress ```solidity -contract IInterchainTokenService interchainTokenService +address implementationAddress ``` +Returns the standardized token implementation address + ### constructor ```solidity -constructor(address interchainTokenService_) internal +constructor(address implementationAddress_) public ``` -Constructs the TokenManager contract. +Constructor for the InterchainTokenDeployer contract #### Parameters -| Name | Type | Description | -| ------------------------ | ------- | ------------------------------------------- | -| interchainTokenService\_ | address | The address of the interchain token service | +| Name | Type | Description | +| ---- | ---- | ----------- | +| implementationAddress_ | address | Address of the StandardizedToken contract | -### onlyService +### deployInterchainToken ```solidity -modifier onlyService() +function deployInterchainToken(bytes32 salt, address tokenManager, address distributor, string name, string symbol, uint8 decimals) external payable returns (address tokenAddress) ``` -_A modifier that allows only the interchain token service to execute the function._ +Deploys a new instance of the StandardizedTokenProxy contract -### onlyToken +#### Parameters -```solidity -modifier onlyToken() -``` +| Name | Type | Description | +| ---- | ---- | ----------- | +| salt | bytes32 | The salt used by Create3Deployer | +| tokenManager | address | Address of the token manager | +| distributor | address | Address of the distributor | +| name | string | Name of the token | +| symbol | string | Symbol of the token | +| decimals | uint8 | Decimals of the token | -_A modifier that allows only the token to execute the function._ +#### Return Values -### tokenAddress +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress | address | Address of the deployed token | + +### deployedAddress ```solidity -function tokenAddress() public view virtual returns (address) +function deployedAddress(bytes32 salt) external view returns (address tokenAddress) ``` -A function that should return the address of the token. -Must be overridden in the inheriting contract. +Returns the standardized token deployment address. #### Return Values -| Name | Type | Description | -| ---- | ------- | ----------------------------- | -| [0] | address | address address of the token. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| tokenAddress | address | the token address. | + +## AddressTracker -### setup +### constructor ```solidity -function setup(bytes params) external +constructor(address owner_, string chainName_, string[] trustedChainNames, string[] trustedAddresses) public ``` -_This function should only be called by the proxy, and only once from the proxy constructor_ - -#### Parameters - -| Name | Type | Description | -| ------ | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| params | bytes | the parameters to be used to initialize the TokenManager. The exact format depends on the type of TokenManager used but the first 32 bytes are reserved for the address of the operator, stored as bytes (to be compatible with non-EVM chains) | - -### interchainTransfer +### setTrustedAddress ```solidity -function interchainTransfer(string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable virtual +function setTrustedAddress(string chain, string address_) external ``` -Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. +_Sets the trusted address for the specified chain_ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------------- | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the address of the user to send tokens to. | -| amount | uint256 | the amount of tokens to take from msg.sender. | -| metadata | bytes | | +| Name | Type | Description | +| ---- | ---- | ----------- | +| chain | string | Chain name to be trusted | +| address_ | string | Trusted address to be added for the chain | -### callContractWithInterchainToken +### removeTrustedAddress ```solidity -function callContractWithInterchainToken(string destinationChain, bytes destinationAddress, uint256 amount, bytes data) external payable virtual +function removeTrustedAddress(string chain) external ``` -Calls the service to initiate a cross-chain transfer with data after taking the appropriate amount of tokens from the user. +_Remove the trusted address of the chain._ #### Parameters -| Name | Type | Description | -| ------------------ | ------- | --------------------------------------------- | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the address of the user to send tokens to. | -| amount | uint256 | the amount of tokens to take from msg.sender. | -| data | bytes | the data to pass to the destination contract. | +| Name | Type | Description | +| ---- | ---- | ----------- | +| chain | string | Chain name that should be made untrusted | -### transmitInterchainTransfer +## InterchainTokenExecutable + +### NotService ```solidity -function transmitInterchainTransfer(address sender, string destinationChain, bytes destinationAddress, uint256 amount, bytes metadata) external payable virtual +error NotService(address caller) ``` -Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. This can only be called by the token itself. - -#### Parameters +### interchainTokenService -| Name | Type | Description | -| ------------------ | ------- | ------------------------------------------------------------ | -| sender | address | the address of the user paying for the cross chain transfer. | -| destinationChain | string | the name of the chain to send tokens to. | -| destinationAddress | bytes | the address of the user to send tokens to. | -| amount | uint256 | the amount of tokens to take from msg.sender. | -| metadata | bytes | | +```solidity +address interchainTokenService +``` -### giveToken +### EXECUTE_SUCCESS ```solidity -function giveToken(address destinationAddress, uint256 amount) external returns (uint256) +bytes32 EXECUTE_SUCCESS ``` -This function gives token to a specified address. Can only be called by the service. - -#### Parameters +### constructor -| Name | Type | Description | -| ------------------ | ------- | ------------------------------ | -| destinationAddress | address | the address to give tokens to. | -| amount | uint256 | the amount of token to give. | +```solidity +constructor(address interchainTokenService_) internal +``` -#### Return Values +### onlyService -| Name | Type | Description | -| ---- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| [0] | uint256 | the amount of token actually given, which will only be different than `amount` in cases where the token takes some on-transfer fee. | +```solidity +modifier onlyService() +``` -### setFlowLimit +### executeWithInterchainToken ```solidity -function setFlowLimit(uint256 flowLimit) external +function executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) external virtual returns (bytes32) ``` -This function sets the flow limit for this TokenManager. Can only be called by the operator. +This will be called after the tokens arrive to this contract + +_Executable should revert unless the msg.sender is the InterchainTokenService_ #### Parameters -| Name | Type | Description | -| --------- | ------- | -------------------------------------------------------------------------------------------------- | -| flowLimit | uint256 | the maximum difference between the tokens flowing in and/or out at any given interval of time (6h) | +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | the name of the source chain | +| sourceAddress | bytes | the address that sent the contract call | +| data | bytes | the data to be processed | +| tokenId | bytes32 | the tokenId of the token manager managing the token. | +| token | address | the address of the token. | +| amount | uint256 | the amount of token that was sent | -### \_takeToken +### _executeWithInterchainToken ```solidity -function _takeToken(address from, uint256 amount) internal virtual returns (uint256) +function _executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) internal virtual ``` -Transfers tokens from a specific address to this contract. -Must be overridden in the inheriting contract. +## InterchainTokenExpressExecutable -#### Parameters +### EXPRESS_EXECUTE_SUCCESS -| Name | Type | Description | -| ------ | ------- | ---------------------------------------------- | -| from | address | The address from which the tokens will be sent | -| amount | uint256 | The amount of tokens to receive | +```solidity +bytes32 EXPRESS_EXECUTE_SUCCESS +``` -#### Return Values +### constructor -| Name | Type | Description | -| ---- | ------- | ------------------------------ | -| [0] | uint256 | uint amount of tokens received | +```solidity +constructor(address interchainTokenService_) internal +``` -### \_giveToken +### expressExecuteWithInterchainToken ```solidity -function _giveToken(address receiver, uint256 amount) internal virtual returns (uint256) +function expressExecuteWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) external virtual returns (bytes32) ``` -Transfers tokens from this contract to a specific address. -Must be overridden in the inheriting contract. +This will be called after the tokens arrive to this contract -#### Parameters +_Executable should revert unless the msg.sender is the InterchainTokenService_ -| Name | Type | Description | -| ------ | ------- | -------------------------------------------- | -| from | address | The address to which the tokens will be sent | -| amount | uint256 | The amount of tokens to send | +#### Parameters -#### Return Values +| Name | Type | Description | +| ---- | ---- | ----------- | +| sourceChain | string | the name of the source chain | +| sourceAddress | bytes | the address that sent the contract call | +| data | bytes | the data to be processed | +| tokenId | bytes32 | the token id of the token manager managing the token. | +| token | address | the address of the token. | +| amount | uint256 | the amount of token that was sent | -| Name | Type | Description | -| ---- | ------- | -------------------------- | -| [0] | uint256 | uint amount of tokens sent | +## IAddressTracker -### \_setup +### setTrustedAddress ```solidity -function _setup(bytes params) internal virtual +function setTrustedAddress(string chain, string address_) external ``` -_Additional setup logic to perform -Must be overridden in the inheriting contract._ +_Sets the trusted address for the specified chain_ #### Parameters -| Name | Type | Description | -| ------ | ----- | -------------------- | -| params | bytes | The setup parameters | +| Name | Type | Description | +| ---- | ---- | ----------- | +| chain | string | Chain name to be trusted | +| address_ | string | Trusted address to be added for the chain | -### \_getTokenId +### removeTrustedAddress ```solidity -function _getinterchainTokenId() internal view returns (bytes32 tokenId) +function removeTrustedAddress(string chain) external ``` -Gets the token ID from the token manager proxy. +_Remove the trusted address of the chain._ -#### Return Values +#### Parameters -| Name | Type | Description | -| ------- | ------- | ------------------- | -| tokenId | bytes32 | The ID of the token | +| Name | Type | Description | +| ---- | ---- | ----------- | +| chain | string | Chain name that should be made untrusted | -## TokenManagerAddressStorage +## IMockAxelarGateway -This contract extends the TokenManager contract and provides additional functionality to store and retrieve -the token address using a predetermined storage slot +This interface is used for testing with an AxelarGateway that will arbitrarily approve calls. -### constructor +### NotSelf ```solidity -constructor(address interchainTokenService_) internal +error NotSelf() ``` -_Creates an instance of the TokenManagerAddressStorage contract._ - -#### Parameters - -| Name | Type | Description | -| ------------------------ | ------- | ---------------------------------------------------- | -| interchainTokenService\_ | address | The address of the interchain token service contract | - -### TOKEN_ADDRESS_SLOT +### NotProxy ```solidity -uint256 TOKEN_ADDRESS_SLOT +error NotProxy() ``` -### tokenAddress +### InvalidCodeHash ```solidity -function tokenAddress() public view returns (address tokenAddress_) +error InvalidCodeHash() ``` -_Reads the stored token address from the predetermined storage slot_ - -#### Return Values +### SetupFailed -| Name | Type | Description | -| -------------- | ------- | ------------------------ | -| tokenAddress\_ | address | The address of the token | +```solidity +error SetupFailed() +``` -### \_setTokenAddress +### InvalidAuthModule ```solidity -function _setTokenAddress(address tokenAddress_) internal +error InvalidAuthModule() ``` -_Stores the token address in the predetermined storage slot_ +### InvalidTokenDeployer -#### Parameters +```solidity +error InvalidTokenDeployer() +``` -| Name | Type | Description | -| -------------- | ------- | --------------------------------- | -| tokenAddress\_ | address | The address of the token to store | +### InvalidAmount -## TokenManagerLiquidityPool +```solidity +error InvalidAmount() +``` -This contract is a an implementation of TokenManager that stores all tokens in a separate liquity pool -rather than within itself. +### InvalidChainId -_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. -It uses the Axelar SDK to safely transfer tokens._ +```solidity +error InvalidChainId() +``` -### LIQUIDITY_POOL_SLOT +### InvalidCommands ```solidity -uint256 LIQUIDITY_POOL_SLOT +error InvalidCommands() ``` -### constructor +### TokenDoesNotExist ```solidity -constructor(address interchainTokenService_) public +error TokenDoesNotExist(string symbol) ``` -_Constructs an instance of TokenManagerLiquidityPool. Calls the constructor -of TokenManagerAddressStorage which calls the constructor of TokenManager._ - -#### Parameters +### TokenAlreadyExists -| Name | Type | Description | -| ------------------------ | ------- | ---------------------------------------------------- | -| interchainTokenService\_ | address | The address of the interchain token service contract | +```solidity +error TokenAlreadyExists(string symbol) +``` -### implementationType +### TokenDeployFailed ```solidity -function implementationType() external pure returns (uint256) +error TokenDeployFailed(string symbol) ``` -A function that should return the implementation type of the token manager. - -### \_setup +### TokenContractDoesNotExist ```solidity -function _setup(bytes params) internal +error TokenContractDoesNotExist(address token) ``` -_Sets up the token address and liquidity pool address._ - -#### Parameters +### BurnFailed -| Name | Type | Description | -| ------ | ----- | ------------------------------------------------------------------------------------------------------- | -| params | bytes | The setup parameters in bytes. Should be encoded with the token address and the liquidity pool address. | +```solidity +error BurnFailed(string symbol) +``` -### \_setLiquidityPool +### MintFailed ```solidity -function _setLiquidityPool(address liquidityPool_) internal +error MintFailed(string symbol) ``` -_Stores the liquidity pool address at a specific storage slot_ - -#### Parameters +### InvalidSetMintLimitsParams -| Name | Type | Description | -| --------------- | ------- | --------------------------------- | -| liquidityPool\_ | address | The address of the liquidity pool | +```solidity +error InvalidSetMintLimitsParams() +``` -### liquidityPool +### ExceedMintLimit ```solidity -function liquidityPool() public view returns (address liquidityPool_) +error ExceedMintLimit(string symbol) ``` -_Reads the stored liquidity pool address from the specified storage slot_ - -#### Return Values +### TokenSent -| Name | Type | Description | -| --------------- | ------- | --------------------------------- | -| liquidityPool\_ | address | The address of the liquidity pool | +```solidity +event TokenSent(address sender, string destinationChain, string destinationAddress, string symbol, uint256 amount) +``` -### setLiquidityPool +### ContractCall ```solidity -function setLiquidityPool(address newLiquidityPool) external +event ContractCall(address sender, string destinationChain, string destinationContractAddress, bytes32 payloadHash, bytes payload) ``` -_Updates the address of the liquidity pool. Can only be called by the operator._ - -#### Parameters +### ContractCallWithToken -| Name | Type | Description | -| ---------------- | ------- | ------------------------------------- | -| newLiquidityPool | address | The new address of the liquidity pool | +```solidity +event ContractCallWithToken(address sender, string destinationChain, string destinationContractAddress, bytes32 payloadHash, bytes payload, string symbol, uint256 amount) +``` -### \_takeToken +### Executed ```solidity -function _takeToken(address from, uint256 amount) internal returns (uint256) +event Executed(bytes32 commandId) ``` -_Transfers a specified amount of tokens from a specified address to the liquidity pool._ - -#### Parameters +### TokenDeployed -| Name | Type | Description | -| ------ | ------- | ----------------------------------- | -| from | address | The address to transfer tokens from | -| amount | uint256 | The amount of tokens to transfer | +```solidity +event TokenDeployed(string symbol, address tokenAddresses) +``` -#### Return Values +### ContractCallApproved -| Name | Type | Description | -| ---- | ------- | --------------------------------------------------------------------------------------------- | -| [0] | uint256 | uint The actual amount of tokens transferred. This allows support for fee-on-transfer tokens. | +```solidity +event ContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, bytes32 sourceTxHash, uint256 sourceEventIndex) +``` -### \_giveToken +### ContractCallApprovedWithMint ```solidity -function _giveToken(address to, uint256 amount) internal returns (uint256) +event ContractCallApprovedWithMint(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, string symbol, uint256 amount, bytes32 sourceTxHash, uint256 sourceEventIndex) ``` -_Transfers a specified amount of tokens from the liquidity pool to a specified address._ +### TokenMintLimitUpdated -#### Parameters +```solidity +event TokenMintLimitUpdated(string symbol, uint256 limit) +``` -| Name | Type | Description | -| ------ | ------- | --------------------------------- | -| to | address | The address to transfer tokens to | -| amount | uint256 | The amount of tokens to transfer | +### OperatorshipTransferred -#### Return Values +```solidity +event OperatorshipTransferred(bytes newOperatorsData) +``` -| Name | Type | Description | -| ---- | ------- | -------------------------------------------- | -| [0] | uint256 | uint The actual amount of tokens transferred | +### Upgraded -## TokenManagerLockUnlock +```solidity +event Upgraded(address implementation) +``` -This contract is an implementation of TokenManager that locks and unlocks a specific token on behalf of the interchain token service. +### callContract -_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. -It uses the Axelar SDK to safely transfer tokens._ +```solidity +function callContract(string destinationChain, string contractAddress, bytes payload) external +``` -### constructor +### isContractCallApproved ```solidity -constructor(address interchainTokenService_) public +function isContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) external view returns (bool) ``` -_Constructs an instance of TokenManagerLockUnlock. Calls the constructor -of TokenManagerAddressStorage which calls the constructor of TokenManager._ - -#### Parameters +### validateContractCall -| Name | Type | Description | -| ------------------------ | ------- | ---------------------------------------------------- | -| interchainTokenService\_ | address | The address of the interchain token service contract | +```solidity +function validateContractCall(bytes32 commandId, string sourceChain, string sourceAddress, bytes32 payloadHash) external returns (bool) +``` -### implementationType +### setTokenAddress ```solidity -function implementationType() external pure returns (uint256) +function setTokenAddress(string symbol, address tokenAddress) external ``` -A function that should return the implementation type of the token manager. - -### \_setup +### approveContractCall ```solidity -function _setup(bytes params) internal +function approveContractCall(bytes params, bytes32 commandId) external ``` -_Sets up the token address._ - -#### Parameters +### isCommandExecuted -| Name | Type | Description | -| ------ | ----- | ------------------------------------------------------------------------ | -| params | bytes | The setup parameters in bytes. Should be encoded with the token address. | +```solidity +function isCommandExecuted(bytes32 commandId) external view returns (bool) +``` -### \_takeToken +### tokenAddresses ```solidity -function _takeToken(address from, uint256 amount) internal returns (uint256) +function tokenAddresses(string symbol) external view returns (address tokenAddress) ``` -_Transfers a specified amount of tokens from a specified address to this contract._ - -#### Parameters +## IStandardizedTokenProxy -| Name | Type | Description | -| ------ | ------- | ----------------------------------- | -| from | address | The address to transfer tokens from | -| amount | uint256 | The amount of tokens to transfer | +_Proxy contract for StandardizedToken contracts. Inherits from FixedProxy and implements IStandardizedTokenProxy._ -#### Return Values +## CanonicalTokenRegistrarProxy -| Name | Type | Description | -| ---- | ------- | --------------------------------------------------------------------------------------------- | -| [0] | uint256 | uint The actual amount of tokens transferred. This allows support for fee-on-transfer tokens. | +_Proxy contract for interchain token service contracts. Inherits from the Proxy contract._ -### \_giveToken +### constructor ```solidity -function _giveToken(address to, uint256 amount) internal returns (uint256) +constructor(address implementationAddress, address owner) public ``` -_Transfers a specified amount of tokens from this contract to a specified address._ +_Constructs the InterchainTokenServiceProxy contract._ #### Parameters -| Name | Type | Description | -| ------ | ------- | --------------------------------- | -| to | address | The address to transfer tokens to | -| amount | uint256 | The amount of tokens to transfer | +| Name | Type | Description | +| ---- | ---- | ----------- | +| implementationAddress | address | Address of the interchain token service implementation | +| owner | address | Address of the owner of the proxy | + +### contractId + +```solidity +function contractId() internal pure returns (bytes32) +``` + +_Override for the 'contractId' function in FinalProxy. Returns a unique identifier for this contract._ #### Return Values -| Name | Type | Description | -| ---- | ------- | -------------------------------------------- | -| [0] | uint256 | uint The actual amount of tokens transferred | - -## TokenManagerMintBurn +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | bytes32 | bytes32 identifier for this contract | -This contract is an implementation of TokenManager that mints and burns a specific token on behalf of the interchain token service. +## InterchainTokenServiceProxy -_This contract extends TokenManagerAddressStorage and provides implementation for its abstract methods. -It uses the Axelar SDK to safely transfer tokens._ +_Proxy contract for interchain token service contracts. Inherits from the FinalProxy contract._ ### constructor ```solidity -constructor(address interchainTokenService_) public +constructor(address implementationAddress, address owner, address operator) public ``` -_Constructs an instance of TokenManagerMintBurn. Calls the constructor -of TokenManagerAddressStorage which calls the constructor of TokenManager._ +_Constructs the InterchainTokenServiceProxy contract._ #### Parameters -| Name | Type | Description | -| ------------------------ | ------- | ---------------------------------------------------- | -| interchainTokenService\_ | address | The address of the interchain token service contract | +| Name | Type | Description | +| ---- | ---- | ----------- | +| implementationAddress | address | Address of the interchain token service implementation | +| owner | address | Address of the owner of the proxy | +| operator | address | | -### implementationType +### contractId ```solidity -function implementationType() external pure returns (uint256) +function contractId() internal pure returns (bytes32) ``` -A function that should return the implementation type of the token manager. - -### \_setup +_Override for the 'contractId' function in FinalProxy. Returns a unique identifier for this contract._ -```solidity -function _setup(bytes params) internal -``` +#### Return Values -_Sets up the token address._ +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | bytes32 | bytes32 identifier for this contract | -#### Parameters +## TokenRegistrarProxy -| Name | Type | Description | -| ------ | ----- | ------------------------------------------------------------------------ | -| params | bytes | The setup parameters in bytes. Should be encoded with the token address. | +_Proxy contract for interchain token service contracts. Inherits from the Proxy contract._ -### \_takeToken +### constructor ```solidity -function _takeToken(address from, uint256 amount) internal returns (uint256) +constructor(address implementationAddress, address owner) public ``` -_Burns the specified amount of tokens from a particular address._ +_Constructs the InterchainTokenServiceProxy contract._ #### Parameters -| Name | Type | Description | -| ------ | ------- | --------------------------- | -| from | address | Address to burn tokens from | -| amount | uint256 | Amount of tokens to burn | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ---------------------------- | -| [0] | uint256 | uint Amount of tokens burned | +| Name | Type | Description | +| ---- | ---- | ----------- | +| implementationAddress | address | Address of the interchain token service implementation | +| owner | address | Address of the owner of the proxy | -### \_giveToken +### contractId ```solidity -function _giveToken(address to, uint256 amount) internal returns (uint256) +function contractId() internal pure returns (bytes32) ``` -_Mints the specified amount of tokens to a particular address_ +_Override for the 'contractId' function in FinalProxy. Returns a unique identifier for this contract._ -#### Parameters +#### Return Values -| Name | Type | Description | -| ------ | ------- | ------------------------- | -| to | address | Address to mint tokens to | -| amount | uint256 | Amount of tokens to mint | +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | bytes32 | bytes32 identifier for this contract | -#### Return Values +## InterchainExecutableTest -| Name | Type | Description | -| ---- | ------- | ---------------------------- | -| [0] | uint256 | uint Amount of tokens minted | +### MessageReceived -## Distributable +```solidity +event MessageReceived(string sourceChain, bytes sourceAddress, address receiver, string message, bytes32 tokenId, uint256 amount) +``` -_A contract module which provides a basic access control mechanism, where -there is an account (a distributor) that can be granted exclusive access to -specific functions. This module is used through inheritance._ +### constructor -### DISTRIBUTOR_SLOT +```solidity +constructor(address interchainTokenService_) public +``` + +### lastMessage ```solidity -uint256 DISTRIBUTOR_SLOT +string lastMessage ``` -### onlyDistributor +### _executeWithInterchainToken ```solidity -modifier onlyDistributor() +function _executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) internal ``` -_Throws a NotDistributor custom error if called by any account other than the distributor._ +## DistributableTest -### distributor +### nonce ```solidity -function distributor() public view returns (address distributor_) +uint256 nonce ``` -Get the address of the distributor - -#### Return Values +### constructor -| Name | Type | Description | -| ------------- | ------- | ------------------ | -| distributor\_ | address | of the distributor | +```solidity +constructor(address distributor) public +``` -### \_setDistributor +### testDistributable ```solidity -function _setDistributor(address distributor_) internal +function testDistributable() external ``` -_Internal function that stores the new distributor address in the correct storage slot_ +### distributorRole -#### Parameters +```solidity +function distributorRole() external pure returns (uint8) +``` -| Name | Type | Description | -| ------------- | ------- | ---------------------------------- | -| distributor\_ | address | The address of the new distributor | +## FlowLimitTest -### transferDistributorship +### TOKEN_ID ```solidity -function transferDistributorship(address distributor_) external +bytes32 TOKEN_ID ``` -Change the distributor of the contract +### setFlowLimit -_Can only be called by the current distributor_ +```solidity +function setFlowLimit(uint256 flowLimit) external +``` -#### Parameters +### addFlowIn -| Name | Type | Description | -| ------------- | ------- | ---------------------------------- | -| distributor\_ | address | The address of the new distributor | +```solidity +function addFlowIn(uint256 flowInAmount) external +``` -## FlowLimit +### addFlowOut -Implements flow limit logic for interchain token transfers. +```solidity +function addFlowOut(uint256 flowOutAmount) external +``` -_This contract implements low-level assembly for optimization purposes._ +## FlowLimitTestLiveNetwork ### FLOW_LIMIT_SLOT @@ -4762,6 +5202,12 @@ uint256 PREFIX_FLOW_OUT_AMOUNT uint256 PREFIX_FLOW_IN_AMOUNT ``` +### TOKEN_ID + +```solidity +bytes32 TOKEN_ID +``` + ### EPOCH_TIME ```solidity @@ -4771,245 +5217,107 @@ uint256 EPOCH_TIME ### flowLimit ```solidity -function flowLimit() public view returns (uint256 flowLimit) +function flowLimit() public view returns (uint256 flowLimit_) ``` Returns the current flow limit #### Return Values -| Name | Type | Description | -| --------- | ------- | ---------------------------- | -| flowLimit | uint256 | The current flow limit value | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowLimit_ | uint256 | The current flow limit value | -### \_setFlowLimit +### _setFlowLimit ```solidity -function _setFlowLimit(uint256 flowLimit, bytes32 tokenId) internal +function _setFlowLimit(uint256 flowLimit_) internal ``` -_Internal function to set the flow limit_ - -#### Parameters - -| Name | Type | Description | -| --------- | ------- | -------------------------------------------- | -| flowLimit | uint256 | The value to set the flow limit to | -| tokenId | bytes32 | The id of the token whose limit is being set | - -### \_getFlowOutSlot +### _getFlowOutSlot ```solidity function _getFlowOutSlot(uint256 epoch) internal pure returns (uint256 slot) ``` -_Returns the slot which is used to get the flow out amount for a specific epoch_ - -#### Parameters - -| Name | Type | Description | -| ----- | ------- | ---------------------------------------- | -| epoch | uint256 | The epoch to get the flow out amount for | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | ---------------------------------------- | -| slot | uint256 | The slot to get the flow out amount from | - -### \_getFlowInSlot +### _getFlowInSlot ```solidity function _getFlowInSlot(uint256 epoch) internal pure returns (uint256 slot) ``` -_Returns the slot which is used to get the flow in amount for a specific epoch_ - -#### Parameters - -| Name | Type | Description | -| ----- | ------- | --------------------------------------- | -| epoch | uint256 | The epoch to get the flow in amount for | - -#### Return Values - -| Name | Type | Description | -| ---- | ------- | --------------------------------------- | -| slot | uint256 | The slot to get the flow in amount from | - ### flowOutAmount ```solidity -function flowOutAmount() external view returns (uint256 flowOutAmount) +function flowOutAmount() external view returns (uint256 flowOutAmount_) ``` Returns the current flow out amount #### Return Values -| Name | Type | Description | -| ------------- | ------- | --------------------------- | -| flowOutAmount | uint256 | The current flow out amount | +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowOutAmount_ | uint256 | The current flow out amount | ### flowInAmount ```solidity -function flowInAmount() external view returns (uint256 flowInAmount) +function flowInAmount() external view returns (uint256 flowInAmount_) ``` Returns the current flow in amount #### Return Values -| Name | Type | Description | -| ------------ | ------- | -------------------------- | -| flowInAmount | uint256 | The current flow in amount | - -### \_addFlow - -```solidity -function _addFlow(uint256 flowLimit, uint256 slotToAdd, uint256 slotToCompare, uint256 flowAmount) internal -``` - -_Adds a flow amount while ensuring it does not exceed the flow limit_ - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | ------------------------------------ | -| flowLimit | uint256 | | -| slotToAdd | uint256 | The slot to add the flow to | -| slotToCompare | uint256 | The slot to compare the flow against | -| flowAmount | uint256 | The flow amount to add | - -### \_addFlowOut - -```solidity -function _addFlowOut(uint256 flowOutAmount) internal -``` - -_Adds a flow out amount_ - -#### Parameters - -| Name | Type | Description | -| ------------- | ------- | -------------------------- | -| flowOutAmount | uint256 | The flow out amount to add | - -### \_addFlowIn - -```solidity -function _addFlowIn(uint256 flowInAmount) internal -``` - -_Adds a flow in amount_ - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ------------------------- | -| flowInAmount | uint256 | The flow in amount to add | - -## Implementation - -This contract serves as a base for other contracts and enforces a proxy-first access restriction. - -_Derived contracts must implement the setup function._ +| Name | Type | Description | +| ---- | ---- | ----------- | +| flowInAmount_ | uint256 | The current flow in amount | -### constructor +### _addFlow ```solidity -constructor() internal +function _addFlow(uint256 flowLimit_, uint256 slotToAdd, uint256 slotToCompare, uint256 flowAmount) internal ``` -_Contract constructor that sets the implementation address to the address of this contract._ - -### onlyProxy +### _addFlowOut ```solidity -modifier onlyProxy() +function _addFlowOut(uint256 flowOutAmount_) internal ``` -_Modifier to require the caller to be the proxy contract. -Reverts if the caller is the current contract (i.e., the implementation contract itself)._ - -### setup +### _addFlowIn ```solidity -function setup(bytes params) external virtual +function _addFlowIn(uint256 flowInAmount_) internal ``` -Initializes contract parameters. -This function is intended to be overridden by derived contracts. -The overriding function must have the onlyProxy modifier. - -#### Parameters - -| Name | Type | Description | -| ------ | ----- | -------------------------------------------- | -| params | bytes | The parameters to be used for initialization | - -## TokenManagerDeployer - -This contract is used to deploy new instances of the TokenManagerProxy contract. - -### deployer +### setFlowLimit ```solidity -contract Create3Deployer deployer +function setFlowLimit(uint256 flowLimit_) external ``` -Getter for the Create3Deployer. - -### constructor +### addFlowIn ```solidity -constructor(address deployer_) public +function addFlowIn(uint256 flowInAmount_) external ``` -Constructor for the TokenManagerDeployer contract - -#### Parameters - -| Name | Type | Description | -| ---------- | ------- | --------------------------------------- | -| deployer\_ | address | Address of the Create3Deployer contract | - -### deployTokenManager +### addFlowOut ```solidity -function deployTokenManager(bytes32 tokenId, uint256 implementationType, bytes params) external payable returns(address tokenManager) +function addFlowOut(uint256 flowOutAmount_) external ``` -Deploys a new instance of the TokenManagerProxy contract - -#### Parameters - -| Name | Type | Description | -| ------------------ | ------- | ------------------------------------------------------------ | -| tokenId | bytes32 | The unique identifier for the token | -| implementationType | uint256 | Token manager implementation type | -| params | bytes | Additional parameters used in the setup of the token manager | - -#### Return Values - -| Name | Type | Description | -| ------------ | ------- | ---------------------------------------- | -| tokenManager | address | the address of the deployed tokenManager | - -## IStandardizedToken - -This contract implements a standardized token which extends InterchainToken functionality. -This contract also inherits Distributable and Implementation logic. +## ImplementationTest -### contractId +### val ```solidity -function contractId() external view returns (bytes32) +uint256 val ``` -Returns the contract id, which a proxy can check to ensure no false implementation was used. - ### setup ```solidity @@ -5022,114 +5330,59 @@ _This should be hidden by the proxy._ #### Parameters -| Name | Type | Description | -| ------ | ----- | ------------------------------------------- | +| Name | Type | Description | +| ---- | ---- | ----------- | | params | bytes | the data to be used for the initialization. | -### WrongImplementation +## NakedProxy -```solidity -error WrongImplementation() -``` - -### contractId +### implementation ```solidity -function contractId() external view returns (bytes32) +address implementation ``` -Returns the contract id, which a proxy can check to ensure no false implementation was used. - -## StandardizedTokenProxy - -\_Proxy contract for StandardizedToken contracts. Inherits from FixedProxy. - -### contractId +### constructor ```solidity -bytes32 contractId +constructor(address implementation_) public ``` -Returns the contract id, which a proxy can check to ensure no false implementation was used. - -### constructor +### fallback ```solidity -constructor(address implementationAddress, bytes params) public +fallback() external payable virtual ``` -_Constructs the StandardizedTokenProxy contract._ - -#### Parameters - -| Name | Type | Description | -| --------------------- | ------- | ------------------------------------------------------------ | -| implementationAddress | address | Address of the StandardizedToken implementation | -| params | bytes | Initialization parameters for the StandardizedToken contract | - -## InterchainTokenDeployer - -This contract is used to deploy new instances of the StandardizedTokenProxy contract. - -### deployer +### receive ```solidity -contract Create3Deployer deployer +receive() external payable virtual ``` -Getter for the Create3Deployer. +## OperatorableTest -### implementationMintBurnAddress +### nonce ```solidity -address implementationMintBurnAddress +uint256 nonce ``` -### implementationLockUnlockAddress +### constructor ```solidity -address implementationLockUnlockAddress +constructor(address operator) public ``` -### constructor +### testOperatorable ```solidity -constructor(address deployer_, address implementationLockUnlockAddress_, address implementationMintBurnAddress_) public +function testOperatorable() external ``` -Constructor for the InterchainTokenDeployer contract - -#### Parameters - -| Name | Type | Description | -| --------------------------------- | ------- | --------------------------------------------------- | -| deployer\_ | address | Address of the Create3Deployer contract | -| implementationLockUnlockAddress\_ | address | Address of the StandardizedTokenLockUnlock contract | -| implementationMintBurnAddress\_ | address | Address of the StandardizedTokenMintBurn contract | - -### deployInterchainToken +### operatorRole ```solidity -function deployInterchainToken(bytes32 salt, address tokenManager, address distributor, string name, string symbol, uint8 decimals, uint256 mintAmount, address mintTo) external payable returns (address tokenAddress) +function operatorRole() external pure returns (uint8) ``` -Deploys a new instance of the StandardizedTokenProxy contract - -#### Parameters - -| Name | Type | Description | -| ------------ | ------- | ---------------------------------- | -| salt | bytes32 | The salt used by Create3Deployer | -| tokenManager | address | Address of the token manager | -| distributor | address | Address of the distributor | -| name | string | Name of the token | -| symbol | string | Symbol of the token | -| decimals | uint8 | Decimals of the token | -| mintAmount | uint256 | Amount of tokens to mint initially | -| mintTo | address | Address to mint initial tokens to | - -#### Return Values - -| Name | Type | Description | -| ------------ | ------- | --------------------- | -| tokenAddress | address | address of the token. |