Skip to content

Commit

Permalink
fix: multi bank fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbpvsc committed Nov 21, 2023
1 parent 26439ea commit 5120b79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 5 additions & 5 deletions apps/alpha-liquidator/src/liquidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ class Liquidator {
debug("Swapping any remaining non-usdc to usdc");
const banks = this.client.banks.values();
const usdcBank = this.client.getBankByMint(USDC_MINT)!;
await Promise.all([...banks].map(async (bank) => {
for (const bank of banks) {
if (bank.mint.equals(USDC_MINT)) {
return;
continue;
}

let uiAmount = await this.getTokenAccountBalance(bank.mint, false);
Expand All @@ -399,7 +399,7 @@ class Liquidator {

if (usdValue.lte(DUST_THRESHOLD_UI)) {
// debug!("Not enough %s to swap, skipping...", this.getTokenSymbol(bank));
return;
continue;
} else {
debug("Account has %d ($%d) %s", uiAmount, usdValue, this.getTokenSymbol(bank));
}
Expand All @@ -418,14 +418,14 @@ class Liquidator {

if (uiAmount.lte(DUST_THRESHOLD_UI)) {
debug("Account has no more %s, skipping...", this.getTokenSymbol(bank));
return;
continue;
}
}

debug("Swapping %d %s to USDC", uiAmount, this.getTokenSymbol(bank));

await this.swap(bank.mint, USDC_MINT, uiToNative(uiAmount, bank.mintDecimals));
}));
}

const usdcBalance = await this.getTokenAccountBalance(USDC_MINT);

Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12132,13 +12132,6 @@ [email protected]:
dependencies:
node-fetch "2.6.1"

[email protected]:
version "3.1.5"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==
dependencies:
node-fetch "2.6.7"

[email protected]:
version "3.1.6"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.6.tgz#bae05aa31a4da760969756318feeee6e70f15d6c"
Expand Down

0 comments on commit 5120b79

Please sign in to comment.