-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f70032
commit f83c0cf
Showing
2 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
BreakdownAdapter, | ||
FetchResultVolume, | ||
ProtocolType, | ||
} from "../../adapters/types"; | ||
|
||
import fetchURL from "../../utils/fetchURL"; | ||
|
||
const urlTotalStats = | ||
"https://api.mngo.cloud/data/v4/stats/protocol-total-volume-fees"; | ||
const urlDailyStats = | ||
"https://api.mngo.cloud/data/v4/stats/protocol-daily-volume-fees"; | ||
|
||
interface TotalStats { | ||
total_volume: number; | ||
total_fees: number; | ||
spot_volume: number; | ||
perp_volume: number; | ||
spot_fees: number; | ||
perp_fees: number; | ||
} | ||
interface DailyStats { | ||
total_volume_24h: number; | ||
total_fees_24h: number; | ||
spot_volume_24h: number; | ||
perp_volume_24h: number; | ||
spot_fees_24h: number; | ||
perp_fees_24h: number; | ||
} | ||
|
||
const fetchSpotVolume = async ( | ||
timestamp: number, | ||
): Promise<FetchResultVolume> => { | ||
const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; | ||
const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; | ||
return { | ||
dailyVolume: dailyStats?.spot_volume_24h.toString(), | ||
totalVolume: totalStats?.spot_volume.toString(), | ||
timestamp: timestamp, | ||
}; | ||
}; | ||
|
||
const fetchPerpVolume = async ( | ||
timestamp: number, | ||
): Promise<FetchResultVolume> => { | ||
const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; | ||
const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; | ||
return { | ||
dailyVolume: dailyStats?.perp_volume_24h.toString(), | ||
totalVolume: totalStats?.perp_volume.toString(), | ||
timestamp: timestamp, | ||
}; | ||
}; | ||
|
||
const adapter: BreakdownAdapter = { | ||
breakdown: { | ||
spot: { | ||
solana: { | ||
fetch: fetchSpotVolume, | ||
runAtCurrTime: true, | ||
customBackfill: undefined, | ||
start: async () => 0, | ||
}, | ||
}, | ||
perp: { | ||
solana: { | ||
fetch: fetchPerpVolume, | ||
runAtCurrTime: true, | ||
customBackfill: undefined, | ||
start: async () => 0, | ||
}, | ||
}, | ||
}, | ||
protocolType: ProtocolType.PROTOCOL, | ||
}; | ||
|
||
export default adapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { | ||
BreakdownAdapter, | ||
FetchResultFees, | ||
ProtocolType, | ||
SimpleAdapter, | ||
} from "../adapters/types"; | ||
import fetchURL from "../utils/fetchURL"; | ||
|
||
const urlTotalStats = | ||
"https://api.mngo.cloud/data/v4/stats/protocol-total-volume-fees"; | ||
const urlDailyStats = | ||
"https://api.mngo.cloud/data/v4/stats/protocol-daily-volume-fees"; | ||
|
||
interface TotalStats { | ||
total_volume: number; | ||
total_fees: number; | ||
spot_volume: number; | ||
perp_volume: number; | ||
spot_fees: number; | ||
perp_fees: number; | ||
} | ||
interface DailyStats { | ||
total_volume_24h: number; | ||
total_fees_24h: number; | ||
spot_volume_24h: number; | ||
perp_volume_24h: number; | ||
spot_fees_24h: number; | ||
perp_fees_24h: number; | ||
} | ||
|
||
const fetchSpotFees = async (timestamp: number): Promise<FetchResultFees> => { | ||
const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; | ||
const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; | ||
return { | ||
dailyFees: dailyStats?.total_fees_24h.toString(), | ||
totalFees: totalStats?.total_fees.toString(), | ||
timestamp: timestamp, | ||
}; | ||
}; | ||
|
||
const fetchPerpFees = async (timestamp: number): Promise<FetchResultFees> => { | ||
const totalStats: TotalStats = (await fetchURL(urlTotalStats)).data; | ||
const dailyStats: DailyStats = (await fetchURL(urlDailyStats)).data; | ||
return { | ||
dailyFees: dailyStats?.total_fees_24h.toString(), | ||
totalFees: totalStats?.total_fees.toString(), | ||
timestamp: timestamp, | ||
}; | ||
}; | ||
|
||
const adapter: BreakdownAdapter = { | ||
breakdown: { | ||
spot: { | ||
solana: { | ||
fetch: fetchSpotFees, | ||
runAtCurrTime: true, | ||
customBackfill: undefined, | ||
start: async () => 0, | ||
meta: { | ||
methodology: { | ||
Fees: "Swap fees are 0.1%, with a fee of 0.2% for stop-loss swaps. CLOB maker/taker fees are -0.02%/0.04%.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
perp: { | ||
solana: { | ||
fetch: fetchPerpFees, | ||
runAtCurrTime: true, | ||
customBackfill: undefined, | ||
start: async () => 0, | ||
meta: { | ||
methodology: { | ||
Fees: "Maker/taker fees are -0.03%/0.1%. Stop-loss orders have a fee of 0.2%", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
protocolType: ProtocolType.PROTOCOL, | ||
}; | ||
|
||
export default adapter; |