KLAYswap
English
English
  • Introduction
  • Protocol Overview
  • Core Concept
  • KLAYswap Advantages
  • Risk & Security
  • Privacy Policy
  • Audit
  • TOKENOMICS
    • KSP
      • KSP TOKENOMICS
      • Automation of KSP distribution rate
        • Voting policy on passing governance
        • KSP distribution ratio reflection policy
      • KSP Allocation
  • PRODUCT
    • SWAP
    • Single-side Deposit
      • Detailed policy of Single Deposit
    • Pair Deposit
    • V3 Pair Deposit
      • V2 to V3 Migration
        • V2 to V3 Migration Guide
        • V2 to V3 Migration Policy
      • V3 Pair Deposit
        • V3 Deposit Guide
        • V3 pair Deposit Policy
      • V3 to V3 Migration
        • V3 to V3 Migration Guide
        • V3 to V3 Migration Policy
      • V3 Pair Withdraw
        • V3 Withdraw Guide
        • V3 Withdraw Policy
    • Plus Deposit
      • Detailed policy of Plus Deposit
    • Long/Short Position Deposit
      • Open and Close Long/Short Positions
        • Open Short Positions
        • Open Long Positions
        • Remove Long Position
        • Remove Short Position
      • Position Deposit Details Policy
    • KSP Staking & Voting
      • Staking, Pool Voting Policy
    • Governance
      • Governance Voting Policy
    • Drops
    • Ecopot
    • Pool Airdrop
    • APR & APY
      • TVL
      • Pool
      • Staking
    • Interest rate
  • DEVELOPERS
    • Contract
      • Factory
      • Exchange
      • PoolVoting
      • VotingKSP
      • Treasury
      • Distribution
      • Governor
      • SinglePool
      • SinglePool Factory
      • PlusPool
      • PlusPool Factory
      • Store
      • Utils
      • Single/Plus Utils
      • Helper
      • EcoPotVoting
      • EcoPot
      • V3
        • V3Factory
        • V3Pool
        • NonfungiblePositionManager
        • NonfungibleTokenPositionDescriptor
        • V3SwapRouter
        • V3Migrator
        • V3Estimator
        • PositionMigrator
        • V3Treasury
        • V3AirdropOperator
        • UniversalRouter
    • Airdrop
      • Set Airdrop Operator
      • Start Airdrop
    • EcoPot
      • Set EcoPot
      • Start EcoPot
  • HOW-TO GUIDES
    • KLAYswap Guide
    • How to add liquidity on KLAYswap
    • [Burrito Wallet] How to deposit assets using mobile devices?
    • How to create a liquidity pool on KLAYswap
    • How to stake and vote on KLAYswap
    • How to deposit assets
      • Deposit Klaytn-based assets
      • Deposit Ethereum-based assets
      • Deposit XRP
    • FAQ
  • KLAYswap
  • Orbit Bridge
  • KLAYswap git
  • Orbit Bridge git
  • KLAYswap audit report
Powered by GitBook
On this page
  • 1. Contract Deploy
  • 2. Contract Submission
  • 3. ValidOperator Request

Was this helpful?

  1. DEVELOPERS
  2. EcoPot

Set EcoPot

PreviousEcoPotNextStart EcoPot

Last updated 3 years ago

Was this helpful?

1. Contract Deploy

  • 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 Klaytn's Smart contract deployment .

pragma solidity 0.5.6;

interface IKIP7 {
    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 EcoPotLike {
    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 payable;
    function depositKlay() external payable;
    function depositToken(uint) external;
    function refixAmountPerBlock(uint) external;
}

interface EcoPotVotingLike {
    function ecoPotExist(address) external view returns (bool);
}

contract EcoPotOperator {
    address constant public ecoPotVoting = 0x2ce59e21364DcA92c90970AD15442146D638997f;
    address constant public ksp = 0xC6a2Ad8cC6e4A7E08FC37cC5954be07d499E7654;

    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;
        if(token != address(0)) require(IKIP7(token).decimals() != 0);
        name = _name;
    }

    function version() external pure returns (string memory) {
        return "EcoPotOperator20220221A";
    }

    // valid fallback
    function () payable external { }

    // ======================= 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;
        if(tokenAddr == address(0)){
            balance = (address(this)).balance;
            if(balance > 0){
                (bool res, ) = owner.call.value(balance)("");
                require(res);
            }
        }
        else{
            balance = IKIP7(tokenAddr).balanceOf(address(this));
            if(balance > 0){
                require(IKIP7(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;

        EcoPotLike pot = EcoPotLike(ecoPot);

        totalAmount = pot.totalAmount();
        blockAmount = pot.amountPerBlock();
        distributableBlock = pot.distributableBlock();
        endBlock = pot.estimateEndBlock();
        distributed = pot.getDistributedCurrent();
        if(token == address(0)){
            remain = (ecoPot).balance;
        }
        else{
            remain = IKIP7(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;

        EcoPotLike pot = EcoPotLike(ecoPot);

        totalAmount = pot.totalAmount();
        blockAmount = pot.amountPerBlock();
        distributableBlock = pot.distributableBlock();
        endBlock = pot.estimateEndBlock();
        distributed = pot.getDistributedCurrent();
        if(token == address(0)){
            remain = (ecoPot).balance;
        }
        else{
            remain = IKIP7(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 payable onlyOwner {
        require(totalAmount != 0);
        require(blockAmount != 0);
        require(startBlock >= block.number);

        EcoPotLike pot = EcoPotLike(ecoPot);
        require(pot.operator() == address(this));
        require(!pot.isInitialized());

        if(token == address(0)){
            require((address(this)).balance >= totalAmount);
            pot.initialize.value(totalAmount)(totalAmount, blockAmount, startBlock);
        }
        else {
            require(IKIP7(token).transferFrom(owner, address(this), totalAmount));
            require(IKIP7(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 {
        EcoPotLike pot = EcoPotLike(ecoPot);

        require(pot.operator() == address(this));
        require(pot.isAvailable());
        require(amount != 0);

        if(token == address(0)){
            require((address(this)).balance >= amount);
            pot.depositKlay.value(amount)();
        }
        else{
            require(IKIP7(token).balanceOf(address(this)) >= amount);
            require(IKIP7(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 {
        EcoPotLike pot = EcoPotLike(ecoPot);

        require(pot.operator() == address(this));
        require(pot.isAvailable());
        require(blockAmount != 0);

        pot.refixAmountPerBlock(blockAmount);
    }
}

2. Contract Submission

3. ValidOperator Request

  • Operator registration request (support@klayswap.com)

  • Set Valid Operator after confirming the contract distributed with Public EcoPotOperator Code

here
Klaytnscope Contract Submission