forked from DefiLlama/defillama-server
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d6aedf4
commit f0f2eb8
Showing
3 changed files
with
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import getTokenPrices from "./level"; | ||
|
||
export function level(timestamp: number = 0) { | ||
console.log("starting level finance"); | ||
return getTokenPrices(timestamp) | ||
} |
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,27 @@ | ||
import { Write, } from "../../utils/dbInterfaces"; | ||
import { | ||
addToDBWritesList, | ||
} from "../../utils/database"; | ||
import { getApi } from "../../utils/sdk"; | ||
|
||
const oracles = [ | ||
'0xce676CbAb0B76F95A262Bd460a98B0157110D07a', | ||
] | ||
|
||
const chain = 'arbitrum' | ||
|
||
export default async function getTokenPrices(timestamp: number) { | ||
const writes: Write[] = []; | ||
const api = await getApi(chain, timestamp, true) | ||
const tranches = await api.multiCall({ abi: 'address:lpToken', calls: oracles }) | ||
const [ decimals, symbols, oraclePrice ] = await Promise.all([ | ||
api.multiCall({ abi: 'uint8:decimals', calls: tranches }), | ||
api.multiCall({ abi: 'string:symbol', calls: tranches }), | ||
api.multiCall({ abi: 'address:price', calls: oracles }), | ||
]) | ||
tranches.forEach((token: any, i: number) => { | ||
addToDBWritesList(writes, chain, token, oraclePrice[i] / (10 ** decimals[i]), decimals[i], symbols[i], timestamp, 'level-finance', 0.99) | ||
}) | ||
|
||
return writes | ||
} |