Skip to content

Commit

Permalink
Fix fulfill amount
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlotfi authored and mrlotfi committed Oct 31, 2024
1 parent 6127271 commit 160ca42
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/auction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ export class AuctionFulfillerConfig {
const minAmountNeededForFulfill = Number(minAmountNeededForFulfill64) / 10 ** swap.toToken.decimals;

const mappedMinAmountIn = minAmountNeededForFulfill * (effectiveAmountIn / output);
const mappedBpsAmountIn = (swap.fromAmount.toNumber() * Number(bpsFees)) / 10000; // upper estimate

if (mappedMinAmountIn > effectiveAmountIn - mappedBpsAmountIn) {
if (mappedMinAmountIn > effectiveAmountIn) {
logger.warn(
`AuctionFulfillerConfig.normalizedBidAmount: mappedMinAmountIn > effectiveAmountIn ${mappedMinAmountIn} > ${effectiveAmountIn}`,
);
Expand All @@ -213,7 +212,7 @@ export class AuctionFulfillerConfig {

const aggressionPercent = this.fulfillAggressionPercent; // 0 - 100

const profitMargin = effectiveAmountIn - mappedMinAmountIn - mappedBpsAmountIn;
const profitMargin = effectiveAmountIn - mappedMinAmountIn;

const finalAmountIn = mappedMinAmountIn + (profitMargin * aggressionPercent) / 100;

Expand Down

0 comments on commit 160ca42

Please sign in to comment.