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

Fees adapter for Zeebu #2308

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Fees adapter for Zeebu #2308

wants to merge 5 commits into from

Conversation

dsarvaiya
Copy link

Adding fees dimensional adapters for Zeebu (revenue and fees)

Added adapter for ZEEBU to show fees & revenue
update methodology and remove unwanted functions
remove syntax error
@llamabutler
Copy link

The zeebu adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees zeebu

🦙 Running ZEEBU adapter 🦙
---------------------------------------------------
Start Date:	Sun, 12 Jan 2025 11:53:14 GMT
End Date:	Mon, 13 Jan 2025 11:53:14 GMT
---------------------------------------------------

BASE 👇
Backfill start time: 10/10/2024
Daily fees: 216.00 k
└─ Methodology: 2% collectively paid by merchant and customer
Total fees: 13.29 M
└─ Methodology: 2% collectively paid by merchant and customer
Daily user fees: 216.00 k
└─ Methodology: Daily fees
Total user fees: 13.29 M
└─ Methodology: Daily fees
Daily revenue: 216.00 k
└─ Methodology: Invoice fees
Total revenue: 13.29 M
└─ Methodology: Invoice fees
Daily holders revenue: 1.30 k
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
Total holders revenue: 79.77 k
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
End timestamp: 1736769193 (2025-01-13T11:53:13.000Z)


BSC 👇
Backfill start time: 30/6/2023
Daily fees: 0
└─ Methodology: 2% collectively paid by merchant and customer
Total fees: 90.19 M
└─ Methodology: 2% collectively paid by merchant and customer
Daily user fees: 0
Total user fees: 90.19 M
Daily revenue: 0
└─ Methodology: Invoice fees
Total revenue: 90.19 M
└─ Methodology: Invoice fees
Daily holders revenue: 0
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
Total holders revenue: 541.14 k
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
End timestamp: 1736769193 (2025-01-13T11:53:13.000Z)

// Fetch total fees
const totalFeesResponse = await request(graphUrls[chain], totalFeesQuery, { });
const totalFees = totalFeesResponse.overallVolumeFeesAggregates.reduce(
(sum, item) => sum + parseFloat(((item.totalFees * 2)/1e18) || 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

why value is 2x ?

Copy link
Author

Choose a reason for hiding this comment

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

We charge 1% fees from both parties (i.e customer & merchant), we charge 1% from customer at invoice smart contract while payment being processed, 1% will charges from merchant when they will claim their invoice settlement amount at PSP portal .

For your information, you can refer this : https://zeebu.gitbook.io/zeebu-whitepaper-2.0/Eo5Icop4mRkIyIwSDGM8/zeebu-settlement/platform-overview

Copy link
Contributor

Choose a reason for hiding this comment

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

why it not include at your totalFees ?

Copy link
Author

Choose a reason for hiding this comment

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

Its there, look at this code snipest:

const totalFees = totalFeesResponse.overallVolumeFeesAggregates.reduce(
(sum, item) => sum + parseFloat(((item.totalFees * 2)/1e18) || 0),
0
);

we multiply it by 2 also.

we charge 1% on both the side, we can get 1% fees values for customer from smart contract using subgraph, while for merchant we can not calculate it on blockchain. Its stored centralise. Should we used rest API to fetch those fees data here?

Copy link
Contributor

Choose a reason for hiding this comment

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

is it incorrect ? because it not real number you can collect

Copy link
Author

Choose a reason for hiding this comment

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

well collectively we received 2% fees of invoice amount, 1% charge on smart contract from customer side and 1% charge on centralise when merchant claimed invoice settlement. ex. customer A pay $1000 worth of zeebu to merchant B, customer actually pay $1010 (where $10 is 1% fees) which will collect on invoice contract side.

Invoice contract will deduct 1% fees and send rest of $1000 to merchant, merchant will claim this settlement at PSP portal where he/she have to pay 1% fees, so here merchant will receive $990, ($10 will goes to portal fees account)

Kindly guide us what to do next?

const totalSupplySideRevenue = totalFees * 0.6 / 100;

return {dailyFees, totalFees, dailyUserFees, totalUserFees, dailyRevenue, totalRevenue, dailyHoldersRevenue, totalHoldersRevenue };
} catch (error) {
Copy link
Member

Choose a reason for hiding this comment

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

we prefer adapter failing over returning empty result

Copy link
Author

Choose a reason for hiding this comment

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

Kindly help or suggest to overcome the same!

Copy link
Author

Choose a reason for hiding this comment

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

should I remove exception handling?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes should remove try catch

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @dtmkeng , I removed the same and commited the code

remove exception handling as per suggestion by defillama team
@llamabutler
Copy link

The zeebu adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees zeebu

🦙 Running ZEEBU adapter 🦙
---------------------------------------------------
fees/zeebu/index.ts(89,1): error TS1128: Declaration or statement expected.

remove syntax error
@llamabutler
Copy link

The zeebu adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts fees zeebu

🦙 Running ZEEBU adapter 🦙
---------------------------------------------------
Start Date:	Tue, 14 Jan 2025 15:15:33 GMT
End Date:	Wed, 15 Jan 2025 15:15:33 GMT
---------------------------------------------------

BASE 👇
Backfill start time: 10/10/2024
Daily fees: 413.61 k
└─ Methodology: 2% collectively paid by merchant and customer
Total fees: 14.35 M
└─ Methodology: 2% collectively paid by merchant and customer
Daily user fees: 413.61 k
└─ Methodology: Daily fees
Total user fees: 14.35 M
└─ Methodology: Daily fees
Daily revenue: 413.61 k
└─ Methodology: Invoice fees
Total revenue: 14.35 M
└─ Methodology: Invoice fees
Daily holders revenue: 2.48 k
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
Total holders revenue: 86.10 k
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
End timestamp: 1736954132 (2025-01-15T15:15:32.000Z)


BSC 👇
Backfill start time: 30/6/2023
Daily fees: 0
└─ Methodology: 2% collectively paid by merchant and customer
Total fees: 90.19 M
└─ Methodology: 2% collectively paid by merchant and customer
Daily user fees: 0
Total user fees: 90.19 M
Daily revenue: 0
└─ Methodology: Invoice fees
Total revenue: 90.19 M
└─ Methodology: Invoice fees
Daily holders revenue: 0
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
Total holders revenue: 541.14 k
└─ Methodology: Staking rewards earned by veZBU holders, 0.6% of collected fees 
End timestamp: 1736954132 (2025-01-15T15:15:32.000Z)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants