# Deposit and Join

This section outlines the process to deposit tokens into a Bancor liquidity pool and join the rewards program in a single transaction.

This process reduces gas costs and ensures your tokens are earning the maximum available yield.

### 1. Approve

In order for the contract to interact with the tokens in your wallet and perform the transaction, an *`Approval`* must be set first for the contract.

{% hint style="info" %}
If you wish to deposit ETH or have already set approval for a very large amount for the token, skip to [step 3](#3.-function-depositandjoin).
{% endhint %}

* Visit the relevant token contract. \
  This can be found on Etherscan by searching for the token ticker, or by clicking the Etherscan link on Coingecko token pages. \
  For example: [BNT](https://etherscan.io/token/0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c#writeContract) | [DAI](https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f#writeContract) | [LINK](https://etherscan.io/token/0x514910771af9ca656af840dff83e8264ecf986ca#writeContract)
* Connect your wallet as explained in "[Using Etherscan](https://docs.bancor.network/guides/bancor-etherscan-guide/broken-reference)"
* Execute the `Approve` function (this is a Write function)

<table data-header-hidden><thead><tr><th width="220"></th><th></th></tr></thead><tbody><tr><td>_spender</td><td>The address of the <em><code>StandardRewards</code></em> <a href="broken-reference">found here</a></td></tr><tr><td>_value</td><td>The amount you would like to approve (it can be identical or larger than the amount you wish to deposit, BUT NOT LESS) in <code>WEI</code> format as <a href="broken-reference">explained here</a></td></tr></tbody></table>

![](https://273705617-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC9gDtGR2KNhur3c7qIJR%2Fuploads%2Fwd4dY60fjcJIrTeYlVQF%2Fimage.png?alt=media\&token=1d002cc6-1da0-47bb-ab92-01a2b2c9c459)

* Click `Write` to sign the *`Approve`* in your wallet

### 2. Function latestProgramId()

In order to join the latest rewards program, you first need to identify the token's **program ID**.

* Visit the *`StandardRewards`* contract [on etherscan](https://etherscan.io/address/0xb0B958398ABB0b5DB4ce4d7598Fb868f5A00f372#readProxyContract)
* Execute the `latestProgramId` function (this is a Read function)

![](https://273705617-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC9gDtGR2KNhur3c7qIJR%2Fuploads%2FQ5g8Q8sqrIXwMahUsOWg%2Fimage.png?alt=media\&token=9fa02ef2-f818-4c56-b033-b55a2369d6c3)

`Input variable`

| Name | Type  | Description                                  |
| ---- | ----- | -------------------------------------------- |
| pool | Token | The address of the token you wish to deposit |

{% hint style="info" %}
For ETH use *0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE*
{% endhint %}

`Output response`

| Name | Type    | Description                                                                |
| ---- | ------- | -------------------------------------------------------------------------- |
| id   | uint256 | The unique identifier for the latest program available for the input token |

{% hint style="info" %}
You will require the id value for the depositAndJoin function.
{% endhint %}

### 3. Function depositAndJoin()

{% hint style="danger" %}
Some pools might be in deficit which might effect the ability to withdraw the full amount you have deposited ([more info](https://blog.bancor.network/market-conditions-update-june-19-2022-e5b857b39336)).
{% endhint %}

Now that you know the program ID and have the approval in place, you are ready to deposit your tokens into the Bancor pool and rewards contracts.&#x20;

Execute the **depositAndJoin** function, with the id you received from the first step, and the number of tokens you wish to deposit.&#x20;

* Visit the *`StandardRewards`* contract [on etherscan](https://etherscan.io/address/0xb0B958398ABB0b5DB4ce4d7598Fb868f5A00f372#writeProxyContract)
* Execute the *`depositAndJoin`* function (this is a Write function)

![](https://273705617-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC9gDtGR2KNhur3c7qIJR%2Fuploads%2FPiwoosYSiQA3KTIGgdP3%2Fimage.png?alt=media\&token=0e4f1316-96d6-4f84-bf6c-edb3eecf3f36)

| Name           | Type    | Description                                                                                                                                                                            |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| depositAndJoin | uint256 | <p>Note:<br>IF ETH, indicate the ETH amount in full units (10.5 ETH should be indicated as 10.5)<br>For any other token, this should be set to 0</p>                                   |
| id             | uint256 | <p>The unique identifier for the latest program available for the input token <br>(extracted in <a href="#2.-function-latestprogramid">step 2</a>)</p>                                 |
| tokenAmount    | uint256 | The token (i.e BNT, ETH, DAI, LINK) amount you would like to deposit (using `WEI` format [explained here](https://docs.bancor.network/guides/bancor-etherscan-guide/broken-reference)) |

Once executed successfully, the following will happen:

1. Your tokens will be deposited into the Bancor pool
2. The protocol will generate bnTokens that represent your position in the pool, and automatically stake them into the rewards contract


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bancor.network/guides/bancor-etherscan-guide/deposit-and-join.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
