-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/sell #350
base: develop
Are you sure you want to change the base?
Feat/sell #350
Conversation
# Conflicts: # packages/packages.json # packages/valory/agents/trader/aea-config.yaml # packages/valory/services/trader/service.yaml # packages/valory/services/trader_pearl/service.yaml # packages/valory/skills/decision_maker_abci/skill.yaml # packages/valory/skills/trader_abci/skill.yaml # packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml
packages/valory/skills/decision_maker_abci/states/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
# TODO: not sure this is the correct use of remove_fraction_wei, is sell amount in wxDAI? | ||
self.sell_amount = remove_fraction_wei(sell_amount, self.params.slippage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the sell amount should be in WEI, though I do not think we should subtract the slippage from it.
…reachability' into feat/sell # Conflicts: # packages/packages.json # packages/valory/agents/trader/aea-config.yaml # packages/valory/services/trader/service.yaml # packages/valory/services/trader_pearl/service.yaml # packages/valory/skills/decision_maker_abci/skill.yaml # packages/valory/skills/trader_abci/skill.yaml # packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml
We need to wait for the staking-kpi-reachability pr is merged before merging this as it relies on changes made there. |
# Conflicts: # packages/packages.json # packages/valory/agents/trader/aea-config.yaml # packages/valory/services/trader/service.yaml # packages/valory/services/trader_pearl/service.yaml # packages/valory/skills/decision_maker_abci/skill.yaml # packages/valory/skills/market_manager_abci/skill.yaml # packages/valory/skills/trader_abci/skill.yaml # packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/bet_placement.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/bet_placement.py
Outdated
Show resolved
Hide resolved
def _build_sell_tx(self) -> WaitableConditionType: | ||
"""Get the sell tx data encoded.""" | ||
response_msg = yield from self.get_contract_api_response( | ||
performative=ContractApiMessage.Performative.GET_STATE, # type: ignore | ||
contract_address=self.market_maker_contract_address, | ||
contract_id=str(FixedProductMarketMakerContract.contract_id), | ||
contract_callable="get_sell_data", | ||
return_amount=self.return_amount, | ||
outcome_index=self.outcome_index, | ||
max_outcome_tokens_to_sell=self.sell_amount, | ||
) | ||
if response_msg.performative != ContractApiMessage.Performative.STATE: | ||
self.context.logger.error( | ||
f"Could not get the data for the buy transaction: {response_msg}" | ||
) | ||
return False | ||
|
||
sell_data = response_msg.state.body.get("data", None) | ||
if sell_data is None: | ||
self.context.logger.error( | ||
f"Something went wrong while trying to encode the buy data: {response_msg}" | ||
) | ||
return False | ||
|
||
batch = MultisendBatch( | ||
to=self.market_maker_contract_address, | ||
data=HexBytes(sell_data), | ||
) | ||
self.multisend_batches.append(batch) | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
# if the vote is the same as the previous vote then there is no change in the supported outcome, so we | ||
# should not sell | ||
if self.synchronized_data.vote == self.synchronized_data.previous_vote: | ||
payload = MultisigTxPayload( | ||
agent, tx_submitter, betting_tx_hex, mocking_mode | ||
) | ||
|
||
yield from self.finish_behaviour(payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will not need this check as it will be moved to the post tx settlement that comes after the bet placement round.
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
packages/valory/skills/decision_maker_abci/behaviours/sell_outcome_token.py
Outdated
Show resolved
Hide resolved
# update the previous vote before calling the super method | ||
SynchronizedData.update( | ||
previous_vote=SynchronizedData.vote | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to update this as we discussed.
# Conflicts: # packages/packages.json # packages/valory/agents/trader/aea-config.yaml # packages/valory/services/trader/service.yaml # packages/valory/services/trader_pearl/service.yaml # packages/valory/skills/decision_maker_abci/skill.yaml # packages/valory/skills/market_manager_abci/skill.yaml # packages/valory/skills/trader_abci/skill.yaml # packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml
Reported error: > Issue: [B105:hardcoded_password_string] Possible hardcoded password: 'sell_outcome_token_done'
Do not allow merging on `main` from any branch other than `develop`. [no ci]
Update the bets so that we map all the investments per vote
# Conflicts: # packages/packages.json # packages/valory/agents/trader/aea-config.yaml # packages/valory/services/trader/service.yaml # packages/valory/services/trader_pearl/service.yaml # packages/valory/skills/decision_maker_abci/skill.yaml # packages/valory/skills/trader_abci/skill.yaml # packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml
@@ -77,7 +77,7 @@ def _build_approval_tx(self) -> WaitableConditionType: | |||
status = yield from self.build_approval_tx( | |||
self.return_amount, | |||
self.market_maker_contract_address, | |||
self.market_maker_contract_address, | |||
self.sampled_bet.get_outcome(self.outcome_index), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a string, not a token address.
if previous_vote == 0: | ||
return self.sampled_bet.invested_amount_yes | ||
|
||
else: | ||
return self.sampled_bet.invested_amount_no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot know if index 0 will always be "yes".
You could extract the following logic to a separate method and reuse it here:
trader/packages/valory/skills/market_manager_abci/bets.py
Lines 290 to 294 in a3aae14
if vote is None: | |
return False | |
vote_name = self.get_outcome(vote) | |
to_update = self.investments[vote_name] |
…ement.py fix: replace approval tx with status Co-authored-by: Adamantios Zaras <[email protected]>
…ement.py Co-authored-by: Adamantios Zaras <[email protected]>
queue_status: QueueStatus = QueueStatus.FRESH | ||
# a mapping from vote to investment amounts | ||
investments: Dict[str, List[int]] = dataclasses.field(default_factory=dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invesments will be treated as a dataclass when decoding is being done, a hook will have to be setup for this or will have to make investments as a data class
|
||
def __post_init__(self) -> None: | ||
"""Post initialization to adjust the values.""" | ||
self._validate() | ||
self._cast() | ||
self._check_usefulness() | ||
self.investments = {self.yes: [], self.no: []} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.investments = {self.yes: [], self.no: []} | |
if self.outcomes: | |
self.investments = {self.yes: [], self.no: []} | |
else: | |
self.investments = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decoder will have to updated to check for new missing arguments
48d1f1e
to
b8190fc
Compare
No description provided.