Skip to content

Commit

Permalink
local data tigris
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Oct 20, 2023
1 parent e063247 commit b7ad65e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions dexs/tigris/arbitrum.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dexs/tigris/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ const fetchFromAPI = async (chain: Chain, timestamp: number): Promise<ApiRespons
}

function startOfDayTimestamp(timestamp: number): number {
const date = new Date(timestamp * 1000);
const date = new Date(timestamp * 1000);
date.setUTCHours(0, 0, 0, 0);
return Math.floor(date.getTime() / 1000);
}

const fetch = (chain: Chain) => {
return async (timestamp: number) => {
try {
const dataPoints = await fetchFromAPI(chain, timestamp);
const dataPoints = require(`./${chain}.json`) as ApiResponse[];

const adjustedTimestamp = startOfDayTimestamp(timestamp);


const matchingData = dataPoints.find(e => e.day === adjustedTimestamp);

Expand Down
1 change: 1 addition & 0 deletions dexs/tigris/polygon.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions fees/tigris/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ const fetchFromAPI = async (chain: Chain, timestamp: number): Promise<ApiRespons
}

function startOfDayTimestamp(timestamp: number): number {
const date = new Date(timestamp * 1000);
const date = new Date(timestamp * 1000);
date.setUTCHours(0, 0, 0, 0);
return Math.floor(date.getTime() / 1000);
}

const fetch = (chain: Chain) => {
return async (timestamp: number): Promise<FetchResultFees> => {
try {
const dataPoints = await fetchFromAPI(chain, timestamp);

// const dataPoints = await fetchFromAPI(chain, timestamp);
const dataPoints = require(`../../dexs/tigris/${chain}.json`) as ApiResponse[];

const adjustedTimestamp = startOfDayTimestamp(timestamp);

const matchingData = dataPoints.find(e => e.day === adjustedTimestamp);
Expand Down Expand Up @@ -102,4 +103,4 @@ const adapter: Adapter = {
}
}

export default adapter;
export default adapter;
3 changes: 2 additions & 1 deletion options/tigris/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function startOfDayTimestamp(timestamp: number): number {
const fetch = (chain: Chain) => {
return async (timestamp: number) => {
try {
const dataPoints = await fetchFromAPI(chain, timestamp);
// const dataPoints = await fetchFromAPI(chain, timestamp);
const dataPoints = require(`../../dexs/tigris/${chain}.json`) as ApiResponse[];

const adjustedTimestamp = startOfDayTimestamp(timestamp);

Expand Down

0 comments on commit b7ad65e

Please sign in to comment.