forked from sushi-labs/sushiswap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: run sort script and add to pre-commit hook
- Loading branch information
1 parent
ae897ec
commit e4af9ed
Showing
2,064 changed files
with
52,958 additions
and
74,840 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
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@sushiswap/eslint-config'], | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm check | ||
pnpm sort | ||
pnpm run check | ||
# npm test |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// @ts-check | ||
/** @type {import('mocha').MochaOptions} */ | ||
const mochaConfig = { | ||
require: ["ts-node/register/files"], | ||
require: ['ts-node/register/files'], | ||
timeout: 20000, | ||
}; | ||
} | ||
|
||
module.exports = mochaConfig; | ||
module.exports = mochaConfig |
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
This file was deleted.
Oops, something went wrong.
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 @@ | ||
module.exports = require('@sushiswap/prettier-config').default |
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 |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require("@sushiswap/eslint-config"); | ||
module.exports = require('@sushiswap/eslint-config') |
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 |
---|---|---|
@@ -1,48 +1,48 @@ | ||
import type { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import { getUnixTime } from "date-fns"; | ||
import type { VercelRequest, VercelResponse } from '@vercel/node' | ||
import { getUnixTime } from 'date-fns' | ||
|
||
import redis from "../../lib/redis"; | ||
import redis from '../../lib/redis' | ||
|
||
export default async (request: VercelRequest, response: VercelResponse) => { | ||
const chainId = request.query.chainId as string; | ||
const chainId = request.query.chainId as string | ||
|
||
if (chainId) { | ||
const data = await redis.hget("farms", chainId); | ||
const data = await redis.hget('farms', chainId) | ||
|
||
if (!data) { | ||
return response.status(503); | ||
return response.status(503) | ||
} | ||
|
||
const json = JSON.parse(data); | ||
const json = JSON.parse(data) | ||
|
||
const now = getUnixTime(Date.now()); | ||
const now = getUnixTime(Date.now()) | ||
|
||
return response.status(200).json({ | ||
...json, | ||
updatedSecondsAgo: now - json.updatedAtTimestamp, | ||
}); | ||
}) | ||
} | ||
|
||
const data = await redis.hgetall("farms"); | ||
const data = await redis.hgetall('farms') | ||
|
||
if (!data) { | ||
return response.status(503); | ||
return response.status(503) | ||
} | ||
|
||
const now = getUnixTime(Date.now()); | ||
const now = getUnixTime(Date.now()) | ||
|
||
return response.status(200).json( | ||
Object.fromEntries( | ||
Object.entries(data).map(([chainId, data]) => { | ||
const json = JSON.parse(data); | ||
const json = JSON.parse(data) | ||
return [ | ||
chainId, | ||
{ | ||
...json, | ||
updatedSecondsAgo: now - json.updatedAtTimestamp, | ||
}, | ||
]; | ||
] | ||
}) | ||
) | ||
); | ||
}; | ||
) | ||
} |
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 |
---|---|---|
@@ -1,73 +1,70 @@ | ||
import type { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import type { VercelRequest, VercelResponse } from '@vercel/node' | ||
|
||
import redis from "../../lib/redis"; | ||
import redis from '../../lib/redis' | ||
|
||
interface ChainIdFarmMap { | ||
[key: string]: { | ||
chainId: number; | ||
farms: FarmsMap; | ||
}; | ||
chainId: number | ||
farms: FarmsMap | ||
} | ||
} | ||
|
||
interface FarmsMap { | ||
[poolAddress: string]: Farm; | ||
[poolAddress: string]: Farm | ||
} | ||
|
||
interface Farm { | ||
id: string; | ||
chainId: number; | ||
pool: string; | ||
id: string | ||
chainId: number | ||
pool: string | ||
incentives: { | ||
apr: number; | ||
rewardPerDay: number; | ||
apr: number | ||
rewardPerDay: number | ||
rewardToken: { | ||
address: string; | ||
decimals: number; | ||
symbol: string; | ||
}; | ||
address: string | ||
decimals: number | ||
symbol: string | ||
} | ||
rewarder: { | ||
address: string; | ||
type: "Primary" | "Secondary"; | ||
}; | ||
}[]; | ||
chefType: "MasterChefV1" | "MasterChefV2" | "MiniChef"; | ||
poolType: "Legacy" | "Trident" | "Kashi" | "Unknown"; | ||
address: string | ||
type: 'Primary' | 'Secondary' | ||
} | ||
}[] | ||
chefType: 'MasterChefV1' | 'MasterChefV2' | 'MiniChef' | ||
poolType: 'Legacy' | 'Trident' | 'Kashi' | 'Unknown' | ||
} | ||
|
||
export default async (request: VercelRequest, response: VercelResponse) => { | ||
const data = await redis.hgetall("farms"); | ||
const data = await redis.hgetall('farms') | ||
|
||
if (!data) { | ||
return response.status(503); | ||
return response.status(503) | ||
} | ||
|
||
return response.status(200).json( | ||
Object.entries(data).reduce( | ||
(previousValue: Farm[], [key, value]: [string, string]) => { | ||
const { | ||
chainId, | ||
farms, | ||
}: { | ||
chainId: number; | ||
farms: FarmsMap; | ||
} = JSON.parse(value); | ||
return [ | ||
...previousValue, | ||
...Object.entries(farms).reduce<Farm[]>( | ||
(previousValue, [key, value]) => [ | ||
...previousValue, | ||
{ | ||
...value, | ||
id: `${chainId}:${key}`, | ||
chainId, | ||
pool: key, | ||
}, | ||
], | ||
[] | ||
), | ||
]; | ||
}, | ||
[] | ||
) | ||
); | ||
}; | ||
Object.entries(data).reduce((previousValue: Farm[], [key, value]: [string, string]) => { | ||
const { | ||
chainId, | ||
farms, | ||
}: { | ||
chainId: number | ||
farms: FarmsMap | ||
} = JSON.parse(value) | ||
return [ | ||
...previousValue, | ||
...Object.entries(farms).reduce<Farm[]>( | ||
(previousValue, [key, value]) => [ | ||
...previousValue, | ||
{ | ||
...value, | ||
id: `${chainId}:${key}`, | ||
chainId, | ||
pool: key, | ||
}, | ||
], | ||
[] | ||
), | ||
] | ||
}, []) | ||
) | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import Redis from "ioredis"; | ||
import Redis from 'ioredis' | ||
|
||
if (!process.env.REDIS_URL) throw new Error("REDIS_URL is required"); | ||
if (!process.env.REDIS_URL) throw new Error('REDIS_URL is required') | ||
|
||
const redis = new Redis(process.env.REDIS_URL); | ||
const redis = new Redis(process.env.REDIS_URL) | ||
|
||
export default redis; | ||
export default redis |
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 |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require("@sushiswap/eslint-config"); | ||
module.exports = require('@sushiswap/eslint-config') |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require("@sushiswap/eslint-config"); | ||
module.exports = require('@sushiswap/eslint-config') |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require("@sushiswap/eslint-config"); | ||
module.exports = require('@sushiswap/eslint-config') |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import CHAINLINK_TOKEN_LIST from "@sushiswap/chainlink-token-list"; | ||
import type { VercelRequest, VercelResponse } from "@vercel/node"; | ||
import CHAINLINK_TOKEN_LIST from '@sushiswap/chainlink-token-list' | ||
import type { VercelRequest, VercelResponse } from '@vercel/node' | ||
|
||
export default (request: VercelRequest, response: VercelResponse) => { | ||
return response.status(200).json(CHAINLINK_TOKEN_LIST); | ||
}; | ||
return response.status(200).json(CHAINLINK_TOKEN_LIST) | ||
} |
Oops, something went wrong.