-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
modules/pool/lib/apr-data-sources/yb-apr-handlers/sources/defillama-apr-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { AprHandler } from '..'; | ||
import { YbAprConfig } from '../../../../../network/apr-config-types'; | ||
|
||
const query = ` | ||
{ | ||
osTokens { | ||
apy | ||
} | ||
} | ||
`; | ||
|
||
const requestQuery = { | ||
query, | ||
}; | ||
|
||
interface Response { | ||
data: { | ||
timestamp: string; | ||
apyBase: number; | ||
}[]; | ||
} | ||
|
||
const baseURL = 'https://yields.llama.fi/chart/'; | ||
|
||
export class Defillama implements AprHandler { | ||
constructor(private config: YbAprConfig['defillama']) {} | ||
|
||
async getAprs() { | ||
const aprs: { token: string; apr: number }[] = []; | ||
|
||
for (const token of this.config!) { | ||
{ | ||
const response = await fetch(baseURL + token.defillamaPoolId); | ||
|
||
const data = (await response.json()) as Response; | ||
|
||
const apr = Number(data.data[data.data.length - 1].apyBase) / 100; | ||
aprs.push({ token: token.tokenAddress, apr }); | ||
} | ||
} | ||
return Object.fromEntries(aprs.map(({ token, apr }) => [token, { apr, isIbYield: true }])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters