8ISuperToken

This is the technical reference related to the interface for Super Tokens.

Implementation addressesarrow-up-right

Super Token deployments work in a proxy pattern with the original implementation being comon between all super tokens for each chain. The implementation address for the SuperToken is different for each network and can be found in the SuperTokenFactory at the method getSuperTokenLogic.

To get the addresses of all the SuperTokenFactory contracts, you can use the Tagomi Explorer, section Protocol.

In order to interact with any contract satistying the ISuperToken interface, you can use the following ABI:

chevron-rightClick here to show ISuperToken ABIhashtag

Fn initializearrow-up-right

function initialize(
    contract IERC20 underlyingToken,
    uint8 underlyingDecimals,
    string n,
    string s
) 
    external

Initialize the contract

Parametersarrow-up-right

Name
Type
Description

underlyingToken

contract IERC20

underlyingDecimals

uint8

n

string

s

string

Fn initializeWithAdminarrow-up-right

Initialize the contract with an admin

Parametersarrow-up-right

Name
Type
Description

underlyingToken

contract IERC20

underlyingDecimals

uint8

n

string

s

string

admin

address

Fn changeAdminarrow-up-right

Only the current admin can call this function if admin is address(0), it is implicitly the host address

Parametersarrow-up-right

Name
Type
Description

newAdmin

address

New admin address

Changes the admin for the SuperToken

Returns the admin address for the SuperToken

Fn CONSTANT_OUTFLOW_NFTarrow-up-right

Fn CONSTANT_INFLOW_NFTarrow-up-right

Fn POOL_ADMIN_NFTarrow-up-right

Fn POOL_MEMBER_NFTarrow-up-right

Returns the name of the token.

Returns the symbol of the token, usually a shorter version of the name.

_Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2).

Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value ERC20 uses, unless setupDecimals is called.

Notearrow-up-right

SuperToken always uses 18 decimals.

This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including IBEP20-balanceOf and IBEP20-transfer.

Fn totalSupplyarrow-up-right

See IBEP20-totalSupply.

Fn balanceOfarrow-up-right

Returns the amount of tokens owned by an account (owner).

Parametersarrow-up-right

Name
Type
Description

account

address

Moves amount tokens from the caller's account to recipient.

Parametersarrow-up-right

Name
Type
Description

recipient

address

amount

uint256

Return Valuesarrow-up-right

Name
Type
Description

[0]

bool

Returns Success a boolean value indicating whether the operation succeeded.

Emitsarrow-up-right

a BEP20 Transfer event.

Fn allowancearrow-up-right

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default.

Parametersarrow-up-right

Name
Type
Description

owner

address

spender

address

This value changes when approve or transferFrom are called.

Sets amount as the allowance of spender over the caller's tokens.

Parametersarrow-up-right

Name
Type
Description

spender

address

amount

uint256

Return Valuesarrow-up-right

Name
Type
Description

[0]

bool

Returns Success a boolean value indicating whether the operation succeeded.

Notearrow-up-right

Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards

Emitsarrow-up-right

an Approval event.

Fn transferFromarrow-up-right

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance.

Parametersarrow-up-right

Name
Type
Description

sender

address

recipient

address

amount

uint256

Return Valuesarrow-up-right

Name
Type
Description

[0]

bool

Returns Success a boolean value indicating whether the operation succeeded.

Emitsarrow-up-right

a Transfer event.

Fn increaseAllowancearrow-up-right

_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 IBEP20-approve._

Parametersarrow-up-right

Name
Type
Description

spender

address

addedValue

uint256

Emitsarrow-up-right

an Approval event indicating the updated allowance.

@custom:requirements

  • `spender` cannot be the zero address.

Fn decreaseAllowancearrow-up-right

_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 IBEP20-approve._

Parametersarrow-up-right

Name
Type
Description

spender

address

subtractedValue

uint256

Emitsarrow-up-right

an Approval event indicating the updated allowance.

