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

feat: Improve ability to distinguish between networks, assets, and trade types #61

Merged
merged 6 commits into from
Dec 6, 2024
Merged
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
6 changes: 3 additions & 3 deletions cdp-agentkit-core/cdp_agentkit_core/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ def get_all_cdp_actions() -> list[type[CdpAction]]:
CDP_ACTIONS = get_all_cdp_actions()

__all__ = [
"CDP_ACTIONS",
"CdpAction",
"GetWalletDetailsAction",
"DeployNftAction",
"DeployTokenAction",
"GetBalanceAction",
"GetWalletDetailsAction",
"MintNftAction",
"RegisterBasenameAction",
"RequestFaucetFundsAction",
"TradeAction",
"TransferAction",
"WowCreateTokenAction",
"WowBuyTokenAction",
"WowCreateTokenAction",
"WowSellTokenAction",
"CDP_ACTIONS",
]
5 changes: 3 additions & 2 deletions cdp-agentkit-core/cdp_agentkit_core/actions/deploy_nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from cdp_agentkit_core.actions import CdpAction

DEPLOY_NFT_PROMPT = """
This tool will deploy an NFT (ERC-721) contract onchain from the wallet. It takes the name of the NFT collection, the symbol of the NFT collection, and the base URI for the token metadata as inputs."""

This tool will deploy an NFT (ERC-721) contract onchain from the wallet.
It takes the name of the NFT collection, the symbol of the NFT collection, and the base URI for the token metadata as inputs.
"""

class DeployNftInput(BaseModel):
"""Input argument schema for deploy NFT action."""
Expand Down
3 changes: 2 additions & 1 deletion cdp-agentkit-core/cdp_agentkit_core/actions/deploy_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from cdp_agentkit_core.actions import CdpAction

DEPLOY_TOKEN_PROMPT = """
This tool will deploy an ERC20 token smart contract. It takes the token name, symbol, and total supply as input. The token will be deployed using the wallet's default address as the owner and initial token holder.
This tool will deploy an ERC20 token smart contract. It takes the token name, symbol, and total supply as input.
The token will be deployed using the wallet's default address as the owner and initial token holder.
"""


Expand Down
5 changes: 3 additions & 2 deletions cdp-agentkit-core/cdp_agentkit_core/actions/get_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from cdp_agentkit_core.actions import CdpAction

GET_BALANCE_PROMPT = """
This tool will get the balance of all the addresses in the wallet for a given asset. It takes the asset ID as input. Always use `eth` for the native asset ETH and `usdc` for USDC."""

This tool will get the balance of all the addresses in the wallet for a given asset.
It takes the asset ID as input. Always use 'eth' for the native asset ETH and 'usdc' for USDC.
"""

class GetBalanceInput(BaseModel):
"""Input argument schema for get balance action."""
Expand Down
6 changes: 4 additions & 2 deletions cdp-agentkit-core/cdp_agentkit_core/actions/mint_nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
from cdp_agentkit_core.actions import CdpAction

MINT_NFT_PROMPT = """
This tool will mint an NFT (ERC-721) to a specified destination address onchain via a contract invocation. It takes the contract address of the NFT onchain and the destination address onchain that will receive the NFT as inputs. Do not use the contract address as the destination address. If you are unsure of the destination address, please ask the user before proceeding."""

