ETH BSC Swap Contracts are responsible for registering swap pairs and swapping assets between ETH and BSC.
-
Users register swap pair for erc20 token on ETH via ETHSwapAgent(
createSwapPair) if token is not registered. -
Swap service will monitor the
SwapPairRegisterevent and create swap pair on BSC:- create an BEP20 token on BSC
- record the relation between erc20 token and bep20 token.
Once swap pair is registered, users can swap tokens from ETH to BSC.
- Users call
swapBSC2ETHvia ETHSwapAgent and specify erc20 token address, amount and swap fee. - Swap service will monitor the
SwapStartedevent and callfillETH2BSCSwapvia BSCSwapAgent to mint corresponding bep20 tokens to the same address that initiate the swap.
Once swap pair is registered, users can swap tokens from BSC to ETH.
- Users call
swapBSC2ETHvia BSCSwapAgent and specify bep20 token address, amount and swap fee. Bep20 tokens will be burned. - Swap service will monitor the
SwapStartedevent and callfillBSC2ETHSwapvia BSCSwapAgent to transfer corresponding erc20 tokens to the same address that initiate the swap.
npm run generateGenerate test contracts from templates:
npm run generate-testRun tests:
npm run truffle:testRun coverage:
npm run coverage