Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Srecko Smodis committed May 27, 2021
0 parents commit 12bcfd3
Show file tree
Hide file tree
Showing 48 changed files with 27,542 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GANACHE_MNEMONIC=
TESTNET_MNEMONIC=
INFURA_API_KEY=
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**/node_modules

#Hardhat files
/artifacts
/cache
/typechain
/deployments

build/
dist/
docs/

*.env
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
27 changes: 27 additions & 0 deletions contracts/EcoFiERC1155.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;
pragma abicoder v2;

import "protocol-contracts/tokens/contracts/erc-1155/ERC1155Base.sol";

contract EcoFiERC1155 is ERC1155Base {
event CreateEcoFiERC1155(address owner, string name, string symbol);

function __EcoFiERC1155_init(string memory _name, string memory _symbol, string memory baseURI, string memory contractURI) external initializer {
__Ownable_init_unchained();
__ERC1155Lazy_init_unchained();
__ERC165_init_unchained();
__Context_init_unchained();
__Mint1155Validator_init_unchained();
__ERC1155_init_unchained("");
__HasContractURI_init_unchained(contractURI);
__ERC1155Burnable_init_unchained();
__RoyaltiesV2Upgradeable_init_unchained();
__ERC1155Base_init_unchained(_name, _symbol);
_setBaseURI(baseURI);
_setDefaultApproval(_msgSender(), true);
emit CreateEcoFiERC1155(_msgSender(), _name, _symbol);
}
uint256[50] private __gap;
}
24 changes: 24 additions & 0 deletions contracts/EcoFiExchangeV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;
pragma abicoder v2;

import "protocol-contracts/exchange-v2/contracts/ExchangeV2Core.sol";
import "protocol-contracts/exchange-v2/contracts/RaribleTransferManager.sol";
import "@rarible/royalties/contracts/IRoyaltiesProvider.sol";

contract EcoFiExchangeV2 is ExchangeV2Core, RaribleTransferManager {
function __EcoExchangeV2_init(
INftTransferProxy _transferProxy,
IERC20TransferProxy _erc20TransferProxy,
uint newProtocolFee,
address newDefaultFeeReceiver,
IRoyaltiesProvider newRoyaltiesProvider
) external initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__TransferExecutor_init_unchained(_transferProxy, _erc20TransferProxy);
__RaribleTransferManager_init_unchained(newProtocolFee, newDefaultFeeReceiver, newRoyaltiesProvider);
__OrderValidator_init_unchained();
}
}
88 changes: 88 additions & 0 deletions contracts/EcoFiToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: AGPL-3.0-only
// EcoFi Token Contract
// Copyright (C) 2021
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
pragma solidity ^0.8.0;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20Burnable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

/**
* @title EcoFo Token (ECO)
* @notice Implementation of OpenZepplin's ERC20Burnable Token with custom burn and staking mechanism.
*/
contract EcoFiToken is ERC20Burnable {
address internal deployer;
address internal sproutContract = address(0);
constructor(
address _ecoMultisig
)
ERC20("EcoFi Token", "ECO")
{
deployer = msg.sender;
_mint(_ecoMultisig, 10*10**6*10**18);
}

/**
* @notice Overload OpenZepplin internal _transfer() function to add extra require statement preventing
* transferring tokens to the contract address
* @param _sender The senders address
* @param _recipient The recipients address
* @param _amount Amount of tokens to transfer (in wei units)
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* Additional requirements:
*
* - `_recipient` cannot be the token contract address.
*/
function _transfer(address _sender, address _recipient, uint256 _amount) internal override {
require(_recipient != address(this), "EcoFiToken: transfer to token contract address");
super._transfer(_sender, _recipient, _amount);
}

/**
* @notice Overload OpenZepplin public transfer() function to add extra require statement preventing
* transferring tokens to the sprout contract by calling transfer() (should only work with transferFrom)
* @param _recipient The recipients address
* @param _amount Amount of tokens to transfer (in wei units)
* @dev Moves tokens `amount` to `recipient` by calling `_transfer()`.
*
* Additional requirements:
*
* - `_recipient` cannot be the sprout contract address.
*/
function transfer(address _recipient, uint256 _amount) public virtual override returns (bool) {
require(_recipient != address(sproutContract), "EcoFiToken: transfer to sprout contract address (use transferFrom instead)");
return super.transfer(_recipient, _amount);
}

/**
* @notice Set Sprout address once it is deployed, so we can prevent users from mistakenly transferring
* ECO to the SPRT contract incorrectly (thus locking up their tokens)
* @param _sproutContract Sprout contract address
* @dev Sets `sproutContract` to supplied argument `_sproutContract` only one time.
*
* Additional requirements:
*
* - Can only be called by `deployer` .
*/

function setSproutAddress(address _sproutContract) public {
require(sproutContract == address(0), "may only be called once");
require(msg.sender == deployer, "must be called by deployer");
sproutContract = _sproutContract;
}

}
Loading

0 comments on commit 12bcfd3

Please sign in to comment.