@@ -7,6 +7,7 @@ import { PERMISSION_BY_TYPE } from "./constants.js";
77import type {
88 ClaimFarmRewardsProps ,
99 CreditAccountOperationResult ,
10+ CreditManagerOperationResult ,
1011 ICreditAccountsService ,
1112 RepayAndLiquidateCreditAccountProps ,
1213 RepayCreditAccountProps ,
@@ -26,17 +27,24 @@ export class CreditAccountServiceV310
2627 botBaseType,
2728 stopBot,
2829
29- creditAccount : ca ,
30- } : SetBotProps ) : Promise < CreditAccountOperationResult > {
31- const cm = this . sdk . marketRegister . findCreditManager ( ca . creditManager ) ;
30+ targetContract,
31+ } : SetBotProps ) : Promise <
32+ CreditAccountOperationResult | CreditManagerOperationResult
33+ > {
34+ const cm = this . sdk . marketRegister . findCreditManager (
35+ targetContract . creditManager ,
36+ ) ;
3237
33- const priceUpdatesCalls = await this . getPriceUpdatesForFacade ( {
34- creditManager : ca . creditManager ,
35- creditAccount : ca ,
36- } ) ;
38+ const priceUpdatesCalls =
39+ targetContract . type === "creditAccount"
40+ ? await this . getPriceUpdatesForFacade ( {
41+ creditManager : targetContract . creditManager ,
42+ creditAccount : targetContract ,
43+ } )
44+ : [ ] ;
3745
3846 const addBotCall : MultiCall = {
39- target : ca . creditFacade ,
47+ target : cm . creditFacade . address ,
4048 callData : encodeFunctionData ( {
4149 abi : iCreditFacadeMulticallV310Abi ,
4250 functionName : "setBotPermissions" ,
@@ -46,7 +54,10 @@ export class CreditAccountServiceV310
4654
4755 const calls = [ ...priceUpdatesCalls , addBotCall ] ;
4856
49- const tx = cm . creditFacade . multicall ( ca . creditAccount , calls ) ;
57+ const tx =
58+ targetContract . type === "creditAccount"
59+ ? cm . creditFacade . multicall ( targetContract . creditAccount , calls )
60+ : undefined ;
5061
5162 return { tx, calls, creditFacade : cm . creditFacade } ;
5263 }
0 commit comments