# 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.

To learn more about the underlying Developer Platform functionalities, please visit [Developer Platform Client SDK Defi Module](https://ai-agent-sdk-docs.crypto.com/crypto.com-developer-platform/on-chain-developer-platform-client-sdk/defi-module).

#### 6.1 Get whitelisted tokens&#x20;

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

{% tabs %}
{% tab title="Query" %}

* Arguments

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

  ```
  "Get whitelisted tokens of protocol <example-protocol>"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  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!
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
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",
        "transfer-limit": -1,  # -1 means no limit (unlimited), 0 disables transfers completely, any positive number (e.g. 5) allows exactly that transfer amount
    },
    blockchain_config={
        "api-key": "your-crypto.com-developer-platform-api-key",
        "private-key": "your-private-key",
        "sso-wallet-url": "your-sso-wallet-url",
        "timeout": "timeout-in-seconds-for-API-calls-default-20s")
    },
)
response = agent.interact("Get whitelisted tokens of protocol <example-protocol>")
print(response)
```

#### 6.2 Get all farms&#x20;

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

{% tabs %}
{% tab title="Query" %}

* Arguments

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

  ```
  "Get all farms of protocol <example-protocol>"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  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>
  ...
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
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",
        "transfer-limit": -1,  # -1 means no limit (unlimited), 0 disables transfers completely, any positive number (e.g. 5) allows exactly that transfer amount
    },
    blockchain_config={
        "api-key": "your-crypto.com-developer-platform-api-key",
        "private-key": "your-private-key",
        "sso-wallet-url": "your-sso-wallet-url",
        "timeout": "timeout-in-seconds-for-API-calls-default-20s")
    },
)
response = agent.interact("Get all farms of protocol <example-protocol>")
print(response)
```

#### 6.3 Get farm by symbol&#x20;

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

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```python
  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>"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  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!
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
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",
        "transfer-limit": -1,  # -1 means no limit (unlimited), 0 disables transfers completely, any positive number (e.g. 5) allows exactly that transfer amount
    },
    blockchain_config={
        "api-key": "your-crypto.com-developer-platform-api-key",
        "private-key": "your-private-key",
        "sso-wallet-url": "your-sso-wallet-url",
        "timeout": "timeout-in-seconds-for-API-calls-default-20s")
    },
)

response = agent.interact("Get farm of protocol <example-protocol> symbol <example-symbol>")
print(response)
```
