Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Feb 14, 2025
1 parent f9715d6 commit 28a9374
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,22 @@ export async function checkOwnedOrders(
orderDetails.flat().forEach((v) => {
v.takeOrders.forEach((order) => {
if (
// owner check
order.takeOrder.order.owner.toLowerCase() ===
config.mainAccount.account.address.toLowerCase() &&
// self fund config check
!!(config.selfFundOrders ?? []).find(
(e) =>
e.token.toLowerCase() ===
order.takeOrder.order.validOutputs[
order.takeOrder.outputIOIndex
].token.toLowerCase() &&
BigNumber.from(
order.takeOrder.order.validOutputs[order.takeOrder.outputIOIndex]
.vaultId,
).eq(e.vaultId),
) &&
// repetition check
!ownedOrders.find(
(e) =>
e.orderbook.toLowerCase() === v.orderbook.toLowerCase() &&
Expand Down
2 changes: 1 addition & 1 deletion src/modes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Contract } from "ethers";
import { PublicClient } from "viem";
import { DataFetcher } from "sushi";
import { Token } from "sushi/currency";
import { extendSpanAttributes } from "../utils";
import { findOpp as findInterObOpp } from "./interOrderbook";
import { findOpp as findIntraObOpp } from "./intraOrderbook";
import { findOppWithRetries as findRpOpp } from "./routeProcessor";
import { BotConfig, BundledOrders, ViemClient, DryrunResult, SpanAttrs } from "../types";
import { extendSpanAttributes } from "../utils";

/**
* The main entrypoint for the main logic to find opps.
Expand Down
10 changes: 9 additions & 1 deletion test/orders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,17 @@ describe("Test order", async function () {
viemClient: {
multicall: async () => [0n, 10n],
},
selfFundOrders: [
{
token: order1.sellToken,
vaultId: order1.takeOrders[0].takeOrder.order.validOutputs[0].vaultId,
threshold: "1",
topupAmount: "1",
},
],
};
const result = await checkOwnedOrders(config, orders, hexlify(randomBytes(20)));
const expected = orders.map((v, i) => ({
const expected = orders.slice(0, 1).map((v, i) => ({
id: v.takeOrders[0].id,
vaultId:
v.takeOrders[0].takeOrder.order.validOutputs[
Expand Down

0 comments on commit 28a9374

Please sign in to comment.