Giter VIP home page Giter VIP logo

perp-maker's Introduction

maker

Perp Maker

A simple maker strategy for perpetual protocol v2. Please note that it uses a basic strategy and serves as a template for developers to create their own maker strategy. Use it at your own risk!

Requirement

  • npm >=7 <=7.24.1
  • nodejs >= 16
  • Since maker strategy will adjust your order, please make sure there's only 0 or 1 order in the account.

Warning Check your npm version by using npm -v. It must be within the range of v7.0.0 ~ v7.24.1. v7.24.1 is recommended. Using the versions > 7.24.1 to install packages will get stuck. To install or reinstall npm, run npm install -g [email protected]

Installation

$ git clone https://github.com/perpetual-protocol/perp-maker.git
$ cd perp-maker
$ npm install
$ npm run build

Configuration

Edit the trading parameters in src/configs/config.json:

{
    // the frequency to check price in second
    "PRICE_CHECK_INTERVAL_SEC": 10,
    // the maximum gas fee in Gwei to adjust liquidity. If gas price exceeds this number, the liquidity won't be adjusted
    "ADJUST_MAX_GAS_PRICE_GWEI": 100,

    // Maximum 5 markets
    "MARKET_MAP": {
        "vBTC": {
            // set to `true` to enable this market
            "IS_ENABLED": true,
            // how many amount of USD (after leverage) to provide in the liquidity
            "LIQUIDITY_AMOUNT": 0,

            // the offset to upper price and lower price of the liquidity range.
            // e.g. if set to 0.5, it will provide liquidity with range [current price / 1.5, current price * 1.5]
            "LIQUIDITY_RANGE_OFFSET": 0.5,

            // the offset to adjust range liquidity.
            // e.g. if set to 0.1, it will adjust liquidity when the current price goes out of the range [market price / 1.1, market price * 1.1]
            "LIQUIDITY_ADJUST_THRESHOLD": 0.1
        },
    }
}

Environment Variables

Provide your endpoint(s) and wallet private key in .env:

# endpoint(s)
L2_WEB3_ENDPOINTS={ENDPOINT1,ENDPOINT2,...}

# secrets
PRIVATE_KEY={WALLET_PRIVATE_KEY}

Run

$ env $(cat .env | grep -v '#' | xargs) npm run start

Docker

$ docker build -f maker.Dockerfile -t perp-maker .
$ docker run --env-file ./.env perp-maker

Deployment

AWS Lambda

Prerequisite

  • ~/.aws/credentials should have default profile with aws_access_key_id and aws_secret_access_key
  • copy .env.example to .env
  • Fill in envs in .env

Deploy

npm run build
npm run sls:deploy

If any features/functionalities described in the Perpetual Protocol documentation, code comments, marketing, community discussion or announcements, pre-production or testing code, or other non-production-code sources, vary or differ from the code used in production, in case of any dispute, the code used in production shall prevail.

perp-maker's People

Contributors

cheshirecatnick avatar daidoli avatar normanlinnet avatar sillyleo avatar vinta 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.