diff --git a/packages/packages.json b/packages/packages.json index 9d3829635..6d1fce649 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { - "skill/valory/market_manager_abci/0.1.0": "bafybeiei62pni5gej5wzf3wp3olwnxxrahqvlnlupedgjwvwgj3v7pnraq", - "skill/valory/decision_maker_abci/0.1.0": "bafybeidjsnb373piss6mhrcb2arrfqdrtsxsk7gbdmhlvzzreud5pzqjoa", - "skill/valory/trader_abci/0.1.0": "bafybeifhrrqnx362tzpjrwxrmwn7imzeqe6ovdgyi5tjylf4g5wetfnlmq", + "skill/valory/market_manager_abci/0.1.0": "bafybeihttthwkcj65tq4prfnvtxdg3blodd6ibv3mhcnh2pjqs4rwdsmwu", + "skill/valory/decision_maker_abci/0.1.0": "bafybeihugcpa6f2skx54ticw4kc6hup4vcaya3qvsy6xiy6w63o7udqm4a", + "skill/valory/trader_abci/0.1.0": "bafybeiea5loj4okwlzhprbopbbxsmknogyr2ck67th7ygzektyp7kfycze", "contract/valory/market_maker/0.1.0": "bafybeiehszwvmurz5b5vpqbxbvcm5ty4z553jqpsnernqwdq6d62r3z5wa", - "agent/valory/trader/0.1.0": "bafybeidxhwzmm5e5eti5c3uxsgpgj2wsk5e4aydm2l4iajzqpsk47kh6gy", - "service/valory/trader/0.1.0": "bafybeich7ewea6a7x3sgo26y5bjn4qqgjxbnr5sofvd46gkoebv6w74tau", + "agent/valory/trader/0.1.0": "bafybeie3qrkdnf7j2mcvfjkjlwzp5ofpggdgakiagcougrmzj6bt6dpl3a", + "service/valory/trader/0.1.0": "bafybeic4ifuucba74jplqpetjoljkfbklyzjozmu7guaihav4lgr53zjpq", "contract/valory/erc20/0.1.0": "bafybeihisiakfcftxs2hwx7yxzovao4qjuk3kqbzntiekzv5v75vpax3ui", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeib6ndzgd25ujflzb37hg7yozmqv5tubxdipgnnppaygz4nv545r3m", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeid6lh3q627rkpcix4tpm2q72jwta3ijq3gwt5nwh2swgp2n3r5djm", "contract/valory/mech/0.1.0": "bafybeigvha4ya64ccjl7tbroa3zjqlxm64wxsqx5k2cz2xs3a7igu5qgxa", "contract/valory/realitio/0.1.0": "bafybeic5ie4oodetj4krdogydvbfxg4qggc3matpiflocah626tpevpreq", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 901c6ed0a..54160e691 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -43,10 +43,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeidzajbe3erygeh2xbd6lrjv7nsptznjuzrt24ykgvhgotdeyhfnba - valory/termination_abci:0.1.0:bafybeie4zvjfxvdu7qrulmur3chpjz3kpj5m4bjsxvpk4gvj5zbyyayfaa - valory/transaction_settlement_abci:0.1.0:bafybeiaefgqbs7zsn5xe5kdwrujj7ivygkn3ujpw6crnvi3knvxw75qmja -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeib6ndzgd25ujflzb37hg7yozmqv5tubxdipgnnppaygz4nv545r3m -- valory/market_manager_abci:0.1.0:bafybeiei62pni5gej5wzf3wp3olwnxxrahqvlnlupedgjwvwgj3v7pnraq -- valory/decision_maker_abci:0.1.0:bafybeidjsnb373piss6mhrcb2arrfqdrtsxsk7gbdmhlvzzreud5pzqjoa -- valory/trader_abci:0.1.0:bafybeifhrrqnx362tzpjrwxrmwn7imzeqe6ovdgyi5tjylf4g5wetfnlmq +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeid6lh3q627rkpcix4tpm2q72jwta3ijq3gwt5nwh2swgp2n3r5djm +- valory/market_manager_abci:0.1.0:bafybeihttthwkcj65tq4prfnvtxdg3blodd6ibv3mhcnh2pjqs4rwdsmwu +- valory/decision_maker_abci:0.1.0:bafybeihugcpa6f2skx54ticw4kc6hup4vcaya3qvsy6xiy6w63o7udqm4a +- valory/trader_abci:0.1.0:bafybeiea5loj4okwlzhprbopbbxsmknogyr2ck67th7ygzektyp7kfycze - valory/staking_abci:0.1.0:bafybeiebu4qeblyjbacjvkiiiorxb4p3yy4nuhvsssgbailmqqtgrhwcca default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 808566c31..e000dd088 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeidxhwzmm5e5eti5c3uxsgpgj2wsk5e4aydm2l4iajzqpsk47kh6gy +agent: valory/trader:0.1.0:bafybeie3qrkdnf7j2mcvfjkjlwzp5ofpggdgakiagcougrmzj6bt6dpl3a number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index a2ad3db86..a4f380ed8 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -65,7 +65,7 @@ protocols: - valory/ipfs:0.1.0:bafybeiedxeismnx3k5ty4mvvhlqideixlhqmi5mtcki4lxqfa7uqh7p33u skills: - valory/abstract_round_abci:0.1.0:bafybeiaqcl7h2famylusiffigwem7tevkcsyocdu5xd42jkmgq6kvowzgq -- valory/market_manager_abci:0.1.0:bafybeiei62pni5gej5wzf3wp3olwnxxrahqvlnlupedgjwvwgj3v7pnraq +- valory/market_manager_abci:0.1.0:bafybeihttthwkcj65tq4prfnvtxdg3blodd6ibv3mhcnh2pjqs4rwdsmwu - valory/transaction_settlement_abci:0.1.0:bafybeiaefgqbs7zsn5xe5kdwrujj7ivygkn3ujpw6crnvi3knvxw75qmja behaviours: main: diff --git a/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py b/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py index 96f3e6654..c82d99899 100644 --- a/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py +++ b/packages/valory/skills/market_manager_abci/graph_tooling/queries/omen.py @@ -61,13 +61,14 @@ type: Buy, creator: "${creator}", fpmm_: { + creationTimestamp_gt: "${creationTimestamp_gt}", answerFinalizedTimestamp_not: null, isPendingArbitration: false } } orderBy: fpmm__creationTimestamp orderDirection: asc - first: 1000 + first: ${first} ){ fpmm { answerFinalizedTimestamp diff --git a/packages/valory/skills/market_manager_abci/graph_tooling/requests.py b/packages/valory/skills/market_manager_abci/graph_tooling/requests.py index 71ab08209..7dff47042 100644 --- a/packages/valory/skills/market_manager_abci/graph_tooling/requests.py +++ b/packages/valory/skills/market_manager_abci/graph_tooling/requests.py @@ -197,26 +197,45 @@ def _fetch_redeem_info(self) -> Generator[None, None, Optional[list]]: """Fetch redeeming information from the current subgraph.""" self._fetch_status = FetchStatus.IN_PROGRESS + current_subgraph = self.context.trades_subgraph safe = self.synchronized_data.safe_contract_address - query = trades.substitute(creator=safe.lower()) + creation_timestamp_gt = ( + 0 # used to allow for batching based on creation timestamp + ) + all_trades: List[Dict[str, Any]] = [] + # fetch trades in batches of `QUERY_BATCH_SIZE` + while True: + query = trades.substitute( + creator=safe.lower(), + first=QUERY_BATCH_SIZE, + creationTimestamp_gt=creation_timestamp_gt, + ) - # workaround because we cannot have multiple response keys for a single `ApiSpec` - res_key_backup = self.current_subgraph.response_info.response_key - self.current_subgraph.response_info.response_key = "data:fpmmTrades" + res_raw = yield from self.get_http_response( + content=to_content(query), + **current_subgraph.get_spec(), + ) + res = current_subgraph.process_response(res_raw) + trades_chunk = yield from self._handle_response( + current_subgraph, + res, + res_context="trades", + ) + if res is None: + # something went wrong + self.context.logger.error("Failed to process all trades.") + return all_trades - res_raw = yield from self.get_http_response( - content=to_content(query), - **self.current_subgraph.get_spec(), - ) - res = self.current_subgraph.process_response(res_raw) - self.current_subgraph.response_info.response_key = res_key_backup + trades_chunk = cast(List[Dict[str, Any]], trades_chunk) + if len(trades_chunk) == 0: + # no more trades to fetch + return all_trades - redeem_info = yield from self._handle_response( - self.current_subgraph, - res, - res_context="trades", - ) - return redeem_info + # this is the last trade's creation timestamp + # they are sorted by creation timestamp in ascending order + # so we can use this to fetch the next batch + creation_timestamp_gt = trades_chunk[-1]["fpmm"]["creationTimestamp"] + all_trades.extend(trades_chunk) def _fetch_block_number( self, timestamp: int @@ -316,7 +335,7 @@ def fetch_trades( **current_subgraph.get_spec(), ) res = current_subgraph.process_response(res_raw) - trades = yield from self._handle_response( + trades_chunk = yield from self._handle_response( current_subgraph, res, res_context="trades", @@ -326,16 +345,16 @@ def fetch_trades( self.context.logger.error("Failed to process all trades.") return all_trades - trades = cast(List[Dict[str, Any]], trades) - if len(trades) == 0: + trades_chunk = cast(List[Dict[str, Any]], trades_chunk) + if len(trades_chunk) == 0: # no more trades to fetch return all_trades # this is the last trade's creation timestamp # they are sorted by creation timestamp in ascending order # so we can use this to fetch the next batch - creation_timestamp_gt = trades[-1]["creationTimestamp"] - all_trades.extend(trades) + creation_timestamp_gt = trades_chunk[-1]["creationTimestamp"] + all_trades.extend(trades_chunk) def fetch_user_positions( self, user: str diff --git a/packages/valory/skills/market_manager_abci/skill.yaml b/packages/valory/skills/market_manager_abci/skill.yaml index ec47434a9..87ce77e21 100644 --- a/packages/valory/skills/market_manager_abci/skill.yaml +++ b/packages/valory/skills/market_manager_abci/skill.yaml @@ -16,10 +16,10 @@ fingerprint: graph_tooling/queries/__init__.py: bafybeihbybnl53i7k57ql5ujt5ru5n2eg324jfndh4lcnm4fk52mwbkjda graph_tooling/queries/conditional_tokens.py: bafybeic6ohkdp4rvkcfglieksv6gbzm4qocpgdjaz4sroutl37sxijthji graph_tooling/queries/network.py: bafybeigeq72ys2nrjqspj2uacaudrgljrne5a3o5jvzsktldxdq6m2xmeu - graph_tooling/queries/omen.py: bafybeidza3jmqaapfjxuuxhil2t6ibdphyxdyfnz5f7ggrdz63wxphtvhy + graph_tooling/queries/omen.py: bafybeiesgavgoio6zeovdyvzeezz5qoosdgioktoen5ckrgyxpr4u3m3nu graph_tooling/queries/realitio.py: bafybeiftewjwk5fi6uqrhmalweun47voau2qkxi7hg3faxcmyy3va44zma graph_tooling/queries/trades.py: bafybeigu6c25kf3mrlvmwjeskgagswdjnnxsygpriygmip44us4xvuf7ji - graph_tooling/requests.py: bafybeidgqarihxzjwqnbrv6vwnrxd7sck6udevtu3nc23rkxeid5acejzy + graph_tooling/requests.py: bafybeieki6p6d77hi3ewd2rd4kk43v5y7buqozjnhysxopbzo64n3zy3kq graph_tooling/utils.py: bafybeib75lziydmni6fwqg2my63ioyor2gohe5pin62tu23at5p77nndni handlers.py: bafybeihot2i2yvfkz2gcowvt66wdu6tkjbmv7hsmc4jzt4reqeaiuphbtu models.py: bafybeifmb4cojxesv2lcw6j3pm3yqjpsiuwyxpuexjbz656fpapdqcj2ba diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 11c4768cc..45d2f56fc 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -24,9 +24,9 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeidzajbe3erygeh2xbd6lrjv7nsptznjuzrt24ykgvhgotdeyhfnba - valory/transaction_settlement_abci:0.1.0:bafybeiaefgqbs7zsn5xe5kdwrujj7ivygkn3ujpw6crnvi3knvxw75qmja - valory/termination_abci:0.1.0:bafybeie4zvjfxvdu7qrulmur3chpjz3kpj5m4bjsxvpk4gvj5zbyyayfaa -- valory/market_manager_abci:0.1.0:bafybeiei62pni5gej5wzf3wp3olwnxxrahqvlnlupedgjwvwgj3v7pnraq -- valory/decision_maker_abci:0.1.0:bafybeidjsnb373piss6mhrcb2arrfqdrtsxsk7gbdmhlvzzreud5pzqjoa -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeib6ndzgd25ujflzb37hg7yozmqv5tubxdipgnnppaygz4nv545r3m +- valory/market_manager_abci:0.1.0:bafybeihttthwkcj65tq4prfnvtxdg3blodd6ibv3mhcnh2pjqs4rwdsmwu +- valory/decision_maker_abci:0.1.0:bafybeihugcpa6f2skx54ticw4kc6hup4vcaya3qvsy6xiy6w63o7udqm4a +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeid6lh3q627rkpcix4tpm2q72jwta3ijq3gwt5nwh2swgp2n3r5djm - valory/staking_abci:0.1.0:bafybeiebu4qeblyjbacjvkiiiorxb4p3yy4nuhvsssgbailmqqtgrhwcca behaviours: main: diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 8c3e505c0..c27737a1a 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -21,7 +21,7 @@ protocols: - valory/ledger_api:1.0.0:bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru skills: - valory/abstract_round_abci:0.1.0:bafybeiaqcl7h2famylusiffigwem7tevkcsyocdu5xd42jkmgq6kvowzgq -- valory/decision_maker_abci:0.1.0:bafybeidjsnb373piss6mhrcb2arrfqdrtsxsk7gbdmhlvzzreud5pzqjoa +- valory/decision_maker_abci:0.1.0:bafybeihugcpa6f2skx54ticw4kc6hup4vcaya3qvsy6xiy6w63o7udqm4a - valory/staking_abci:0.1.0:bafybeiebu4qeblyjbacjvkiiiorxb4p3yy4nuhvsssgbailmqqtgrhwcca behaviours: main: