Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labs 1753/limit order arbitrum mainnet #38

Open
wants to merge 4 commits into
base: limitorder-hosted-service
Choose a base branch
from

Conversation

oneleo
Copy link
Contributor

@oneleo oneleo commented Aug 16, 2023

PR: LimitOrder Subgraph for Hosted Service on Mainnet, Arbitrum and Goerli

Major Changes

  1. This version supports the Mainnet, Arbitrum, and Goerli networks.
  2. This version includes the three main events of the LimitOrder: LimitOrderFilledByProtocol, LimitOrderFilledByTrader, and OrderCancelled.
  3. This version also features the integrated LimitOrderFilled Entity, which combines the LimitOrderFilledByProtocol and LimitOrderFilledByTrader events.
  4. Additionally, this version incorporates the updatable Order Entity, providing the ability to query the current status of orders.

Other Changes

  1. Due to incompatibility between the ipfs-utils module and Node.js version 14, the Node.js parameter in GitHub CI has been updated to version 16.
  2. Revised GraphQL query examples for the LimitOrder subgraph.
  3. Add "prepare:arbitrum" and "deploy-staging:arbitrum" to package.json. However, if the corresponding exchange, staking, and limitorder are not supported, execute "echo ${NotUse}".
  4. Update the version of Graph-CLI.
  5. Add "limitorder.yaml" to .gitignore.

Deployment Process to "Subgraph Studio" Platform

% yarn cache clean
% yarn install
% graph auth --studio <YOUR DEPLOY KEY>

### Assuming the Subgraph name you have set in Subgraph Studio is "tokenlon-limitorder-mainnet"
% yarn run prepare:mainnet && yarn run codegen && yarn run build
% yarn workspace "limitorder" run graph deploy --studio tokenlon-limitorder-mainnet limitorder.yaml

### Assuming the Subgraph name you have set in Subgraph Studio is "tokenlon-limitorder-arbitrum"
% yarn run prepare:arbitrum && yarn run codegen && yarn run build
% yarn workspace "limitorder" run graph deploy --studio tokenlon-limitorder-arbitrum limitorder.yaml

### Assuming the Subgraph name you have set in Subgraph Studio is "tokenlon-limitorder-goerli"
% yarn run prepare:goerli && yarn run codegen && yarn run build
% yarn workspace "limitorder" run graph deploy --studio tokenlon-limitorder-goerli limitorder.yaml

GraphQL query examples for the LimitOrder subgraph

query MyQuery {
  orders(orderBy: lastFilledTime, first: 3, orderDirection: desc) {
    id
    maker
    makerToken
    takerToken
    firstFilledTime
    lastFilledTime
    cancelledTime
    orderStatus
  }
  limitOrderFilleds(orderBy: blockTimestamp, first: 3, orderDirection: desc) {
    id
    limitOrderFilledType
    makerTokenFilledAmount
    takerTokenFilledAmount
    recipient
    relayer
    profitRecipient
    takerTokenProfit
    takerTokenProfitFee
    takerTokenProfitBackToMaker
    blockTimestamp
  }
  limitOrderFilledByProtocols(orderBy: blockTimestamp, first: 3, orderDirection: desc) {
    id
    relayer
    profitRecipient
    fillReceiptMakerTokenFilledAmount
    fillReceiptTakerTokenFilledAmount
    fillReceiptRemainingAmount
    takerTokenProfit
    takerTokenProfitFee
    takerTokenProfitBackToMaker
    blockTimestamp
  }
  limitOrderFilledByTraders(first: 3, orderDirection: desc, orderBy: blockTimestamp) {
    id
    recipient
    fillReceiptMakerTokenFilledAmount
    fillReceiptTakerTokenFilledAmount
    fillReceiptRemainingAmount
    blockTimestamp
  }
}

oneleo added 3 commits August 15, 2023 19:00
…er LimitOrder Subgraph

1) Add "prepare:arbitrum" and "deploy-staging:arbitrum" to package.json. However, if the
corresponding exchange, staking, and limitorder are not supported, execute "echo ${NotUse}".

2) Update the version of Graph-CLI.

3) Add "limitorder.yaml" to .gitignore.
1) This version supports the Mainnet, Arbitrum, and Goerli networks.
2) This version includes the three main events of the LimitOrder:
LimitOrderFilledByProtocol, LimitOrderFilledByTrader, and OrderCancelled.
3) This version also features the integrated LimitOrderFilled Entity, which
combines the LimitOrderFilledByProtocol and LimitOrderFilledByTrader events.
4) Additionally, this version incorporates the updatable Order Entity,
providing the ability to query the current status of orders.
1) Due to incompatibility between the ipfs-utils module and Node.js version
14, the Node.js parameter in GitHub CI has been updated to version 16.
2) Revised GraphQL query examples for the LimitOrder section.
const tokenAddr: Address = Address.fromBytes(tokenAddrBytes)
let tokenAddrStr = tokenAddr.toHex()
if (isETH(tokenAddr)) {
tokenAddrStr = WETH_ADDRESS.toHex()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug has been identified here.
When collecting TradedToken Entity, if the assetAddr is detected as of type WETH, it will be replaced with the Mainnet WETH address ("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2") universally.
It should instead replace it with the WETH address on the respective network.
This issue will be addressed in the next commit.

…ith Mainnet address

When collecting TradedToken Entity, if the assetAddr is detected to be of the WETH type,
it is currently being universally replaced with the Mainnet WETH address. Instead,
the intention is to replace it with the WETH address specific to that network.
@charlesjhongc
Copy link

What's the status of this PR? Still work in progress or ready to merge?

@oneleo
Copy link
Contributor Author

oneleo commented Aug 17, 2023

What's the status of this PR? Still work in progress or ready to merge?

This PR serves two main purposes and has one reason.

  1. One purpose is to distinguish the branch merging LimitOrder and Exchange. limitorder_feature branch
  2. Another purpose is to request everyone's assistance in reviewing the code of the upcoming LimitOrder Subgraph that will be deployed on the Hosted Service.
  3. It's not merged into master because the Exchange and Staking Subgraphs on the Hosted Service are still in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants