Skip to content
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

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open

Feat/sell #350

wants to merge 35 commits into from

Conversation

annasambrook
Copy link
Collaborator

No description provided.

# 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
Comment on lines 141 to 142
# 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)
Copy link
Collaborator

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
@annasambrook
Copy link
Collaborator Author

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
@Adamantios Adamantios changed the base branch from main to hotfix/staking-kpi-reachability December 5, 2024 13:23
Comment on lines +100 to +129
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above.

Comment on lines +160 to +167
# 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)
Copy link
Collaborator

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.

Comment on lines 58 to 61
# update the previous vote before calling the super method
SynchronizedData.update(
previous_vote=SynchronizedData.vote
)
Copy link
Collaborator

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.

annasambrook and others added 5 commits December 5, 2024 15:33
# 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'
Adamantios and others added 14 commits December 6, 2024 20:38
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),
Copy link
Collaborator

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.

Comment on lines +67 to +71
if previous_vote == 0:
return self.sampled_bet.invested_amount_yes

else:
return self.sampled_bet.invested_amount_no
Copy link
Collaborator

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:

if vote is None:
return False
vote_name = self.get_outcome(vote)
to_update = self.investments[vote_name]

annasambrook and others added 2 commits December 9, 2024 15:46
…ement.py


fix: replace approval tx with status

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)
Copy link
Collaborator

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: []}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.investments = {self.yes: [], self.no: []}
if self.outcomes:
self.investments = {self.yes: [], self.no: []}
else:
self.investments = {}

Copy link
Collaborator

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

@Adamantios Adamantios force-pushed the hotfix/staking-kpi-reachability branch from 48d1f1e to b8190fc Compare December 11, 2024 16:29
Base automatically changed from hotfix/staking-kpi-reachability to develop December 16, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants