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#

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 need knowledge of the following tools:

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#

Setting up After Testnet XRP Reset#

Info

This section is only for users using FAssets before the testnet XRP reset, so please read more.

Suppose you previously ran the FAssets agent before the XRP testnet reset. You will need to skip the whitelisting part but still need to:

  • pull the latest changes from the repository by git pull;
  • build then with yarn && yarn build;
  • installing the MySQL database and setting it up following the guide later in this document;
  • create a new agent using the existing management address following the guide.

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 for hot wallets and should not hold large token amounts, as their private keys are on an always-online machine. Keep your main account in an offline wallet and transfer funds as needed.
    • As soon as you create the secrets.json file, back it up, and remember to back it up again whenever you add new keys. Store the backup securely, preferably on an external drive in a physical vault, as unauthorized access can compromise the agent. You need to make regular backups only if you make changes.
  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.