This tool will mint an NFT (ERC-721) to a specified destination address onchain via a contract invocation.
It takes the contract address of the NFT onchain and the destination address onchain that will receive the NFT as inputs.
Do not use the contract address as the destination address. If you are unsure of the destination address, please ask the user before proceeding.
"""

class MintNftInput(BaseModel):
"""Input argument schema for mint NFT action."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# Constants
REGISTER_BASENAME_PROMPT = """
This tool will register a Basename for the agent. The agent should have a wallet associated to register a Basename.
When your network ID is `base-mainnet`, the name must end with .base.eth and when your network ID is `base-sepolia`, it must ends with .basetest.eth.
When your network ID is 'base-mainnet' (also sometimes known simply as 'base'), the name must end with .base.eth, and when your network ID is 'base-sepolia', it must ends with .basetest.eth.
Do not suggest any alternatives and never try to register a Basename with another postfix. The prefix of the name must be unique so if the registration of the
Basename fails, you should prompt to try again with a more unique name."""
Basename fails, you should prompt to try again with a more unique name.
"""

# Contract addresses
BASENAMES_REGISTRAR_CONTROLLER_ADDRESS_MAINNET = "0x4cCb0BB02FCABA27e82a56646E81d8c5bC4119a5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

REQUEST_FAUCET_FUNDS_PROMPT = """
This tool will request test tokens from the faucet for the default address in the wallet. It takes the wallet and asset ID as input.
If no asset ID is provided the faucet defaults to ETH. Faucet is only allowed on `base-testnet` and can only provide asset ID `eth` or `usdc`.
If no asset ID is provided the faucet defaults to ETH. Faucet is only allowed on 'base-sepolia' and can only provide asset ID 'eth' or 'usdc'.
You are not allowed to faucet with any other network or asset ID. If you are on another network, suggest that the user sends you some ETH
from another wallet and provide the user with your wallet details."""
from another wallet and provide the user with your wallet details.
"""


class RequestFaucetFundsInput(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def get_all_twitter_actions() -> list[type[TwitterAction]]:
TWITTER_ACTIONS = get_all_twitter_actions()

__all__ = [
"TwitterAction",
"TWITTER_ACTIONS",
"AccountDetailsAction",
"AccountMentionsAction",
"PostTweetAction",
"PostTweetReplyAction",
"TWITTER_ACTIONS",
"TwitterAction",
]
13 changes: 12 additions & 1 deletion cdp-agentkit-core/cdp_agentkit_core/actions/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
from cdp_agentkit_core.actions import CdpAction

TRADE_PROMPT = """
This tool will trade a specified amount of a from asset to a to asset for the wallet. It takes the the amount of the from asset to trade, the from asset ID to trade, and the to asset ID to receive from the trade as inputs. Trades are only supported on Mainnets (e.g. `base-mainnet`, `ethereum-mainnet`). Never allow trades on any other network."""
This tool will trade a specified amount of a 'from asset' to a 'to asset' for the wallet.
It takes the following inputs:
- The amount of the 'from asset' to trade
- The from asset ID to trade
- The asset ID to receive from the trade
Important notes:
- Trades are only supported on mainnet networks (ie, 'base-mainnet', 'base', 'ethereum-mainnet', 'ethereum', etc.)
- Never allow trades on any non-mainnet network (ie, 'base-sepolia', 'ethereum-sepolia', etc.)
- When selling a native asset (e.g. 'eth' on base-mainnet), ensure there is sufficient balance to pay for the trade AND the gas cost of this trade
"""


class TradeInput(BaseModel):
Expand Down
15 changes: 14 additions & 1 deletion cdp-agentkit-core/cdp_agentkit_core/actions/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@
from cdp_agentkit_core.actions import CdpAction

TRANSFER_PROMPT = """
This tool will transfer an asset from the wallet to another onchain address. It takes the amount, the asset ID to transfer, the destination to send the funds (either an onchain address, an ENS `example.eth`, or Basename `example.base.eth`), and whether to do a gasless transfer as inputs. The gasless option is available on `base-sepolia` and `base-mainnet` networks for `usdc` asset only. Always use the gasless option when it is available. Always use the asset ID `usdc` when attempting to transfer USDC. Always ensure that you have enough balance of the input asset ID to complete the transfer."""
This tool will transfer an asset from the wallet to another onchain address.
It takes the following inputs:
- amount: The amount to transfer
- assetId: The asset ID to transfer
- destination: Where to send the funds (can be an onchain address, ENS 'example.eth', or Basename 'example.base.eth')
- gasless: Whether to do a gasless transfer
Important notes:
- Gasless transfers are only available on base-sepolia and base-mainnet (base) networks for 'usdc' asset
- Always use gasless transfers when available
- Always use asset ID 'usdc' when transferring USDC
- Ensure sufficient balance of the input asset before transferring
- When sending native assets (e.g. 'eth' on base-mainnet), ensure there is sufficient balance for the transfer itself AND the gas cost of this transfer
"""

class TransferInput(BaseModel):
"""Input argument schema for transfer action."""
Expand Down
18 changes: 16 additions & 2 deletions cdp-agentkit-core/cdp_agentkit_core/actions/wow/buy_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,21 @@
from cdp_agentkit_core.actions.wow.utils import get_buy_quote

WOW_BUY_TOKEN_PROMPT = """
This tool will buy a Zora Wow ERC20 memecoin with ETH. This tool takes the WOW token contract address, the address to receive the tokens, and the amount of ETH to spend (in wei, meaning "1" is 1 wei or 0.000000000000000001 of ETH). The amount is a string and cannot have any decimal points, since the unit of measurement is wei. Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action. The minimum to buy is 100000000000000 wei which is 0.0000001 ether. It is only supported on Base Sepolia and Base Mainnet.
This tool can only be used to buy a Zora Wow ERC20 memecoin with ETH. Do not use this tool for any other purpose, or trading other assets.
Inputs:
- WOW token contract address
- Address to receive the tokens
- Amount of ETH to spend (in wei)
Important notes:
- The amount is a string and cannot have any decimal points, since the unit of measurement is wei.
- Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action.
- 1 wei = 0.000000000000000001 ETH
- Minimum purchase amount is 100000000000000 wei (0.0000001 ETH)
- Only supported on the following networks:
- Base Sepolia (ie, 'base-sepolia')
- Base Mainnet (ie, 'base', 'base-mainnnet')
"""


Expand Down Expand Up @@ -57,7 +71,7 @@ def wow_buy_token(wallet: Wallet, contract_address: str, amount_eth_in_wei: str)
"recipient": wallet.default_address.address_id,
"refundRecipient": wallet.default_address.address_id,
"orderReferrer": "0x0000000000000000000000000000000000000000",
"expectedMarketType": has_graduated and "1" or "0",
"expectedMarketType": (has_graduated and "1") or "0",
"minOrderSize": min_tokens,
"sqrtPriceLimitX96": "0",
"comment": "",
Expand Down
13 changes: 12 additions & 1 deletion cdp-agentkit-core/cdp_agentkit_core/actions/wow/create_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
)

