Skip to content

Commit

Permalink
Add share tokens balance endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Sep 30, 2024
1 parent e2208e2 commit 53ffc54
Show file tree
Hide file tree
Showing 35 changed files with 2,435 additions and 16 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# beefy-balances-api


https://balances-api.beefy.finance/api/v1/status
http://localhost:4000/api/v1/status


https://balances-api.beefy.finance/api/v1/holders/counts/all
http://localhost:4000/api/v1/holders/counts/all

https://balances-api.beefy.finance/api/v1/vault/base/baseswap-cow-weth-cbbtc/20449610/share-tokens-balances
http://localhost:4000/api/v1/vault/base/baseswap-cow-weth-cbbtc/20449610/share-tokens-balances

172 changes: 164 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,33 @@
"@fastify/etag": "^5.1.0",
"@fastify/helmet": "^11.1.1",
"@fastify/rate-limit": "^9.1.0",
"@fastify/swagger-ui": "^3.0.0",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^3.0.0",
"@fastify/under-pressure": "^8.3.0",
"@sinclair/typebox": "^0.32.33",
"@types/lodash-es": "^4.17.12",
"async-lock": "^1.4.1",
"blockchain-addressbook": "^0.47.18",
"decimal.js": "^10.4.3",
"dotenv": "^16.4.5",
"fastify": "^4.26.2",
"graphql": "^16.6.0",
"graphql-request": "^6.1.0",
"graphql-tag": "^2.12.6",
"graphql": "^16.6.0",
"lodash": "^4.17.21",
"node-cache": "^5.1.2",
"pino": "^8.19.0"
"pino": "^8.19.0",
"viem": "^2.21.16"
},
"lint-staged": {
"src/**/*.{ts,graphql,json}": "biome check --write"
},
"devDependencies": {
"@biomejs/biome": "1.8.2",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/typescript": "^4.0.7",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "^4.2.1",
"@graphql-codegen/typescript": "^4.0.7",
"@jest/globals": "^29.7.0",
"@types/async-lock": "^1.4.2",
"@types/jest": "^29.5.12",
Expand All @@ -67,8 +69,8 @@
"npm-check-updates": "^16.14.18",
"pino-pretty": "^11.0.0",
"ts-jest": "^29.1.2",
"ts-node-dev": "^2.0.0",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.5"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
Expand Down
3 changes: 2 additions & 1 deletion src/config/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StringEnum } from '../utils/typebox';

export enum ChainId {
arbitrum = 'arbitrum',
avalanche = 'avalanche',
avax = 'avax',
base = 'base',
bsc = 'bsc',
ethereum = 'ethereum',
Expand All @@ -16,6 +16,7 @@ export enum ChainId {
moonbeam = 'moonbeam',
optimism = 'optimism',
polygon = 'polygon',
rootstock = 'rootstock',
sei = 'sei',
zksync = 'zksync',
}
Expand Down
35 changes: 35 additions & 0 deletions src/queries/VaultSharesBalances.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
query VaultSharesBalances(
$token_in_1: [Bytes!]!
$token_in_2: [String!]!
$account_not_in: [String!]!
$block: Int
$first: Int = 1000
$skip: Int = 0
) {
tokens(first: $first, skip: $skip, where: { id_in: $token_in_1 }) {
id
name
decimals
symbol
}
tokenBalances(
block: { number: $block }
orderBy: id
orderDirection: desc
first: $first
skip: $skip
where: {
amount_gt: 0
token_in: $token_in_2
account_not_in: $account_not_in
}
) {
token {
id
}
account {
id
}
amount
}
}
2 changes: 2 additions & 0 deletions src/routes/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
import holders from './holders';
import status from './status';
import vault from './vault';

export default async function (
instance: FastifyInstance,
Expand All @@ -9,5 +10,6 @@ export default async function (
) {
instance.register(status, { prefix: '/status' });
instance.register(holders, { prefix: '/holders' });
instance.register(vault, { prefix: '/vault' });
done();
}
Loading

0 comments on commit 53ffc54

Please sign in to comment.