Skip to content

Commit

Permalink
Merge pull request #47 from balancer/v3-canary
Browse files Browse the repository at this point in the history
V3 canary
  • Loading branch information
franzns authored Jan 23, 2024
2 parents fcd9c85 + 38646bc commit 632adf5
Show file tree
Hide file tree
Showing 45 changed files with 1,106 additions and 644 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ userInitStakedBalances
### Setup database & Prisma from backup

Retrieve the current pg_dump file under `https://api-db-dump.s3.eu-central-1.amazonaws.com/canary/api-dump.YYYYMMDD`.
Database dumps are kept for the previous 7 days, replace YYYYMMDD in the URL above (ie: 20230317) to download a db dump.
Database dumps are kept for the previous 7 days, replace YYYYMMDD in the URL above (ie: 20230317) to download a db dump.

Run `docker-compose up -d` to start the database via docker compose.

Retrieve the docker container ID through `docker ps`.

Run `docker exec -i <container-ID> /bin/bash -c "PGPASSWORD=let-me-in psql --username backend database" < /path/on/your/machine/dump`
with the container-ID from the step before.
Run `docker exec -i $(docker ps -qf "name=balancer-backend") /bin/bash -c "PGPASSWORD=let-me-in psql --username backend database" < /path/on/your/machine/dump`

The output at the very end saying `ERROR: role "rdsadmin" does not exist` is normal and can be ignored.

Expand Down Expand Up @@ -90,4 +87,4 @@ To contribute, branch from `v2-canary` (which is our development branch) and ope

### Database Updates

If you make any changes to the database schema be sure to run `yarn prisma migrate dev --name <change_name>` which will create a new file in `prisma/migrations` that contains all the database changes you've made as an SQL update script.
If you make any changes to the database schema be sure to run `yarn prisma migrate dev --name <change_name>` which will create a new file in `prisma/migrations` that contains all the database changes you've made as an SQL update script.
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ version: '3'

services:
postgres:
image: postgres
container_name: balancer-backend
image: postgres:14-alpine
ports:
- '5431:5432'
environment:
POSTGRES_USER: backend
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: database
networks:
- balancer

networks:
balancer:
name: balancer
10 changes: 8 additions & 2 deletions modules/content/github-content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,24 @@ export class GithubContentService implements ContentService {
});
}

const linearPool = pools.find(
const wrappedLinearPoolToken = pools.find(
(pool) => pool.linearData && pool.tokens[pool.linearData.wrappedIndex]?.address === token.address,
);

if (linearPool && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
if (wrappedLinearPoolToken && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
types.push({
id: `${token.address}-linear-wrapped`,
chain: networkContext.chain,
type: 'LINEAR_WRAPPED_TOKEN',
tokenAddress: token.address,
});
}

if (!wrappedLinearPoolToken && tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
prisma.prismaTokenType.delete({
where: { id_chain: { id: `${token.address}-linear-wrapped`, chain: networkContext.chain } },
});
}
}

await prisma.prismaTokenType.createMany({ skipDuplicates: true, data: types });
Expand Down
11 changes: 9 additions & 2 deletions modules/content/sanity-content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import SanityClient from '@sanity/client';
import { env } from '../../app/env';
import { chainToIdMap } from '../network/network-config';
import { wrap } from 'module';

interface SanityToken {
name: string;
Expand Down Expand Up @@ -184,18 +185,24 @@ export class SanityContentService implements ContentService {
});
}

