ODCdataManagersfractionalizersERC1155Fraction

FractionERC1155DataManager

Contract for managing fractions of a Wrapper NFT using an ERC1155 token

_This contract is used to manage fractions of a Wrapper NFT using an OmnichainUpgradeableERC1155DataManager contract to provide the ERC1155 token functionality.

 NOTE: This contract and the Data Object contract MUST be approved in the Data Index contract to interact with the given
 Data Point.

 On secondary chains this contract functionality is limited to OmnichainUpgradeableERC1155DataManager
 We are using same contract both on primary and secondary chains to ensure they have same address on all chains.

 Since this contract use the OmnichainFungibleFractionsWithLocalMintBurnSupplyDO data object, the missing function
 localMintBurnSupply() is implemented here._

UserUnlockDisabled

error UserUnlockDisabled()

Error thrown when user unlock enabled is false

FractionConfig

struct FractionConfig {
  address wrapper;
  uint256 nftId;
  uint256 initialSupply;
  uint256 upperGenesisId;
  bool userUnlockEnabled;
}

wrapper

address wrapper

Wrapper Contract address

nftId

uint256 nftId

Wrapped NFT id

userUnlockEnabled

bool userUnlockEnabled

Allows unlock by fraction owners burning their fractions

upperGenesisId

uint256 upperGenesisId

This is the upper limit of the genesis id. f.i. if genesis ids are 0, 1, 2, 3 then this limit is equal to 3.

Genesis ids are always the first consecutives ids up to the upper genesis limit needed.

totalSupplyGenesisIds

uint256 totalSupplyGenesisIds

The total supply of all the genesis ids

onlyPrimaryChain

modifier onlyPrimaryChain()

Modifier to check if the contract is on the primary chain

onlyIfUserUnlockEnabled

modifier onlyIfUserUnlockEnabled()

Modifier to check if fraction owners can unlock by burning their fractions

constructor

constructor() public

initialize

function initialize(struct IFractionERC1155DataManager.OmnichainERC1155InitData omnichainERC1155InitData, address beneficiary_, address wrapper_, uint256 nftId_, uint256 amountToBeMinted_, uint256 upperGenesisId_, bool userUnlockEnabled_) external virtual

Initializes the DataManager

Parameters

NameTypeDescription
omnichainERC1155InitDatastruct IFractionERC1155DataManager.OmnichainERC1155InitDataInit data for Omnichain ERC1155 DM
beneficiary_addressAddress which receives minted fractions
wrapper_addressAddress of the Wrapper contract (same as Wrapped NFT), must be 0 on secondary chains
nftId_uint256Id of the Wrapped NFT
amountToBeMinted_uint256Amount of fractions ot mint
upperGenesisId_uint256The upper limit of the genesis ids
userUnlockEnabled_boolEnables Fraction owners to unlock via burning their fractions

__OmnichainUpgradeableERC1155DataManager_init_with_struct

function __OmnichainUpgradeableERC1155DataManager_init_with_struct(struct IFractionERC1155DataManager.OmnichainERC1155InitData omnichainERC1155InitData) internal

__FractionERC1155DataManager_init_unchained

function __FractionERC1155DataManager_init_unchained(address beneficiary_, struct FractionERC1155DataManager.FractionConfig fractionConfig_) internal

forceUnlockNft

function forceUnlockNft(address receiver) external

Can be used by contract owner to receive Wrapped NFT

Parameters

NameTypeDescription
receiveraddresswho should receive NFT

forceFullyUnlockWrappedAssets

function forceFullyUnlockWrappedAssets(address receiver) external

Can be used by contract owner to receive wrapped assets (this includes burning the Wrapped NFT)

Parameters

NameTypeDescription
receiveraddresswho should receive wrapped assets

fullyUnlockWrappedAssets

function fullyUnlockWrappedAssets(address beneficiary) external

Can be used by fractions owner to recieve wrapped assets in exchange to all fractions All fractions will be burned.

Parameters

NameTypeDescription
beneficiaryaddresswho should receive wrapped assets

partiallyUnlockWrappedAssets

function partiallyUnlockWrappedAssets(uint256 genesisId, uint256 fractionsToBurn, bool skipNonPercentageWtypes, address beneficiary) external

Can be used by fractions owner to recieve part of wrapped assets in exchange to his fractions Amount of assets he receives is proportional to burned fractions

Parameters

NameTypeDescription
genesisIduint256the genesis id to be used
fractionsToBurnuint256amount of fractions to burn
skipNonPercentageWtypesboolallows to skip non-fungible assets, where correct percentage can not be counted, otherwise if there are such wrapped assets, this call will revert
beneficiaryaddresswho should receive wrapped assets

partiallyUnlockWrappedAssetsBatch

function partiallyUnlockWrappedAssetsBatch(uint256[] genesisIds, uint256[] fractionsToBurnforId, bool skipNonPercentageWtypes, address beneficiary) external

Batch version of partially unlocking wrapped assets. Can be used by fractions owner to recieve part of wrapped assets in exchange to his fractions Amount of assets he receives is proportional to burned fractions

Parameters

