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

Endpoints for use in main and archive api #3

Merged
merged 2 commits into from
May 21, 2024
Merged
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
12 changes: 0 additions & 12 deletions src/config/chains.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { Chain as ViemChain, MulticallBatchOptions } from 'viem';
import { arbitrum, base, optimism, type Prettify } from 'viem/chains';
import { keyBy } from 'lodash';
import { keys } from '../utils/object';

export type Chain<T extends string = string> = {
id: T;
name: string;
viem: ViemChain;
batch?: boolean | MulticallBatchOptions | undefined;
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
rpc: string;
};

function toChainMap<T extends ReadonlyArray<Chain>>(arr: T) {
Expand All @@ -20,20 +14,14 @@ export const chains = toChainMap([
{
id: 'arbitrum',
name: 'Arbitrum',
viem: arbitrum,
rpc: 'http://localhost:8547',
},
{
id: 'base',
name: 'Base',
viem: base,
rpc: 'http://localhost:8547',
},
{
id: 'optimism',
name: 'Optimism',
viem: optimism,
rpc: 'http://localhost:8547',
},
] as const satisfies ReadonlyArray<Chain>);

Expand Down
22 changes: 22 additions & 0 deletions src/queries/VaultHistoricPrices.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
query VaultHistoricPrices(
$vault_address: ID!
$since: BigInt!
$period: BigInt!
$first: Int = 1000
$skip: Int = 0
) {
beefyCLVault(id: $vault_address) {
snapshots(
first: $first
skip: $skip
orderBy: roundedTimestamp
orderDirection: asc
where: { roundedTimestamp_gte: $since, period: $period }
) {
roundedTimestamp
priceRangeMin1
priceOfToken0InToken1
priceRangeMax1
}
}
}
20 changes: 20 additions & 0 deletions src/queries/VaultHistoricPricesRange.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
query VaultHistoricPricesRange($vault_address: ID!, $period: BigInt!) {
beefyCLVault(id: $vault_address) {
minSnapshot: snapshots(
first: 1
orderBy: roundedTimestamp
orderDirection: asc
where: { period: $period }
) {
roundedTimestamp
}
maxSnapshot: snapshots(
first: 1
orderBy: roundedTimestamp
orderDirection: desc
where: { period: $period }
) {
roundedTimestamp
}
}
}
7 changes: 7 additions & 0 deletions src/queries/VaultPrice.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query VaultPrice($vault_address: ID!) {
beefyCLVault(id: $vault_address) {
priceOfToken0InToken1
priceRangeMin1
priceRangeMax1
}
}
66 changes: 0 additions & 66 deletions src/queries/VaultPrices.graphql

This file was deleted.

21 changes: 12 additions & 9 deletions src/queries/VaultApy.graphql → src/queries/Vaults.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ fragment Token on Token {
decimals
}

query VaultApy($first: Int = 100, $skip: Int = 0) {
beefyCLVaults(first: 1000, skip: 0, where: { lifecycle_not: INITIALIZING }) {
vault_address: id
sharesToken {
...Token
}
query Vaults($since: BigInt!, $first: Int = 1000, $skip: Int = 0) {
beefyCLVaults(first: $first, skip: $skip, where: { lifecycle_not: INITIALIZING }) {
vaultAddress: id
priceOfToken0InToken1
priceRangeMin1
priceRangeMax1
underlyingToken0 {
...Token
}
underlyingToken1 {
...Token
}
totalSupply
collectedFees(first: $first, skip: $skip, orderBy: timestamp, orderDirection: desc) {
collectedFees(
first: 1000
where: { timestamp_gte: $since }
orderBy: timestamp
orderDirection: desc
) {
timestamp
underlyingMainAmount0
underlyingMainAmount1
Expand All @@ -27,7 +31,6 @@ query VaultApy($first: Int = 100, $skip: Int = 0) {
collectedAmount1
token0ToNativePrice
token1ToNativePrice
nativeToUSDPrice
}
}
}
113 changes: 0 additions & 113 deletions src/routes/v1/chain.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/routes/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';
import investor from './investor';
import vault from './vault';
import chain from './chain';
import vaults from './vaults';

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