text: "use strict";
  
  const MasterChefAbi = require('./abi/masterchef.json');
  const PancakePlatformFork = require("../../common").PancakePlatformFork;
  
  module.exports = class cronaswap1 extends PancakePlatformFork {
    static MASTER_ADDRESS = "0x77ea4a4cF9F77A034E4291E8f457Af7772c2B254"
  
    constructor(cache, priceOracle, tokenCollector, liquidityTokenCollector, farmCollector, cacheManager) {
      super(cache, priceOracle, tokenCollector, liquidityTokenCollector);
  
      this.cache = cache;
      this.priceOracle = priceOracle;
      this.tokenCollector = tokenCollector;
      this.farmCollector = farmCollector;
      this.cacheManager = cacheManager;
      this.masterAbi = {};
    }
  
    async getFetchedFarms() {
      const cacheKey = `${this.getName()}-v3-master-farms`
  
      const cache = await this.cacheManager.get(cacheKey)
      if (cache) {
        return cache;
      }
  
      const foo = (await this.farmCollector.fetchForMasterChef(this.getMasterChefAddress(), this.getChain(), {
        abi: MasterChefAbi,
      }));
  
      const reformat = foo.map(f => {
        f.lpAddresses = f.lpAddress
  
        if (f.isTokenOnly === true) {
          f.tokenAddresses = f.lpAddress
        }
  
        return f
      })
  
      await this.cacheManager.set(cacheKey, reformat, {ttl: 60 * 30})
  
      return reformat;
    }
  
    getRawFarms() {
      return this.getFetchedFarms();
    }
  
    getRawPools() {
      return [];
    }
  
    getName() {
      return 'cronaswap';
    }
  
    getChain() {
      return 'cronos';
    }
  
    getFarmLink(farm) {
      return 'https://app.cronaswap.org';
    }
  
    getFarmEarns(farm) {
      return farm.id.startsWith(`${this.getName()}_farm_`)
        ? farm.raw.earns ? farm.raw.earns.map(i => i.symbol.toLowerCase()) : []
        : undefined;
    }
  
    getPendingRewardContractMethod() {
      return 'pendingCrona';
    }
  
    getSousAbi() {
      return [];
    }
  
    async getMasterChefAbi() {
      return MasterChefAbi;
    }
  
    getMasterChefAddress() {
      return cronaswap1.MASTER_ADDRESS;
    }
  
    async onFarmsBuild(farms) {
      farms.forEach(farm => {
        farm.main_platform = 'cronaswap';
        farm.platform = 'cronaswap';
        farm.provider = 'cronaswap';
      });
    }
  };
  