WOW_CREATE_TOKEN_PROMPT = """
This tool will create a Zora Wow ERC20 memecoin using the WoW factory. This tool takes the token name, token symbol, and optionally a token URI containing metadata about the token. It uses a bonding curve so there is no need to add liquidity to the pool upfront. It is only supported on Base Sepolia and Base Mainnet.
This tool can only be used to create a Zora Wow ERC20 memecoin using the WoW factory. Do not use this tool for any other purpose, or creating other types of tokens.
Inputs:
- Token name (e.g. WowCoin)
- Token symbol (e.g. WOW)
- Token URI (optional) - Contains metadata about the token
Important notes:
- Uses a bonding curve - no upfront liquidity needed
- Only supported on the following networks:
- Base Sepolia (ie, 'base-sepolia')
- Base Mainnet (ie, 'base', 'base-mainnnet')
"""


Expand Down
15 changes: 14 additions & 1 deletion cdp-agentkit-core/cdp_agentkit_core/actions/wow/sell_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@
from cdp_agentkit_core.actions.wow.utils import get_sell_quote

WOW_SELL_TOKEN_PROMPT = """
This tool will sell a Zora Wow ERC20 memecoin for ETH. This tool takes the WOW token contract address, and the amount of tokens to sell (in wei, meaning 1 is 1 wei or 0.000000000000000001 of the token). The minimum to sell is 100000000000000 wei which is 0.0000001 ether. The amount is a string and cannot have any decimal points, since the unit of measurement is wei. Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action. It is only supported on Base Sepolia and Base Mainnet.
This tool can only be used to sell a Zora Wow ERC20 memecoin for ETH. Do not use this tool for any other purpose, or trading other assets.
Inputs:
- WOW token contract address
- Amount of tokens to sell (in wei)
Important notes:
- The amount is a string and cannot have any decimal points, since the unit of measurement is wei.
- Make sure to use the exact amount provided, and if there's any doubt, check by getting more information before continuing with the action.
- 1 wei = 0.000000000000000001 ETH
- Minimum purchase amount is 100000000000000 wei (0.0000001 ETH)
- Only supported on the following networks:
- Base Sepolia (ie, 'base-sepolia')
- Base Mainnet (ie, 'base', 'base-mainnnet')
"""


