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

Treehouse tETH APR handler #1126

Merged
merged 1 commit into from
Oct 29, 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
5 changes: 5 additions & 0 deletions .changeset/hungry-elephants-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': minor
---

Treehouse tETH APR handler
1 change: 1 addition & 0 deletions config/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export default <NetworkData>{
token: '0x09db87a538bd693e9d08544577d5ccfaa6373a48',
},
sveth: true,
teth: true,
defaultHandlers: {
uniETH: {
tokenAddress: '0xf1376bcef0f78459c0ed0ba5ddce976f1ddf51f4',
Expand Down
1 change: 1 addition & 0 deletions modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const sourceToHandler = {
sveth: sources.svEthAprHandler,
dforce: sources.DForce,
defillama: sources.Defillama,
teth: sources.TreehouseAprHandler,
};

export class YbAprHandlers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * from './etherfi-apr-handler';
export * from './sv-eth';
export * from './dforce-apr-handler';
export * from './defillama-apr-handler';
export * from './teth';
38 changes: 38 additions & 0 deletions modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/teth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { AprHandler } from '../types';

const TETH = '0xd11c452fc99cf405034ee446803b6f6c1f6d5ed8';
const url = 'https://api.treehouse.finance/rate/mey';

// The apr config needs to be custom made as the resulting value
// is equal to Lido's wstETH APR plus the data from the below query.
export class TreehouseAprHandler implements AprHandler {
constructor() {}

async getAprs() {
try {
const response = await fetch(url);
const { key, message, data } = (await response.json()) as { key: string; message: string; data: string };
if (key !== 'SUCCESS') {
throw new Error('Treehouse API failed: ' + message);
}

// Get Lido wstETH APR
const lido = await fetch('https://eth-api.lido.fi/v1/protocol/steth/apr/sma');
const {
data: { smaApr },
} = (await lido.json()) as { data: { smaApr: number } };

const aprs = {
[TETH]: {
apr: (parseFloat(data) + smaApr) / 100,
isIbYield: true,
},
};

return aprs;
} catch (error) {
console.error(`Treehouse IB APR handler failed: `, error);
return {};
}
}
}
Loading