Giter Site home page Giter Site logo

openbook-twap's Introduction

OpenBook TWAP

License LGPLv2.1

A program that allows you to fetch on-chain TWAPs from OpenBook V2 markets.

Oracle

We provide a Uniswap V2-style oracle. This means:

  • For each market, there is a running price aggregator.
  • Before the first trade in a slot, we add the current spot price (defined as the average of the best bid and the best offer) to the aggregator.
  • To fetch a TWAP between two points, one can compute (current_aggregator - past_aggregator) / slots_elapsed. Just like in Uniswap V2, the client is responsible for storing past aggregator points.

Interacting with a TWAP market

The TWAP market program decorates the OpenBook v2 program. It does this by having a wrapper TWAPMarket account that stores the TWAP and is the open_orders_admin of the underlying openbook_v2 market. That way, all order book state transitions are forced to proxy through the twap_market program.

Deployed versions

tag network program ID
v0.1 mainnet TWAPrdhADy2aTKN5iFZtNnkQYXERD9NvKjPFVPMSCNN
v0.1 devnet TWAPrdhADy2aTKN5iFZtNnkQYXERD9NvKjPFVPMSCNN
v0 mainnet TWAP7frdvD3ia7TWc8e9SxZMmrpd2Yf3ifSPAHS8VG3
v0 devnet TWAP7frdvD3ia7TWc8e9SxZMmrpd2Yf3ifSPAHS8VG3

All programs are immutable.

Verifying

The program was compiled with solana-verifiable-build, which means that anyone can verify that the on-chain program matches the source code. To do so, install the CLI and run:

$ solana-verify verify-from-repo -um --program-id TWAPrdhADy2aTKN5iFZtNnkQYXERD9NvKjPFVPMSCNN https://github.com/metaDAOproject/openbook-twap --library-name openbook_twap -b ellipsislabs/solana:1.16.10

You can also see OtterSec's attestation of this verification here.

openbook-twap's People

Contributors

metaproph3t avatar soundsonacid avatar sapphire-alysa-star 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.