-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStaticMarketFetcher.ts
37 lines (32 loc) · 1 KB
/
StaticMarketFetcher.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {
Address,
MarketConfig,
MarketMapping,
ScaledMarketData,
} from "../../types";
import { delay } from "../../utils/promises";
import { MarketFetcher } from "../fetchers.interfaces";
import { StaticFetcher } from "./StaticFetcher";
export class StaticMarketFetcher
extends StaticFetcher
implements MarketFetcher
{
constructor(
private _marketsList: string[],
private _marketsConfigs: MarketMapping<MarketConfig>,
private _marketsData: MarketMapping<ScaledMarketData>,
_longDelay: number,
_shortDelay?: number
) {
super(_longDelay, _shortDelay);
}
async fetchAllMarkets(): Promise<string[]> {
return delay(this._marketsList, this._longDelay);
}
async fetchMarketData(underlyingAddress: Address): Promise<ScaledMarketData> {
return delay(this._marketsData[underlyingAddress], this._shortDelay);
}
async fetchMarketConfig(underlyingAddress: Address): Promise<MarketConfig> {
return delay(this._marketsConfigs[underlyingAddress], this._shortDelay);
}
}