Skip to content

chainflip-io/chainflip-perseverance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

chainflip-perseverance

Pre-requisites

Setup

Clone the repo

git clone https://github.com/chainflip-io/chainflip-perseverance.git
cd chainflip-perseverance

Generating Keys

mkdir -p ./chainflip/keys/lp
mkdir -p ./chainflip/keys/broker
docker run --platform=linux/amd64 --entrypoint=/usr/local/bin/chainflip-cli chainfliplabs/chainflip-cli:perseverance generate-keys --json > chainflip/lp-keys.json
docker run --platform=linux/amd64 --entrypoint=/usr/local/bin/chainflip-cli chainfliplabs/chainflip-cli:perseverance generate-keys --json > chainflip/broker-keys.json
cat chainflip/broker-keys.json | jq -r '.signing_key.secret_key' > chainflip/keys/broker/signing_key_file
cat chainflip/lp-keys.json | jq -r '.signing_key.secret_key' > chainflip/keys/lp/signing_key_file

Fund Accounts

Note: The minimum funding amount for registering as a Broker or LP role is technically 1 FLIP. However, we recommend funding your accounts with at least 5 FLIP to account for transaction fees.

  1. Get some tFLIP

    a. Add the tFLIP token to your wallet using the following address: 0xdC27c60956cB065D19F08bb69a707E37b36d8086

    b. Get in touch with us on Discord and we'll send you some tFLIP

  2. Get the public key of the Broker or LP account:

# Broker
cat chainflip/broker-keys.json | jq -r '.signing_account_id'

# LP
cat chainflip/lp-keys.json | jq -r '.signing_account_id'
  1. Then head to the Auctions Web App
  2. Connect your wallet
  3. Click "Add Node"
  4. Follow the instructions to fund the account

Running the APIs

Important Note

💡 Note: By default, the Node, LP and Broker APIs accept connection from any host. This is intentional to make testing easier. However, if you wish to make this more secure, feel free to update the ports in the docker-compose.yml file to only accept connections from localhost.

This can be achieved by adding 127.0.0.1: before the port number. For example:

  lp:
    image: chainfliplabs/chainflip-lp-api:perseverance
    pull_policy: always
    stop_grace_period: 5s
    stop_signal: SIGINT
    platform: linux/amd64
    restart: unless-stopped
    ports:
      - "127.0.0.1:10589:80"
    volumes:
      - ./chainflip/keys/lp:/etc/chainflip/keys
    entrypoint:
      - /usr/local/bin/chainflip-lp-api
    command:
      - --state_chain.ws_endpoint=ws://node:9944
    depends_on:
      - node

Starting the Node and APIs

Start by starting the node and wait for it to sync:

docker compose up node -d
docker compose logs -f

💡 Note: You know that your node is synced once you start seeing logs similar to the following:

chainflip-perseverance-node-1  | 2023-10-13 16:02:00 ✨ Imported #614404 (0x990b…be63)

Once the node is synced you can start the APIs:

docker compose up -d
docker compose logs -f

If you want to only start the Broker API, you can run:

docker compose up -d broker
docker compose logs -f broker

If you want to only start the LP API, you can run:

docker compose up -d lp
docker compose logs -f lp

Interacting with the APIs

You can connect to your local RPC using PolkadotJS to see chain events.

Note: The following commands take a little while to respond because it submits and waits for finality.

Broker

Register a broker account:

curl -H "Content-Type: application/json" \
    -d '{"id":1, "jsonrpc":"2.0", "method": "broker_registerAccount"}' \
    http://localhost:10997

Request a swap deposit address:

curl -H "Content-Type: application/json" \
    -d '{"id":1, "jsonrpc":"2.0", "method": "broker_requestSwapDepositAddress", "params": ["ETH", "FLIP","0xabababababababababababababababababababab", 0]}' \
    http://localhost:10997

LP

Register an LP account:

curl -H "Content-Type: application/json" \
    -d '{"id":1, "jsonrpc":"2.0", "method": "lp_register_account", "params": [0]}' \
    http://localhost:10589

Register a liquidity refund address:

Before you can deposit liquidity, you need to register a liquidity refund address. This is the address that will receive your liquidity back when you withdraw it.

curl -H "Content-Type: application/json" \
    -d '{"id":1, "jsonrpc":"2.0", "method": "lp_register_liquidity_refund_address", "params": {"chain": "Ethereum", "address": "0xabababababababababababababababababababab"}}' \
    http://localhost:10589

Request a liquidity deposit address:

curl -H "Content-Type: application/json" \
    -d '{"id":1, "jsonrpc":"2.0", "method": "lp_liquidity_deposit", "params": ["ETH"]}' \
    http://localhost:10589

For more details please refer to the Integrations documentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published