ERC20
This contract is an ERC20 token.
Name
Amp
Symbol
AMP
Decimals
18
Total Supply
89,767,795,053 AMP
About link
Amp (AMP) is a cryptocurrency and operates on the Ethereum platform. Amp has a current supply of 99,213,408,535 with 42,227,702,186 in circulation. The last known price of Amp is 0.04440069 USD and is down -5.23 over the last 24 hours. It is currently trading on 27 active market(s) with $26,787,501.39 traded over the last 24 hours. More information can be found at https://amptoken.org.
Stats
Public Functions
37
Event Types
15
Code Size
80,206 bytes
Library Use
Uses SafeMath for uint256.
Events (15) keyboard_arrow_up
Constants (11) keyboard_arrow_up
defaultPartition Constant
bytes32 help
0x0000000000000000000000000000000000000000000000000000000000000000
ERC1820REGISTRY Constant
ERC1820Registry help
the result of calling ERC1820Registry with UNKNOWN ARGUMENT
State Variables (36) keyboard_arrow_up
_indexOfPartitionsOf Variable
mapping(address => mapping(bytes32 => uint256)) help
Internal Variable
_balanceOfByPartition Variable
mapping(address => mapping(bytes32 => uint256)) help
Internal Variable
_allowedByPartition Variable
mapping(bytes32 => mapping(address => mapping(address => uint256))) help
Internal Variable
_authorizedOperatorByPartition Variable
mapping(address => mapping(bytes32 => mapping(address => bool))) help
Internal Variable
Functions
owner keyboard_arrow_up
authorizedNewOwner keyboard_arrow_up
authorizeOwnershipTransfer keyboard_arrow_up
assumeOwnership keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
Source Code
function assumeOwnership() external {
require(msg.sender == _authorizedNewOwner, "Invalid sender");
address oldValue = _owner;
_owner = _authorizedNewOwner;
_authorizedNewOwner = address(0);
emit OwnerUpdate(oldValue, _owner);
}
canImplementInterfaceForAddress keyboard_arrow_up
Source Code
function canImplementInterfaceForAddress(
bytes32 _interfaceHash,
address // Comments to avoid compilation warnings for unused variables. /*addr*/
) external view returns (bytes32) {
if (_interfaceHashes[_interfaceHash]) {
return ERC1820_ACCEPT_MAGIC;
} else {
return "";
}
}
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Requirements help
_value
must be less than or equal to
_balanceOfByPartition for the sender's address for defaultPartition
Source Code
function transfer(address _to, uint256 _value)
external
override
returns (bool)
{
_transferByDefaultPartition(msg.sender, msg.sender, _to, _value, "");
return true;
}
transferFrom keyboard_arrow_up
Requirements help
_value
must be less than or equal to
_balanceOfByPartition for the sender's address for defaultPartition
Source Code
function transferFrom(
address _from,
address _to,
uint256 _value
) external override returns (bool) {
_transferByDefaultPartition(msg.sender, _from, _to, _value, "");
return true;
}
allowance keyboard_arrow_up
approve keyboard_arrow_up
Requirements help
Source Code
function approve(address _spender, uint256 _value)
external
override
returns (bool)
{
_approveByPartition(defaultPartition, msg.sender, _spender, _value);
return true;
}
increaseAllowance keyboard_arrow_up
Requirements help
Source Code
function increaseAllowance(address _spender, uint256 _addedValue)
external
returns (bool)
{
_approveByPartition(
defaultPartition,
msg.sender,
_spender,
_allowedByPartition[defaultPartition][msg.sender][_spender].add(_addedValue)
);
return true;
}
decreaseAllowance keyboard_arrow_up
Requirements help
Source Code
function decreaseAllowance(address _spender, uint256 _subtractedValue)
external
returns (bool)
{
_approveByPartition(
defaultPartition,
msg.sender,
_spender,
_allowedByPartition[defaultPartition][msg.sender][_spender].sub(
_subtractedValue
)
);
return true;
}
swap keyboard_arrow_up
Source Code
function swap(address _from) public {
uint256 amount = swapToken.allowance(_from, address(this));
require(amount > 0, EC_53_INSUFFICIENT_ALLOWANCE);
require(
swapToken.transferFrom(_from, swapTokenGraveyard, amount),
EC_60_SWAP_TRANSFER_FAILURE
);
_mint(msg.sender, _from, amount);
emit Swap(msg.sender, _from, amount);
}
balanceOfByPartition keyboard_arrow_up
Source Code
function balanceOfByPartition(bytes32 _partition, address _tokenHolder)
external
view
returns (uint256)
{
return _balanceOfByPartition[_tokenHolder][_partition];
}
partitionsOf keyboard_arrow_up
transferByPartition keyboard_arrow_up
Parameters help
Requirements help
_value
must be less than or equal to
_balanceOfByPartition for the sender's address for defaultPartition
Source Code
function transferByPartition(
bytes32 _partition,
address _from,
address _to,
uint256 _value,
bytes calldata _data,
bytes calldata _operatorData
) external returns (bytes32) {
return
_transferByPartition(
_partition,
msg.sender,
_from,
_to,
_value,
_data,
_operatorData
);
}
authorizeOperator keyboard_arrow_up
revokeOperator keyboard_arrow_up
Requirements help
Source Code
function revokeOperator(address _operator) external {
require(_operator != msg.sender, EC_58_INVALID_OPERATOR);
_authorizedOperator[msg.sender][_operator] = false;
emit RevokedOperator(_operator, msg.sender);
}
authorizeOperatorByPartition keyboard_arrow_up
revokeOperatorByPartition keyboard_arrow_up
Requirements help
Source Code
function revokeOperatorByPartition(bytes32 _partition, address _operator)
external
{
require(_operator != msg.sender, EC_58_INVALID_OPERATOR);
_authorizedOperatorByPartition[msg.sender][_partition][_operator] = false;
emit RevokedOperatorByPartition(_partition, _operator, msg.sender);
}
isOperator keyboard_arrow_up
isOperatorForPartition keyboard_arrow_up
Source Code
function isOperatorForPartition(
bytes32 _partition,
address _operator,
address _tokenHolder
) external view returns (bool) {
return _isOperatorForPartition(_partition, _operator, _tokenHolder);
}
isOperatorForCollateralManager keyboard_arrow_up
Parameters help
Source Code
function isOperatorForCollateralManager(
bytes32 _partition,
address _operator,
address _collateralManager
) external view returns (bool) {
return
_isCollateralManager[_collateralManager] &&
(_isOperator(_operator, _collateralManager) ||
_authorizedOperatorByPartition[_collateralManager][_partition][
_operator
]);
}
name keyboard_arrow_up
symbol keyboard_arrow_up
decimals keyboard_arrow_up
granularity keyboard_arrow_up
totalPartitions keyboard_arrow_up
allowanceByPartition keyboard_arrow_up
Source Code
function allowanceByPartition(
bytes32 _partition,
address _owner,
address _spender
) external view returns (uint256) {
return _allowedByPartition[_partition][_owner][_spender];
}
approveByPartition keyboard_arrow_up
Requirements help
Source Code
function approveByPartition(
bytes32 _partition,
address _spender,
uint256 _value
) external returns (bool) {
_approveByPartition(_partition, msg.sender, _spender, _value);
return true;
}
increaseAllowanceByPartition keyboard_arrow_up
Requirements help
Source Code
function increaseAllowanceByPartition(
bytes32 _partition,
address _spender,
uint256 _addedValue
) external returns (bool) {
_approveByPartition(
_partition,
msg.sender,
_spender,
_allowedByPartition[_partition][msg.sender][_spender].add(_addedValue)
);
return true;
}
decreaseAllowanceByPartition keyboard_arrow_up
Parameters help
Requirements help
Source Code
function decreaseAllowanceByPartition(
bytes32 _partition,
address _spender,
uint256 _subtractedValue
) external returns (bool) {
// TOOD: Figure out if safe math will panic below 0
_approveByPartition(
_partition,
msg.sender,
_spender,
_allowedByPartition[_partition][msg.sender][_spender].sub(_subtractedValue)
);
return true;
}
registerCollateralManager keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
Source Code
function registerCollateralManager() external {
// Short circuit a double registry
require(!_isCollateralManager[msg.sender], EC_5C_ADDRESS_CONFLICT);
collateralManagers.push(msg.sender);
_isCollateralManager[msg.sender] = true;
emit CollateralManagerRegistered(msg.sender);
}
isCollateralManager keyboard_arrow_up
setPartitionStrategy keyboard_arrow_up
Requirements help
Source Code
function setPartitionStrategy(bytes4 _prefix, address _implementation)
external
{
require(msg.sender == owner(), EC_56_INVALID_SENDER);
require(!_isPartitionStrategy[_prefix], EC_5E_PARTITION_PREFIX_CONFLICT);
require(_prefix != ZERO_PREFIX, EC_5F_INVALID_PARTITION_PREFIX_0);
string memory iname = PartitionUtils._getPartitionStrategyValidatorIName(
_prefix
);
ERC1820Client.setInterfaceImplementation(iname, _implementation);
partitionStrategies.push(_prefix);
_isPartitionStrategy[_prefix] = true;
emit PartitionStrategySet(_prefix, iname, _implementation);
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal Amp._transferByPartition keyboard_arrow_up
Parameters help
Requirements help
_value
must be less than or equal to
_balanceOfByPartition for the sender's address for defaultPartition
Source Code
function _transferByPartition(
bytes32 _fromPartition,
address _operator,
address _from,
address _to,
uint256 _value,
bytes memory _data,
bytes memory _operatorData
) internal returns (bytes32) {
require(_to != address(0), EC_57_INVALID_RECEIVER);
// If the `_operator` is attempting to transfer from a different `_from`
// address, first check that they have the requisite operator or
// allowance permissions.
if (_from != _operator) {
require(
_isOperatorForPartition(_fromPartition, _operator, _from) ||
(_value <= _allowedByPartition[_fromPartition][_from][_operator]),
EC_53_INSUFFICIENT_ALLOWANCE
);
// If the sender has an allowance for the partition, that should
// be decremented
if (_allowedByPartition[_fromPartition][_from][_operator] >= _value) {
_allowedByPartition[_fromPartition][_from][
msg.sender
] = _allowedByPartition[_fromPartition][_from][_operator].sub(_value);
} else {
_allowedByPartition[_fromPartition][_from][_operator] = 0;
}
}
_callPreTransferHooks(
_fromPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
require(
_balanceOfByPartition[_from][_fromPartition] >= _value,
EC_52_INSUFFICIENT_BALANCE
);
bytes32 toPartition = PartitionUtils._getDestinationPartition(
_data,
_fromPartition
);
_removeTokenFromPartition(_from, _fromPartition, _value);
_addTokenToPartition(_to, toPartition, _value);
_callPostTransferHooks(
toPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
emit Transfer(_from, _to, _value);
emit TransferByPartition(
_fromPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
if (toPartition != _fromPartition) {
emit ChangedPartition(_fromPartition, toPartition, _value);
}
return toPartition;
}
internal Amp._transferByDefaultPartition keyboard_arrow_up
Parameters help
Requirements help
_value
must be less than or equal to
_balanceOfByPartition for the sender's address for defaultPartition
Source Code
function _transferByDefaultPartition(
address _operator,
address _from,
address _to,
uint256 _value,
bytes memory _data
) internal {
_transferByPartition(
defaultPartition,
_operator,
_from,
_to,
_value,
_data,
""
);
}
internal Amp._removeTokenFromPartition keyboard_arrow_up
Source Code
function _removeTokenFromPartition(
address _from,
bytes32 _partition,
uint256 _value
) internal {
if (_value == 0) {
return;
}
_balances[_from] = _balances[_from].sub(_value);
_balanceOfByPartition[_from][_partition] = _balanceOfByPartition[_from][
_partition
]
.sub(_value);
totalSupplyByPartition[_partition] = totalSupplyByPartition[_partition].sub(
_value
);
// If the total supply is zero, finds and deletes the partition.
// Do not delete the _defaultPartition from totalPartitions.
if (
totalSupplyByPartition[_partition] == 0 && _partition != defaultPartition
) {
_removePartitionFromTotalPartitions(_partition);
}
// If the balance of the TokenHolder's partition is zero, finds and
// deletes the partition.
if (_balanceOfByPartition[_from][_partition] == 0) {
uint256 index = _indexOfPartitionsOf[_from][_partition];
if (index == 0) {
return;
}
// move the last item into the index being vacated
bytes32 lastValue = _partitionsOf[_from][_partitionsOf[_from].length - 1];
_partitionsOf[_from][index - 1] = lastValue; // adjust for 1-based indexing
_indexOfPartitionsOf[_from][lastValue] = index;
_partitionsOf[_from].pop();
_indexOfPartitionsOf[_from][_partition] = 0;
}
}
internal Amp._addTokenToPartition keyboard_arrow_up
Source Code
function _addTokenToPartition(
address _to,
bytes32 _partition,
uint256 _value
) internal {
if (_value == 0) {
return;
}
_balances[_to] = _balances[_to].add(_value);
if (_indexOfPartitionsOf[_to][_partition] == 0) {
_partitionsOf[_to].push(_partition);
_indexOfPartitionsOf[_to][_partition] = _partitionsOf[_to].length;
}
_balanceOfByPartition[_to][_partition] = _balanceOfByPartition[_to][
_partition
]
.add(_value);
if (_indexOfTotalPartitions[_partition] == 0) {
_addPartitionToTotalPartitions(_partition);
}
totalSupplyByPartition[_partition] = totalSupplyByPartition[_partition].add(
_value
);
}
internal Amp._addPartitionToTotalPartitions keyboard_arrow_up
internal Amp._removePartitionFromTotalPartitions keyboard_arrow_up
Source Code
function _removePartitionFromTotalPartitions(bytes32 _partition) internal {
uint256 index = _indexOfTotalPartitions[_partition];
if (index == 0) {
return;
}
// move the last item into the index being vacated
bytes32 lastValue = _totalPartitions[_totalPartitions.length - 1];
_totalPartitions[index - 1] = lastValue; // adjust for 1-based indexing
_indexOfTotalPartitions[lastValue] = index;
_totalPartitions.pop();
_indexOfTotalPartitions[_partition] = 0;
}
internal Amp._callPreTransferHooks keyboard_arrow_up
Parameters help
Source Code
function _callPreTransferHooks(
bytes32 _fromPartition,
address _operator,
address _from,
address _to,
uint256 _value,
bytes memory _data,
bytes memory _operatorData
) internal {
address senderImplementation;
senderImplementation = interfaceAddr(_from, AMP_TOKENS_SENDER);
if (senderImplementation != address(0)) {
IAmpTokensSender(senderImplementation).tokensToTransfer(
msg.sig,
_fromPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
}
// Used to ensure that hooks implemented by a collateral manager to validate
// transfers from it's owned partitions are called
bytes4 fromPartitionPrefix = PartitionUtils._getPartitionPrefix(
_fromPartition
);
if (_isPartitionStrategy[fromPartitionPrefix]) {
address fromPartitionValidatorImplementation;
fromPartitionValidatorImplementation = interfaceAddr(
address(this),
PartitionUtils._getPartitionStrategyValidatorIName(fromPartitionPrefix)
);
if (fromPartitionValidatorImplementation != address(0)) {
IAmpPartitionStrategyValidator(fromPartitionValidatorImplementation)
.tokensFromPartitionToValidate(
msg.sig,
_fromPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
}
}
}
internal Amp._callPostTransferHooks keyboard_arrow_up
Parameters help
Source Code
function _callPostTransferHooks(
bytes32 _toPartition,
address _operator,
address _from,
address _to,
uint256 _value,
bytes memory _data,
bytes memory _operatorData
) internal {
bytes4 toPartitionPrefix = PartitionUtils._getPartitionPrefix(_toPartition);
if (_isPartitionStrategy[toPartitionPrefix]) {
address partitionManagerImplementation;
partitionManagerImplementation = interfaceAddr(
address(this),
PartitionUtils._getPartitionStrategyValidatorIName(toPartitionPrefix)
);
if (partitionManagerImplementation != address(0)) {
IAmpPartitionStrategyValidator(partitionManagerImplementation)
.tokensToPartitionToValidate(
msg.sig,
_toPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
}
} else {
require(toPartitionPrefix == ZERO_PREFIX, EC_5D_PARTITION_RESERVED);
}
address recipientImplementation;
recipientImplementation = interfaceAddr(_to, AMP_TOKENS_RECIPIENT);
if (recipientImplementation != address(0)) {
IAmpTokensRecipient(recipientImplementation).tokensReceived(
msg.sig,
_toPartition,
_operator,
_from,
_to,
_value,
_data,
_operatorData
);
}
}
internal Amp._approveByPartition keyboard_arrow_up
Parameters help
Requirements help
Source Code
function _approveByPartition(
bytes32 _partition,
address _tokenHolder,
address _spender,
uint256 _amount
) internal {
require(_tokenHolder != address(0), EC_56_INVALID_SENDER);
require(_spender != address(0), EC_58_INVALID_OPERATOR);
_allowedByPartition[_partition][_tokenHolder][_spender] = _amount;
emit ApprovalByPartition(_partition, _tokenHolder, _spender, _amount);
if (_partition == defaultPartition) {
emit Approval(_tokenHolder, _spender, _amount);
}
}
internal Amp._isOperator keyboard_arrow_up
Source Code
function _isOperator(address _operator, address _tokenHolder)
internal
view
returns (bool)
{
return (_operator == _tokenHolder ||
_authorizedOperator[_tokenHolder][_operator]);
}
internal Amp._isOperatorForPartition keyboard_arrow_up
Source Code
function _isOperatorForPartition(
bytes32 _partition,
address _operator,
address _tokenHolder
) internal view returns (bool) {
return (_isOperator(_operator, _tokenHolder) ||
_authorizedOperatorByPartition[_tokenHolder][_partition][_operator] ||
_callPartitionStrategyOperatorHook(_partition, _operator, _tokenHolder));
}
internal Amp._callPartitionStrategyOperatorHook keyboard_arrow_up
Source Code
function _callPartitionStrategyOperatorHook(
bytes32 _partition,
address _operator,
address _tokenHolder
) internal view returns (bool) {
bytes4 prefix = PartitionUtils._getPartitionPrefix(_partition);
if (!_isPartitionStrategy[prefix]) {
return false;
}
address strategyValidatorImplementation;
strategyValidatorImplementation = interfaceAddr(
address(this),
PartitionUtils._getPartitionStrategyValidatorIName(prefix)
);
if (strategyValidatorImplementation != address(0)) {
return
IAmpPartitionStrategyValidator(strategyValidatorImplementation)
.isOperatorForPartitionScope(_partition, _operator, _tokenHolder);
}
// Not a partition format that imbues special operator rules
return false;
}
internal Amp._mint keyboard_arrow_up
Source Code
function _mint(
address _operator,
address _to,
uint256 _value
) internal {
require(_to != address(0), EC_57_INVALID_RECEIVER);
_totalSupply = _totalSupply.add(_value);
_addTokenToPartition(_to, defaultPartition, _value);
_callPostTransferHooks(
defaultPartition,
_operator,
address(0),
_to,
_value,
"",
""
);
emit Minted(_operator, _to, _value, "");
emit Transfer(address(0), _to, _value);
emit TransferByPartition(
bytes32(0),
_operator,
address(0),
_to,
_value,
"",
""
);
}
internal ERC1820Client.setInterfaceImplementation keyboard_arrow_up
Source Code
function setInterfaceImplementation(
string memory _interfaceLabel,
address _implementation
) internal {
bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel));
ERC1820REGISTRY.setInterfaceImplementer(
address(this),
interfaceHash,
_implementation
);
}
internal ERC1820Client.interfaceAddr keyboard_arrow_up
Source Code
function interfaceAddr(address addr, string memory _interfaceLabel)
internal
view
returns (address)
{
bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel));
return ERC1820REGISTRY.getInterfaceImplementer(addr, interfaceHash);
}