Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fully on-chain orderbook ERC-20/ERC-20 DEX using Red-Black Trees and Queues (WIP)

NotificationsYou must be signed in to change notification settings

bokkypoobah/chadex

Repository files navigation

chadex is a non-custodial peer-to-peer ERC-20/ERC-20 decentralised exchange protocol.

  • Users permit the chadex smart contract to perform ERC-20 token transfers
  • Users express their desire to exchange ERC-20 tokens to other ERC-20 tokens by adding orders to the exchange
  • If the prices match between users, the exchange takes place.

Fully on-chain ERC-20/ERC-20 DEX using Red-Black Trees and queues for sorted orderbook executions.

Status: Work in progress

https://bokkypoobah.github.io/chadex/



Notes

npm install --save-dev @nomiclabs/hardhat-truffle5 @nomiclabs/hardhat-web3 web3

https://docs.openzeppelin.com/test-helpers/0.5/

npm install --save-dev @openzeppelin/test-helpersnpm install --save-dev solidity-coverage

npm install --save-dev @nomiclabs/hardhat-ethers 'ethers@^5.0.0'

Coverage

Run coverage reports using the command

npx hardhat coverage

Output will be in the generated coverage directory

If you are using yarn, you can run

yarn hardhat coverage


Old Stuff

Token incompatibilities -An Incompatibility in Ethereum Smart Contract Threatening dApp Ecosystem

  • Token registry includes rating
    • 0 scam, 1 suspect, 2 unrated, 3 OK, 5 reputable
  • Prevent front running

hash(ccy1/ccy2) => Orderbook

OrderbookRedBlackTree index by pricebuyOrders - Expiring Queue=> Order* OrderType orderType;* address baseToken; // GNT* address quoteToken; // ETH* uint price; // GNT/ETH = 0.00054087 = #quoteToken per unit baseToken* uint expiry;* uint amount; // GNT - baseTokensellOrders

TODO:

  • Move past consumed orders, graceful gas limit exit
  • Handle canTransferFrom() -ethereum/EIPs#1594`function canTransferFrom(address _from, address _to, uint256 _value, bytes _data) external view returns (bool, byte, bytes32);``

Function Calls

trade

functiontrade(uintorderFlag,addressbaseToken,addressquoteToken,uintprice,uintexpiry,uintbaseTokens,addressuiFeeAccount)publicpayablereturns(uint_baseTokensFilled,uint_quoteTokensFilled,uint_baseTokensOnOrder,bytes32_orderKey);
ParametersNotes
orderFlaguint256
baseTokenaddress of the baseToken
quoteTokenaddress of the quoteToken
priceuint256
expiryuint256
baseTokensuint256
uiFeeAccountaddress

AndorderFlag is constructed using the following bitmasks

// Note that the BUY and SELL flags are used as indicesuintconstantpublicORDERTYPE_BUY=0x00;uintconstantpublicORDERTYPE_SELL=0x01;uintconstantpublicORDERFLAG_BUYSELL_MASK=0x01;// BK Default is to fill as much as possibleuintconstantpublicORDERFLAG_FILL=0x00;uintconstantpublicORDERFLAG_FILLALL_OR_REVERT=0x10;uintconstantpublicORDERFLAG_FILL_AND_ADD_ORDER=0x20;

About

Fully on-chain orderbook ERC-20/ERC-20 DEX using Red-Black Trees and Queues (WIP)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp