Skip to main content

ReceiptTokenManager

Git Source

Inherits: ERC6909Wrappable, IReceiptTokenManager

Title: ReceiptTokenManager

Manager contract for creating and managing ERC6909 receipt tokens for deposits

Extracted from DepositManager to reduce contract size. Key Features:

  • Creator-only minting/burning: Only the contract that creates a token can mint/burn it
  • ERC6909 compatibility with optional ERC20 wrapping via CloneableReceiptToken clones
  • Deterministic token ID generation based on owner, asset, deposit period, and operator
  • Automatic wrapped token creation for seamless DeFi integration Security Model:
  • Token ownership is immutable and set to msg.sender during creation
  • All mint/burn operations are gated by onlyTokenOwner modifier
  • Token IDs include owner address to prevent collision attacks

State Variables

_tokenOwners

Maps token ID to the authorized owner (for mint/burn operations)

mapping(uint256 tokenId => address authorizedOwner) internal _tokenOwners

Functions

constructor

constructor() ERC6909Wrappable(address(new CloneableReceiptToken()));

createToken

Creates a new receipt token

This function reverts if:

  • The asset is the zero address
  • The deposit period is 0
  • The operator is the zero address
  • A token with the same parameters already exists
function createToken(IERC20 asset_, uint8 depositPeriod_, address operator_, string memory operatorName_)
external
returns (uint256 tokenId);

Parameters

NameTypeDescription
asset_IERC20The underlying asset
depositPeriod_uint8The deposit period
operator_addressThe operator address
operatorName_stringThe operator name for token metadata

Returns

NameTypeDescription
tokenIduint256The created token ID

_onlyTokenOwner

function _onlyTokenOwner(uint256 tokenId_) internal view;

onlyTokenOwner

modifier onlyTokenOwner(uint256 tokenId_) ;

mint

Mints tokens to a recipient

This function reverts if:

  • The token ID is invalid (not created)
  • The caller is not the token owner
  • The recipient is the zero address
  • The amount is 0
function mint(address to_, uint256 tokenId_, uint256 amount_, bool shouldWrap_)
external
onlyValidTokenId(tokenId_)
onlyTokenOwner(tokenId_);

Parameters

NameTypeDescription
to_addressThe recipient
tokenId_uint256The token ID
amount_uint256The amount to mint
shouldWrap_boolWhether to wrap as ERC20

burn

Burns tokens from a holder

This function reverts if:

  • The token ID is invalid (not created)
  • The caller is not the token owner
  • The account is the zero address
  • The amount is 0
  • For wrapped tokens: account has not approved ReceiptTokenManager to spend the wrapped ERC20 token
  • For unwrapped tokens: account has not approved the caller to spend ERC6909 tokens
  • The account has insufficient token balance
function burn(address from_, uint256 tokenId_, uint256 amount_, bool isWrapped_)
external
onlyValidTokenId(tokenId_)
onlyTokenOwner(tokenId_);

Parameters

NameTypeDescription
from_addressThe holder
tokenId_uint256The token ID
amount_uint256The amount to burn
isWrapped_boolWhether the tokens are wrapped

getReceiptTokenId

Generates a receipt token ID

function getReceiptTokenId(address owner_, IERC20 asset_, uint8 depositPeriod_, address operator_)
public
pure
override
returns (uint256);

Parameters

NameTypeDescription
owner_addressThe owner address
asset_IERC20The asset
depositPeriod_uint8The deposit period
operator_addressThe operator

Returns

NameTypeDescription
<none>uint256tokenId The generated token ID

getTokenName

Returns the name of a receipt token

function getTokenName(uint256 tokenId_) public view override returns (string memory);

Parameters

NameTypeDescription
tokenId_uint256The ID of the receipt token

Returns

NameTypeDescription
<none>stringname The name of the receipt token

getTokenSymbol

Returns the symbol of a receipt token

function getTokenSymbol(uint256 tokenId_) public view override returns (string memory);

Parameters

NameTypeDescription
tokenId_uint256The ID of the receipt token

Returns

NameTypeDescription
<none>stringsymbol The symbol of the receipt token

getTokenDecimals

Returns the decimals of a receipt token

function getTokenDecimals(uint256 tokenId_) public view override returns (uint8);

Parameters

NameTypeDescription
tokenId_uint256The ID of the receipt token

Returns

NameTypeDescription
<none>uint8decimals The decimals of the receipt token

getTokenOwner

Gets the owner of a token

function getTokenOwner(uint256 tokenId_) public view override returns (address);

Parameters

NameTypeDescription
tokenId_uint256The token ID

Returns

NameTypeDescription
<none>addressowner The token owner

getTokenAsset

Gets the asset of a token

function getTokenAsset(uint256 tokenId_) external view override returns (IERC20);

Parameters

NameTypeDescription
tokenId_uint256The token ID

Returns

NameTypeDescription
<none>IERC20asset The underlying asset

getTokenDepositPeriod

Gets the deposit period of a token

function getTokenDepositPeriod(uint256 tokenId_) external view override returns (uint8);

Parameters

NameTypeDescription
tokenId_uint256The token ID

Returns

NameTypeDescription
<none>uint8depositPeriod The deposit period

getTokenOperator

Gets the operator of a token

function getTokenOperator(uint256 tokenId_) external view override returns (address);

Parameters

NameTypeDescription
tokenId_uint256The token ID

Returns

NameTypeDescription
<none>addressoperator The operator address

supportsInterface

function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC6909Wrappable, IERC165)
returns (bool);