This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
forked from Uniswap/v2-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89d7b9a
commit f1f4511
Showing
7 changed files
with
74 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
NODE_MODE=developement | ||
NODE_MODE=deployed | ||
DATABASE_URL_LOCAL=mongodb://localhost:27017/V2-graphQL | ||
DATABASE_URL_ONLINE=mongodb+srv://admin:[email protected]/V2-graphQL?retryWrites=true&w=majority | ||
FACTORY_ADDRESS=157ece984b5ee7c58ae95299b4b7afa890bddb1d9f710fe2384a9e589f9b1bb8 | ||
token0=ebd3469763c597ef971782ea6a164531183c2251cac023cabf84b7c6bb521136 | ||
token1=d595a82535e34b87ee37b5cc094241304e28b0904f70ff83ffbc9f71bc9b5410 | ||
pair=5d7922b0281a1074663be274d0e0e8bd14aae748aa28d3b552aef8d0a5a7963b | ||
FACTORY_CONTRACT=157ece984b5ee7c58ae95299b4b7afa890bddb1d9f710fe2384a9e589f9b1bb8 | ||
PAIR_CONTRACT=5d7922b0281a1074663be274d0e0e8bd14aae748aa28d3b552aef8d0a5a7963b | ||
CALLEE_CONTRACT=fbfeda8b97f056f526f20c2fc2b486d9bdbfb3e46b9a164527e57c0c86e68612 | ||
TOKEN0_CONTRACT=ebd3469763c597ef971782ea6a164531183c2251cac023cabf84b7c6bb521136 | ||
TOKEN1_CONTRACT=d595a82535e34b87ee37b5cc094241304e28b0904f70ff83ffbc9f71bc9b5410 | ||
|
||
GRAPHQL=http://localhost:3000/graphql | ||
CHAIN_NAME=casper-test | ||
|
@@ -67,9 +68,3 @@ SET_TREASURY_FEE_PERCENT_PAYMENT_AMOUNT=5000000000 | |
SET_FEE_TO_PAYMENT_AMOUNT=5000000000 | ||
SET_FEE_TO_SETTER_PAYMENT_AMOUNT=5000000000 | ||
CREATE_PAIR_PAYMENT_AMOUNT=5000000000 | ||
|
||
FACTORY_CONTRACT=157ece984b5ee7c58ae95299b4b7afa890bddb1d9f710fe2384a9e589f9b1bb8 | ||
PAIR_CONTRACT=5d7922b0281a1074663be274d0e0e8bd14aae748aa28d3b552aef8d0a5a7963b | ||
CALLEE_CONTRACT=fbfeda8b97f056f526f20c2fc2b486d9bdbfb3e46b9a164527e57c0c86e68612 | ||
TOKEN0_CONTRACT=ebd3469763c597ef971782ea6a164531183c2251cac023cabf84b7c6bb521136 | ||
TOKEN1_CONTRACT=d595a82535e34b87ee37b5cc094241304e28b0904f70ff83ffbc9f71bc9b5410 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Casper_Uniswap_V2 GraphQL | ||
|
||
Casper Uniswap is a decentralized protocol for automated token exchange on Casper. | ||
|
||
This graphql dynamically tracks any pair created by the casper uniswap factory. It tracks of the current state of casper Uniswap contracts, and contains derived stats for things like historical data and USD prices. | ||
|
||
- aggregated data across pairs and tokens, | ||
- data on individual pairs and tokens, | ||
- data on transactions | ||
- data on liquidity providers | ||
- historical data on Uniswap, pairs or tokens, aggregated by day | ||
|
||
## Running Locally | ||
|
||
npm install to install the require packages | ||
npm start to start the server | ||
|
||
## Queries | ||
|
||
Below are a few ways to show how to query the casper-uniswap-graphql for data. The queries show most of the information that is queryable, but there are many other filtering options that can be used, just check out the [querying api](https://thegraph.com/docs/graphql-api). These queries can be used locally or in The Graph Explorer playground. | ||
|
||
## Key Entity Overviews | ||
|
||
#### Casper UniswapFactory | ||
|
||
Contains data across all of Casper Uniswap V2. This entity tracks important things like total liquidity (in CSPR and USD, see below), all time volume, transaction count, number of pairs and more. | ||
|
||
#### Token | ||
|
||
Contains data on a specific token. This token specific data is aggregated across all pairs, and is updated whenever there is a transaction involving that token. | ||
|
||
#### Pair | ||
|
||
Contains data on a specific pair. | ||
|
||
#### Transaction | ||
|
||
Every transaction on Uniswap is stored. Each transaction contains an array of mints, burns, and swaps that occured within it. | ||
|
||
#### Mint, Burn, Swap | ||
|
||
These contain specifc information about a transaction. Things like which pair triggered the transaction, amounts, sender, recipient, and more. Each is linked to a parent Transaction entity. | ||
|
||
## Example Queries | ||
|
||
### Querying Aggregated Casper Uniswap Data | ||
|
||
This query fetches aggredated data from all Casper uniswap pairs and tokens, to give a view into how much activity is happening within the whole protocol. | ||
|
||
```graphql | ||
{ | ||
uniswapFactories(first: 1) { | ||
pairCount | ||
totalVolumeUSD | ||
totalLiquidityUSD | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +0,0 @@ | ||
// var mongoose = require('mongoose'); | ||
// require('mongoose-bigdecimal'); | ||
// var Schema = mongoose.Schema; | ||
// var BigDecimal = require('big.js'); | ||
|
||
// //define your schema | ||
// var ProductSchema = new Schema({ | ||
// price: { | ||
// type: Schema.Types.BigDecimal, | ||
// required: true, | ||
// index:true | ||
// }, | ||
// discounts:[{ | ||
// type: Schema.Types.BigDecimal | ||
// }] | ||
// }); | ||
// Product = mongoose.model('Product', ProductSchema); | ||
|
||
// //use it | ||
// var book = new Product(); | ||
// book.price = new BigDecimal(12); | ||
// book.save(done); | ||
// var data=[ | ||
// [ | ||
// { data: 'contract_package_hash' }, | ||
// { | ||
// data: '0024dc4c2ea77a01a0da90893c3283cfa602d78acf198aaa67e61e9bc9b44c93' | ||
// } | ||
// ], | ||
// [ { data: 'event_type' }, { data: 'transfer' } ], | ||
// [ | ||
// { data: 'from' }, | ||
// { | ||
// data: 'Key::Account(0000000000000000000000000000000000000000000000000000000000000000)' | ||
// } | ||
// ], | ||
// [ | ||
// { data: 'to' }, | ||
// { | ||
// data: 'Key::Account(e56a24ed039010d56c2f47aad13fb740b94f3253889500129421054ebb38d917)' | ||
// } | ||
// ], | ||
// [ { data: 'value' }, { data: '50' } ] | ||
// ]; | ||
|
||
// console.log("data: ",data[0][1].data); | ||
|
||
const { request } = require('graphql-request'); | ||
|
||
// request('http://localhost:3000/graphql', | ||
// `mutation handleTransfer( $pairAddress: String!, $from: String!, $to: String!, $value: Int!, $deployHash: String!, $timeStamp: Int!, $blockHash: String!){ | ||
// handleTransfer( pairAddress: $pairAddress, from: $from, to: $to, value: $value, deployHash: $deployHash, timeStamp: $timeStamp, blockHash: $blockHash) { | ||
// id | ||
// } | ||
|
||
// }`, | ||
// {pairAddress:'11f6e1b2d9566ab6d796f026b1d4bd36b71664c4ee8805fbc9cdca406607cd59', from: '0000000000000000000000000000000000000000000000000000000000000000', to: '0000000000000000000000000000000000000000000000000000000000000111', value: 5, pairAddress:'11f6e1b2d9566ab6d796f026b1d4bd36b71664c4ee8805fbc9cdca406607cd59', deployHash:'0000000000000000000000000000000000000000000000000000000000000000', timeStamp:1000, blockHash:'0000000000000000000000000000000000000000000000000000000000000000'}) | ||
// .then(data => console.log(data)) | ||
// .catch(error => console.error(error)); | ||
|
||
// request('http://localhost:3000/graphql', | ||
// `mutation handleNewPair( $token0: String!, $token1: String!, $pair: String!, $all_pairs_length: Int!, $timeStamp: Int!, $blockHash: String!){ | ||
// handleNewPair( token0: $token0, token1: $token1, pair: $pair, all_pairs_length: $all_pairs_length, timeStamp: $timeStamp, blockHash: $blockHash) { | ||
// id | ||
// } | ||
|
||
// }`, | ||
// {token0:'51254d70d183f4b1e59ee5d5b0c76d3c3a81d0366278beecc05b546d49a9835c', token1: '96b0431770a34f5b651a43c830f3c8537e7c44f2cb8191d7efbcca2379785cda', pair: '11f6e1b2d9566ab6d796f026b1d4bd36b71664c4ee8805fbc9cdca406607cd59', all_pairs_length: 5, timeStamp:1000, blockHash:'0000000000000000000000000000000000000000000000000000000000000000'}) | ||
// .then(data => console.log(data)) | ||
// .catch(error => console.error(error)); | ||
|
||
|
||
// var data="Key::hash(45d8a07febaf15b0b0c5ace02533c9d278fd2b6e31b84e7a7abd0c7478e57ea2)"; | ||
// var from=data.split('('); | ||
// var from1=from[1].split(')'); | ||
// console.log("from: ", from1[0]); | ||
// var data1="1"; | ||
|
||
// console.log("from: ", parseInt(data1)); | ||
|
||
// var int=1635977242919; | ||
// console.log("int: ",int.toString()); | ||
|
||
|
||
request('http://localhost:3000/graphql', | ||
`mutation handleSync( $reserve0: Int!, $reserve1: Int!, $pairAddress: String!){ | ||
handleSync( reserve0: $reserve0, reserve1: $reserve1, pairAddress: $pairAddress) { | ||
result | ||
} | ||
}`, | ||
{reserve0:0, reserve1: 0, pairAddress: "c22c075df6da91e5c803ebc8914b12a215261c9d0cf28f637a9ce83b96f9842b"}) | ||
.then(data => console.log(data)) | ||
.catch(error => console.error(error)); | ||