Skip to content

Commit

Permalink
fix: more logging during liquidation
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Jan 13, 2025
1 parent 6ad5886 commit 90921a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/sdk/accounts/CreditAccountsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
type CreditAccountDataSlice,
type RouterCloseResult,
} from "../router";
import type { MultiCall, RawTx } from "../types";
import type { ILogger, MultiCall, RawTx } from "../types";
import { childLogger } from "../utils";
import { simulateMulticall } from "../utils/viem";

type CompressorAbi = typeof iCreditAccountCompressorAbi;
Expand Down Expand Up @@ -156,13 +157,15 @@ export interface PermitResult {
export class CreditAccountsService extends SDKConstruct {
#compressor: Address;
#batchSize?: number;
#logger?: ILogger;

constructor(sdk: GearboxSDK, options?: CreditAccountServiceOptions) {
super(sdk);
this.#compressor = sdk.addressProvider.getLatestVersion(
AP_CREDIT_ACCOUNT_COMPRESSOR,
);
this.#batchSize = options?.batchSize;
this.#logger = childLogger("CreditAccountsService", sdk.logger);
}

/**
Expand Down Expand Up @@ -805,6 +808,10 @@ export class CreditAccountsService extends SDKConstruct {
const tokens = Array.from(tokensByPool.get(pool) ?? []);
priceFeeds.push(...oracle.priceFeedsForTokens(tokens));
}
this.#logger?.debug(
{ account: creditAccount?.creditAccount, manager: cm.name },
`generating price feed updates for ${priceFeeds.length} price feeds`,
);
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
priceFeeds,
creditAccount ? { account: creditAccount.creditAccount } : undefined,
Expand All @@ -822,11 +829,16 @@ export class CreditAccountsService extends SDKConstruct {
desiredQuotas: Array<Asset> | undefined,
): Promise<Array<OnDemandPriceUpdate>> {
const market = this.sdk.marketRegister.findByCreditManager(creditManager);
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
const update = await this.getUpdateForAccount(
creditManager,
creditAccount,
desiredQuotas,
);
this.#logger?.debug(
{ account: creditAccount?.creditAccount, manager: cm.name },
`getting on demand price updates from ${update.txs.length} txs`,
);
return market.priceOracle.onDemandPriceUpdates(update);
}

Expand Down
1 change: 1 addition & 0 deletions src/sdk/market/PriceOracleBaseContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class PriceOracleBaseContract<abi extends Abi | readonly unknown[]>
// it would be much nicer to have intermediate format and get RawTx/OnDemandPriceUpdate/ViemMulticall from it (as it's done in liquidator)
const result: OnDemandPriceUpdate[] = [];
if (!updates) {
this.logger?.debug("empty updates list");
return result;
}
const { txs } = updates;
Expand Down

0 comments on commit 90921a6

Please sign in to comment.