-
Notifications
You must be signed in to change notification settings - Fork 38
Deployment Guide
Setup your personalized local environment:
export NETWORK_NAME=mainnet
export GAS_PRICE_GWEI=13
export PK=<your private key goes here>
export MY_ETHERSCAN_API_KEY=<your private Etherscan API key goes here>
Note the space before the private key exports ensures that the line will not be recorded in your bash history.
# clear build directory
rm -r build
npx truffle compile
npm run networks-inject
npx truffle migrate --reset --network $NETWORK_NAME
npm run networks-extract
npx truffle run verify BatchExchange --network $NETWORK_NAME
If last command (verifier) doesn't work, do it manually using the flattener:
npx truffle-flattener contracts/BatchExchange.sol > flattend.txt
Commit new network.json file and then bump npm package:
npm version patch -m “New deployment”
npm publish
npx truffle exec scripts/stablex/add_token_list.js --network $NETWORK_NAME
# Deposit OWL:
npx truffle exec scripts/stablex/deposit.js --accountId=0 --tokenId=0 --amount=30 --network $NETWORK_NAME
npx truffle exec scripts/stablex/invokeViewFunction.js ‘tokenAddressToIdMap’ <Token Address> --network $NETWORK_NAME
export TOKEN_ID=<Result of Previous Command>
npx truffle exec scripts/stablex/deposit.js --accountId=0 --tokenId=$TOKEN_ID --amount=98 --network $NETWORK_NAME
0 - OWL - 0x1a5f9352af8af974bfc03399e3767df6370d82e4
1 - WETH - 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
2 - USDT - 0xdac17f958d2ee523a2206206994597c13d831ec7
3 - TUSD - 0x0000000000085d4780B73119b644AE5ecd22b376
4 - USDC - 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
5 - PAX - 0x8e870d67f660d95d5be530380d0ec0bd388289e1
6 - GUSD - 0x056fd409e1d7a124bd7017459dfea2f387b6d5cd
7 - DAI - 0x6b175474e89094c44da98b954eedeac495271d0f
OWL for DAI order:
npx truffle exec scripts/stablex/place_order.js --accountId=0 --buyToken=$TOKEN_ID_DAI --sellToken=0 --minBuy=1000 --maxSell=1000 --validFor=2000 --network $NETWORK_NAME
Market maker order TUSD vs DAI:
npx truffle exec scripts/stablex/place_order.js --accountId=0 --buyToken=$TOKEN_ID_DAI --sellToken=$TOKEN_ID_TUSD --minBuy=1000 --maxSell=998 --validFor=200 --network $NETWORK_NAME
Market maker order DAI vs TUSD
npx truffle exec scripts/stablex/place_order.js --accountId=0 --buyToken=$TOKEN_ID_TUSD --sellToken=$TOKEN_ID_DAI --minBuy=1000 --maxSell=998 --validFor=200 --network $NETWORK_NAME
WARNING!
Some tokens, such as USDC
, have only 6 decimals while most have 18. This must be taken into consideration when depositing and placing orders, especially via these scripts since the convert values by multiplying 10^18.
Observe, for example, the order placed between DAI and TUSD above in comparison with the following:
npx truffle exec scripts/stablex/place_order.js --accountId=0 --buyToken=3 --sellToken=4 --minBuy=102000000000000 --maxSell=100 --validFor=2000 --network $NETWORK_NAME
npx truffle exec scripts/stablex/place_order.js --accountId=0 --buyToken=4 --sellToken=3 --minBuy=102 --maxSell=100000000000000 --validFor=2000 --network $NETWORK_NAME
Use the script ensure_owl_liquidity for automatic OWL liquidity provision for all tokens:
npx truffle exec scripts/stablex/ensure_owl_liquidity.js --network $NETWORK_NAME