-
Notifications
You must be signed in to change notification settings - Fork 1.8k
track prediction markets' notional volume #5764
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?
Changes from all commits
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||||||||||||||||||
| import { FetchOptions, SimpleAdapter } from "../../adapters/types"; | ||||||||||||||||||||||||||||
| import { CHAIN } from "../../helpers/chains"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const MARKETS = { | ||||||||||||||||||||||||||||
| const MARKETS:any = { | ||||||||||||||||||||||||||||
| [CHAIN.ABSTRACT]: '0x3e0F5F8F5Fb043aBFA475C0308417Bf72c463289', | ||||||||||||||||||||||||||||
| [CHAIN.LINEA]: '0x39e66ee6b2ddaf4defded3038e0162180dbef340', | ||||||||||||||||||||||||||||
| [CHAIN.BSC]: '0x39e66ee6b2ddaf4defded3038e0162180dbef340', | ||||||||||||||||||||||||||||
|
|
@@ -19,24 +19,27 @@ async function fetch({ createBalances, chain, api, getLogs }: FetchOptions) { | |||||||||||||||||||||||||||
| const dailyFees = createBalances(); | ||||||||||||||||||||||||||||
| const dailySupplySideRevenue = createBalances(); | ||||||||||||||||||||||||||||
| const dailyRevenue = createBalances(); | ||||||||||||||||||||||||||||
| const dailyNotionalVolume = createBalances(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const markets = await api.call({ abi: 'uint256[]:getMarkets', target: market }); | ||||||||||||||||||||||||||||
| const marketData = await api.multiCall({ target: market, abi: abi.getMarketAltData, calls: markets }) | ||||||||||||||||||||||||||||
| const marketFees = (await api.multiCall({ target: market, abi: abi.getMarketFees, calls: markets })) | ||||||||||||||||||||||||||||
| const marketMapping: any = {} | ||||||||||||||||||||||||||||
| markets.forEach((val, idx) => marketMapping[val] = { | ||||||||||||||||||||||||||||
| markets.forEach((val:any, idx:any) => marketMapping[val] = { | ||||||||||||||||||||||||||||
| token: marketData[idx].token, | ||||||||||||||||||||||||||||
| fees: marketFees[idx] | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
|
Comment on lines
27
to
31
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find the file
fd -t f "index.ts" | grep -E "fees.*myriadmarkets"Repository: DefiLlama/dimension-adapters Length of output: 99 🏁 Script executed: #!/bin/bash
# Check if the file exists and read the relevant lines
if [ -f "fees/myriadmarkets/index.ts" ]; then
echo "File exists. Reading lines 20-35 for context:"
sed -n '20,35p' fees/myriadmarkets/index.ts | cat -n
else
echo "File not found at fees/myriadmarkets/index.ts. Searching..."
find . -name "index.ts" -path "*myriad*" 2>/dev/null
fiRepository: DefiLlama/dimension-adapters Length of output: 913 🏁 Script executed: #!/bin/bash
# Check for biome configuration
ls -la | grep -i biome || echo "No biome config in root"
find . -name "biome.json" -o -name "biome.toml" 2>/dev/null | head -5Repository: DefiLlama/dimension-adapters Length of output: 148 🏁 Script executed: #!/bin/bash
# Read the biome configuration
cat biome.jsonRepository: DefiLlama/dimension-adapters Length of output: 1847 🌐 Web query:
💡 Result: Biome’s lint rule for “return statements inside
What it enforces:
Example that triggers it: arr.forEach(() => {
return 1; // flagged: should not return a value
});Fix patterns:
Config: {
"linter": {
"rules": {
"suspicious": {
"useIterableCallbackReturn": "error"
}
}
}
}Citations:
Fix forEach callback to satisfy Proposed fix- markets.forEach((val:any, idx:any) => marketMapping[val] = {
- token: marketData[idx].token,
- fees: marketFees[idx]
- })
+ markets.forEach((val: any, idx: any) => {
+ marketMapping[val] = {
+ token: marketData[idx].token,
+ fees: marketFees[idx],
+ }
+ })📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (2.3.13)[error] 28-28: This callback passed to forEach() iterable method should not return a value. Either remove this return or remove the returned value. (lint/suspicious/useIterableCallbackReturn) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| marketFees.forEach(i => { | ||||||||||||||||||||||||||||
| i.buyFees = i.buyFees.map(j => Number(j) / 1e18) | ||||||||||||||||||||||||||||
| i.buyFees = i.buyFees.map((j:any) => Number(j) / 1e18) | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| const tradeLogs = await getLogs({ target: market, eventAbi: abi.MarketActionTx, }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| tradeLogs.forEach(({ action, marketId, value }) => { | ||||||||||||||||||||||||||||
| tradeLogs.forEach(({ action, marketId, value, shares }) => { | ||||||||||||||||||||||||||||
| value = Number(value) | ||||||||||||||||||||||||||||
| action = Number(action) | ||||||||||||||||||||||||||||
| shares = Number(shares) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const { fees, token } = marketMapping[marketId] | ||||||||||||||||||||||||||||
| const isBuy = action === 0 | ||||||||||||||||||||||||||||
| const feeKey = isBuy ? 'buyFees' : 'sellFees' | ||||||||||||||||||||||||||||
|
|
@@ -47,6 +50,7 @@ async function fetch({ createBalances, chain, api, getLogs }: FetchOptions) { | |||||||||||||||||||||||||||
| case 0: // buy | ||||||||||||||||||||||||||||
| case 1: // sell | ||||||||||||||||||||||||||||
| dailyVolume.add(token, value); | ||||||||||||||||||||||||||||
| dailyNotionalVolume.add(token, shares); | ||||||||||||||||||||||||||||
| dailyFees.add(token, value * totalFee, isBuy ? 'BuyFee' : 'SellFee') | ||||||||||||||||||||||||||||
| dailySupplySideRevenue.add(token, value * distributorFee, 'DistributorFee') | ||||||||||||||||||||||||||||
| dailySupplySideRevenue.add(token, value * fee, 'LPFee') | ||||||||||||||||||||||||||||
|
|
@@ -58,9 +62,10 @@ async function fetch({ createBalances, chain, api, getLogs }: FetchOptions) { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||
| dailyVolume, | ||||||||||||||||||||||||||||
| dailyNotionalVolume, | ||||||||||||||||||||||||||||
| dailyFees, | ||||||||||||||||||||||||||||
| dailyRevenue, | ||||||||||||||||||||||||||||
| dailyProtocolRevenue: dailyRevenue.clone(), | ||||||||||||||||||||||||||||
| dailyProtocolRevenue: dailyRevenue, | ||||||||||||||||||||||||||||
| dailyHoldersRevenue: 0, | ||||||||||||||||||||||||||||
| dailySupplySideRevenue | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
Guard against null/undefined totals from Dune.
If
total_volume_usdortotal_notional_volumeis null/undefined for a day, the current division yieldsNaN. Consider defaulting to0beforeaddUSDValue.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents