Skip to content

Commit

Permalink
[predictoor] Use float instead of int for stake amount (#259)
Browse files Browse the repository at this point in the history
* Use float instead of int

* Fix stake calculation in approach 2

* Add comment

* Update envvars readme

* Black

* Fix linter error

* Blackl
  • Loading branch information
trizin authored Oct 19, 2023
1 parent 68e85fe commit 4cffbab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions READMEs/envvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ These are envvars that are specific to a given agent.
### Predictoor Agent

- **SECONDS_TILL_EPOCH_END**: Determines how soon to start predicting. Example: if value is `60` then it will start submitting predictions 60 seconds before. It will continue to periodically submit predictions until there's no time left.
- **STAKE_AMOUNT**: The amount to stake in units of Eth.
- For approach 1 stake amount is randomly determined this has no effect.
- For approach 2 stake amount is determined by: `STAKE_AMOUNT * confidence` where confidence is between 0 and 1.
- For approach 3 this is the stake amount.

### DFBuyer Agent

Expand Down
2 changes: 1 addition & 1 deletion pdr_backend/predictoor/approach2/main2.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def process_block(block, model, main_pd):
if predicted_value is not None and predicted_confidence > 0:
# We have a prediction, let's submit it
stake_amount = (
int(getenv("STAKE_AMOUNT", "1")) * predicted_confidence / 100
int(getenv("STAKE_AMOUNT", "1")) * predicted_confidence
) # TO DO have a customizable function to handle this
print(
f"Contract:{predictoor_contract.contract_address} - "
Expand Down
7 changes: 6 additions & 1 deletion pdr_backend/predictoor/base_predictoor_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ class BasePredictoorConfig(BaseConfig, ABC):
def __init__(self):
super().__init__()
self.s_until_epoch_end = int(getenv("SECONDS_TILL_EPOCH_END", "60"))
self.stake_amount = int(getenv("STAKE_AMOUNT", "1"))

# For approach 1 stake amount is randomly determined this has no effect.
# For approach 2 stake amount is determined by:
# `STAKE_AMOUNT * confidence` where confidence is between 0 and 1.
# For approach 3 this is the stake amount.
self.stake_amount = float(getenv("STAKE_AMOUNT", "1")) # stake amount in eth

0 comments on commit 4cffbab

Please sign in to comment.