Skip to content

Commit

Permalink
feat: do not try to submit bid if jup output amount is lower than wha…
Browse files Browse the repository at this point in the history
…t we need (#284)
  • Loading branch information
m30m authored Dec 5, 2024
1 parent 4cd7d12 commit 44dbd9d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/dex-router/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ export class DexRouter {
const order = opportunity.order;
const routeBest = await this.getBestRoute(order);

const remainingOutput = order.state.expectedOutputAmount.sub(
order.state.filledOutputAmount
);
if (routeBest.output.amountOut < remainingOutput) {
throw new Error(
`Route output amount is less than remaining output amount: ${routeBest.output.amountOut.toString(
10
)} < ${remainingOutput.toString(10)}`
);
}
return {
transaction: Buffer.from(routeBest.tx.serialize()).toString("base64"),
chain_id: this.chainId,
Expand Down

0 comments on commit 44dbd9d

Please sign in to comment.