Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/coinbase-agentkit/coinbase_agentkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
wallet_action_provider,
weth_action_provider,
wow_action_provider,
compass_action_provider,
)
from .agentkit import AgentKit, AgentKitConfig
from .wallet_providers import (
Expand Down Expand Up @@ -52,6 +53,7 @@
"allora_action_provider",
"cdp_api_action_provider",
"compound_action_provider",
"compass_action_provider",
"erc20_action_provider",
"hyperbolic_action_provider",
"morpho_action_provider",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
basename_action_provider,
)
from .cdp.cdp_api_action_provider import CdpApiActionProvider, cdp_api_action_provider
from .cdp.cdp_wallet_action_provider import CdpWalletActionProvider, cdp_wallet_action_provider
from .compass.compass_action_provider import CompassActionProvider, compass_action_provider
from .compound.compound_action_provider import CompoundActionProvider, compound_action_provider
from .erc20.erc20_action_provider import ERC20ActionProvider, erc20_action_provider
from .hyperboliclabs.hyperbolic_action_provider import (
Expand Down Expand Up @@ -40,6 +42,8 @@
"cdp_api_action_provider",
"CompoundActionProvider",
"compound_action_provider",
"CompassActionProvider",
"compass_action_provider",
"ERC20ActionProvider",
"erc20_action_provider",
"HyperbolicActionProvider",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Compass action provider for lending protocol interactions."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from langchain_compass.toolkits import LangchainCompassToolkit

from coinbase_agentkit.action_providers.action_provider import (
Action,
ActionProvider,
TWalletProvider,
)
from coinbase_agentkit.network import (
CHAIN_ID_TO_NETWORK_ID,
NETWORK_ID_TO_CHAIN,
Network,
arbitrum,
base,
mainnet,
)
from coinbase_agentkit.wallet_providers import EvmWalletProvider

SUPPORTED_NETWORKS = [base, arbitrum, mainnet]


class CompassActionProvider(ActionProvider[EvmWalletProvider]):
"""Provides actions for interacting with Morpho Vaults."""

def __init__(self):
super().__init__("compass", [])

def get_actions(self, wallet_provider: TWalletProvider) -> list[Action]:
"""Get all Compass actions."""
return LangchainCompassToolkit().get_tools()

def supports_network(self, network: Network) -> bool:
"""Check if this provider supports the given network."""
if network.chain_id is None:
network.network_id = CHAIN_ID_TO_NETWORK_ID[network.chain_id]
if network.network_id:
return NETWORK_ID_TO_CHAIN[network.network_id] in [base, arbitrum, mainnet]
return False


def compass_action_provider() -> CompassActionProvider:
"""Create a new Compass action provider.

Returns:
CompassActionProvider: A new Compass action provider instance.

"""
return CompassActionProvider()
2 changes: 2 additions & 0 deletions python/coinbase-agentkit/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ dependencies = [
"ecdsa>=0.19.0,<0.20",
"pyjwt[crypto]>=2.10.1,<3",
"jsonschema>=4.23.0,<5",
"langchain-compass>=0.2.27",
"numpy>=2.2.4",
]

[tool.hatch.metadata]
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Compass Toolkit Tests

from unittest.mock import MagicMock

import pytest

from coinbase_agentkit.action_providers.compass.compass_action_provider import (
compass_action_provider,
)

mock_wallet = MagicMock()
actions = compass_action_provider().get_actions(wallet_provider=mock_wallet)


@pytest.mark.parametrize("action", actions)
def test_compass_tools(action):
"""Test calls every single tool with default args."""
action.invoke(input=action.example_args)
2 changes: 2 additions & 0 deletions python/examples/langchain-cdp-server-chatbot/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
pyth_action_provider,
wallet_action_provider,
weth_action_provider,
compass_action_provider,
)
from coinbase_agentkit_langchain import get_langchain_tools
from dotenv import load_dotenv
Expand Down Expand Up @@ -62,6 +63,7 @@ def initialize_agent(config: CdpEvmServerWalletProviderConfig):
wallet_action_provider(),
weth_action_provider(),
allora_action_provider(),
compass_action_provider(),
],
)
)
Expand Down