@@ -7,14 +7,18 @@ import {
77 AP_ROUTER ,
88 type CreditAccountData ,
99 filterDust ,
10- type OnDemandPriceUpdate ,
10+ type OnDemandPriceUpdates ,
11+ type PriceUpdateV300 ,
1112 VERSION_RANGE_300 ,
1213} from "@gearbox-protocol/sdk" ;
1314import {
1415 iCreditFacadeV3Abi ,
1516 iCreditFacadeV3MulticallAbi ,
1617} from "@gearbox-protocol/types/abi" ;
17- import type { OptimisticResult } from "@gearbox-protocol/types/optimist" ;
18+ import type {
19+ OptimisticResult ,
20+ PriceUpdate ,
21+ } from "@gearbox-protocol/types/optimist" ;
1822import type { Address , TransactionReceipt } from "viem" ;
1923import { encodeFunctionData , parseEventLogs } from "viem" ;
2024import type { BatchLiquidatorSchema } from "../../config/index.js" ;
@@ -148,7 +152,8 @@ export default class BatchLiquidator
148152 for ( const ca of accounts ) {
149153 // pathfinder returns input without price updates
150154 const input = this . #getEstimateBatchInput( ca ) ;
151- input . priceUpdates = priceUpdatesByAccount [ ca . creditAccount ] ;
155+ input . priceUpdates = priceUpdatesByAccount [ ca . creditAccount ]
156+ . raw as PriceUpdateV300 [ ] ;
152157 inputs . push ( input ) ;
153158 }
154159 const { result } = await this . client . pub . simulateContract ( {
@@ -163,16 +168,16 @@ export default class BatchLiquidator
163168 for ( let i = 0 ; i < accounts . length ; i ++ ) {
164169 const ca = accounts [ i ] ;
165170 const cm = this . sdk . marketRegister . findCreditManager ( ca . creditManager ) ;
166- const updates = priceUpdatesByAccount [ ca . creditAccount ] . map (
167- ( { token , reserve , data } ) => ( {
168- target : cm . creditFacade . address ,
169- callData : encodeFunctionData ( {
170- abi : iCreditFacadeV3MulticallAbi ,
171- functionName : "onDemandPriceUpdate" ,
172- args : [ token , reserve , data ] ,
173- } ) ,
171+ const updates = (
172+ priceUpdatesByAccount [ ca . creditAccount ] . raw as PriceUpdateV300 [ ]
173+ ) . map ( ( { token , reserve , data } ) => ( {
174+ target : cm . creditFacade . address ,
175+ callData : encodeFunctionData ( {
176+ abi : iCreditFacadeV3MulticallAbi ,
177+ functionName : "onDemandPriceUpdate" ,
178+ args : [ token , reserve , data ] ,
174179 } ) ,
175- ) ;
180+ } ) ) ;
176181 result [ i ] . calls = [ ...updates , ...result [ i ] . calls ] ;
177182 }
178183
@@ -265,7 +270,8 @@ export default class BatchLiquidator
265270 pathAmount : 0n ,
266271 liquidatorPremium : batch [ a . creditAccount ] ?. profit ?? 0n ,
267272 liquidatorProfit : 0n , // cannot compute for single account
268- priceUpdates : priceUpdatesByAccount [ a . creditAccount ] ,
273+ priceUpdates : priceUpdatesByAccount [ a . creditAccount ]
274+ . raw as PriceUpdate [ ] ,
269275 isError : ! liquidated . has ( a . creditAccount ) ,
270276 error : getError ( a ) ,
271277 batchId : `${ index + 1 } /${ total } ` ,
@@ -379,7 +385,7 @@ export default class BatchLiquidator
379385 */
380386 async #batchLiquidationPreviewUpdates(
381387 accounts : CreditAccountData [ ] ,
382- ) : Promise < Record < Address , OnDemandPriceUpdate [ ] > > {
388+ ) : Promise < Record < Address , OnDemandPriceUpdates > > {
383389 const tokensByAccount : Record < Address , Set < Address > > = { } ;
384390 for ( const ca of accounts ) {
385391 const accTokens = tokensByAccount [ ca . creditAccount ] ?? new Set < Address > ( ) ;
@@ -393,13 +399,15 @@ export default class BatchLiquidator
393399 }
394400 const updates =
395401 await this . creditAccountService . getUpdateForAccounts ( accounts ) ;
396- const result : Record < Address , OnDemandPriceUpdate [ ] > = { } ;
402+ const result : Record < Address , OnDemandPriceUpdates > = { } ;
397403 for ( const ca of accounts ) {
398404 const market = this . sdk . marketRegister . findByCreditManager (
399405 ca . creditManager ,
400406 ) ;
401- result [ ca . creditAccount ] =
402- market . priceOracle . onDemandPriceUpdates ( updates ) ;
407+ result [ ca . creditAccount ] = market . priceOracle . onDemandPriceUpdates (
408+ ca . creditFacade ,
409+ updates ,
410+ ) ;
403411 }
404412 return result ;
405413 }
0 commit comments