-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use prices api for lending price oracle ohlc
- Loading branch information
Alunara
committed
Jan 29, 2025
1 parent
578e1fa
commit 225393c
Showing
5 changed files
with
164 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
import type * as Responses from './responses' | ||
import type * as Models from './models' | ||
import { toUTC } from '../timestamp' | ||
|
||
export const parseLoanDistribution = (x: Responses.GetLoanDistributionResponse): Models.LoanDistribution => ({ | ||
stablecoin: x.stablecoin.map((x) => ({ value: x.value, label: x.label })), | ||
debt: x.debt.map((x) => ({ value: x.value, label: x.label })), | ||
collateral: x.collateral.map((x) => ({ value: x.value, label: x.label })), | ||
}) | ||
|
||
export const parseOracle = (x: Responses.GetOracleResponse): Models.Oracle => ({ | ||
chain: x.chain, | ||
controller: x.controller, | ||
oracle: x.oracle, | ||
pools: x.oracle_pools.map((pool) => ({ | ||
address: pool.address, | ||
borrowedIndex: pool.borrowed_ix, | ||
borrowedSymbol: pool.borrowed_symbol, | ||
borrowedAddress: pool.borrowed_address, | ||
collateralIndex: pool.collateral_ix, | ||
collateralSymbol: pool.collateral_symbol, | ||
collateralAddress: pool.collateral_address, | ||
})), | ||
ohlc: x.data.map((ohlc) => ({ | ||
time: toUTC(ohlc.time), | ||
open: ohlc.open, | ||
close: ohlc.close, | ||
high: ohlc.high, | ||
low: ohlc.low, | ||
basePrice: ohlc.base_price, | ||
oraclePrice: ohlc.oracle_price, | ||
})), | ||
}) |
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