diff --git a/.changeset/hungry-elephants-beg.md b/.changeset/hungry-elephants-beg.md new file mode 100644 index 00000000..bd631f3f --- /dev/null +++ b/.changeset/hungry-elephants-beg.md @@ -0,0 +1,5 @@ +--- +'backend': minor +--- + +Treehouse tETH APR handler diff --git a/config/mainnet.ts b/config/mainnet.ts index 11c11074..1ff3076e 100644 --- a/config/mainnet.ts +++ b/config/mainnet.ts @@ -278,6 +278,7 @@ export default { token: '0x09db87a538bd693e9d08544577d5ccfaa6373a48', }, sveth: true, + teth: true, defaultHandlers: { uniETH: { tokenAddress: '0xf1376bcef0f78459c0ed0ba5ddce976f1ddf51f4', diff --git a/modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts b/modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts index 48a6c599..fe66c126 100644 --- a/modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts +++ b/modules/pool/lib/apr-data-sources/yb-apr-handlers/index.ts @@ -27,6 +27,7 @@ const sourceToHandler = { sveth: sources.svEthAprHandler, dforce: sources.DForce, defillama: sources.Defillama, + teth: sources.TreehouseAprHandler, }; export class YbAprHandlers { diff --git a/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/index.ts b/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/index.ts index 259c4e27..1c99a79b 100644 --- a/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/index.ts +++ b/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/index.ts @@ -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'; diff --git a/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/teth.ts b/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/teth.ts new file mode 100644 index 00000000..9d69451d --- /dev/null +++ b/modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/teth.ts @@ -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 {}; + } + } +}