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

Fix: Funding job to send amount upto the topup #637

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

OjusWiZard
Copy link
Member

Proposed changes

  • Funding job only send enough amount to reach the fund_requirements, and sends less if the balance is lower.
  • Funding job counts the balance of wrapped asset along with native asset for checking with threshold
  • [FUNDING_JOB] tagged logs in the funding job

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Comment on lines +1528 to +1534
if asset_address == ZERO_ADDRESS:
# also count the balance of the wrapped native asset
safe_balance += get_asset_balance(
ledger_api=ledger_api,
contract_address=WRAPPED_NATIVE_ASSET.get(chain, asset_address),
address=chain_data.multisig,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this approach not taken into account also for the agent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because in the case of Agent EOA, the agent doesn't swap xDAI for wxDAI and we don't want to it to happen that someone send wxDAI to the Agent EOA and the funding job no long funds xDAI in it, failing the agent to make transactions anymore.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems quite custom logic, but ok.

@@ -1491,19 +1491,25 @@ def fund_service_single_chain( # pylint: disable=too-many-arguments,too-many-lo
address=key.address,
)
self.logger.info(
f"Agent {key.address} Asset: {asset_address} balance: {agent_balance}"
f"[FUNDING_JOB] Agent {key.address} Asset: {asset_address} balance: {agent_balance}"
)
if agent_fund_threshold > 0:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this check not performed in safe as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really see why we have this check. agent_fund_threshold will always be passed as positive without any programming error

Copy link
Collaborator

Choose a reason for hiding this comment

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

Me neither. Assuming the template has nonnegative values for the fund requirement, if we set, e.g. 0 fund requirements for USDC, then the condition agent_balance < agent_fund_threshold will not be triggered anyways...

@jmoreira-valory jmoreira-valory merged commit 75b3c78 into feature/modius Dec 31, 2024
4 of 5 checks passed
@OjusWiZard OjusWiZard deleted the fix/funding-amount-diff branch December 31, 2024 16:41
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.

2 participants