Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Bitoro Volume Adapter #1402

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions dexs/bitoro/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { FetchResultVolume, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { httpGet } from "../../utils/fetchURL";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import customBackfill from "../../helpers/customBackfill";

// Bitoro volume API endpoint
const bitoroApiVolumeEndpoint = "https://api.bitoro.network/btr/stats/volume"
// March 25, 2024 UTC timestamp
const bitoroLaunchDate = 1711324800
// constructing request URL
const makeRequest = (startTime: number, endTime: number) => bitoroApiVolumeEndpoint + `?start=${startTime}&end=${endTime}`

const fetch = async (timestamp: number) => {
const startOfDayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) + 86400
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why start time is day +1 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm under the impression that 24hr volume is meant to be calculated for the current day, not the day before. getUniqStartOfTodayTimestamp gives the end of the prior day and we wanted start of current day. Is 24 hour volume meant to be for the day prior? I can see how this can be an issue with custom backfill

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there tvl adapter ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tvl adapter. Still waiting on endpoint.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any update?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not merge the volume adapter without a TVL adapter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that the case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ppl will complaint why that protocol does not tvl but volume high is it fake volume and will delist

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. We are working on this.

const endOfDayTimestamp = startOfDayTimestamp + 86400;

// Get today's volume
let request = makeRequest(startOfDayTimestamp, endOfDayTimestamp)
let data = await httpGet(request)
const todayVolume = data["volume"]

// Get total volume
request = makeRequest(bitoroLaunchDate, endOfDayTimestamp)
data = await httpGet(request)
const totalVolume = data["volume"]

return {
timestamp,
dailyVolume: todayVolume.toString(),
totalVolume: totalVolume.toString()
}
}

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.ARBITRUM]: {
start: bitoroLaunchDate,
fetch,
customBackfill: customBackfill(CHAIN.ARBITRUM, () => fetch)
}
}
}



export default adapter;
Loading