Skip to content
Open
Show file tree
Hide file tree
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
52 changes: 52 additions & 0 deletions fees/tectonic/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { FetchOptions, FetchResult, SimpleAdapter } from "../../adapters/types";
import { compoundV2Export } from "../../helpers/compoundV2";
import { CHAIN } from "../../helpers/chains";

const comptrollers: any = {
[CHAIN.CRONOS]: [
"0xb3831584acb95ed9ccb0c11f677b5ad01deaeec0",
"0x8312A8d5d1deC499D00eb28e1a2723b13aA53C1e",
"0x7E0067CEf1e7558daFbaB3B1F8F6Fa75Ff64725f",
]
};

async function fetch(options: FetchOptions): Promise<FetchResult> {
const dailyFees = options.createBalances();
const dailyRevenue = options.createBalances();
const dailySupplySideRevenue = options.createBalances();

await Promise.all(comptrollers[options.chain].map(async (comptroller: string) => {
const { adapter } = compoundV2Export({ [options.chain]: comptroller });
const data = await (adapter!.cronos.fetch! as any)(options);

dailyFees.add(data.dailyFees);
dailyRevenue.add(data.dailyRevenue);
dailySupplySideRevenue.add(data.dailySupplySideRevenue);
}));

return {
dailyFees,
dailyRevenue,
dailySupplySideRevenue,
dailyHoldersRevenue:dailyRevenue.clone(0.5),
dailyProtocolRevenue:dailyRevenue.clone(0.5),
}
}

const methodology = {
Fees: "Total interest paid by borrowers",
Revenue: "Protocol and holders share of interest",
ProtocolRevenue: "50% of the revenue goes to treasury",
HoldersRevenue: "50% of the revenue goes to TONIC stakers",
SupplySideRevenue: "Interest paid to lenders in liquidity pools",
};

const adapter: SimpleAdapter = {
version: 2,
fetch,
chains: [CHAIN.CRONOS],
methodology,
start: '2021-12-22'
}

export default adapter;
6 changes: 3 additions & 3 deletions helpers/compoundV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export function compoundV2Export(config: IJSON<string>, exportOptions?: any) {
blacklists: exportOptions.blacklists,
})
: await getFees(market, options, {})
const dailyHoldersRevenue = dailyRevenue
const dailyProtocolRevenue = dailyRevenue.clone()
const dailySupplySideRevenue = options.createBalances()
dailySupplySideRevenue.addBalances(dailyFees)
Object.entries(dailyRevenue.getBalances()).forEach(([token, balance]) => {
dailySupplySideRevenue.addTokenVannila(token, Number(balance) * -1)
})
return { dailyFees, dailyRevenue, dailySupplySideRevenue, dailyHoldersRevenue }
return { dailyFees, dailyRevenue, dailySupplySideRevenue, dailyHoldersRevenue:0,dailyProtocolRevenue }
Copy link
Member

Choose a reason for hiding this comment

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

any reason behind making dailyHoldersRevenue as 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compound doesnt have holders revenue right? Everything goes to treasury

Copy link
Contributor

Choose a reason for hiding this comment

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

@KPHEMRAJ I pushed a update for compound export helper, can you check and update again please?

}),
}
})
Expand All @@ -136,7 +136,7 @@ export function compoundV2Export(config: IJSON<string>, exportOptions?: any) {
version: 2,
methodology: {
Fees: "Total interest paid by borrowers",
Revenue: "Protocol's share of interest treasury",
Revenue: "Protocol and holders share of interest",
ProtocolRevenue: "Protocol's share of interest into treasury",
HoldersRevenue: "Share of interest into protocol governance token holders.",
SupplySideRevenue: "Interest paid to lenders in liquidity pools"
Expand Down
Loading