Skip to content

Commit 012ba19

Browse files
committed
Update operator rewards calc
Signed-off-by: cyc60 <[email protected]>
1 parent 8fed0dc commit 012ba19

File tree

4 files changed

+18
-88
lines changed

4 files changed

+18
-88
lines changed

oracle/networks.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"0x144a98cb1CdBb23610501fE6108858D9B7D24934"
5454
),
5555
ORACLE_PRIVATE_KEY=config("ORACLE_PRIVATE_KEY", default=""),
56-
ORACLE_STAKEWISE_OPERATOR=Web3.toChecksumAddress(
56+
OPERATOR_ADDRESS=Web3.toChecksumAddress(
5757
"0x5fc60576b92c5ce5c341c43e3b2866eb9e0cddd1"
5858
),
5959
WITHDRAWALS_GENESIS_EPOCH=194048,
@@ -75,11 +75,6 @@
7575
SYNC_PERIOD=timedelta(days=1),
7676
IS_POA=False,
7777
DEPOSIT_TOKEN_SYMBOL="ETH",
78-
VALIDATORS_SPLIT={
79-
Web3.toChecksumAddress("0xfe26832d3580e0ade4813f9e60e7c17b45e92cba"): 64,
80-
Web3.toChecksumAddress("0x59ecf48345a221e0731e785ed79ed40d0a94e2a5"): 63,
81-
Web3.toChecksumAddress("0x01f26d7f195a37d368cb772ed75ef70dd29700f5"): 64,
82-
},
8378
),
8479
HARBOUR_MAINNET: dict(
8580
STAKEWISE_SUBGRAPH_URLS=config(
@@ -117,7 +112,7 @@
117112
"0x6C7692dB59FDC7A659208EEE57C2c876aE54a448"
118113
),
119114
ORACLE_PRIVATE_KEY=config("ORACLE_PRIVATE_KEY", default=""),
120-
ORACLE_STAKEWISE_OPERATOR=EMPTY_ADDR_HEX,
115+
OPERATOR_ADDRESS=EMPTY_ADDR_HEX,
121116
WITHDRAWALS_GENESIS_EPOCH=194048,
122117
AWS_BUCKET_NAME=config(
123118
"AWS_BUCKET_NAME",
@@ -140,7 +135,6 @@
140135
SYNC_PERIOD=timedelta(days=1),
141136
IS_POA=False,
142137
DEPOSIT_TOKEN_SYMBOL="ETH",
143-
VALIDATORS_SPLIT={},
144138
),
145139
GOERLI: dict(
146140
STAKEWISE_SUBGRAPH_URLS=config(
@@ -178,7 +172,7 @@
178172
"0x1867c96601bc5fE24F685d112314B8F3Fe228D5A"
179173
),
180174
ORACLE_PRIVATE_KEY=config("ORACLE_PRIVATE_KEY", default=""),
181-
ORACLE_STAKEWISE_OPERATOR=EMPTY_ADDR_HEX,
175+
OPERATOR_ADDRESS=EMPTY_ADDR_HEX,
182176
WITHDRAWALS_GENESIS_EPOCH=162304,
183177
AWS_BUCKET_NAME=config("AWS_BUCKET_NAME", default="oracle-votes-goerli"),
184178
AWS_REGION=config("AWS_REGION", default="eu-central-1"),
@@ -198,7 +192,6 @@
198192
SYNC_PERIOD=timedelta(hours=1),
199193
IS_POA=True,
200194
DEPOSIT_TOKEN_SYMBOL="ETH",
201-
VALIDATORS_SPLIT={},
202195
),
203196
HARBOUR_GOERLI: dict(
204197
STAKEWISE_SUBGRAPH_URLS=config(
@@ -236,7 +229,7 @@
236229
"0x66D6c253084d8d51c7CFfDb3C188A0b53D998a3d"
237230
),
238231
ORACLE_PRIVATE_KEY=config("ORACLE_PRIVATE_KEY", default=""),
239-
ORACLE_STAKEWISE_OPERATOR=EMPTY_ADDR_HEX,
232+
OPERATOR_ADDRESS=EMPTY_ADDR_HEX,
240233
WITHDRAWALS_GENESIS_EPOCH=162304,
241234
AWS_BUCKET_NAME=config(
242235
"AWS_BUCKET_NAME",
@@ -259,7 +252,6 @@
259252
SYNC_PERIOD=timedelta(days=1),
260253
IS_POA=True,
261254
DEPOSIT_TOKEN_SYMBOL="ETH",
262-
VALIDATORS_SPLIT={},
263255
),
264256
GNOSIS_CHAIN: dict(
265257
STAKEWISE_SUBGRAPH_URLS=config(
@@ -297,7 +289,7 @@
297289
"0x8737f638E9af54e89ed9E1234dbC68B115CD169e"
298290
),
299291
ORACLE_PRIVATE_KEY=config("ORACLE_PRIVATE_KEY", default=""),
300-
ORACLE_STAKEWISE_OPERATOR=EMPTY_ADDR_HEX,
292+
OPERATOR_ADDRESS=EMPTY_ADDR_HEX,
301293
WITHDRAWALS_GENESIS_EPOCH=648704,
302294
AWS_BUCKET_NAME=config("AWS_BUCKET_NAME", default="oracle-votes-gnosis"),
303295
AWS_REGION=config("AWS_REGION", default="eu-north-1"),
@@ -317,9 +309,5 @@
317309
SYNC_PERIOD=timedelta(days=1),
318310
IS_POA=True,
319311
DEPOSIT_TOKEN_SYMBOL="GNO",
320-
VALIDATORS_SPLIT={
321-
Web3.toChecksumAddress("0x59ecf48345a221e0731e785ed79ed40d0a94e2a5"): 4971,
322-
Web3.toChecksumAddress("0xf37c8f35fc820354b402054699610c098559ae44"): 4971,
323-
},
324312
),
325313
}

oracle/oracle/common/graphql_queries.py

-13
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,6 @@
342342
"""
343343
)
344344

345-
OPERATORS_REWARDS_QUERY = gql(
346-
"""
347-
query getOperatorsRewards($block_number: Int) {
348-
operators(block: { number: $block_number }) {
349-
id
350-
validatorsCount
351-
revenueShare
352-
distributorPoints
353-
updatedAtBlock
354-
}
355-
}
356-
"""
357-
)
358345

359346
PARTNERS_QUERY = gql(
360347
"""

oracle/oracle/distributor/common/eth1.py

+12-54
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
DISABLED_STAKER_ACCOUNTS_QUERY,
1515
DISTRIBUTOR_CLAIMED_ACCOUNTS_QUERY,
1616
ONE_TIME_DISTRIBUTIONS_QUERY,
17-
OPERATORS_REWARDS_QUERY,
1817
PARTNERS_QUERY,
1918
PERIODIC_DISTRIBUTIONS_QUERY,
2019
)
@@ -162,69 +161,28 @@ async def get_distributor_claimed_accounts(
162161

163162

164163
async def get_operators_rewards(
165-
network: str,
166-
from_block: BlockNumber,
167-
to_block: BlockNumber,
168164
total_reward: Wei,
165+
operator_address: ChecksumAddress,
169166
reward_token_address: ChecksumAddress,
170-
validators_split: dict,
171167
) -> Tuple[Rewards, Wei]:
172-
"""Fetches operators rewards."""
173-
result: Dict = await execute_sw_gql_query(
174-
network=network,
175-
query=OPERATORS_REWARDS_QUERY,
176-
variables=dict(
177-
block_number=to_block,
178-
),
179-
)
180-
operators = result["operators"]
181-
182-
# process operators
183-
points: Dict[ChecksumAddress, int] = {}
184-
total_points = 0
185-
total_validators = 0
186-
for operator in operators:
187-
account = Web3.toChecksumAddress(operator["id"])
188-
if account == EMPTY_ADDR_HEX:
189-
continue
190-
191-
validators_count = int(operator["validatorsCount"]) + validators_split.get(
192-
account, 0
193-
)
194-
total_validators += validators_count
195-
196-
revenue_share = int(operator["revenueShare"])
197-
prev_account_points = int(operator["distributorPoints"])
198-
updated_at_block = BlockNumber(int(operator["updatedAtBlock"]))
199-
if from_block > updated_at_block:
200-
updated_at_block = from_block
201-
prev_account_points = 0
202-
203-
account_points = prev_account_points + (
204-
validators_count * revenue_share * (to_block - updated_at_block)
205-
)
206-
if account_points <= 0:
207-
continue
208-
209-
points[account] = points.get(account, 0) + account_points
210-
total_points += account_points
211-
212-
if total_validators <= 0:
168+
"""Send half of rewards to a single operator address."""
169+
if operator_address == EMPTY_ADDR_HEX:
170+
logger.error("Invalid operator address")
213171
return {}, total_reward
214172

215-
operators_reward = Wei(
216-
(total_reward * total_points)
217-
// (total_validators * 10000 * (to_block - from_block))
218-
)
173+
operators_reward = Wei(total_reward // 2)
174+
219175
if operators_reward <= 0:
220176
return {}, total_reward
221177

222178
operators_reward = min(total_reward, operators_reward)
223-
rewards = calculate_points_based_rewards(
224-
total_reward=operators_reward,
225-
points=points,
226-
total_points=total_points,
179+
180+
rewards: Rewards = {}
181+
DistributorRewards.add_value(
182+
rewards=rewards,
183+
to=operator_address,
227184
reward_token=reward_token_address,
185+
amount=operators_reward,
228186
)
229187

230188
return rewards, Wei(total_reward - operators_reward)

oracle/oracle/distributor/controller.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,9 @@ async def process(self, voting_params: DistributorVotingParameters) -> None:
163163

164164
protocol_reward = voting_params["protocol_reward"]
165165
operators_rewards, left_reward = await get_operators_rewards(
166-
network=NETWORK,
167-
from_block=from_block,
168-
to_block=to_block,
169166
total_reward=protocol_reward,
170167
reward_token_address=NETWORK_CONFIG["REWARD_TOKEN_CONTRACT_ADDRESS"],
171-
validators_split=NETWORK_CONFIG["VALIDATORS_SPLIT"],
168+
operator_address=NETWORK_CONFIG["OPERATOR_ADDRESS"],
172169
)
173170
partners_rewards, left_reward = await get_partners_rewards(
174171
network=NETWORK,

0 commit comments

Comments
 (0)