⚙️DoKENHubProxy Deployment

An Alternative way to make your project compatible to DoKEN Dividend Hub

Lets say you already have deployed token which implement like for example roger wu dividend interface or something else, and want to register into DoKEN Dividend Hub.

Technically, you have to implements those function mentioned on the Dividend Hub Installation page to make your token compatible with our Dividend Hub.

But changing your token smart contract code would be impossible, so what is your option ?

Fortunately, we can do some "little-trick" to make your contract compatible to our Dividend Hub, by creating new contract that will have a role as a proxy or middle man, which later helps our Dividend Hub to communicate with your smart contract.

Feel free to deploy the smart contract boiler plate below, and dont forget to changes to make it follow your real token project.

Once you get the deployed DoKENHubProxy address, use that address to register on our DividendHub Registration page, and turn on the "This is DoKENHub Proxy Address"

// SPDX-License-Identifier: MIT License

pragma solidity ^0.8.6;


/**
 * MainTokenInterface is an interface which represent functions on your
 * main token contract that is able to returns the value which is required by DoKENDividendHub
 **/
 
interface MainTokenInterface {
    // please adjust the function names below to follow with your real project function names,
    // this is just an example
    function mainTokenFunctionWhichReturnRewardAddress() external view returns(address);
    function mainTokenFunctionWhichReturnRewardOnPool() external view returns(uint256);
    function mainTokenFunctionWhichReturnTokenFees() external view returns(uint256,uint256,uint256,uint256,uint256,uint256);
    function mainTokenFunctionWhichReturnGetTotalDividendsDistributed() external view returns(uint256);
    function mainTokenFunctionWhichReturnGetAccount(address account) external view returns(address,
          int256,
          int256,
          uint256,
          uint256,
          uint256,
          uint256,
          uint256,
          uint256
          );
    function mainTokenFunctionWhichProcessAccount(address payable account, bool automatic) external;
    function mainTokenFunctionWhichGetNumberOfTokenHolders() external view returns(uint256);
}

contract DoKENHubProxy {
    
    address public realProjectAddress = 0xf9A2d40589271Be17612A3F57A9028A568f56e3d; // change it to your token / project address
    address public dividendTrackerAddress = someaddresshere;
    MainTokenInterface public realProject = MainTokenInterface(realProjectAddress);
    
    // this function is mandatory, 
    function DoKENGetMainAddress() external view returns(address){
        return realProjectAddress;
    }
    
    function DoKENDividendTrackerAddress() external view returns(address){
        return dividendTrackerAddress;
    }
    
    // You have to make a call to your main contract, which returns the value
    // that is required by DoKENDiviendHub Interface
    // pls adjust it to follow with your project contract
    
    function DoKENRewardAddress() external view returns (address) {
        return realProject.mainTokenFunctionWhichReturnRewardAddress(); // this is just an example
    }
    
    function DoKENRewardOnPool() external view returns (uint256) {
        return realProject.mainTokenFunctionWhichReturnRewardOnPool();
    }
    
    function DoKENTokenFees() external view 
    returns ( uint256,uint256,uint256,uint256,uint256,uint256)
      {
        return realProject.mainTokenFunctionWhichReturnTokenFees();
      }
    
    function DoKENRewardDistributed() external view returns (uint256) {
        return realProject.mainTokenFunctionWhichReturnGetTotalDividendsDistributed();
    }
    
    function DoKENGetAccountDividendsInfo(address account)
    public
    view
        returns (
          address,
          int256,
          int256,
          uint256,
          uint256,
          uint256,
          uint256,
          uint256,
          uint256
        )
      {
         return realProject.mainTokenFunctionWhichReturnGetAccount(account);
      }
      
   function DoKENRewardPaid(address holder) external view returns (uint256) {
       (, , , , uint256 paidAmount, , , , ) = DoKENGetAccountDividendsInfo(holder);
       return paidAmount;
   }
   
    
    function DoKENRewardUnPaid(address holder) external view returns (uint256) {
        (, , , uint256 unpaidAmount, , , , , ) = DoKENGetAccountDividendsInfo(
          holder
        );
       
        return unpaidAmount;
    }
    
    
    function DoKENNumberOfDividendTokenHolders() external view returns (uint256) {
        return realProject.mainTokenFunctionWhichGetNumberOfTokenHolders();
    }
    
    
}

Manual Claim can be worked if you have "claim" function without any parameters on your main contract if you are using DoKENHubProxy Implementation

Smart Contract above are boilerplate of DoKENHubProxy, if you like to see real example you can visit this url

Last updated