def make_payment_calculations(self, payment_cycle, reward_data):

        if reward_data["delegators_nb"] == 0:
            logger.warn(
                "No delegators at cycle {}. Check your delegation status".
                format(payment_cycle))
            return [], 0

        rc = RoundingCommand(self.prcnt_scale)
        reward_calc = TzScanRewardCalculatorApi(self.founders_map, reward_data,
                                                self.min_delegation_amt,
                                                self.excluded_delegators_set,
                                                rc)

        rewards, total_rewards = reward_calc.calculate()

        logger.info("Total rewards={}".format(total_rewards))

        if total_rewards == 0: return [], 0
        fm, om = self.founders_map, self.owners_map
        rouding_command = RoundingCommand(self.pymnt_scale)
        pymnt_calc = PaymentCalculator(fm, om, rewards, total_rewards,
                                       self.fee_calc, payment_cycle,
                                       rouding_command)
        payment_logs = pymnt_calc.calculate()

        return payment_logs, total_rewards
Exemplo n.º 2
0
 def __init__(self,
              founders_map,
              min_delegation_amt,
              excluded_set,
              rc=RoundingCommand(None)):
     super(RpcRewardCalculatorApi, self).__init__(founders_map,
                                                  excluded_set)
     self.min_delegation_amt_mutez = min_delegation_amt * MUTEZ
     self.logger = main_logger
     self.rc = rc
    def __init__(self,
                 name,
                 initial_payment_cycle,
                 network_config,
                 payments_dir,
                 calculations_dir,
                 run_mode,
                 service_fee_calc,
                 release_override,
                 payment_offset,
                 baking_cfg,
                 payments_queue,
                 life_cycle,
                 dry_run,
                 wllt_clnt_mngr,
                 node_url,
                 provider,
                 verbose=False):
        super(PaymentProducer, self).__init__()
        self.baking_address = baking_cfg.get_baking_address()
        self.owners_map = baking_cfg.get_owners_map()
        self.founders_map = baking_cfg.get_founders_map()
        self.excluded_delegators_set = baking_cfg.get_excluded_delegators_set()
        self.min_delegation_amt = baking_cfg.get_min_delegation_amount()
        self.pymnt_scale = baking_cfg.get_payment_scale()
        self.prcnt_scale = baking_cfg.get_percentage_scale()

        self.name = name

        rc = RoundingCommand(self.prcnt_scale)

        provider_factory = ProviderFactory(provider)
        self.reward_api = provider_factory.newRewardApi(
            network_config, self.baking_address, wllt_clnt_mngr, node_url)
        self.block_api = provider_factory.newBlockApi(network_config,
                                                      wllt_clnt_mngr, node_url)
        self.reward_calculator_api = provider_factory.newCalcApi(
            self.founders_map, self.min_delegation_amt,
            self.excluded_delegators_set, rc)

        self.fee_calc = service_fee_calc
        self.initial_payment_cycle = initial_payment_cycle
        self.nw_config = network_config
        self.payments_root = payments_dir
        self.calculations_dir = calculations_dir
        self.run_mode = run_mode
        self.exiting = False

        self.release_override = release_override
        self.payment_offset = payment_offset
        self.verbose = verbose
        self.payments_queue = payments_queue
        self.life_cycle = life_cycle
        self.dry_run = dry_run
        logger.debug('Producer started')
    def make_payment_calculations(self, payment_cycle, reward_data):

        if reward_data["delegators_nb"] == 0:
            logger.warn(
                "No delegators at cycle {}. Check your delegation status".
                format(payment_cycle))
            return [], 0

        rewards, total_rewards = self.reward_calculator_api.calculate(
            reward_data)

        logger.info("Total rewards={}".format(total_rewards))

        if total_rewards == 0: return [], 0
        fm, om = self.founders_map, self.owners_map
        rouding_command = RoundingCommand(self.pymnt_scale)
        pymnt_calc = PaymentCalculator(fm, om, rewards, total_rewards,
                                       self.fee_calc, payment_cycle,
                                       rouding_command)
        payment_logs = pymnt_calc.calculate()

        return payment_logs, total_rewards