# Bancor V3

Bancor is a decentralized network of on-chain automated market makers (AMMs) supporting instant, low-cost trading, as well as Single-Sided Liquidity Provision and Liquidity Protection for any listed token.

You can learn more about the specifications of Bancor Protocol and our implementation, and find various user guides in these docs.

{% hint style="danger" %}
The Bancor V3 technical documentation is a work in progress, however, smart contract functions are set and will NOT change.
{% endhint %}

{% content-ref url="/pages/-M8pYHUN8OMz8niRkWFw" %}
[Contracts & Functions](/developer-guides/contracts)
{% endcontent-ref %}

{% content-ref url="/pages/-M3ByyuiJ5S6SG2Oh2yy" %}
[Resources](/about-bancor-network/faqs/resources)
{% endcontent-ref %}

{% content-ref url="/pages/-MO736g0Iycf2XnrdYdf" %}
[Bancor Basics](/about-bancor-network/faqs)
{% endcontent-ref %}

{% hint style="info" %}
Looking for help? Visit our [Support site](https://support.bancor.network).
{% endhint %}


# Bancor Basics

Frequently asked questions about Bancor Protocol


# About Bancor

Bancor is the best DeFi staking protocol for passive income.

* Bancor is the only protocol that enables automated token trading and Single-Sided Staking.
* Overseen by the Bancor DAO, the protocol’s mission is to facilitate simple and safe access to decentralized trading and yield.
* Launched in 2017, Bancor was the first DeFi protocol. Today, it generates millions in fees for depositors
* Bancor is the preferred treasury management solution of 30+ DAOs including UMA, Paraswap, Nexus Mutual, KeeperDAO, BarnBridge & WOO Network DAO.


# What Can I Do With Bancor?

* Perform instant, automated token trades.
* Earn interest by providing liquidity with [Single-Sided Liquidity.](/about-bancor-network/faqs/single-side-liquidity)
* Propose a token for whitelisting by the Bancor DAO.
* Flashloan trading and transactions.
* Integrate Bancor's on-chain trading and yield features into any application.


# Liquidity Pools

Liquidity pools are automated market maker (AMM) smart contracts that exchange assets algorithmically using on-chain reserves.

Liquidity on traditional asset exchanges has historically been provided by a small handful of professional trading firms with permissioned access and specialized tools. This concentrates liquidity in the hands of a few actors who can withdraw and manipulate assets during periods of volatility and restrict trading when users need it the most.

In contrast, AMM pools allow liquidity to flow from an unlimited number of everyday users, lowering the barrier to token creation and yield generation, and increasing resistance to market manipulation and censorship.

Launched in June 2017, Bancor created the first-ever network of AMMs on the blockchain. Since then, AMM liquidity pools have evolved into a core building block of decentralized finance (DeFi), attracting over $30 billion in locked value across numerous blockchains.

##


# Single-Side Liquidity

Bancor supports Single-Sided Staking for any listed asset.

Bancor natively supports Single-Sided Liquidity Provision of tokens in a liquidity pool. This is one of the main benefits to liquidity providers that distinguishes Bancor from other DeFi staking protocols.

Typical AMM liquidity pools require a liquidity provider to provide two assets. Meaning, if you wish to deposit "TKN1" into a pool, you would be forced to sell 50% of that token and trade it for "TKN2". When providing liquidity, your deposit is composed of both TKN1 and TKN2 in the pool.

Bancor Single-Side Staking changes this  and enables liquidity providers to:

* Provide *only* the token they hold (TKN1 from the example above)
* Collect liquidity providers fees in TKN1&#x20;


# Why Use Bancor?

With Bancor, we designed a [Single-Sided Staking](/about-bancor-network/faqs/single-side-liquidity) system that allows liquidity providers to:

* **Provide only the token you love:** No more 50/50 split; deposit only one token and earn.
* **Auto-compounding fees**: Trading fees are automatically re-added to your deposit, compounding your gains.
* **Rewards**: Earn Liquidity Mining Rewards that are auto-compounding.


# Resources

Learn about Bancor, use the protocol and engage with the community

* [Bancor Github](https://github.com/bancorprotocol/contracts-v3)
* [Bancor.network App](https://www.bancor.network/)
* [Bancor Analytics Dashboard](https://analytics.bancor.network/)
* [Bancor Discord](https://discord.gg/bancor)
* [Bancor DAO Governance](http://gov.bancor.network/) (Discourse)
* [Bancor DAO Voting](https://vote.bancor.network/) (Snapshot)
* Telegram: [Protocol](https://t.me/bancor), [Traders](https://t.me/bancortraders), [Developers](https://t.me/BancorDevelopers)
* [Medium blog](https://blog.bancor.network/), [Twitter](https://twitter.com/Bancor), [YouTube](https://www.youtube.com/channel/UCA125wWsdbsG1XPenWcBkyg)

### Guides

* [Staking guide](https://support.bancor.network/hc/en-us/articles/5465153442194-Bancor-Staking-Guide)

{% embed url="<https://www.youtube.com/watch?v=936fWa721tQ>" %}

* [Trading guide](https://support.bancor.network/hc/en-us/articles/5113733073042-Bancor-Trading-Guide)

### Analytics

* [Analytics Dashboard](https://analytics.bancor.network/)
* [Bancor Simulator](https://simulator.bancor.network/chapters/bancor-simulator.html)
* [Dune Analytics](https://duneanalytics.com/Bancor/bancor_1)
* [Bancor Subgraph](https://subgraphs.messari.io/subgraph?endpoint=https://api.thegraph.com/subgraphs/name/messari/bancor-v3-ethereum\&tab=protocol) (Messari)
* vBNT Burn Rate & Pool Alerts ([BancorVortex](https://twitter.com/BancorVortex))
* [Bancor APIs](https://docs.bancor.network/rest-api/api-reference)
* [Token Terminal](https://www.tokenterminal.com/terminal/projects/bancor)

### Papers:

* [Bancor V3 Technical Primer](https://drive.google.com/drive/folders/1TUNF7gOFitTkl52-PGqS4m28edp-eyst) (December, 2021)
* [Bancor V3 Governance Proposal](https://gov.bancor.network/t/bip15-proposing-bancor-3/3445)
* [Bancor V2.1 Economic Analysis](https://drive.google.com/file/d/1en044m2wchn85aQBcoVx2elmxEYd5kEA/view) ([TopazeBlue](https://topaze.blue/))
* [Study: Impermanent Loss in "Concentrated Liquidity" AMMs](https://arxiv.org/abs/2111.09192) (November, 2021)
* [Bancor Whitepaper](https://storage.googleapis.com/website-bancor/2018/04/01ba8253-bancor_protocol_whitepaper_en.pdf) (2018)

### Bancor V3 Explainers

* [Bancor V3 Governance Proposal (BIP 15)](https://gov.bancor.network/t/bip15-proposing-bancor-3/3445)
* [Bancor Tokenomics](https://medium.com/@kaishinaw/bancor3-tokenomics-a-new-token-model-53f7892267ec)
* [Bancor V3 Phase I Summary](https://blog.bancor.network/bancor-v3-phase-1-governance-proposal-summary-b5b31bbc687d)
* Explainer Videos: [Part I](https://www.youtube.com/watch?v=vplyoEbM83I), [Part II](https://www.youtube.com/watch?v=ZGQU-4geDLU), [Part III](https://www.youtube.com/watch?v=ImG_RblBLVg)
* [Bancor V3: The Next Step Forward for DeFi? (Aylo)](https://alphapls.substack.com/p/bancor-v3-step-forward-for-defi?s=w)
* [Complete Guide to Bancor V3 (Blocmates)](https://blocmates.com/blogmates/a-complete-guide-to-bancor-3-dawn/)
* [Nansen report on Bancor V3](https://twitter.com/nansen_alpha/status/1509805674598854656)

## ***More information***

* [Bancor V2.1 Technical Docs](https://bancor-network.gitbook.io/v2.1/)

***Trading:***

* [Connecting Your Wallet](https://www.youtube.com/watch?v=-bqI7IsC6c0\&t=117s)
* [Trading Tokens](https://www.youtube.com/watch?v=QlqDlZAHSLg\&t=4s)
* [Gas-Free Limit Orders](https://www.youtube.com/watch?v=KaU3ssaK4N8\&t=7s)
* [Buy ETH with Fiat on Bancor](https://www.youtube.com/watch?v=x_usnvlIu7g)

***Protocol:***

* [vBNT Burning](https://blog.bancor.network/vbnt-burning-is-live-cd814c2b07fa)
* [Bancor Protocol ELI5](https://www.youtube.com/watch?v=MQa8_4s9wMo) (MBR)
* [Say Adios to Impermanent Loss with Bancor](https://www.youtube.com/watch?v=dJYjx9_OK6A) (The Defiant)
* [How Bancor's Impermanent Loss Protection Works](https://www.youtube.com/watch?v=6YA61LeJqE8) (Economics Design)
* [Bancor: the Crypto Passive Income Powerhouse](https://www.youtube.com/watch?v=4clRscC9BR0\&t=2s) (DeFi Donut)
* [Bancor Vortex ](https://www.youtube.com/watch?v=SbUqcbNqQ-Y)(MBR)
* [Lazy Yield Hacking with Bancor](https://www.youtube.com/watch?v=8YpNh27HD0Y) (Amadeo Brands)
* [vBNT Burning](https://www.youtube.com/watch?v=cWg-oTm5OM8\&t=3s) (Taiki Maeda)

***Governance:***

* [Template for Token Whitelist Proposals](https://docs.google.com/document/d/1PE39vDz6uefxvibEtESGTdU2pUnqfmT0wpiqZscbf3w/edit)
* [How to Submit Proposals in the Bancor DAO](https://blog.bancor.network/a-guide-to-bancordao-due-process-d958ceade75)
* [How to Delegate Voting Power in the Bancor DAO](https://blog.bancor.network/how-to-delegate-voting-power-in-the-bancordao-b82df46be416)

***Progress Reports**:*&#x20;

* Weekly updates on[ blog.bancor.network](https://blog.bancor.network/)

### Speaking

* [Cryptotesters](https://twitter.com/cryptotesters/status/1372606017477955592?s=20)
* [Blockcrunch](https://podcasts.apple.com/us/podcast/alpha-leak-how-bancor-solves-impermanent-loss-nate/id1350649166?i=1000513405411)
* [DeFiYield](https://www.youtube.com/watch?v=U_I1vWvI9r4\&t=239s)
* [Saffron Academy](https://www.youtube.com/watch?v=TjOeUd_BRNQ)
* [Crypto Valley Conference: What Are Liquidity Pools & What is IL?](https://www.youtube.com/watch?v=zI_NFEH1xsQ)


# Resources for DAOs

Bancor can be a liquidity solution for DAO treasuries and their tokens. Before a new token can be added to Bancor, however, it must first be whitelisted via a Bancor DAO vote. &#x20;

To see if your token is eligible for Bancor, see [Token Whitelisting Requirements](/about-bancor-network/resources-for-daos/token-whitelisting-requirements).

For information on creating a rewards program for your token, see [Liquidity Mining](/about-bancor-network/resources-for-daos/liquidity-mining).&#x20;


# Token Whitelisting Requirements

[**See the most up to date technical requirements for whitelisting.**](https://gov.bancor.network/t/whitelisting-requirements/1849)

***Requirements:***

### Transparency&#x20;

1. The token contract needs to be verified on Etherscan.&#x20;
2. The token contract should have an audit from a known security auditor or explain why it wasn’t audited (for example, if it’s a standard token from the OpenZeppelin library).&#x20;
3. The project should have a publicly visible test suite with decent test coverage.

### Administrative Risk&#x20;

Special administrative privileges over the protocol - such as minting privileges - should be restricted:

1. They **should not** be owned by EOA.&#x20;
2. They can be governed by multisigs.&#x20;
3. They can enforce timelock or similar restrictions.

Protocols that don’t comply with this should provide an explanation why (the DAO reserves the right to decide whether to accept the explanation or not).

The above **may not** contradict with the technical requirements - e.g. an upgradable token can not be whitelisted regardless of the reasoning.

### Technical&#x20;

1. The token contract should not be upgradable.&#x20;
2. Only the token holders themselves should be able to transfer or burn their tokens. It shouldn’t be possible for any other account (including owners/admins) to transfer or burn tokens belonging to other users, without their explicit permission.&#x20;
3. Minting of new tokens should be restricted and conform to the whitepaper and the security audit.&#x20;
4. Rebasing tokens or tokens with elastic supply aren’t currently supported.&#x20;
5. Tokens that apply transfer fees aren’t currently supported.&#x20;
6. Token transfers shouldn’t be pausable or subjected to a whitelist unless a reasonable explanation is provided.&#x20;
7. There should not be any restrictions on transferring or trading (e.g., restricting how many blocks you have to hold a token before you can transfer it, fees/taxes on transfers, including to/from trading pools, etc.)&#x20;
8. The token should not have any transfer hooks (notifications on sender/recipient etc.) as those open the possibility for re-entrancy issues

### Economic Requirements&#x20;

1. The token should be fairly distributed (e.g., it can’t be concentrated in a few addresses). If not, the token can only be whitelisted if they provide external liquidity protection equal to the proposed trading liquidity.
2. Deprecated tokens cannot be whitelisted if already deprecated at the time of the proposal


# Liquidity Mining

Bancor V3 enables several ways to incentivize liquidity providers. Incentives in Bancor V3 include Auto Compounding Rewards, which are rewards given in the same token as a liquidity pool, and Standard Rewards, which are rewards given in a different token.

This flexibility provides additional utility to the incentive structure, creating new ways for teams and community members to support their favorite token projects.&#x20;

[Auto Compounding Rewards](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards)

[Standard (External) Rewards](/about-bancor-network/resources-for-daos/liquidity-mining/standard-external-rewards)


# Auto Compounding Rewards

Bancor V3 enables liquidity providers to opt-in and collect rewards with a **gasless** process, simply by depositing their tokens in the pool of their choice. Rewards are automatically compounded into each liquidity provider's position.&#x20;

For more details, see the following sections:

* [How Auto Compounding Rewards Work](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards/how-auto-compounding-rewards-work)
* [How to Create an Auto Compounding Rewards Program](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards/how-to-create-an-auto-compounding-rewards-program)
* [Custom Rewards Programs](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards/custom-rewards-programs)


# How Auto Compounding Rewards work

Every pool has the ability to mint/burn pool tokens following a user deposit or withdrawal. The Bancor Auto Compounding Rewards contract inherits the ability to burn pool tokens (only burn). The contract can only burn the bnTokens it holds.

When bnTokens are burned, the pool re-distributes the underlying (deposited) token to the remaining pool tokens, making the value of each pool token higher than before.

```
Example:
John deposits 10,000 DAI and receives 10,000 bnDAI
Jill deposits 10,000 DAI and receives 10,000 bnDAI
Each one holds 50% of the pool tokens and has access to 50% of the underlying token.
1 bnDAI = total deposited tokens/total pool token = 
1 bnDAI = 20,000 DAI / 20,000 bnDAI = 1 DAI

Assume that John deposited 2000 of his bnDAI pool tokens into 
the Auto Compounding Rewards contract, 
and set them to burn at a pace of 10 per day.
...
After 100 days:
John holds 8,000 pool tokens
Jill holds 10,000 pool tokens
Auto Compounding Rewards contract holds 1,000 pool tokens 
    (100*10=1000 bnDAI were burnt)

Deposited tokens in the pool are still 20,000 DAI
1 pool token = 20,000 DAI / 19,000 bnDAI = 1.0526315789 DAI
```


# How to Create an Auto Compounding Rewards Program

This section explains how to create an Auto Compounding Rewards Program using available bnTokens in your wallet.

{% hint style="info" %}
You will need to first add liquidity (deposit) to the pool to receive bnTokens
{% endhint %}

### Transfer bnTokens to the rewards contract

This section explains how to transfer bnTokens to the Auto Compounding Rewards contract:

1. Open your wallet and select the bnToken that will be given as rewards
2. Set the *`ExternalRewardsVault`* ([on etherscan](https://etherscan.io/address/0x2A2A2BE5cCf20F3633c6ca2D429Ac51186a631e1#readProxyContract)) contract address as the recipient &#x20;
3. Enter the number of bnTokens to transfer:\
   ![](/files/DsMxdvpFdOyYnfV2Y9zv)
4. Transfer the bnTokens

Once pool tokens have been sent, the DAO multisig will set them up for distribution according to the [default rewards schedule](#default-rewards-schedule), **unless a custom rewards schedule has been communicated beforehand**. See [Custom Rewards Programs](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards/custom-rewards-programs) for more details.&#x20;

### Default Rewards Schedule

The default rewards schedule is:

* Length: 1 year
* Distribution: Linear (flat)&#x20;

This means that rewards would be distributed equally over a 1-year time span.

```
Example:
Assume 50,000 bnTokens were transferred
Emission would be:
50,000 bnTokens / 365 days = 136.9863013699 bnTokens per day 
```

### Reward Implementation by the DAO

The [DAO multisig](/about-bancor-network/security-and-audits/dao-msig-intervention-policy) implements required tasks, such as rewards programs, periodically (typically twice a week).

Once implemented, the program will start and value will start moving to the liquidity providers.&#x20;


# Custom Rewards Programs

The [default rewards schedule](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards/how-to-create-an-auto-compounding-rewards-program#default-rewards-schedule) was designed to "fit all," providing a good balance between program length and emissions. However, Bancor enables flexibility which allows projects to design their own custom rewards schedule and control the different parameters that affect the duration and emission.&#x20;

### Customizable Emissions

Bancor supports two types of programs that can be adjusted by the projects:

#### Flat (linear) emission

{% hint style="success" %}
Popular
{% endhint %}

Flat emissions will emit the same amount of tokens per second for the selected duration.

Please indicate the following value:

* **Time span:** The length of the program (i.e. 365 days, 58,800 minutes, etc).&#x20;

#### Exponential decay emission

{% hint style="danger" %}
Advanced
{% endhint %}

Exponential decay emission will emit an ever-reducing amount of rewards over time using a bonding curve.

Please indicate the following value:

* **Half life:** This value indicates the time needed to give out half the available rewards. (i.e. setting this to 1 year, will force to give half of available rewards over the first year, then half of the remainder over the next year, etc.)

### Requesting a Custom Rewards Program

To create a custom rewards schedule, create a post in our [governance forum](https://gov.bancor.network/c/bancor-marketing-discussion/12) with:

1. The TX in which the LP tokens were sent to the External Rewards contract
2. The market price of the Token & BNT at the time it was sent
3. The desired rewards schedule, including:&#x20;
   1. The time span / half life
   2. The distribution type (linear or exponential)

### Example Request

Topic: Custom Rewards Program for our Token

```
Hey Bancor,

We would like to create a custom auto compounding rewards schedule for our token! 

Here is the TX in which we sent the pool tokens: 0xfb321f16f08aea1d378efc8d82d26d02e5319863e9c131262a4f6cfa2004d4a4

Market price of Token: $0.25
Market price of BNT: $1.36
Rewards Time length: 2 years
Distribution type: linear

Thanks!
```


# Dual Liquidity Mining

Bancor V3 enables the possibility for liquidity providers to receive rewards in two tokens at the same time, referred to as Dual Liquidity Mining. Pools with Dual Liquidity Mining will receive [Auto Compounding Rewards](/about-bancor-network/resources-for-daos/liquidity-mining/auto-compounding-rewards) and BNT rewards through the [Standard Rewards](/about-bancor-network/resources-for-daos/liquidity-mining/standard-external-rewards) at the same time.&#x20;

### Bancor V3 Boostrap Inititative

To help bootstrap Bancor V3, the Bancor DAO has voted for qualifying projects that provide Auto Compounding Rewards to receive a match of up to 50,000 BNT tokens, distributed through Standard Rewards over 2 years.&#x20;

Qualification requirements are outlined in [this governance vote](https://vote.bancor.network/#/proposal/0x9a12eff6d3a9f434101a1fc2dddeac3b1cf7eda590d00b7688e0dfd1f1938382).&#x20;


# Standard (External) Rewards

In Bancor version 3, rewards can be distributed to a liquidity pool in any token using the Standard Rewards contract. For example, a project could distribute its earnings to token holders by creating a rewards program that distributes USDC.&#x20;

This mechanism also enables rewards to be distributed in 2 different tokens at the same time, referred to as [Dual Liquidity Mining](/about-bancor-network/resources-for-daos/liquidity-mining/dual-liquidity-mining).&#x20;

Standard Rewards will be used to distribute BNT rewards in the Bancor V3 bootstrapping campaign.&#x20;

{% hint style="info" %}
Rewards earned from a Standard Rewards program do not automatically compound, as they are a different token than the one provided - they must be claimed.&#x20;
{% endhint %}

### Standard Rewards vs Auto Compounding Rewards

Standard Rewards differ from Auto Compounding Rewards in the following ways:

|                        | Standard Rewards                                                                                                                                                                                                                                                               | Auto Compounding Rewards                                                                      |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------- |
| Reward token           | Any token (deposited or non-deposited)                                                                                                                                                                                                                                         | <p>Deposited token only<br>(i.e. for a DAI deposit, rewards can only be in the DAI token)</p> |
| Requires manual opt-in | <p>Yes - users must manually:<br>1. Join the rewards program using a <code>join</code> transaction (stake bnTokens)<br>2. Claim rewards using <code>claim</code> or<code>stake</code> transaction<br>3. Exit the program using <code>leave</code> to return their bnTokens</p> | No - users receive the rewards automatically by holding bnTokens                              |


# Security & Audits

### Bancor bug bounty

* [Bancor $1M Bug Bounty](https://github.com/bancorprotocol/contracts-v3/blob/dev/docs/bug-bounty.md)&#x20;

### Security audits

* [Peckshield](https://github.com/bancorprotocol/contracts-v3/blob/dev/docs/audits/PeckShield-Audit-Report-BancorV3-v1.0.pdf)
* [OpenZeppelin](https://github.com/bancorprotocol/contracts-v3/blob/dev/docs/audits/OpenZeppelin-V3-Audit-Report.pdf)
* [OpenZepplin (Auto Compounding Rewards)](https://github.com/bancorprotocol/contracts-v3/blob/dev/docs/audits/OpenZeppelin-AutoCompoundingRewards-Audit-Report.pdf)
* Certora: To be published soon
* Chainsecurity: To be published soon


# Multisig Rights

### Powers of the Bancor DAO MSIG

* The Bancor DAO MSIG governs all aspects of Bancor V3 and is responsible for the execution of decisions that are made by the Bancor DAO.
* In emergency situations, the Bancor DAO MSIG can call the “pause” function which will pause the entire protocol. As long as the “pause” is ongoing, no deposits, withdrawals or transactions can be made until the protocol is “unpaused”. This would likely be called by the Gnosis safe 2 wallet.

### MSIG rule

5/7 members must sign for a transaction to be executed.

### MSIG Signers

1. Foundation proposed signatory&#x20;
2. Foundation proposed signatory&#x20;
3. Foundation proposed signatory&#x20;
4. Matic proposed signatory
5. Harvest Finance proposed signatory
6. 88 MPH proposed signatory
7. WOO DAO proposed signatory

### **Expectation of Signers**

* They have Bancor’s best interest at heart
* They will faithfully execute the will of the Bancor DAO as expressed by their votes
* They will be available to sign a tx when needed based on the following flow:
  1. Bancor DAO votes
  2. Bancor DAO MSIG performs the will of the voters
     * All decisions are effective immediately (upon final vote outcome)
     * The MSIG implementation stage follows:
       * Minimum 2 days of [public community discussion](https://gov.bancor.network/t/a-guide-to-bancordao-due-process/1669)
       * 3 days of voting window (where it needs to meet [vote criteria](https://gov.bancor.network/t/bip20-quorum-and-supermajority-requirements/3503))&#x20;


# Oracles

### External Oracles

Bancor V3 does not use external oracles for price discovery.

### Internal Oracles

Bancor V3 pools calculate the EMA (**E**xponential **M**oving **A**verage).

The EMA is a type of [weighted moving average (WMA)](https://www.investopedia.com/terms/l/linearlyweightedmovingaverage.asp) that gives more weighting or importance to recent price data. The EMA is used to see price trends over time.&#x20;

{% hint style="info" %}
This was recently updated from the use of SMA (**S**imple **M**oving **A**verage) which included time as a factor in calculating the SMA rate. This new calculation (EMA), is more resilient to price manipulation even on smaller pools.
{% endhint %}


# DAO MSIG Intervention Policy

{% hint style="info" %}
Based on a DAO proposal ([link](https://gov.bancor.network/t/bip21-dao-multisig-intervention-policy/3504)) and vote ([link](https://vote.bancor.network/#/proposal/0x69e6083f6fb711185f51b7e0cdcafd29e96a40fabe62c927681701c09bcabd0d))
{% endhint %}

## Overview

The prerequisites for whitelisting a token on Bancor are in place to prevent attempted exploits of the Bancor protection mechanism. However, hacks and exploits, and coordinated exits (“rug-pulls”) affecting a token that has passed the vetting process can still become a threat to the system.

This proposal provides a detailed policy whereby the BancorDAO can intervene in the operation of affected pools, immediately after a token has become compromised.

The scope of the interventions available to the DAO authority are:

1. Adding liquidity is disabled on the affected pool.
2. Swaps are disabled on the affected pool.
3. The DAO isn’t allowed to intervene with the withdrawal of funds, save for the adjustments to the protection mechanism.

The actions of the operations multi-sig signers must then be ratified with a DAO vote. The signers must provide a short report that describes the motivation behind any actions taken, and publish it to [Discourse 1](http://gov.bancor.network/) in a timely manner. The DAO will then vote to uphold or reverse the decision via the normal process.

This format allows for action to be taken to protect the protocol in time-sensitive situations. The requirement for retroactive community approval preserves the integrity and authority of the BancorDAO

![](/files/Q0U10FxSojZZBoyrNhby)

### Some Threats Cannot be Anticipated on Long Time Horizons <a href="#some-threats-cannot-be-anticipated-on-long-time-horizons-3" id="some-threats-cannot-be-anticipated-on-long-time-horizons-3"></a>

The [prerequisites for whitelisting a token](https://gov.bancor.network/t/whitelisting-requirements/1849) on Bancor provide a helpful filter against predictable security risks. A reasonable scope of common abuse vectors are covered that provide a high level of protection from deliberate exploit attempts, hacks, and other nefarious behavior that could allow an antagonist to siphon value from the network. However, an element of risk will always persist, where events elsewhere in the Defi ecosystem can affect the health of a pool, regardless of the community’s diligence during whitelisting.

There are an infinite number of possible scenarios where a fully-audited, vetted and community-approved token for a respectable and trustworthy project can turn malignant. For example, a large reservoir of the token could be drained from another protocol, AMM or otherwise, which could then be used to perform a very large trade on Bancor. In such a scenario, neither the token’s ERC20 contract nor the team that created it are at fault, and anticipating these types of attack vectors for all tokens on our network is simply untenable.

### DAO Bureaucracy is Effective, but Slow <a href="#dao-bureaucracy-is-effective-but-slow-4" id="dao-bureaucracy-is-effective-but-slow-4"></a>

The BancorDAO has demonstrated an exceptional ability to govern. Processes have been created that ensure a high level of engagement and community awareness, albeit at a significant time cost. The time interval between the appearance of a well-considered and polished proposal on Discourse, and executing the relevant actions following a successful DAO vote is simply too long to be a tenable route to intercepting an apparent threat, after it is discovered. Moreover, the fact that such a proposal exists serves to advertise the exploit opportunity, heightening the risk that an antagonist might act on it. In short, the existing channels for the DAO to exercise its powers are rendered impotent in the face of an oncoming and imminent attack, or an exploit in an external contract that can damage the protocol unintentionally.

### Retroactive, Time-Sensitive Decisions <a href="#retroactive-time-sensitive-decisions-5" id="retroactive-time-sensitive-decisions-5"></a>

Some threats can be anticipated, and presents a short window of time wherein the DAO multi-sig signers can act, thus eliminating or reducing damage to the Bancor Network. With the acceptance of this proposal, the DAO is agreeing to allow the mult-sig signers to act appropriately when a perceived, avoidable risk becomes known. The actions that the mult-sig authority may take prior to a formal DAO vote are strictly limited. To prevent theft, or another problem arising from a known issue affecting certain tokens, the DAO will allow the multi-sig authority to temporarily cease swaps and liquidity provision to affected pools, as required. These actions need not be executed together; depending on the nature of the perceived threat, it may only be necessary to exercise only one of these options rather than all of them. Importantly, user withdrawals must not be inhibited.

### Ratification of Actions Taken <a href="#ratification-of-actions-taken-6" id="ratification-of-actions-taken-6"></a>

After the multi-sig signers have interrupted the functioning of a pool, a written report must be made available that clearly describes the rationale for the actions taken, and provide sufficient evidence for DAO members to consider whether the action was warranted. This is unlikely to be controversial. Thereafter, the report will be incorporated into a formal DAO proposal, and the actions of the mult-sig signers will be ratified via the voting process. This is especially important if the measures taken to protect the protocol are expected to persist indefinitely.

### False Alarms and Reactivation <a href="#false-alarms-and-reactivation-7" id="false-alarms-and-reactivation-7"></a>

If due to a misunderstanding, or misinterpretation of the perceived threat, or it being nullified in a timely manner, the MSIG signers may reverse the actions taken to restore proper functioning of the pool, prior to a DAO vote. Under these circumstances, a written report must be made available, regardless of the decision reversal. The report should detail precisely why action was taken, and reasoning for its reversal. In these cases, the report should be published to the governance Discourse pages, under the Community Chatroom category (as the report is not a draft proposal, and will not result in a vote).


# Contracts

### Bancor V3 Github

All Bancor contracts are visible on [Github](https://github.com/bancorprotocol/contracts-v3/tree/master/contracts).

### Bancor V3 contracts

{% hint style="info" %}
Bancor contracts use`Proxy,` which means these addresses will not change.
{% endhint %}

<table><thead><tr><th width="255.33333333333331">Name</th><th width="256.56316201560134">Address</th><th>Description</th></tr></thead><tbody><tr><td><em><code>AutoCompoundingRewards</code></em></td><td><em><code>0x036f8B31D78ca354Ada40dbd117e54F78B6f6CDc</code></em><br><a href="https://etherscan.io/address/0x036f8b31d78ca354ada40dbd117e54f78b6f6cdc#code">View on etherscan</a></td><td>This contract manages auto compounding reward programs.</td></tr><tr><td><em><code>vBNT BancorGovernance</code></em></td><td><em><code>0x892f481BD6E9d7D26aE365211D9B45175d5D00e4</code></em><br><a href="https://etherscan.io/address/0x892f481BD6E9d7D26aE365211D9B45175d5D00e4#code">View on etherscan</a></td><td>Bancor vBNT governance contract.</td></tr><tr><td><em><code>BNT BancorGovernance</code></em></td><td><em><code>0xebFaFc802533F3D2835Af7464Fcd4492e8F82eB2</code></em><br><a href="https://etherscan.io/address/0xebFaFc802533F3D2835Af7464Fcd4492e8F82eB2">View on etherscan</a></td><td>Bancor BNT governance contract.</td></tr><tr><td><em><code>BancorNetwork</code></em></td><td><em><code>0xeEF417e1D5CC832e619ae18D2F140De2999dD4fB</code></em><br><a href="https://etherscan.io/address/0xeEF417e1D5CC832e619ae18D2F140De2999dD4fB#code">View on etherscan</a></td><td>This contract serve as the entry point for all interactions with Bancor.</td></tr><tr><td><em><code>BancorNetworkInfo</code></em></td><td><em><code>0x8E303D296851B320e6a697bAcB979d13c9D6E760</code></em><br><a href="https://etherscan.io/address/0x8E303D296851B320e6a697bAcB979d13c9D6E760#code">View on etherscan</a></td><td>This contract holds all Read functions and allow easy process to collect information.</td></tr><tr><td><em><code>BancorPortal</code></em></td><td><em><code>0x9f292ccB69fF9A0644475C7bC8d4651039e133d5</code></em><br><a href="#undefined">View on etherscan</a></td><td>A utility contract that allows easy, single click migration from other platforms to Bancor.</td></tr><tr><td><em><code>BancorV1Migration</code></em></td><td><em><code>0xd761D538240E23B465c9c08236D781029DC3cc96</code></em><br><a href="https://etherscan.io/address/0xd761D538240E23B465c9c08236D781029DC3cc96#code">View on etherscan</a></td><td>A utility contract that allows easy, single click migration from legacy V1 Bancor pool tokens to V3.</td></tr><tr><td><em><code>BNTPool</code></em></td><td><em><code>0x02651E355D26f3506C1E644bA393FDD9Ac95EaCa</code></em><br><a href="https://etherscan.io/address/0x02651E355D26f3506C1E644bA393FDD9Ac95EaCa#code">View on etherscan</a></td><td>This contract manages protocol owned liquidity funding.</td></tr><tr><td><code>ExternalILVault</code></td><td>0xFd31662b3d54eddE9B6Bdd32c9c27C8E292cAD57<br><a href="https://etherscan.io/address/0xfd31662b3d54edde9b6bdd32c9c27c8e292cad57">View on etherscan</a></td><td>This contract holds tokens for impermanent loss protection that were provided externally.</td></tr><tr><td><em><code>ExternalRewardsVault</code></em></td><td><em><code>0x2A2A2BE5cCf20F3633c6ca2D429Ac51186a631e1</code></em><br><a href="https://etherscan.io/address/0x2A2A2BE5cCf20F3633c6ca2D429Ac51186a631e1#code">View on etherscan</a></td><td>This contract holds rewards that are provided by external parties.</td></tr><tr><td><em><code>MasterVault</code></em></td><td><em><code>0x649765821D9f64198c905eC0B2B037a4a52Bc373</code></em><br><a href="https://etherscan.io/address/0x649765821D9f64198c905eC0B2B037a4a52Bc373#code">View on etherscan</a></td><td>This contract holds all token deposits.</td></tr><tr><td><em><code>NetworkSettings</code></em></td><td><em><code>0x83E1814ba31F7ea95D216204BB45FE75Ce09b14F</code></em><br><a href="https://etherscan.io/address/0x83E1814ba31F7ea95D216204BB45FE75Ce09b14F#code">View on etherscan</a></td><td>Hold global protocol settings and pool funding limits.</td></tr><tr><td><em><code>PendingWithdrawals</code></em></td><td><em><code>0x857Eb0Eb2572F7092C417CD386BA82e45EbA9B8a</code></em><br><a href="https://etherscan.io/address/0x857Eb0Eb2572F7092C417CD386BA82e45EbA9B8a#code">View on etherscan</a></td><td>This contract holds bnTokens that are pending liquidation during cooldown.</td></tr><tr><td><em><code>PoolCollection</code></em><br><em><code>(not proxy)</code></em></td><td>This address changes from time to time. To identify the latest address, please follow the <a href="/pages/IQ7EyAO9g4JeqWv1DNfT">collectionByPool() guide</a></td><td>Manages liquidity pools.<br></td></tr><tr><td><em><code>PoolMigrator</code></em></td><td><em><code>0x97CeC0F2D355BF073619A5093F989709caE4a191</code></em><br><a href="https://etherscan.io/address/0x97CeC0F2D355BF073619A5093F989709caE4a191#code">View on etherscan</a></td><td>This utility contract migrates pools during upgrades etc.</td></tr><tr><td><em><code>StandardRewards</code></em></td><td><em><code>0xb0B958398ABB0b5DB4ce4d7598Fb868f5A00f372</code></em><br><a href="https://etherscan.io/address/0xb0B958398ABB0b5DB4ce4d7598Fb868f5A00f372#code">View on etherscan</a></td><td>This contract manages standard (non auto-compounding) reward programs.</td></tr></tbody></table>

### Tokens

| Name  | Address                                        | Description                               |
| ----- | ---------------------------------------------- | ----------------------------------------- |
| BNT   | *`0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C`* | The Bancor network token.                 |
| vBNT  | *`0x48Fb253446873234F2fEBbF9BdeAA72d9d387f94`* | The Bancor governance token.              |
| bnBNT | *`0xAB05Cf7C6c3a288cd36326e4f7b8600e7268E344`* | The poolToken issued against BNT deposit. |

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


# Write Functions


# Transaction Prerequisites

Before interacting with a blockchain smart contract, you need approval

Before interacting with any blockchain smart contract, approval must be granted by the user for use of their tokens.&#x20;

The options to grant approval include:

* [approve()](/developer-guides/write-functions/transaction-prerequisites/approve-allowance)
* [allowance()](/developer-guides/write-functions/transaction-prerequisites/approve-allowance)


# approve() / allowance()

Give permission for a contract to access your wallet

### approve() / allowance()

Allowance functions give permission for a contract to access your wallet and interact with (withdraw) tokens you hold.

Approval or allowance must be set prior to any transactions.&#x20;

{% hint style="info" %}
The first step in execution for smart contracts is typically for the contract to withdraw tokens from the requestor's wallet. Thus, in order to enable this, allowance must be set prior to the transaction.
{% endhint %}

[Read more about allowance functions and functionality](https://eips.ethereum.org/EIPS/eip-2612).


# Trading

2 function that enable trade flexibility

Trading tokens on Bancor is as easy as calling a single function.&#x20;

Bancor allows trading of native ETH tokens, wrapped ETH (wETH) and any other supported ERC20 tokens such as LINK, USDC, USDT, WBTC and many more.

{% hint style="info" %}
As a developer, you can simulate the trading function call with the tokens you wish to trade to see if the transaction can be completed as is, or if there are unexpected issues. If the trade can't be completed it returns an error indicating the issue, such as un-supported tokens, permissions, etc, and includes a clear way to resolve them.
{% endhint %}

Bancor now supports 2 different “trade” functions that enable greater flexibility:  &#x20;

1. [tradeBySourceAmount](#tradebysourceamount) - \
   this is the “normal” trade function where you indicate the amount you wish to trade out and receive the max possible of the selected token based on the current pool rate.&#x20;
2. [tradeByTargetAmount](#tradebytargetamount) - \
   this function allows you to indicate exactly how much you wish to receive at the end of the trade. Meaning you indicate the amount you wish to receive, and the trade will use the required amount in order to fulfill your request. The benefit of using this function is that you will know exactly how much you receive at the end. &#x20;


# tradeBySourceAmount()

Trade an exact amount of source tokens for as many target tokens as possible

### Function **tradeBySourceAmount()**

{% code title="BancorNetwork.sol" %}

```solidity
    function tradeBySourceAmount(
        Token sourceToken,
        Token targetToken,
        uint256 sourceAmount,
        uint256 minReturnAmount,
        uint256 deadline,
        address beneficiary
    ) external payable
```

{% endcode %}

Trades the exact amount of **source** tokens for as many **target** tokens as possible.&#x20;

### **Function Arguments**

<table><thead><tr><th>Name</th><th width="222.00000000000003">Type</th><th>Description</th></tr></thead><tbody><tr><td>sourceToken</td><td>Token</td><td>The source token address</td></tr><tr><td>targetToken</td><td>Token</td><td>The target token address</td></tr><tr><td>sourceAmount</td><td>uint256</td><td>The amount of source tokens</td></tr><tr><td>minReturnAmount</td><td>uint256</td><td>The minimum amount of target tokens that must be received for the transaction to not revert</td></tr><tr><td>deadline</td><td>uint256</td><td>Unix timestamp after which the transaction will revert</td></tr><tr><td>beneficiary</td><td>address</td><td>The address receiving the target tokens</td></tr></tbody></table>

See [Errors and Troubleshooting](/developer-guides/write-functions/trading/trading-troubleshooting) for a list of common errors and how to resolve them.&#x20;

{% hint style="info" %}
To trade directly with the Ether token, use the contract address: *0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE*&#x20;
{% endhint %}


# tradeByTargetAmount()

Trade target tokens for the least amount of source tokens possible

### Function **tradeByTargetAmount()**

```solidity
    function tradeByTargetAmount(
        Token sourceToken,
        Token targetToken,
        uint256 targetAmount,
        uint256 maxSourceAmount,
        uint256 deadline,
        address beneficiary
    ) external payable 
```

Trades to receive the exact amount of **target** tokens for as few **source** tokens as possible.&#x20;

### **Function Arguments**

| Name            | Type    | Description                                                                            |
| --------------- | ------- | -------------------------------------------------------------------------------------- |
| sourceToken     | Token   | The source token address                                                               |
| targetToken     | Token   | The target token address                                                               |
| targetAmount    | uint256 | The exact amount of tokens to receive                                                  |
| maxSourceAmount | uint256 | The maximum amount of source tokens that can be used for the transaction to not revert |
| deadline        | uint256 | Unix timestamp after which the transaction will revert                                 |
| beneficiary     | address | The address receiving the target tokens                                                |

See [Errors and Troubleshooting](/developer-guides/write-functions/trading/trading-troubleshooting) for a list of common errors and how to resolve them.&#x20;

{% hint style="info" %}
To trade directly with the Ether token, use the contract address: *0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE*&#x20;
{% endhint %}


# Trading Troubleshooting

Common errors for trading on Bancor v3

#### Allowance (Approve)

The `BancorNetwork` contract requires token approval to access the user's wallet and execute the transaction. Without an "Approve"/"Allowance" in place, the transaction will not be able to proceed. \
[Read more on how to trigger "Approve"/"Allowance"](/developer-guides/write-functions/transaction-prerequisites/approve-allowance)&#x20;

{% hint style="info" %}
Some tokens support **gasless** approval by using the permit() function. [Learn more](broken://pages/gwPVUFOcvbYWJKmqWtCA) on trading "Permitted" tokens.
{% endhint %}

#### Token not available

This indicates if the token is not available to be traded on Bancor V3.&#x20;

#### Deadline not valid

This indicates that the deadline is set to a time that has already passed. Fix this by changing the value to a future time.


# Adding Liquidity

Provide liquidity with only one asset

One of the innovations of Bancor v3 is that all liquidity provisions are now [single-sided](/about-bancor-network/faqs/single-side-liquidity). \
This means that only one asset is necessary in order to provide liquidity and begin earning yield, instead of needing to equally balance a pair of resources in order to provide liquidity.

{% 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 %}


# deposit()

Deposit tokens for ownership in a liquidity pool

{% 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 %}

### Function **deposit()**

{% code title="BancorNetwork.sol" %}

```solidity
    function deposit(Token pool, uint256 tokenAmount)
        external
        payable
```

{% endcode %}

`deposit` is a function that allows you to deposit tokens into a Bancor liquidity pool.

### **Function Arguments**

| Name        | Type    | Description                                      |
| ----------- | ------- | ------------------------------------------------ |
| pool        | Token   | The address of the token deposited into the pool |
| tokenAmount | uint256 | The amount to deposit                            |

{% hint style="success" %}
Bancor v3 use the Token address to indicate the pool mapping. Meaning, when asked to provide a `pool` address, you can use the `token` address.
{% endhint %}

{% hint style="info" %}
All pools on Bancor are initiated with a 1:1 ratio between reserve to pool token. Once fees are collected, this ratio will change to represent the increased value of pool tokens to reserve. For example, if the ratio is 1 pool token : 2 reserve, it means that the pool token value has doubled since initiation.
{% endhint %}

### BNT Deposits

When you `deposit` BNT into the Bancor pool, you will receive vBNT equal to the number of pool tokens.&#x20;

Bancor v3 supports infinity pools and deposits as a result. However, the trading liquidity is limited based on the `poolFundingLimit()` function.

See [Errors and Troubleshooting](/developer-guides/write-functions/adding-liquidity/deposit-troubleshooting) for a list of common errors and how to resolve them.&#x20;


# depositFor()

Deposit tokens on behalf of a different address

{% 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 %}

### Function depositFo&#x72;**()**

```
function depositFor(
        address provider,
        Token pool,
        uint256 tokenAmount
    )
        external
        payable
```

`depositFor` is a function that allows you to deposit tokens into a Bancor pool on behalf of a different address and make sure that the received pool tokens will be sent to that address (and not the transaction initiator).

### **Function Arguments**

| Name        | Type    | Description                                                                            |
| ----------- | ------- | -------------------------------------------------------------------------------------- |
| provider    | address | Indicating the address that will receive the pool tokens at the end of the transaction |
| pool        | Token   | The address of the token deposited into the pool                                       |
| tokenAmount | uint256 | The amount to deposit                                                                  |

{% hint style="info" %}
All pools on Bancor are initiated at 1:1 ratio between reserve to pool token. Once fees are collected, this ratio will change to represent the increased value of pool tokens to reserve. For example, if the ratio is 1 pool token : 2 reserve, it means that the pool token value has doubled since initiation.
{% endhint %}

See [Errors and Troubleshooting](/developer-guides/write-functions/adding-liquidity/deposit-troubleshooting) for a list of common errors and how to resolve them.


# Deposit Troubleshooting

Common errors for adding liquidity in Bancor v3


# depositAndJoin()

This function is in the StandardRewards.sol contract.

### Function depositAndJoin()

{% code title="StandardRewards.sol" %}

```solidity
function depositAndJoin(uint256 id, uint256 tokenAmount)
        external
        payable
```

{% endcode %}

This function is used to deposit tokens into a liquidity pool and simultaneously join the rewards program.&#x20;

The function accepts the ID of the rewards program and the number of tokens to deposit as arguments.&#x20;

### Function Arguments

| Name        | Type    | Description                              |
| ----------- | ------- | ---------------------------------------- |
| id          | uint256 | This is the ID of the rewards program.   |
| tokenAmount | uint256 | This is the number of tokens to deposit. |

This function does not return anything.


# Removing Liquidity

Initiating withdrawal and the withdrawal process

## Overview

Removing liquidity from Bancor pool requires the user to perform 2 transactions in a specific order to complete the withdrawal.

## Process

1. [Initiate the withdrawal process](/developer-guides/write-functions/removing-liquidity/initiating-cooldown)
2. [Complete the withdrawal process](/developer-guides/write-functions/removing-liquidity/withdraw)


# Initiating Cooldown

Stake pool tokens in withdrawal contracts with Bancor

The process of withdrawing tokens always start with the user initiating the withdrawal process.


# initWithdrawal()

Functions on the PendingWithdrawals contract

### Function **initWithdrawal()**

```
function initWithdrawal(IPoolToken poolToken, uint256 poolTokenAmount)
        external
```

The traditional function `initWithdrawal()` takes only a pool and an amount as arguments, this means that the address calling the function must be the depositor of the pool tokens or have approval from the depositor to access their pool tokens.

### **Function Arguments**

| Name            | Type       | Description                                      |
| --------------- | ---------- | ------------------------------------------------ |
| poolToken       | IPoolToken | The address of the token deposited into the pool |
| poolTokenAmount | uint256    | Amount to withdraw                               |

{% hint style="warning" %}
In order to identify the poolToken address needed for this function, follow the steps in the poolToken Mapping section
{% endhint %}


# withdraw()

Withdrawing funds

{% hint style="warning" %}
It is highly recommended to call the function [isPoolStable()](/developer-guides/read-functions/liquidity-pool-details/ispoolstable) to check if the withdrawal can currently be processed before calling withdraw().
{% endhint %}

{% hint style="info" %}
Every pending withdrawal has a unique ID. To get a list of pending withdrawals for an address, see [withdrawalRequestIds()](/developer-guides/read-functions/withdrawals/withdrawalrequestids).
{% endhint %}

### **Function withdraw()**

```solidity
function withdraw(uint256 id) external whenNotPaused nonReentrant returns (uint256)
```

`withdraw()` is a function that burns the pool tokens and sends the underlying asset to the beneficiary wallet address.&#x20;

### **Function Arguments**

<table><thead><tr><th width="161">Name</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>uint256</td><td>The id of the pending withdrawal that was initiated by the <code>initWithdrawal</code> transaction</td></tr></tbody></table>

{% hint style="info" %}
Withdrawing the BNT token requires vBNT tokens in your wallet equal to the number of pool tokens being withdrawn.

vBNT must be approved in order to successfully complete this process
{% endhint %}

### Return Variables

This function returns the number of tokens received from the withdrawal.&#x20;

| Variable Type | Description                     |
| ------------- | ------------------------------- |
| uint256       | The number of tokens withdrawn. |


# cancelWithdrawal()

This function is in the BancorNetwork.sol contract

{% hint style="info" %}
Every pending withdrawal has a unique ID. To get a list of pending withdrawals for an address, see [withdrawalRequestIds()](/developer-guides/read-functions/withdrawals/withdrawalrequestids).
{% endhint %}

### **Function** cancelWithdrawa&#x6C;**()**

```solidity
function cancelWithdrawal(uint256 id) external
```

This function cancels a pending withdrawal. It accepts the ID of the pending withdrawal as arguments, and can only be done by the address that owns the pending withdrawal.&#x20;

### **Function Arguments**

<table><thead><tr><th width="161">Name</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>uint256</td><td>The ID of the pending withdrawal to cancel. </td></tr></tbody></table>

This function does not return anything.


# Withdraw Troubleshooting

Common errors for removing liquidity in Bancor v3

**Withdrawal Cancellation**&#x20;

If the withdrawal is canceled, the fees and rewards that would have accrued during the time they were staked in the withdrawal contract will still belong to the user when they reclaim their pool tokens.


# Flashloan

In a single block, borrow capital and return it with an additional fee

## Overview

All assets in Bancor v3 can be borrowed using flash loans. A flash loan is a Web 3 innovation giving anyone access to vast amounts of capital for a single transaction, while using the blockchain to guarantee that the funds are all returned (in addition to a fee).

A slightly more technical definition is that the flash loan only executes if it is returned along with the fee in the same transaction that it is borrowed, otherwise it reverts. This can be difficult to understand at first, both because it has no parallel in the traditional finance world, and because it involves an understanding of how blockchain transactions work.


# flashLoan()

Borrow an indicated amount from the liquidity pool

### Function flashLoan()

```
    function flashLoan(
        Token token,
        uint256 amount,
        IFlashLoanRecipient recipient,
        bytes calldata data
    )
        external
```

Triggers a flashloan where the indicated amount is borrowed from the pool to execute the calldata and returned within an atomic transaction.

| Name      | Type                | Description                                                                                                                                          |
| --------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| token     | Token               | The address of the token deposited into the pool                                                                                                     |
| amount    | unit256             | The amount to borrow from the pool                                                                                                                   |
| recipient | IFlashloanRecipient | The address of the flash loan `recipient`                                                                                                            |
| bytes     | calldata            | This parameter is included for the caller to pass arbitrary information to the `receiver`, without impacting the utility of the `flashLoan` standard |

{% hint style="warning" %}
Flash loans must be returned in the same transaction they are borrowed.&#x20;
{% endhint %}


# Flashloan Troubleshooting

Common errors for flash loans in Bancor v3


# Migrating Liquidity to v3

Care has been taken to ensure that if you have positions in Bancor v2 that migrating to v3 positions will be as simple as possible. In addition, the migration contracts are also capable of migrating positions from other [AMM](broken://pages/TeD0G2eBvkp5AQTYaohz) platforms.&#x20;

This guide will detail the migration process from previous versions to Bancor v3.


# Migrating Bancor positions to v3

Enable the migration of user liquidity

This section includes functions that enable the migration of user liquidity to Bancor V3.&#x20;

For whitelisted pools (v2.1) use [migratePositions()](/developer-guides/write-functions/migrating-liquidity-to-v3/migrating-bancor-positions-to-v3/migratepositions).&#x20;

For non-whitelisted pools (v1) use [migratePoolTokens()](/developer-guides/write-functions/migrating-liquidity-to-v3/migrating-bancor-positions-to-v3/migratepooltokens).


# migratePositions()

Migrate Bancor v2.1 pool tokens to Bancor v3

### Function migratePositions()

{% code title="LiquidityProtection.sol" %}

```javascript
function migratePositions(PositionList[] calldata positionLists) external

struct PositionList {
        IDSToken poolToken; // pool token address
        IReserveToken reserveToken; // reserve token address
        uint256[] positionIds; // position ids
    }
```

{% endcode %}

This function migrates **Bancor v2.1** pool tokens to Bancor v3. Use this function for whitelisted pools on the Bancor network.&#x20;

### Function Arguments

| Name         | Type          | Description                               |
| ------------ | ------------- | ----------------------------------------- |
| poolToken    | IDSToken      | The token being migrated from Bancor v2.1 |
| reserveToken | IReserveToken | The token being reserved on Bancor v3     |
| positionIds  | uint256       | Identify which token is at which position |


# migratePoolTokens()

Migrate Bancor v1 pool tokens to Bancor v3

### Function migratePoolTokens()

{% code title="BancorV1Migration.sol" %}

```javascript
function migratePoolTokens(IPoolToken poolToken, uint256 amount) external
```

{% endcode %}

This function migrates **Bancor v1** pool tokens to Bancor v3. Use this function for non-whitelisted pools on the Bancor network.&#x20;

You can trigger this function on any Bancor pool tokens that exist in your wallet.

### Function Arguments

| Name      | Type       | Description                                      |
| --------- | ---------- | ------------------------------------------------ |
| poolToken | IPoolToken | The address of the token deposited into the pool |
| amount    | uint256    | The amount to deposit                            |


# Errors and Troubleshooting

Common errors for migrating Bancor positions from previous versions


# Migrating from Uniswap v2


# migrateUniswapV2Position()

Common errors for migrating Uniswap v2 positions to Bancor v3

{% hint style="danger" %}
This function does NOT support Uniswap v3 positions.&#x20;
{% endhint %}

### Function migrateUniswapV2Position()

{% code title="IBancorPortal.sol" %}

```javascript
    function migrateUniswapV2Position(
        Token token0,
        Token token1,
        uint256 amount
    ) external
```

{% endcode %}

This function migrates liquidity from Uniswap v2 to Bancor v3.

### Function Arguments

| Name    | Type   | Description                          |
| ------- | ------ | ------------------------------------ |
| Token   | token0 | Token being migrated from Uniswap v2 |
| Token   | token1 | Token being reserved on Bancor v3    |
| uint256 | amount | The amount to deposit                |


# Migrating from Sushiswap

Bancor, Uniswap and Sushiswap are liquidity protocols that enable essentially anyone with funds to become a market maker and earn trading fees.

This section of the Bancor Developer Guides will walk you through the function for migrating from Sushiswap to Bancor v3.&#x20;


# migrateSushiSwapV1Position()

Common errors for migrating SushiSwap positions to Bancor v3

### Function migrateSushiSwapV1Position()

{% code title="IBancorPortal.sol" %}

```javascript
   function migrateSushiSwapV1Position(
        Token token0,
        Token token1,
        uint256 amount
    ) external
```

{% endcode %}

This function migrates liquidity from a SushiSwap position to Bancor v3.&#x20;

| Name    | Type   | Description                         |
| ------- | ------ | ----------------------------------- |
| Token   | token0 | Token being migrated from SushiSwap |
| Token   | token1 | Token being reserved on Bancor v3   |
| uint256 | amount | The amount to deposit               |


# Rewards


# join()

This function is in the StandardRewards.sol contract.

### Function join()

{% code title="StandardRewards.sol" %}

```solidity
function join(uint256 id, uint256 poolTokenAmount) external greaterThanZero(poolTokenAmount) nonReentrant \
```

{% endcode %}

This function is used to deposit Bancor pool tokens (bnTokens) into a rewards program.&#x20;

{% hint style="info" %}
This function requires approval to be set for the relevant pool tokens prior to calling the function.&#x20;
{% endhint %}

The function accepts a reward program ID and the number of pool tokens as arguments, and does not return anything.&#x20;

### Function Arguments

| Name            | Type    | Description                            |
| --------------- | ------- | -------------------------------------- |
| id              | uint256 | This is the ID of the rewards program. |
| poolTokenAmount | uint256 | The number of pool tokens.             |


# stakeRewards()

This function is in the StandardRewards.sol contract.

### Function stakeRewards()

{% code title="StandardRewards.sol" %}

```solidity
function stakeRewards(uint256[] calldata ids) external uniqueArray(ids) nonReentrant returns (StakeAmounts memory)
```

{% endcode %}

This function is used to claim & stake pending rewards from one or more standard rewards programs.&#x20;

The function accepts a list of reward program IDs as arguments and returns the number of reward tokens claimed & staked, and the number of pool tokens received.&#x20;

### Function Arguments

| Name | Type       | Description                             |
| ---- | ---------- | --------------------------------------- |
| ids  | uint256\[] | This is an array of reward program IDs. |

### Return Variables

| Variable Type | Returns                             |
| ------------- | ----------------------------------- |
| uint256       | The amount of rewards claimed.      |
| uint256       | The amount of pool tokens received. |


# autoProcessRewards()

This function is in the AutoCompoundingRewards.sol contract.

### Function autoProcessRewards()

{% code title="AutoCompoundingRewards.sol" %}

```solidity
function autoProcessRewards() external nonReentrant
```

{% endcode %}

This function is used to trigger the actual distribution of the auto compounding rewards based on the pre-defined program. Once called, it will burn the calculated bnTokens from the amount deposited in the externalRewardsVault and redistribute the underlying asset and value to all liquidity providers.


# claimRewards()

This function is in the StandardRewards.sol contract.

### Function claimRewards()

{% code title="StandardRewards.sol" %}

```solidity
function claimRewards(uint256[] calldata ids) external uniqueArray(ids) nonReentrant returns (uint256)
```

{% endcode %}

This function is used to claim pending rewards from one or more standard rewards programs.&#x20;

The function accepts a list of reward program IDs as arguments, and returns the number of rewards claimed.&#x20;

### Function Arguments

| Name | Type       | Description                             |
| ---- | ---------- | --------------------------------------- |
| ids  | uint256\[] | This is an array of reward program IDs. |

### Return Variables

| Variable Type | Returns                        |
| ------------- | ------------------------------ |
| uint256       | The amount of rewards claimed. |


# leave()

This function is in the StandardRewards.sol contract.

### Function leave()

{% code title="StandardRewards.sol" %}

```solidity
function leave(uint256 id, uint256 poolTokenAmount) external greaterThanZero(poolTokenAmount) nonReentrant
```

{% endcode %}

This function is used to withdraw staked pool tokens from a rewards program.

### Function Arguments

| Name            | Type    | Description                            |
| --------------- | ------- | -------------------------------------- |
| id              | uint256 | The ID of the rewards program.         |
| poolTokenAmount | uint256 | The number of pool tokens to withdraw. |

This function does not return anything.&#x20;


# Surplus migration

Following [DAO votes](https://vote.bancor.network/#/), any available surplus found in the pools can be migrated to carbon POL contract.

The following function allows anyone to execute the required call.


# withdrawPOL()

```solidity
    function withdrawPOL(Token pool) external returns (uint256);
```

This function allows to disable trading in pools and migrate any available surplus to the CarbonPOL contract.&#x20;

The function is public and can be called by any caller.

Only tokens that are on the whitelist AND in surplus can be effected by this function.

{% hint style="info" %}
It is recommended to call this function only on pools that are in surplus state and part of the [approved whitelist](/developer-guides/read-functions/surplus-whitelist/protectedtokenwhitelist)
{% endhint %}

### **Function Arguments**

<table><thead><tr><th width="162">Name</th><th width="114.66666666666663">Type</th><th>Description</th></tr></thead><tbody><tr><td>pool</td><td>Token</td><td>The pool (which is also the token) address to disable and/or migrate surplus </td></tr></tbody></table>

### Example

{% code overflow="wrap" %}

```solidity
withdrawPOL(
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 //token address
)

```

{% endcode %}


# Network Fees

Following a [DAO vote](https://vote.bancor.network/#/proposal/0x588313a4a6c950277427bc42347182952bd5b48befb61222eec6913d51128e41), a new set of functions is now publicly available for anyone to call and execute them.


# burnNetworkFees()

```solidity
    function burnNetworkFees() external whenNotPaused nonReentrant returns (uint256)
```

This function burns all pendingNetworkFeeAmount() that are available in the contract.&#x20;

The function is public, can be called by any caller, and does not require any parameters.

{% hint style="info" %}
This function will revert if the [pendingNetworkFeeAmount()](/developer-guides/read-functions/vortex/pendingnetworkfeeamount) < [minNetworkFeeBurn()](/developer-guides/read-functions/vortex/minnetworkfeeburn)&#x20;
{% endhint %}


# Read Functions

Use read functions to simulate an on-chain response

Read Functions enable active data querying from the smart contracts enabling developers to access on-chain stored values and data.


# Rewards

Reward programs supported by Bancor v3

Bancor v3 supports 2 types of reward programs to maximize the flexibility and usability of the rewards that can be used by projects and community members and incentivized liquidity providers to deposit their tokens into Bancor pools:

1. [Auto Compounding ](/developer-guides/read-functions/rewards/standard-rewards/identify-if-a-program-exists/auto-compounding)
2. [Standard Rewards](/developer-guides/read-functions/rewards/standard-rewards/identify-if-a-program-exists/standard-rewards)


# Standard rewards


# Identify if a program exists

Given that rewards plan can be activated by any person, it is important to check and identify whether an active program exists for a specific token and pool.


# Auto Compounding

Check if a pool has a rewards program

### function isProgramActive()

{% code title="AutoCompoundingStakingRewards.sol" %}

```javascript
    function isProgramActive(Token pool) external view returns (bool) 
```

{% endcode %}

By passing the pool address (which is identical to the token address), the function would indicate if there is an active Auto-Compounding rewards plan for it.

### Function Arguments

| Name | Type  | Description |
| ---- | ----- | ----------- |
| pool | Token |             |

### Return Variables

The function`isProgramActive()`returns the variable named bool.&#x20;

Solidity provides [boolean data types](https://subscription.packtpub.com/book/application-development/9781788831383/3/ch03lvl1sec41/boolean). The bool data type is a binary variable that returns variables like, true or false.&#x20;

| Variable Name | Return                                                    |
| ------------- | --------------------------------------------------------- |
| bool          | true or false for if a pool has an active rewards program |


# Standard Rewards

List reward programs for token pools

### function activeProgramId()

{% code title="StandardStakingRewards.sol" %}

```javascript
function activeProgramId(Token pool) external view returns (uint256)
```

{% endcode %}

### Function Arguments

| Name | Type    | Description |
| ---- | ------- | ----------- |
| pool | Token   |             |
| pool | uint256 |             |

### Return Variables

The read function `activeProgramId()` provides return variables with the return statement.&#x20;

The return will be a list of the active program ids and their respective pool addresses.

| Variable Name                | Returns                                          |
| ---------------------------- | ------------------------------------------------ |
| activeProgramIDbyPool\[pool] | the id of active program with their pool address |
| unit256                      | indicates the returns with be 256 bits in size   |


# programIds()

This function is in the StandardRewards.sol contract.

### Function StandardRewards.sol()

{% code title="StandardRewards.sol" %}

```javascript
function programIds() external view returns (uint256[] memory)
```

{% endcode %}

This function is used to get a list of all reward program IDs.&#x20;

### Return Variables

This function returns a list of all reward program IDs.

| Variable Type | Returns                                                                                                                       |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| uint256\[]    | <p>The returned list includes IDs for each reward program.<br><br>Example response:<br><code>1, 2, 3, 4 uint256\[]</code></p> |


# programs()

This function is in the StandardRewards.sol contract.

### Function programs()

{% code title="StandardRewards.sol" %}

```javascript
function programs(uint256[] calldata ids) external view uniqueArray(ids) returns (ProgramData[] memory)
```

{% endcode %}

This function is used to get details for a list of rewards programs.

### Function Arguments

| Name | Type       | Description                             |
| ---- | ---------- | --------------------------------------- |
| ids  | uint256\[] | This is an array of reward program IDs. |

### Return Variables

This function gets details for the indicated rewards programs.&#x20;

| Variable Type | Returns                                                                            |
| ------------- | ---------------------------------------------------------------------------------- |
| uint256       | The ID of the rewards program.                                                     |
| address       | The token address of the token.                                                    |
| address       | The token address of the pool token (bnToken).                                     |
| address       | The token address of the token being distributed as rewards.                       |
| bool          | <p>True: The program is currently enabled.<br>False: The program is disabled. </p> |
| uint32        | The Unix timestamp indicating the start time of the program.                       |
| uint32        | The Unix timestamp indicating the end time of the program.                         |
| uint256       | The rate at which rewards are distributed.                                         |
| uint256       | The amount of rewards yet to be distributed.                                       |

Example response:\
`tuple[] : 1,0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C,0xAB05Cf7C6c3a288cd36326e4f7b8600e7268E344,0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C,true,1650318544,1652737744,18394510582010582,30586756872551000345330`


# providerProgramIds()

This function is in the StandardRewards.sol contract.

### Function providerProgramIds()

{% code title="StandardRewards.sol" %}

```javascript
function providerProgramIds(address provider) external view returns (uint256[] memory)
```

{% endcode %}

This function is used to get the list of rewards programs a specific address is participating in.&#x20;

### Function Arguments

| Name     | Type    | Description                                                  |
| -------- | ------- | ------------------------------------------------------------ |
| provider | address | The address for which to check reward program participation. |

### Return Variables

This function gets a list of rewards programs that the specified address is a participant in.&#x20;

| Variable Type | Returns                                                                                                    |
| ------------- | ---------------------------------------------------------------------------------------------------------- |
| uint256\[]    | The returned list is an array of the rewards program IDs for which the indicated address is a participant. |


# pendingRewards()

This function is in the StandardRewards.sol contract.

### Function pendingRewards()

{% code title="StandardRewards.sol" %}

```javascript
 function pendingRewards(address provider, uint256[] calldata ids) external view uniqueArray(ids) returns (uint256)
```

{% endcode %}

This function is used to check the pending rewards for an address.

{% hint style="info" %}
The indicated rewards programs must have the same token as their reward.&#x20;
{% endhint %}

### Function Arguments

| Name     | Type       | Description                              |
| -------- | ---------- | ---------------------------------------- |
| provider | address    | The address to check.                    |
| ids      | uint256\[] | The list of reward program IDs to check. |

### Return Variables

This function gets the number of pending rewards for an address for each of the indicated rewards programs.

| Variable Type | Returns                        |
| ------------- | ------------------------------ |
| uint256       | The number of pending rewards. |

Example response:

`uint256 :  4033607631980985925`


# latestProgramId()

This function is in the StandardRewards.sol contract.

### Function latestProgramId()

{% code title="StandardRewards.sol" %}

```javascript
function latestProgramId(Token pool) external view returns (uint256)
```

{% endcode %}

This function is used to find the ID of the rewards program for a given token.&#x20;

### Function Arguments

| Name | Type  | Description          |
| ---- | ----- | -------------------- |
| pool | Token | The token's address. |

### Return Variables

This function returns the ID of the latest rewards program for the given token.

| Variable Type | Returns                        |
| ------------- | ------------------------------ |
| uint256       | The ID of the rewards program. |

Example response:

`uint256`` `**`:`**`  ``1`


# isProgramActive()

This function is in the StandardRewards.sol contract.

### Function isProgramActive()

{% code title="StandardRewards.sol" %}

```javascript
function isProgramActive(uint256 id) external view returns (bool)
```

{% endcode %}

This function is used to check if a specific rewards program is currently active.

### Function Arguments

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| id   | uint256 | The ID of the rewards program. |

### Return Variables

This function returns a boolean indicating if the rewards program is currently active.&#x20;

<table><thead><tr><th>Variable Type</th><th width="420">Returns</th></tr></thead><tbody><tr><td>bool</td><td><strong>True:</strong> Rewards program is active.<br><strong>False:</strong> Rewards program is inactive. </td></tr></tbody></table>


# isProgramEnabled()

This function is in the StandardRewards.sol contract.

### Function isProgramEnabled()

{% code title="StandardRewards.sol" %}

```javascript
function _isProgramEnabled(ProgramData memory p) private pure returns (bool)
```

{% endcode %}

This function is used to check if a specific rewards program exists.

{% hint style="info" %}
If a rewards program is enabled, it does NOT mean that it's currently active.&#x20;

To check if a rewards program is currently active, use [isProgramActive()](/developer-guides/read-functions/rewards/standard-rewards/isprogramactive).
{% endhint %}

### Function Arguments

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| id   | uint256 | The ID of the rewards program. |

### Return Variables

This function returns a boolean indicating if a rewards program with the indicated ID has been enabled.&#x20;

| Variable Type | Returns                                                                                                           |
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
| bool          | <p><strong>True:</strong> Rewards program exists.<br><strong>False:</strong> Rewards program does not exist. </p> |


# providerStake()

This function is in the StandardRewards.sol contract.

### Function providerStake()

{% code title="StandardRewards.sol" %}

```javascript
function providerStake(address provider, uint256 id) external view returns (uint256)
```

{% endcode %}

This function checks the amount staked by a specific address in a rewards program.

### Function Arguments

| Name     | Type    | Description                    |
| -------- | ------- | ------------------------------ |
| provider | address | The address to check.          |
| id       | uint256 | The ID of the rewards program. |

### Return Variables

This function gets the number of tokens staked in a specific rewards program for the specified address.&#x20;

| Variable Type | Returns                                     |
| ------------- | ------------------------------------------- |
| uint256       | The number of tokens staked by the address. |

Example response:

`uint256 :  90947879999930743403434`


# programStake()

This function is in the StandardRewards.sol contract.

### Function programStake()

{% code title="StandardRewards.sol" %}

```javascript
function programStake(uint256 id) external view returns (uint256)
```

{% endcode %}

This function gets details about the amount currently staked in a specific program.

### Function Arguments

| Name | Type    | Description                  |
| ---- | ------- | ---------------------------- |
| id   | uint256 | The ID of a rewards program. |

### Return Variables

This function gets the number of tokens staked in the specified rewards program.&#x20;

| Variable Type | Returns                                                                 |
| ------------- | ----------------------------------------------------------------------- |
| uint256       | The number of tokens currently staked in the specified rewards program. |

Example response:

*`uint256`*` ``:  1204490848879513812011104`


# providerRewards()

This function is in the StandardRewards.sol contract.

### Function providerRewards()

{% code title="StandardRewards.sol" %}

```javascript
    function providerRewards(address provider, uint256 id) external view returns (ProviderRewards memory)
```

{% endcode %}

This function gets details about the rewards accumulated for a specific address.&#x20;

### Function Arguments

| Name     | Type    | Description                                     |
| -------- | ------- | ----------------------------------------------- |
| provider | address | The address of the rewards program participant. |
| id       | uint256 | The ID of the rewards program.                  |

### Return Variables

This function returns details about the address's pending rewards.&#x20;

| Variable Type | Returns                                                              |
| ------------- | -------------------------------------------------------------------- |
| uint256       | This is the number of rewards earned per token.                      |
| uint256       | This is the number of pending rewards available to claim.            |
| uint256       | This is a reserved variable slot that might be used at a later time. |
| uint256       | This is the number of tokens staked by the provided address.         |

Example response:

```
tuple :  68831588346139022,37056808364398624,0,90945511981234743406523
```


# Auto compounding rewards


# bnToken balance

This is the number of remaining bnTokens being distributed through a rewards program. There is no dedicated function for this, however, it can be obtained using the Web3 library via web3.getBalance.&#x20;


# isProgramActive()

### Function isProgramActive()

{% code title="AutoCompoundingRewards.sol" %}

```javascript
function isProgramActive(Token pool) external view returns (bool)
```

{% endcode %}

This function is used to check if a specific rewards program is currently active.

### Function Arguments

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| pool | address | The contract address of the token. |

### Return Variables

This function returns a boolean indicating if the rewards program is currently active.&#x20;

<table><thead><tr><th>Variable Type</th><th width="420">Returns</th></tr></thead><tbody><tr><td>bool</td><td><strong>True:</strong> Rewards program is active.<br><strong>False:</strong> Rewards program is inactive. </td></tr></tbody></table>


# isProgramPaused()

### Function isProgramPaused()

{% code title="AutoCompoundingRewards.sol" %}

```javascript
 function isProgramPaused(Token pool) external view returns (bool)
```

{% endcode %}

This function is used to check if a specific rewards program is currently paused.

### Function Arguments

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| pool | address | The contract address of the token. |

### Return Variables

This function returns a boolean indicating if the rewards program is currently paused.&#x20;

<table><thead><tr><th>Variable Type</th><th width="420">Returns</th></tr></thead><tbody><tr><td>bool</td><td><strong>True:</strong> Rewards program is paused.<br><strong>False:</strong> Rewards program is not paused. </td></tr></tbody></table>


# pools()

### Function pools()

{% code title="AutoCompoundingRewards.sol" %}

```javascript
function pools() external view returns (address[] memory)
```

{% endcode %}

This function is used to get a list of token addresses that have rewards programs.&#x20;

### Return Variables

This function returns a list of token addresses.&#x20;

<table><thead><tr><th>Variable Type</th><th width="420">Returns</th></tr></thead><tbody><tr><td>list</td><td>A list of token addresses, for example:<br><code>0x444d6088b0f625f8c20192623b3c43001135e0fa,0xb2cabf797bc907b049e4ccb5b84d13be3a8cfc21,0x939b462ee3311f8926c047d2b576c389092b1649 address[]</code></td></tr></tbody></table>


# program()

### Function program()

{% code title="AutoCompoundingRewards.sol" %}

```javascript
 function program(Token pool) external view returns (ProgramData memory)
```

{% endcode %}

This function is used to get detailed information about a specific rewards program.&#x20;

### Function Arguments

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| pool | address | The contract address of the token. |

### Return Variables

This function returns details about the specified rewards program.

| Variable Type | Returns                                                                                                           |
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
| uint32        | The Unix timestamp indicating when the  rewards program started.                                                  |
| uint32        | The Unix timestamp indicating when the  rewards program will end.                                                 |
| uint32        | The half-life of the rewards program if the program does not use a linear distribution.                           |
| uint32        | The Unix timestamp of the previous distribution period.                                                           |
| Token         | The token address of the bnToken being distributed as rewards.                                                    |
| bool          | <p>True: The program is currently paused.<br>False: The program is not paused. </p>                               |
| uint8         | <p>The distribution schedule for the program. <br>0: Linear distribution<br>1: Exponential decay distribution</p> |
| uint256       | The total number of reward tokens being distributed through the program.                                          |
| uint256       | The number of reward tokens yet to be distributed.                                                                |

Example response:

`tuple : 1663606800,1671469200,0,0,0x356d286A49F484B73e58d757d85fc5ABc9Ebf4F2,false,0,3750004567458270746848413,3750004567458270746848413`


# programs()

### Function programs()

{% code title="AutoCompoundingRewards.sol" %}

```javascript
function programs() external view returns (ProgramData[] memory);
```

{% endcode %}

This function is used to get detailed information about all rewards programs.

### Return Variables

This function returns a list with details about each rewards program. Each list item includes:

| Variable Type | Returns                                                                                                           |
| ------------- | ----------------------------------------------------------------------------------------------------------------- |
| uint32        | The Unix timestamp indicating when the  rewards program started.                                                  |
| uint32        | The Unix timestamp indicating when the  rewards program will end.                                                 |
| uint32        | The half-life of the rewards program if the program does not use a linear distribution.                           |
| uint32        | The Unix timestamp of the previous distribution period.                                                           |
| Token         | The token address of the bnToken being distributed as rewards.                                                    |
| bool          | <p>True: The program is currently paused.<br>False: The program is not paused. </p>                               |
| uint8         | <p>The distribution schedule for the program. <br>0: Linear distribution<br>1: Exponential decay distribution</p> |
| uint256       | The total number of reward tokens being distributed through the program.                                          |
| uint256       | The number of reward tokens yet to be distributed.                                                                |


# Liquidity Pool Details

This section includes read functions that provide details about liquidity pools.

The following functions provide information about liquidity pools on the Bancor Network:

* [liquidityPools()](/developer-guides/read-functions/liquidity-pool-details/liquiditypools)
* [isPoolValid()](/developer-guides/read-functions/liquidity-pool-details/ispoolvalid)


# liquidityPools()

This function is in the BancorNetwork.sol contract.

### Function liquidityPools()

{% code title="NetworkSettings.sol" %}

```javascript
function liquidityPools() external view returns (Token[] memory)
```

{% endcode %}

This function gets a list of all available liquidity pools on the Bancor Network.&#x20;

### Return Variables

The function returns a list of all token contract addresses that have a liquidity pool on Bancor.&#x20;

| Variable Type | Returns                                                                                                                                                                                                                                                                     |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| list          | <p>The returned list includes the token addresses of available liquidity pools. <br><br>Example response:<br><code>0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, 0x6b175474e89094c44da98b954eedeac495271d0f, 0x514910771af9ca656af840dff83e8264ecf986ca address\[]</code></p> |

{% hint style="info" %}
Note that the addresses returned are for the base tokens, **not** the contract addresses of Bancor pool tokens (bnTokens).&#x20;
{% endhint %}


# isPoolValid()

This function is in the BancorNetwork.sol contract.

### Function isPoolValid()

{% code title="BancorNetwork.sol" %}

```javascript
    function isPoolValid(Token pool) external view returns (bool)
```

{% endcode %}

This function is used to determine if a specific token has a liquidity pool on the Bancor Network.&#x20;

### Function Arguments

| Name | Type  | Description                                                                                                                                                                                                                                                        |
| ---- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| pool | Token | <p>The contract address of a token for which to check the existence of a liquidity pool.<br><br>For example, <a href="https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f">DAI</a>:<br><em>0x6B175474E89094C44Da98b954EedeAC495271d0F</em></p> |

### Return Variables

This function returns true or false depending on the existence of a liquidity pool for a given token.&#x20;

| Variable Type | Returns                                                                                                                                                                         |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| boolean       | <p><strong>True:</strong> The token has a liquidity pool on the Bancor Network.<br><strong>False:</strong> The token does not have a liquidity pool on the Bancor Network. </p> |


# isPoolStable()

This function is in the BancorNetworkInfo.sol contract.

### Function isPoolStable()

{% code title="BancorNetworkInfo.sol" %}

```javascript
function isPoolStable(Token pool) external view returns (bool);
```

{% endcode %}

This function is used to determine if it's currently possible to withdraw from a liquidity pool.&#x20;

{% hint style="info" %}
When pools experience significant volatility, withdrawals are temporarily disabled. This is typically resolved in a short amount of time.&#x20;
{% endhint %}

### Function Arguments

| Name | Type  | Description                                                                                                                                                                                                     |
| ---- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pool | Token | <p>The contract address of the token.<br><br>For example, <a href="https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f">DAI</a>:<br><em>0x6B175474E89094C44Da98b954EedeAC495271d0F</em></p> |

### Return Variables

This function returns true or false to indicate if it's currently possible to withdraw from the given pool.&#x20;

| Variable Type | Returns                                                                                                                     |
| ------------- | --------------------------------------------------------------------------------------------------------------------------- |
| boolean       | <p><strong>True:</strong> Withdrawals are possible.<br><strong>False:</strong> Withdrawals are not currently possible. </p> |


# tradingLiquidity()

This function is in the BancorNetworkInfo.sol contract.

### Function tradingLiquidity()

{% code title="BancorNetworkInfo.sol" %}

```javascript
function tradingLiquidity(Token pool) external view returns (TradingLiquidity memory);
```

{% endcode %}

This function is used to determine the available trading liquidity for a given token.&#x20;

### Function Arguments

| Name | Type  | Description                                                                                                                                                                                                     |
| ---- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pool | Token | <p>The contract address of the token.<br><br>For example, <a href="https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f">DAI</a>:<br><em>0x6B175474E89094C44Da98b954EedeAC495271d0F</em></p> |

### Return Variables

This function returns two numbers: the number of BNT available to trade for the indicated pool, and the number of tokens available to trade.&#x20;

| Variable Type | Returns                                                        |
| ------------- | -------------------------------------------------------------- |
| uint256       | The available trading liquidity in BNT                         |
| uint256       | The number of tokens available to trade in the specified token |

Example Response:

```
tuple :  35507645789415459211470741,6814142261515743619858238
```

In the example above:

* BNT available to trade: 35,507,645.789415459211470741&#x20;
* TOKEN available to trade: 6,814,142.261515743619858238


# depositingEnabled()

This function is in the BancorNetworkInfo.sol contract.

### Function depositingEnabled()

{% code title="BancorNetworkInfo.sol" %}

```
function depositingEnabled(Token pool) external view returns (bool);
```

{% endcode %}

This function is used to determine if deposits are enabled for a specific token.&#x20;

### Function Arguments

| Name | Type  | Description                                                                                                                                                                                                                  |
| ---- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pool | Token | <p>The contract address of the token to check.<br><br>For example, <a href="https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f">DAI</a>:<br><code>0x6B175474E89094C44Da98b954EedeAC495271d0F</code></p> |

### Return Variables

This function returns true or false to indicate if pool deposits are enabled.

| Variable Type | Returns                                                                                                                                                |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| boolean       | <p><strong>True:</strong> Deposits are enabled for the specified token.<br><strong>False:</strong> Deposits are disabled for the specified token. </p> |


# poolFundingLimit()

Bancor v3 supports infinity pools and deposits

### Function poolFundingLimit()

{% code title="NetworkSettings.sol" %}

```
    function poolFundingLimit(Token pool) external view returns (uint256)
```

{% endcode %}

Bancor v3 supports infinity pools and deposits. \
However, the trading liquidity is limited based on the `poolFundingLimit()` function.

{% hint style="info" %}
Funding limit effects the pool liquidity depth and therefore trading slippage
{% endhint %}

### Function Arguments

| Name | Type    | Description |
| ---- | ------- | ----------- |
| pool | Token   |             |
| pool | uint256 |             |

### Return Variables

The read function `Function poolFundingLimit()` provides return variables with the return statement.&#x20;

`The function's`return value is an amount in BNT token units.

| Variable Name            | Returns                                                                                              |
| ------------------------ | ---------------------------------------------------------------------------------------------------- |
| poolFundingLimits\[pool] | The amount of BNT tokens that represent the funding limit of a token pool and the token pool address |
| unit256                  | indicates the returns with be 256 bits in size                                                       |


# Trades

These functions return the expected results of a trade.


# tradeOutputBySourceAmount()

### Function tradeOutputBySourceAmount()

{% code title="BancorNetworkInfo.sol" %}

```javascript
function tradeOutputBySourceAmount(Token sourceToken, Token targetToken, uint256 sourceAmount) 
external view validTokensForTrade(sourceToken, targetToken) greaterThanZero(sourceAmount) 
returns (uint256)
```

{% endcode %}

This function is used to determine the number of tokens expected to be received by trading one token to another.&#x20;

### Function Arguments

| Name         | Type    | Description                      |
| ------------ | ------- | -------------------------------- |
| sourceToken  | Token   | The token being sold.            |
| targetToken  | Token   | The token being bought.          |
| sourceAmount | uint256 | The number of tokens being sold. |

### Return Variables

This function returns the number of tokens expected to be received.

| Variable Type | Returns                                                           |
| ------------- | ----------------------------------------------------------------- |
| uint256       | The number of target tokens expected to be received by the trade. |


# tradeInputByTargetAmount()

### Function tradeInputByTargetAmount()

{% code title="BancorNetworkInfo.sol" %}

```javascript
function tradeInputByTargetAmount(Token sourceToken, Token targetToken, uint256 targetAmount) 
external view validTokensForTrade(sourceToken, targetToken) greaterThanZero(targetAmount) 
returns (uint256)
```

{% endcode %}

This function is used to determine how many source tokens need to be swapped to receive a specific number of target tokens.&#x20;

For example, this could be used to determine how many ETH would be required to swap for 1000 LINK.&#x20;

### Function Arguments

| Name         | Type    | Description                                         |
| ------------ | ------- | --------------------------------------------------- |
| sourceToken  | Token   | The token being sold.                               |
| targetToken  | Token   | The token being bought.                             |
| targetAmount | uint256 | The number of target tokens desired to be received. |

### Return Variables

This function returns the number of source tokens required to be swapped to receive a specific number of target tokens.&#x20;

| Variable Type | Returns                                                                             |
| ------------- | ----------------------------------------------------------------------------------- |
| uint256       | The number of source tokens required to receive a specific number of target tokens. |


# tradingEnabled()

This function is in the BancorNetworkInfo.sol contract.

### Function tradingEnabled()

{% code title="BancorNetworkInfo.sol" %}

```javascript
function tradingEnabled(Token pool) external view returns (bool);
```

{% endcode %}

This function is used to determine if trading is enabled for a specific token.&#x20;

### Function Arguments

| Name | Type  | Description                                                                                                                                                                                                              |
| ---- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| pool | Token | <p>The contract address of the token to check.<br><br>For example, <a href="https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f">DAI</a>:<br><em>0x6B175474E89094C44Da98b954EedeAC495271d0F</em></p> |

### Return Variables

This function returns true or false to indicate if trading is enabled for a given token.

| Variable Type | Returns                                                                                            |
| ------------- | -------------------------------------------------------------------------------------------------- |
| boolean       | <p><strong>True:</strong> Trading is enabled.<br><strong>False:</strong> Trading is disabled. </p> |


# tradingFeePMM()

This function is in the BancorNetworkInfo.sol contract.

### Function tradingFeePMM()

{% code title="BancorNetworkInfo.sol" %}

```javascript
function tradingFeePPM(Token pool) external view returns (uint32);
```

{% endcode %}

This function is used to check the fee taken for trading a specified token.

### Function Arguments

| Name | Type  | Description                                                                                                                                                                                                              |
| ---- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| pool | Token | <p>The contract address of the token to check.<br><br>For example, <a href="https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f">DAI</a>:<br><em>0x6B175474E89094C44Da98b954EedeAC495271d0F</em></p> |

### Return Variables

This function returns the number value of the fee taken for trading a given token.

| Variable Type | Returns                                                                                                      |
| ------------- | ------------------------------------------------------------------------------------------------------------ |
| uint32        | <p>The fee taken for trading the specified token.<br><br>For example, a value of 2000 is equal to 0.2%. </p> |


# Withdrawals

This section includes withdrawal-related read functions.


# isReadyForWithdrawal()

This function is in both PendingWithdrawals.sol and BancorNetworkInfo.sol.

### Function isReadyForWithdrawal()

{% code title="PendingWithdrawals.sol" %}

```javascript
function isReadyForWithdrawal(uint256 id) external view returns (bool)
```

{% endcode %}

This function indicates if a specific withdrawal has finished its cooldown period and is ready to be withdrawn.&#x20;

{% hint style="info" %}
This function can be called from either the PendingWithdrawals.sol or BancorNetworkInfo.sol contract.
{% endhint %}

### Function Arguments

| Name | Type    | Description                             |
| ---- | ------- | --------------------------------------- |
| id   | uint256 | This is the id of a pending withdrawal. |

### Return Variables

This function returns a boolean indicating if a specific withdrawal is ready to be withdrawn.&#x20;

| Variable Type | Returns                                                                                                                                                                      |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| boolean       | <p><strong>True:</strong> The pending withdrawal is ready to be withdrawn.<br><strong>False:</strong> The pending withdrawal has not yet completed its cooldown period. </p> |


# withdrawalRequest()

This function is in the PendingWithdrawals.sol contract.

### Function withdrawalRequest()

{% code title="PendingWithdrawals.sol" %}

```javascript
function withdrawalRequest(uint256 id) external view returns (WithdrawalRequest memory)
```

{% endcode %}

This function provides detailed information about a pending withdrawal.&#x20;

### Function Arguments

| Name | Type    | Description                     |
| ---- | ------- | ------------------------------- |
| id   | uint256 | The ID of a pending withdrawal. |

### Return Variables

This function returns a list of information about the pending withdrawal.&#x20;

Example response:

```
tuple :  0x04444499F1Cf0C0264664B43977ED08fEee22222,0xAB05Cf7C6c3a288cd36326e4f7b8600e7268E344,0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C,1652132072,35689994719818965491542,35693378174384324203302
```

| Variable Type | Returns                                                                 |
| ------------- | ----------------------------------------------------------------------- |
| address       | This is the address to which the withdrawn tokens will go.              |
| address       | This is the address of the Bancor Pool tokens that are being withdrawn. |
| address       | This is the address of the token that will be received.                 |
| uint32        | The Unix timestamp of when the requested was initiated.                 |
| uint256       | The number of pool tokens (bnTokens) being withdrawn.                   |
| uint256       | The number of tokens that will be received.                             |




---

[Next Page](/llms-full.txt/1)

