> For the complete documentation index, see [llms.txt](https://bitcow.gitbook.io/amm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bitcow.gitbook.io/amm/developer.md).

# Developer

## Source Code

Source code can be found on [github](https://github.com/bitSmiley-protocol/bitcow).

### Contract Events

See these lines in [ISsTradingPairV1.sol](https://github.com/bitSmiley-protocol/bitcow/blob/main/contracts/interface/ISsTradingPairV1.sol).

```
event AddLiquidity(address user, uint256 xAmount, uint256 yAmount, uint256 lpAmount);
event RemoveLiquidity(address user, uint256 lpAmount, uint256 xAmount, uint256 yAmount);
event Swap(address user, bool isXtoY, uint256 xAmount, uint256 yAmount);
// note that in the Swap event, isXtoY indicates whether this is an X-to-Y swap or a Y-to-X swap
```

### Obtaining Pool state

To obtain pool's reserves, you can query the ERC20 balance of the corresponding contract. For more detailed information, you can also query each contract's `getStats()` interface in [ISsTradingPairV1.sol](https://github.com/bitSmiley-protocol/bitcow/blob/main/contracts/interface/ISsTradingPairV1.sol).

```
    function getStats() external view returns(StatsV1 memory);
    
    struct StatsV1{
        uint64 concentration;
        uint256 feeMillionth;
        uint256 protocolFeeShareThousandth;

        // cumulative
        uint256 totalProtocolFeeX;
        uint256 totalProtocolFeeY;
        uint256 cumulativeVolume;
        FeeRecords feeRecords;
        // stats
        uint256 currentX_;
        uint256 currentY_;
        uint256 multX_;
        uint256 multY_;
        uint256 totalLP_;
    }
```

## Contract Addresses

### BitLayer

* router address: 0xF42F777538911510a38c80aD28B5E358a110b88A
* bitusd-USDT:
  * contract: 0x764c40Df756058250FA5478115E667Fcef7E72E0
  * LP token: 0x9E938F3d55712595Da3Fd839944255768c6A5b38
* WBTC-bitusd:
  * contract: 0xDFA33A77ce4420bf4cA7bFa9c1a57A40307a092e
  * LP token: 0xb7dB5bF3fe5C2Cc4C2c035796E0026B8e1A417C0
* Bitkey-bitusd:
  * contract: 0xBD867dd8b357a067A075c54Eb0E9324ef9592C3d
  * LP token: 0xb7c1340663bCe57b78eB0825E2Db5855578CF3BD
* BDOG-bitusd
  * contract: 0xc117238434fe8AD8a8302C19A10d0470E0Dd3A09
  * LP token: 0xAa01Ccd7318AD3791A25afA40b383523429cC9aF
* BONE-bitusd
  * contract: 0x6c85A831a945BA9b565d500a3a9e107A0AAd868E
  * LP token: 0x61EdA410Ff7c497D25b81659921Fcc9473520935
* BONE-WBTC
  * contract: 0xD736A3947860F2d7ac316a12085755001F360775
  * LP token: 0x9D5de535f4153279F58fc513d457A23011547350
