-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStaticUserFetcher.ts
47 lines (40 loc) · 1.31 KB
/
StaticUserFetcher.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
38
39
40
41
42
43
44
45
46
47
import { BigNumber, constants } from "ethers";
import { BlockTag } from "@ethersproject/abstract-provider";
import { WadRayMath } from "@morpho-labs/ethers-utils/lib/maths";
import {
Address,
MarketMapping,
ScaledUserMarketData,
StEthData,
} from "../../types";
import { delay } from "../../utils/promises";
import { UserFetcher } from "../fetchers.interfaces";
import { StaticFetcher } from "./StaticFetcher";
export class StaticUserFetcher extends StaticFetcher implements UserFetcher {
constructor(
private _userData: {
ethBalance: BigNumber;
stEthData: StEthData;
},
private _userMarketsData: MarketMapping<ScaledUserMarketData>,
_longDelay: number,
_shortDelay?: number
) {
super(_longDelay, _shortDelay);
}
async fetchUserMarketData(underlyingAddress: Address, userAddress: Address) {
return delay(this._userMarketsData[underlyingAddress], this._shortDelay);
}
async fetchUserETHBalance() {
return delay(this._userData.ethBalance, this._longDelay);
}
async fetchManagerApproval(userAddress: Address, managerAddress: Address) {
return delay(
{ isBulkerManaging: true, nonce: constants.Zero },
this._longDelay
);
}
fetchStethData(userAddress: Address, blockTag?: BlockTag) {
return delay(this._userData.stEthData, this._shortDelay);
}
}