> 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/dydx.md).

# dYdX

Interact with the dy/dx Protocol

## Deposit

This connector deposits assets into the dYdX protocol

```
spells.add({
  connector: "dydx",
  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 withdraw tokens from the dYdX protocol

```
spells.add({
  connector: "dydx",
  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 the dYdX protocol

```
spells.add({
  connector: "dydx",
  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 from the dYdX protocol

```
spells.add({
  connector: "dydx",
  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 pay back                                   |
| setId     | number  | ID stores the amount of token paid back                                      |
