Skip to content

Commit

Permalink
Merge branch '2025-01-22-test-quote-gas-pr' into minor-update-pr-test
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Jan 25, 2025
2 parents e6d7ce8 + 7492a2e commit 8cd790c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV DOCKER_TAG=$DOCKER_CHANNEL

WORKDIR /arb-bot
ADD . .
RUN rm -rf test/*.js test/*.ts test/e2e
RUN npm install
RUN npm run build
CMD node arb-bot
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ export const main = async (argv: any, version?: string) => {
v.sg,
lastReadOrdersTimestamp,
v.skip,
options.timeout,
// options.timeout,
roundSpan,
),
),
Expand Down
50 changes: 23 additions & 27 deletions src/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,20 +302,14 @@ export function prepareOrdersForRound(
const orderbookBundledOrders: BundledOrders[] = [];
for (const [, ownerProfile] of ownersProfileMap) {
let remainingLimit = ownerProfile.limit;
const activeOrdersProfiles = Array.from(ownerProfile.orders).filter((v) => v[1].active);
let remainingOrdersPairs = activeOrdersProfiles.filter(
(v) => v[1].takeOrders.length > 0,
);
// reset if all orders are already consumed
if (remainingOrdersPairs.length === 0) {
for (const [, orderProfile] of activeOrdersProfiles) {
orderProfile.takeOrders.push(...orderProfile.consumedTakeOrders.splice(0));
}
remainingOrdersPairs = activeOrdersProfiles;
}
const activeOrdersProfiles = Array.from(ownerProfile.orders);
// consume orders limits
for (const [orderHash, orderProfile] of remainingOrdersPairs) {
if (remainingLimit > 0) {
for (const [orderHash, orderProfile] of activeOrdersProfiles) {
if (
remainingLimit > 0 &&
orderProfile.active &&
orderProfile.takeOrders.length > 0
) {
const consumingOrderPairs = orderProfile.takeOrders.splice(0, remainingLimit);
remainingLimit -= consumingOrderPairs.length;
orderProfile.consumedTakeOrders.push(...consumingOrderPairs);
Expand All @@ -326,20 +320,22 @@ export function prepareOrdersForRound(
// reset and start consuming again from top until limit is reached
if (remainingLimit > 0) {
for (const [orderHash, orderProfile] of activeOrdersProfiles) {
orderProfile.takeOrders.push(...orderProfile.consumedTakeOrders.splice(0));
if (remainingLimit > 0) {
const consumingOrderPairs = orderProfile.takeOrders.splice(
0,
remainingLimit,
);
remainingLimit -= consumingOrderPairs.length;
orderProfile.consumedTakeOrders.push(...consumingOrderPairs);
gatherPairs(
orderbook,
orderHash,
consumingOrderPairs,
orderbookBundledOrders,
);
if (orderProfile.active) {
orderProfile.takeOrders.push(...orderProfile.consumedTakeOrders.splice(0));
if (remainingLimit > 0) {
const consumingOrderPairs = orderProfile.takeOrders.splice(
0,
remainingLimit,
);
remainingLimit -= consumingOrderPairs.length;
orderProfile.consumedTakeOrders.push(...consumingOrderPairs);
gatherPairs(
orderbook,
orderHash,
consumingOrderPairs,
orderbookBundledOrders,
);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ export async function getOrderChanges(
subgraph: string,
startTimestamp: number,
skip: number,
timeout?: number,
// timeout?: number,
span?: Span,
) {
timeout;
// timeout;
let skip_ = skip;
let count = 0;
const allResults: SgTx[] = [];
Expand Down

0 comments on commit 8cd790c

Please sign in to comment.