Skip to content

Commit

Permalink
Don't hardcode 24h finalization
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored and berteotti committed Oct 7, 2024
1 parent ccb2732 commit 817c405
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions app/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
OrderDirection,
} from '@/queries/omen';
import { AI_AGENTS_ALLOWLIST } from '../constants';
import { _24HoursInSeconds, nowTimestamp } from '@/utils/time';
import { nowTimestamp } from '@/utils/time';
import {WXDAI, SDAI} from '@/constants/index';

export type OrderFilter = {
Expand Down Expand Up @@ -53,8 +53,6 @@ export type StateFilter = {
when: FixedProductMarketMaker_Filter;
};

const oneDayAgoTimestamp = nowTimestamp - _24HoursInSeconds;

export const stateFilters: StateFilter[] = [
{
name: 'Open',
Expand All @@ -76,7 +74,8 @@ export const stateFilters: StateFilter[] = [
key: 'finalizing',
when: {
resolutionTimestamp: null,
currentAnswerTimestamp_gt: oneDayAgoTimestamp,
answerFinalizedTimestamp_gt: nowTimestamp,
answerFinalizedTimestamp_not: null,
openingTimestamp_lt: nowTimestamp,
isPendingArbitration: false,
currentAnswer_not: null,
Expand Down
4 changes: 2 additions & 2 deletions entities/markets/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FixedProductMarketMaker } from '@/queries/omen';
import { fromHex } from 'viem';
import { Outcome } from '@/entities';
import { isPast } from 'date-fns';
import { _24HoursInSeconds, nowTimestamp } from '@/utils/time';
import { nowTimestamp } from '@/utils/time';

const INVALID_ANSWER_HEX =
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
Expand All @@ -25,7 +25,7 @@ export class Market {
this.closingDate = new Date(+fpmm.openingTimestamp * 1000);
this.isAnswerFinal =
!!fpmm.resolutionTimestamp ||
nowTimestamp - fpmm.currentAnswerTimestamp > _24HoursInSeconds;
fpmm.answerFinalizedTimestamp < nowTimestamp;

this.currentAnswer = fpmm.question?.currentAnswer
? fpmm.question.currentAnswer === INVALID_ANSWER_HEX
Expand Down
2 changes: 2 additions & 0 deletions queries/omen/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const getMarketsQuery = (
$currentAnswer: Bytes
$currentAnswer_not: Bytes
$answerFinalizedTimestamp_lt: Int
$answerFinalizedTimestamp_gt: Int
$openingTimestamp_lte: Int
$scaledLiquidityParameter_gt: Int
$resolutionTimestamp: Int
Expand All @@ -172,6 +173,7 @@ const getMarketsQuery = (
${params.currentAnswer !== undefined ? 'currentAnswer: $currentAnswer' : ''}
${params.currentAnswer_not !== undefined ? 'currentAnswer_not: $currentAnswer_not' : ''}
${params.answerFinalizedTimestamp_lt ? 'answerFinalizedTimestamp_lt: $answerFinalizedTimestamp_lt' : ''}
${params.answerFinalizedTimestamp_gt ? 'answerFinalizedTimestamp_gt: $answerFinalizedTimestamp_gt' : ''}
${params.openingTimestamp_lte ? 'openingTimestamp_lte: $openingTimestamp_lte' : ''}
${params.scaledLiquidityParameter_gt !== undefined ? 'scaledLiquidityParameter_gt: $scaledLiquidityParameter_gt' : ''}
${params.resolutionTimestamp !== undefined ? 'resolutionTimestamp: $resolutionTimestamp' : ''}
Expand Down
1 change: 0 additions & 1 deletion utils/time.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const _24HoursInSeconds = 24 * 60 * 60;
export const nowTimestamp = Math.floor(Date.now() / 1000);

0 comments on commit 817c405

Please sign in to comment.