Skip to content

Commit

Permalink
Merge pull request #279 from crestalnetwork/feat/owner-mode
Browse files Browse the repository at this point in the history
Fix: some small fixes
  • Loading branch information
hyacinthus authored Feb 23, 2025
2 parents b125c6a + 0f86132 commit ad1b52d
Show file tree
Hide file tree
Showing 31 changed files with 847 additions and 1,323 deletions.
37 changes: 14 additions & 23 deletions app/core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ def agent_prompt(agent: Agent, agent_data: AgentData) -> str:
prompt = "# SYSTEM PROMPT\n\n"
if config.system_prompt:
prompt += config.system_prompt + "\n\n"
prompt += "You are an autonomous AI agent in an opensource platform 'IntentKit'.\n"
prompt += "You are an ai agent built using IntentKit.\n"
prompt += "Your tools are called 'skills'.\n"
prompt += "If your skill fails to execute due to a technical error ask the user to try again later. If someone asks you to do something you can't do with your currently available skills, you must say so, recommend them to submit their feedback to the IntentKit team at https://github.com/crestalnetwork/intentkit. Be concise and helpful with your responses. Refrain from restating your skills' descriptions unless it is explicitly requested.\n"
if agent.name:
prompt += f"Your name is {agent.name}.\n"
if agent.ticker:
prompt += f"Your ticker symbol is {agent.ticker}.\n"
if agent_data and agent.cdp_enabled:
if agent_data.cdp_wallet_data:
if agent_data:
if agent_data.cdp_wallet_data and agent.cdp_enabled:
wallet_data = json.loads(agent_data.cdp_wallet_data)
prompt += f"Your CDP wallet address in {agent.cdp_network_id} is {wallet_data['default_address_id']} .\n"
prompt += (
"## Crypto Wallet\n\n"
"Wallet addresses are public information. If someone asks for your default wallet, current wallet, "
"personal wallet, crypto wallet, or wallet public address, don't use any address in message history, "
"you must use the 'get_wallet_details' tool to retrieve your wallet address every time."
)
prompt += "When you get balance from tools, or pass amount to tools, don't forget they have decimals.\n"
prompt += "USDC and USDT has 6 decimals, you must divide the amount you get by 10^6, multiply 10^6 when passing to tools.\n"
prompt += "Other currencies include native ETH usually has 18 decimals, you need divide or multiply 10^18.\n"
if agent.cdp_network_id == "base-mainnet":
prompt += "The USDC contract address in base-mainnet is 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\n"
prompt += "When you get balance from tools, or pass amount to tools, don't forget they have decimals.\n"
prompt += "USDC and USDT has 6 decimals, you must divide the amount you get by 10^6, multiply 10^6 when passing to tools.\n"
prompt += "Other currencies include native ETH usually has 18 decimals, you need divide or multiply 10^18.\n"
if agent_data.twitter_id:
prompt += f"Your twitter id is {agent_data.twitter_id}, never reply or retweet yourself.\n"
if agent_data.twitter_username:
Expand All @@ -44,23 +51,7 @@ def agent_prompt(agent: Agent, agent_data: AgentData) -> str:
prompt += f"## Principles\n\n{agent.principles}\n\n"
if agent.prompt:
prompt += f"## Initial Rules\n\n{agent.prompt}\n\n"
elif agent.cdp_enabled:
prompt += (
"## Coinbase AgentKit Skills Guide\n\n"
"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-mainnet'. 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."
"\n\nWallet addresses are public information. If someone asks for your default wallet, current wallet, "
"personal wallet, crypto wallet, or wallet public address, don't use any address in message history, "
"you must use the 'get_wallet_details' tool to retrieve your wallet address every time."
)
if agent.enso_enabled:
if agent.enso_skills and len(agent.enso_skills) > 0:
prompt += """## ENSO Skills Guide\n\nYou are integrated with the Enso API. You can use enso_get_tokens to retrieve token information,
including APY, Protocol Slug, Symbol, Address, Decimals, and underlying tokens. When interacting with token amounts,
ensure to multiply input amounts by the token's decimal places and divide output amounts by the token's decimals.
Expand Down
116 changes: 29 additions & 87 deletions docs/skills/cdp.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,35 @@

## CDP AgentKit

All CDP Skills are supported by [AgentKit](https://github.com/coinbase/cdp-agentkit/).
All CDP Skills are supported by [AgentKit](https://github.com/coinbase/agentkit/).

AgentKit supports the following tools:

### Wallet Management
- `get_wallet_details` - Get detailed information about your MPC Wallet, including the wallet's address and current network.

- `get_balance` - Query token balances for specific assets in your wallet. Supports querying balances for any token using its asset ID (e.g., "eth", "usdc") or contract address.

- `request_faucet_funds` - Request test tokens from the [Base Sepolia faucet](https://portal.cdp.coinbase.com/products/faucet). Useful for testing and development on testnet.

- `address_reputation` - Check the reputation and risk assessment of any Ethereum address. Helps evaluate the trustworthiness of addresses you interact with.

### Asset Operations
- `transfer` - Transfer tokens between addresses. Features:
- Supports any ERC20 token or native asset (ETH)
- Accepts amount in standard units (e.g., "15", "0.000001")
- Destination can be an address, ENS name (example.eth), or Basename (example.base.eth)
- Supports gasless transfers for USDC on Base networks (base-sepolia and base-mainnet)

- `trade` - Execute token trades on supported DEXs (mainnet networks only). Allows trading between any supported assets by specifying:
- Amount to trade
- Source asset ID (e.g., "eth", "usdc", or contract address)
- Target asset ID

- `wrap_eth` - Convert ETH to WETH (Wrapped Ether) for DeFi compatibility. WETH is the ERC20 token version of ETH required by many DeFi protocols.

### Token Management
- `deploy_token` - Deploy custom [ERC-20](https://www.coinbase.com/learn/crypto-glossary/what-is-erc-20) token contracts. Specify:
- Token name
- Symbol
- Total supply
The deploying wallet becomes the owner and initial token holder.

- `deploy_contract` - Deploy any smart contract with custom bytecode and constructor arguments. Provides full flexibility for deploying any type of contract.

### NFT Operations
- `get_balance_nft` - Query NFT balances for specific collections. Check ownership of NFTs in any ERC721 contract.

- `mint_nft` - Mint NFTs from existing contracts. Useful for participating in NFT drops or creating new tokens in your own collections.

- `deploy_nft` - Deploy new NFT (ERC-721) contracts with customizable parameters:
- Collection name
- Symbol
- Base URI for token metadata

- `transfer_nft` - Transfer NFTs between addresses. Supports:
- Any ERC721 contract
- Transfer by token ID
- Custom source address
- Destination can be address, ENS, or Basename

### Base Name Service
- `register_basename` - Register a [Basename](https://www.base.org/names) for your wallet address. Basenames are human-readable identifiers for your wallet on Base network (e.g., "example.base.eth").

### Zora Wow Integration
- `wow_create_token` - Deploy a token using [Zora's Wow Launcher](https://wow.xyz/mechanics) with bonding curve (Base only). Specify:
- Token name
- Symbol
- Optional IPFS metadata URI

- `wow_buy_token` - Buy [Zora Wow](https://wow.xyz/) ERC-20 memecoins with ETH (Base only). Purchase tokens from existing Wow contracts.

- `wow_sell_token` - Sell [Zora Wow](https://wow.xyz/) ERC-20 memecoins for ETH (Base only). Specify:
- Contract address
- Amount in wei (1 wei = 0.000000000000000001 tokens)

### Superfluid Integration
- `superfluid_create_flow` - Create a continuous token streaming flow. Set up recurring payments by specifying:
- Recipient address
- Token address
- Flow rate (tokens per second in wei)

- `superfluid_update_flow` - Modify an existing token streaming flow. Adjust the flow rate of ongoing streams.

- `superfluid_delete_flow` - Stop and delete an existing token streaming flow. Terminate ongoing payment streams.

### Morpho Integration
- `morpho_deposit` - Deposit assets into Morpho's yield-generating vaults. Earn yield on your deposited tokens.

- `morpho_withdraw` - Withdraw assets from Morpho's yield-generating vaults. Access your deposited funds and earned yield.

### Pyth Network Integration
- `pyth_fetch_price` - Get real-time price data from Pyth Network oracles. Access accurate price feeds for various assets.

- `pyth_fetch_price_feed_id` - Retrieve price feed IDs for Pyth Network price feeds. Required for accessing specific price data streams.

Any action not supported by default by AgentKit can be added by [adding agent capabilities](https://docs.cdp.coinbase.com/agentkit/docs/add-agent-capabilities).

AgentKit supports every network that the [CDP SDK supports](https://docs.cdp.coinbase.com/cdp-apis/docs/networks).
```
WalletActionProvider_get_balance
WalletActionProvider_get_wallet_details
WalletActionProvider_native_transfer
CdpApiActionProvider_address_reputation
CdpApiActionProvider_request_faucet_funds
CdpWalletActionProvider_deploy_contract
CdpWalletActionProvider_deploy_nft
CdpWalletActionProvider_deploy_token
CdpWalletActionProvider_trade
PythActionProvider_fetch_price
PythActionProvider_fetch_price_feed_id
BasenameActionProvider_register_basename
ERC20ActionProvider_get_balance
ERC20ActionProvider_transfer
Erc721ActionProvider_get_balance
Erc721ActionProvider_mint
Erc721ActionProvider_transfer
WethActionProvider_wrap_eth
MorphoActionProvider_deposit
MorphoActionProvider_withdraw
SuperfluidActionProvider_create_flow
SuperfluidActionProvider_delete_flow
SuperfluidActionProvider_update_flow
WowActionProvider_buy_token
WowActionProvider_create_token
WowActionProvider_sell_token
```
87 changes: 55 additions & 32 deletions skills/defillama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,58 @@
from abstracts.agent import AgentStoreABC
from abstracts.skill import SkillStoreABC
from skills.defillama.base import DefiLlamaBaseTool

# TVL Tools
from skills.defillama.tvl.fetch_protocols import DefiLlamaFetchProtocols
from skills.defillama.tvl.fetch_protocol import DefiLlamaFetchProtocol
from skills.defillama.tvl.fetch_historical_tvl import DefiLlamaFetchHistoricalTvl
from skills.defillama.tvl.fetch_chain_historical_tvl import DefiLlamaFetchChainHistoricalTvl
from skills.defillama.tvl.fetch_protocol_current_tvl import DefiLlamaFetchProtocolCurrentTvl
from skills.defillama.tvl.fetch_chains import DefiLlamaFetchChains
from skills.defillama.coins.fetch_batch_historical_prices import (
DefiLlamaFetchBatchHistoricalPrices,
)
from skills.defillama.coins.fetch_block import DefiLlamaFetchBlock

# Coins Tools
from skills.defillama.coins.fetch_current_prices import DefiLlamaFetchCurrentPrices
from skills.defillama.coins.fetch_historical_prices import DefiLlamaFetchHistoricalPrices
from skills.defillama.coins.fetch_batch_historical_prices import DefiLlamaFetchBatchHistoricalPrices
from skills.defillama.coins.fetch_first_price import DefiLlamaFetchFirstPrice
from skills.defillama.coins.fetch_historical_prices import (
DefiLlamaFetchHistoricalPrices,
)
from skills.defillama.coins.fetch_price_chart import DefiLlamaFetchPriceChart
from skills.defillama.coins.fetch_price_percentage import DefiLlamaFetchPricePercentage
from skills.defillama.coins.fetch_first_price import DefiLlamaFetchFirstPrice
from skills.defillama.coins.fetch_block import DefiLlamaFetchBlock

# Fees Tools
from skills.defillama.fees.fetch_fees_overview import DefiLlamaFetchFeesOverview
from skills.defillama.stablecoins.fetch_stablecoin_chains import (
DefiLlamaFetchStablecoinChains,
)
from skills.defillama.stablecoins.fetch_stablecoin_charts import (
DefiLlamaFetchStablecoinCharts,
)
from skills.defillama.stablecoins.fetch_stablecoin_prices import (
DefiLlamaFetchStablecoinPrices,
)

# Stablecoins Tools
from skills.defillama.stablecoins.fetch_stablecoins import DefiLlamaFetchStablecoins
from skills.defillama.stablecoins.fetch_stablecoin_charts import DefiLlamaFetchStablecoinCharts
from skills.defillama.stablecoins.fetch_stablecoin_chains import DefiLlamaFetchStablecoinChains
from skills.defillama.stablecoins.fetch_stablecoin_prices import DefiLlamaFetchStablecoinPrices
from skills.defillama.tvl.fetch_chain_historical_tvl import (
DefiLlamaFetchChainHistoricalTvl,
)
from skills.defillama.tvl.fetch_chains import DefiLlamaFetchChains
from skills.defillama.tvl.fetch_historical_tvl import DefiLlamaFetchHistoricalTvl
from skills.defillama.tvl.fetch_protocol import DefiLlamaFetchProtocol
from skills.defillama.tvl.fetch_protocol_current_tvl import (
DefiLlamaFetchProtocolCurrentTvl,
)

# Yields Tools
from skills.defillama.yields.fetch_pools import DefiLlamaFetchPools
from skills.defillama.yields.fetch_pool_chart import DefiLlamaFetchPoolChart
# TVL Tools
from skills.defillama.tvl.fetch_protocols import DefiLlamaFetchProtocols

# Volumes Tools
from skills.defillama.volumes.fetch_dex_overview import DefiLlamaFetchDexOverview
from skills.defillama.volumes.fetch_dex_summary import DefiLlamaFetchDexSummary
from skills.defillama.volumes.fetch_options_overview import DefiLlamaFetchOptionsOverview
from skills.defillama.volumes.fetch_options_overview import (
DefiLlamaFetchOptionsOverview,
)
from skills.defillama.yields.fetch_pool_chart import DefiLlamaFetchPoolChart

# Yields Tools
from skills.defillama.yields.fetch_pools import DefiLlamaFetchPools

# Fees Tools
from skills.defillama.fees.fetch_fees_overview import DefiLlamaFetchFeesOverview

def get_defillama_skill(
name: str,
Expand Down Expand Up @@ -77,19 +94,19 @@ def get_defillama_skill(
agent_id=agent_id,
agent_store=agent_store,
)
elif name == "fetch_historical_tvl":
elif name == "fetch_historical_tvl":
return DefiLlamaFetchHistoricalTvl(
skill_store=store,
agent_id=agent_id,
agent_store=agent_store,
)
elif name == "fetch_chain_historical_tvl":
elif name == "fetch_chain_historical_tvl":
return DefiLlamaFetchChainHistoricalTvl(
skill_store=store,
agent_id=agent_id,
agent_store=agent_store,
)
elif name == "fetch_protocol_current_tvl":
elif name == "fetch_protocol_current_tvl":
return DefiLlamaFetchProtocolCurrentTvl(
skill_store=store,
agent_id=agent_id,
Expand All @@ -101,7 +118,7 @@ def get_defillama_skill(
agent_id=agent_id,
agent_store=agent_store,
)

# Coins Skills
elif name == "fetch_current_prices":
return DefiLlamaFetchCurrentPrices(
Expand Down Expand Up @@ -145,15 +162,17 @@ def get_defillama_skill(
agent_id=agent_id,
agent_store=agent_store,
)

# Stablecoins Skills
elif name == "fetch_stablecoins":
return DefiLlamaFetchStablecoins(
skill_store=store,
agent_id=agent_id,
agent_store=agent_store,
)
elif name == "fetch_stablecoin_charts": # Handles both all and chain-specific charts
elif (
name == "fetch_stablecoin_charts"
): # Handles both all and chain-specific charts
return DefiLlamaFetchStablecoinCharts(
skill_store=store,
agent_id=agent_id,
Expand All @@ -171,7 +190,7 @@ def get_defillama_skill(
agent_id=agent_id,
agent_store=agent_store,
)

# Yields Skills
elif name == "fetch_pools":
return DefiLlamaFetchPools(
Expand All @@ -185,7 +204,7 @@ def get_defillama_skill(
agent_id=agent_id,
agent_store=agent_store,
)

# Volumes Skills
elif name == "fetch_dex_overview": # Handles both base and chain-specific overviews
return DefiLlamaFetchDexOverview(
Expand All @@ -199,15 +218,19 @@ def get_defillama_skill(
agent_id=agent_id,
agent_store=agent_store,
)
elif name == "fetch_options_overview": # Handles both base and chain-specific overviews
elif (
name == "fetch_options_overview"
): # Handles both base and chain-specific overviews
return DefiLlamaFetchOptionsOverview(
skill_store=store,
agent_id=agent_id,
agent_store=agent_store,
)

# Fees Skills
elif name == "fetch_fees_overview": # Handles both base and chain-specific overviews
elif (
name == "fetch_fees_overview"
): # Handles both base and chain-specific overviews
return DefiLlamaFetchFeesOverview(
skill_store=store,
agent_id=agent_id,
Expand Down
Loading

0 comments on commit ad1b52d

Please sign in to comment.