/fasset-bots

Primary LanguageTypeScriptMIT LicenseMIT

FAsset bots

FAsset bots

The FAsset system is a protocol that bridges assets from non-smart contract chains to Flare/Songbird. It includes bots that automate actions for various roles (agent, challenger, liquidator) in response to events that need quick reactions, such as collateral reservation, minting, redemption, low collateral ratio, and price changes.

Actors in FAsset system

  • Agent: The main player in the FAsset system.
  • Challenger: Ensures the health of the FAsset system.
  • Liquidator: Liquidates bad agents.
  • SystemKeeper: Keeps the FAsset system in order by opening and closing liquidations.
  • TimeKeeper: Maintains the underlying block by proving and updating it to prevent the current block from being too outdated, which would otherwise shorten the time for minting or redemption payments.

Install

Clone this repository fasset-bots and enter the fasset-bots directory.

git clone git@gitlab.com:flarenetwork/fasset-bots.git
cd fassets-bots

If you are beta tester, switch to branch private_beta_v.1.0.

git checkout private_beta_v.1.0

Install fasset-bots

yarn && yarn build

Setup

Agent Bot

Follow this step by step guide to setup an Agent Bot for XRP on Testnet

How to run

Agent bot

Run yarn run-agent.

The script will create AgentBotRunner. The runner will initiate needed context and connect to native network. Then it will constantly check if any active agent stored in persistent state should handle any incoming events.

In order to create new agent, deposit funds and do other manual operations, command line interface is provided agent-bot. You can access it with opening another terminal and run command yarn agent-bot [command].

Challenger, Liquidator, SystemKeeper, TimeKeeper

Other bots can be run using ActorBaseRunner. The runner will initiate needed context and create desired actor via method async create(config: TrackedStateConfig, address: string, kind: ActorBaseKind), where ActorBaseKind determines which actor should be created.

Example for such scripts:

  • Run yarn run-challenger for Challenger.

  • Run yarn run-liquidator for Liquidator.

  • Run yarn run-systemKeeper for SystemKeeper.

  • Run yarn run-timeKeeper for TimeKeeper.

Helpers: In order to efficiently run Challenger, Liquidation, SystemKeeper some non-persistent state is being tracked with TrackedState and TrackedAgentState. See here.

Agent bot command line interface

Command line interface is provided for Agent bot, User bot and for key/password generation. For more see here.

User bot command line interface

More information about the user bot can be found here.

Examples

REST APIs for Agent bot

Same commands as in cli agent-bot can be run via REST APIs. For more see here.

Logging

Log files are created every hour and can be found in packages/fasset-bots-core/log/.

What to be aware of when testing on Coston and testnet XRP

  • Run TimeKeeper or manually run proveAndUpdateUnderlyingBlock before reserving collateral, before redeeming, ...
  • Newly created testnet XRP account should get initial deposit of at least 10 XRP. Otherwise payment to this account will be rejected by tecNO_DST_INSUF_XRP.

Testnet faucets

Other usefull webclients