decred.org/dcrdex@v1.0.5/dex/testing/dcrdex/genmarkets.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  TEST_ROOT=~/dextest
     4  FILEPATH=${TEST_ROOT}/dcrdex/markets.json
     5  
     6  EPOCH_DURATION=${EPOCH:-15000}
     7  if [ "${EPOCH_DURATION}" -lt 1000 ]; then
     8      echo "epoch duration cannot be < 1000 ms"
     9      exit 1
    10  fi
    11  
    12  # run with NODERELAY=1 to use a node relay for the bitcoin node.
    13  BTC_NODERELAY_ID=""
    14  DCR_NODERELAY_ID=""
    15  BTC_CONFIG_PATH="${TEST_ROOT}/btc/alpha/alpha.conf"
    16  DCR_CONFIG_PATH="${TEST_ROOT}/dcr/alpha/dcrd.conf"
    17  if [[ -n ${NODERELAY} ]]; then
    18      BTC_NODERELAY_ID="btc_a21afba3"
    19      DCR_NODERELAY_ID="dcr_a21afba3"
    20      RELAY_CONF_PATH="${TEST_ROOT}/btc/alpha/alpha_noderelay.conf"
    21      if [ ! -f "${RELAY_CONF_PATH}" ]; then
    22          cp "${BTC_CONFIG_PATH}" "${RELAY_CONF_PATH}"
    23          echo "rpcbind=noderelay:${BTC_NODERELAY_ID}" >> "${RELAY_CONF_PATH}"
    24      fi
    25      BTC_CONFIG_PATH="${RELAY_CONF_PATH}"
    26  
    27      RELAY_CONF_PATH="${TEST_ROOT}/dcr/alpha/dcrd_noderelay.conf"
    28      if [ ! -f "${RELAY_CONF_PATH}" ]; then
    29          cp "${DCR_CONFIG_PATH}" "${RELAY_CONF_PATH}"
    30          echo "rpclisten=noderelay:${DCR_NODERELAY_ID}" >> "${RELAY_CONF_PATH}"
    31      fi
    32      DCR_CONFIG_PATH="${RELAY_CONF_PATH}"
    33  fi
    34  
    35  ~/dextest/bch/harness-ctl/alpha getblockchaininfo &> /dev/null
    36  BCH_ON=$?
    37  
    38  ~/dextest/ltc/harness-ctl/alpha getblockchaininfo &> /dev/null
    39  LTC_ON=$?
    40  
    41  ~/dextest/doge/harness-ctl/alpha getblockchaininfo &> /dev/null
    42  DOGE_ON=$?
    43  
    44  ~/dextest/firo/harness-ctl/alpha getblockchaininfo &> /dev/null
    45  FIRO_ON=$?
    46  
    47  ~/dextest/zec/harness-ctl/alpha getblockchaininfo &> /dev/null
    48  ZEC_ON=$?
    49  
    50  ~/dextest/zcl/harness-ctl/alpha getblockchaininfo &> /dev/null
    51  ZCL_ON=$?
    52  
    53  ~/dextest/dgb/harness-ctl/alpha getblockchaininfo &> /dev/null
    54  DGB_ON=$?
    55  
    56  ~/dextest/dash/harness-ctl/alpha getblockchaininfo &> /dev/null
    57  DASH_ON=$?
    58  
    59  ~/dextest/eth/harness-ctl/alpha attach --exec 'eth.blockNumber' &> /dev/null
    60  ETH_ON=$?
    61  
    62  ~/dextest/polygon/harness-ctl/alpha --exec 'eth.blockNumber' &> /dev/null
    63  POLYGON_ON=$?
    64  
    65  echo "Writing markets.json and dcrdex.conf"
    66  
    67  # Write markets.json.
    68  # The dcr and btc harnesses should be running. The assets config paths
    69  # used here are created by the respective harnesses.
    70  cat > "${FILEPATH}" <<EOF
    71  {
    72      "markets": [
    73          {
    74              "base": "DCR_simnet",
    75              "quote": "BTC_simnet",
    76              "lotSize": 2000000000,
    77              "rateStep": 100,
    78              "epochDuration": ${EPOCH_DURATION},
    79              "marketBuyBuffer": 1.2,
    80              "parcelSize": 4
    81  EOF
    82  
    83  if [ $LTC_ON -eq 0 ]; then
    84      cat << EOF >> "${FILEPATH}"
    85          },
    86          {
    87              "base": "LTC_simnet",
    88              "quote": "DCR_simnet",
    89              "lotSize": 5000000,
    90              "rateStep": 100000,
    91              "epochDuration": ${EPOCH_DURATION},
    92              "marketBuyBuffer": 1.2,
    93              "parcelSize": 1000
    94  EOF
    95  else echo "Litecoin is not running. Configuring dcrdex markets without LTC."
    96  fi
    97  
    98  if [ $BCH_ON -eq 0 ]; then
    99      cat << EOF >> "${FILEPATH}"
   100          },
   101          {
   102              "base": "BCH_simnet",
   103              "quote": "DCR_simnet",
   104              "lotSize": 100000,
   105              "rateStep": 1000000,
   106              "epochDuration": ${EPOCH_DURATION},
   107              "marketBuyBuffer": 1.2,
   108              "parcelSize": 1200
   109  EOF
   110  else echo "Bitcoin Cash is not running. Configuring dcrdex markets without BCH."
   111  fi
   112  
   113  if [ $ETH_ON -eq 0 ]; then
   114      cat << EOF >> "${FILEPATH}"
   115          },
   116          {
   117              "base": "DCR_simnet",
   118              "quote": "ETH_simnet",
   119              "lotSize": 1000000000,
   120              "rateStep": 1000,
   121              "epochDuration": ${EPOCH_DURATION},
   122              "marketBuyBuffer": 1.2,
   123              "parcelSize": 4
   124          },
   125          {
   126              "base": "ETH_simnet",
   127              "quote": "BTC_simnet",
   128              "lotSize": 100000000,
   129              "rateStep": 1000,
   130              "epochDuration": ${EPOCH_DURATION},
   131              "marketBuyBuffer": 1.2,
   132              "parcelSize": 4
   133          },
   134          {
   135              "base": "BTC_simnet",
   136              "quote": "USDC.ETH_simnet",
   137              "lotSize": 1000000,
   138              "rateStep": 10000,
   139              "epochDuration": ${EPOCH_DURATION},
   140              "marketBuyBuffer": 1.2,
   141              "parcelSize": 4
   142          },
   143          {
   144              "base": "DCR_simnet",
   145              "quote": "USDC.ETH_simnet",
   146              "lotSize": 100000000,
   147              "rateStep": 100000,
   148              "epochDuration": ${EPOCH_DURATION},
   149              "marketBuyBuffer": 1.2,
   150              "parcelSize": 4
   151          },
   152          {
   153              "base": "BTC_simnet",
   154              "quote": "USDT.ETH_simnet",
   155              "lotSize": 1000000,
   156              "rateStep": 10000,
   157              "epochDuration": ${EPOCH_DURATION},
   158              "marketBuyBuffer": 1.2,
   159              "parcelSize": 4
   160          },
   161          {
   162              "base": "USDC.ETH_simnet",
   163              "quote": "USDT.ETH_simnet",
   164              "lotSize": 10000000,
   165              "rateStep": 10000,
   166              "epochDuration": ${EPOCH_DURATION},
   167              "marketBuyBuffer": 1.2,
   168              "parcelSize": 4
   169  EOF
   170  else echo "Ethereum is not running. Configuring dcrdex markets without ETH."
   171  fi
   172  
   173  if [ $POLYGON_ON -eq 0 ]; then
   174      cat << EOF >> "${FILEPATH}"
   175          },
   176          {
   177              "base": "POLYGON_simnet",
   178              "quote": "DCR_simnet",
   179              "lotSize": 100000000,
   180              "rateStep": 1000,
   181              "epochDuration": ${EPOCH_DURATION},
   182              "marketBuyBuffer": 1.2,
   183              "parcelSize": 2500
   184          },
   185          {
   186              "base": "DCR_simnet",
   187              "quote": "USDC.POLYGON_simnet",
   188              "lotSize": 10000000,
   189              "rateStep": 100,
   190              "epochDuration": ${EPOCH_DURATION},
   191              "marketBuyBuffer": 1.2,
   192              "parcelSize": 500
   193          },
   194          {
   195              "base": "DCR_simnet",
   196              "quote": "USDT.POLYGON_simnet",
   197              "lotSize": 1000000,
   198              "rateStep": 10000,
   199              "epochDuration": ${EPOCH_DURATION},
   200              "marketBuyBuffer": 1.2,
   201              "parcelSize": 4
   202  EOF
   203  else echo "Polygon is not running. Configuring dcrdex markets without Polygon."
   204  fi
   205  
   206  if [ $DOGE_ON -eq 0 ]; then
   207      cat << EOF >> "${FILEPATH}"
   208          },
   209          {
   210              "base": "DCR_simnet",
   211              "quote": "DOGE_simnet",
   212              "lotSize": 1000000,
   213              "rateStep": 1000000000,
   214              "epochDuration": ${EPOCH_DURATION},
   215              "marketBuyBuffer": 1.2,
   216              "parcelSize": 1500
   217  EOF
   218  else echo "Dogecoin is not running. Configuring dcrdex markets without DOGE."
   219  fi
   220  
   221  if [ $FIRO_ON -eq 0 ]; then
   222      cat << EOF >> "${FILEPATH}"
   223          },
   224          {
   225              "base": "DCR_simnet",
   226              "quote": "FIRO_simnet",
   227              "lotSize": 1000000,
   228              "rateStep": 1000000,
   229              "epochDuration": ${EPOCH_DURATION},
   230              "marketBuyBuffer": 1.2,
   231              "parcelSize": 1500
   232  EOF
   233  else echo "Firo is not running. Configuring dcrdex markets without FIRO."
   234  fi
   235  
   236  if [ $ZEC_ON -eq 0 ]; then
   237      cat << EOF >> "${FILEPATH}"
   238          },
   239          {
   240              "base": "ZEC_simnet",
   241              "quote": "BTC_simnet",
   242              "lotSize": 100000000,
   243              "rateStep": 10,
   244              "epochDuration": ${EPOCH_DURATION},
   245              "marketBuyBuffer": 1.2,
   246              "parcelSize": 5
   247  EOF
   248  else echo "Zcash is not running. Configuring dcrdex markets without ZEC."
   249  fi
   250  
   251  if [ $ZCL_ON -eq 0 ]; then
   252      cat << EOF >> "${FILEPATH}"
   253          },
   254          {
   255              "base": "ZCL_simnet",
   256              "quote": "BTC_simnet",
   257              "lotSize": 5000000,
   258              "rateStep": 100000,
   259              "epochDuration": ${EPOCH_DURATION},
   260              "marketBuyBuffer": 1.2,
   261              "parcelSize": 8
   262  EOF
   263  else echo "Zclassic is not running. Configuring dcrdex markets without ZCL."
   264  fi
   265  
   266  if [ $DGB_ON -eq 0 ]; then
   267      cat << EOF >> "${FILEPATH}"
   268          },
   269          {
   270              "base": "DCR_simnet",
   271              "quote": "DGB_simnet",
   272              "lotSize": 1000000,
   273              "rateStep": 1000000,
   274              "epochDuration": ${EPOCH_DURATION},
   275              "marketBuyBuffer": 1.2,
   276              "parcelSize": 1500
   277  EOF
   278  else echo "Digibyte is not running. Configuring dcrdex markets without DGB."
   279  fi
   280  
   281  if [ $DASH_ON -eq 0 ]; then
   282      cat << EOF >> "${FILEPATH}"
   283          },
   284          {
   285              "base": "DCR_simnet",
   286              "quote": "DASH_simnet",
   287              "lotSize": 1000000,
   288              "rateStep": 1000000,
   289              "epochDuration": ${EPOCH_DURATION},
   290              "marketBuyBuffer": 1.2,
   291              "parcelSize": 1500
   292  EOF
   293  else echo "Dash is not running. Configuring dcrdex markets without DASH."
   294  fi
   295  
   296  cat << EOF >> "${FILEPATH}"
   297      }
   298      ],
   299      "assets": {
   300          "DCR_simnet": {
   301              "bip44symbol": "dcr",
   302              "network": "simnet",
   303              "maxFeeRate": 10,
   304              "swapConf": 1,
   305              "configPath": "${DCR_CONFIG_PATH}",
   306              "regConfs": 1,
   307              "regFee": 100000000,
   308              "regXPub": "spubVWKGn9TGzyo7M4b5xubB5UV4joZ5HBMNBmMyGvYEaoZMkSxVG4opckpmQ26E85iHg8KQxrSVTdex56biddqtXBerG9xMN8Dvb3eNQVFFwpE",
   309              "bondAmt": 50000000,
   310              "bondConfs": 1,
   311              "nodeRelayID": "${DCR_NODERELAY_ID}"
   312          },
   313          "BTC_simnet": {
   314              "bip44symbol": "btc",
   315              "network": "simnet",
   316              "maxFeeRate": 100,
   317              "swapConf": 1,
   318              "configPath": "${BTC_CONFIG_PATH}",
   319              "regConfs": 2,
   320              "regFee": 20000000,
   321              "regXPub": "vpub5SLqN2bLY4WeZJ9SmNJHsyzqVKreTXD4ZnPC22MugDNcjhKX5xNX9QiQWcE4SSRzVWyHWUihpKRT7hckDGNzVc69wSX2JPcfGeNiT5c2XZy",
   322              "bondAmt": 100000,
   323              "bondConfs": 1,
   324              "nodeRelayID": "${BTC_NODERELAY_ID}"
   325  EOF
   326  
   327  if [ $LTC_ON -eq 0 ]; then
   328      cat << EOF >> "${FILEPATH}"
   329           },
   330          "LTC_simnet": {
   331              "bip44symbol": "ltc",
   332              "network": "simnet",
   333              "maxFeeRate": 20,
   334              "swapConf": 2,
   335              "configPath": "${TEST_ROOT}/ltc/alpha/alpha.conf",
   336              "bondAmt": 1000000,
   337              "bondConfs": 1
   338  EOF
   339  fi
   340  
   341  if [ $BCH_ON -eq 0 ]; then
   342      cat << EOF >> "${FILEPATH}"
   343           },
   344          "BCH_simnet": {
   345              "bip44symbol": "bch",
   346              "network": "simnet",
   347              "maxFeeRate": 20,
   348              "swapConf": 2,
   349              "configPath": "${TEST_ROOT}/bch/alpha/alpha.conf",
   350              "bondAmt": 1000000,
   351              "bondConfs": 1
   352  EOF
   353  fi
   354  
   355  if [ $ETH_ON -eq 0 ]; then
   356  ETH_CONFIG_PATH=${TEST_ROOT}/eth.conf
   357  ETH_IPC_FILE=${TEST_ROOT}/eth/alpha/node/geth.ipc
   358  
   359  cat > $ETH_CONFIG_PATH <<EOF
   360  ws://localhost:38559 , 2000
   361  # comments are respected
   362  ; http://localhost:38556
   363  ${ETH_IPC_FILE},2
   364  EOF
   365  
   366  cat << EOF >> "${FILEPATH}"
   367           },
   368          "ETH_simnet": {
   369              "bip44symbol": "eth",
   370              "network": "simnet",
   371              "maxFeeRate": 200,
   372              "swapConf": 2,
   373              "configPath": "$ETH_CONFIG_PATH"
   374          },
   375          "USDC.ETH_simnet": {
   376              "bip44symbol": "usdc.eth",
   377              "network": "simnet",
   378              "maxFeeRate": 200,
   379              "swapConf": 2
   380          },
   381          "USDT.ETH_simnet": {
   382              "bip44symbol": "usdt.eth",
   383              "network": "simnet",
   384              "maxFeeRate": 200,
   385              "swapConf": 2
   386  EOF
   387  fi # end if ETH_ON
   388  
   389  if [ $POLYGON_ON -eq 0 ]; then
   390  POLYGON_CONFIG_PATH=${TEST_ROOT}/polygon.conf
   391  POLYGON_IPC_FILE=${TEST_ROOT}/polygon/alpha/bor/bor.ipc
   392  
   393  cat > $POLYGON_CONFIG_PATH <<EOF
   394  ws://localhost:34985 , 2000
   395  # comments are respected
   396  ; http://localhost:48297
   397  ${POLYGONf_IPC_FILE},2
   398  EOF
   399  
   400  cat << EOF >> "${FILEPATH}"
   401           },
   402          "POLYGON_simnet": {
   403              "bip44symbol": "polygon",
   404              "network": "simnet",
   405              "maxFeeRate": 200,
   406              "swapConf": 2,
   407              "configPath": "$POLYGON_CONFIG_PATH"
   408          },
   409          "USDC.POLYGON_simnet": {
   410              "bip44symbol": "usdc.polygon",
   411              "network": "simnet",
   412              "maxFeeRate": 200,
   413              "swapConf": 2
   414          },
   415          "USDT.POLYGON_simnet": {
   416              "bip44symbol": "usdt.polygon",
   417              "network": "simnet",
   418              "maxFeeRate": 200,
   419              "swapConf": 2
   420  EOF
   421  fi # end if POLYGON_ON
   422  
   423  if [ $DOGE_ON -eq 0 ]; then
   424      cat << EOF >> "${FILEPATH}"
   425           },
   426          "DOGE_simnet": {
   427              "bip44symbol": "doge",
   428              "network": "simnet",
   429              "maxFeeRate": 40000,
   430              "swapConf": 2,
   431              "configPath": "${TEST_ROOT}/doge/alpha/alpha.conf",
   432              "bondAmt": 2000000000,
   433              "bondConfs": 1
   434  EOF
   435  fi
   436  
   437  if [ $FIRO_ON -eq 0 ]; then
   438      cat << EOF >> "${FILEPATH}"
   439           },
   440          "FIRO_simnet": {
   441              "bip44symbol": "firo",
   442              "network": "simnet",
   443              "maxFeeRate": 10,
   444              "swapConf": 2,
   445              "configPath": "${TEST_ROOT}/firo/alpha/alpha.conf"
   446  EOF
   447  fi
   448  
   449  if [ $ZEC_ON -eq 0 ]; then
   450      cat << EOF >> "${FILEPATH}"
   451           },
   452          "ZEC_simnet": {
   453              "bip44symbol": "zec",
   454              "network": "simnet",
   455              "maxFeeRate": 200,
   456              "swapConf": 1,
   457              "configPath": "${TEST_ROOT}/zec/alpha/alpha.conf"
   458  EOF
   459  fi
   460  
   461  if [ $ZCL_ON -eq 0 ]; then
   462      cat << EOF >> "${FILEPATH}"
   463           },
   464          "ZCL_simnet": {
   465              "bip44symbol": "zcl",
   466              "network": "simnet",
   467              "maxFeeRate": 200,
   468              "swapConf": 1,
   469              "configPath": "${TEST_ROOT}/zcl/alpha/alpha.conf",
   470              "bondAmt": 40000000,
   471              "bondConfs": 1
   472  EOF
   473  fi
   474  
   475  if [ $DASH_ON -eq 0 ]; then
   476      cat << EOF >> "${FILEPATH}"
   477           },
   478          "DASH_simnet": {
   479              "bip44symbol": "dash",
   480              "network": "simnet",
   481              "maxFeeRate": 10,
   482              "swapConf": 2,
   483              "configPath": "${TEST_ROOT}/dash/alpha/alpha.conf",
   484              "bondAmt": 10000000,
   485              "bondConfs": 1
   486  EOF
   487  fi
   488  
   489  if [ $DGB_ON -eq 0 ]; then
   490      cat << EOF >> "${FILEPATH}"
   491           },
   492          "DGB_simnet": {
   493              "bip44symbol": "dgb",
   494              "network": "simnet",
   495              "maxFeeRate": 2000,
   496              "swapConf": 1,
   497              "configPath": "${TEST_ROOT}/dgb/alpha/alpha.conf",
   498              "bondAmt": 20000000000,
   499              "bondConfs": 1
   500  EOF
   501  fi
   502  
   503  cat << EOF >> "${FILEPATH}"
   504          }
   505      }
   506  }
   507  EOF