Last updated
Last updated
constructor
constructor(swapTokenAddress, name, symbol)
Initialize AMP, initialize the default partition, and register the contract implementation in the global ERC1820Registry.
totalSupply
totalSupply()
Retrieves the total number of minted tokens.
Returns
Amp.totalSupply
returns a uint256
containing the total number of minted tokens.
balanceOf
balanceOf(tokenHolder)
Retrieves the balance of the account with address tokenHolder
across all partitions.
Note that this figure should not be used as the arbiter of the amount a token holder will successfully be able to send via the ERC-20 compatible Amp.transfer
method. In order to get that figure, use Amp.balanceOfByPartition
to get the balance of the default partition.
Method parameters
Returns
Amp.balanceOf
returns a uint256
containing the amount of tokens held by tokenHolder
across all partitions.
transfer
transfer(to, value)
Transfers an amount of tokens to the specified address.
Note that this only transfers from the msg.sender
address's default partition. To transfer from other partitions, use function Amp.transferByPartition
.
Method parameters
Returns
Amp.transfer
returns a bool
indicating whether the operation was successful.
transferFrom
transferFrom(from, to, value)
Transfers an amount of tokens between two accounts.
Note that this only transfers from the from
address's default partition. To transfer from other partitions, use function Amp.transferByPartition
.
Method parameters
Returns
Amp.transferFrom
returns a bool
indicating whether the operation was successful.
allowance
allowance(owner, spender)
Retrieves the allowance of tokens that has been granted by owner
to spender
for the default partition.
Note that this only returns the allowance of the owner
address's default partition. To retrieve the allowance for a different partition, use function Amp.allowanceByParititon
.
Method parameters
Returns
Amp.allowance
returns a uint256
specifying the amount of tokens available for the spender
to transfer from the owner
's default partition.
approve
approve(spender, value)
Sets an allowance for an address to transfer an amount of tokens on behalf of the caller.
Note that this only affects the msg.sender
address's default partition. To approve transfers from other partitions, use function Amp.approveByPartition
.
Functions Amp.increaseAllowance
and Amp.decreaseAllowance
should be used instead.
Method parameters
Returns
Amp.approve
returns a bool
indicating if the operation was successful.
increaseAllowance
increaseAllowance(spender, addedValue)
Increases the allowance granted to spender
by the caller.
Note that this only affects the msg.sender
address's default partition. To increase the allowance for other partitions, use function Amp.increaseAllowanceByPartition
.
Requirements:
spender
cannot be the zero address.
Method parameters
Returns
Amp.increaseAllowance
returns a bool
indicating if the operation was successful.
decreaseAllowance
decreaseAllowance(spender, substractedValue)
Decreases the allowance granted to spender
by the caller.
Note that this only affects the msg.sender
address's default partition. To decrease the allowance for other partitions, use function decreaseAllowanceByPartition
.
Requirements:
spender
cannot be the zero address.
spender
must have an allowance for the caller of at least subtractedValue
.
Method parameters
Returns
Amp.decreaseAllowance
returns a bool
indicating if the operation was successful.
swap
swap(from)
Exchanges an amount of source swap tokens from the contract defined at deployment for the equivalent amount of Amp tokens.
Requires the from
account to have granted the Amp contract an allowance of swap tokens no greater than their balance.
Method parameters
balanceOfByPartition
balanceOfByPartition(partition, tokenHolder)
Retrieves the balance of a token holder for a specific partition.
Method parameters
Returns
Amp.balanceOfByPartition
returns a uint256
containing the amount of tokens held by tokenHolder
in partition
.
partitionsOf
partitionsOf(tokenHolder)
Retrieves the set of partitions for a particular token holder.
Method parameters
Returns
Amp.partitionsOf
returns a bytes32[]
containing the partitions of tokenHolder
.
transferByPartition
transferByPartition(partition, from, to, value, data, operatorData)
Transfers tokens from a specific partition on behalf of a token holder, optionally changing the partition and including arbitrary data used by the partition strategies and collateral managers to authorize the transfer.
This can be used to transfer an address's own tokens, or transfer a different address's tokens by specifying the from
param. If attempting to transfer from a different address than msg.sender
, the msg.sender
will need to be an operator or have enough allowance for the partition
of the from
address.
Method parameters
Returns
Amp.transferByPartition
returns a bytes32
containing the destination partition.
authorizeOperator
authorizeOperator(operator)
Authorizes an address as an operator of msg.sender
to transfer tokens on its behalf.
Note that this applies to all partitions.
msg.sender
is always an operator for itself, and does not need to be explicitly added.
Method parameters
revokeOperator
revokeOperator(operator)
Remove the right of the operator
address to be an operator for msg.sender
and to transfer tokens on its behalf.
Note that this affects the account-wide authorization granted via function Amp.authorizeOperator
, and does not affect authorizations granted via function Amp.authorizeOperatorByPartition
.
msg.sender
is always an operator for itself, and cannot be removed.
Method parameters
authorizeOperatorByPartition
authorizeOperatorByPartition(partition, operator)
Authorizes an account as an operator of a particular partition.
The msg.sender
is always an operator for itself, and does not need to be explicitly added to a partition.
Method parameters
revokeOperatorByPartition
revokeOperatorByPartition(partition, operator)
Deauthorizes an address as an operator for a particular partition.
Note that this does not override an account-wide authorization granted via function Amp.authorizeOperator
.
msg.sender
is always an operator for itself, and cannot be removed from a partition.
Method parameters
isOperator
isOperator(operator, tokenHolder)
Indicates whether the operator
address is an operator of the tokenHolder
address.
Note that this applies to all of the partitions of the msg.sender
address.
Method parameters
Returns
Amp.isOperator
returns a bool
indicating whether operator
is an operator of tokenHolder
.
isOperatorForPartition
isOperatorForPartition(partition, operator, tokenHolder)
Indicate whether the operator
address is an operator of the tokenHolder
address for the partition
Method parameters
Returns
Amp.isOperatorForPartition
returns a bool
indicating whether operator
is an operator of tokenHolder
for the partition
.
isOperatorForCollateralManager
isOperatorForCollateralManager(partition, operator, collateralManager)
Indicates whether the operator
address is an operator of the collateralManager
address for the partition
.
This method is functionally identical to Amp.isOperatorForPartition
, except that it also requires the address that operator
is being checked for must be a registered collateral manager.
Method parameters
Returns
Amp.isOperatorForCollateralManager
returns a bool
indicating whether the operator
address is an operator of the collateralManager
address for the partition
.
name
name()
Retrieves the name of the token.
Returns
Amp.name
returns a string
containing the name of the token. Always "Amp".
symbol
symbol()
Retrieves the symbol of the token.
Returns
Amp.symbol
returns a string
containing the symbol of the token. Always "AMP".
decimals
decimals()
Retrieves the number of decimals of the token.
Returns
Amp.decimals
returns a uint8
containing the number of decimals of the token. Always 18.
granularity
granularity()
Retrieves the smallest part of the token that is not divisible.
Returns
Amp.granularity
returns a uint256
containing the smallest non-divisible part of the token. Always 1.
totalPartitions
totalPartitions()
Retrieves the set of existing partitions.
Returns
Amp.totalPartitions
returns a bytes32[]
containing all partitions.
allowanceByPartition
allowanceByPartition(partition, owner, spender)
Retrieves the allowance of tokens that has been granted by a token holder to another account.
Method parameters
Returns
Amp.allowanceByPartition
returns a uint256
containing the amount of tokens available for spender
to transfer.
approveByPartition
approveByPartition(partition, spender, value)
Approves the spender
address to transfer the specified amount of tokens in partition
on behalf of msg.sender
.
Method parameters
Returns
Amp.approveByPartition
returns a bool
indicating if the operation was successful.
increaseAllowanceByPartition
increaseAllowanceByPartition(partition, spender, addedValue)
Increases the allowance granted to an account by the caller for a partition.
Requirements:
spender
cannot be the zero address.
Method parameters
Returns
Amp.increaseAllowanceByPartition
returns a bool
indicating if the operation was successful.
decreaseAllowanceByPartition
decreaseAllowanceByPartition(partition, spender, subtractedValue)
Decreases the allowance granted to spender
by the caller.
Requirements:
spender
cannot be the zero address.
spender
must have an allowance for the caller of at least subtractedValue
.
Method parameters
Returns
Amp.decreaseAllowanceByPartition
returns a bool
indicating if the operation was successful.
registerCollateralManager
registerCollateralManager(collateralManager)
Registers msg.sender
as a collateral manager.
isCollateralManager
isCollateralManager(collateralManager)
Retrieves whether the supplied address is a collateral manager.
Method parameters
Returns
Amp.isCollateralManager
returns a bool
indicating whether collateralManager
is registered as a collateral manager.
setPartitionStrategy
setPartitionStrategy(prefix, implementation)
Sets an implementation for a partition strategy identified by prefix
.
Note: this function can only be called by the contract owner.
Method parameters
isPartitionStrategy
isPartitionStrategy(prefix)
Return whether the prefix
has had a partition strategy registered.
Method parameters
Returns
Amp.isPartitionStrategy
returns a bool
indicating if the strategy has been registered.
owner
owner()
Retrieves the owner of the contract
Returns
Amp.owner
returns an address
containing the contract owner.
authorizedNewOwner
authorizedNewOwner()
Retrieves the authorized new owner of the contract
Returns
Amp.authorizedNewOwner
returns an address
containing the authorized new contract owner.
authorizeOwnershipTransfer
authorizeOwnershipTransfer(authorizedAddress)
Authorizes the transfer of ownership from owner to the provided address.
Note that the transfer will not occur until authorizedAddress
calls function Amp.assumeOwnership
.
This authorization may be removed by another call to this function authorizing the zero address.
Method parameters
assumeOwnership
assumeOwnership()
Transfers ownership of this contract to the authorized new owner.
canImplementInterfaceForAddress
canImplementInterfaceForAddress(interfaceHash,undefined)
Indicates whether the contract implements the interface interfaceHash
.
Method parameters
Returns
Amp.canImplementInterfaceForAddress
returns a bytes32
containing the ERC-1820 "accept magic" string if the contract implements ìnterfaceHash
.
This method is required for ERC-20 compatibility, but is subject to the race condition described in .
This is an alternative to Amp.approve
that can be used as a mitigation for the race condition described in .
This is an alternative to Amp.approve
that can be used as a mitigation for the race condition described in .
Note that this method is subject to the race condition described in . Functions Amp.increaseAllowanceByPartition
and Amp.decreaseAllowanceByPartition
should be used instead.
This is an alternative to function Amp.approveByPartition
that can be used as a mitigation for the race condition described in
This is an alternative to function Amp.approveByPartition
that can be used as a mitigation for the race condition described in
Parameter Name
Status
Type
Description
swapTokenAddress
Required
address
The address of the ERC-20 token that is set to be swappable for AMP
name
Required
string
Name of the token to be initialized
symbol
Required
string
Symbol of the token to be initialized
Parameter Name
Status
Type
Description
tokenHolder
Required
address
Address for which the balance is returned.
Parameter Name
Status
Type
Description
to
Required
address
The address to which the tokens should be transferred.
value
Required
uint256
The amount of tokens to be transferred.
Parameter Name
Status
Type
Description
from
Required
address
The address from which the tokens are to be transferred.
to
Required
address
The address to which the tokens should be transferred.
value
Required
uint256
The amount of tokens to be transferred.
Parameter Name
Status
Type
Description
owner
Required
address
The address holding the authorized tokens.
spender
Required
address
The address authorized to transfer the tokens from owner
.
Parameter Name
Status
Type
Description
value
Required
uint256
The amount of tokens to be authorized.
spender
Required
address
The address which is authorized to transfer tokens from default partition of msg.sender
.
Parameter Name
Status
Type
Description
spender
Required
address
The account authorized to transfer the tokens.
addedValue
Required
uint256
Additional amount of the msg.sender
's tokens spender
is allowed to transfer.
Parameter Name
Status
Type
Description
spender
Required
address
Account whose authorization to transfer tokens is to be decreased.
substractedValue
Required
uint256
Amount by which the authorization for spender
to transfer tokens held by msg.sender
's account is to be decreased.
Parameter Name
Status
Type
Description
from
Required
address
Token holder whose swap tokens will be exchanged for AMP tokens.
Parameter Name
Status
Type
Description
partition
Required
bytes32
The partition for which the balance is returned.
tokenHolder
Required
address
Address for which the balance is returned.
Parameter Name
Status
Type
Description
tokenHolder
Required
address
Address for which the partitions are returned.
Parameter Name
Status
Type
Description
partition
Required
bytes32
The partition from which the tokens are to be transferred.
from
Required
address
Address from which the tokens are to be transferred.
to
Required
address
Address to which the tokens are to be transferred.
value
Required
uint256
Amount of tokens to be transferred.
data
Required
bytes
Information attached to the transfer. Will contain the destination partition if changing partitions.
operatorData
Required
bytes
Additional data attached to the transfer. Used by partition strategies and collateral managers to authorize the transfer.
Parameter Name
Status
Type
Description
operator
Required
address
Address to set as an operator for msg.sender
.
Parameter Name
Status
Type
Description
operator
Required
address
Address to be deauthorized an operator for msg.sender
.
Parameter Name
Status
Type
Description
partition
Required
bytes32
The partition for which the operator
is to be authorized.
operator
Required
address
Address to be authorized as an operator for msg.sender
.
Parameter Name
Status
Type
Description
partition
Required
bytes32
The partition for which the operator
is deauthorized.
operator
Required
address
Address to deauthorize as an operator for msg.sender
.
Parameter Name
Status
Type
Description
operator
Required
address
Address which may be an operator of tokenHolder
.
tokenHolder
Required
address
Address of a token holder which may have the operator
address as an operator.
Parameter Name
Status
Type
Description
partition
Required
bytes32
Partition for which operator
may be authorized.
operator
Required
address
Address which may be an operator of tokenHolder
for the partition
.
tokenHolder
Required
address
Address of a token holder which may have the operator
address as an operator for the partition
.
Parameter Name
Status
Type
Description
partition
Required
bytes32
Partition for which operator
may be authorized.
operator
Required
address
Address which may be an operator of collateralManager
for the partition
collateralManager
Required
address
Address of a collateral manager which may have the operator
address as an operator for the partition
.
Parameter Name
Status
Type
Description
partition
Required
bytes32
Partition for which the spender may be authorized.
owner
Required
address
The address which owns the tokens.
spender
Required
address
The address which is authorized transfer tokens on behalf of the token holder.
Parameter Name
Status
Type
Description
partition
Required
bytes32
Partition for which the spender
is to be authorized to transfer tokens.
spender
Required
address
The address of the account to be authorized to transfer tokens.
value
Required
uint256
The amount of tokens to be authorized.
Parameter Name
Status
Type
Description
partition
Required
bytes32
Partition for which the spender
is to be authorized to transfer tokens.
spender
Required
address
The address of the account to be authorized to transfer tokens.
addedValue
Required
uint256
Additional amount of the msg.sender
's tokens spender
is allowed to transfer.
Parameter Name
Status
Type
Description
partition
Required
bytes32
Partition for which spender
's allowance is to be decreased.
spender
Required
address
Amount by which the authorization for spender
to transfer tokens held by msg.sender
's account is to be decreased.
subtractedValue
Required
uint256
Amount of the msg.sender
's tokens spender
is no longer allowed to transfer.
Parameter Name
Status
Type
Description
collateralManager
Required
address
The address of the collateral manager.
Parameter Name
Status
Type
Description
prefix
Required
bytes4
The 4 byte partition prefix the strategy applies to.
implementation
Required
address
The address of the implementation of the strategy hooks.
Parameter Name
Status
Type
Description
prefix
Required
bytes4
The partition strategy identifier.
Parameter Name
Status
Type
Description
authorizedAddress
Required
address
The address authorized to become the new owner
Parameter Name
Status
Type
Description
interfaceHash
Required
bytes32
keccak256 hash of the name of the interface.
undefined
Required
address
Function