示例#1
0
    def __init__(self,
                 vault,
                 api_version=None,
                 token=None,
                 registry=None,
                 watch_events_forever=True):
        self._strategies = {}
        self._revoked = {}
        self._reports = []
        self.vault = vault
        self.api_version = api_version
        if token is None:
            token = vault.token()
        self.token = contract(token)
        self.registry = registry
        self.scale = 10**self.vault.decimals()
        # multicall-safe views with 0 inputs and numeric output.
        self._views = safe_views(self.vault.abi)

        # load strategies from events and watch for freshly attached strategies
        self._topics = [[
            encode_hex(event_abi_to_log_topic(event))
            for event in self.vault.abi
            if event["type"] == "event" and event["name"] in STRATEGY_EVENTS
        ]]
        self._watch_events_forever = watch_events_forever
        self._done = threading.Event()
        self._thread = threading.Thread(target=self.watch_events, daemon=True)
示例#2
0
 def __init__(self, strategy, vault):
     self.strategy = Contract(strategy)
     self.vault = vault
     self.name = self.strategy.name()
     self._views = safe_views(self.strategy.abi)
     self._harvests = []
     self._topics = [[
         encode_hex(event_abi_to_log_topic(event))
         for event in self.strategy.abi
         if event["type"] == "event" and event["name"] in STRATEGY_EVENTS
     ]]
     self._done = threading.Event()
     self._thread = threading.Thread(target=self.watch_events, daemon=True)
示例#3
0
 def __init__(self, strategy, vault):
     self.strategy = Contract(strategy)
     self.vault = vault
     self.name = self.strategy.name()
     self._views = safe_views(self.strategy.abi)