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
87 changes: 87 additions & 0 deletions fees/ipor-protocol/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { getConfig } from "../../helpers/cache";
import { CHAIN } from "../../helpers/chains";

const IPOR_GITHUB_ADDRESSES_URL = "https://raw.githubusercontent.com/IPOR-Labs/ipor-abi/refs/heads/main/mainnet/addresses.json";

const eventAbis = {
managementFee: "event ManagementFeeRealized(uint256 unrealizedFeeInUnderlying, uint256 unrealizedFeeInShares)",
}

const methodology = {
Fees: 'Management fees are included in event logs emitted by each vault contract.',
Revenue: 'Total fees collected by the protocol.',

Choose a reason for hiding this comment

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

hmm, this doesnt match our methodology:

image

https://docs.llama.fi/list-your-project/other-dashboards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it the wording that is an issue? If I remove collected by the protocol from the Fees text would that be more accurate?

}

const fetch = async (options: FetchOptions) => {
const dailyFees = options.createBalances()
const dailyRevenue = options.createBalances()

const config = await getConfig('ipor/assets', IPOR_GITHUB_ADDRESSES_URL);
const chainConfig = config[options.chain];
if (!chainConfig || !chainConfig.vaults) {
return { dailyFees, dailyRevenue };
}

const vaults = chainConfig.vaults.map((vault: any) => vault.PlasmaVault);

const logs = await options.api.getLogs({
targets: vaults,
eventAbi: eventAbis.managementFee,
fromBlock: await options.getFromBlock(),
toBlock: await options.getToBlock(),
})

// Call asset() for each vault to get underlying tokens
const assetCalls = await options.api.multiCall({
abi: 'function asset() view returns (address)',
calls: vaults,
permitFailure: true,
})

const vaultToToken: Record<string, string> = {}
vaults.forEach((v: string, i: number) => {
if (assetCalls[i]) {
vaultToToken[v.toLowerCase()] = assetCalls[i]
}
})

logs.forEach((log: any) => {
const token = vaultToToken[log.address.toLowerCase()]
if (token) {
dailyFees.add(token, log.args[0])
dailyRevenue.add(token, log.args[0])
}
})

return { dailyFees, dailyRevenue }
}

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ETHEREUM]: {
fetch,
start: "9-29-2024",
},
[CHAIN.ARBITRUM]: {
fetch,
start: "9-3-2024",
},
[CHAIN.BASE]: {
fetch,
start: "11-8-2024",
},
[CHAIN.UNICHAIN]: {
fetch,
start: "6-18-2025",
},
[CHAIN.TAC]: {
fetch,
start: "7-11-2025",
},
},
methodology
}

export default adapter;
Loading