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

integrations compatible with agent #57

Merged
merged 3 commits into from
Jun 12, 2024
Merged

integrations compatible with agent #57

merged 3 commits into from
Jun 12, 2024

Conversation

jwarmuz99
Copy link
Contributor

Agents can accept protocol integrations as input. The contracts parameter is now optional.

@jwarmuz99 jwarmuz99 requested review from Gonmeso and franalgaba June 7, 2024 12:20
chain=chain,
integrations=["UniswapV3"],
id=id,
chain="ethereum:sepolia:https://sepolia.infura.io/v3/765888cfa824440c8c0feb5b492abedd",
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the URL as it might be a private RPC node

self.chain = chain
self.account = account
self._check_passphrase_in_env()
self._check_or_create_account()
self.contract_handler = ContractHandler(contracts, integrations)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an if statement so if contracts and integrations are both None a error is raised

duplicates = set(contract_names) & set(integrations)
if duplicates:
duplicate_names = ", ".join(duplicates)
raise ValueError(
Copy link
Contributor

Choose a reason for hiding this comment

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

For future reference, lets create a custom exception for this

@staticmethod
def from_name(name: str, sender: AccountAPI) -> uniswap_module.Uniswap:
match name:
case "UniswapV3":
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that it would be better to have an enum for this, maybe open an issue and will deal with this later

amount1Desired: int,
amount0Min: int = 0,
amount1Min: int = 0,
deadline: int = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

deadline: int | None = None

from giza.agents.integrations.uniswap.pool import Pool


class PoolFactory:
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstrings and logging

from ape.contracts import ContractInstance


class Quoter:
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstrings, None type hints and logging

from giza.agents.integrations.uniswap.router import Router


class Uniswap:
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstrings, typhints and logging

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing docstrings and typehints, for utils no logging is needed if you feel like it

@@ -0,0 +1,13 @@
from ape.api import AccountAPI

import giza.agents.integrations.uniswap.uniswap as uniswap_module
Copy link
Contributor

Choose a reason for hiding this comment

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

Create an __init__.py inside integrations which imports Uniswap class.

__init__.py

from import giza.agents.integrations.uniswap.uniswap import Uniswap

__all__ = ["Uniswap"]

New import:

from giza.agents.integrations import Uniswap

Another suggestion could be to call all the integration where the main integration is with a common name like core.py or integration_handler.py so all the new integrations could be referenced the same way

from giza.agents.integrations.uniswap.core import UniswapV3
from giza.agents.integrations.enzyme.core import Enzyme

…ract names, assets included in toml file, fixed typing
Copy link
Contributor

@Gonmeso Gonmeso left a comment

Choose a reason for hiding this comment

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

Well done man!

@Gonmeso Gonmeso merged commit 70ca92a into main Jun 12, 2024
1 check passed
@Gonmeso Gonmeso deleted the feat/integrations branch June 12, 2024 13:54
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