Skip to content
Open
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
62 changes: 62 additions & 0 deletions fees/moneyfi/index.ts
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();
Copy link
Member

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

Copy link
Member

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?

Copy link
Author

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

Copy link
Member

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

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;
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

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

our contract doesn't have that now can i make API?

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

The 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],
Copy link
Member

Choose a reason for hiding this comment

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

please add all chains where moneyfi operates, core and base

Copy link
Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

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

okay then it's fine as long aptos is your main chain.

Copy link
Author

Choose a reason for hiding this comment

The 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;
Loading