# Yield Farm

This section explains how users can earn a yield on their digital assets by depositing their assets in different vaults.

<figure><img src="/files/DxA7SeMRhBsw94E8WA4K" alt="" width="563"><figcaption></figcaption></figure>

### Step 1: **Check the allowance of the vault for the token that the user wants to deposit.**

**API URL**: [﻿`https://api.expand.network/fungibletoken/getuserallowance`](https://docs.expand.network/how-to/﻿https:/api.expand.network/fungibletoken/getuserallowance)

***

**Sample Request:**

```url
﻿https://api.expand.network/fungibletoken/getuserallowance?owner=0x6Fb447Ae94F5180254D436A693907a1f57696900&tokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f&spender=0xBA12222222228d8Ba445958a75a0704d566BF2C8
```

***

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "allowance": "999000000000000000000"
    }
}
```

### Step 2: **Approve the vault contract from the token**

If the allowance is less than the token amount to deposit, the user must approve the vault contract from the token.

This can be done using the following API endpoint:&#x20;

**API URL**: [`https://api.expand.network/fungibletoken/approve`](https://docs.expand.network/categories/fungible-tokens/erc20#approve)

***

**Sample Request:**

```json
{
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006", 
    "tokenAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",  
    "amount": "1000000000000000000000",                  
    "to": "0x828b154032950c8ff7cf8085d841723db2696056", 
    "gas": "100000",
    "chainId": "1"
}
```

***

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "value": "0",
        "gas": "100000",
        "data": "0x095ea7b3000000000000000000000000828b154032950c8ff7cf8085d841723db269605600000000000000000000000000000000000000000000003635c9adc5dea00000"
    }
}
```

### Step 3: Deposit

This can be done using the following API endpoint:&#x20;

**API URL**: [﻿`https://api.expand.network/yieldaggregator/depositvault`](https://docs.expand.network/how-to/﻿https:/api.expand.network/yieldaggregator/depositvault)

***

**Sample Request:**

```json
{ 
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount": "500000",
    "gas": "2307200",
    "yieldAggregatorId": "5100"
}
```

***

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0xFE09e53A81Fe2808bc493ea64319109B5bAa573e",
        "value": "0",
        "gas": "2307200",
        "data": "0xb6b55f25000000000000000000000000000000000000000000000000000000000007a120"
    }
}
```

> The user will receive the LP tokens on depositing the token.

### Step 4: Withdraw

The user needs to provide the LP tokens to withdraw. To provide the LP tokens to the vault, the vault needs to be approved by the LP token.

This can be done using the following API endpoint:&#x20;

**API URL**: [﻿`https://api.expand.network/yieldaggregator/withdrawvault`](https://docs.expand.network/how-to/﻿https:/api.expand.network/yieldaggregator/withdrawvault)

***

**Sample Request:**

```json
{
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount": "500000",
    "gas": "2307200",
    "yieldAggregatorId": "5100"
}
```

***

**Sample Response:**&#x20;

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0xFE09e53A81Fe2808bc493ea64319109B5bAa573e",
        "value": "0",
        "gas": "2307200",
        "data": "0x2e1a7d4d00000000000000000000000000000000000000000000000000000000004b4a52"
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.expand.network/how-to/yield-farm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
