Querying Laminar Flow Protocols using GraphQL

Bette Chen
Laminar
Published in
2 min readNov 11, 2019

What is Subgraph

The Graph is an easy way to get data off the blockchain for direct consumption by applications and users. Projects can deploy their own Subgraphes that encapsulate which on-chain data are indexed, how they are stored and a GraphQL schema for querying. A Subgraph can be deployed on the Graph decentralized network, and supported for filtering, sorting, WebSocket subscriptions, etc.

Sounds cool! So, we have built a Laminar Flow Protocol Subgraph, so that anyone can easily explore and access the data from the Laminar Flow smart contracts.

Laminar Flow Protocols Subgraph

The Protocols

The Laminar Flow Protocols powers synthetic assets, margin trading with the integrated money market. The protocol is deployed on Ethereum Kovan Testnet in November 2019. It enables minting synthetic EUR and JPY, up to 20x margin trading with instant liquidity, and a built-in money market to earn interests while trading.

The Subgraph

The Laminar Flow Protocol Kovan Subgraph provides access to the most essential data in the protocols. This is a work in progress. Please provide us feedback, contribute if you like, and help us improve. We have highlighted the areas that would be interesting to anyone exploring the Flow Protocols below.

Synthetic Assets

  • These are essentially the synthetic assets aka fTokens available to mint

Synthetic Asset Trading Events

  • There could be multiple events in a single transaction

Market Prices

  • Price feeds are available for each fToken

Margin Trading Pairs

  • These are the available margin trading pairs with leverage

Margin Trading Positions

  • These are the open and closed positions.
  • Each position stores the open price, which can be used to calculate the current margin position. Anyone can track whether a position is unsafe, or completely liquidated.
  • A position is liquidated when either side (the trader or the liquidity pool) has lost all of its margins.
// a position is liquidated if
(currentPrice - openPrice) / openPrice * leverage >= 1
OR
(currentPrice - openPrice) / openPrice * leverage <= -1
  • A position is deemed unsafe when liquidity pool lost more than the safe margin
// a position is unsafe if
(currentPrice - openPrice) / openPrice * leverage > SafeMargin
OR
(currentPrice - openPrice) / openPrice * leverage < -SafeMargin

The source code: https://github.com/laminar-protocol/flow-protocol-ethereum/tree/master/subgraph

The subgraph explorer: https://thegraph.com/explorer/subgraph/laminar-protocol/flow-protocol-subgraph

Mainnet

Laminar Flow Protocols are currently on Ethereum Kovan testnet, and are actively under development and improvements. You are welcome to follow us for mainnet release plans and announcements. The Subgraph will be kept up to date with any changes, and in sync with mainnet release.

Get Updates from Laminar

Official Website: https://laminar.one
Twitter: https://twitter.com/LaminarProtocol
Github: https://github.com/laminar-protocol/flow-protocol-ethereum
LinkedIn:https://www.linkedin.com/company/laminar-protocols

--

--

Bette Chen
Laminar
Editor for

COO & Co-Founder @Laminar & @AcalaNetwork. Full-stack Product Manager. Budling for a decentralized future.