An ERC-20 contract for ManageLife. Token Symbol: LIFE ($LIFE) This contract manages token rewards issued to ManageLife homeowners and investors. This contract also handles native token functions (EIP20 Token Standard).
mapping(uint256 => uint64) startOfStakingRewards
Mapping to get the start of staking for each NFTs. Start of stake data is in UNIX timestamp form.
contract ManageLife _manageLifeToken
Instance of the MLIFE NFT contract
contract ManageLifeInvestorsNFT _investorsNft
Instance of the NFTi contract
constructor(uint256 initialSupply) public
Set initial token supply before deploying.
function pause() external
Security feature to Pause smart contracts transactions
function unpause() external
Unpausing the Paused transactions feature.
function setManageLifeToken(address manageLifeToken_) external
Set the MLIFE's NFT contract address.
Important to set this after deployment.
Name | Type | Description |
---|---|---|
manageLifeToken_ | address | Address of the MLIFE NFT contract |
function setNftiToken(address investorsNft_) external
Set the NFTi contract address.
Important to set this after deployment.
Name | Type | Description |
---|---|---|
investorsNft_ | address | Contract address of NFTi contract. |
function manageLifeToken() external view returns (address)
Return the MLIFE's contract address.
If set, this will return the MLIFE contract address
Name | Type | Description |
---|---|---|
[0] | address | address . |
function manageLifeInvestorsNft() external view returns (address)
Return the NFTi's contract address.
If set, this will return the NFTi contract address.
Name | Type | Description |
---|---|---|
[0] | address | address . |
function initStakingRewards(uint256 tokenId) external
Initialize the Staking for an NFT.
Reverts if the caller is not the MLIFE contract address, MLIFE contact address is not set and if the contract is on-paused status.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the NFT to start stake. |
function updateStartOfStaking(uint256 tokenId, uint64 newStartDate) external
Update the start of stake of an NFT.
Since staking reward is based on time, this function will reset the stake start of an NFT that just recently claimed a token reward. This will be also an on-demand operation where the admins needs to reset the start of stake of an NFT, based off UNIX time.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenID of an NFT. |
newStartDate | uint64 | New start of stake of an NFT. This param should be based on UNIX timestamp and into uint64 type. |
function claimableStakingRewards(uint256 tokenId) public view returns (uint256)
Returns the claimable $LIFE token of an NFT.
MLIFE contract is dependent on this function in calculating the estimated staking rewards of an MLIFE. Formula in calculating the reward: Rewards = Current timestamp - StartOfStake timestamp * Life token issuance rate.
Name | Type | Description |
---|---|---|
tokenId | uint256 | MLIFE's tokenId. |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 |
function burnLifeTokens(uint256 amount, uint256 tokenId) external
Burns $LIFE token from a sender's account.
Name | Type | Description |
---|---|---|
amount | uint256 | Amount to burn. |
tokenId | uint256 | TokenID of the NFT. This will be used as a param for access modifier. |
function mint(uint256 _amount) external
Function to mint additional token supply.
Newly minted amount will be credited to the contract owner.
Name | Type | Description |
---|---|---|
_amount | uint256 | Additional amount to be minted. |
function mintInvestorsRewards(address investorAddress, uint256 _amount) external
Mint $LIFE token rewards for NFTi Investors.
NFTi contract depends on this function to mint $LIFE token rewards to investors. Newly minted tokens here will be credited directly to the investor's wallet address and NOT on the admin wallet.
Name | Type | Description |
---|---|---|
investorAddress | address | Wallet address of the investor. |
_amount | uint256 | Amount to be minted on the investor's address. Amount is based on the calculated staking rewards from NFTi contract. |
function claimStakingRewards(uint256 tokenId) public
Claim $LIFE token staking rewards.
_MLIFE's rewards issuance is reliant on this function. Once the user claim the rewards, this function will mint the tokens directly on the homeowner's wallet. Notes:
- ML's admin or deployer wallet cannot claim $LIFE rewards.
- Setting the MLIFE contract address is prerequisite in running this function.
- This function can only be called by MLIFE holders.
- A percentage of the token reward will be burned. Percentage will be determined by the ML admin.
- Burn call will be handled separately by the frontend app._
Name | Type | Description |
---|---|---|
tokenId | uint256 | MLIFE's tokenId. |
modifier onlyMembers(uint256 tokenId)
Custom access modifier to make sure that the caller of transactions are member of ML.
This identifies if the caller is an investor or NFTi holder.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the NFT that needs to be checked. |
NFTi (ERC-721) contract for ManageLife Investors. Owning this NFT represents a investment in ManageLife's properties in real life. NFT Symbol: NFTi
contract Life lifeToken
Life token instance
mapping(uint256 => uint256) _lifeTokenIssuanceRate
Mapping of NFTi tokenId to their issuance rates
mapping(uint256 => uint64) stakingRewards
Mapping of NFTi tokenId to their start of staking
mapping(uint256 => uint256) unlockDate
Mapping of NFTi tokenId to their unlock dates
string baseUri
Public base URI of ML's NFTs
event BaseURIUpdated(string _newURIAddress)
event StakingClaimed(uint256 tokenId)
event TokenBurned(address burnFrom, uint256 amount)
event TokenIssuanceRateUpdates(uint256 tokenId, uint256 newLifeTokenIssuanceRate)
event StakingInitiated(uint256 tokenId)
event BurnedNft(uint256 tokenId)
constructor() public
function mint(uint256 quantity) external
Mint new NFTis.
Name | Type | Description |
---|---|---|
quantity | uint256 | Number of NFTis to be minted. |
function _baseURI() internal view virtual returns (string)
Base URI for computing {tokenURI}. If set, the resulting URI for each
token will be the concatenation of the baseURI
and the tokenId
. Empty
by default, it can be overridden in child contracts.
function setBaseURI(string newBaseUri) external
Function to change the base URI of the NFTs.
Giving the ML Admins an options in the future to change the URI of NFTs.
Name | Type | Description |
---|---|---|
newBaseUri | string | New URI string. |
function setLifeToken(address lifeToken_) external
Set the Life token contract address.
Important to set this after deployment in order to build integration with the ERC20 contract.
Name | Type | Description |
---|---|---|
lifeToken_ | address | $LIFE token contract address. |
function lifeTokenIssuanceRate(uint256 tokenId) external view returns (uint256)
Query the life token issuance rate of an NFTi.
Default token issuance rate of NFTi is set by admins once the NFTi is issued to investor. Issuance rates varies per NFTi and is maintained by ML admins.
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFTi's tokenId. |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 |
function updateLifeTokenIssuanceRate(uint256 tokenId, uint256 newLifeTokenIssuanceRate) external
Update life token issuance rate of an NFTi.
Updated issuance rate will be provided manually by ML admins. If an NFTi has an accumulated rewards already, the reward will be transferred first to the holder before updating the issuance rate.
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFTi's tokenId. |
newLifeTokenIssuanceRate | uint256 | New issuance rate as provided by ML admins. |
function initStakingRewards(uint256 tokenId) internal
Initialize the staking reward for an NFTi.
This will be triggered by the transfer hook and requires that the MLIFE contract should be set.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of NFTi to be set. |
function issueNftToInvestor(address to, uint256 tokenId, uint256 lifeTokenIssuanceRate_) external
Function to issue an NFT to investors for the first time. Should be used by ML admins only.
Admins will be able to set an initial issuance rate for the NFT and initiate their staking. If the NFT has already an accumulated rewards, admins will not be able to transfer it to other address. Once this has been issued to an investor, the NFTi will be locked up by default for 1 year. At this period, the NFTi will not be able to be transfer to any contract or wallet address. Lock up period can be updated by admin wallet.
Name | Type | Description |
---|---|---|
to | address | Address to issue the NFT |
tokenId | uint256 | TokenId to be issued. |
lifeTokenIssuanceRate_ | uint256 | Token issuance rate. Will be based on ML's mortgrage payment book. |
function checkClaimableStakingRewards(uint256 tokenId) public view returns (uint256)
Function to check the claimable staking reward of an NFT
function claimStakingRewards(uint256 tokenId) public
Claim $LIFE token staking rewards.
_The rewards will be directly minted on the caller address. Once success, the timestamp of stakingRewards for that tokenId will be reset.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the NFT. |
function burnTokens(uint256 amount, uint256 tokenId) external
Burn $LIFE token rewards from an NFTi holder.
Burn percentage if being managed from the frontend app.
Name | Type | Description |
---|---|---|
amount | uint256 | Calculated amount to be burned. |
tokenId | uint256 | TokenId of the NFT, will be used as param in access modifier. |
function transferNft(address to, uint256 tokenId) external
Transfer NFTi function
_This transfer operation checks for some requirements before it successfully proceed. Requirements:
- Sender must be the NFTi owner
- NFTi should have no or have finished the locked up period._
Name | Type | Description |
---|---|---|
to | address | Receiver of NFTi |
tokenId | uint256 | NFTi tokenId to be sent. |
function returnNftToML(uint256 tokenId) external
Return the NFTi to ML wallet.
Use case - The investment period has been completed for a specificc NFTi and the asset needs to be returned. The investor should also clear the lockup period of the NFT so that the admins can transfer it to anyone at anytime. In an event that the NFTi has a claimable reward during the execution of this operation, the reward will be transferred first to the investor.
Name | Type | Description |
---|---|---|
tokenId | uint256 | NFTi's tokenId. |
function setLockDate(uint256 tokenId, uint256 _newLockDate) external
function burnNFt(uint256 tokenId) external
function forceClaimNft(uint256 tokenId) external
modifier onlyInvestor(uint256 tokenId)
Modifier checks to see if the token holder is an NFTi investor
NFT (ERC-721) contract for ManageLife Homeowners. An NFT represents a property or home ownership in real life. Properties are all being managed by ManageLife. NFT Symbol: MLIFE
contract Life lifeToken
contract Marketplace marketplace
address PROPERTY_CUSTODIAN
This is the wallet address where all property NFTs will be stored as soon as the property got vacated or returned to ML.
mapping(uint256 => uint256) lifeTokenIssuanceRate
Mapping to get the issuance rate of a tokenId (propery).
mapping(uint256 => bool) fullyPaid
Mapping to check the payment status of a tokenId.
event FullyPaid(uint256 tokenId)
event StakingInitialized(uint256 tokenId)
event PropertyReturned(address from, uint256 tokenId)
event PropertyCustodianUpdated(address newPropertyCustodian)
event TokenIssuanceRateUpdated(uint256 token, uint256 newLifeTokenIssuanceRate)
constructor() public
string baseUri
Public base URI of ML's NFTs
function _baseURI() internal view virtual returns (string)
Base URI for computing {tokenURI}. If set, the resulting URI for each
token will be the concatenation of the baseURI
and the tokenId
. Empty
by default, can be overridden in child contracts.
function setBaseURI(string newBaseUri) external
Function to change the base URI of the NFTs.
Giving the ML Admins an options in the future to change the URI of NFTs.
Name | Type | Description |
---|---|---|
newBaseUri | string | New URI string. |
function setMarketplace(address payable marketplace_) external
Function to set the Marketplace contract address.
Very important to set this after contract deployment.
Name | Type | Description |
---|---|---|
marketplace_ | address payable | Address of the marketplace contract. |
function setLifeToken(address lifeToken_) external
Function to set the @LIFE token contract address.
Very important to set this after contract deployment.
Name | Type | Description |
---|---|---|
lifeToken_ | address | Address of the $LIFE token contract. |
function markFullyPaid(uint256 tokenId) external
Mark an NFT or property fully paid from all mortgages at ML.
This can only be executed by the contract deployer or admin wallet.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the NFT. |
function mint(uint256 propertyId, uint256 lifeTokenIssuanceRate_) external
Function to mint new NFT properties.
Property ID will be the property number provided by the ML-NFT-API service. Life token issuance rate will be populated by the web3 admin from the portal app.
Name | Type | Description |
---|---|---|
propertyId | uint256 | Property ID of the NFT. This will be provided by the FrontEnd app. |
lifeTokenIssuanceRate_ | uint256 | Issuance rate percentage that is based on morgage payments maintained by ML. |
function burn(uint256 tokenId) public
Burn an NFT. Typical use case is remove an property from ML's custody.
Can only be executed by the admin/deployer wallet.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the NFT to be burned. |
function retract(uint256 tokenId) external
Admin wallet to retract a property (NFT) from a customer.
Use case is the admin wallet needs to force claim an NFT from a customer.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the property that needs to be retrackted. |
function returnProperty(uint256 tokenId) external
Homeowners or NFT holders to return a property to ML wallet.
This will fail if the caller is not the owner of the NFT.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of the NFT to be returned. |
function approve(address to, uint256 tokenId) public
Allow homeowners/NFT holders to approve a 3rd party account to perform transactions on their behalf.
_This works like setApprovalForAll. The owner is giving ownership wo their NFT. Use case of this is an ML customer who would like to give an access to anyone to use the home/property. Requirements in order to make sure this call will succeed:
- The property should be fully paid.
- Function caller should be the ml admin deployer wallet.
- Receiver should be the Marketplace contract address._
Name | Type | Description |
---|---|---|
to | address | Wallet address who will be granted with the above permission. |
tokenId | uint256 | TokenId of the NFT. |
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal
Transfer hooks. The functions inside will be executed as soon as the concerned NFT is being trasnferred.
_Operations inside this hook will be accomplished if either of the checks below were accomplished:
- Customers cannot be able to transfer their NFTs if they are not yet fully paid.
- Sender is the contract owner.
- Receiver is the contract owner.
- Caller of thid function is the Marketplace contract address._
Name | Type | Description |
---|---|---|
from | address | Sender of the NFT. |
to | address | Receiver of the NFT. |
tokenId | uint256 | TokenId of the NFT. |
function _burn(uint256 tokenId) internal
function tokenURI(uint256 tokenId) public view returns (string)
Query the tokenURI of an NFT.
Name | Type | Description |
---|---|---|
tokenId | uint256 | TokenId of an NFT to be queried. |
Name | Type | Description |
---|---|---|
[0] | string | string - API address of the NFT's metadata |
function updateLifeTokenIssuanceRate(uint256 tokenId, uint256 newLifeTokenIssuanceRate) external
function updatePropertyCustodian(address _newPropertyCustodian) external
Update the property custodian.
New address set here will be the new owner of all returned NFTs/properties. Will emit PropertyCustodianUpdated event.
Name | Type | Description |
---|---|---|
_newPropertyCustodian | address | Wallet address of the new property custodian. |
Marketplace contract for ManageLife. This contract the market trading of NFTs in the ML ecosystem. In real life, an NFT here represents a home or real-estate property run by ManageLife.
address mlAdmin
constructor() public
Deployer address will be considered as the ML admins
uint256 PERCENTS_DIVIDER
Percent divider to calculate ML's transaction earnings.
bool allowTrading
Trading status. This determines if normal users will be allowed to permitted to perform market trading (Bidding, Selling, Buy). By default Admin wallet will perform all these functions on behalf of all customers due to legal requirements. Once legal landscape permits, customers will be able to perform market trading by themselves.
contract ManageLife mLife
instance of the MLIFE NFT contract.
struct Offer {
uint32 tokenId;
address seller;
uint256 price;
address offeredTo;
}
struct Bid {
address bidder;
uint256 value;
}
uint256 adminPercent
Default admin fee.
uint256 adminPending
Status for adming pending claimable earnings.
mapping(uint256 => struct Marketplace.Offer) offers
Mapping of MLIFE tokenIds to Offers
mapping(uint256 => struct Marketplace.Bid) bids
Mapping of MLIFE tokenIds to Bids
event Offered(uint256 tokenId, uint256 price, address toAddress)
event BidEntered(uint32 tokenId, uint256 value, address fromAddress)
event BidCancelled(uint256 tokenId, uint256 value, address bidder)
event Bought(uint256 tokenId, uint256 value, address fromAddress, address toAddress, bool isInstant)
event BidWithdrawn(uint256 tokenId, uint256 value)
event Cancelled(uint256 tokenId)
event TradingStatus(bool _isTradingAllowed)
event Received(address, uint256)
error InvalidPercent(uint256 _percent, uint256 minimumPercent)
function pause() external
Security feature to Pause smart contracts transactions
function unpause() external
Unpausing the Paused transactions feature.
function setTrading(bool _isTradingAllowed) external
Update the allowTrading
status to true/false.
Can only be executed by contract owner. Will emit TradingStatus event.
Name | Type | Description |
---|---|---|
_isTradingAllowed | bool | New boolean status to set. |
function setNftContract(address nftAddress) external
Set the MLIFE contract.
Important to set this after deployment. Only MLIFE address is needed. Will not access 0x0 (zero/invalid) address.
Name | Type | Description |
---|---|---|
nftAddress | address | Address of MLIFE contract. |
function setAdminPercent(uint256 _percent) external
Allows admin wallet to set new percentage fee.
This throws an error is the new percentage is less than 500.
Name | Type | Description |
---|---|---|
_percent | uint256 | New admin percentage. |
function withdraw() external
Withdraw marketplace earnings.
Can only be triggered by the admin wallet or contract owner. This will transfer the market earning to the admin wallet.
function cancelForSale(uint32 tokenId) external
Cancel and existing sale offer.
Once triggered, the offer struct for this tokenId will be destroyed. Can only be called by MLIFE holders. The caller of this function should be the owner if the NFT in MLIFE contract.
Name | Type | Description |
---|---|---|
tokenId | uint32 | TokenId of the NFT. |
function offerForSale(uint32 tokenId, uint256 minSalePrice) external
Offer a property or NFT for sale in the marketplace.
If allowTrading
is equals to true,
users are allowed to execute this function. Else, admin wallet will facilitate
the offering sale on their behalf.
Name | Type | Description |
---|---|---|
tokenId | uint32 | MLIFE tokenId to be put on sale. |
minSalePrice | uint256 | Minimum sale price of the property. |
function offerForSaleToAddress(uint32 tokenId, uint256 minSalePrice, address toAddress) external
Offer a property for sale to a specific wallet address only.
Allows MLIFE holders to sell their property to a specific wallet address.
By default, this process is being performed by the admin wallet on behalf of the customers
not until the allowTrading
has been set to true
.
Name | Type | Description |
---|---|---|
tokenId | uint32 | TokenId of the property to be offered. |
minSalePrice | uint256 | Minimum sale prices of the property. |
toAddress | address | Wallet address on where the property will be offered to. |
function buy(uint32 tokenId) external payable
Allows users to buy a property that is registered in ML.
By default, this operation is disabled for customers.
Only admin wallet can perform this on their behalf until the
allowTrading
variable is equals to true.
Name | Type | Description |
---|---|---|
tokenId | uint32 | TokenId of the property. |
function placeBid(uint32 tokenId) external payable
Allows users to submit a bid to any properties.
By default, bidding is disabled for customers.
Only admin wallet can perform bidding on their behalf until the
allowTrading
variable is equals to true.
Name | Type | Description |
---|---|---|
tokenId | uint32 | tokenId of the property. |
function acceptBid(uint32 tokenId, uint256 minPrice) external
Allows home owners to accept bids on their properties
Name | Type | Description |
---|---|---|
tokenId | uint32 | tokenId of the property. |
minPrice | uint256 | Minimum bidding price. |
function withdrawBid(uint32 tokenId) external
Allows bidders to withdraw their bid on a specific property.
There will be different process flows on this function depending
on the value of allowTrading
. By default, the entire trading will be
facilitated by the admin wallet.
Name | Type | Description |
---|---|---|
tokenId | uint32 | tokenId of the property that is currently being bid. |
receive() external payable
This records the address and ether value that was sent to the Marketplace
function _safeTransferETH(address to, uint256 value) internal
Eth transfer hook
function setMLAdmin(address newAdminAddress) external
Allow admins to set new ML Admin wallet. Only contract owner/deployer can execute this function
Name | Type | Description |
---|---|---|
newAdminAddress | address | New wallet address to be used. |
modifier onlyMLifeOwner()
Modifier to make sure only MLIFE NFT holders can run a specific functions.
modifier isTradingAllowed()
Modifier to make sure only admin wallet can perform market tradings on behalf of all users.
allowTrading
should be set to true
in order for the users to facilitate the
market trading by themselves.