Meshswap
Search
K

Set EcoPot

1. Contract Deploy

Deploy Guide
EcoPot Operator Smart Contract Code
  • The token and project name for EcoPot are set at the time of creation and cannot be modified.
  • Please check whether the contract is deployed in the public environment
  • Please pay attention to the security of the Owner account.
  • Please refer to Polygon's Smart contract deployment here
pragma solidity 0.5.6;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function decimals() external view returns (uint8);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
interface IEcoPot {
function totalAmount() external view returns (uint);
function amountPerBlock() external view returns (uint);
function distributableBlock() external view returns (uint);
function estimateEndBlock() external view returns (uint);
function operator() external view returns (address);
function getDistributedCurrent() external view returns (uint);
function isInitialized() external view returns (bool);
function isAvailable() external view returns (bool);
function initialize(uint, uint, uint) external;
function depositToken(uint) external;
function refixAmountPerBlock(uint) external;
}
interface IEcoPotVoting {
function ecoPotExist(address) external view returns (bool);
}
contract EcoPotOperator {
// mumbai : 0xeFaFFdd6Cd27C4B4985e60fb270A9733aFeA91Ea
address constant public ecoPotVoting = 0x13c5C5a5D418B5365Fb30CA1Ec8A9FB2A6f622D1;
// mumbai : 0x6a5d8703e612CFe33388Cf0C92d409934Fad98Cb
address constant public mesh = 0x82362Ec182Db3Cf7829014Bc61E9BE8a2E82868a;
address public owner;
address public nextOwner;
address public ecoPot;
address public token;
string public name;
constructor(address _token, string memory _name) public {
owner = msg.sender;
token = _token;
require(IERC20(token).decimals() != 0);
name = _name;
}
function version() external pure returns (string memory) {
return "EcoPotOperator20220502";
}
function () payable external { revert(); }
// ======================= owner method ===========================
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function changeNextOwner(address _nextOwner) public onlyOwner {
nextOwner = _nextOwner;
}
function changeOwner() public {
require(msg.sender == nextOwner);
owner = nextOwner;
nextOwner = address(0);
}
//withdraw tokens remaining in the operator contract
function withdraw(address tokenAddr) public onlyOwner {
uint balance = 0;
balance = IERC20(tokenAddr).balanceOf(address(this));
if (balance > 0) {
require(IERC20(tokenAddr).transfer(owner, balance));
}
}
modifier onlyEcoPotVoting {
require(msg.sender == ecoPotVoting);
_;
}
function setEcoPot(address _ecoPot) public onlyEcoPotVoting {
require(ecoPot == address(0));
ecoPot = _ecoPot;
}
// ====================== Stat ====================================
function getEcoPotStat() public view returns (
address ecoPotContract, // airdrop distribution contract address
uint totalAmount, // Total amount of tokens to be distributed
uint blockAmount, // Amount of tokens to be distributed per block
uint distributableBlock, // Block number to airdrop start
uint endBlock, // Block number to airdrop end
uint distributed, // Amount of tokens distributed
uint remain // amount remaining in the contract
) {
ecoPotContract = ecoPot;
IEcoPot pot = IEcoPot(ecoPot);
totalAmount = pot.totalAmount();
blockAmount = pot.amountPerBlock();
distributableBlock = pot.distributableBlock();
endBlock = pot.estimateEndBlock();
distributed = pot.getDistributedCurrent();
remain = IERC20(token).balanceOf(ecoPot);
}
// For Drops AirdropPool
function getAirdropStat() public view returns (
address ecoPotContract, // airdrop distribution contract address
uint totalAmount, // Total amount of tokens to be distributed
uint blockAmount, // Amount of tokens to be distributed per block
uint distributableBlock, // Block number to airdrop start
uint endBlock, // Block number to airdrop end
uint distributed, // Amount of tokens distributed
uint remain, // amount remaining in the contract
uint emptyUint, // return for airdropPool
address[] memory emptyAddressArr, // return for airdropPool
uint[] memory emptyUintArr // return for airdropPool
) {
ecoPotContract = ecoPot;
IEcoPot pot = IEcoPot(ecoPot);
totalAmount = pot.totalAmount();
blockAmount = pot.amountPerBlock();
distributableBlock = pot.distributableBlock();
endBlock = pot.estimateEndBlock();
distributed = pot.getDistributedCurrent();
remain = IERC20(token).balanceOf(ecoPot);
emptyUint = 0;
emptyAddressArr = new address[](0);
emptyUintArr = new uint[](0);
}
// ===================== Airdrop method ===========================
///@param totalAmount : Total amount of tokens to be distributed
///@param blockAmount : Amount of tokens to be distributed per block
///@param startBlock : Block number to airdrop start
function initialize(uint totalAmount, uint blockAmount, uint startBlock) public onlyOwner {
require(totalAmount != 0);
require(blockAmount != 0);
require(startBlock >= block.number);
IEcoPot pot = IEcoPot(ecoPot);
require(pot.operator() == address(this));
require(!pot.isInitialized());
require(IERC20(token).transferFrom(owner, address(this), totalAmount));
require(IERC20(token).approve(ecoPot, totalAmount));
pot.initialize(totalAmount, blockAmount, startBlock);
}
// Airdrop token deposit
///@param amount : Amount of airdrop token to deposit
function deposit(uint amount) public onlyOwner {
IEcoPot pot = IEcoPot(ecoPot);
require(pot.operator() == address(this));
require(pot.isAvailable());
require(amount != 0);
require(IERC20(token).balanceOf(address(this)) >= amount);
require(IERC20(token).approve(ecoPot, amount));
pot.depositToken(amount);
}
// Airdrop amount per block modification function
// The function is applied immediately from the called block
///@param blockAmount : airdrop block amount to change
function refixBlockAmount(uint blockAmount) public onlyOwner {
IEcoPot pot = IEcoPot(ecoPot);
require(pot.operator() == address(this));
require(pot.isAvailable());
require(blockAmount != 0);
pot.refixAmountPerBlock(blockAmount);
}
}

2. Contract Submission

3. ValidOperator Request

  • Operator registration request ([email protected])
  • Set Valid Operator after confirming the contract distributed with Public EcoPotOperator Code