Skip to content

Commit

Permalink
Adds instructions how to set up a liquidator FLA-289
Browse files Browse the repository at this point in the history
  • Loading branch information
fassko committed Jun 27, 2024
1 parent d15060c commit 416af71
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 26 deletions.
12 changes: 3 additions & 9 deletions docs/infra/fassets/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ This guide provides the following information:
* How to set up an FAssets agent and provide collateral;
* How to run the agent so FAssets system users can convert (mint and redeem) assets from the testnet XRP Ledger to the Flare test network and back.

!!! info "Open Beta"

The FAssets system is currently in the [Open Beta](../../tech/fassets/open-beta.md) period.
During this phase, user-friendly tools are still being developed.

--8<-- "./include/fassets/issue-collector.html"

Alternatively, you can contact [support@flarelabs.org](mailto:support@flarelabs.org).
--8<-- "./include/fassets/open-beta.md"

## Contract Addresses

Expand Down Expand Up @@ -328,7 +321,8 @@ Visit the original Flare block explorer at the address of the contract you just

And check that the **Code** tab has a green checkmark next to it.

## Related Docs
## Related Pages

* [Minting and Redeeming FAssets](../../user/fassets/index.md)
* [Setting up an FAssets Liquidator](./liquidator.md)
* [FAssets Open Beta](../../tech/fassets/open-beta.md)
1 change: 1 addition & 0 deletions docs/infra/fassets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
The following guide explains how to set up and manage an [FAssets](../../tech/fassets/index.md) agent.

* [Deploying an FAssets agent](./agent.md)
* [Setting up an FAssets Liquidator](./liquidator.md)
71 changes: 71 additions & 0 deletions docs/infra/fassets/liquidator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Setting up an FAssets Liquidator

As a critical component of the [FAssets](../../tech/fassets/index.md) system, [liquidators](../../tech/fassets/index.md#liquidators) oversee agents and ensure their self-sufficiency, contributing to the overall stability and efficiency of the system by carrying out [liquidation](../../tech/fassets/liquidation.md).
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.

--8<-- "./include/fassets/open-beta.md"

--8<-- "./include/fassets/setup-commandline.md"

## 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](https://faucet.flare.network/).

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

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

--8<-- "./include/fassets/generate-keys-info.md"

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

```bash
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:

```json
"native_rpc": "AavSehMLhcgz3crQHH5YJ3Rt8GMQGdV9aViGilADXGnTcjij",
```

1. 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](https://faucet.flare.network/).

2. The `liquidator` account must hold enough FAssets to execute [liquidation tasks](../../tech/fassets/index.md#liquidators) 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](../../user/fassets/index.md) 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:

```console
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](https://github.com/flare-labs-ltd/fasset-bots/blob/main/docs/systemd/systemd-service.md).
Using this guide, you must change the `agent-bot` to the `liquidator-bot`.


## Related Pages

* [Minting and Redeeming FAssets](../../user/fassets/index.md)
* [Deploying an FAssets Agent](agent.md)
* [FAssets Open Beta](../../tech/fassets/open-beta.md)
3 changes: 2 additions & 1 deletion docs/tech/fassets/open-beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Although other advanced users can join, they can interact with the FAssets syste

Following the Coston open beta, the next stage will launch on Songbird.

## Related Docs
## Related Pages

* [Minting and Redeeming FAssets](../../user/fassets/index.md)
* [Deploying FAssets Agent](../../infra/fassets/agent.md)
* [Setting up an FAssets Liquidator](../../infra/fassets/liquidator.md)
9 changes: 1 addition & 8 deletions docs/user/fassets/minting-redeeming-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ This guide provides the following information:
* How to convert testnet XRP to FAssets (FTestXRP) on the Flare test network (minting).
* How to convert FAssets (FTestXRP) from Flare test network back to testnet XRP Ledger network (redemption).

!!! info "Open Beta"

The FAssets system is currently in the [Open Beta](../../tech/fassets/open-beta.md) period.
During this phase, user-friendly tools are still being developed.

--8<-- "./include/fassets/issue-collector.html"

Alternatively, you can contact [support@flarelabs.org](mailto:support@flarelabs.org).
--8<-- "./include/fassets/open-beta.md"

--8<-- "./include/fassets/setup-commandline.md"

Expand Down
5 changes: 3 additions & 2 deletions include/fassets/generate-keys-info.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
!!! info

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

!!! warning

To prevent serious security risks, avoid storing your addresses and private keys in the `secrets.json` file. Instead, transfer funds from your wallet to these generated addresses.
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.
8 changes: 8 additions & 0 deletions include/fassets/open-beta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!!! info "Open Beta"

The FAssets system is currently in the [Open Beta](../../tech/fassets/open-beta.md) period.
During this phase, user-friendly tools are still being developed.

--8<-- "./include/fassets/issue-collector.html"

Alternatively, you can contact [support@flarelabs.org](mailto:support@flarelabs.org).
10 changes: 5 additions & 5 deletions include/fassets/setup-commandline.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ You will need knowledge of the following tools:

!!! info

If you set up an FAssets agent or user, please use a separate directory for each setup.
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:

```console
```bash
git clone https://github.com/flare-labs-ltd/fasset-bots.git
cd fasset-bots
```

2. Switch to the `open_beta` branch:

```console
```bash
git checkout open_beta
```

3. Install dependencies and build the project:

```console
```bash
yarn && yarn build
```

Expand All @@ -46,6 +46,6 @@ You will need knowledge of the following tools:

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

```console
```bash
cp .env.template .env
```
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,10 @@ nav:
- infra/data/managing-ecosystem/index.md
- infra/data/managing-ecosystem/exploring-collusion.md
- infra/data/managing-ecosystem/monitoring-price-history.md
- FAssets Agents:
- FAssets:
- infra/fassets/index.md
- infra/fassets/agent.md
- infra/fassets/liquidator.md
- Observer Nodes:
- infra/observation/index.md
- infra/observation/deploying.md
Expand Down

0 comments on commit 416af71

Please sign in to comment.