-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add revenue moneyfi #4317
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
base: master
Are you sure you want to change the base?
Add revenue moneyfi #4317
Changes from all commits
1d5e868
852bd73
5fdbaba
beb8f3d
37b02e3
bf615e7
cc3d269
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { SimpleAdapter, FetchOptions } from "../../adapters/types"; | ||
| import { CHAIN } from "../../helpers/chains"; | ||
| import { getEnv } from "../../helpers/env"; | ||
| import { httpPost } from "../../utils/fetchURL"; | ||
|
|
||
| const BASE = getEnv("APTOS_RPC") as string; | ||
| const API = BASE.endsWith("/v1") ? BASE : `${BASE}/v1`; | ||
| const VIEW_URL = `${API}/view`; | ||
| const VIEW_FN = "0x97c9ffc7143c5585090f9ade67d19ac95f3b3e7008ed86c73c947637e2862f56::vault::get_fee"; | ||
|
|
||
| const USDC_TOKEN = "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"; | ||
| const USDT_TOKEN = "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b"; | ||
|
|
||
| const TOKENS = [ | ||
| { arg: USDC_TOKEN, decimals: 6 }, | ||
| { arg: USDT_TOKEN, decimals: 6 }, | ||
| ]; | ||
|
|
||
|
|
||
| const fetch = async (options: FetchOptions) => { | ||
| const dailyFees = options.createBalances(); | ||
| const dailyProtocolRevenue = options.createBalances(); | ||
|
|
||
| const results = await Promise.all( | ||
| TOKENS.map(t => | ||
| httpPost(VIEW_URL, { | ||
| function: VIEW_FN, | ||
| type_arguments: [], | ||
| arguments: [t.arg], | ||
| }, undefined, { withMetadata: true }) | ||
| ) | ||
| ); | ||
|
|
||
| let usdTotal = 0; | ||
| results.forEach((res, i) => { | ||
| const raw = BigInt(Array.isArray(res.data) ? res.data[0] : res.data); | ||
| usdTotal += (Number(raw) * 5) / 10 ** TOKENS[i].decimals; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will run this adapter daily so we have to make sure it doesn't add the fees in cumulative way, it should only return any given day fees. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am calculating the total amount from past to present. Do you want me to pay interest for each day I can call through my API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's daily protocol fees, so it has to only show current day fees There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. our contract doesn't have that now can i make API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, but plz add methodology you use for calculating the protocol fees share There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oke thanks you |
||
| }); | ||
|
|
||
| dailyProtocolRevenue.addUSDValue(usdTotal); | ||
|
|
||
| return { | ||
| dailyFees, | ||
| dailyRevenue: dailyProtocolRevenue, | ||
| dailyProtocolRevenue | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
| const adapter: SimpleAdapter = { | ||
| version: 2, | ||
| fetch, | ||
| chains: [CHAIN.APTOS], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add all chains where moneyfi operates, core and base There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are currently working on Aptos only, we will update it next time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay then it's fine as long aptos is your main chain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks |
||
| start: "2025-08-04", | ||
| methodology: { | ||
| Fees: "Yield generated by the Moneyfi protocol.", | ||
| Revenue: "Management and performance fees of moneyfi protocol.", | ||
| ProtocolRevenue: "Management and performance fees of moneyfi protocol.", | ||
| }, | ||
| }; | ||
|
|
||
| export default adapter; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to also track yield earned by user through the protocol too. i've added methodology
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TuanTwendee we need to track this, too, is there any fixed % which goes to the protocol from generated yield? what's formula?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are collecting 20% from user profits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add this as as protocolrevenue and remaining 80% as the supplysiderevenue