diff --git a/bots/util.py b/bots/util.py index 71b2c14..d40b834 100644 --- a/bots/util.py +++ b/bots/util.py @@ -1186,15 +1186,13 @@ def single_event_str(self, event_log): # Pull args from the event log. token_address = event_log.args.get("token") token_amount_long = event_log.args.get("amount") # AddDeposit, AddWithdrawal - bdv = None - if event_log.args.get("bdvs") is not None: - bdv = bean_to_float(sum(event_log.args.get("bdvs"))) - else: - bdv = bean_to_float(event_log.args.get("bdv")) _, _, token_symbol, decimals = get_erc20_info(token_address, web3=self._web3).parse() amount = token_to_float(token_amount_long, decimals) + # Use current bdv rather than the deposited bdv reported in the event + bdv = amount * self.beanstalk_client.get_bdv(get_erc20_info(token_address)) + value = None if bdv > 0: value = bdv * bean_price diff --git a/data_access/eth_chain.py b/data_access/eth_chain.py index 0f5cc6b..06394bd 100644 --- a/data_access/eth_chain.py +++ b/data_access/eth_chain.py @@ -654,6 +654,12 @@ def get_seeds(self, token, block_number='latest'): token_settings = call_contract_function_with_retry(self.contract.functions.tokenSettings(token), block_number=block_number) return (token_settings[1] * 10000) / 10 ** STALK_DECIMALS + def get_bdv(self, erc20_info, block_number='latest'): + """Returns the current bdv `token`.""" + token = Web3.to_checksum_address(erc20_info.addr) + bdv = call_contract_function_with_retry(self.contract.functions.bdv(token, 10 ** erc20_info.decimals), block_number=block_number) + return bean_to_float(bdv) + class BeanClient(ChainClient): """Common functionality related to the Bean token.""" @@ -2763,6 +2769,7 @@ def monitor_beanstalk_events(): client = EthEventsClient(EventClientType.SEASON) events = client.get_log_range(20566115, 20566115) logging.info(f"found txn: {events[0].txn_hash.hex()}") + logging.info(f"lp bdv {bs.get_bdv(get_erc20_info(BEAN_WSTETH_WELL_ADDR), 20566115)}") # monitor_beanstalk_events() # monitor_curve_pool_events()