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

publish to prod #1262

Merged
merged 6 commits into from
Dec 11, 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# backend

## 1.26.3

### Patch Changes

- cdf0cb6: aave pricing
- d497a71: fix: handle checksum addresses in tags assignment
- 1a0f088: Morpho APRs and pricing
- 75cb205: handle all aave prices from aprs config

## 1.26.2

### Patch Changes
Expand Down
1 change: 1 addition & 0 deletions config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default <NetworkData>{
},
},
ybAprConfig: {
morpho: true,
defaultHandlers: {
cbETH: {
tokenAddress: '0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22',
Expand Down
1 change: 1 addition & 0 deletions config/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default <NetworkData>{
},
},
ybAprConfig: {
morpho: true,
aave: {
v2: {
subgraphUrl: `https://gateway-arbitrum.network.thegraph.com/api/${env.THEGRAPH_API_KEY_BALANCER}/subgraphs/id/8wR23o1zkS4gpLqLNU4kG3JHYVucqGyopL5utGxP2q1N`,
Expand Down
2 changes: 2 additions & 0 deletions modules/actions/pool/sync-incentivized-category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const syncIncentivizedCategory = async () => {

const ids = poolsWithReward.map(({ poolId }) => poolId);

if (!ids.length) return;

await prisma.$transaction([
// Remove incentivized category from pools
prisma.$executeRaw`UPDATE "PrismaPool"
Expand Down
7 changes: 4 additions & 3 deletions modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ export type { AprHandler, AprHandlerConstructor, TokenApr };
const sourceToHandler = {
aave: sources.AaveAprHandler,
beefy: sources.BeefyAprHandler,
bloom: sources.BloomAprHandler,
sftmx: sources.SftmxAprHandler,
// euler: sources.EulerAprHandler, // Removed, pools rekt
// gearbox: sources.GearboxAprHandler, // Removed, endpoint is down
// idle: sources.IdleAprHandler, // Removed, endpoint is down
maker: sources.MakerAprHandler,
ovix: sources.OvixAprHandler,
// reaper: sources.ReaperCryptAprHandler, // Removed, pools rekt
tetu: sources.TetuAprHandler,
tranchess: sources.TranchessAprHandler,
Expand All @@ -27,6 +24,10 @@ const sourceToHandler = {
dforce: sources.DForce,
defillama: sources.Defillama,
teth: sources.TreehouseAprHandler,
morpho: sources.MorphoAprHandler,
ovix: sources.OvixAprHandler,
bloom: sources.BloomAprHandler,
sftmx: sources.SftmxAprHandler,
};

export class YbAprHandlers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './etherfi-apr-handler';
export * from './dforce-apr-handler';
export * from './defillama-apr-handler';
export * from './teth';
export * from './morpho-apr-handler';
// These need a refactor, because they depend on the network context
export * from './sftmx-apr-handler';
export * from './ovix-apr-handler';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { gql, request } from 'graphql-request';
import { AprHandler } from '../types';
import { Chain } from '@prisma/client';

const url = 'https://blue-api.morpho.org/graphql';
const query = gql`
{
vaults(first: 1000, where: { netApy_gte: 0.00001 }) {
items {
address
chain {
network
}
state {
netApy
}
}
}
}
`;

type Vault = {
address: string;
chain: {
network: 'ethereum' | 'base';
};
state: {
netApy: number;
};
};

type BlueApiResponse = {
vaults: {
items: Vault[];
};
};

export class MorphoAprHandler implements AprHandler {
group = 'MORPHO';

constructor() {}

async getAprs(chain: Chain) {
if (chain !== Chain.MAINNET && chain !== Chain.BASE) {
return {};
}

const morphoChain = chain === Chain.MAINNET ? 'ethereum' : 'base';

try {
const r = await request<BlueApiResponse>(url, query);
const items = r?.vaults?.items;
const aprs = Object.fromEntries(
items
.filter((vault) => vault.chain.network === morphoChain)
.map((vault) => [
vault.address.toLowerCase(),
{
apr: vault.state.netApy,
group: this.group,
isIbYield: true,
},
]),
);

return aprs;
} catch (e) {
console.error(`Failed to fetch Morpho APRs`, e);
return {};
}
}
}
2 changes: 1 addition & 1 deletion modules/sources/github/pool-erc4626-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getErc4626Tags = async (

for (const erc4626Metadata of erc4626MetadataList) {
for (const chainId in erc4626Metadata.addresses) {
const addresses = erc4626Metadata.addresses[chainId];
const addresses = erc4626Metadata.addresses[chainId].map((address) => address.toLowerCase());
const poolsWithThisErc4626Token = await prisma.prismaPool.findMany({
where: {
chain: chainIdToChain[chainId],
Expand Down
Loading
Loading