@custom:requirements

  • `spender` cannot be the zero address.

  • `spender` must have allowance for the caller of at least `subtractedValue`.

Fn granularityarrow-up-right

Returns the smallest part of the token that is not divisible. This means all token operations (creation, movement and destruction) must have amounts that are a multiple of this number.

Notearrow-up-right

For super token contracts, this value is always 1

_Moves amount tokens from the caller's account to recipient.

If send or receive hooks are registered for the caller and recipient, the corresponding functions will be called with userData and empty operatorData. See IERC777Senderarrow-up-right and IERC777Recipientarrow-up-right._

Parametersarrow-up-right

Name
Type
Description

recipient

address

amount

uint256

userData

bytes

Emitsarrow-up-right

a Sent event.

@custom:requirements

  • the caller must have at least `amount` tokens.

  • `recipient` cannot be the zero address.

  • if `recipient` is a contract, it must implement the IERC777Recipient interface.

_Destroys amount tokens from the caller's account, reducing the total supply and transfers the underlying token to the caller's account.

If a send hook is registered for the caller, the corresponding function will be called with userData and empty operatorData. See IERC777Sender._

Parametersarrow-up-right

Name
Type
Description

amount

uint256

userData

bytes

Emitsarrow-up-right

a Burned event.

@custom:requirements

  • the caller must have at least `amount` tokens.

Fn isOperatorForarrow-up-right

_Returns true if an account is an operator of tokenHolder. Operators can send and burn tokens on behalf of their owners. All accounts are their own operator.

See operatorSend and operatorBurn._

Parametersarrow-up-right

Name
Type
Description

operator

address

tokenHolder

address

Fn authorizeOperatorarrow-up-right

_Make an account an operator of the caller.

See isOperatorFor._

Parametersarrow-up-right

Name
Type
Description

operator

address

Emitsarrow-up-right

an AuthorizedOperator event.

@custom:requirements

  • `operator` cannot be calling address.

Fn revokeOperatorarrow-up-right

_Revoke an account's operator status for the caller.

See isOperatorFor and defaultOperators._

Parametersarrow-up-right

Name
Type
Description

operator

address

Emitsarrow-up-right

a RevokedOperator event.

@custom:requirements

  • `operator` cannot be calling address.

Fn defaultOperatorsarrow-up-right

_Returns the list of default operators. These accounts are operators for all token holders, even if authorizeOperator was never called on them.

This list is immutable, but individual holders may revoke these via revokeOperator, in which case isOperatorFor will return false._

Fn operatorSendarrow-up-right

_Moves amount tokens from sender to recipient. The caller must be an operator of sender.

If send or receive hooks are registered for sender and recipient, the corresponding functions will be called with userData and operatorData. See IERC777Sender and IERC777Recipient._

Parametersarrow-up-right

Name
Type
Description

sender

address

recipient

address

amount

uint256

userData

bytes

operatorData

bytes

Emitsarrow-up-right

a Sent event.

@custom:requirements

  • `sender` cannot be the zero address.

  • `sender` must have at least `amount` tokens.

  • the caller must be an operator for `sender`.

  • `recipient` cannot be the zero address.

  • if `recipient` is a contract, it must implement the IERC777Recipient interface.

Fn operatorBurnarrow-up-right

_Destroys amount tokens from account, reducing the total supply. The caller must be an operator of account.

If a send hook is registered for account, the corresponding function will be called with userData and operatorData. See IERC777Sender._

Parametersarrow-up-right

Name
Type
Description

account

address

amount

uint256

userData

bytes

operatorData

bytes

Emitsarrow-up-right

a Burned event.

@custom:requirements

  • `account` cannot be the zero address.

  • `account` must have at least `amount` tokens.

  • the caller must be an operator for `account`.

_Mint new tokens for the account If userData is not empty, the tokensReceived hook is invoked according to ERC777 semantics.

@custom:modifiers

  • onlySelf_

Parametersarrow-up-right

Name
Type
Description

account

address

amount

uint256

userData

bytes

_Burn existing tokens for the account If userData is not empty, the tokensToSend hook is invoked according to ERC777 semantics.

@custom:modifiers

  • onlySelf_

Parametersarrow-up-right

Name
Type
Description

account

address

amount

uint256

userData

bytes

Fn selfTransferFromarrow-up-right

_Transfer amount tokens from the sender to recipient. If spender isn't the same as sender, checks if spender has allowance to spend tokens of sender.

@custom:modifiers

  • onlySelf_

Parametersarrow-up-right

Name
Type
Description

sender

address

spender

address

recipient

address

amount

uint256

Fn selfApproveForarrow-up-right

_Give spender, amount allowance to spend the tokens of account.

@custom:modifiers

  • onlySelf_

Parametersarrow-up-right

Name
Type
Description

account

address

spender

address

amount

uint256

Fn transferAllarrow-up-right

Transfer all available balance from msg.sender to recipient

Parametersarrow-up-right

Name
Type
Description

recipient

address

Fn getUnderlyingTokenarrow-up-right

Return the underlying token contract

Return Valuesarrow-up-right

Name
Type
Description

tokenAddr

address

Underlying token address

Fn getUnderlyingDecimalsarrow-up-right

Return the underlying token decimals

Return Valuesarrow-up-right

Name
Type
Description

underlyingDecimals

uint8

Underlying token decimals

Fn toUnderlyingAmountarrow-up-right

Return the underlying token conversion rate

Parametersarrow-up-right

Name
Type
Description

amount

uint256

Number of tokens to be upgraded (in 18 decimals)

Return Valuesarrow-up-right

Name
Type
Description

underlyingAmount

uint256

The underlying token amount after scaling

adjustedAmount

uint256

The super token amount after scaling

Upgrade ERC20 to SuperToken.

Parametersarrow-up-right

Name
Type
Description

amount

uint256

Number of tokens to be upgraded (in 18 decimals)

Notearrow-up-right

It will use `transferFrom` to get tokens. Before calling this function you should `approve` this contract

Fn upgradeToarrow-up-right

Upgrade BEP20 to SuperToken and transfer immediately

Parametersarrow-up-right

Name
Type
Description

to

address

The account to receive upgraded tokens

amount

uint256

Number of tokens to be upgraded (in 18 decimals)

userData

bytes

User data for the TokensRecipient callback

Notearrow-up-right

It will use `transferFrom` to get tokens. Before calling this function you should `approve` this contract

@custom:warning

  • there is potential of reentrancy IF the "to" account is a registered ERC777 recipient. @custom:requirements

  • if `userData` is NOT empty AND `to` is a contract, it MUST be a registered ERC777 recipient otherwise it reverts.

Fn downgradearrow-up-right

Downgrade SuperToken to ERC20. It will call transfer to send tokens

Parametersarrow-up-right

Name
Type
Description

amount

uint256

Number of tokens to be downgraded

Fn downgradeToarrow-up-right

Downgrade SuperToken to BEP20 and transfer immediately

Parametersarrow-up-right

Name
Type
Description

to

address

The account to receive downgraded tokens

amount

uint256

Number of tokens to be downgraded (in 18 decimals)

Fn operationApprovearrow-up-right

Perform BEP20 approve by host contract.

Parametersarrow-up-right

Name
Type
Description

account

address

The account owner to be approved.

spender

address

The spender of account owner's funds.

amount

uint256

Number of tokens to be approved.

@custom:modifiers

  • onlyHost |

Fn operationIncreaseAllowancearrow-up-right

Parametersarrow-up-right

Name
Type
Description

account

address

spender

address

addedValue

uint256

Fn operationDecreaseAllowancearrow-up-right

Parametersarrow-up-right

Name
Type
Description

account

address

spender

address

subtractedValue

uint256

Fn operationTransferFromarrow-up-right

Perform ERC20 transferFrom by host contract.

Parametersarrow-up-right

Name
Type
Description

account

address

The account to spend sender's funds.

spender

address

The account where the funds is sent from.

