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
33 changes: 30 additions & 3 deletions report.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
"contracts",
"ServiceRegistryTokenUtility.json",
)
MECH_CONTRACT_ADDRESS = "0x77af31De935740567Cf4fF1986D04B2c964A786a"
MECH_CONTRACT_JSON_PATH = Path(
SCRIPT_PATH,
"trader",
"packages",
"valory",
"contracts",
"mech",
"build",
"mech.json",
)

SAFE_BALANCE_THRESHOLD = 500000000000000000
AGENT_XDAI_BALANCE_THRESHOLD = 50000000000000000
Expand Down Expand Up @@ -277,6 +288,15 @@ def _parse_args() -> Any:
abi=service_registry_token_utility_abi,
)

with open(MECH_CONTRACT_JSON_PATH, "r", encoding="utf-8") as file:
mech_contract_data = json.load(file)

mech_contract_abi = mech_contract_data.get("abi", [])

mech_contract = w3.eth.contract(
address=MECH_CONTRACT_ADDRESS, abi=mech_contract_abi
)

security_deposit = (
service_registry_token_utility_contract.functions.getOperatorBalance(
operator_address, service_id
Expand Down Expand Up @@ -320,9 +340,16 @@ def _parse_args() -> Any:
service_staking_token_contract.functions.livenessPeriod().call()
)
last_checkpoint_ts = next_checkpoint_ts - liveness_period
mech_requests_current_epoch = _get_mech_requests_count(
mech_requests, last_checkpoint_ts
)

mech_request_count = mech_contract.functions.getRequestsCount(safe_address).call()
mech_request_count_on_last_checkpoint = (
service_staking_token_contract.functions.getServiceInfo(service_id).call()
)[2][1]
mech_requests_since_last_cp = mech_request_count - mech_request_count_on_last_checkpoint
# mech_requests_current_epoch = _get_mech_requests_count(
# mech_requests, last_checkpoint_ts
# )
mech_requests_current_epoch = mech_requests_since_last_cp
_print_status(
"Num. Mech txs current epoch",
f"{mech_requests_current_epoch} {_warning_message(mech_requests_current_epoch, mech_requests_24h_threshold, f'- Too low. Threshold is {mech_requests_24h_threshold}.')}",
Expand Down
10 changes: 7 additions & 3 deletions run_service.sh
Original file line number Diff line number Diff line change
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.13.1"
service_version="v0.13.2"

# Define constants for on-chain interaction
gnosis_chain_id=100
Expand All @@ -602,16 +602,20 @@ export CUSTOM_SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESS="0xa45E64d13A30a51b91ae0eb1
export CUSTOM_GNOSIS_SAFE_PROXY_FACTORY_ADDRESS="0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE"
export CUSTOM_GNOSIS_SAFE_SAME_ADDRESS_MULTISIG_ADDRESS="0x6e7f594f680f7aBad18b7a63de50F0FeE47dfD06"
export CUSTOM_MULTISEND_ADDRESS="0x40A2aCCbd92BCA938b02010E17A5b8929b49130D"
export MECH_CONTRACT_ADDRESS="0x77af31De935740567Cf4fF1986D04B2c964A786a"
export WXDAI_ADDRESS="0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"
export MECH_CONTRACT_ADDRESS="0x77af31De935740567Cf4fF1986D04B2c964A786a"
export MECH_WRAPPED_NATIVE_TOKEN_ADDRESS=$WXDAI_ADDRESS
export DISABLE_TRADING=false
export STOP_TRADING_IF_STAKING_KPI_MET=true
export RESET_PAUSE_DURATION=300
Copy link
Collaborator Author

@jmoreira-valory jmoreira-valory Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this admissible? (300s = 5 minutes)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to override this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that the trader waits 5 minutes before restarting the cycle, to avoid unnecessary cycles, excessive logging, etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also slow down the trades though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this only affect the agents in staked services? That would be acceptable, and it can always be changed.

If it also affects the non-staked agents, then this would be unnecessary long IMO

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It affects all agents. The rational is that waits for some time before trying to go through the trading cycle. Feel free to modify with a lower value / remove it, if you find it appropriate.


# check if USE_NEVERMINED is set to true
if [ "$USE_NEVERMINED" == "true" ];
then
echo "A Nevermined subscription will be used to pay for the mech requests."
export MECH_CONTRACT_ADDRESS="0x327E26bDF1CfEa50BFAe35643B23D5268E41F7F9"
export AGENT_REGISTRY_ADDRESS="0xAed729d4f4b895d8ca84ba022675bB0C44d2cD52"
export REQUEST_PRICE=0
export MECH_REQUEST_PRICE=0
fi

sleep_duration=12
Expand Down