Be sure that you have NodeJS and yarn installed.
To run the project clone the repository locally, and from the local folder, fetch the necessary dependencies:
yarnIn order to interact with the Arbitrum Mainnet deployment of Futureswap, you need to access a node provider. Infura and Alchemy are two popular choices. You would need to create a project on either of the provider websites, and obtain access keys, in order to send transactions to the blockchain. As well as to read the current state of the blockchain. Note that, a free account might provide enough quota for your project, unless you are going to use the CLI very intensely.
Configuration is stored locally in a file called .env. Depending on the chain
you are going to access, you should put different parameters into this file as
described in the following subsections.
You can keep parameters for multiple chains in your .env file. You are going
to select a specific chain parameters using a --network argument of the CLI
commands.
For Arbitrum Mainnet configuration, which is the Futureswap main deployment,
you need to provide the following parameters, in your .env file:
MAINNET_ARBITRUM_MNEMONIC=<only need it for commands that change something>
MAINNET_ARBITRUM_CHAINID=42161
MAINNET_ARBITRUM_RPC_URL=<Your Infura or Alchemy JSON-RPC endpoint URL>For Arbitrum Rinkeby configuration, which is the Futureswap testnet
deployment, you need to provide the following parameters, in your .env file:
RINKEBY_ARBITRUM_MNEMONIC=<only need it for commands that change something>
RINKEBY_ARBITRUM_CHAINID=421611
RINKEBY_ARBITRUM_RPC_URL=<Your Infura or Alchemy JSON-RPC endpoint URL>Many of the operations below are requiring some additional parameters. You can
set default values for them over the .env file so usually there would be no
need to provide them again
For example adding to .env
NETWORK=mainnet_arbitrum
MAINNET_ARBITRUM_EXCHANGE=0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2would allow to approve tokens with only
yarn start approve-tokensyarn start approve-tokens --network mainnet_arbitrum \
--exchange 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2yarn start change-position --network mainnet_arbitrum \
--exchange 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2 \
--delta-asset <delta asset> \
--delta-stable <delta stable>yarn start change-position-estimate --network mainnet_arbitrum \
--exchange 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2 \
--delta-asset <delta asset> \
--delta-stable <delta stable>yarn start liquidate --network mainnet_arbitrum \
--exchange 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2 \
--trader <trader_address>yarn start estimateLiquidate --network mainnet_arbitrum \
--exchange 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2 \
--trader <trader address>yarn start liquidation-bot --network mainnet_arbitrum \
--exchange 0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2It would restart the bot in case of crashed, provides a basic dashboard with metrics, save logs into files and ensure that bot will not stop after you will close the terminal
Unfortunately, passing parameters to the commands below like it has been done
in the command above will not work. The easiest way would be to add NETWORK
and MAINNET_ARBITRUM_EXCHANGE to your .env file like it explained in
Additional parameters section above or to add them to
pm2.config.js file to env field e.g. replacing
env: {
TS_NODE_FILES: true,
TS_NODE_TRANSPILE_ONLY: true,
REPORTING: "pm2",
},with
env: {
TS_NODE_FILES: true,
TS_NODE_TRANSPILE_ONLY: true,
REPORTING: "pm2",
NETWORK "mainnet_arbitrum",
MAINNET_ARBITRUM_EXCHANGE" "0x1B5A08020E94066a3fB91Aff8B395De2d9cfaDd2"
},Start the liquidation bot:
yarn liquidation-bot:pm2:startStop already running bot:
yarn liquidation-bot:pm2:stopOpen the dashboard for the running bot:
yarn pm2:monitNote that with current configuration, after system restart the liquidation bot will not start automatically. Setting it up would require installing pm2 globally. More details can be found in the PM2 official documentation