> For the complete documentation index, see [llms.txt](https://docs.boom.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.boom.market/boom-blockchain/boomswap/developer.md).

# Developer

Boomswap is a [Uniswap V2](https://docs.uniswap.org/contracts/v2/overview) fork. Developers can interact with Boomswap in the same way they use Uniswap repositories and SDKs.

{% hint style="info" %}
Boomswap has a total **fee structure** of  **1.9%** from which 0.3% goes to the protocol.
{% endhint %}

The following steps were made when forking the original code:

## V2-Core-Master Module <a href="#v2-core-master-module" id="v2-core-master-module"></a>

### Contracts and Modifications <a href="#contracts-and-modifications" id="contracts-and-modifications"></a>

* **BoomswapERC20.sol** : Originally [`UniswapV2ERC20`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/Pair-ERC-20), this contract has been modified for LP name and symbol adjustments.
* **BoomswapPair.sol** : Originally [`UniswapV2Pair`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/pair). Fee value in updated in the `BoomswapPair-swap()` function at these two lines:

```solidity
// 19 = 1.9% fee
uint256 balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(19));
uint256 balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(19));
```

* **BoomswapFactory.sol**: Formerly [`UniswapV2Factory`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/factory). Key modification includes the initialization of the state variable `INIT_CODE_HASH`. The deployment of this contract requires a specified `_feeToSetter` address, which has the authority to adjust the `feeTo` parameter.

## V2-Periphery-Master Module <a href="#v2-periphery-master-module" id="v2-periphery-master-module"></a>

### Implementation Steps

1. Retrieve the contract address and `INIT_CODE_HASH` from the deployed Factory.
2. In [`UniswapV2Library.sol`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/library), replace the existing init code hash in the `pairFor` function (Remove the '0x' prefix).
3. Compile and deploy the `IUniswapV2Router02` and **`BoomswapRouter.sol`** contracts (previously [`UniswapV2Router02`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02)) using the appropriate pragma solidity version.
4. **BoomswapRouter Deployment**: Requires the `_FACTORY` address and the WBMC address (formerly WETH).

Consider modifying `UniswapV2Library.sol` and `UniswapV2LiquidityMathLibrary.sol` fees initially at 0.3% (997/1000).

{% hint style="danger" %}
Don't subsitute WETH with WBMC. Maintain the convention usage of ETH everywhere in the code: in names like *IWETH*, *amountETHMin*, etc.
{% endhint %}

## API Endpoints Documentation

Don't forget to approve token before calling any of the following endpoints.

### [🔗 Pair Interaction](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/factory#createpair) <a href="#f0-9f-94-97-pair-interaction" id="f0-9f-94-97-pair-interaction"></a>

* [Create Pair](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/factory#createpair)
* [Get Pair](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/factory#getpair)

### [🔗 Providing Liquidity](https://docs.uniswap.org/contracts/v2/guides/smart-contract-integration/providing-liquidity) <a href="#f0-9f-94-97-providing-liquidity" id="f0-9f-94-97-providing-liquidity"></a>

* Use [`addLiquidity`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#addliquidity) for ERC-20/ERC-20 pairs.
* For WBMC pairs (WETH convention), use [`addLiquidityETH`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#addliquidityeth).
* To remove liquidity, use [`removeLiquidity`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#removeliquidity) or [`removeLiquidityETH`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#removeliquidityeth).
* For withdrawal estimates, follow the logic in [`UniswapV2Pair-burn()`](https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair.sol).

### [🔗 Swap Operations](https://docs.uniswap.org/contracts/v2/guides/smart-contract-integration/trading-from-a-smart-contract) <a href="#f0-9f-94-97-swap-operations" id="f0-9f-94-97-swap-operations"></a>

* [`swapExactTokensForTokens`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#swapexacttokensfortokens)
* [`swapTokensForExactTokens`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#swaptokensforexacttokens)
* [`swapExactETHForTokens`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#swapexactethfortokens)
* [`swapTokensForExactETH`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#swaptokensforexacteth)
* [`swapExactTokensForETH`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#swapexacttokensforeth)
* [`swapETHForExactTokens`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#swapethforexacttokens)

### [🔗 Pricing](https://docs.uniswap.org/contracts/v2/concepts/advanced-topics/pricing#pricing-trades) <a href="#f0-9f-94-97-pricing" id="f0-9f-94-97-pricing"></a>

* **Quotation**: Use [`quote`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#quote).
* **Exact Output**: Use [`getAmountOut`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#getamountout) | [`getAmountsOut`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#getamountsout).
* **Exact Input**: Use [`getAmountIn`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#getamountin) | [`getAmountsIn`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02#getamountsin).
* **Pair Reserves (TVL)**: Use [`getReserves`](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/pair#getreserves).

### Resources <a href="#resources-1" id="resources-1"></a>

* [Uniswap V2 Router Contracts Documentation](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02)
* [Uniswap V2 Factory Contracts Documentation](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/factory)
* [Uniswap V2 Libraries Documentation](https://docs.uniswap.org/contracts/v2/reference/smart-contracts/library)

***

{% content-ref url="/pages/FBqVw68OYEhBLncrvvu8" %}
[Contracts](/reference/contracts.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

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

```
GET https://docs.boom.market/boom-blockchain/boomswap/developer.md?ask=<question>
```

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

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