Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ SOLANA_PRIVATE_KEY=
DISCORD_TOKEN=
XAI_API_KEY=
TOGETHER_API_KEY=
DEBRIDGE_ACCESS_KEY=

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Each plugin has its own configuration options that can be specified in the agent
- Custom slippage settings
- Token swaps via Sonic DEX
- Network switching (mainnet/testnet)

- DeBridge - Bridge tokens across multiple chains
- EternalAI
- Transform agents to smart contracts
- Deploy on 10+ blockchains
Expand Down
4 changes: 3 additions & 1 deletion agents/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
"name": "evm",
"network": "ethereum"
},

{
"name": "debridge"
},
{
"name": "discord",
"message_read_count": 10,
Expand Down
126 changes: 122 additions & 4 deletions poetry.lock

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions src/actions/debridge_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import logging
from src.action_handler import register_action

logger = logging.getLogger("actions.debridge_actions")

@register_action("create-bridge-tx")
def create_bridge_tx(agent, **kwargs):
"""Create Bridge TX using Debridge"""
try:
required_args = ['srcChainId', 'srcChainTokenIn', 'srcChainTokenInAmount', 'dstChainId', 'dstChainTokenOut', 'dstChainTokenOutAmount', 'dstChainTokenOutRecipient', 'srcChainOrderAuthorityAddress', 'dstChainOrderAuthorityAddress']
for arg in required_args:
if arg not in kwargs:
logger.error(f"Missing required argument: {arg}")
return None

response = agent.connection_manager.connections["debridge"].create_bridge_tx(
srcChainId=kwargs['srcChainId'],
srcChainTokenIn=kwargs['srcChainTokenIn'],
srcChainTokenInAmount=kwargs['srcChainTokenInAmount'],
dstChainId=kwargs['dstChainId'],
dstChainTokenOut=kwargs['dstChainTokenOut'],
dstChainTokenOutAmount=kwargs['dstChainTokenOutAmount'],
dstChainTokenOutRecipient=kwargs['dstChainTokenOutRecipient'],
srcChainOrderAuthorityAddress=kwargs['srcChainOrderAuthorityAddress'],
dstChainOrderAuthorityAddress=kwargs['dstChainOrderAuthorityAddress'],
affiliateFeeRecipient=kwargs.get('affiliateFeeRecipient'),
prependOperatingExpense=kwargs.get('prependOperatingExpense', True),
affiliateFeePercent=kwargs.get('affiliateFeePercent', 0)
)
return response
except Exception as e:
logger.error(f"Failed to create bridge transaction: {str(e)}")
return None

@register_action("get-order-status")
def get_order_status(agent, **kwargs):
"""Get order status using Debridge"""
try:
response = agent.connection_manager.connections["debridge"].get_order_status(
id=kwargs.get('id'),
hash=kwargs.get('hash')
)
return response
except Exception as e:
logger.error(f"Failed to get order status: {str(e)}")
return None

@register_action("get-order-details")
def get_order_details(agent, **kwargs):
"""Get order details using Debridge"""
try:
if 'id' not in kwargs:
logger.error("Missing required argument: id")
return None

response = agent.connection_manager.connections["debridge"].get_order_details(
id=kwargs['id']
)
return response
except Exception as e:
logger.error(f"Failed to get order details: {str(e)}")
return None

@register_action("cancel-tx")
def cancel_tx(agent, **kwargs):
"""Cancel transaction using Debridge"""
try:
if 'id' not in kwargs:
logger.error("Missing required argument: id")
return None

response = agent.connection_manager.connections["debridge"].cancel_tx(
id=kwargs['id']
)
return response
except Exception as e:
logger.error(f"Failed to cancel transaction: {str(e)}")
return None

@register_action("extcall-cancel-tx")
def extcall_cancel_tx(agent, **kwargs):
"""External call to cancel transaction using Debridge"""
try:
if 'id' not in kwargs:
logger.error("Missing required argument: id")
return None

response = agent.connection_manager.connections["debridge"].extcall_cancel_tx(
id=kwargs['id']
)
return response
except Exception as e:
logger.error(f"Failed to perform external call to cancel transaction: {str(e)}")
return None

@register_action("get-supported-chains")
def get_supported_chains(agent, **kwargs):
"""Get supported chains using Debridge"""
try:
response = agent.connection_manager.connections["debridge"].get_supported_chains()
return response
except Exception as e:
logger.error(f"Failed to get supported chains: {str(e)}")
return None

@register_action("get-token-list")
def get_token_list(agent, **kwargs):
"""Get token list using Debridge"""
try:
if 'chainId' not in kwargs:
logger.error("Missing required argument: chainId")
return None

response = agent.connection_manager.connections["debridge"].get_token_list(
chainId=kwargs['chainId']
)
return response
except Exception as e:
logger.error(f"Failed to get token list: {str(e)}")
return None

@register_action("execute-bridge-tx")
def execute_bridge_tx(agent, **kwargs):
"""Execute bridge transaction using Debridge"""
try:
if 'connection' not in kwargs:
logger.error("Missing required argument: connection")
return None

response = agent.connection_manager.connections["debridge"].execute_bridge_tx(
connection=kwargs['connection'],
compute_unit_price=kwargs.get('compute_unit_price', 200_000),
compute_unit_limit=kwargs.get('compute_unit_limit')
)
return response
except Exception as e:
logger.error(f"Failed to execute bridge transaction: {str(e)}")
return None
8 changes: 7 additions & 1 deletion src/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from src.connections.together_connection import TogetherAIConnection
from src.connections.evm_connection import EVMConnection
from src.connections.perplexity_connection import PerplexityConnection
from src.connections.debridge_connection import DebridgeConnection

logger = logging.getLogger("connection_manager")

Expand Down Expand Up @@ -73,6 +74,8 @@ def _class_name_to_type(class_name: str) -> Type[BaseConnection]:
return EVMConnection
elif class_name == "perplexity":
return PerplexityConnection
elif class_name == "debridge":
return DebridgeConnection
return None

def _register_connection(self, config_dic: Dict[str, Any]) -> None:
Expand All @@ -87,7 +90,10 @@ def _register_connection(self, config_dic: Dict[str, Any]) -> None:
try:
name = config_dic["name"]
connection_class = self._class_name_to_type(name)
connection = connection_class(config_dic)
if name == "debridge":
connection = DebridgeConnection(config_dic, self.connections)
else:
connection = connection_class(config_dic)
self.connections[name] = connection
except Exception as e:
logging.error(f"Failed to initialize connection {name}: {e}")
Expand Down
Loading