# Lending Protocols

### Get Pool

The user will be able to get the lend and borrow APY for the given pool from the given protocol.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_getPool",
    "params": [
        {
            "lendborrowId": "1200",
            "asset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_getPool",
        "result": {
            "tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
            "variableBorrowRate": "5.95",
            "stableBorrowRate": "7.50",
            "variableSupplyRate": "0",
            "stableSupplyRate": "4.77"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Get Pools

The user will be able to get the list of supply and borrow APYs of the mentioned assets.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_getPools",
    "params": [
        {
            "lendborrowId": "1200",
            "assets": [
                "0x6b175474e89094c44da98b954eedeac495271d0f",
                "0xdac17f958d2ee523a2206206994597c13d831ec7",
                "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0"
            ]
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_getPools",
        "result": {
            "DAI": {
                "tokenAddress": "0x6b175474e89094c44da98b954eedeac495271d0f",
                "variableBorrowRate": "5.87",
                "stableBorrowRate": "7.49",
                "variableSupplyRate": "0",
                "stableSupplyRate": "4.65",
                "tokenSymbol": "DAI"
            },
            "USDT": {
                "tokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                "variableBorrowRate": "5.91",
                "stableBorrowRate": "10.94",
                "variableSupplyRate": "0",
                "stableSupplyRate": "4.71",
                "tokenSymbol": "USDT"
            },
            "LUSD": {
                "tokenAddress": "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0",
                "variableBorrowRate": "16.84",
                "stableBorrowRate": "21.84",
                "variableSupplyRate": "0",
                "stableSupplyRate": "12.51",
                "tokenSymbol": "LUSD"
            }
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Get User Account Data

The user will be able to get the repay, borrow, and withdraw amount details for the given user.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_getUserAccountData",
    "params": [
        {
            "lendborrowId": "1200",
            "asset": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
            "address": "0x025C62433Ecf89Ed45EDf7F41BF05318204d0b2b",
            "interestRateMode": "1"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_getUserAccountData",
        "result": {
            "tokenAddress": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
            "repayAmount": "0",
            "borrowAmount": "1170139125",
            "borrowErrorMessage": "The Stable Rate is not enabled for this currency",
            "withdrawAmount": "1118338519"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Get Enter Market Status

The user will be able to check whether the user approved before depositing on compound.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_getLendBorrowEnterMarketStatus",
    "params": [
        {
            "lendborrowId": "1100",
            "account": "0x6Fb447Ae94F5180254D436A693907a1f57696900"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_getLendBorrowEnterMarketStatus",
        "result": {
            "enterMarketStatus": [
                "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
                "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",
                "0xf650C3d88D12dB855b8bf7D11Be6C55A4e07dCC9",
                "0xFAce851a4921ce59e912d19329929CE6da6EB0c7"
            ]
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Borrow

The user will be able to trigger the borrow transaction from the given protocol.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_borrow",
    "params": [
        {
            "lendborrowId": "1100",
            "asset": "USDC",
            "amount": "100000",
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "gas": "608298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_borrow",
        "result": {
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "to": "0x39aa39c021dfbae8fac545936693ac917d5e7563",
            "value": "0",
            "gas": "608298",
            "data": "0xc5ebeaec00000000000000000000000000000000000000000000000000000000000186a0"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Deposit

The user will be able to trigger the deposit transaction from the given protocol.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_deposit",
    "params": [
        {
            "lendborrowId": "1100",
            "asset": "DAI",
            "amount": "1000000000000000000",
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "gas": "608298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_deposit",
        "result": {
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "to": "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643",
            "value": "0",
            "gas": "608298",
            "data": "0xa0712d680000000000000000000000000000000000000000000000000de0b6b3a7640000"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Repay

The user will be able to trigger the repay transaction from the given protocol.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_repay",
    "params": [
        {
            "lendborrowId": "1100",
            "asset": "USDC",
            "amount": "100000",
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "gas": "608298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_repay",
        "result": {
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "to": "0x39aa39c021dfbae8fac545936693ac917d5e7563",
            "value": "0",
            "gas": "608298",
            "data": "0x0e75270200000000000000000000000000000000000000000000000000000000000186a0"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Withdraw

The user will be able to trigger the repay transaction from the given protocol.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_withdraw",
    "params": [
        {
            "lendborrowId": "1100",
            "asset": "DAI",
            "amount": "1000000000000000000",
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "gas": "608298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_withdraw",
        "result": {
            "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "to": "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643",
            "value": "0",
            "gas": "608298",
            "data": "0x852a12e30000000000000000000000000000000000000000000000000de0b6b3a7640000"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Enter Market

The user will be able to approve before they can start deposit on Compound.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_enterMarket",
    "params": [
        {
            "lendborrowId": "1100",
            "asset": "USDT",
            "from": "0x356dB816602c85e2075774bB77D13995c8Bab023",
            "gas": "408298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_enterMarket",
        "result": {
            "from": "0x356dB816602c85e2075774bB77D13995c8Bab023",
            "to": "0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b",
            "value": "0",
            "gas": "408298",
            "data": "0xc299823800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f650c3d88d12db855b8bf7d11be6c55a4e07dcc9"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Exit Market

The user will be able to trigger the exit market transaction on Compound.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_exitMarket",
    "params": [
        {
            "lendborrowId": "1100",
            "asset": "USDT",
            "from": "0x356dB816602c85e2075774bB77D13995c8Bab023",
            "gas": "608298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_exitMarket",
        "result": {
            "from": "0x356dB816602c85e2075774bB77D13995c8Bab023",
            "to": "0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b",
            "value": "0",
            "gas": "608298",
            "data": "0xede4edd0000000000000000000000000f650c3d88d12db855b8bf7d11be6c55a4e07dcc9"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Exit Isolation Mode

The user will be able to trigger the exit of isolation mode options on Aave v3.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_exitIsolationMode",
    "params": [
        {
            "lendborrowId": "1200",
            "asset": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
            "from": "0xf7426829DBAAc7F26b48C49A04a93fc4f75cfa41",
            "gas": "429000"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_exitIsolationMode",
        "result": {
            "from": "0xf7426829DBAAc7F26b48C49A04a93fc4f75cfa41",
            "to": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
            "value": "0",
            "gas": "429000",
            "data": "0x5a3b74b90000000000000000000000009f8f72aa9304c8b593d555f12ef6589cc3a579a20000000000000000000000000000000000000000000000000000000000000000"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Set User E-mode

The user will be able to trigger the E-Mode options on Aave v3.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_setUserEMode",
    "params": [
        {
            "lendborrowId": "1200",
            "from": "0x829bFB482331b9Dc2BEcb5483ecA79c0578c3A45",
            "categoryId": "1",
            "gas": "408298"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_setUserEMode",
        "result": {
            "from": "0x829bFB482331b9Dc2BEcb5483ecA79c0578c3A45",
            "to": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
            "value": "0",
            "gas": "408298",
            "data": "0x28530a470000000000000000000000000000000000000000000000000000000000000001"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}

### Migrate

The user will be able to trigger a transaction to migrate their positions from Aave v2 to Aave v3.

{% tabs %}
{% tab title="Sample Request" %}
**URL:**

```url
https://lend-borrow.quicknode.expand.network/lendborrow
```

**Payload:**

```json
{
    "method": "en_migrate",
    "params": [
        {
            "lendborrowId": "1200",
            "assets": [
                "0x6b175474e89094c44da98b954eedeac495271d0f"
            ],
            "from": "0x356dB816602c85e2075774bB77D13995c8Bab023",
            "gas": "329000"
        }
    ]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
    "id": 1,
    "result": {
        "message": "success",
        "method": "en_migrate",
        "result": {
            "from": "0x356dB816602c85e2075774bB77D13995c8Bab023",
            "to": "0xb748952c7bc638f31775245964707bcc5ddfabfc",
            "value": "0",
            "gas": "329000",
            "data": "0x3698d492000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        }
    },
    "jsonrpc": "2.0"
}
```

{% endtab %}
{% endtabs %}
