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

Feature/graph ql implementation #131

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,5 @@ module.exports = {
'promise/prefer-await-to-then': 'warn',
'@typescript-eslint/no-non-null-assertion': 'off',
},
ignorePatterns: ['src/types/contracts/**/*', 'src/types/graphql/**/*'],
}
22 changes: 22 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { CodegenConfig } from '@graphql-codegen/cli'
import * as path from 'path'

const config: CodegenConfig = {
overwrite: true,
schema: ['https://api.studio.thegraph.com/query/73688/kkk/version/latest'],
documents: [
path.resolve(__dirname, './graphql/**/*.graphql'),
path.resolve(__dirname, './graphql/**/**/*.graphql'),
],
generates: {
['src/types/graphql/index.ts']: {
plugins: [
'typescript',
'typescript-operations',
'typescript-document-nodes',
],
},
},
}

export default config
10 changes: 10 additions & 0 deletions graphql/core/pool/get-total-staked-per-day.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query GetTotalStakedPerDay($date: String!, $timestamp: BigInt!) {
poolInteractions(
first: 1
orderDirection: desc
where: { timestamp_lte: $timestamp, pool: $date }
orderBy: timestamp
) {
totalStaked
}
}
10 changes: 10 additions & 0 deletions graphql/core/ref-data/get-referrers-total-claimed.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query GetReferrersTotalClaimed($poolId: BigInt!, $user: Bytes!) {
referrers(
where: {
user: $user,
poolId: $poolId
}
) {
totalClaimed
}
}
11 changes: 11 additions & 0 deletions graphql/core/user/get-deposited-amount-user-referrers.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
query GetDepositedAmountUserReferrers($poolId: BigInt!, $referrer: Bytes!) {
userReferrers(
where: {
poolId: $poolId,
referrer: $referrer,
amount_gt: "0"
}
) {
amount
}
}
23 changes: 23 additions & 0 deletions graphql/core/user/get-specific-user-referrers.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
query GetSpecificUserReferrers(
$poolId: BigInt!
$referrer: Bytes!
$first: Int!
$skip: Int!
$orderDirection: OrderDirection
) {
userReferrers(
where: {
poolId: $poolId,
referrer: $referrer,
amount_gt: "0"
},
first: $first,
skip: $skip,
orderDirection: $orderDirection
) {
amount
id
poolId
user
}
}
61 changes: 61 additions & 0 deletions graphql/core/user/get-user-yield-per-day.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
extend type Query {
toBytes(value: BigInt!): Bytes!
}

query GetUserYieldPerDay(
$poolId: BigInt!,
$poolIdBytes: Bytes!,
$user: Bytes!,
$fromTimestamp: BigInt!,
$toTimestamp: BigInt!
) {
initialUserInteractions: userInteractions (
orderBy: timestamp
orderDirection: desc
where: {
user: $user,
poolId: $poolId,
timestamp_lt: $fromTimestamp
}
first: 1
) {
timestamp
rate
deposited
claimedRewards
pendingRewards
}

userInteractions (
orderBy: timestamp
orderDirection: asc
where: {
user: $user,
poolId: $poolId,
timestamp_gt: $fromTimestamp,
timestamp_lt: $toTimestamp
}
) {
timestamp
rate
deposited
claimedRewards
pendingRewards
}

poolInteractions (
orderBy: timestamp
orderDirection: desc
where: {
rate_gt: 0,
timestamp_lt: $toTimestamp,
pool_: {
id: $poolIdBytes
}
}
first: 1
) {
timestamp
rate
}
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
"lint:scripts": "eslint \"{src,config}/**/*.{vue,js,ts}\" --cache --fix --max-warnings=0",
"preview": "vite preview",
"rsc": "node scripts/release-sanity-check.mjs",
"generate-ether-types": "typechain --target=ethers-v5 'src/abi/**/*.json' --out-dir src/types/contracts"
"generate-ether-types": "typechain --target=ethers-v5 'src/abi/**/*.json' --out-dir src/types/contracts",
"generate-graphql-types": "graphql-codegen --config codegen.ts"
},
"dependencies": {
"@apollo/client": "^3.9.10",
"@brutforce/vue3-paginate": "^0.1.3",
"@distributedlab/tools": "^1.0.0-rc.13",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@graphql-codegen/cli": "^5.0.3",
"@graphql-codegen/typescript": "^4.1.2",
"@graphql-codegen/typescript-document-nodes": "^4.0.12",
"@graphql-codegen/typescript-operations": "^4.4.0",
"@uniswap/sdk-core": "^5.8.0",
"@uniswap/smart-order-router": "^4.6.0",
"@uniswap/v2-core": "^1.0.1",
Expand Down
Loading