Giter VIP home page Giter VIP logo

eth-bsc-swap-contracts's Introduction

ETH BSC Swap Contracts

Security Report

here

Overview

ETH BSC Swap Contracts are responsible for registering swap pairs and swapping assets between ETH and BSC.

Register swap pair

  1. Users register swap pair for erc20 token on ETH via ETHSwapAgent(createSwapPair) if token is not registered.

  2. Swap service will monitor the SwapPairRegister event and create swap pair on BSC:

    1. create an BEP20 token on BSC
    2. record the relation between erc20 token and bep20 token.

Swap from ETH to BSC

Once swap pair is registered, users can swap tokens from ETH to BSC.

  1. Users call swapBSC2ETH via ETHSwapAgent and specify erc20 token address, amount and swap fee.
  2. Swap service will monitor the SwapStarted event and call fillETH2BSCSwap via BSCSwapAgent to mint corresponding bep20 tokens to the same address that initiate the swap.

Swap from BSC to ETH

Once swap pair is registered, users can swap tokens from BSC to ETH.

  1. Users call swapBSC2ETH via BSCSwapAgent and specify bep20 token address, amount and swap fee. Bep20 tokens will be burned.
  2. Swap service will monitor the SwapStarted event and call fillBSC2ETHSwap via BSCSwapAgent to transfer corresponding erc20 tokens to the same address that initiate the swap.

Generate contracts from templates

npm run generate

Test

Generate test contracts from templates:

npm run generate-test

Run tests:

npm run truffle:test

Run coverage:

npm run coverage

eth-bsc-swap-contracts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eth-bsc-swap-contracts's Issues

Swap From BSC to ETH Inavlid RPC Response

Contract: ETHSwapAgent and BSCSwapAgent
√ Register Standard ERC20 and create swap pair (3102ms)
√ Swap from ETH to BSC (2469ms)
1) Swap from BSC to ETH
> No events were emitted
√ Set BSC to ETH swap fee (498ms)
√ Set ETH to BSC swap fee (447ms)
√ ETH ownership (649ms)
√ BSC ownership (771ms)

6 passing (9s)
1 failing

  1. Contract: ETHSwapAgent and BSCSwapAgent
    Swap from BSC to ETH:
    Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (node_modules\web3-core-helpers\src\errors.js:42:16)
    at XMLHttpRequest.request.onreadystatechange (node_modules\web3-providers-http\src\index.js:106:32)
    at XMLHttpRequestEventTarget.dispatchEvent (node_modules\xhr2-cookies\xml-http-request-event-target.ts:44:13)
    at XMLHttpRequest._setReadyState (node_modules\xhr2-cookies\xml-http-request.ts:219:8)
    at XMLHttpRequest._onHttpRequestError (node_modules\xhr2-cookies\xml-http-request.ts:379:8)
    at ClientRequest. (node_modules\xhr2-cookies\xml-http-request.ts:266:37)
    at ClientRequest.emit (node:events:327:20)
    at Socket.socketErrorListener (node:_http_client:478:9)
    at Socket.emit (node:events:327:20)
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)

BSC转到ETH不成功?

从ETH转到BSC上正常,但是从BSC转回到ETH上时,只在BSC中执行了销毁操作,没有在ETH上归还相应的资产。
查询日志,发现服务在ETH上获取blockinfo 失败,但是可以肯定eth_provide配置是可用的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.