Skip to content

Commit

Permalink
refactor: account for denominator of inputAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Feb 2, 2024
1 parent effe780 commit 928a6b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/token-converter-bot/src/converter-bot/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "dotenv/config";

import { Fraction } from "@pancakeswap/sdk";
import { Address } from "viem";

import { coreVTokenAbi, protocolShareReserveAbi, tokenConverterAbi, vBnbAdminAbi } from "../config/abis/generated";
Expand Down Expand Up @@ -64,7 +64,8 @@ const executeTrade = async (t: BalanceResult) => {

const trade = await tokenConverter.getBestTrade(t.assetIn.address, t.assetOut.address, amountIn[1]);

const minIncome = t.assetOut.balance - trade.inputAmount.numerator;

const minIncome = BigInt(new Fraction(t.assetOut.balance, 1).subtract(new Fraction(trade.inputAmount.numerator, trade.inputAmount.denominator)).toFixed(0, {}));

await tokenConverter.arbitrage(t.tokenConverter, trade, amountIn[1], minIncome);
};
Expand Down

0 comments on commit 928a6b1

Please sign in to comment.