ODCdataManagersfractionalizersERC20Fraction

FractionERC20DataManager

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

_This contract is used to manage fractions of a Wrapper NFT using an OmnichainUpgradeableERC20DataManager contract to provide the ERC20 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 OmnichainUpgradeableERC20DataManager
 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 OmnichainFungibleTokenWithLocalMintBurnSupplyDO data object, the missing function
 localMintBurnSupply() is implemented here._

UserUnlockDisabled

error UserUnlockDisabled()

Error thrown when user unlock enabled is false

wrapper

address wrapper

Wrapper Contract address

nftId

uint256 nftId

Wrapped NFT id

userUnlockEnabled

bool userUnlockEnabled

allows unlock by fraction owners burning their fractions

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(bytes32 dataPoint_, address beneficiary_, address wrapper_, address dataIndex_, address dataObject_, string name_, string symbol_, uint256 nftId_, uint256 amountToBeMinted_, bool userUnlockEnabled_) external virtual

Initializes the DataManager

Parameters

NameTypeDescription
dataPoint_bytes32DataPoint used for the project
beneficiary_address
wrapper_addressAddress of the Wrapper contract (same as Wrapped NFT), must be 0 on secondary chains
dataIndex_addressAddress of DataIndex implementation
dataObject_addressData Object used to store balance data (use OmnichainFungibleTokenWithLocalMintBurnSupplyDO)
name_stringName of the Fraction token
symbol_stringSymbol of the Fraction token
nftId_uint256Id of the Wrapped NFT
amountToBeMinted_uint256Amount of fractions to mint
userUnlockEnabled_boolEnables Fraction owners to unlock via burning their fractions

__FractionERC20DataManager_init_unchained

function __FractionERC20DataManager_init_unchained(uint256 nftId_, address beneficiary_, address wrapper_, uint256 amountToBeMinted_, bool userUnlockEnabled_) 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 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
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

burnFromOwnerUnwrapToAccount

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

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 ERC20 Data Manager

Parameters

NameTypeDescription
newOwneraddressAddress of the new owner

localMintBurnSupply

function localMintBurnSupply() public view returns (uint256)

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

This function returns 0 in secondary chains

Return Values

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

transferFrom

function transferFrom(address from, OmnichainAddress to, uint256 value, address payable refundAddress) public payable virtual returns (bool)

transferFrom

Parameters

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

mint

function mint(address to, uint256 value) public

Mint value tokens to to

The caller must be allowed to mint

Parameters

NameTypeDescription
toaddressAddress to mint tokens to
valueuint256Amount to mint

burn

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

Burn value tokens from from (of id in ERC1155)

Parameters

NameTypeDescription
fromaddressAddress to burn tokens from
uint256
valueuint256Amount to burn