Skip to content

Setting up an FAssets Liquidator#

As a critical component of the FAssets system, liquidators oversee agents and ensure their self-sufficiency, contributing to the overall stability and efficiency of the system by carrying out liquidation. They initiate a process where FAssets are sent into the system in exchange for collateral plus a premium. This process involves burning the FAssets, which effectively reduces the agent collateral requirement and allows them to earn rewards in the process. Anyone can become a liquidator, supporting the FAssets system and earning rewards.

This guide explains how to run a program called an FAssets bot that observes the FAssets system and reacts to its state. The bot must be running at all times and be constantly online to avoid the risk of missing liquidation opportunities and earning rewards.

Open Beta

The FAssets system is currently in the Open Beta period. During this phase, user-friendly tools are still being developed.

Some web browsers and ad blockers might prevent this functionality.

Alternatively, you can contact support@flarelabs.org.

Prerequisites#

To participate in the open beta, you need a server with at least a minimum of 2 CPUs and 4GB RAM, or 2GB if the database is on a separate server.

You will need knowledge of the following tools:

  • Git version control system;
  • Yarn package manager;
  • Command line terminal;
  • Code editor.

Warning

If you are using Windows, it is strongly recommended to use Windows Subsystem for Linux, version 2 (WSL 2).

Setting up the FAssets tools#

Clone and Setup the Tools Repository#

Info

If you set up an FAssets agent, bot or user, please use a separate directory for each role.

  1. Clone the repository and enter the working directory:

    git clone https://github.com/flare-labs-ltd/fasset-bots.git
    cd fasset-bots
    
  2. Switch to the open_beta branch:

    git checkout open_beta
    
  3. Install dependencies and build the project:

    yarn && yarn build
    

    Info

    Fresh installation can take more than 10 minutes, depending on if you have cached dependencies before.

  4. Copy the environment file from a template .env.template to .env:

    cp .env.template .env
    

Configure the Access Keys#

The FAsset liquidators operate with an address for the Flare network chain. You must generate these keys to set up the liquidator.

  1. Create or use an existing management wallet that will be your liquidator's management address. Fund this wallet with some CFLR so you can pay the gas fees for various smart contract calls using the Flare faucet.

  2. Generate the secrets using this command by replacing the MANAGEMENT_WALLET_ADDRESS with your cold wallet address:

    yarn key-gen generateSecrets --other MANAGEMENT_WALLET_ADDRESS --other -o secrets.json
    

    Info

    This command can only be executed once, after which all secret keys will be generated. You must use a separate directory for each role you want to perform: agent, bot, or minter and redeemer.

    Warning

    The addresses in secrets.json are designed to be used as hot wallets and should not hold large amounts of tokens, since their private keys are accessible on a machine that is permanently online. Instead, it's best to keep your main account in an offline wallet and transfer funds to these hot wallets as needed.

  3. Prevent other users from reading the secrets.json file:

    chmod 600 secrets.json
    
  4. The native_rpc is the API key used to connect to a public node on the Coston blockchain network. This key is necessary for authenticating and enabling secure communication between your application and the blockchain network. To configure your connection, you must fill the native_rpc field in the secrets.json file with the API key provided by the Flare team during the FAssets testing period. Use this value in the secrets.json file:

    "native_rpc": "AavSehMLhcgz3crQHH5YJ3Rt8GMQGdV9aViGilADXGnTcjij",
    
  5. The secrets.json file contains the liquidator.address and liquidator.private_key fields, representing the Flare account responsible for running the liquidator and covering gas fees for the smart contract calls. Ensure this address has enough tokens to cover gas fees by transferring some CFLR to it. You can obtain CFLR tokens from the Flare faucet.

  6. The liquidator account must hold enough FAssets to execute liquidation tasks and cover the liquidated agent FAssets amount. Therefore, you must mint FAssets and move them to the liquidator account. For a more detailed explanation, please refer to the Minting and Redeeming guide.

Running the Liquidator#

The liquidator observes the FAssets system and reacts to its state. To run the liquidator, you need to run the following command:

yarn run-liquidator

When you want to stop the server, press Ctrl + C.

Running the Liquidator as System Service#

In production scenarios, run the run-liquidator command as a service to maximize uptime Here, you have instructions to run the liquidator as a systemd service for running the liquidator as a daemon. Using this guide, you must change the agent-bot to the liquidator-bot.