const linearPool = pools.find(
const wrappedLinearPoolToken = pools.find(
(pool) => pool.linearData && pool.tokens[pool.linearData.wrappedIndex].address === token.address,
);

if (linearPool && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
if (wrappedLinearPoolToken && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
types.push({
id: `${token.address}-linear-wrapped`,
chain: this.chain,
type: 'LINEAR_WRAPPED_TOKEN',
tokenAddress: token.address,
});
}

if (!wrappedLinearPoolToken && tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
prisma.prismaTokenType.delete({
where: { id_chain: { id: `${token.address}-linear-wrapped`, chain: this.chain } },
});
}
}

await prisma.prismaTokenType.createMany({ skipDuplicates: true, data: types });
Expand Down
32 changes: 18 additions & 14 deletions modules/network/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,73 +181,77 @@ export const gnosisNetworkConfig: NetworkConfig = {
},
{
name: 'update-liquidity-for-active-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(8, 'minutes') : every(4, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'),
},
{
name: 'update-pool-apr',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(7, 'minutes') : every(5, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'),
},
{
name: 'load-on-chain-data-for-pools-with-active-updates',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(9, 'minutes') : every(5, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(4, 'minutes') : every(1, 'minutes'),
},
{
name: 'sync-new-pools-from-subgraph',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(12, 'minutes') : every(8, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'),
},
{
name: 'sync-tokens-from-pool-tokens',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(7, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'update-liquidity-24h-ago-for-all-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(15, 'minutes') : every(8, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'cache-average-block-time',
interval: every(1, 'hours'),
},
{
name: 'sync-staking-for-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(15, 'minutes') : every(10, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'sync-latest-snapshots-for-all-pools',
interval: every(90, 'minutes'),
},
{
name: 'update-lifetime-values-for-all-pools',
interval: every(45, 'minutes'),
interval: every(50, 'minutes'),
},
{
name: 'sync-changed-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(2, 'minutes') : every(1, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(2, 'minutes') : every(30, 'seconds'),
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
},
{
name: 'user-sync-wallet-balances-for-all-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(29, 'minutes') : every(9, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(20, 'seconds'),
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
},
{
name: 'user-sync-staked-balances',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(31, 'minutes') : every(11, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(20, 'seconds'),
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
},
{
name: 'sync-coingecko-coinids',
interval: every(2, 'hours'),
},
{
name: 'update-fee-volume-yield-all-pools',
interval: every(75, 'minutes'),
interval: every(1, 'hours'),
},
{
name: 'sync-vebal-balances',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(20, 'minutes') : every(14, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(9, 'minutes') : every(3, 'minutes'),
},
{
name: 'sync-vebal-totalSupply',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(20, 'minutes') : every(16, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'feed-data-to-datastudio',
Expand Down
12 changes: 6 additions & 6 deletions modules/network/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,11 @@ export const mainnetNetworkConfig: NetworkConfig = {
name: 'sync-global-coingecko-prices',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(2, 'minutes'),
},
// {
// name: 'global-purge-old-tokenprices',
// interval: every(1, 'days'),
// alarmEvaluationPeriod: 1,
// alarmDatapointsToAlarm: 1,
// },
{
name: 'global-purge-old-tokenprices',
interval: every(1, 'days'),
alarmEvaluationPeriod: 1,
alarmDatapointsToAlarm: 1,
},
],
};
32 changes: 18 additions & 14 deletions modules/network/zkevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,73 +211,77 @@ export const zkevmNetworkConfig: NetworkConfig = {
},
{
name: 'update-liquidity-for-active-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(8, 'minutes') : every(4, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'),
},
{
name: 'update-pool-apr',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(7, 'minutes') : every(5, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'),
},
{
name: 'load-on-chain-data-for-pools-with-active-updates',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(9, 'minutes') : every(5, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(4, 'minutes') : every(1, 'minutes'),
},
{
name: 'sync-new-pools-from-subgraph',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(12, 'minutes') : every(8, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'),
},
{
name: 'sync-tokens-from-pool-tokens',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(7, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'update-liquidity-24h-ago-for-all-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(15, 'minutes') : every(8, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'cache-average-block-time',
interval: every(1, 'hours'),
},
{
name: 'sync-staking-for-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(15, 'minutes') : every(10, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'sync-latest-snapshots-for-all-pools',
interval: every(90, 'minutes'),
},
{
name: 'update-lifetime-values-for-all-pools',
interval: every(45, 'minutes'),
interval: every(50, 'minutes'),
},
{
name: 'sync-changed-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(2, 'minutes') : every(1, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(2, 'minutes') : every(30, 'seconds'),
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
},
{
name: 'user-sync-wallet-balances-for-all-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(29, 'minutes') : every(9, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(20, 'seconds'),
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
},
{
name: 'user-sync-staked-balances',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(31, 'minutes') : every(11, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(20, 'seconds'),
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1,
},
{
name: 'sync-coingecko-coinids',
interval: every(2, 'hours'),
},
{
name: 'update-fee-volume-yield-all-pools',
interval: every(75, 'minutes'),
interval: every(1, 'hours'),
},
{
name: 'sync-vebal-balances',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(20, 'minutes') : every(14, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(9, 'minutes') : every(3, 'minutes'),
},
{
name: 'sync-vebal-totalSupply',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(20, 'minutes') : every(16, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'),
},
{
name: 'feed-data-to-datastudio',
Expand Down
Loading

0 comments on commit 632adf5

Please sign in to comment.