Skip to content

Commit de307f2

Browse files
committed
fix: remove blocknumbers
1 parent 991eafd commit de307f2

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

src/sdk/accounts/CreditAccountsService.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {
2121
PriceOracleContract,
2222
UpdatePriceFeedsResult,
2323
} from "../market";
24-
import type { MultiCall, RawTx, ReadContractOptions } from "../types";
24+
import type { MultiCall, RawTx } from "../types";
2525
import { simulateMulticall } from "../utils/viem";
2626

2727
type CompressorAbi = typeof iCreditAccountCompressorAbi;
@@ -58,17 +58,14 @@ export class CreditAccountsService extends SDKConstruct {
5858
*/
5959
public async getCreditAccountData(
6060
account: Address,
61-
options?: ReadContractOptions,
6261
): Promise<CreditAccountData | undefined> {
63-
const blockNumber = options?.blockNumber;
6462
let raw: CreditAccountData;
6563
try {
6664
raw = await this.provider.publicClient.readContract({
6765
abi: iCreditAccountCompressorAbi,
6866
address: this.#compressor,
6967
functionName: "getCreditAccountData",
7068
args: [account],
71-
blockNumber, // TODO: we should cache price updates for block to speed up optimistic liquidator
7269
});
7370
} catch (e) {
7471
// TODO: reverts if account is not found, how to handle other revert reasons?
@@ -93,7 +90,6 @@ export class CreditAccountsService extends SDKConstruct {
9390
allowFailure: false,
9491
gas: 550_000_000n,
9592
batchSize: 0, // we cannot have price updates and compressor request in different batches
96-
blockNumber,
9793
});
9894
const cad = resp.pop() as CreditAccountData;
9995
return cad;
@@ -111,7 +107,6 @@ export class CreditAccountsService extends SDKConstruct {
111107
*/
112108
public async getCreditAccounts(
113109
args?: CreditAccountFilter,
114-
options?: ReadContractOptions,
115110
): Promise<CreditAccountData[]> {
116111
const {
117112
creditManager,
@@ -144,7 +139,6 @@ export class CreditAccountsService extends SDKConstruct {
144139
const [accounts, newOffset] = await this.#getCreditAccounts(
145140
[arg0, { ...caFilter, reverting }, offset],
146141
priceUpdateTxs,
147-
options,
148142
);
149143
allCAs.push(...accounts);
150144
offset = newOffset;
@@ -226,13 +220,13 @@ export class CreditAccountsService extends SDKConstruct {
226220

227221
/**
228222
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
229-
* @param param0
223+
* @param args
224+
* @param priceUpdateTxs
230225
* @returns
231226
*/
232227
async #getCreditAccounts(
233228
args: GetCreditAccountsArgs,
234229
priceUpdateTxs?: RawTx[],
235-
options?: ReadContractOptions,
236230
): Promise<[accounts: CreditAccountData[], newOffset: bigint]> {
237231
if (priceUpdateTxs?.length) {
238232
const resp = await simulateMulticall(this.provider.publicClient, {
@@ -249,7 +243,6 @@ export class CreditAccountsService extends SDKConstruct {
249243
allowFailure: false,
250244
gas: 550_000_000n,
251245
batchSize: 0, // we cannot have price updates and compressor request in different batches
252-
blockNumber: options?.blockNumber,
253246
});
254247
const getCreditAccountsResp = resp.pop() as any as [
255248
CreditAccountData[],
@@ -267,7 +260,6 @@ export class CreditAccountsService extends SDKConstruct {
267260
address: this.#compressor,
268261
functionName: "getCreditAccounts",
269262
args,
270-
blockNumber: options?.blockNumber,
271263
});
272264
}
273265

@@ -308,32 +300,28 @@ export class CreditAccountsService extends SDKConstruct {
308300
/**
309301
* Returns account price updates in a non-encoded format
310302
* @param acc
311-
* @param blockNumber
312303
* @returns
313304
*/
314305
public async getOnDemandPriceUpdates(
315306
acc: CreditAccountData,
316-
blockNumber?: bigint,
317307
): Promise<OnDemandPriceUpdate[]> {
318308
const market = this.sdk.marketRegister.findByCreditManager(
319309
acc.creditManager,
320310
);
321-
const update = await this.getUpdateForAccounts([acc], blockNumber);
311+
const update = await this.getUpdateForAccounts([acc]);
322312
return market.priceOracle.onDemandPriceUpdates(update);
323313
}
324314

325315
/**
326316
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...)
327317
* @param acc
328-
* @param blockNumber
329318
* @returns
330319
*/
331320
public async getPriceUpdatesForFacade(
332321
acc: CreditAccountData,
333-
blockNumber?: bigint,
334322
): Promise<MultiCall[]> {
335323
const cm = this.sdk.marketRegister.findCreditManager(acc.creditManager);
336-
const updates = await this.getOnDemandPriceUpdates(acc, blockNumber);
324+
const updates = await this.getOnDemandPriceUpdates(acc);
337325
return updates.map(({ token, reserve, data }) => ({
338326
target: cm.creditFacade.address,
339327
callData: encodeFunctionData({

src/sdk/types/transactions.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@ export interface MultiCall {
2020
target: Address;
2121
callData: Hex;
2222
}
23-
24-
export interface ReadContractOptions {
25-
blockNumber?: bigint;
26-
}

0 commit comments

Comments
 (0)