Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions run_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ get_private_key() {
# Function to warm start the policy
warm_start() {
echo '["prediction-online", "prediction-online-sme", "prediction-online-summarized-info", "prediction-sentence-embedding-bold", "prediction-sentence-embedding-conservative"]' | sudo tee "$PWD/../$store/available_tools_store.json" > /dev/null
echo '{"counts": [1,1,1,1,1], "eps": 0.1, "rewards": [0.0,0.0,0.0,0.0,0.0]}' | sudo tee "$PWD/../$store/policy_store.json" > /dev/null
echo '{"counts": [0,0,0,0,0], "eps": 0.1, "rewards": [0.0,0.0,0.0,0.0,0.0]}' | sudo tee "$PWD/../$store/policy_store.json" > /dev/null
echo '{}' | sudo tee "$PWD/../$store/utilized_tools.json" > /dev/null
}

Expand Down Expand Up @@ -581,7 +581,7 @@ directory="trader"
service_repo=https://github.com/$org_name/$directory.git
# This is a tested version that works well.
# Feel free to replace this with a different version of the repo, but be careful as there might be breaking changes
service_version="v0.12.4"
service_version="v0.12.5"

# Define constants for on-chain interaction
gnosis_chain_id=100
Expand Down Expand Up @@ -609,7 +609,7 @@ export WXDAI_ADDRESS="0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"
if [ "$USE_NEVERMINED" == "true" ];
then
echo "A Nevermined subscription will be used to pay for the mech requests."
export MECH_AGENT_ADDRESS="0x1Ce2Bc116fF7E668b1c57572B8981Ac0947034D1"
export MECH_AGENT_ADDRESS="0x327E26bDF1CfEa50BFAe35643B23D5268E41F7F9"
export AGENT_REGISTRY_ADDRESS="0xAed729d4f4b895d8ca84ba022675bB0C44d2cD52"
fi

Expand Down
26 changes: 14 additions & 12 deletions trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def _parse_args() -> Any:
return args


def _to_content(q: str) -> dict[str, Any]:
def _to_content(q: str) -> Dict[str, Any]:
"""Convert the given query string to payload content, i.e., add it under a `queries` key and convert it to bytes."""
finalized_query = {
"query": q,
Expand All @@ -320,7 +320,7 @@ def _query_omen_xdai_subgraph( # pylint: disable=too-many-locals
to_timestamp: float = DEFAULT_TO_TIMESTAMP,
fpmm_from_timestamp: float = DEFAULT_FROM_TIMESTAMP,
fpmm_to_timestamp: float = DEFAULT_TO_TIMESTAMP,
) -> dict[str, Any]:
) -> Dict[str, Any]:
"""Query the subgraph."""
url = "https://api.thegraph.com/subgraphs/name/protofire/omen-xdai"

Expand Down Expand Up @@ -365,11 +365,11 @@ def _query_omen_xdai_subgraph( # pylint: disable=too-many-locals
return all_results


def _query_conditional_tokens_gc_subgraph(creator: str) -> dict[str, Any]:
def _query_conditional_tokens_gc_subgraph(creator: str) -> Dict[str, Any]:
"""Query the subgraph."""
url = "https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc"

all_results: dict[str, Any] = {"data": {"user": {"userPositions": []}}}
all_results: Dict[str, Any] = {"data": {"user": {"userPositions": []}}}
userPositions_id_gt = ""
while True:
query = conditional_tokens_gc_user_query.substitute(
Expand Down Expand Up @@ -419,7 +419,7 @@ def wei_to_olas(wei: int) -> str:
return "{:.2f} OLAS".format(wei_to_unit(wei))


def _is_redeemed(user_json: dict[str, Any], fpmmTrade: dict[str, Any]) -> bool:
def _is_redeemed(user_json: Dict[str, Any], fpmmTrade: Dict[str, Any]) -> bool:
user_positions = user_json["data"]["user"]["userPositions"]
outcomes_tokens_traded = int(fpmmTrade["outcomeTokensTraded"])
condition_id = fpmmTrade["fpmm"]["condition"]["id"]
Expand Down Expand Up @@ -451,7 +451,7 @@ def _compute_roi(initial_value: int, final_value: int) -> float:


def _compute_totals(
table: dict[Any, dict[Any, Any]], mech_statistics: dict[str, Any]
table: Dict[Any, Dict[Any, Any]], mech_statistics: Dict[str, Any]
) -> None:
for row in table.keys():
total = sum(table[row][c] for c in table[row])
Expand Down Expand Up @@ -489,7 +489,7 @@ def _compute_totals(
)


def _format_table(table: dict[Any, dict[Any, Any]]) -> str:
def _format_table(table: Dict[Any, Dict[Any, Any]]) -> str:
column_width = 14

table_str = " " * column_width
Expand Down Expand Up @@ -617,11 +617,12 @@ def _format_table(table: dict[Any, dict[Any, Any]]) -> str:
def parse_user( # pylint: disable=too-many-locals,too-many-statements
rpc: str,
creator: str,
creator_trades_json: dict[str, Any],
mech_statistics: dict[str, Any],
) -> tuple[str, dict[Any, Any]]:
creator_trades_json: Dict[str, Any],
mech_statistics: Dict[str, Any],
) -> tuple[str, Dict[Any, Any]]:
"""Parse the trades from the response."""

_mech_statistics = dict(mech_statistics)
user_json = _query_conditional_tokens_gc_subgraph(creator)

statistics_table = {
Expand Down Expand Up @@ -670,10 +671,11 @@ def parse_user( # pylint: disable=too-many-locals,too-many-statements
market_status
] += collateral_amount
statistics_table[MarketAttribute.FEES][market_status] += fee_amount
mech_data = _mech_statistics.pop(fpmmTrade["title"], {})
statistics_table[MarketAttribute.MECH_CALLS][
market_status
] += mech_statistics.get(fpmmTrade["title"], {}).get("count", 0)
mech_fees = mech_statistics.get(fpmmTrade["title"], {}).get("fees", 0)
] += mech_data.get("count", 0)
mech_fees = mech_data.get("fees", 0)
statistics_table[MarketAttribute.MECH_FEES][market_status] += mech_fees

output += f" Market status: {market_status}\n"
Expand Down