NameTypeDescription
genesisIdsuint256[]the genesis ids to be used
fractionsToBurnforIduint256[]
skipNonPercentageWtypesboolallows to skip non-fungible assets, where correct percentage can not be counted, otherwise if there are such wrapped assets, this call will revert
beneficiaryaddresswho should receive wrapped assets

burnMintAndPartiallyUnwrap

function burnMintAndPartiallyUnwrap(uint256 fractionsToHandle, uint256 burnId, uint256 mintId, address account, address[] tokens, uint256[] ids, uint256[] values) external

Allows contract owner to burn, mint and partially unwrap assets depending on specific ids and amounts

Parameters

NameTypeDescription
fractionsToHandleuint256The amount of fractions to burn for burnId and mint of mintId
burnIduint256The id from which fractionsToHandle will be burnt
mintIduint256The id of which fractionsToHandle will be minted (if 0 no id is minted)
accountaddressThe address from which the fractions will be burnt, to which the minted fractions will be minted and unwrapped assets will be provided
tokensaddress[]The array of token addresses to be unwrapped
idsuint256[]The array of ids to be unwrapped
valuesuint256[]The array of values to be unwrapped

burnFromOwnerMintToAccount

function burnFromOwnerMintToAccount(uint256 fractionsToHandle, uint256 burnId, uint256 mintId, address account) external

Allows contract owner to burn amount from himself/herself and mint to an account Both burnId and mintId should be genesis ids

Parameters

NameTypeDescription
fractionsToHandleuint256The amount of fractions to burn for burnId and mint of mintId
burnIduint256The id from which fractionsToHandle will be burnt
mintIduint256The id of which fractionsToHandle will be minted
accountaddressThe address to which the minted fractions will be minted

burnFromOwnerUnwrapToAccount

function burnFromOwnerUnwrapToAccount(uint256 fractionsToHandle, uint256 burnId, address account, address[] tokens, uint256[] ids, uint256[] values) external

percentageBurnMintAndPartiallyUnwrap

function percentageBurnMintAndPartiallyUnwrap(uint256 fractionsToHandle, uint256 burnId, uint256 mintId, address account, uint256 percentageToProvide) external

Allows contract owner to burn, mint and partially unwrap assets depending on a percentage

Parameters

NameTypeDescription
fractionsToHandleuint256The amount of fractions to burn for burnId and mint of mintId
burnIduint256The id from which fractionsToHandle will be burnt
mintIduint256The id of which fractionsToHandle will be minted (if 0 no id is minted)
accountaddressThe address from which the fractions will be burnt, to which the minted fractions will be minted and unwrapped assets will be provided
percentageToProvideuint256The percentage of the wrapped assets to be provided to the account

execute

function execute(address token, bytes input) external payable

Allows contract owner to send messages (execute calls) on wrapped assets

Parameters

NameTypeDescription
tokenaddressAsset contract to send message to
inputbytesMessage to send (abi-encoded call payload with method selector and arguments)

onERC721Received

function onERC721Received(address, address, uint256, bytes) external pure returns (bytes4)

_Whenever an {IERC721} tokenId token is transferred to this contract via {IERC721-safeTransferFrom} by operator from from, this function is called.

It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.

The selector can be obtained in Solidity with IERC721Receiver.onERC721Received.selector._

transferOwnership

function transferOwnership(address newOwner) public virtual

Function used to transfer ownership of the Fraction ERC1155 Data Manager

Parameters

NameTypeDescription
newOwneraddressAddress of the new owner

localMintBurnSupplyAll

function localMintBurnSupplyAll() public view returns (uint256)

Function used to get count of all minted and not burned tokens on current chain of all ids

Return Values

NameTypeDescription
[0]uint256Difference between tokens minted and burned on current chain of all ids

localMintBurnSupply

function localMintBurnSupply(uint256 id) public view returns (uint256)

Function used to get count of all minted and not burned tokens on current chain of a specific id

Parameters

NameTypeDescription
iduint256Id of the token

Return Values

NameTypeDescription
[0]uint256Difference between tokens minted and burned on current chain of the id

safeTransferFrom

function safeTransferFrom(address from, OmnichainAddress to, uint256 id, uint256 value, bytes data, address payable refundAddress) public payable virtual

SafeTransferFrom

Parameters

NameTypeDescription
fromaddressAddress to get the token from
toOmnichainAddressAddress to provide tokens to
iduint256The id of the token
valueuint256The amount of the tokens to transfer
databytesExtra data needed
refundAddressaddress payableAddress to send native coin refund to

mint

function mint(address to, uint256 id, uint256 value, bytes data) public

Mint value tokens of id to to

The caller must be allowed to mint

Parameters

NameTypeDescription
toaddressAddress to mint tokens to
iduint256Token id to mint
valueuint256Amount to mint
databytesAdditional data with no specified format

burn

function burn(address from, uint256 id, uint256 value) public

Burn value tokens from from (of id in ERC1155)

Parameters

NameTypeDescription
fromaddressAddress to burn tokens from
iduint256The tokenId to burn (only for erc1155)
valueuint256Amount to burn