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
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
node: ['14.x']
node: ['16.x']
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ build/
generated/
exchange.yaml
staking.yaml
limitorder.yaml
subgraphs/staking/src/helper.ts
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
"codegen": "yarn workspaces run codegen",
"deploy": "yarn workspaces run deploy",
"deploy-staging:mainnet": "yarn workspaces run deploy-staging:mainnet",
"deploy-staging:arbitrum": "yarn workspaces run deploy-staging:arbitrum",
"deploy-staging:goerli": "yarn workspaces run deploy-staging:goerli",
"prepare:mainnet": "yarn workspaces run prepare:mainnet",
"prepare:arbitrum": "yarn workspaces run prepare:arbitrum",
"prepare:goerli": "yarn workspaces run prepare:goerli"
},
"dependencies": {
"@graphprotocol/graph-cli": "^0.33.1",
"@graphprotocol/graph-ts": "0.27.0"
"@graphprotocol/graph-cli": "0.55.0",
"@graphprotocol/graph-ts": "0.30.0"
},
"devDependencies": {
"mustache": "^4.2.0",
"yargs-parser": "^21.1.1"
"yargs-parser": "^21.1.1",
"matchstick-as": "0.5.0"
}
}
2 changes: 2 additions & 0 deletions subgraphs/exchange/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"build": "graph build exchange.yaml",
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ consenlabs/tokenlon-v5-exchange exchange.yaml",
"deploy-staging:mainnet": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ $SUBGRAPH_USER/tokenlon-v5-exchange exchange.yaml",
"deploy-staging:arbitrum": "echo ${NotUse}",
"deploy-staging:goerli": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ $SUBGRAPH_USER/tokenlon-v5-goerli-exchange exchange.yaml",
"prepare:mainnet": "mustache config/mainnet.json template.yaml > exchange.yaml",
"prepare:arbitrum": "echo ${NotUse}",
"prepare:goerli": "mustache config/goerli.json template.yaml > exchange.yaml"
}
}
213 changes: 213 additions & 0 deletions subgraphs/limitorder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Subgraph for imToken LimitOrder contract in Goerli Testnet

## Prepare

