Blockwell

Amp

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

Approval Event

Parameters help
owner
address help
spender
address help
value
uint256 help

ApprovalByPartition Event

Parameters help
partition
bytes32 help
owner
address help
spender
address help
value
uint256 help

AuthorizedOperator Event

Parameters help
operator
address help
tokenHolder
address help

AuthorizedOperatorByPartition Event

Parameters help
partition
bytes32 help
operator
address help
tokenHolder
address help

ChangedPartition Event

Parameters help
fromPartition
bytes32 help
toPartition
bytes32 help
value
uint256 help

CollateralManagerRegistered Event

Parameters help
collateralManager
address help

Minted Event

Parameters help
operator
address help
to
address help
value
uint256 help
data
bytes help

OwnerUpdate Event

Parameters help
oldValue
address help
newValue
address help

OwnershipTransferAuthorization Event

Parameters help
authorizedAddress
address help

PartitionStrategySet Event

Parameters help
flag
bytes4 help
name
string help
implementation
address help

RevokedOperator Event

Parameters help
operator
address help
tokenHolder
address help

RevokedOperatorByPartition Event

Parameters help
partition
bytes32 help
operator
address help
tokenHolder
address help

Swap Event

Parameters help
operator
address help
from
address help
value
uint256 help

Transfer Event

Parameters help
from
address help
to
address help
value
uint256 help

TransferByPartition Event

Parameters help
fromPartition
bytes32 help
operator
address help
from
address help
to
address help
value
uint256 help
data
bytes help
operatorData
bytes help

AMP_INTERFACE_NAME Constant

string help
AmpToken

ERC20_INTERFACE_NAME Constant

string help
ERC20Token

AMP_TOKENS_SENDER Constant

string help
AmpTokensSender

AMP_TOKENS_RECIPIENT Constant

string help
AmpTokensRecipient

AMP_TOKENS_CHECKER Constant

string help
AmpTokensChecker

_granularity Constant

uint256 help
1

defaultPartition Constant

bytes32 help
0x0000000000000000000000000000000000000000000000000000000000000000

ZERO_PREFIX Constant

bytes4 help
0x00000000

swapTokenGraveyard Constant

address help

ERC1820REGISTRY Constant

ERC1820Registry help

ERC1820_ACCEPT_MAGIC Constant

bytes32 help

swapToken Variable

address help

totalSupplyByPartition Variable

mapping(bytes32 => uint256) help

_name Variable

string help
Internal Variable

_symbol Variable

string help
Internal Variable

_totalSupply Variable

uint256 help
Internal Variable

_balances Variable

mapping(address => uint256) help
Internal Variable

_totalPartitions Variable

bytes32[] help
Internal Variable

_indexOfTotalPartitions Variable

mapping(bytes32 => uint256) help
Internal Variable

_partitionsOf Variable

mapping(address => bytes32[]) help
Internal Variable

_indexOfPartitionsOf Variable

mapping(address => mapping(bytes32 => uint256)) help
Internal Variable

_balanceOfByPartition Variable

mapping(address => mapping(bytes32 => uint256)) help
Internal Variable

_authorizedOperator Variable

mapping(address => mapping(address => bool)) 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

collateralManagers Variable

address[] help
Internal Variable

_isCollateralManager Variable

mapping(address => bool) help
Internal Variable

partitionStrategies Variable

bytes4[] help
Internal Variable

_isPartitionStrategy Variable

mapping(bytes4 => bool) help
Internal Variable

_interfaceHashes Variable

mapping(bytes32 => bool) help
Internal Variable

EC_50_TRANSFER_FAILURE Variable

string help
Internal Variable

EC_51_TRANSFER_SUCCESS Variable

string help
Internal Variable

EC_52_INSUFFICIENT_BALANCE Variable

string help
Internal Variable

EC_53_INSUFFICIENT_ALLOWANCE Variable

string help
Internal Variable

EC_56_INVALID_SENDER Variable

string help
Internal Variable

EC_57_INVALID_RECEIVER Variable

string help
Internal Variable

EC_58_INVALID_OPERATOR Variable

string help
Internal Variable

EC_59_INSUFFICIENT_RIGHTS Variable

string help
Internal Variable

EC_5A_INVALID_SWAP_TOKEN_ADDRESS Variable

string help
Internal Variable

EC_5B_INVALID_VALUE_0 Variable

string help
Internal Variable

EC_5C_ADDRESS_CONFLICT Variable

string help
Internal Variable

EC_5D_PARTITION_RESERVED Variable

string help
Internal Variable

EC_5E_PARTITION_PREFIX_CONFLICT Variable

string help
Internal Variable

EC_5F_INVALID_PARTITION_PREFIX_0 Variable

string help
Internal Variable

EC_60_SWAP_TRANSFER_FAILURE Variable

string help
Internal Variable

_owner Variable

address help
Internal Variable

_authorizedNewOwner Variable

address help
Internal Variable

Functions Expand All Collapse All

owner keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function owner() public view returns (address) {
  return _owner;
}

authorizedNewOwner keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function authorizedNewOwner() public view returns (address) {
  return _authorizedNewOwner;
}

authorizeOwnershipTransfer keyboard_arrow_up

Parameters help

Name Type
_authorizedAddress
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function authorizeOwnershipTransfer(address _authorizedAddress) external {
  require(msg.sender == _owner, "Invalid sender");

  _authorizedNewOwner = _authorizedAddress;

  emit OwnershipTransferAuthorization(_authorizedNewOwner);
}

assumeOwnership keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
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

Parameters help

Name Type
_interfaceHash
bytes32 help
address help

Properties

Visibility help public
Mutability help view
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 "";
  }
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function totalSupply() external view override returns (uint256) {
  return _totalSupply;
}

Parameters help

Name Type
_tokenHolder
address help

Properties

Visibility help public
Mutability help view
Source Code
function balanceOf(address _tokenHolder)
  external
  view
  override
  returns (uint256)
{
  return _balances[_tokenHolder];
}

Parameters help

Name Type
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function transfer(address _to, uint256 _value)
  external
  override
  returns (bool)
{
  _transferByDefaultPartition(msg.sender, msg.sender, _to, _value, "");
  return true;
}

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) external override returns (bool) {
  _transferByDefaultPartition(msg.sender, _from, _to, _value, "");
  return true;
}

Parameters help

Name Type
_owner
address help
_spender
address help

Properties

Visibility help public
Mutability help view
Source Code
function allowance(address _owner, address _spender)
  external
  view
  override
  returns (uint256)
{
  return _allowedByPartition[defaultPartition][_owner][_spender];
}

Parameters help

Name Type
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function approve(address _spender, uint256 _value)
  external
  override
  returns (bool)
{
  _approveByPartition(defaultPartition, msg.sender, _spender, _value);
  return true;
}

Parameters help

Name Type
_spender
address help
_addedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

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;
}

Parameters help

Name Type
_spender
address help
_subtractedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

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

Parameters help

Name Type
_from
address help

Properties

Visibility help public
Mutability help transaction

Requirements help

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

Parameters help

Name Type
_partition
bytes32 help
_tokenHolder
address help

Properties

Visibility help public
Mutability help view
Source Code
function balanceOfByPartition(bytes32 _partition, address _tokenHolder)
  external
  view
  returns (uint256)
{
  return _balanceOfByPartition[_tokenHolder][_partition];
}

partitionsOf keyboard_arrow_up

Parameters help

Name Type
_tokenHolder
address help

Properties

Visibility help public
Mutability help view
Source Code
function partitionsOf(address _tokenHolder)
  external
  view
  returns (bytes32[] memory)
{
  return _partitionsOf[_tokenHolder];
}

transferByPartition keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help
_from
address help
_to
address help
_value
uint256 help
_data
bytes help
_operatorData
bytes help

Properties

Visibility help public
Mutability help transaction
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

Parameters help

Name Type
_operator
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function authorizeOperator(address _operator) external {
  require(_operator != msg.sender, EC_58_INVALID_OPERATOR);

  _authorizedOperator[msg.sender][_operator] = true;
  emit AuthorizedOperator(_operator, msg.sender);
}

revokeOperator keyboard_arrow_up

Parameters help

Name Type
_operator
address help

Properties

Visibility help public
Mutability help transaction
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

Parameters help

Name Type
_partition
bytes32 help
_operator
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function authorizeOperatorByPartition(bytes32 _partition, address _operator)
  external
{
  require(_operator != msg.sender, EC_58_INVALID_OPERATOR);

  _authorizedOperatorByPartition[msg.sender][_partition][_operator] = true;
  emit AuthorizedOperatorByPartition(_partition, _operator, msg.sender);
}

revokeOperatorByPartition keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help
_operator
address help

Properties

Visibility help public
Mutability help transaction
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

Parameters help

Name Type
_operator
address help
_tokenHolder
address help

Properties

Visibility help public
Mutability help view
Source Code
function isOperator(address _operator, address _tokenHolder)
  external
  view
  returns (bool)
{
  return _isOperator(_operator, _tokenHolder);
}

isOperatorForPartition keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help
_operator
address help
_tokenHolder
address help

Properties

Visibility help public
Mutability help view
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

Name Type
_partition
bytes32 help
_operator
address help
_collateralManager
address help

Properties

Visibility help public
Mutability help view
Source Code
function isOperatorForCollateralManager(
  bytes32 _partition,
  address _operator,
  address _collateralManager
) external view returns (bool) {
  return
    _isCollateralManager[_collateralManager] &&
    (_isOperator(_operator, _collateralManager) ||
      _authorizedOperatorByPartition[_collateralManager][_partition][
        _operator
      ]);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function name() external view returns (string memory) {
  return _name;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function symbol() external view returns (string memory) {
  return _symbol;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function decimals() external pure returns (uint8) {
  return uint8(18);
}

granularity keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function granularity() external pure returns (uint256) {
  return _granularity;
}

totalPartitions keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function totalPartitions() external view returns (bytes32[] memory) {
  return _totalPartitions;
}

allowanceByPartition keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help
_owner
address help
_spender
address help

Properties

Visibility help public
Mutability help view
Source Code
function allowanceByPartition(
  bytes32 _partition,
  address _owner,
  address _spender
) external view returns (uint256) {
  return _allowedByPartition[_partition][_owner][_spender];
}

approveByPartition keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

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

Parameters help

Name Type
_partition
bytes32 help
_spender
address help
_addedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

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

Name Type
_partition
bytes32 help
_spender
address help
_subtractedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

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.

Properties

Visibility help public
Mutability help transaction
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

Parameters help

Name Type
_collateralManager
address help

Properties

Visibility help public
Mutability help view
Source Code
function isCollateralManager(address _collateralManager)
  external
  view
  returns (bool)
{
  return _isCollateralManager[_collateralManager];
}

setPartitionStrategy keyboard_arrow_up

Parameters help

Name Type
_prefix
bytes4 help
_implementation
address help

Properties

Visibility help public
Mutability help transaction
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);
}

isPartitionStrategy keyboard_arrow_up

Parameters help

Name Type
_prefix
bytes4 help

Properties

Visibility help public
Mutability help view
Source Code
function isPartitionStrategy(bytes4 _prefix) external view returns (bool) {
  return _isPartitionStrategy[_prefix];
}

Internal Functions Expand All Collapse All

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

Name Type
_fromPartition
bytes32 help
_operator
address help
_from
address help
_to
address help
_value
uint256 help
_data
bytes help
_operatorData
bytes help

Properties

Visibility help internal
Mutability help transaction
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

Name Type
_operator
address help
_from
address help
_to
address help
_value
uint256 help
_data
bytes help

Properties

Visibility help internal
Mutability help transaction
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

Parameters help

Name Type
_from
address help
_partition
bytes32 help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction
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

Parameters help

Name Type
_to
address help
_partition
bytes32 help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction
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

Parameters help

Name Type
_partition
bytes32 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _addPartitionToTotalPartitions(bytes32 _partition) internal {
  _totalPartitions.push(_partition);
  _indexOfTotalPartitions[_partition] = _totalPartitions.length;
}

internal Amp._removePartitionFromTotalPartitions keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help

Properties

Visibility help internal
Mutability help transaction
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

Name Type
_fromPartition
bytes32 help
_operator
address help
_from
address help
_to
address help
_value
uint256 help
_data
bytes help
_operatorData
bytes help

Properties

Visibility help internal
Mutability help transaction
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

Name Type
_toPartition
bytes32 help
_operator
address help
_from
address help
_to
address help
_value
uint256 help
_data
bytes help
_operatorData
bytes help

Properties

Visibility help internal
Mutability help transaction
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

Name Type
_partition
bytes32 help
_tokenHolder
address help
_spender
address help
_amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

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

Parameters help

Name Type
_operator
address help
_tokenHolder
address help

Properties

Visibility help internal
Mutability help view
Source Code
function _isOperator(address _operator, address _tokenHolder)
  internal
  view
  returns (bool)
{
  return (_operator == _tokenHolder ||
    _authorizedOperator[_tokenHolder][_operator]);
}

internal Amp._isOperatorForPartition keyboard_arrow_up

Parameters help

Name Type
_partition
bytes32 help
_operator
address help
_tokenHolder
address help

Properties

Visibility help internal
Mutability help view
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

Parameters help

Name Type
_partition
bytes32 help
_operator
address help
_tokenHolder
address help

Properties

Visibility help internal
Mutability help view
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

Parameters help

Name Type
_operator
address help
_to
address help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

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

Parameters help

Name Type
_interfaceLabel
string help
_implementation
address help

Properties

Visibility help internal
Mutability help transaction
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

Parameters help

Name Type
addr
address help
_interfaceLabel
string help

Properties

Visibility help internal
Mutability help view
Source Code
function interfaceAddr(address addr, string memory _interfaceLabel)
  internal
  view
  returns (address)
{
  bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel));
  return ERC1820REGISTRY.getInterfaceImplementer(addr, interfaceHash);
}

internal ERC1820Client.delegateManagement keyboard_arrow_up

Parameters help

Name Type
_newManager
address help

Properties

Visibility help internal
Mutability help transaction
Source Code
function delegateManagement(address _newManager) internal {
  ERC1820REGISTRY.setManager(address(this), _newManager);
}

internal ERC1820Implementer._setInterface keyboard_arrow_up

Parameters help

Name Type
_interfaceLabel
string help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _setInterface(string memory _interfaceLabel) internal {
  _interfaceHashes[keccak256(abi.encodePacked(_interfaceLabel))] = true;
}

internal Ownable.constructor keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help transaction
Source Code
constructor() internal {
  _owner = msg.sender;
}