Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-agarwal-coinbase committed Nov 7, 2024
1 parent 3695bc1 commit 0a1c673
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
12 changes: 12 additions & 0 deletions cdp-agentkit-core/cdp_agentkit_core/actions/uniswap_v3/get_pool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from collections.abc import Callable

from cdp import SmartContract
from pydantic import BaseModel, Field

from cdp_agentkit_core.actions.cdp_action import CdpAction
from cdp_agentkit_core.actions.uniswap_v3.constants import (
UNISWAP_V3_FACTORY_ABI,
get_contract_address,
Expand Down Expand Up @@ -56,3 +59,12 @@ def uniswap_v3_get_pool(network_id: str, token_a: str, token_b: str, fee: str) -
)

return f"Pool contract address for {token_a} and {token_b} with fee {fee} on network {network_id} is {pool_address}."


class UniswapV3GetPoolAction(CdpAction):
"""Uniswap V3 get pool action."""

name: str = "uniswap_v3_get_pool"
description: str = UNISWAP_V3_GET_POOL_PROMPT
args_schema: type[BaseModel] | None = UniswapV3GetPoolInput
func: Callable[..., str] = uniswap_v3_get_pool
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from collections.abc import Callable

from cdp import SmartContract
from pydantic import BaseModel, Field

from cdp_agentkit_core.actions.cdp_action import CdpAction
from cdp_agentkit_core.actions.uniswap_v3.constants import (
UNISWAP_V3_POOL_ABI,
)
Expand Down Expand Up @@ -43,3 +46,12 @@ def uniswap_v3_get_pool_liquidity(network_id: str, pool_contract_address: str) -
)

return f"Liquidity for pool {pool_contract_address} is {liquidity}."


class UniswapV3GetPoolLiquidityAction(CdpAction):
"""Uniswap V3 get pool liquidity action."""

name: str = "uniswap_v3_get_pool_liquidity"
description: str = UNISWAP_V3_GET_POOL_LIQUIDITY_PROMPT
args_schema: type[BaseModel] | None = UniswapV3GetPoolLiquidityInput
func: Callable[..., str] = uniswap_v3_get_pool_liquidity
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from collections.abc import Callable

from cdp import SmartContract
from pydantic import BaseModel, Field

from cdp_agentkit_core.actions.cdp_action import CdpAction
from cdp_agentkit_core.actions.uniswap_v3.constants import (
UNISWAP_V3_POOL_ABI,
)
Expand Down Expand Up @@ -53,3 +56,12 @@ def uniswap_v3_get_pool_observe(
)

return f"Observations for pool {pool_contract_address} are {observations}."


class UniswapV3GetPoolObserveAction(CdpAction):
"""Uniswap V3 get pool observe action."""

name: str = "uniswap_v3_get_pool_observe"
description: str = UNISWAP_V3_GET_POOL_OBSERVE_PROMPT
args_schema: type[BaseModel] | None = UniswapV3GetPoolObserveInput
func: Callable[..., str] = uniswap_v3_get_pool_observe
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from collections.abc import Callable

from cdp import SmartContract
from pydantic import BaseModel, Field

from cdp_agentkit_core.actions.cdp_action import CdpAction
from cdp_agentkit_core.actions.uniswap_v3.constants import (
UNISWAP_V3_POOL_ABI,
)
Expand Down Expand Up @@ -48,3 +51,12 @@ def uniswap_v3_get_pool_slot0(network_id: str, pool_contract_address: str) -> st
)

return f"Slot0 for pool {pool_contract_address} is {slot0}."


class UniswapV3GetPoolSlot0Action(CdpAction):
"""Uniswap V3 get pool slot0 action."""

name: str = "uniswap_v3_get_pool_slot0"
description: str = UNISWAP_V3_GET_POOL_SLOT0_PROMPT
args_schema: type[BaseModel] | None = UniswapV3GetPoolSlot0Input
func: Callable[..., str] = uniswap_v3_get_pool_slot0
1 change: 1 addition & 0 deletions cdp-langchain/examples/chatbot/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Configure a file to persist the agent's CDP MPC Wallet Data.
wallet_data_file = "wallet_data.txt"


def initialize_agent():
"""Initialize the agent with CDP Agentkit."""
# Initialize LLM.
Expand Down
4 changes: 0 additions & 4 deletions cdp-langchain/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0a1c673

Please sign in to comment.