Skip to content

Commit

Permalink
Renamed TokenX -> EToken (#67)
Browse files Browse the repository at this point in the history
* Renamed TokenX to EToken

* a -> an before EToken

* Renamed README.md to match branch
  • Loading branch information
peteremiljensen committed Jan 15, 2019
1 parent a167621 commit 0ac9232
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 116 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TokenX - an [eToro](https://www.etoro.com/) stablecoin
[![Build Status](https://circleci.com/gh/eTokenize/TokenX.svg?style=shield&circle-token=797dc9ae3f839ac4fc5d5edad6c993ae9faa3943&maxAge=0)](https://circleci.com/gh/eTokenize/TokenX) [![Coverage Status](https://coveralls.io/repos/github/eTokenize/TokenX/badge.svg?t=un8yQ7&maxAge=0)](https://coveralls.io/github/eTokenize/TokenX)
# eToken - an [eToro](https://www.etoro.com/) stablecoin
[![Build Status](https://circleci.com/gh/eTokenize/eToken.svg?style=shield&circle-token=797dc9ae3f839ac4fc5d5edad6c993ae9faa3943&maxAge=0)](https://circleci.com/gh/eTokenize/eToken) [![Coverage Status](https://coveralls.io/repos/github/eTokenize/eToken/badge.svg?t=un8yQ7&maxAge=0)](https://coveralls.io/github/eTokenize/eToken)

TokenX is stablecoin implementation by [eToro](https://www.etoro.com/) targeting the [Ethereum](https://www.ethereum.org/) platform.
eToken is stablecoin implementation by [eToro](https://www.etoro.com/) targeting the [Ethereum](https://www.ethereum.org/) platform.

## USAGE
To test the library and setup the development environment, issue the following commands in a shell:
Expand All @@ -20,8 +20,8 @@ This repository has only been tested on UNIX-derived systems.

*__Figure 1:__ Design overview. To simplify the overview, aspects related to the token upgrading functionality are not shown here but are described separately in Figure 2.*

### TokenX - ERC20
This document describes the design and implementation of the smart contracts comprising TokenX which is intended to be used for powering several different stablecoins representing various assets. At its core, TokenX is an ERC20 token with additional supporting infrastructure relating to token management, permission management and token upgradability. The remainder of this document gives a high-level overview of the design and implementation of the token itself and its supporting infrastructure.
### eToken - ERC20
This document describes the design and implementation of the smart contracts comprising eToken which is intended to be used for powering several different stablecoins representing various assets. At its core, eToken is an ERC20 token with additional supporting infrastructure relating to token management, permission management and token upgradability. The remainder of this document gives a high-level overview of the design and implementation of the token itself and its supporting infrastructure.

Initially, we intended to base our implementation entirely on the OpenZeppelin (OZ) solidity library and extend from its unmodified ERC20 implementation. However, we found that implementing a number of our desired features was impossible without modifying the underlying OZ code. Therefore, our current implementation contains several modified and extended OZ components.When modifying OZ components, we have attempted to retain major design decisions and making non-intrusive and predictable code alteration.

Expand All @@ -33,7 +33,7 @@ An overview of the design is shown in Figure 1 and a detailed diagram of the int

* The Ethereum Name System (ENS) is used to allow frontends to identify (possibly changing) contract addresses through a constant name.

* TokenX(n) are ERC20 tokens which uses an ERC20 implementation extended from the OpenZeppelin library to enable the use of an separate contract for storing balances and allowances. The need for this separation was driven by our requirement of being able to upgrade the tokens. We discuss the token implementation itself in the following section.
* eToken(n) are ERC20 tokens which uses an ERC20 implementation extended from the OpenZeppelin library to enable the use of an separate contract for storing balances and allowances. The need for this separation was driven by our requirement of being able to upgrade the tokens. We discuss the token implementation itself in the following section.

#### Upgradability and external storage ERC20 implementation
Due to the immutability of Ethereum smart contracts, upgrading the functionality of a previously deployed contract is a well known challenge. The strategy we use for upgrading previously deployed tokens are similar to, eg., TrueUSD and Tether USD and works by allowing the functions comprising the external interface of a token to which modes such that they proxy all calls to a new contract. In particular, the following is achieved.
Expand Down Expand Up @@ -99,7 +99,7 @@ In order to limit the damage which can be caused by a compromised minter account
Path | Description
------------- | -------------
`contracts/` | All the solidity files making up the implementation
`contracts/token` | Contains the TokenX implementation
`contracts/token` | Contains the eToken implementation
`contracts/token/ERC20` | ERC20 implementation using an external storage
`contracts/roles` | Defines the roles implementation, i.e. whitelisting, blacklisting, miners etc.
`contracts/lifecycle` | Implements lifecycle behaviors. Taken from OpenZeppelin
Expand Down
48 changes: 24 additions & 24 deletions contracts/TokenManager.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.24;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "./token/ITokenX.sol";
import "./token/IEToken.sol";

/**
* @title The Token Manager contract
Expand All @@ -10,23 +10,23 @@ import "./token/ITokenX.sol";
contract TokenManager is Ownable {

/**
* @dev A TokenEntry defines a relation between a TokenX instance and the
* @dev A TokenEntry defines a relation between an EToken instance and the
* index of the names list containing the name of the token.
*/
struct TokenEntry {
bool exists;
uint index;
ITokenX token;
IEToken token;
}

mapping (bytes32 => TokenEntry) private tokens;
bytes32[] private names;

event TokenAdded(bytes32 indexed name, ITokenX indexed addr);
event TokenDeleted(bytes32 indexed name, ITokenX indexed addr);
event TokenAdded(bytes32 indexed name, IEToken indexed addr);
event TokenDeleted(bytes32 indexed name, IEToken indexed addr);
event TokenUpgraded(bytes32 indexed name,
ITokenX indexed from,
ITokenX indexed to);
IEToken indexed from,
IEToken indexed to);

/**
* @dev Require that the token _name exists
Expand All @@ -47,32 +47,32 @@ contract TokenManager is Ownable {
}

/**
* @dev Require that the token _iTokenX is not null
* @param _iTokenX Token that is checked for
* @dev Require that the token _iEToken is not null
* @param _iEToken Token that is checked for
*/
modifier notNullToken(ITokenX _iTokenX) {
require(_iTokenX != ITokenX(0), "Supplied token is null");
modifier notNullToken(IEToken _iEToken) {
require(_iEToken != IEToken(0), "Supplied token is null");
_;
}

/**
* @dev Adds a token to the tokenmanager
* @param _name Name of the token to be added
* @param _iTokenX Token to be added
* @param _iEToken Token to be added
*/
function addToken(bytes32 _name, ITokenX _iTokenX)
function addToken(bytes32 _name, IEToken _iEToken)
public
onlyOwner
tokenNotExists(_name)
notNullToken(_iTokenX)
notNullToken(_iEToken)
{
tokens[_name] = TokenEntry({
index: names.length,
token: _iTokenX,
token: _iEToken,
exists: true
});
names.push(_name);
emit TokenAdded(_name, _iTokenX);
emit TokenAdded(_name, _iEToken);
}

/**
Expand All @@ -84,7 +84,7 @@ contract TokenManager is Ownable {
onlyOwner
tokenExists(_name)
{
ITokenX prev = tokens[_name].token;
IEToken prev = tokens[_name].token;
delete names[tokens[_name].index];
delete tokens[_name].token;
delete tokens[_name];
Expand All @@ -94,17 +94,17 @@ contract TokenManager is Ownable {
/**
* @dev Upgrades a token
* @param _name Name of token to be upgraded
* @param _iTokenX Upgraded version of token
* @param _iEToken Upgraded version of token
*/
function upgradeToken(bytes32 _name, ITokenX _iTokenX)
function upgradeToken(bytes32 _name, IEToken _iEToken)
public
onlyOwner
tokenExists(_name)
notNullToken(_iTokenX)
notNullToken(_iEToken)
{
ITokenX prev = tokens[_name].token;
tokens[_name].token = _iTokenX;
emit TokenUpgraded(_name, prev, _iTokenX);
IEToken prev = tokens[_name].token;
tokens[_name].token = _iEToken;
emit TokenUpgraded(_name, prev, _iEToken);
}

/**
Expand All @@ -116,7 +116,7 @@ contract TokenManager is Ownable {
public
tokenExists(_name)
view
returns (ITokenX)
returns (IEToken)
{
return tokens[_name].token;
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/mocks/TokenXExplicitSenderMock.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pragma solidity ^0.4.24;

import "../token/TokenXExplicitSender.sol";
import "../token/ETokenExplicitSender.sol";

/**
* @title Mock contract for testing TokenXExplicitSender
* @title Mock contract for testing ETokenExplicitSender
*/
contract TokenXExplicitSenderMock is TokenXExplicitSender {
contract ETokenExplicitSenderMock is ETokenExplicitSender {

/**
* Initializes an TokenXExplicitSender. Forwards parameters
* Initializes an ETokenExplicitSender. Forwards parameters
* as is except that the initial minting recipient (see
* tokens/ERC20/ExternalERC20Mintable) is set to a static value.
*/
Expand All @@ -19,11 +19,11 @@ contract TokenXExplicitSenderMock is TokenXExplicitSender {
Accesslist accesslist,
bool whitelistEnabled,
ExternalERC20Storage stor,
IUpgradableTokenX upgradedFrom,
IUpgradableEToken upgradedFrom,
bool initialDeployment
)
public
TokenXExplicitSender(
ETokenExplicitSender(
name, symbol, decimals, accesslist, whitelistEnabled,
stor, address(0xf00f), upgradedFrom, initialDeployment)
{}
Expand Down
14 changes: 7 additions & 7 deletions contracts/mocks/TokenXMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ pragma solidity ^0.4.24;

/* solium-disable max-len */
import "../token/ERC20/ExternalERC20Storage.sol";
import "../token/TokenX.sol";
import "../token/IUpgradableTokenX.sol";
import "../token/EToken.sol";
import "../token/IUpgradableEToken.sol";
import "./PauserRoleMock.sol";

/** @title Mock contract for testing TokenX */
contract TokenXMock is TokenX, PauserRoleMock {
/** @title Mock contract for testing EToken */
contract ETokenMock is EToken, PauserRoleMock {

/**
* Initializes a TokenX contract and optionally mint some amount to a
* Initializes an EToken contract and optionally mint some amount to a
* given account
* @param name The name of the token
* @param symbol The symbol of the token
Expand Down Expand Up @@ -38,12 +38,12 @@ contract TokenXMock is TokenX, PauserRoleMock {
bool whitelistEnabled,
ExternalERC20Storage stor,
address mintingRecip,
IUpgradableTokenX upgradedFrom,
IUpgradableEToken upgradedFrom,
bool initialDeployment,
address initialAccount,
uint256 initialBalance
)
TokenX(
EToken(
name, symbol, decimals,
accesslist, whitelistEnabled, stor, mintingRecip, upgradedFrom,
initialDeployment
Expand Down
22 changes: 11 additions & 11 deletions contracts/token/TokenX.sol → contracts/token/EToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ pragma solidity ^0.4.24;

import "./ERC20/ExternalERC20Storage.sol";

import "./TokenXExplicitSender.sol";
import "./ITokenX.sol";
import "./IUpgradableTokenX.sol";
import "./ETokenExplicitSender.sol";
import "./IEToken.sol";
import "./IUpgradableEToken.sol";

/** @title Main TokenX contract */
contract TokenX is ITokenX, TokenXExplicitSender {
/** @title Main EToken contract */
contract EToken is IEToken, ETokenExplicitSender {

ExternalERC20Storage private externalStorage;
IUpgradableTokenX public upgradedToken;
IUpgradableEToken public upgradedToken;

/**
* @param name The name of the token
Expand Down Expand Up @@ -40,7 +40,7 @@ contract TokenX is ITokenX, TokenXExplicitSender {
bool initialDeployment
)
public
TokenXExplicitSender(
ETokenExplicitSender(
name,
symbol,
decimals,
Expand All @@ -64,18 +64,18 @@ contract TokenX is ITokenX, TokenXExplicitSender {
* @return Is this token upgraded
*/
function isUpgraded() public view returns (bool) {
return upgradedToken != IUpgradableTokenX(0);
return upgradedToken != IUpgradableEToken(0);
}

/**
* Upgrades the current token
* @param _upgradedToken The address of the token that this token should be upgraded to
*/
function upgrade(IUpgradableTokenX _upgradedToken) public onlyOwner {
function upgrade(IUpgradableEToken _upgradedToken) public onlyOwner {
require(!isUpgraded(), "Token is already upgraded");
require(_upgradedToken != IUpgradableTokenX(0),
require(_upgradedToken != IUpgradableEToken(0),
"Cannot upgrade to null address");
require(_upgradedToken != IUpgradableTokenX(this),
require(_upgradedToken != IUpgradableEToken(this),
"Cannot upgrade to myself");
require(externalStorage.isImplementor(),
"I don't own my storage. This will end badly.");
Expand Down
Loading

0 comments on commit 0ac9232

Please sign in to comment.