Skip to content

Commit

Permalink
Add transaction statistics from the Merlin chain
Browse files Browse the repository at this point in the history
  • Loading branch information
surf-one committed Apr 15, 2024
1 parent 2e1e8e5 commit a0b8b65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
20 changes: 11 additions & 9 deletions dexs/surfone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { httpGet } from "../../utils/fetchURL";

const volumeEndpoint = "https://apigateway.surf.one/pool/24h/data"
// const volumeEndpoint = "https://apigateway.surf.one/pool/24h/data"
const volumeEndpointV2 = "https://apigateway.surf.one/v2/market/total/stat"

const headers = {
"Block-Chain-Id": '8453',
"Block-Chain-Id":"4200",
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
};

interface IVolume {
totalVolume: number,
totalTradeSize: number,
'total_vol': number,
'24h_vol': number,
}

const fetch = () => {
return async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))
const response = (await httpGet(volumeEndpoint, { headers }));
const response = (await httpGet(volumeEndpointV2, { headers }));

const volume: IVolume = response.data;
return {
totalVolume: `${volume?.totalVolume || undefined}`,
dailyVolume: `${volume?.totalTradeSize || undefined}`,
totalVolume: `${volume?.total_vol || undefined}`,
dailyVolume: `${volume['24h_vol'] || undefined}`,
timestamp: dayTimestamp,
};
};
Expand All @@ -31,10 +33,10 @@ const fetch = () => {

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.BASE]: {
['merlin']: {
fetch: fetch(),
runAtCurrTime: true,
start: 7963804,
start: 9142115,
}
},
};
Expand Down
16 changes: 9 additions & 7 deletions fees/surfone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { httpGet } from "../../utils/fetchURL";

const volumeEndpoint = "https://apigateway.surf.one/pool/24h/data"
// const volumeEndpoint = "https://apigateway.surf.one/pool/24h/data"
const volumeEndpointV2 = "https://apigateway.surf.one/v2/market/total/stat"

const headers = {
"Block-Chain-Id": '8453',
"Block-Chain-Id":"4200",
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
};

interface IVolume {
totalTradeFee: number,
total_fee: number,
}

const fetch = () => {
return async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))
const response = (await httpGet(volumeEndpoint, { headers }));
const response = (await httpGet(volumeEndpointV2, { headers }));

const volume: IVolume = response.data;
return {
dailyFees: `${volume?.totalTradeFee || undefined}`,
dailyFees: `${volume?.total_fee || undefined}`,
timestamp: dayTimestamp,
};
};
Expand All @@ -29,10 +31,10 @@ const fetch = () => {

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.BASE]: {
['merlin']: {
fetch: fetch(),
runAtCurrTime: true,
start: 7963804,
start: 9142115,
}
},
};
Expand Down

0 comments on commit a0b8b65

Please sign in to comment.