forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Boson protocol volume #2
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
Open
zajck
wants to merge
11
commits into
master
Choose a base branch
from
boson-fees-volume
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0ec84b6
Calculate protocol fee
zajck 0971424
rename `encumberedByToken` -> `collectedByToken`
zajck 7b39263
Daily volume calculation
zajck 125fa7f
Initial plan
Copilot 17ad86b
Update dexs/boson/utils.ts
zajck df175b9
Apply suggestions from code review
zajck 943936e
Merge pull request #3 from bosonprotocol/copilot/sub-pr-2
levalleux-ludo 3453893
Update daily volume calculation
zajck fb54e67
Merge branch 'boson-fees-volume' of github.com:bosonprotocol/dimensio…
zajck 3f1f7db
Update methodology.
zajck 7e3b8ba
remove dex adapter
zajck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,53 @@ | ||
| import { Adapter, FetchOptions, FetchResultV2 } from "../../adapters/types"; | ||
| import { CHAIN } from "../../helpers/chains"; | ||
|
|
||
| const ProtocolFeeCollectedEvent = | ||
| "event ProtocolFeeCollected(uint256 indexed exchangeId, address indexed exchangeToken, uint256 amount, address indexed executedBy)"; | ||
| const protocolFeeCollectedTopic = | ||
| "0x9399ed37d26489264206ddf87ad81aaa13557b4e56b5443503a2b64a24ec42db"; | ||
zajck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const protocolDiamondAddress = "0x59A4C19b55193D5a2EAD0065c54af4d516E18Cb5"; | ||
zajck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async function getProtocolFees(options: FetchOptions): Promise<FetchResultV2> { | ||
| const { getLogs, createBalances } = options; | ||
| const dailyFees = createBalances(); | ||
|
|
||
| const logs = await getLogs({ | ||
| target: protocolDiamondAddress, | ||
| topics: [protocolFeeCollectedTopic], | ||
| eventAbi: ProtocolFeeCollectedEvent, | ||
| }); | ||
|
|
||
| const collectedByToken: Record<string, bigint> = {}; | ||
| for (const log of logs) { | ||
| const token = log.exchangeToken; | ||
| const amount = BigInt(log.amount); | ||
| collectedByToken[token] = (collectedByToken[token] || 0n) + amount; | ||
| } | ||
|
|
||
| for (const [token, amount] of Object.entries(collectedByToken)) { | ||
| dailyFees.add(token, amount); | ||
| } | ||
|
|
||
| return { | ||
| dailyFees, | ||
| dailyRevenue: dailyFees, | ||
| dailyProtocolRevenue: dailyFees, | ||
| }; | ||
| } | ||
|
|
||
| const adapter: Adapter = { | ||
| fetch: getProtocolFees, | ||
| adapter: { | ||
| [CHAIN.POLYGON]: { start: "2022-10-12" }, | ||
| [CHAIN.ETHEREUM]: { start: "2023-09-29" }, | ||
| [CHAIN.BASE]: { start: "2025-01-31" }, | ||
| [CHAIN.ARBITRUM]: { start: "2025-04-01" }, | ||
| [CHAIN.OPTIMISM]: { start: "2025-03-10" }, | ||
| }, | ||
| version: 2, | ||
| methodology: { | ||
| Fees: "A fee is charged on every successful trade executed on the Boson Protocol.", | ||
| }, | ||
| }; | ||
|
|
||
| export default adapter; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.