Crypto.com AI Agent SDK
  • Getting Started
    • Introduction
    • Quick Start Guide: Simulation Entry Point
  • Core Concepts Overview
    • Plugins
    • Tools
    • Blockchain Functions
      • Wallet Management
      • Token Interaction
      • Transaction Queries
      • Block Information
      • Contract Operations
      • CronosID Operations
      • Defi Operations
      • Crypto.com Exchange
    • Built-in Telegram Feature
    • Advanced Usage: Custom Instructions
    • Dynamic AI Model Manager
  • Crypto.com On-Chain Developer Platform
    • Developer Platform API Methods
  • On-Chain Functions and Examples
    • AI Agent Chatbot
    • "Magic Link" Signer
  • Resources for Developers
Powered by GitBook
On this page

Was this helpful?

  1. Core Concepts Overview
  2. Blockchain Functions

Defi Operations

The AI Agent SDK provides powerful DeFi-related features, enabling seamless access to essential data from the Crypto.com ecosystem. It allows developers to retrieve a list of whitelisted tokens for a specified DeFi protocol, fetch information about all available farms, and obtain detailed information about a specific farm identified by its symbol.

7.1 Get whitelisted tokens

Retrieve a list of whitelisted tokens for the specified DeFi protocol from the Crypto.com developer platform.

  • Arguments

    protocol (str): The DeFi protocol name (e.g., "H2", "VVS").
  • Example Query

    "Get whitelisted tokens of protocol <example-protocol>"
  • Returns

    str: A formatted string containing the list of whitelisted tokens.
  • Example Response

    Here are the whitelisted tokens for the <example-protocol> protocol:
    
    <example-token-name>
       - Address: [<example-address>](<example-explore-link>)
       - Decimal: <example-decimal>
       - Swappable: <example-boolean>
       - ![<example-token-name> Logo](<example-img-link>)
    <example-token-name>
    ...
    
    Feel free to ask if you need more information about any specific token!

Example Code

from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4",
        "provider-api-key": "sk-proj-example-key",
        "temperature": "float-controlling-output-randomness",
    },
    blockchain_config={
         "chainId": "chain-id",
         "explorer-api-key": "your-api-key",
         "private-key": "your-private-key",
         "sso-wallet-url": "your-sso-wallet-url",
    },
)
response = agent.interact("Get whitelisted tokens of protocol <example-protocol>")
print(response)

7.2 Get all farms

Retrieve information about all available farms for the specified DeFi protocol from the Crypto.com developer platform.

  • Arguments

    protocol (str): The DeFi protocol name (e.g., "H2", "VVS").
  • Example Query

    "Get all farms of protocol <example-protocol>"
  • Returns

    str: A formatted string containing information about all farms.
  • Example Response

    Here are the farms available for the <example-protocol>:
    <example-farm-symbol>
       - LP Address: <example-lp-address>
       - Base APR: <example-percentage>
       - Base APY: <example-percentage>
       - Reward Start Date: <example-date>
       - Chain: <example-chain-name>
    <example-farm-symbol>
    ...

Example Code

from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4",
        "provider-api-key": "sk-proj-example-key",
        "temperature": "float-controlling-output-randomness",
    },
    blockchain_config={
         "chainId": "chain-id",
         "explorer-api-key": "your-api-key",
         "private-key": "your-private-key",
         "sso-wallet-url": "your-sso-wallet-url",
    },
)
response = agent.interact("Get all farms of protocol <example-protocol>")
print(response)

7.3 Get farm by symbol

Retrieve detailed information about a specific farm identified by its symbol for the specified DeFi protocol.

  • Arguments

    protocol (str): The DeFi protocol name (e.g., "H2", "VVS").
    symbol (str): The farm symbol (e.g., "zkCRO-MOON", "CRO-GOLD").
  • Example Query

    "Get farm of protocol <example-protocol> symbol <example-symbol>"
  • Returns

    str: A formatted string containing information about the specific farm.
  • Example Response

    Here is the information for the farm with the symbol <example-symbol> in the <example-protocol> protocol:
    
    - Farm ID: <example-farm-id>
    - LP Symbol: <example-lp-symbol>
    - LP Address: [<example-lp-address>](<example-explorer-link>)
    - Token:
      - Symbol: <example-token-symbol>
      - Address: [<example-token-address>](<example-explorer-link>)
    - Quote Token:
      - Symbol: <example-quote-token-symbol>
      - Address: [<example-quote-token-address>](<example-explorer-link>)
    - Version: <example-version>
    - Reward Start Date: <example-date>, at <example-time>
    - Finished: <example-boolean>
    - Migrated: <example-boolean>
    - Boost Enabled: <example-boolean>
    - Auto Harvest Enabled: <example-boolean>
    - Chain: <example-chain-name>
    - Chain ID: <example-chain-id>
    - Base APR: <example-percentage>
    - Base APY: <example-percentage>
    - LP APR: <example-percentage>
    - LP APY: <example-percentage>
    
    If you need further assistance or more details, feel free to ask!

Example Code

from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4",
        "provider-api-key": "sk-proj-example-key",
        "temperature": "float-controlling-output-randomness",
    },
    blockchain_config={
         "chainId": "chain-id",
         "explorer-api-key": "your-api-key",
         "private-key": "your-private-key",
         "sso-wallet-url": "your-sso-wallet-url",
    },
)

response = agent.interact("Get farm of protocol <example-protocol> symbol <example-symbol>")
print(response)
PreviousCronosID OperationsNextCrypto.com Exchange

Last updated 1 day ago

Was this helpful?