Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# backend

## 2.1.3

### Patch Changes

- 95170c3: update euler ib handler

## 2.1.2

### Patch Changes
Expand Down
6 changes: 2 additions & 4 deletions apps/worker/job-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import { LoopsService } from '../../modules/loops/service';
import { ContentController } from '../../modules/content/content-controller';
import { StakedSonicController } from '../../modules/sts/sts-controller';
import { UserBalancesController } from '../../modules/user/user-balances-controller';
import { ca } from '@bgd-labs/aave-address-book/dist/ChainlinkEthereum-CbJoeh6P';
import { error } from 'console';

const runningJobs: Set<string> = new Set();

Expand Down Expand Up @@ -66,14 +64,14 @@ async function runIfNotAlreadyRunning(
const durationSuccess = moment.duration(moment().diff(startJobTime)).asSeconds();
if (process.env.AWS_ALERTS === 'true') {
await cronsMetricPublisher.publish(`${jobId}-done`);
await cronsDurationMetricPublisher.publish(`${jobId}-done`, durationSuccess);
// await cronsDurationMetricPublisher.publish(`${jobId}-done`, durationSuccess);
}
console.log(`Successful job ${jobId}-done`, durationSuccess);
} catch (error: any) {
const durationError = moment.duration(moment().diff(startJobTime)).asSeconds();
if (process.env.AWS_ALERTS === 'true') {
await cronsMetricPublisher.publish(`${jobId}-error`);
await cronsDurationMetricPublisher.publish(`${jobId}-error`, durationError);
// await cronsDurationMetricPublisher.publish(`${jobId}-error`, durationError);
}
const duration = moment.duration(moment().diff(startJobTime)).asSeconds();
console.log(`Error job ${jobId}-error`, duration, error.message || error);
Expand Down
2 changes: 1 addition & 1 deletion config/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default <NetworkData>{
markets: [AaveV3Avalanche],
},
euler: {
url: 'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/43114/vaults.json',
url: 'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/43114/products.json',
lens: '0xc820c24905c210aefe21dae40723ec28d62c1544',
chain: 'AVALANCHE',
},
Expand Down
2 changes: 1 addition & 1 deletion config/plasma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default <NetworkData>{
},
euler: {
chain: 'PLASMA',
url: 'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/9745/vaults.json',
url: 'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/9745/products.json',
lens: '0xc55f6e262FE21Da068ece5D3fa015D8451bAf625',
},
},
Expand Down
12 changes: 1 addition & 11 deletions config/sonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,12 @@ export default <NetworkData>{
token: '0xe5da20f15420ad15de0fa650600afc998bbe3955',
},
euler: {
url: 'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/146/vaults.json',
url: 'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/146/products.json',
lens: '0xc3a705ea6e339a53a7d301d3c5d7e6f499a9366a',
chain: 'SONIC',
},
contract: {
calls: [
'0x87178fe8698c7eda8aa207083c3d66aea569ab98', //solvbtc market 13
'0x52fc9e0a68b6a4c9b57b9d1d99fb71449a99dcd8', // solvbtc.bbn market 13
'0x016c306e103fbf48ec24810d078c65ad13c5f11b', // wS market 25
'0x219656f33c58488d09d518badf50aa8cdcaca2aa', // wETH market 26
'0x6c49b18333a1135e9a376560c07e6d1fd0350eaf', // Ws market 28
'0x0a94e18bdbccd048198806d7ff28a1b1d2590724', // scbtc market 32
'0x42ce2234fd5a26bf161477a996961c4d01f466a3', // usdc 33
'0xe6605932e4a686534d19005bb9db0fba1f101272', // scusdc 46
'0x08c320a84a59c6f533e0dca655cf497594bca1f9', // weth 35
'0x24c74b30d1a4261608e84bf5a618693032681dac', // sceth 47
'0x11ba70c0ebab7946ac84f0e6d79162b0cbb2693f', // usdc 36
].map((market) => ({
chain: 'SONIC',
Expand Down
2 changes: 1 addition & 1 deletion modules/network/worker-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const activeChainWorkerJobsGlobal: WorkerJob[] = [
},
{
name: 'post-subgraph-lag-metrics',
interval: every(2, 'minutes'),
interval: every(15, 'minutes'),
},
{
name: 'sync-token-tvl',
Expand Down
42 changes: 31 additions & 11 deletions modules/token-yields/handlers/sources/euler-yield-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { Multicaller3Call } from '../../../web3/types';
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
import { formatUnits } from 'viem';

type VaultsResponse = {
[address: string]: {
type ProductsResponse = {
[productKey: string]: {
name: string;
vaults: string[];
deprecatedVaults?: string[];
};
};

Expand Down Expand Up @@ -39,23 +41,36 @@ type ComputeAPYs = AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof euler
export const eulerYieldHandler: TokenYieldHandler = async (config: { chain: Chain; url: string; lens: string }) => {
try {
// find vaults that we have in our pools
const vaults = await fetch(config.url).then((response) => response.json() as Promise<VaultsResponse>);
const products = await fetch(config.url).then((response) => response.json() as Promise<ProductsResponse>);

const vaultsAddresses = Object.keys(vaults).map((address) => address.toLowerCase());
const activeAddresses = new Set<string>();
const deprecatedAddresses = new Set<string>();
for (const product of Object.values(products)) {
for (const address of product.vaults ?? []) {
activeAddresses.add(address.toLowerCase());
}
for (const address of product.deprecatedVaults ?? []) {
deprecatedAddresses.add(address.toLowerCase());
}
}
const allAddresses = [...activeAddresses, ...deprecatedAddresses];

const poolTokens = await prisma.prismaPoolToken
.findMany({
where: {
chain: config.chain,
address: { in: vaultsAddresses },
address: { in: allAddresses },
},
select: { address: true },
})
.then((pts) => [...new Set(pts.map((pt) => pt.address))]);

// query the required data for each vault on chain
const activePoolTokens = poolTokens.filter((a) => activeAddresses.has(a));
const deprecatedPoolTokens = poolTokens.filter((a) => deprecatedAddresses.has(a));

// query the required data for each active vault on chain
const calls: Multicaller3Call[] = [];
for (const vault of poolTokens) {
for (const vault of activePoolTokens) {
calls.push({
path: `${vault}.interestRate`,
address: vault as `0x${string}`,
Expand Down Expand Up @@ -86,9 +101,9 @@ export const eulerYieldHandler: TokenYieldHandler = async (config: { chain: Chai

const vaultsResponse = await multicallViem(client, calls);

// compute APY on chain for each vault
// compute APY on chain for each active vault
const apyCalls: Multicaller3Call[] = [];
for (const vault of poolTokens) {
for (const vault of activePoolTokens) {
apyCalls.push({
path: `${vault}.computeAPYs`,
address: config.lens as `0x${string}`,
Expand All @@ -108,8 +123,13 @@ export const eulerYieldHandler: TokenYieldHandler = async (config: { chain: Chai

const aprs: TokenApr[] = [];

// get the APY for each vault and return it
for (const vault of poolTokens) {
// deprecated vaults get APR 0
for (const vault of deprecatedPoolTokens) {
aprs.push({ address: vault, apr: 0 });
}

// get the APY for each active vault and return it
for (const vault of activePoolTokens) {
const apy = apyResponse[vault].computeAPYs;
if (apy) {
aprs.push({ address: vault, apr: parseFloat(apy) });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "2.1.2",
"version": "2.1.3",
"description": "Backend service for Beethoven X and Balancer",
"repository": "https://github.com/balancer/backend",
"author": "Beethoven X",
Expand Down
Loading