-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
…are no integrations and only contracts
examples/uni_v3_lp/action_agent.py
Outdated
chain=chain, | ||
integrations=["UniswapV3"], | ||
id=id, | ||
chain="ethereum:sepolia:https://sepolia.infura.io/v3/765888cfa824440c8c0feb5b492abedd", |
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.
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) |
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.
Add an if
statement so if contracts and integrations are both None a error is raised
giza/agents/agent.py
Outdated
duplicates = set(contract_names) & set(integrations) | ||
if duplicates: | ||
duplicate_names = ", ".join(duplicates) | ||
raise ValueError( |
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.
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": |
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.
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, |
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.
deadline: int | None = None
from giza.agents.integrations.uniswap.pool import Pool | ||
|
||
|
||
class PoolFactory: |
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.
Docstrings and logging
from ape.contracts import ContractInstance | ||
|
||
|
||
class Quoter: |
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.
Docstrings, None
type hints and logging
from giza.agents.integrations.uniswap.router import Router | ||
|
||
|
||
class Uniswap: |
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.
Docstrings, typhints and logging
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.
Missing docstrings and typehints, for utils no logging is needed if you feel like it
giza/agents/integration.py
Outdated
@@ -0,0 +1,13 @@ | |||
from ape.api import AccountAPI | |||
|
|||
import giza.agents.integrations.uniswap.uniswap as uniswap_module |
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.
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
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.
Well done man!
Agents can accept protocol integrations as input. The contracts parameter is now optional.