Skip to content

Commit

Permalink
use removeBorrowers instead of removeBorrower
Browse files Browse the repository at this point in the history
  • Loading branch information
mn13 committed Mar 20, 2024
1 parent d8cbea0 commit e16bb62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { populateDbWithBorrowers } from "./sync";
import { getDebtCoeff, getAccountPosition, getReserves, getBalance, liquidate } from "./infrastructure/soroban/contracts";
import { POOL_PRECISION_FACTOR, SOROBAN_URL, LIQUIDATOR_ADDRESS } from "./configuration";
import { SorobanRpc } from "@stellar/stellar-sdk";
import { deleteBorrower, deleteBorrowers, readBorrowers } from "./infrastructure/db/domain";
import { deleteBorrowers, readBorrowers } from "./infrastructure/db/domain";
import { AppDataSource } from "./infrastructure/db/data-source";

async function main() {
Expand Down Expand Up @@ -93,7 +93,7 @@ async function main() {

for (const liquidationResult of liquidationResults) {
if (liquidationResult.status === "fulfilled" && liquidationResult.value[1] == undefined) {
await deleteBorrower(liquidationResult.value[0]);
await deleteBorrowers([liquidationResult.value[0]]);
} else {
console.warn(`Liquidation error: ${liquidationResult}`);
}
Expand Down
8 changes: 0 additions & 8 deletions src/infrastructure/db/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ export const insertBorrowers = async (borrowers: string[]) => {
}
}

export const deleteBorrower = async (borrower: string) => {
const slenderKeeperRepository = AppDataSource.getRepository(SlenderKeeperState);
const currentState = await slenderKeeperRepository.findOneBy({ chain: CHAIN, contractAddress: POOL_ID });
const slenderBorrowerRepository = AppDataSource.getRepository(SlenderBorrower);
const b = await slenderBorrowerRepository.findOneBy({ keeperStateId: currentState.id, borrower });
slenderBorrowerRepository.remove(b);
}

export const deleteBorrowers = async (borrowers: string[]) => {
const slenderKeeperRepository = AppDataSource.getRepository(SlenderKeeperState);
const currentState = await slenderKeeperRepository.findOneBy({ chain: CHAIN, contractAddress: POOL_ID });
Expand Down

0 comments on commit e16bb62

Please sign in to comment.