- Please follow this [official document](https://thegraph.com/docs/en/cookbook/quick-start/) to install graph-cli

## Download and Compile

- Download

```shell
# Download
% git clone "[email protected]:consenlabs/tokenlon-v5-subgraph.git"
% code "tokenlon-v5-subgraph/"

# Get dependence
% yarn install
```

- Compile subgraph (Goerli Testnet)

```shell
% yarn run prepare:goerli && yarn run codegen && yarn run build
```

## Deploy for LimitOrder contract only in Goerli Testnet

```shell
% graph auth --studio <Your Deploy Key>
% yarn workspace "limitorder" run graph deploy --studio limitorder
```

Output:

```shell
yarn workspace v1.22.19
yarn run v1.22.19
$ /Users/irara/MyGithubOneleo/tokenlon-v5-subgraph/node_modules/.bin/graph deploy --studio limitorder
✔ Version Label (e.g. v0.0.1) · v0.0.1
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
✔ Apply migrations
✔ Load subgraph from subgraph.yaml
Compile data source: LimitOrder => build/LimitOrder/LimitOrder.wasm
✔ Compile subgraph
Copy schema file build/schema.graphql
Write subgraph file build/LimitOrder/abis/LimitOrder.json
Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/
Add file to IPFS build/schema.graphql
.. QmRtsYrCjJ2YHBJE1xxdm1tQJMzzveWygGwFbzC96t6aT4
Add file to IPFS build/LimitOrder/abis/LimitOrder.json
.. QmWtZnAiKbLZ9e6Z8jk6ApR5X9HQhQBn9JPV4P8jBzQvSh
Add file to IPFS build/LimitOrder/LimitOrder.wasm
.. QmUtpUNyP6P2JsxEPSuGLLH6YVUPHA2X9tf1v9q1vmJb8k
✔ Upload subgraph to IPFS

Build completed: QmYigtJzraLhczyemJtNVsUDBpCw741cKajvuUZNVmKUDC

Deployed to https://thegraph.com/studio/subgraph/limitorder

Subgraph endpoints:
Queries (HTTP): https://api.studio.thegraph.com/query/34764/limitorder/v0.0.1

✨ Done in 40.66s.
✨ Done in 40.80s.
```

## Try GraphQL in Subgraph Playground

:notebook: Created by GraphQL Explorer in Subgraph Playground

```graphql
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
}
}
```

## Query output:

```
{
"data": {
"orders": [
{
"id": "0x3f2c773464fa2c2e69ac2d76d07106e33b4dcb057f07ac46676ecbccc395e2ef",
"maker": "0x81b576c27dc24f1f5892c2016d1ae7cfc7bf6880",
"makerToken": "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6",
"takerToken": "0xa93ef9215b907c19e739e2214e1aa5412a0401b5",
"firstFilledTime": "1663325172",
"lastFilledOrCancelledTime": "1663325172",
"orderStatus": "FullyFilled"
},
{
"id": "0x8ef1b0f0ccfaa8b4e73957696b73f87b7b51b3fd71220eb71e6e0e6a4aa0fcf5",
"maker": "0x83f95c33d61ef8814db62f83490f31e2741d0507",
"makerToken": "0x6da0e6abd44175f50c563cd8b860dd988a7c3433",
"takerToken": "0xa93ef9215b907c19e739e2214e1aa5412a0401b5",
"firstFilledTime": "1663325220",
"lastFilledOrCancelledTime": "1663325220",
"orderStatus": "FullyFilled"
},
{
"id": "0x56527f821250a9fddd5b9715dd00f206de30e8ca054179e17840b8e578dbf958",
"maker": "0x81b576c27dc24f1f5892c2016d1ae7cfc7bf6880",
"makerToken": "0x6da0e6abd44175f50c563cd8b860dd988a7c3433",
"takerToken": "0xa93ef9215b907c19e739e2214e1aa5412a0401b5",
"firstFilledTime": "1663325244",
"lastFilledOrCancelledTime": "1663325244",
"orderStatus": "FullyFilled"
}
],
"limitOrders": [
{
"id": "0x2e01f211fd39bd2c5281680057debb5e9e31b84cabf389721b5ed206c4b1de06-0x13c4a375ea5494258476b4139cc2313606a62c1d9c2342e0fda4c9f2d701b201-156",
"limitOrderType": "ByProtocol",
"makerTokenFilledAmount": "100000000000000000",
"takerTokenFilledAmount": "402000000",
"blockTimestamp": "1663325172"
},
{
"id": "0xd7bf25963d75bcecb5e323796cf00cd77bbbe25631f88c9aee8cf8aeec5e8eb4-0x94b1e07a8411a4ebea04282ff92354b7acc26e0f15650c42536a452a137d7d78-304",
"limitOrderType": "ByProtocol",
"makerTokenFilledAmount": "10000000000000000000",
"takerTokenFilledAmount": "27820700",
"blockTimestamp": "1663325220"
},
{
"id": "0x37aa37ea523ac640f1d50033b0148222786a361aca41116d59f6ff29762b718b-0x7b7ab03420759f39b154793f883ed1386a26439e6c1a94a476ee48fea32c2634-191",
"limitOrderType": "ByProtocol",
"makerTokenFilledAmount": "10000000000000000000",
"takerTokenFilledAmount": "25000000",
"blockTimestamp": "1663325244"
}
],
"limitOrderFilledByProtocols": [
{
"id": "0x2e01f211fd39bd2c5281680057debb5e9e31b84cabf389721b5ed206c4b1de06-0x13c4a375ea5494258476b4139cc2313606a62c1d9c2342e0fda4c9f2d701b201-156",
"fillReceipt_makerTokenFilledAmount": "100000000000000000",
"fillReceipt_takerTokenFilledAmount": "402000000",
"fillReceipt_remainingAmount": "0",
"blockTimestamp": "1663325172"
},
{
"id": "0xd7bf25963d75bcecb5e323796cf00cd77bbbe25631f88c9aee8cf8aeec5e8eb4-0x94b1e07a8411a4ebea04282ff92354b7acc26e0f15650c42536a452a137d7d78-304",
"fillReceipt_makerTokenFilledAmount": "10000000000000000000",
"fillReceipt_takerTokenFilledAmount": "27820700",
"fillReceipt_remainingAmount": "0",
"blockTimestamp": "1663325220"
},
{
"id": "0x37aa37ea523ac640f1d50033b0148222786a361aca41116d59f6ff29762b718b-0x7b7ab03420759f39b154793f883ed1386a26439e6c1a94a476ee48fea32c2634-191",
"fillReceipt_makerTokenFilledAmount": "10000000000000000000",
"fillReceipt_takerTokenFilledAmount": "25000000",
"fillReceipt_remainingAmount": "0",
"blockTimestamp": "1663325244"
}
],
"limitOrderFilledByTraders": []
}
}
```

## Published to Graph Explorer on Goerli Testnet

- [Tokenlon Limit Order Subgraph on Goerli Testnet](https://testnet.thegraph.com/explorer/subgraph?id=DSCkswEpNfuaa5gwDWP514QXdtQs7Wh8hKruSN1sV97L)
77 changes: 77 additions & 0 deletions subgraphs/limitorder/abis/ERC20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
31 changes: 31 additions & 0 deletions subgraphs/limitorder/abis/ERC20Bytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]

Loading