-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #675 from DefiLlama/split-velodrome
split velodrome
- Loading branch information
Showing
7 changed files
with
69 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { Chain } from "@defillama/sdk/build/general"; | ||
import { fetchV2 } from "./v2"; | ||
|
||
|
||
const fetch = (_: Chain) => { | ||
return async (timestamp: number) => { | ||
const [v2] = await Promise.all([fetchV2(timestamp)]) | ||
const dailyVolume = Number(v2.dailyVolume); | ||
return { | ||
dailyVolume: `${dailyVolume}`, | ||
timestamp | ||
} | ||
} | ||
} | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.OPTIMISM]: { | ||
fetch: fetch(CHAIN.OPTIMISM), | ||
start: async () => 1677110400 | ||
}, | ||
}, | ||
}; | ||
|
||
export default adapter; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Adapter, Fetch, FetchResultFees } from '../../adapters/types'; | ||
import { CHAIN, OPTIMISM } from '../../helpers/chains'; | ||
import { fetchV2 } from './velodrome-v2'; | ||
import { fees_bribes } from './bribes'; | ||
import { getBlock } from '../../helpers/getBlock'; | ||
|
||
|
||
const getFees = async (timestamp: number): Promise<FetchResultFees> => { | ||
const fromTimestamp = timestamp - 60 * 60 * 24 | ||
const toTimestamp = timestamp | ||
const fromBlock = (await getBlock(fromTimestamp, CHAIN.OPTIMISM, {})); | ||
const toBlock = (await getBlock(toTimestamp, CHAIN.OPTIMISM, {})); | ||
const [feeV2, bribes] = await Promise.all([fetchV2(fromBlock, toBlock,timestamp), fees_bribes(fromBlock, toBlock, timestamp)]); | ||
const dailyFees = Number(feeV2.dailyFees); | ||
const dailyRevenue = Number(feeV2.dailyRevenue) + bribes; | ||
const dailyHoldersRevenue = Number(feeV2.dailyHoldersRevenue) + bribes; | ||
return { | ||
dailyFees: `${dailyFees}`, | ||
dailyRevenue: `${dailyRevenue}`, | ||
dailyHoldersRevenue: `${dailyHoldersRevenue}`, | ||
dailyBribesRevenue: `${bribes}`, | ||
timestamp | ||
} | ||
} | ||
|
||
const adapter: Adapter = { | ||
adapter: { | ||
[OPTIMISM]: { | ||
fetch: getFees, | ||
start: async () => 1677110400, // TODO: Add accurate timestamp | ||
}, | ||
}, | ||
}; | ||
export default adapter; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters