Skip to content

Commit aa52404

Browse files
committed
fix: add getActiveBots to CreditAccountService
1 parent c45b667 commit aa52404

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/sdk/accounts/CreditAccountsService.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { encodeFunctionData } from "viem";
44
import {
55
iCreditAccountCompressorAbi,
66
iCreditFacadeV3MulticallAbi,
7+
iPeripheryCompressorAbi,
78
iRewardsCompressorAbi,
89
} from "../abi";
9-
import type { CreditAccountData, RewardInfo } from "../base";
10+
import type { BotData, CreditAccountData, RewardInfo } from "../base";
1011
import { SDKConstruct } from "../base";
1112
import {
1213
ADDRESS_0X0,
1314
AP_CREDIT_ACCOUNT_COMPRESSOR,
15+
AP_PERIPHERY_COMPRESSOR,
1416
AP_REWARDS_COMPRESSOR,
1517
MAX_UINT256,
1618
MIN_INT96,
@@ -296,6 +298,19 @@ export class CreditAccountsService extends SDKConstruct {
296298
return [...rewards];
297299
}
298300

301+
async getActiveBots(
302+
marketConfigurator: Address,
303+
account: Address,
304+
): Promise<BotData[]> {
305+
const botsData = await this.provider.publicClient.readContract({
306+
abi: iPeripheryCompressorAbi,
307+
address: this.peripheryCompressor,
308+
functionName: "getActiveBots",
309+
args: [marketConfigurator, account],
310+
});
311+
return [...botsData];
312+
}
313+
299314
/**
300315
* Generates transaction to liquidate credit account
301316
* @param account
@@ -1047,4 +1062,8 @@ export class CreditAccountsService extends SDKConstruct {
10471062
private get rewardCompressor(): Address {
10481063
return this.sdk.addressProvider.getLatestVersion(AP_REWARDS_COMPRESSOR);
10491064
}
1065+
1066+
private get peripheryCompressor(): Address {
1067+
return this.sdk.addressProvider.getLatestVersion(AP_PERIPHERY_COMPRESSOR);
1068+
}
10501069
}

0 commit comments

Comments
 (0)