diff --git a/oracle/oracle/common/graphql_queries.py b/oracle/oracle/common/graphql_queries.py index 6c9145d..80eadba 100644 --- a/oracle/oracle/common/graphql_queries.py +++ b/oracle/oracle/common/graphql_queries.py @@ -341,18 +341,3 @@ } """ ) - - -PARTNERS_QUERY = gql( - """ - query getPartners($block_number: Int) { - partners(block: { number: $block_number }) { - id - contributedAmount - revenueShare - distributorPoints - updatedAtBlock - } - } -""" -) diff --git a/oracle/oracle/distributor/common/eth1.py b/oracle/oracle/distributor/common/eth1.py index 5167d81..b2df673 100644 --- a/oracle/oracle/distributor/common/eth1.py +++ b/oracle/oracle/distributor/common/eth1.py @@ -14,7 +14,6 @@ DISABLED_STAKER_ACCOUNTS_QUERY, DISTRIBUTOR_CLAIMED_ACCOUNTS_QUERY, ONE_TIME_DISTRIBUTIONS_QUERY, - PARTNERS_QUERY, PERIODIC_DISTRIBUTIONS_QUERY, ) from oracle.oracle.distributor.common.ipfs import get_one_time_rewards_allocations @@ -188,105 +187,6 @@ async def get_operators_rewards( return rewards, Wei(total_reward - operators_reward) -async def get_partners_rewards( - network: str, - from_block: BlockNumber, - to_block: BlockNumber, - total_reward: Wei, - reward_token_address: ChecksumAddress, -) -> Tuple[Rewards, Wei]: - """Fetches partners rewards.""" - result: Dict = await execute_sw_gql_query( - network=network, - query=PARTNERS_QUERY, - variables=dict( - block_number=to_block, - ), - ) - partners = result["partners"] - - # process partners - points: Dict[ChecksumAddress, int] = {} - total_points = 0 - total_contributed = 0 - for partner in partners: - account = Web3.toChecksumAddress(partner["id"]) - if account == EMPTY_ADDR_HEX: - continue - - contributed_amount = Wei(int(partner["contributedAmount"])) - total_contributed += contributed_amount - - revenue_share = int(partner["revenueShare"]) - prev_account_points = int(partner["distributorPoints"]) - updated_at_block = BlockNumber(int(partner["updatedAtBlock"])) - if from_block > updated_at_block: - updated_at_block = from_block - prev_account_points = 0 - - account_points = prev_account_points + ( - contributed_amount * revenue_share * (to_block - updated_at_block) - ) - if account_points <= 0: - continue - - points[account] = account_points - total_points += account_points - - if total_contributed <= 0: - return {}, total_reward - - partners_reward = Wei( - (total_reward * total_points) - // (total_contributed * 10000 * (to_block - from_block)) - ) - if partners_reward <= 0: - return {}, total_reward - - partners_reward = min(total_reward, partners_reward) - rewards = calculate_points_based_rewards( - total_reward=partners_reward, - points=points, - total_points=total_points, - reward_token=reward_token_address, - ) - - return rewards, Wei(total_reward - partners_reward) - - -def calculate_points_based_rewards( - total_reward: int, - points: Dict[ChecksumAddress, int], - total_points: int, - reward_token: ChecksumAddress, -) -> Rewards: - """Calculates points based rewards.""" - if total_reward <= 0 or total_points <= 0: - return {} - - rewards: Rewards = {} - last_account_index = len(points) - 1 - distributed = 0 - for i, account in enumerate(points): - if i == last_account_index: - reward = total_reward - distributed - else: - reward = (total_reward * points[account]) // total_points - - if reward <= 0: - continue - - DistributorRewards.add_value( - rewards=rewards, - to=account, - reward_token=reward_token, - amount=reward, - ) - distributed += reward - - return rewards - - async def get_one_time_rewards( network: str, from_block: BlockNumber, diff --git a/oracle/oracle/distributor/controller.py b/oracle/oracle/distributor/controller.py index b66ccf0..0d78ade 100644 --- a/oracle/oracle/distributor/controller.py +++ b/oracle/oracle/distributor/controller.py @@ -14,7 +14,6 @@ get_distributor_claimed_accounts, get_one_time_rewards, get_operators_rewards, - get_partners_rewards, get_periodic_allocations, ) from oracle.oracle.distributor.common.merkle_tree import calculate_merkle_root @@ -167,13 +166,7 @@ async def process(self, voting_params: DistributorVotingParameters) -> None: reward_token_address=NETWORK_CONFIG["REWARD_TOKEN_CONTRACT_ADDRESS"], operator_address=NETWORK_CONFIG["OPERATOR_ADDRESS"], ) - partners_rewards, left_reward = await get_partners_rewards( - network=NETWORK, - from_block=from_block, - to_block=to_block, - total_reward=left_reward, - reward_token_address=NETWORK_CONFIG["REWARD_TOKEN_CONTRACT_ADDRESS"], - ) + if left_reward > 0: fallback_rewards: Rewards = { self.distributor_fallback_address: { @@ -185,7 +178,7 @@ async def process(self, voting_params: DistributorVotingParameters) -> None: rewards2=fallback_rewards, ) - for rewards in [operators_rewards, partners_rewards]: + for rewards in [operators_rewards]: final_rewards = DistributorRewards.merge_rewards(final_rewards, rewards) # merge final rewards with unclaimed rewards diff --git a/oracle/settings.py b/oracle/settings.py index 95ac118..76f125e 100644 --- a/oracle/settings.py +++ b/oracle/settings.py @@ -34,7 +34,7 @@ IPFS_FETCH_ENDPOINTS = config( "IPFS_FETCH_ENDPOINTS", cast=Csv(), - default="http://cloudflare-ipfs.com,https://ipfs.io,https://gateway.pinata.cloud", + default="https://ipfs.io,https://gateway.pinata.cloud", ) LOCAL_IPFS_CLIENT_ENDPOINT = config("LOCAL_IPFS_CLIENT_ENDPOINT", default="") diff --git a/pyproject.toml b/pyproject.toml index ca8d29c..2cd5d48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "oracle" -version = "3.3.1" +version = "3.4.0" description = "StakeWise Oracles are responsible for submitting off-chain data." authors = ["Dmitri Tsumak "] license = "AGPL-3.0-only"