If you wish to suggest changes on this document, please open a PR on the Liquidity Provider Server Repository
Liquidity Provider Server
The Liquidity Provider Server (LPS) is a server that interacts with a Liquidity Bridge Contract (LBC) to provide liquidity for users as part of the Flyover protocol. This server performs all the necessary operations to play the role of the Liquidity Provider, involving transactions in both Rootstock and Bitcoin networks.
Liquidity Providers (LPs) interact with the protocol to perform management operations related to topics such as collateral, funds, fees management, configuration, etc. through the LPS. The LP does these operations through the Liquidity Provider Server, which is why the LPS also has an API that the LP interacts with to perform various management operations.
Actors in the Flyover Protocol
In the Flyover Protocol, there are three main Actors:
- The regular user (user), who is the party interested in executing Peg-In/Peg-Out operations
- The Liquidity Provider (LP), who provides liquidity to speed up the operation for the user in exchange for a fee as a reward
- The integrator who integrates the flyover SDK into their dapp/protocol. In order to do this, the user and the LP need to agree on the terms of the service (a Peg-In/Peg-Out Quote). This implies that the different LPs may offer different quotes, so the user needs to be able to interact with each LP to receive quote details and decide which one is going to be used for the operation.
The user interacts with the Flyover Protocol through the Flyover SDK. This SDK fetches the list of the available LP from the liquidity bridge contract (LBC), this contract returns a list where each element has some information about the LP, among this information will be the URL of the liquidity provider server (LPS) instance of that LP so the user can communicate with it. This means that the LPS has an API that every user interacts with to do the quote agreement.
How to Run LPS
To run the project locally you can follow these steps:
git clone git@github.com:rsksmart/liquidity-provider-server.gitcd docker-compose/localexport LPS_STAGE=regtest./lps-env.sh up
This will set up a local environment, please keep in mind that a productive set-up could vary in multiple aspects.
How to run the tests
For the unit tests you can run make test in the root of the repository and for the integration tests please check this file
Installing the project
If you want to play with the code and make modifications to it then run the following commands (remember that you need to have Go installed with the version specified in the go.mod file):
git clone git@github.com:rsksmart/liquidity-provider-server.gitmake tools
LPS APIs
The LPS has two main APIs:
- User/Public API: This API is used by the user to interact with the LP to agree on a quote. See Using the Public API
- LP/Management API: This API is used by the LP to interact with the LPS to perform management operations. It can be accessed via
<LPS URL>/management. See LP Management Section
Note The Management UI and Public API share the same server, accessible through the same URL. However, the Management API requires authentication for access, while the Public API does not. While authentication is a security measure, it's still recommended to deploy the Management API behind a Web Application Firewall (WAF) or Virtual Private Network (VPN) for added protection.
API limitations can vary based on the specific infrastructure of each Liquidity Provider Server (LPS). The current implementation does not impose explicit rate limits.
Configuring the Liquidity Provider Server
A Liquidity Provider Server acts as a crucial component of the Flyover protocol by managing liquidity between the Bitcoin and Rootstock networks. Interacting directly with the Liquidity Bridge Contract (LBC), the LP server fulfills requests for token swaps by holding reserves of both BTC and RBTC. It executes complex operations such as collateral management, fund transfers, and fee adjustments.
By default, the Management API is disabled, and it can be enabled only by setting the ENABLE_MANAGEMENT_API environment variable to true. This is a security measure to ensure that the API will only be accessible if it is explicitly enabled by the LP (or the person setting up the environment).
If the ENABLE_MANAGEMENT_API environment variable is set to true, it is the responsibility of the LP and the individual setting up the environment to ensure that the API is properly secured.
Environment Variables
To see the required environment variables to run an instance of this server and its description check the Environment.md file.
API Details
The HTTP API provided in this server is divided in two; the public API and the Management (private) API. To understand the purpose of each API check the LP Management file.
To see the details of the interface itself and the structures involved check the OpenAPI.yml file that is in the root of the repository.