Skip to content

Commit

Permalink
fix: only reduce reserves when cash is greter than 0
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Feb 1, 2024
1 parent 7f2a2e5 commit deb851b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/converter-bot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,16 @@ const main = async () => {
functionName: "getCash",
});

await wallet.writeContract({
address: addresses.VBNBAdmin as Address,
abi: vBnbAdminAbi,
functionName: "reduceReserves",
args: [totalReserves < cash ? totalReserves : cash],
});
if (cash > 0) {
await wallet.writeContract({
address: addresses.VBNBAdmin as Address,
abi: vBnbAdminAbi,
functionName: "reduceReserves",
args: [totalReserves < cash ? totalReserves : cash],
});
} else {
console.error("Unable to reduce reservers vBnb Admin is out of cash");
}

const tokenConverterConfigs = formatTokenConverterConfigs(tokenConverters);
const results = await Promise.allSettled(
Expand Down

0 comments on commit deb851b

Please sign in to comment.