recipient

address

The recipient of the funds.

amount

uint256

Number of tokens to be transferred.

@custom:modifiers

  • onlyHost |

Fn operationSendarrow-up-right

Perform ERC777 send by host contract.

Parametersarrow-up-right

Name
Type
Description

spender

address

The account where the funds is sent from.

recipient

address

The recipient of the funds.

amount

uint256

Number of tokens to be transferred.

userData

bytes

Arbitrary user inputted data

@custom:modifiers

  • onlyHost |

Fn operationUpgradearrow-up-right

Upgrade ERC20 to SuperToken by host contract.

Parametersarrow-up-right

Name
Type
Description

account

address

The account to be changed.

amount

uint256

Number of tokens to be upgraded (in 18 decimals)

@custom:modifiers

  • onlyHost |

Fn operationDowngradearrow-up-right

Downgrade ERC20 to SuperToken by host contract.

Parametersarrow-up-right

Name
Type
Description

account

address

The account to be changed.

amount

uint256

Number of tokens to be downgraded (in 18 decimals)

@custom:modifiers

  • onlyHost |

Event AdminChangedarrow-up-right

Parametersarrow-up-right

Name
Type
Description

oldAdmin

address

newAdmin

address

Event TokenUpgradedarrow-up-right

Token upgrade event

Parametersarrow-up-right

Name
Type
Description

account

address

Account where tokens are upgraded to

amount

uint256

Amount of tokens upgraded (in 18 decimals)

Event TokenDowngradedarrow-up-right

Token downgrade event

Parametersarrow-up-right

Name
Type
Description

account

address

Account whose tokens are downgraded

amount

uint256

Amount of tokens downgraded

Event ConstantOutflowNFTCreatedarrow-up-right

Constant Outflow NFT proxy created event

Parametersarrow-up-right

Name
Type
Description

constantOutflowNFT

contract IConstantOutflowNFT

constant outflow nft address

Event ConstantInflowNFTCreatedarrow-up-right

Constant Inflow NFT proxy created event

Parametersarrow-up-right

Name
Type
Description

constantInflowNFT

contract IConstantInflowNFT

constant inflow nft address

Event PoolAdminNFTCreatedarrow-up-right

Pool Admin NFT proxy created event

Parametersarrow-up-right

Name
Type
Description

poolAdminNFT

contract IPoolAdminNFT

pool admin nft address

Event PoolMemberNFTCreatedarrow-up-right

Pool Member NFT proxy created event

Parametersarrow-up-right

Name
Type
Description

poolMemberNFT

contract IPoolMemberNFT

pool member nft address

SUPER_TOKEN_CALLER_IS_NOT_OPERATOR_FOR_HOLDERarrow-up-right

SUPER_TOKEN_NOT_ERC777_TOKENS_RECIPIENTarrow-up-right

SUPER_TOKEN_INFLATIONARY_DEFLATIONARY_NOT_SUPPORTEDarrow-up-right

SUPER_TOKEN_NO_UNDERLYING_TOKENarrow-up-right

SUPER_TOKEN_ONLY_SELFarrow-up-right

SUPER_TOKEN_ONLY_ADMINarrow-up-right

SUPER_TOKEN_ONLY_GOV_OWNERarrow-up-right

SUPER_TOKEN_APPROVE_FROM_ZERO_ADDRESSarrow-up-right

SUPER_TOKEN_APPROVE_TO_ZERO_ADDRESSarrow-up-right

SUPER_TOKEN_BURN_FROM_ZERO_ADDRESSarrow-up-right

SUPER_TOKEN_MINT_TO_ZERO_ADDRESSarrow-up-right

SUPER_TOKEN_TRANSFER_FROM_ZERO_ADDRESSarrow-up-right

SUPER_TOKEN_TRANSFER_TO_ZERO_ADDRESSarrow-up-right

SUPER_TOKEN_NFT_PROXY_ADDRESS_CHANGEDarrow-up-right

Last updated

Was this helpful?