How to stake tokens on the Bancor network?
Financial exchanges and payments have functioned in a centralized manner for a very long time. Slowly but gradually, the finance industry began to look for decentralized ways to conduct transactions. This is where blockchain technology stepped in. With blockchain technology and cryptocurrencies, decentralized exchange platforms (DEXs) also came into the picture soon. However, the system hadn’t been entirely decentralized yet as DEXs acted as an intermediary for trading or swapping cryptocurrencies. This problem existed till Bancor was launched. But how did Bancor resolve it?
In this article, we will learn about Bancor by answering the following questions:
- What is Bancor?
- What are Smart Tokens?
- What is Bancor V2?
- How to stake tokens on the Bancor network?
- How to stake liquidity in Bancor pools?
- How to add liquidity to Bancor network using a dApp or smart contract?
Let’s begin by learning about what is Bancor.
What is the Bancor protocol?
Bancor is a blockchain protocol that enables users to exchange assets directly instead of depending on exchanges. It is an entirely on-chain liquidity protocol and can be implemented on smart contract blockchains.
Bancor is an open-source standard for liquidity pools to provide automated market-making against smart contracts.
With Bancor, one can:
- Trade tokens on EOS and Ethereum.
- Deploy a custom liquidity pool.
- Deploy a BNT token liquidity pool.
- Provide liquidity to a deployed pool.
- Integrate Bancor liquidity and trading into a smart contract.
- Integrate Bancor into a smart contract or dApp to earn affiliate fees.
The Bancor Network
Normally, decentralized exchanges work by matching a seller and a buyer and earn a small trading fee after executing the trade. However, Bancor works differently. Instead of involving buyers and sellers, it executes trades via a smart contract that is more commonly known as a liquidity pool in the Bancor network.
Currently, the Bancor Network operates on Ethereum and EOS blockchains. However, the protocol is interoperable for additional blockchains. One can easily integrate its open-source implementation into any application that enables value exchanges. It encourages its participants to contribute to the protocol and enhance it.
A user can execute a trade by telling the Bancor protocol which token they want to buy and the amount they wish to purchase. Then, Bancor will compute the trade and tell the cost to the user. The price will depend on the size of the order and the amount of liquidity present. If the order size is small and there is a lot of liquidity, the cost will be similar to the market price. However, the price will rise if there isn’t a lot of liquidity for the required token and the order size is large.
The user can initiate the trade after agreeing with the price. All trades use Bancor’s native token, BNT, as an intermediary trading token. For example, if the user wants to swap or trade DAI for MKR, then Bancor will swap DAI for BNT, which will then get swapped for MKR.
Hence, trading with the Bancor network has the following advantages:
- Smart contracts hold the exchanges. Therefore, there is no third-party involved.
- The price may fluctuate according to your order size.
- It offers unlimited liquidity, but up to the limit of number of tokens on the platform.
- Prices are known in advance.
BNT – Bancor’s Native Token
The BNT token is the native cryptocurrency of the Bancor protocol. BNT stands for Bancor Network Token.
BNT is the core for all Bancor trades, as it acts as an intermediary token. As explained in the above section, for any trade to occur, the token first gets swapped for BNT, and then BNT is swapped for the required token.
Along with BNT, the Bancor protocol also launched a new cryptocurrency class, known as Smart tokens. But why? What are smart tokens? Let’s discuss.
What are Smart Tokens?
Smart tokens are standard ERC20 tokens. They implement the Bancor protocol by providing liquidity continuously along with facilitating automatic price-discovery.
Smart tokens were launched to:
- Resolve the issue of limited liquidity for new cryptocoins.
- Offer more choices to cryptocoin entrants rather than just limiting swaps to Ethereum and Bitcoins.
A smart token holds the reserve of other ERC-20 tokens. Smart tokens are issued when they are purchased and are destroyed when liquidated. Hence, at the current price, one can:
- buy a smart token with its reserve token
- liquidate a smart token to its reserve token.
The smart token’s smart contract processes orders instantly, which facilitates the price-discovery process. This capability makes smart tokens independent of the need to be traded in an exchange to become liquid.
Smart tokens use a method based on the “Constant Reserve Ratio” (CRR) for price-discovery. For each reserve token, the CRR is set by the smart token’s creator and is used in the price calculation. The smart token’s current supply and reserve are also used.
Price = Balance/Supply x CRR
It ensures that the constant ratio stays between the reserve token balance and the smart token’s market cap. The reserve token denominates the smart token’s price. The smart contract readjusts the price according to liquidation or purchases. They are responsible for changes in the reserve balance and the token’s supply that ultimately affect the token’s price.
The Bancor protocol enables liquidity and price-discovery through this method.
Let’s look at some advantages of smart tokens.
Advantages of Smart Tokens
Smart tokens have several advantages:
- No Extra Fees: The only required fee is the smart token’s gas fees, which is also relatively low.
- Continuous Liquidity: Tokens are always liquid irrespective of their trading volume because purchasing and liquidating is always done through smart contracts.
- Same Prices for Purchasing and Liquidating Tokens: The prices for purchasing and liquidating the smart tokens are the same as the price calculation is algorithmically done by the smart tokens.
- Predictable Price Slippage: Smart tokens can pre-calculate the price slippage according to the transaction size before it is executed.
- Lower Volatility: Higher CRR leads to the lower volatility of the smart token.
In July 2020, Bancor released a new version of the protocol, known as Bancor V2. Let’s learn about how the new version brought some changes to the protocol.
What is Bancor V2?
Bancor V2 is the latest update to the Bancor protocol. Even though Bancor was one of the first protocols to implement liquidity pools, it didn’t attract many users because of numerous issues. Some of these issues were:
- high gas fee
- exposure to impermanent losses
- capital inefficiency
- the compulsory requirement to use an additional BNT token to add liquidity to pools
- the opportunity cost of providing liquidity, etc.
These issues were not only making Bancor troublesome to use, they were also hindering the broader adoption of Automated Market Makers (AMM).
Bancor V2 was launched with various new features to tackle these issues. The most significant highlight of Bancor V2 is known as the Dynamic Automated Market Maker. Let’s learn more about it.
Dynamic Automated Market Maker (DAMM)
The Dynamic Automated Market Maker (DAMM) uses price oracles to determine if the balance between tokens in a pool should be changed. They provide smart contracts with external prices in a decentralized way.
The pool’s current balance should be as close to the stake balance of the liquidity provider (LP) as possible so that LPs can withdraw the number of tokens they provided to the pool to mitigate impermanent loss. Current Balance refers to the balance of tokens in the pool, also known as Reserve Balance. Stake Balance refers to the balance provided by the LP.
In order to mitigate impermanent loss, Bancor V2 DAMMs incentivize market participants to bring the current balance and stake balance closer. They do so with the help of dynamic fees. For example, if the current balance deviates from the staked balance, the fees for incentive market participants are adjusted to bring both balances closer.
The DAMMs also similarly deal with other issues.
How to stake tokens on the Bancor network?
One has to buy relay tokens and hold them in their wallet in order to stake tokens on the Bancor network. Relays enable all tokens in the Bancor network to easily convert to other tokens in a single transaction. You can sell your relay tokens at any time.
In order to stake tokens on the Bancor Network, follow these steps:
Step 1: Go to https://app.bancor.network/eth/data and log into your account or connect your wallet.
Step 2: From the first dropdown, choose the token with which you wish to make the payment.
Step 3: From the second dropdown, choose the relay token you want to receive.
Step 4: Press “Convert”
That’s it. After you buy your desired relay token, you’re staking on Bancor and earning fees for each conversion processed by the relay.
Now let’s take a look at how you can stake liquidity in Bancor pools.
How to stake liquidity in Bancor pools?
Users can stake tokens in the Bancor liquidity pools and generate fees from the trade volume.
Liquidity pools perform peer-to-contract and autonomous token trades while generating fees from each trade. Users can provide liquidity to a pool and receive a conversion fee in return.
Providing liquidity to a Bancor pool is permissionless, i.e., no centralized authority can control the process. Liquidity providers receive pool tokens that are proportional to their share of assets in the pool.
To stake liquidity in Bancor pools, follow these steps:
Step 1:Connect your wallet. Then, go to https://app.bancor. network/eth/data and click the “Add Liquidity” sign denoted by “+” in front of the pool to which you wish to add liquidity.
The blue shield on the left side of pools indicates that the pool is “Whitelisted,” which implies:
- It is protected against impermanent losses.
- It is available for single side staking.
Step 2: Under the “Single-Sided Protection,” press “Stake and Protect.”
Step 3: Enter the amount of tokens you wish to stake and protect.
The “Stake and Protect” option will appear once you enter the amount. Press that option and confirm the transaction. Your protected, single-sided liquidity stake will appear on the Protection screen.
Now that you understand how you can provide liquidity using the front-end interface, let’s see how it can be done using dApp or smart contracts.
How to Add Liquidity to Bancor Network using a dApp or Smart Contract?
As a developer, one can follow the following steps to add liquidity to the bancor network from a dApp or smart contract.
Step 1: Identify the Pool Version
Bancor is a fast-moving, permissionless, and decentralized protocol. When an upgrade is launched, the converter contract’s owner must opt into the new version. Hence, developers must first check what type of converter they’re interacting with to know how to interface with the contract correctly.
You can use the Bancor SDK to query for the converter version.
const BancorSDK = require('bancor-sdk').SDK; const settings = { // optional, mandatory when interacting with the ethereum mainnet ethereumNodeEndpoint: '', // optional, mandatory when interacting with the EOS mainnet eosNodeEndpoint: ' ' }; const bancorSDK = await BancorSDK.create(settings); const converter = { blockchainType: 'ethereum', // or 'eos' blockchainId: ' ' } const version = await bancorSDK.utils.getConverterVersion(converter);
Step 2: Query for Converter Type (version >= 28)
According to version 28:
- The LiquidTokenConverter manages a liquid token and has a single reserve.
- The LiquidityPoolV1Converter is the base contract for converters managing liquidity pools and has multiple reserves.
- The LiquidityPoolV2Converter is the Bancor v2 base contract and has two reserves.
Each contract has a converterType function that will return:
- 0 for a LiquidTokenConverter
- 1 for a LiquidityPoolV1Converter
- 2 for a LiquidityPoolV2Converter
You’ll only be able to add liquidity for converter types 1 & 2.
Step 3: Part 1 – Adding Liquidity Bancor V2/ Version >= 28
The Bancor V2 AddLiquidity function is different from other types. It needs you to specify only one reserve, as the “adding liquidity” process is designed for single token staking. Liquidity Providers can now specify the exact amount of tokens of each underlying reserve they wish to contribute. Even though liquidity providers would still have to roughly estimate expected issuance in order to input the _minReturn of liquidity tokens they would accept, the new process leaves less room for error and confusion overall.
Calculating expected pool tokens:
addLiquidity Amount x (StakedBalance / PoolTokenSupply)
Remember that starting with version 28, liquidity providers can directly contribute ETH using the address:
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE. contract IConverter { function addLiquidity( IERC20Token _reserveToken, uint256 _amount, uint256 _minReturn ) external payable; contract MyContract { IConverter converter = IContractRegistry(); function addLiquidity( IERC20Token _reserveToken, uint256[] memory _reserveAmount, uint256 _minReturn ) external payable { converter.addLiquidity.value(msg.value)( _reserveToken, _reserveAmount, _minReturn ); }
Adding liquidity will lead to the emission of an event:
event LiquidityAdded( address indexed _provider, // provider address address indexed _reserve, // token added uint256 _amount, // amount added uint256 _newBalance, // new balance of reserve uint256 _newSupply // new supply of reserve )
You’ll only be able to add liquidity for converter types 1 & 2.
Step 3: Part 2 – Adding Liquidity (Version < 28)
Converters need to be manually upgraded by their owner whenever a new version is released. Hence, many active converters are still using the older versions of code since they haven’t been manually upgraded.
The _amount value in the “fund” function is the number of liquidity tokens expected on liquidity contribution. This may need some math in your smart contract or Web3 code.
contract IConverter { function fund(uint256 _amount) external; } contract MyContract { IConverter converter = IConverter(); function addLiquidity(uint _amount) external { converter.fund(_amount); } }
Conclusion
Bancor is an on-chain liquidity protocol. With its latest version, Bancor V2, the protocol has gained a lot of traction. Its native token, BNT, is the backbone of the project and is essential to complete trades.
Start a conversation by filling the form
All information will be kept confidential.
Insights
Decision intelligence: Benefits, applications, implementation, and future trends
Decision Intelligence (DI) is a data-driven approach to decision-making that leverages advanced analytics, machine learning, and artificial intelligence (AI) to empower organizations with actionable insights.
How AutoML is transforming AI: The Concept of ‘AI Creating AI’
AI creating AI” through AutoML is transforming the field, expanding beyond human-led processes to make AI development more accessible and efficient.
Structured outputs in LLMs: Definition, techniques, applications, benefits
Structured outputs in large language models (LLMs) refer to the ability of these models to generate responses in specific, predefined formats rather than just free-form text.