Skip to content

Commit 1734c59

Browse files
committed
Track markIt Fee/Revenue/Volumes
1 parent 8be321e commit 1734c59

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

fees/markit.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* Markit (Base) — LP-underwritten prediction markets.
3+
*
4+
* Factory deploys standalone MarketEngine contracts per market. LpVault aggregates LP capital and
5+
* allocates it across markets. No AMM / order book; users buy sides and hold until resolution or
6+
* hedge by buying the opposite side (no sell).
7+
*
8+
* MarketCreated(address indexed engine, string question, uint256 bettingCloseTime, uint256 resolveTime)
9+
* BetPlaced(address indexed user, uint8 side, uint256 usdcIn, uint256 fee, uint256 protocolFee,
10+
* uint256 sharesOut, uint256 markPrice)
11+
*
12+
* Fee structure: 2% protocolFee + dynamic LP fee (~1% base ± skew adjustment).
13+
*/
14+
15+
import { FetchOptions, SimpleAdapter } from "../adapters/types";
16+
import { CHAIN } from "../helpers/chains";
17+
import { METRIC } from "../helpers/metrics";
18+
19+
const MARKIT_FACTORY = "0xB86d5c873daaD15817b424f6d55d7641DAbb00E9";
20+
const FACTORY_START_BLOCK = 42886013;
21+
22+
const EVENT_MARKET_CREATED =
23+
"event MarketCreated(address indexed engine, string question, uint256 bettingCloseTime, uint256 resolveTime)";
24+
const EVENT_BET_PLACED =
25+
"event BetPlaced(address indexed user, uint8 side, uint256 usdcIn, uint256 fee, uint256 protocolFee, uint256 sharesOut, uint256 markPrice)";
26+
27+
const fetch = async (options: FetchOptions) => {
28+
const { getLogs, createBalances } = options;
29+
30+
const marketCreatedLogs = await getLogs({
31+
target: MARKIT_FACTORY,
32+
eventAbi: EVENT_MARKET_CREATED,
33+
fromBlock: FACTORY_START_BLOCK,
34+
cacheInCloud: true,
35+
});
36+
37+
const engines: string[] = marketCreatedLogs.map((l: any) => l.engine.toLowerCase());
38+
39+
const dailyVolume = createBalances();
40+
const dailyFees = createBalances();
41+
const dailySupplySideRevenue = createBalances();
42+
const dailyProtocolRevenue = createBalances();
43+
44+
if (!engines.length) {
45+
return { dailyVolume, dailyFees, dailyRevenue: dailyProtocolRevenue, dailySupplySideRevenue, dailyProtocolRevenue };
46+
}
47+
48+
const betLogs = await getLogs({
49+
targets: engines,
50+
eventAbi: EVENT_BET_PLACED,
51+
flatten: true,
52+
});
53+
54+
for (const log of betLogs) {
55+
const usdc = Number(log.usdcIn) / 1e6;
56+
const lp = Number(log.fee) / 1e6;
57+
const protocol = Number(log.protocolFee) / 1e6;
58+
59+
dailyVolume.addUSDValue(usdc);
60+
dailyFees.addUSDValue(lp, METRIC.LP_FEES);
61+
dailyFees.addUSDValue(protocol, METRIC.PROTOCOL_FEES);
62+
dailySupplySideRevenue.addUSDValue(lp, METRIC.LP_FEES);
63+
dailyProtocolRevenue.addUSDValue(protocol, METRIC.PROTOCOL_FEES);
64+
}
65+
66+
return {
67+
dailyVolume,
68+
dailyFees,
69+
dailyRevenue: dailyProtocolRevenue,
70+
dailySupplySideRevenue,
71+
dailyProtocolRevenue,
72+
};
73+
};
74+
75+
const adapter: SimpleAdapter = {
76+
version: 2,
77+
fetch,
78+
chains: [CHAIN.BASE],
79+
start: "2026-03-03",
80+
methodology: {
81+
Fees: "LP fee ~1% base ± skew, protocol fee 2%) from each BetPlaced event.",
82+
Revenue: "2% trading fees collected on every bet.",
83+
SupplySideRevenue: "Dynamic LP fee ~1% base ± skew adjustment of the fees",
84+
ProtocolRevenue: "2% trading fees collected on every bet.",
85+
},
86+
breakdownMethodology: {
87+
Fees: {
88+
[METRIC.LP_FEES]: "Dynamic LP fee ~1% base ± skew adjustment of the fees",
89+
[METRIC.PROTOCOL_FEES]: "2% trading fees collected on every bet.",
90+
},
91+
Revenue: {
92+
[METRIC.PROTOCOL_FEES]: "2% trading fees collected on every bet.",
93+
},
94+
SupplySideRevenue: {
95+
[METRIC.LP_FEES]: "Dynamic LP fee ~1% base ± skew adjustment of the fees",
96+
},
97+
ProtocolRevenue: {
98+
[METRIC.PROTOCOL_FEES]: "2% trading fees collected on every bet.",
99+
},
100+
},
101+
};
102+
103+
export default adapter;

0 commit comments

Comments
 (0)