> For the complete documentation index, see [llms.txt](https://instadapp-3.gitbook.io/instadapp-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://instadapp-3.gitbook.io/instadapp-docs/dsa-sdk/connectors/compound.md).

# Compound

Interact with Compound Protocol

These connectors interact with the Compound protocol to facilitate Compound transactions like deposit, borrow, withdraw, payback, and more.&#x20;

## Deposit

This connector deposits into Compound

```
spells.add({
  connector: "compound",
  method: "deposit",
  args: [token, amount, getId, setId]
});
```

| Parameter | Type    | Description                                                                |
| --------- | ------- | -------------------------------------------------------------------------- |
| token     | address | The token address to deposit                                               |
| amount    | number  | The amount of tokens to deposit. use -1 or dsa`.`maxValue to deposit 100%. |
| getId     | number  | ID fetches the amount of token to deposit.                                 |
| setId     | number  | ID stores the amount of token deposited.                                   |

## Withdraw

This connector withdraws tokens out of Compound.&#x20;

```
spells.add({
  connector: "compound",
  method: "withdraw",
  args: [token, amount, getId, setId]
});
```

| Parameter | Type    | Description                                                                  |
| --------- | ------- | ---------------------------------------------------------------------------- |
| token     | address | The token address to withdraw                                                |
| amount    | number  | The amount of tokens to withdraw. use -1 or `dsa.`maxValue to withdraw 100%. |
| getId     | number  | ID fetches the amount of token to withdraw                                   |
| setId     | number  | ID stores the amount of token withdrawn                                      |

## Borrow

This connector borrows tokens from Compound

```
spells.add({
  connector: "compound",
  method: "borrow",
  args: [token, amount, getId, setId]
});
```

| Parameter | Type    | Description                              |
| --------- | ------- | ---------------------------------------- |
| token     | address | The token address to borrow              |
| amount    | number  | The amount of tokens to borrow           |
| getId     | number  | ID fetches the amount of token to borrow |
| setId     | number  | ID stores the amount of token borrowed   |

## Payback

This connector pays back debt owed to Compound

```
spells.add({
  connector: "compound",
  method: "payback",
  args: [token, amount, getId, setId]
});
```

| Parameter | Type    | Description                                                                |
| --------- | ------- | -------------------------------------------------------------------------- |
| token     | address | The token address to payback                                               |
| amount    | number  | The amount of tokens to payback. use -1 or `dsa.`maxValue to payback 100%. |
| getId     | number  | ID fetches the amount of token to deposit.                                 |
| setId     | number  | ID stores the amount of token deposited.                                   |

## Liquidate

This connector will execute a liquidation on Compound

```
spells.add({
  connector: "compound",
  method: "liquidate",
  args: [borrower, tokenToPay, tokenInReturn, amount, getId, setId]
});
```

| Parameter     | Type    | Description                                                                  |
| ------------- | ------- | ---------------------------------------------------------------------------- |
| borrower      | address | Borrower's Address.                                                          |
| tokenToPay    | address | Token Address to pay for liquidation.                                        |
| tokenInReturn | address | Token Address to return on liquidation.                                      |
| amount        | number  | The amount of tokens to payback. use -1 or \`dsa.maxValue\` to payback 100%. |
| getId         | number  | ID fetches the amount of token to payback.                                   |
| setId         | number  | ID stores the amount of token paid back.                                     |

## Deposit cToken

Similar to the [Deposit](/instadapp-docs/dsa-sdk/connectors/compound.md#deposit) connector except this connector stores the deposit value in **cTokens** in setId

```
spells.add({
  connector: "compound",
  method: "depositCToken",
  args: [token, amount, getId, setId]
});
```

| Parameter | Type    | Description                                                                  |
| --------- | ------- | ---------------------------------------------------------------------------- |
| token     | address | The token address to deposit.                                                |
| amount    | number  | The amount of tokens to deposit. use -1 or \`dsa.maxValue\` to deposit 100%. |
| getId     | number  | ID fetches the amount of token to deposit.                                   |
| setId     | number  | ID stores the amount of ctoken minted.                                       |

## Withdraw cToken

Similar to the [Withdraw](/instadapp-docs/dsa-sdk/connectors/compound.md#withdraw) connector except this connector fetches the cToken amount in getId

```
spells.add({
  connector: "compound",
  method: "withdrawCToken",
  args: [token, amount, getId, setId]
});
```

| Parameter | Type    | Description                                                                     |
| --------- | ------- | ------------------------------------------------------------------------------- |
| token     | address | The token address to withdraw.                                                  |
| amount    | number  | The amount of ctokens to withdraw. use -1 or \`dsa.maxValue\` to withdraw 100%. |
| getId     | number  | ID fetches the amount of ctoken to withdraw.                                    |
| setId     | number  | ID stores the amount of token withdrawn.                                        |
