Git Product home page Git Product logo

chainflip-perseverance's Introduction

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: 0x0485D65da68b2A6b48C3fA28D7CCAce196798B94

    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.

chainflip-perseverance's People

Contributors

ahasna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.