SuperPositions

Git Source

Inherits: ISuperPositions, ERC1155A, StateSyncer

Author: Zeropoint Labs.

SPDX-License-Identifier: Apache-2.0

State Variables

dynamicURI

is the base uri set by admin

string public dynamicURI;

dynamicURIFrozen

is the base uri frozen status

bool public dynamicURIFrozen;

Functions

onlyMinter

minters can be router with id 1 (or) state registry for that beacon

modifier onlyMinter(uint256 superformId) override;

onlyBatchMinter

if registry id is 1 (or) corresponding state registry can mint

minters can be router with id 1 (or) state registry for that beacon

modifier onlyBatchMinter(uint256[] memory superformIds) override;

onlyBurner

if registry id is 1 (or) corresponding state registry can mint

only routers with id 1 can burn super positions

modifier onlyBurner() override;

constructor

constructor(
    string memory dynamicURI_,
    address superRegistry_,
    uint8 routerType_
)
    StateSyncer(superRegistry_, routerType_);

Parameters

NameTypeDescription
dynamicURI_stringURL for external metadata of ERC1155 SuperPositions
superRegistry_addressthe superform registry contract
routerType_uint8the router type

mintSingle

allows minter to mint shares on source

function mintSingle(
    address srcSender_,
    uint256 id_,
    uint256 amount_
)
    external
    override(IStateSyncer, StateSyncer)
    onlyMinter(id_);

Parameters

NameTypeDescription
srcSender_addressis the beneficiary of shares
id_uint256is the id of the shares
amount_uint256is the amount of shares to mint

mintBatch

allows minter to mint shares on source in batch

function mintBatch(
    address srcSender_,
    uint256[] memory ids_,
    uint256[] memory amounts_
)
    external
    override(IStateSyncer, StateSyncer)
    onlyBatchMinter(ids_);

Parameters

NameTypeDescription
srcSender_addressis the beneficiary of shares
ids_uint256[]are the ids of the shares
amounts_uint256[]are the amounts of shares to mint

burnSingle

allows burner to burn shares on source

function burnSingle(
    address srcSender_,
    uint256 id_,
    uint256 amount_
)
    external
    override(IStateSyncer, StateSyncer)
    onlyBurner;

Parameters

NameTypeDescription
srcSender_addressis the address of the sender
id_uint256is the id of the shares
amount_uint256is the amount of shares to burn

burnBatch

allows burner to burn shares on source in batch

function burnBatch(
    address srcSender_,
    uint256[] memory ids_,
    uint256[] memory amounts_
)
    external
    override(IStateSyncer, StateSyncer)
    onlyBurner;

Parameters

NameTypeDescription
srcSender_addressis the address of the sender
ids_uint256[]are the ids of the shares
amounts_uint256[]are the amounts of shares to burn

stateMultiSync

allows state registry contract to mint shares on source

function stateMultiSync(AMBMessage memory data_)
    external
    override(IStateSyncer, StateSyncer)
    returns (uint64 srcChainId_);

Parameters

NameTypeDescription
data_AMBMessageis the received information to be processed.

Returns

NameTypeDescription
srcChainId_uint64is the decoded srcChainId.

stateSync

here we decode the txInfo and params from the data brought back from destination

decode remaining info on superPositions to mint from destination

decode initial payload info stored on source chain in this contract

verify this is a single vault mint

compare final shares beneficiary to be the same (dst/src)

compare txType to be the same (dst/src)

mint super positions accordingly

function stateSync(AMBMessage memory data_) external override(IStateSyncer, StateSyncer) returns (uint64 srcChainId_);

Parameters

NameTypeDescription
data_AMBMessageis the received information to be processed.

Returns

NameTypeDescription
srcChainId_uint64is the decoded srcChainId.

setDynamicURI

here we decode the txInfo and params from the data brought back from destination

decode remaining info on superPositions to mint from destination

decode initial payload info stored on source chain in this contract

verify this is a multi vault mint

compare final shares beneficiary to be the same (dst/src)

compare txType to be the same (dst/src)

mint super positions accordingly

function setDynamicURI(string memory dynamicURI_, bool freeze_) external override onlyProtocolAdmin;

Parameters

NameTypeDescription
dynamicURI_stringis the dynamic uri of the NFT
freeze_boolis to prevent updating the metadata once migrated to IPFS

supportsInterface

Implementation copied from solmate/ERC1155

function supportsInterface(bytes4 interfaceId_) public view virtual override(ERC1155A) returns (bool);

_baseURI

Used to construct return url

function _baseURI() internal view override returns (string memory);