Giter Site home page Giter Site logo

gelato-dutchx's Introduction

Gelato Dev - Testing Environment

Based on

Check out the Gnosis DX-Services.

Setup test environment

# Install dependencies
yarn install

# In one tab, run a local Ganache
yarn rpc

# In the other tab:
# run the setup script, which will:
#   - migrate all contracts into your local node
#   - create some test data, basically:
#       - I'll fund the the second account of generated with the mnemonic, so
#         it has some funds for trading
#       - It'll add a RDN-WETH token pair into the DX
#       - It'll make sure RDN-WETH is running. It'll automatically advance time,
#         or participate in the auctions if it's required
yarn setup

Let's fund the sellers account with some WETH (seller: 0x5AEDA56215b167893e80B4fE645BA6d5Bab767DE):

yarn cli deposit 200 WETH 0x627306090abab3a6e1400e9345bc60c78a8bef57
yarn cli withdraw 200 WETH 0x627306090abab3a6e1400e9345bc60c78a8bef57
yarn cli send 200 WETH 0x5AEDA56215b167893e80B4fE645BA6d5Bab767DE

Create the first sellOrder using the sellers account (accounts[0]:

truffle exec ./createSellOrder.js

Fast forward in time 6 hours (freeze time) and close the currently running auction

yarn cli2 --time 6
yarn cli deposit 4000 RDN 0xf17f52151ebef6c7334fad080c5704d77216b732
yarn cli buy 4000 WETH-RDN 0xf17f52151ebef6c7334fad080c5704d77216b732

Check the current state for AUCTION_START_WAITING_FOR_FUNDING and auction index should be 2. Then execute the first subOrder as the executor (accounts[1]) in auction 2 of WETH-RDN.

yarn cli state WETH-RDN
truffle exec ./execSubOrderAndWithdraw.js "**** PLUG IN SELL ORDER HASH  ******"

Do not forget to wrap the sell order hash in "..."!

Now the Sell Volume of WETH-RDN should have some WETH (~9.95 WETH) from the just executed subOrder.

If you want to go on and execute further sub Orders, you need to progress through various auction states buy funding both auctions (WETH-RDN and RDN-WETH), skipping ahead 7 hours, and then placing buy orders to close both auctions. When you execute the next sub Order, always make sure there is enough WETH in the seller account (default account: accounts[0]).

Here are some useful commands for copy pasting in order (LOOP START):

yarn cli deposit 1000 RDN "0xf17f52151ebef6c7334fad080c5704d77216b732"
yarn cli sell 1000 RDN-WETH "0xf17f52151ebef6c7334fad080c5704d77216b732"
yarn cli2 --time 6

yarn cli deposit 4000 RDN "0xf17f52151ebef6c7334fad080c5704d77216b732"
yarn cli buy 4000 WETH-RDN "0xf17f52151ebef6c7334fad080c5704d77216b732"
yarn cli deposit 5 WETH "0xf17f52151ebef6c7334fad080c5704d77216b732"
yarn cli buy 5 RDN-WETH "0xf17f52151ebef6c7334fad080c5704d77216b732"

yarn cli balances

Now either execute subOrder or withdraw manually

truffle exec ./execSubOrderAndWithdraw.js "**** PLUG IN SELL ORDER HASH  ******"

OR

truffle exec ./withdrawManually.js "**** PLUG IN SELL ORDER HASH  ******"
truffle exec ./execSubOrderAndWithdraw.js  "**** PLUG IN SELL ORDER HASH  ******"

Check balance of seller (LOOP END - start from LOOP START)

yarn cli balances --account 0x5AEDA56215b167893e80B4fE645BA6d5Bab767DE

Other comments to try out:

truffle exec ./calcWithdrawAmount.js
truffle exec ./calcSubOrder.js

... ...

Setup complete

Help

# Print out available CLI  commands
yarn cli --help

# Or, get help from a specific command from it
yarn cli buy --help

Based on code from

gelato-dutchx's People

Contributors

gitpusha avatar

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.