Giter VIP home page Giter VIP logo

limit-order-advance-example's Introduction

Limit Order Taker Example

This is a simple limit order taker example that utilise Jupiter quoting API to execute Jupiter Limit Order.

Getting started

  1. Populate these environment variable to .env file
RPC_URL=<private rpc endpoint>
PRIVATE_KEY=<wallet private key>
JUPITER_API_URL=<self hosted Jupiter endpoint>
  1. Install dependencies
pnpm install
  1. Start the bot
pnpm start

How it work?

  1. Get all the open orders from onchain and subscribe using websocket
  2. Group all the orders by input mint then output mint.
    // {
    //   Sol: {
    //     USDC: [Order, Order, Order],
    //     USDT: [Order, Order, Order],
    //   }
    // }
  1. Get the price of output mint vs input mint like grouping above
  2. Compare the price from quoting and the order, filters orders within 0.3% range of the quote price
  3. Get quote from Jupiter Swap API and check whether the order is profitable to execute.
  4. Bundle Jupiter Swap Ix with Limit Order Flash Fill Ix to execute the order.

Flash FIll

It is similar concept with flash loan. The keeper first borrow the input amount from the order, then it use the input amount to swap in Jupiter and return with desired output amount.

Sample tx: https://solscan.io/tx/4dXdmig9nFFMpggsv59fmKJJQ8KrGstGvNhkdy2yToLpghTKUU9M8ddkAY1UUuZfg2GK3woP7BqnZ4yMCRucScmD

Using this method will not required the keeper to hold any funds, it just need SOL for transaction fees and ata token accounts rent.

limit-order-advance-example's People

Contributors

hjchan 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.