add mango group filtering in api

This commit is contained in:
Tyler Shipe 2021-08-25 13:25:57 -04:00
parent 17f95d4105
commit 83eaed3284
1 changed files with 7 additions and 2 deletions

View File

@ -83,9 +83,14 @@ app.get("/spot/change/24", async (req, res) => {
app.get("/perp/funding_rate", async (req, res) => {
try {
const market = req.query.market as string
const mangoGroup = req.query.mangoGroup as string
if (!market) {
throw new Error("Missing mangoGroup param")
}
if (!mangoGroup) {
throw new Error("Missing mangoGroup param")
}
const stats = await sequelize.query(
`SELECT
@ -95,9 +100,9 @@ app.get("/perp/funding_rate", async (req, res) => {
"baseOraclePrice",
"time"
FROM perp_market_stats
WHERE time > NOW() - interval '1 hour' AND "name" = :market`,
WHERE time > NOW() - interval '1 hour' AND "name" = :market AND "mangoGroup" = :mangoGroup`,
{
replacements: { market },
replacements: { market, mangoGroup },
type: QueryTypes.SELECT,
}
)