# Aave V2

### /getpool

## Get the lend and borrow APY for the given pool from AAVE protocol.

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

#### Query Parameters

| Name                                           | Type   | Description                                                                                                                                      |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| rpc                                            | String | Remote procedural call URL.                                                                                                                      |
| lendborrowId<mark style="color:red;">\*</mark> | String | Refer to the [Lend and Borrow ID](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| asset<mark style="color:red;">\*</mark>        | String | Token address to get the details of.                                                                                                             |

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

```url
https://api.expand.network/lendborrow/getpool?lendborrowId=1000&asset=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "tokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "variableBorrowRate": "3.26",
        "stableBorrowRate": "5.27",
        "variableSupplyRate": "0",
        "stableSupplyRate": "1.26"
    }
}
```

{% endtab %}
{% endtabs %}

### /getpools

## Get the list of supply and borrow APYs of the mentioned assets.

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

#### Query Parameters

| Name                                     | Type   | Description                                                                                                                                  |
| ---------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| lendborrowId                             | String | Refer to the [lend borrow Id](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| assets<mark style="color:red;">\*</mark> | String | Comma-separated values of token address.                                                                                                     |

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

```
https://api.expand.network/lendborrow/getpools?lendborrowId=1000&assets=0x6b175474e89094c44da98b954eedeac495271d0f,0xdac17f958d2ee523a2206206994597c13d831ec7,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "USDT": {
            "tokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "variableBorrowRate": "3.70",
            "stableBorrowRate": "11.85",
            "variableSupplyRate": "0",
            "stableSupplyRate": "3.00",
            "symbol": "USDT"
        },
        "DAI": {
            "tokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
            "variableBorrowRate": "3.01",
            "stableBorrowRate": "11.51",
            "variableSupplyRate": "0",
            "stableSupplyRate": "1.66",
            "symbol": "DAI"
        },
        "WETH": {
            "tokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
            "variableBorrowRate": "3.27",
            "stableBorrowRate": "5.27",
            "variableSupplyRate": "0",
            "stableSupplyRate": "1.26",
            "symbol": "WETH"
        },
        "USDC": {
            "tokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "variableBorrowRate": "2.96",
            "stableBorrowRate": "10.48",
            "variableSupplyRate": "0",
            "stableSupplyRate": "1.83",
            "symbol": "USDC"
        }
    }
}
```

{% endtab %}
{% endtabs %}

### /getuseraccountdata

## Get the repay, borrow, and withdraw amount details for the given user.

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

#### Query Parameters

| Name                                               | Type   | Description                                                                                                                                  |
| -------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| rpc                                                | String | Remote procedural call URL.                                                                                                                  |
| lendborrowId                                       | String | Refer to the [lend borrow Id](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| asset<mark style="color:red;">\*</mark>            | String | Token address.                                                                                                                               |
| address<mark style="color:red;">\*</mark>          | String | Public address of sender.                                                                                                                    |
| interestRateMode<mark style="color:red;">\*</mark> | String | Interest mode as per Aave. Is set '1' as default.                                                                                            |

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

```url
https://api.expand.network/lendborrow/getuseraccountdata?address=0x6Fb447Ae94F5180254D436A693907a1f57696900&asset=0x514910771af9ca656af840dff83e8264ecf986ca&lendborrowId=1000&interestRateMode=1
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "tokenAddress": "0x514910771af9ca656af840dff83e8264ecf986ca",
        "repayAmount": "0",
        "borrowAmount": "201991256034911571",
        "withdrawAmount": "0"
    }
}
```

{% endtab %}
{% endtabs %}

### /borrow

## Trigger the borrow transaction from the given protocol.

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

#### Request Body

| Name                                               | Type   | Description                                                                                                                                      |
| -------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| lendborrowId                                       | String | Refer to the [Lend and Borrow ID](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| asset<mark style="color:red;">\*</mark>            | String | Token address to borrow.                                                                                                                         |
| amount<mark style="color:red;">\*</mark>           | String | Number of tokens to be borrowed.                                                                                                                 |
| interestRateMode<mark style="color:red;">\*</mark> | String | Interest mode as per Aave. 0 for static and 1 for variable.                                                                                      |
| referralCode<mark style="color:red;">\*</mark>     | String | Referral code needed by Aave.                                                                                                                    |
| onBehalfOf<mark style="color:red;">\*</mark>       | String | Required in case borrow need to be done on behalf of other public address.                                                                       |
| from<mark style="color:red;">\*</mark>             | String | Sender public address.                                                                                                                           |
| gas<mark style="color:red;">\*</mark>              | String | Maximum gas to be approved for transaction.                                                                                                      |
| rpc                                                | String | Remote procedural call URL.                                                                                                                      |
| gasPriority                                        | String | low, medium, or high.                                                                                                                            |

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

```json
{
    "lendborrowId": "1000",
    "asset": "0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F",
    "amount": "100",
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "onBehalfOf": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "interestRateMode": "2",
    "gas": "408298"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0x4bd5643ac6f66a5237E18bfA7d47cF22f1c9F210",
        "value": "0",
        "gas": "408298",
        "data": "0xa415bcad000000000000000000000000fc1ab0379db4b6ad8bf5bc1382e108a341e2eabb00000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063056e00436da25bcf48a40dfbbdcc7089351006"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}
**With gasPriority(medium):**

```json
{
    "lendborrowId": "1000",
    "asset": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    "amount": "100000000",
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "onBehalfOf": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "interestRateMode": "2",
    "gas": "408298",
    "gasPriority":"medium"
}
```

{% endtab %}

{% tab title="Sample Response" %}
**With gasPriority:**

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
        "to": "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9",
        "value": "0",
        "gas": "397254",
        "data": "0xa415bcad0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000005f5e10000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fae7d9854995e28beb1b1da864ee2a1e2ec17f07"
    }
}
```

{% endtab %}
{% endtabs %}

### /deposit

## Trigger the deposit transaction from the given protocol.

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

#### Request Body

| Name                                           | Type   | Description                                                                                                                                      |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| lendborrowId                                   | String | Refer to the [Lend and Borrow ID](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| asset<mark style="color:red;">\*</mark>        | String | Token address to deposit.                                                                                                                        |
| amount<mark style="color:red;">\*</mark>       | String | Number of tokens to deposit.                                                                                                                     |
| referralCode<mark style="color:red;">\*</mark> | String | Referral code needed by Aave.                                                                                                                    |
| onBehalfOf<mark style="color:red;">\*</mark>   | String | Required in case deposit need to be done on behalf of other public address.                                                                      |
| from<mark style="color:red;">\*</mark>         | String | Sender public address.                                                                                                                           |
| gas<mark style="color:red;">\*</mark>          | String | Maximum gas to be approved for the transaction.                                                                                                  |
| rpc                                            | String | Remote procedural call URL.                                                                                                                      |
| involveBaseToken                               | String | <p>0 for any ERC-20 token,<br>1 for ETH.</p>                                                                                                     |
| gasPriority                                    | String | low, medium, or high.                                                                                                                            |

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

```json
{
    "lendborrowId": "1000",
    "asset": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "amount": "10000000000000000",
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "onBehalfOf": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "gas": "408298"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0x4bd5643ac6f66a5237E18bfA7d47cF22f1c9F210",
        "value": "0",
        "gas": "408298",
        "data": "0xe8eda9df000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d6000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000063056e00436da25bcf48a40dfbbdcc70893510060000000000000000000000000000000000000000000000000000000000000000"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}
**With gasPriority (low):**

```json
{
    "lendborrowId": "1000",
    "asset": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    "amount": "10000000000000",
    "from": "0x356db816602c85e2075774bb77d13995c8bab023",
    "onBehalfOf": "0x356db816602c85e2075774bb77d13995c8bab023",
    "gas": "520000",
    "gasPriority": "low"
}
```

{% endtab %}

{% tab title="Sample Response" %}
**With gasPriority:**

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId": "1",
        "from": "0x356db816602c85e2075774bb77d13995c8bab023",
        "to": "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9",
        "value": "0",
        "gas": "217582",
        "data": "0xe8eda9df0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a000000000000000000000000000356db816602c85e2075774bb77d13995c8bab0230000000000000000000000000000000000000000000000000000000000000000"
    }
}
```

{% endtab %}
{% endtabs %}

### /liquidate

## Trigger the liquidate transaction from the given protocol.

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

#### Request Body

| Name                                              | Type   | Description                                                                                                                                      |
| ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| lendborrowId                                      | String | Refer to the [Lend and Borrow ID](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| collateralAsset<mark style="color:red;">\*</mark> | String | Address of the collateral token.                                                                                                                 |
| debtAsset<mark style="color:red;">\*</mark>       | String | Address of the debt token.                                                                                                                       |
| user<mark style="color:red;">\*</mark>            | String | Public address of the user whose account need to be liquidated.                                                                                  |
| debtToCover<mark style="color:red;">\*</mark>     | String | Amount of debt to be covered.                                                                                                                    |
| receiveAToken<mark style="color:red;">\*</mark>   | String | Amount of token A to be received.                                                                                                                |
| from<mark style="color:red;">\*</mark>            | String | Sender public address.                                                                                                                           |
| gas<mark style="color:red;">\*</mark>             | String | Maximum gas to be approved for the transaction.                                                                                                  |
| rpc                                               | String | Remote procedural call URL.                                                                                                                      |

### /repay

## Trigger the repay transaction from the given protocol.

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

#### Request Body

| Name                                               | Type   | Description                                                                                                                                      |
| -------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| lendborrowId                                       | String | Refer to the [Lend and Borrow ID](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| asset<mark style="color:red;">\*</mark>            | String | Token address to repay.                                                                                                                          |
| interestRateMode<mark style="color:red;">\*</mark> | String | Interest mode as per Aave. 0 for static and 1 for variable.                                                                                      |
| onBehalfOf<mark style="color:red;">\*</mark>       | String | Required in case repay need to be done on behalf of other public address.                                                                        |
| from<mark style="color:red;">\*</mark>             | String | Sender public address.                                                                                                                           |
| gas<mark style="color:red;">\*</mark>              | String | Maximum gas to be approved for the transaction.                                                                                                  |
| amount<mark style="color:red;">\*</mark>           | String | Number of tokens to repay.                                                                                                                       |
| rpc                                                | String | Remote procedural call URL.                                                                                                                      |
| gasPriority                                        | String | low, medium, or high.                                                                                                                            |

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

```json
{
    "lendborrowId": "1000",
    "asset": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    "amount": "100000",
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "onBehalfOf": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "interestRateMode": "2",
    "gas": "408298"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0x4bd5643ac6f66a5237E18bfA7d47cF22f1c9F210",
        "value": "0",
        "gas": "408298",
        "data": "0x573ade81000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000063056e00436da25bcf48a40dfbbdcc7089351006"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}
**With gasPriority (medium):**

```json
{
    "lendborrowId": "1000",
    "asset": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    "amount": "10000000000",
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "onBehalfOf": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "interestRateMode": "2",
    "gas": "408298",
    "gasPriority":"medium"
}
```

{% endtab %}

{% tab title="Sample Response" %}
**With gasPriority:**

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
        "to": "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9",
        "value": "0",
        "gas": "288354",
        "data": "0x573ade810000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000fae7d9854995e28beb1b1da864ee2a1e2ec17f07"
    }
}
```

{% endtab %}
{% endtabs %}

### /withdraw

## Trigger the withdraw transaction from the given protocol.

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

#### Request Body

| Name                                     | Type   | Description                                                                                                                                      |
| ---------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| lendborrowId                             | String | Refer to the [Lend and Borrow ID](https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/important-ids/lend-and-borrow-id) page for details. |
| asset<mark style="color:red;">\*</mark>  | String | Token address to be withdraw.                                                                                                                    |
| amount<mark style="color:red;">\*</mark> | String | Number of tokens to withdraw.                                                                                                                    |
| to<mark style="color:red;">\*</mark>     | String | Recipient public address.                                                                                                                        |
| from<mark style="color:red;">\*</mark>   | String | Sender public address.                                                                                                                           |
| gas<mark style="color:red;">\*</mark>    | String | Maximum gas to be approved for the transaction.                                                                                                  |
| rpc                                      | String | Remote procedural call URL.                                                                                                                      |
| gasPriority                              | String | low, medium, or high.                                                                                                                            |

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

```json
{
    "lendborrowId": "1000",
    "asset": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    "amount": "1000000000000000000",
    "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "to": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
    "gas": "408298"
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
        "to": "0x4bd5643ac6f66a5237E18bfA7d47cF22f1c9F210",
        "value": "0",
        "gas": "408298",
        "data": "0x69328dec0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000063056e00436da25bcf48a40dfbbdcc7089351006"
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Sample Request" %}
**With gasPriority (low):**

```json
{
    "lendborrowId": "1000",
    "asset": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    "amount": "100000000000",
    "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "to": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
    "gas": "408298",
    "gasPriority":"low"
}
```

{% endtab %}

{% tab title="Sample Response" %}
**With gasPriority:**

```json
{
    "status": 200,
    "msg": "success",
    "data": {
        "chainId":"1",
        "from": "0xfAE7D9854995E28BEB1B1da864ee2A1E2EC17f07",
        "to": "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9",
        "value": "0",
        "gas": "332250",
        "data": "0x69328dec0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000174876e800000000000000000000000000fae7d9854995e28beb1b1da864ee2a1e2ec17f07"
    }
}
```

{% endtab %}
{% endtabs %}
