# Yearn Finance V2

### Supported Chains

Available on **Ethereum, Arbitrum, Base** and **Optimism**

### Available Endpoints:

*Click on the endpoint to jump to the section with full details*

* [<mark style="color:blue;">**/getbalance**</mark>](#getbalance)<mark style="color:blue;">`GET`</mark> -Get balance of the user in a given Vault.
* [<mark style="color:blue;">**/getvaults**</mark>](#getvaults)<mark style="color:blue;">`GET`</mark> - Get the number of the vaults along with the respective vault APY.
* [<mark style="color:blue;">**/depositvault**</mark>](#depositvault) <mark style="color:blue;">`GET`</mark> - Trigger the deposit transaction for the given vault.
* [<mark style="color:blue;">**/withdrawvault**</mark>](#withdrawvault) <mark style="color:green;">`POST`</mark> - Trigger the withdraw transaction for the given vault.

### Yield Aggregator IDs

Many endpoints have a parameter where you can provide a lendborrow ID.&#x20;

Below is a list of lendborrow IDs related to Yearn Finance V2. Please see the \[[yield-aggregator-id](https://docs.expand.network/ids/yield-aggregator-id "mention")]\(../../ids/yield-aggregator-id) for a complete Yield Aggregator ID list and more information.

| Yield Aggregator Name | Chain    | Yield Aggregator ID |
| --------------------- | -------- | ------------------- |
| Yearn Finance V2      | Ethereum | 5000                |
| Yearn Finance V2      | Arbitrum | 5001                |
| Yearn Finance V2      | Base     | 5002                |
| Yearn Finance V2      | Optimism | 5003                |

## Endpoint Details

### /getbalance

{% hint style="warning" %}
For **/getbalance**, the user can either pass the vaultAddress or the tokenAddress and the vaultNumber along with the required parameters.
{% endhint %}

#### Get balance of the user in a given Vault.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/yieldaggregator/getbalance`

#### Query Parameters

| Name                                                | Type   | Description                                                                                                         |
| --------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| rpc                                                 | String | Remote procedural call URL.                                                                                         |
| address<mark style="color:red;">\*</mark>           | String | Public Address of the owner.                                                                                        |
| tokenAddress                                        | String | The address of token.                                                                                               |
| vaultNumber                                         | String | The number of the vault, incase there are multiple vaults.                                                          |
| yieldAggregatorId<mark style="color:red;">\*</mark> | String | Refer to the [yield-aggregator-id](https://docs.expand.network/ids/yield-aggregator-id "mention") page for details. |
| vaultAddress                                        | String | The address of the vault.                                                                                           |

{% tabs %}
{% tab title="Sample Request" %}

#### With tokenAddress:&#x20;

```url
https://api.expand.network/yieldaggregator/getbalance?address=0xC7565379C190014449eE83CF9FD7475206E59f9e&tokenAddress=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&yieldAggregatorId=5000
```

#### With VaultAddress:

```url
https://api.expand.network/yieldaggregator/getbalance?address=0x6Fb447Ae94F5180254D436A693907a1f57696900&yieldAggregatorId=5000&vaultAddress=0xa9fE4601811213c340e850ea305481afF02f5b28
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "vaultBalance": "0"
    }
}
```

{% endtab %}
{% endtabs %}

### /getvaults

#### Get the number of the vaults along with the respective vault APY.

<mark style="color:blue;">`GET`</mark> `https://api.expand.network/yieldaggregator/getvaults`

#### Query Parameters

| Name                                                | Type   | Description                                                                                                         |
| --------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| rpc                                                 | String | Remote procedural call URL                                                                                          |
| yieldAggregatorId<mark style="color:red;">\*</mark> | String | Refer to the [yield-aggregator-id](https://docs.expand.network/ids/yield-aggregator-id "mention") page for details. |
| tokenAddress                                        | String | The address of token.                                                                                               |

{% tabs %}
{% tab title="Sample Request" %}

```url
https://api.expand.network/yieldaggregator/getvaults?tokenAddress=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&yieldAggregatorId=5000
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "tokenVaults": [
            {
                "vaultName": "WETH yVault",
                "vaultSymbol": "yvWETH",
                "vaultAddress": "0xa9fE4601811213c340e850ea305481afF02f5b28",
                "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "apr": {
                    "netAPR": "0.00",
                    "weeklyAPR": "0.00",
                    "monthlyAPR": "0.00",
                    "inceptionAPR": "0.00",
                    "estAPR": "0.00",
                    "boost": null
                },
                "fee": {
                    "managementfee": "0.00",
                    "performancefee": "0.00"
                },
                "vaultNumber": 0
            },
            {
                "vaultName": "WETH yVault",
                "vaultSymbol": "yvWETH",
                "vaultAddress": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
                "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "apr": {
                    "netAPR": "5.06",
                    "weeklyAPR": "6.48",
                    "monthlyAPR": "5.06",
                    "inceptionAPR": "7.54",
                    "estAPR": "5.06",
                    "boost": null
                },
                "fee": {
                    "managementfee": "0.00",
                    "performancefee": "20.00"
                },
                "vaultNumber": 1
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

### /depositvault

{% hint style="warning" %}
For **/depositvault**, the user can either pass the tokenAddress or the vaultAddress along with the required parameters.
{% endhint %}

#### Trigger the deposit transaction for the given vault.

<mark style="color:green;">`POST`</mark> `https://api.expand.network/yieldaggregator/depositvault`

#### Request Body

| Name                                                | Type   | Description                                                                                                         |
| --------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| amount<mark style="color:red;">\*</mark>            | String | The amount of token to deposit.                                                                                     |
| tokenAddress                                        | String | The address of the token.                                                                                           |
| from<mark style="color:red;">\*</mark>              | String | Address of the sender of the token.                                                                                 |
| gas                                                 | String | Maximum gas limit provided by the sender, for the transaction.                                                      |
| vaultNumber                                         | String | The number of the vault, in case there are multiple vaults.                                                         |
| vaultAddress                                        | String | The address of the vault.                                                                                           |
| yieldAggregatorId<mark style="color:red;">\*</mark> | String | Refer to the [yield-aggregator-id](https://docs.expand.network/ids/yield-aggregator-id "mention") page for details. |
| gasPriority                                         | String | low, medium, or high.                                                                                               |

{% tabs %}
{% tab title="Sample Request" %}

#### With tokenAddress:

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

#### With VaultAddress:

```json
{
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "vaultAddress":"0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
    "amount": "500000",
    "yieldAggregatorId": "5000",
    "gas": "2307200"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1",
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
        "value": "0",
        "gas": "2307200",
        "data": "0xb6b55f25000000000000000000000000000000000000000000000000000000000007a120",
        "referenceId": "f99a93a359114de8ba8ae20c2def4dd9"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}

#### With gasPriority (medium)-

#### 1. With tokenAddress:

```json
{
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount": "10000000000",
    "vaultNumber": "1",
    "yieldAggregatorId": "5000",
    "gas": "2307200",
    "gasPriority":"medium"
}
```

#### 2. With VaultAddress:

```json
{
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "vaultAddress":"0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
    "amount": "500000",
    "yieldAggregatorId": "5000",
    "gas": "2307200",
    "gasPriority":"medium"
}
```

{% endtab %}

{% tab title="Sample Response" %}

#### With gasPriority-

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1",
        "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
        "to": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
        "value": "0",
        "gas": "2307200",
        "data": "0xb6b55f2500000000000000000000000000000000000000000000000000000002540be400",
        "gasPrice": "6492084170",
        "referenceId": "ba58ae00a7ba4899a1f1234e2e8f6b05"
    }
}
```

{% endtab %}
{% endtabs %}

### /withdrawvault

{% hint style="danger" %}
For **/withdrawvault**, the user can either pass the tokenAddress or the vaultAddress along with the required parameters.
{% endhint %}

#### Trigger the withdraw transaction for the given vault.

<mark style="color:green;">`POST`</mark> `https://api.expand.network/yieldaggregator/withdrawvault`

#### Request Body

| Name                                                | Type   | Description                                                                                                         |
| --------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| amount<mark style="color:red;">\*</mark>            | String | Amount to be withdrawn.                                                                                             |
| from<mark style="color:red;">\*</mark>              | String | Address of the withdrawer of the token.                                                                             |
| gas                                                 | String | Maximum gas limit provided by the sender, for the transaction.                                                      |
| tokenAddress                                        | String | Address of the token.                                                                                               |
| vaultNumber                                         | String | The number of the vault, in case there are multiple vaults.                                                         |
| vaultAddress                                        | String | Address of the vault.                                                                                               |
| yieldAggregatorId<mark style="color:red;">\*</mark> | String | Refer to the [yield-aggregator-id](https://docs.expand.network/ids/yield-aggregator-id "mention") page for details. |
| gasPriority                                         | String | low, medium, or high.                                                                                               |

{% tabs %}
{% tab title="Sample Request" %}

#### With tokenAddress:

```json
{
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount": "4881310",
    "gas": "2307200",
    "vaultNumber": "1",
    "yieldAggregatorId": "5000"
}
```

#### With vaultAddress:

```json
{
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "vaultAddress": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
    "amount": "4881310",
    "gas": "2307200",
    "yieldAggregatorId": "5000" 
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1",
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
        "value": "0",
        "gas": "2307200",
        "data": "0x2e1a7d4d00000000000000000000000000000000000000000000000000000000004a7b9e",
        "referenceId": "4ea029bdeb874f9ba7866684a752875c"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}

#### With gasPriority (high)-

#### 1. With tokenAddress:

```json
{
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "amount": "10000000",
    "gas": "2307200",
    "gasPriority":"high",
    "vaultNumber": "1",
    "yieldAggregatorId": "5000"
}
```

#### 2. With VaultAddress:

```json
{
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "vaultAddress": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
    "amount": "4881310",
    "gas": "2307200",
    "gasPriority":"high",
    "yieldAggregatorId": "5000"
}
```

{% endtab %}

{% tab title="Sample Response" %}

#### With gasPriority-

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1",
        "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
        "to": "0xa258C4606Ca8206D8aA700cE2143D7db854D168c",
        "value": "0",
        "gas": "2307200",
        "data": "0x2e1a7d4d0000000000000000000000000000000000000000000000000000000000989680",
        "gasPrice": "7967445713",
        "referenceId": "6f60ed42ff354915a4785f4aea4c8b3a"
    }
}
```

{% endtab %}
{% endtabs %}
