prediction-market-agent-tooling 0.62.0.dev467__py3-none-any.whl → 0.62.0.dev468__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,8 @@ from cowdao_cowpy.order_book.generated.model import (
14
14
  OrderMetaData,
15
15
  OrderQuoteRequest,
16
16
  OrderQuoteSide1,
17
+ OrderQuoteSide3,
18
+ OrderQuoteSideKindBuy,
17
19
  OrderQuoteSideKindSell,
18
20
  OrderStatus,
19
21
  TokenAmount,
@@ -34,13 +36,41 @@ def get_order_book_api(env: Envs, chain: Chain) -> OrderBookApi:
34
36
  return OrderBookApi(OrderBookAPIConfigFactory.get_config(env, chain_id))
35
37
 
36
38
 
39
+ def get_sell_token_amount(
40
+ buy_amount: Wei,
41
+ sell_token: ChecksumAddress,
42
+ buy_token: ChecksumAddress,
43
+ chain: Chain = Chain.GNOSIS,
44
+ env: Envs = "prod",
45
+ ) -> Wei:
46
+ """
47
+ Calculate how much of the sell_token is needed to obtain a specified amount of buy_token.
48
+ """
49
+ order_book_api = get_order_book_api(env, chain)
50
+ order_quote_request = OrderQuoteRequest(
51
+ sellToken=Address(sell_token),
52
+ buyToken=Address(buy_token),
53
+ from_=Address(
54
+ "0x1234567890abcdef1234567890abcdef12345678"
55
+ ), # Just random address, doesn't matter.
56
+ )
57
+ order_side = OrderQuoteSide3(
58
+ kind=OrderQuoteSideKindBuy.buy,
59
+ buyAmountAfterFee=TokenAmount(str(buy_amount)),
60
+ )
61
+ order_quote = asyncio.run(
62
+ order_book_api.post_quote(order_quote_request, order_side)
63
+ )
64
+ return Wei(order_quote.quote.sellAmount.root)
65
+
66
+
37
67
  @tenacity.retry(
38
68
  stop=tenacity.stop_after_attempt(3),
39
69
  wait=tenacity.wait_fixed(1),
40
70
  after=lambda x: logger.debug(f"get_buy_token_amount failed, {x.attempt_number=}."),
41
71
  )
42
72
  def get_buy_token_amount(
43
- amount_wei: Wei,
73
+ sell_amount: Wei,
44
74
  sell_token: ChecksumAddress,
45
75
  buy_token: ChecksumAddress,
46
76
  chain: Chain = Chain.GNOSIS,
@@ -56,7 +86,7 @@ def get_buy_token_amount(
56
86
  )
57
87
  order_side = OrderQuoteSide1(
58
88
  kind=OrderQuoteSideKindSell.sell,
59
- sellAmountBeforeFee=TokenAmount(str(amount_wei)),
89
+ sellAmountBeforeFee=TokenAmount(str(sell_amount)),
60
90
  )
61
91
  order_quote = asyncio.run(
62
92
  order_book_api.post_quote(order_quote_request, order_side)
@@ -55,7 +55,7 @@ def get_single_token_unit_to_usd_rate(token_address: ChecksumAddress) -> USD:
55
55
  .as_token.value
56
56
  )
57
57
  in_wei = get_buy_token_amount(
58
- amount_wei=Token(1).as_wei,
58
+ sell_amount=Token(1).as_wei,
59
59
  sell_token=token_address,
60
60
  buy_token=WRAPPED_XDAI_CONTRACT_ADDRESS,
61
61
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.62.0.dev467
3
+ Version: 0.62.0.dev468
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -87,7 +87,7 @@ prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp
87
87
  prediction_market_agent_tooling/tools/contract.py,sha256=K9i7J4F7gt6saoKT3tx5S-fPYVh-eCliJpg2T1eNBWo,20998
88
88
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
89
89
  prediction_market_agent_tooling/tools/cow/cow_manager.py,sha256=F6T4SlKDQ06nwz3W2wVBr0VqgVvdb4Wphf-kI31W4ms,3792
90
- prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=qhtsEd7a9qAV3zKgSdAyOFZOLAiNOL632JgYAPqazUY,4399
90
+ prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=OIOhOWiEW5R3D43kYKmW0qQeZsEmboI6Rh7nMp4MCl0,5341
91
91
  prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
92
92
  prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
93
93
  prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
@@ -116,12 +116,12 @@ prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256=M2ozvdLZyX0R
116
116
  prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=nV9jSUt1ydceDj03cTwdyrJs8kFGqz9z6YcvTVUaNg4,2682
117
117
  prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=1rbwpdCusPgQIVFuo3m00nBZ_b2lCAoFVm67i-YDcEw,812
118
118
  prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=zwV-jGFkPJu4-IslXOUqnsNQjzh_9CrfkruDQL0dq0c,1381
119
- prediction_market_agent_tooling/tools/tokens/usd.py,sha256=0GU7RiWGlu7yDctGeWJeLsy8uYLcpI1JyLWWqFt0QWE,2179
119
+ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=vUZB7h-nHHfZPUwofCXPRBEGWDnrmLEiohqjwDpMivM,2180
120
120
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
121
121
  prediction_market_agent_tooling/tools/utils.py,sha256=7P1veh76ni-0EfT7MlRlLE9hHUU498UOx70Lwxe7UaM,6536
122
122
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=eYCc1iWAVtqDKUPTwnMUHuYolPdwh_OTiM3-AdRgDp4,12198
123
- prediction_market_agent_tooling-0.62.0.dev467.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
124
- prediction_market_agent_tooling-0.62.0.dev467.dist-info/METADATA,sha256=SazQJ5VVLyAPHB3dMx3KmG86o_TJBkGfGxmZOMwnjRY,8696
125
- prediction_market_agent_tooling-0.62.0.dev467.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
126
- prediction_market_agent_tooling-0.62.0.dev467.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
127
- prediction_market_agent_tooling-0.62.0.dev467.dist-info/RECORD,,
123
+ prediction_market_agent_tooling-0.62.0.dev468.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
124
+ prediction_market_agent_tooling-0.62.0.dev468.dist-info/METADATA,sha256=gWdZEHRNcX6f_sNL3NREr5aI_yfBjShvnSX01wTh24c,8696
125
+ prediction_market_agent_tooling-0.62.0.dev468.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
126
+ prediction_market_agent_tooling-0.62.0.dev468.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
127
+ prediction_market_agent_tooling-0.62.0.dev468.dist-info/RECORD,,