prediction-market-agent-tooling 0.62.0.dev466__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.
- prediction_market_agent_tooling/markets/agent_market.py +0 -1
- prediction_market_agent_tooling/tools/_generic_value.py +4 -0
- prediction_market_agent_tooling/tools/cow/cow_order.py +32 -2
- prediction_market_agent_tooling/tools/tokens/usd.py +1 -1
- {prediction_market_agent_tooling-0.62.0.dev466.dist-info → prediction_market_agent_tooling-0.62.0.dev468.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.62.0.dev466.dist-info → prediction_market_agent_tooling-0.62.0.dev468.dist-info}/RECORD +9 -9
- {prediction_market_agent_tooling-0.62.0.dev466.dist-info → prediction_market_agent_tooling-0.62.0.dev468.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.62.0.dev466.dist-info → prediction_market_agent_tooling-0.62.0.dev468.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.62.0.dev466.dist-info → prediction_market_agent_tooling-0.62.0.dev468.dist-info}/entry_points.txt +0 -0
@@ -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
|
-
|
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(
|
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
|
-
|
58
|
+
sell_amount=Token(1).as_wei,
|
59
59
|
sell_token=token_address,
|
60
60
|
buy_token=WRAPPED_XDAI_CONTRACT_ADDRESS,
|
61
61
|
)
|
@@ -34,7 +34,7 @@ prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeu
|
|
34
34
|
prediction_market_agent_tooling/jobs/jobs_models.py,sha256=8vYafsK1cqMWQtjBoq9rruroF84xAVD00vBTMWH6QMg,2166
|
35
35
|
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=Pf6QxPXGyie-2l_wZUjaGPTjZTlpv50_JhP40mULBaU,5048
|
36
36
|
prediction_market_agent_tooling/loggers.py,sha256=MvCkQSJL2_0yErNatqr81sJlc4aOgPzDp9VNrIhKUcc,4140
|
37
|
-
prediction_market_agent_tooling/markets/agent_market.py,sha256=
|
37
|
+
prediction_market_agent_tooling/markets/agent_market.py,sha256=XeDu70yASEGd4FI5_PDPx9VA8O4cJ1P_uTZtyUsi6Zc,14656
|
38
38
|
prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
|
39
39
|
prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=1iTU_D-Uof0E442qVUhSBCfc1rJNQpDcd3UjSnilYZg,2129
|
40
40
|
prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
|
@@ -74,7 +74,7 @@ prediction_market_agent_tooling/monitor/monitor.py,sha256=yvSXwV-3DSAm3vsFZnFC9j
|
|
74
74
|
prediction_market_agent_tooling/monitor/monitor_app.py,sha256=-_6w_ZvQ-Ad5qaeuo7NKTXUOOZ_6OrR8jMe25BGOY4k,4615
|
75
75
|
prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
|
76
76
|
prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
77
|
-
prediction_market_agent_tooling/tools/_generic_value.py,sha256=
|
77
|
+
prediction_market_agent_tooling/tools/_generic_value.py,sha256=0_EDybTsr3iXqPPqy2U1WMw4st_SlYaCrf2p1MZhED4,10511
|
78
78
|
prediction_market_agent_tooling/tools/balances.py,sha256=9MpTTnquwjflTYYo1e0w48iOTceBuQV_6PfvywrTlFk,989
|
79
79
|
prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py,sha256=cui0wc7InSG-GdFvrJ3ypxAvHBTnv7UAFR6QOm6pI8A,4813
|
80
80
|
prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256=uG11UAzM6C0ZKTS7SyT1iVsTs6O13y8_o8RAtm29HFg,5432
|
@@ -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=
|
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=
|
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.
|
124
|
-
prediction_market_agent_tooling-0.62.0.
|
125
|
-
prediction_market_agent_tooling-0.62.0.
|
126
|
-
prediction_market_agent_tooling-0.62.0.
|
127
|
-
prediction_market_agent_tooling-0.62.0.
|
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,,
|
File without changes
|
File without changes
|