Skip to content

Commit

Permalink
first try removing owners_map
Browse files Browse the repository at this point in the history
owners_parent remains for now, but should be sed'd away to just "owners"
next
  • Loading branch information
nicolasochem committed Jul 25, 2024
1 parent ddc3a7d commit b337acb
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 45 deletions.
18 changes: 2 additions & 16 deletions src/calc/calculate_phase4.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CalculatePhase4(CalculatePhaseBase):
Sum of owner ratios equals to ratio of owners_parent record.
"""

def __init__(self, founders_map, owners_map, reward_api=None) -> None:
def __init__(self, founders_map, reward_api=None) -> None:
super().__init__()

self.founders_map = founders_map
Expand Down Expand Up @@ -51,21 +51,7 @@ def calculate(self, reward_data3, total_amount):
new_rewards.append(rl3)

elif rl3.type == TYPE_OWNERS_PARENT:
for addr, ratio in self.owners_map.items():
rl4 = RewardLog(addr, TYPE_OWNER, ratio * rl3.delegating_balance, 0)
# new ratio is parent ratio * ratio of the owner
rl4.ratio = ratio * rl3.ratio
rl4.ratio4 = rl4.ratio
rl4.service_fee_ratio = 0
rl4.service_fee_rate = 0
rl4.parent = rl3
if self.reward_api is not None:
self.reward_api.update_current_balances([rl4])
new_rewards.append(rl4)

# if no owners, add parent object to rewards list
if not self.owners_map.items():
new_rewards.append(rl3)
new_rewards.append(rl3)
else:
rl3.ratio4 = rl3.ratio
new_rewards.append(rl3)
Expand Down
8 changes: 3 additions & 5 deletions src/calc/phased_payment_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ class PhasedPaymentCalculator:
def __init__(
self,
founders_map,
owners_map,
service_fee_calculator,
min_delegation_amount,
min_payment_amount,
rules_model,
reward_api,
):
self.rules_model = rules_model
self.owners_map = owners_map
self.founders_map = founders_map
self.fee_calc = service_fee_calculator
self.min_delegation_amnt = min_delegation_amount
Expand All @@ -50,9 +48,9 @@ def __init__(
#
# calculation details
#
# total reward = delegators reward + owners reward = delegators payment + delegators fee + owners payment
# total reward = delegators reward + owner reward = delegators payment + delegators fee + owner payment
# delegators reward = delegators payment + delegators fee
# owners reward = owners payment = total reward - delegators reward
# owner reward = owner payment = total reward - delegators reward
# founders reward = delegators fee = total reward - delegators reward
####
def calculate(self, reward_provider_model, adjustments=None, rerun=False):
Expand Down Expand Up @@ -138,7 +136,7 @@ def calculate(self, reward_provider_model, adjustments=None, rerun=False):
# *************
# ** phase 4 **
# *************
phase4 = CalculatePhase4(self.founders_map, self.owners_map, self.reward_api)
phase4 = CalculatePhase4(self.founders_map, self.reward_api)
rwrd_logs, total_rwrd_amnt = phase4.calculate(rwrd_logs, total_rwrd_amnt)

# *****************
Expand Down
3 changes: 0 additions & 3 deletions src/config/yaml_baking_conf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from log_config import main_logger
from model.baking_conf import (
FOUNDERS_MAP,
OWNERS_MAP,
BAKING_ADDRESS,
SUPPORTERS_SET,
SERVICE_FEE,
Expand Down Expand Up @@ -75,7 +74,6 @@ def validate(self):
self.validate_baking_address(conf_obj)
self.validate_payment_address(conf_obj)
self.validate_share_map(conf_obj, FOUNDERS_MAP)
self.validate_share_map(conf_obj, OWNERS_MAP)
self.validate_service_fee(conf_obj)
self.validate_min_delegation_amt(conf_obj)
self.validate_min_payment_amt(conf_obj)
Expand All @@ -97,7 +95,6 @@ def process(self):
conf_obj[FULL_SUPPORTERS_SET] = set(
conf_obj[SUPPORTERS_SET]
| set(conf_obj[FOUNDERS_MAP].keys())
| set(conf_obj[OWNERS_MAP].keys())
)

conf_obj[EXCLUDED_DELEGATORS_SET_TOE] = set(
Expand Down
19 changes: 1 addition & 18 deletions src/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
PAYMENT_ADDRESS,
SERVICE_FEE,
FOUNDERS_MAP,
OWNERS_MAP,
MIN_DELEGATION_AMT,
MIN_PAYMENT_AMT,
RULES_MAP,
Expand Down Expand Up @@ -63,7 +62,6 @@
"servicefee": "Specify bakery fee, valid range is between 0 and 100",
"rewardstype": "Specify if baker pays 'ideal' or 'actual' rewards (Be sure to read the documentation to understand the difference). Press enter for 'actual'",
"foundersmap": "Specify FOUNDERS in form 'tz-address':share1,'tz-address':share2,... (Mind quotes, sum must equal 1, e.g: 'tz1a...':0.3, 'tz1b..':0.7) Press enter to leave empty",
"ownersmap": "Specify OWNERS in form 'tz-address':share1,'tz-address':share2,... (Mind quotes, sum must equal 1, e.g: 'tz1a...':0.3, 'tz1b..':0.7) Press enter to leave empty",
"mindelegation": "Specify minimum delegation amount in tez. Press enter for 0",
"mindelegationtarget": "Specify where the reward for delegators failing to satisfy minimum delegation amount go. {}: leave at balance, {}: to founders, {}: to everybody, press enter for {}".format(
TOB, TOF, TOE, TOB
Expand Down Expand Up @@ -172,19 +170,6 @@ def onfoundersmap(input):
fsm.go()


def onownersmap(input):
try:
global parser
dict = ast.literal_eval("{" + input + "}")
parser.set(OWNERS_MAP, dict)
parser.validate_share_map(parser.get_conf_obj(), OWNERS_MAP)
except Exception:
printe("Invalid owners input: " + traceback.format_exc())
return

fsm.go()


def onmindelegation(input):
try:
if not input:
Expand Down Expand Up @@ -371,7 +356,6 @@ def onprefinal(input):
"servicefee": onservicefee,
"rewardstype": onrewardstype,
"foundersmap": onfoundersmap,
"ownersmap": onownersmap,
"mindelegation": onmindelegation,
"mindelegationtarget": onmindelegationtarget,
"minpayment": onminpayment,
Expand All @@ -396,8 +380,7 @@ def onprefinal(input):
{"name": "go", "src": "paymentaddress", "dst": "servicefee"},
{"name": "go", "src": "servicefee", "dst": "rewardstype"},
{"name": "go", "src": "rewardstype", "dst": "foundersmap"},
{"name": "go", "src": "foundersmap", "dst": "ownersmap"},
{"name": "go", "src": "ownersmap", "dst": "mindelegation"},
{"name": "go", "src": "foundersmap", "dst": "mindelegation"},
{"name": "go", "src": "mindelegation", "dst": "mindelegationtarget"},
{"name": "go", "src": "mindelegationtarget", "dst": "minpayment"},
{"name": "go", "src": "minpayment", "dst": "exclude"},
Expand Down
2 changes: 0 additions & 2 deletions src/pay/payment_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def __init__(
baking_cfg.get_dest_map(),
)
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.min_delegation_amt_in_mutez = int(
baking_cfg.get_min_delegation_amount() * MUTEZ_PER_TEZ
Expand Down Expand Up @@ -126,7 +125,6 @@ def __init__(

self.payment_calc = PhasedPaymentCalculator(
self.founders_map,
self.owners_map,
self.fee_calc,
self.min_delegation_amt_in_mutez,
self.min_payment_amt_in_mutez,
Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def test_process_payouts(self):
)
payment_calc = PhasedPaymentCalculator(
founders_map=baking_cfg.get_founders_map(),
owners_map=baking_cfg.get_owners_map(),
service_fee_calculator=srvc_fee_calc,
min_delegation_amount=int(
baking_cfg.get_min_delegation_amount() * MUTEZ_PER_TEZ
Expand Down

0 comments on commit b337acb

Please sign in to comment.