Code Monkey home page Code Monkey logo

kwenta-subgraph's Introduction

CodeQL Discord Twitter Follow GitPOAP Badge

Kwenta

A dApp enabling derivatives trading โ€” powered by the Synthetix protocol.

The decentralized trading UI is available at kwenta.eth.limo.

ENS link: kwenta.eth.

The latest IPFS hash can be found under releases.

Contributing

Kwenta welcomes contributors. Regardless of the time you have available, everyone can provide meaningful contributions to the project by submitting bug reports, feature requests or even the smallest of fixes! To submit your contribution, please fork, fix, commit and create a pull-request describing your work in detail. For more details, please have a look at the Contribution guidelines.

Tech stack

  • Next.js
  • React
  • Redux
  • Kwenta SDK
  • Styled-Components

Ethereum stack

Development

Install dependencies

pnpm install

Set up environment variables

Copy the .env.local.example file in the packages/app directory to .env.local (which will be ignored by Git):

cd packages/app
cp .env.local.example .env.local

Then, open .env.local and add the missing environment variables:

Required:

  • NEXT_PUBLIC_PROVIDER_ID - Specifies the default provider, options are INFURA or BLAST_API
  • NEXT_PUBLIC_INFURA_PROJECT_ID - Infura project id (get it from infura.io) or
  • NEXT_PUBLIC_BLASTAPI_PROJECT_ID - Blast API project id (get it from blastapi.io)
  • NEXT_PUBLIC_SOCKET_API_KEY - Socket API key (get it from socket.tech
  • NEXT_PUBLIC_SATSUMA_API_KEY - API key for Satsuma subgraph queries
  • NEXT_PUBLIC_THEGRAPH_API_KEY - API key for The Graph's decentralized service
  • NEXT_PUBLIC_DEFAULT_PRICE_SERVICE - Specifies the default price server, options are KWENTA or PYTH
  • NEXT_PUBLIC_SERVICES_PROXY - Specify Kwenta proxy server

Run

cd packages/app
pnpm dev

Open http://localhost:3000 to view it in the browser.

Build

cd packages/app
pnpm build
pnpm start

Unit Testing

cd packages/app
pnpm test:jest

For unit tests we use a combination of Jest and React Testing Library

Page tests should be added to the testing folder at the root as it is not possible to co-locate tests and pages in nextjs. Other tests should be co-located in a __tests__ folder next to their related file.

Contact

Join the community on the Kwenta Discord server!

kwenta-subgraph's People

Contributors

0xclem avatar 0xlinus avatar avclarke avatar brossetti1 avatar dbeal-eth avatar dependabot[bot] avatar evgenyboxer avatar insulineru avatar jcmonte avatar jjgonecrypto avatar kmeraz avatar koredefashokun avatar leifuchen avatar noahlitvin avatar sistemico avatar tburm avatar wangyangjun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kwenta-subgraph's Issues

Production Subgraph Updates

  • Deploy production subgraph for optimism mainnet
  • Get contract addresses from Synthetix libraries
  • Add fees to position handler
  • Point UI at production subgraph
  • Add conditional statement to point at mainnet vs testnet subgraphs

Add raw PositionModified Events

Add a handler for the PositionModified events coming from each FuturesMarket contract.

  • Subgraph contains PositionModified entity

Add keeper fee to position

Update fees on Next-price order execution

  • Add keeper fee to position and trade entities if NP order executed by keeper

Limit order investigation

Collect transactions for limit orders through gelato and plan a way to track open orders and transactions

Set up repo

Deliverables:

  • Remove all subgraphs except futures and latest-rates (candles)
  • Review docs for info that is not relevant to Kwenta subgraphs

Implement decentralized subgraph

  • Set up Kwenta test polygon wallet
  • Manually deploy to decentralized subgraph
  • Check curation and indexing on newly deployed graph

Investigate PnL calculation

  • Add basic PnL summation to subgraph
  • Verify PnL includes funding
  • Determine if we should have a separate subgraph for the futures competition

Update README

Update readme with relevant information for Kwenta. Remove deprecated Synthetix information and entities

Subgraph CI Updates

  • Add separate latest-rates deploy to CI
  • Point Kwenta at new latest-rates endpoint
  • Update main subgraph to exclude latest-rates

Update orders

  • Change "Pending" state to "Open"
  • Add event handlers for limit order events

Discuss Future of Subgraph

  • Investigate what to do once subgraph starts sunsetting hosted service (Q3/22)
  • Investigate alternatives

Fix Liquidation Pnl

Liquidation position pnl is showing as >100%

Cap liquidation losses to initial margin + total deposits. This occurs when funding is really high or closing price results in excess losses taken by the debt pool.

  • pnlWithFeesPaid is never >100% for a position
  • Implement pnlWithFeesPaid on frontend queries

Add `FuturesMarginAccount` entity

Add an entity that tracks the margin for each user within each market. The entity will update each time they deposit, withdraw, or modify their position.

  • Added FuturerMarginAccount entity futures subgraph

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.