text: "use strict";
  
  const MasterChefAbi = require('./abi/masterchef.json');
  const PancakePlatformFork = require("../../common").PancakePlatformFork;
  const _ = require("lodash");
  
  module.exports = class fjetswap extends PancakePlatformFork {
    static MASTER_ADDRESS = "0x9180583C1ab03587b545629dd60D2be0bf1DF4f2"
  
    constructor(cache, priceOracle, tokenCollector, farmCollector, cacheManager) {
      super(cache, priceOracle);
  
      this.cache = cache;
      this.priceOracle = priceOracle;
      this.tokenCollector = tokenCollector;
      this.farmCollector = farmCollector;
      this.cacheManager = cacheManager;
      this.masterAbi = {};
    }
  
    async getFetchedFarms() {
      const cacheKey = `${this.getName()}-v1-master-farms`
  
      const cache = await this.cacheManager.get(cacheKey)
      if (cache) {
        return cache;
      }
  
      const foo = (await this.farmCollector.fetchForMasterChef(this.getMasterChefAddress(), this.getChain())).filter(f => f.isFinished !== true);
  
      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();
    }
  
    async getRawPools() {
      return [];
    }
  
    getName() {
      return 'fjetswap';
    }
  
    getChain() {
      return 'fantom';
    }
  
    getFarmLink(farm) {
      return (farm.isTokenOnly === true || farm.id.includes('_sous_'))
        ? 'https://fantom.jetswap.finance/pools'
        : 'https://fantom.jetswap.finance/farms';
    }
  
    getFarmEarns(farm) {
      return farm.id.startsWith(`${this.getName()}_farm_`)
        ? farm.raw.earns ? farm.raw.earns.map(i => i.symbol.toLowerCase()) : []
        : undefined;
    }
  
    getPendingRewardContractMethod() {
      return 'pendingCake';
    }
  
    getSousAbi() {
      return [];
    }
  
    async getMasterChefAbi() {
      return MasterChefAbi;
    }
  
    getMasterChefAddress() {
      return fjetswap.MASTER_ADDRESS;
    }
  
    async onFarmsBuild(farms) {
      farms.forEach(farm => {
        if (farm.id.includes('_farm_')) {
          farm.main_platform = 'jetswap';
          farm.platform = 'jetswap';
        }
      });
    }
  };
  