Expand Down
8 changes: 4 additions & 4 deletions cdp-agentkit-core/cdp_agentkit_core/actions/wow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def get_buy_quote(network_id: str, token_address: str, amount_eth_in_wei: str):
"""
has_graduated = get_has_graduated(network_id, token_address)
token_quote = (
has_graduated
and (get_uniswap_quote(network_id, token_address, amount_eth_in_wei, "buy")).amount_out
(has_graduated
and (get_uniswap_quote(network_id, token_address, amount_eth_in_wei, "buy")).amount_out)
or SmartContract.read(
network_id,
token_address,
Expand All @@ -56,8 +56,8 @@ def get_sell_quote(network_id: str, token_address: str, amount_tokens_in_wei: st
"""
has_graduated = get_has_graduated(network_id, token_address)
token_quote = (
has_graduated
and (get_uniswap_quote(network_id, token_address, amount_tokens_in_wei, "sell")).amount_out
(has_graduated
and (get_uniswap_quote(network_id, token_address, amount_tokens_in_wei, "sell")).amount_out)
or SmartContract.read(
network_id,
token_address,
Expand Down
15 changes: 13 additions & 2 deletions cdp-langchain/examples/chatbot/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ def initialize_agent():
llm,
tools=tools,
checkpointer=memory,
state_modifier="You are a helpful agent that can interact onchain using the Coinbase Developer Platform Agentkit. You are empowered to interact onchain using your tools. If you ever need funds, you can request them from the faucet if you are on network ID `base-sepolia`. If not, you can provide your wallet details and request funds from the user. If someone asks you to do something you can't do with your currently available tools, you must say so, and encourage them to implement it themselves using the CDP SDK + Agentkit, recommend they go to docs.cdp.coinbase.com for more informaton. Be concise and helpful with your responses. Refrain from restating your tools' descriptions unless it is explicitly requested.",
state_modifier=(
"You are a helpful agent that can interact onchain using the Coinbase Developer Platform AgentKit. "
"You are empowered to interact onchain using your tools. If you ever need funds, you can request "
"them from the faucet if you are on network ID 'base-sepolia'. If not, you can provide your wallet "
"details and request funds from the user. Before executing your first action, get the wallet details "
"to see what network you're on. If there is a 5XX (internal) HTTP error code, ask the user to try "
"again later. If someone asks you to do something you can't do with your currently available tools, "
"you must say so, and encourage them to implement it themselves using the CDP SDK + Agentkit, "
"recommend they go to docs.cdp.coinbase.com for more information. Be concise and helpful with your "
"responses. Refrain from restating your tools' descriptions unless it is explicitly requested."
),

), config


Expand Down Expand Up @@ -92,7 +103,7 @@ def run_chat_mode(agent_executor, config):
print("Starting chat mode... Type 'exit' to end.")
while True:
try:
user_input = input("\nUser: ")
user_input = input("\nPrompt: ")
if user_input.lower() == "exit":
break

Expand Down
2 changes: 1 addition & 1 deletion twitter-langchain/examples/chatbot/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def run_chat_mode(agent_executor, config):
print("Starting chat mode... Type 'exit' to end.")
while True:
try:
user_input = input("\nUser: ")
user_input = input("\nPrompt: ")
if user_input.lower() == "exit":
break

Expand Down
Loading