# Instapool

This connector can be used to interact with Instadapp's built-in Flashpool.&#x20;

Instapool, like other flash loans, must be paid back in the same transaction in which they are withdrawn. You can view the current liquidity of the flash pool by utilizing its [resolvers](https://instadapp-3.gitbook.io/instadapp-docs/dsa-sdk/resolvers).

## Flash Borrow

This connector flash borrows tokens for the duration of the transaction

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

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

## Flash Payback

This connector pays back the flash borrowed tokens used in same transaction

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

| Parameter | Type    | Description                                                                            |
| --------- | ------- | -------------------------------------------------------------------------------------- |
| token     | address | The token address to payback.                                                          |
| getId     | number  | Always set this to 0 **(**&#x41;ll Flash Paybacks are paid in are always paid in full) |
| setId     | number  | ID stores the amount of token payed back.                                              |

## Flash MultiBorrow

This connector Flash borrows multiple tokens for the duration of the transaction

```
spells.add({
  connector: "instapool",
  method: "flashMultiBorrow",
  args: [[token_array], [amount_array], [get_array], [set_array]]
});
```

| Parameter     | Type          | Description                               |
| ------------- | ------------- | ----------------------------------------- |
| token\_array  | address array | The token addresses to borrow.            |
| amount\_array | number array  | The amount of tokens to borrow.           |
| get\_array    | number array  | ID fetches the amount of token to borrow. |
| setId         | number array  | ID stores the amount of token borrowed.   |

## Flash MultiPayback

This connector pays back the Flash Multi-borrowed tokens used in the same transaction

```
spells.add({
  connector: "instapool",
  method: "flashMultiPayback",
  args: [[token_array], [get_array], [set_array]]
});
```

| Parameter    | Type          | Description                                                                            |
| ------------ | ------------- | -------------------------------------------------------------------------------------- |
| token\_array | address array | The token addresses to payback.                                                        |
| get\_array   | number array  | Always set this to 0 **(**&#x41;ll Flash Paybacks are paid in are always paid in full) |
| set\_array   | number array  | ID stores the amount of token payed back.                                              |

## Flash PaybackOrigin

This connector returns token liquidity from the InstaPool and transfer 20% of collected fee to origin&#x20;

```
spells.add({
  connector: "instapool",
  method: "flashPaybackOrigin",
  args: [origin, token, getId, setId]
});
```

| Parameter | Type    | Description                                               |
| --------- | ------- | --------------------------------------------------------- |
| origin    | address | The address to transfer 20% of the collected fee.         |
| token     | address | The token address.                                        |
| getId     | number  | Get token amount at this ID from \`InstaMemory\` Contract |
| setId     | number  | Set token amount at this ID in \`InstaMemory\` Contract.  |

## Flash MultiPaybackOrigin

This connector return multiple token liquidity from InstaPool and transfer 20% of the fee to the origin

```
spells.add({
  connector: "instapool",
  method: "flashMultiPaybackOrigin",
  args: [origin, tokens, getId, setId]
});
```

| Parameter | Type    | Description                                                                           |
| --------- | ------- | ------------------------------------------------------------------------------------- |
| origin    | address | The address to transfer 20% of the collected fee                                      |
| tokens    | address | An array of token addresses. (For ETH use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) |
| getId     | number  | Get token amount at this ID from \`InstaMemory\` Contract                             |
| setId     | number  | Set token amount at this ID in \`InstaMemory\` Contract                               |

## Add Fee Amount

This connector adds a fee amount to the Flashloan borrowed

```
spells.add({
  connector: "instapool",
  method: "addFeeAmount",
  args: [token, amt, getId, setId]
});
```

| Parameter | Type    | Description                                               |
| --------- | ------- | --------------------------------------------------------- |
| token     | address | The address of the token in which flashloan is borrowed.  |
| amt       | number  | The amount of flashloan fee to be added.                  |
| getId     | number  | Get token amount at this ID from \`InstaMemory\` Contract |
| setId     | number  | Set token amount at this ID in \`InstaMemory\` Contract.  |
