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.
Merge branch 'master' of https://github.com/sushiswap/sushiswap into …
…feature/farms-api
- Loading branch information
Showing
116 changed files
with
4,653 additions
and
1,391 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 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 @@ | ||
REDIS_URL= |
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 @@ | ||
.vercel |
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 @@ | ||
# Farm |
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,29 @@ | ||
import type { VercelRequest, VercelResponse } from '@vercel/node' | ||
import { getUnixTime } from 'date-fns' | ||
|
||
import redis from '../../lib/redis' | ||
|
||
export default async (request: VercelRequest, response: VercelResponse) => { | ||
const data = await redis.hgetall('farms') | ||
|
||
if (!data) { | ||
return response.status(204) | ||
} | ||
|
||
const now = getUnixTime(Date.now()) | ||
|
||
return response.status(200).json( | ||
Object.fromEntries( | ||
Object.entries(data).map(([chainId, 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Redis from 'ioredis' | ||
|
||
if (!process.env.REDIS_URL) throw new Error('REDIS_URL is required') | ||
|
||
const redis = new Redis(process.env.REDIS_URL) | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "farm", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"lint": "eslint --fix ." | ||
}, | ||
"dependencies": { | ||
"@vercel/node": "^2.2.0", | ||
"date-fns": "2.x", | ||
"ioredis": "5.x" | ||
}, | ||
"devDependencies": { | ||
"@sushiswap/eslint-config": "workspace:*", | ||
"@sushiswap/jest-config": "workspace:*", | ||
"@sushiswap/prettier-config": "workspace:*", | ||
"@sushiswap/typescript-config": "workspace:*" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"exclude": ["node_modules"], | ||
"extends": "@sushiswap/typescript-config/node16.json", | ||
"include": ["."] | ||
} |
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,12 @@ | ||
{ | ||
"headers":[ | ||
{ | ||
"source": "/(.*)", | ||
"headers": [ | ||
{ "key": "Access-Control-Allow-Origin", "value": "*" }, | ||
{ "key": "Access-Control-Allow-Methods", "value": "GET" } | ||
] | ||
} | ||
], | ||
"rewrites": [{ "source": "/v0", "destination": "/api/v0" }] | ||
} |
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,42 +1,48 @@ | ||
import { ChainId } from '@sushiswap/chain' | ||
|
||
export const ENABLED_NETWORKS = [ | ||
// ChainId.ETHEREUM, | ||
ChainId.AVALANCHE, | ||
ChainId.ARBITRUM, | ||
ChainId.BSC, | ||
// ChainId.CELO, | ||
ChainId.CELO, | ||
ChainId.FANTOM, | ||
ChainId.FUSE, | ||
ChainId.GNOSIS, | ||
ChainId.MOONBEAM, | ||
ChainId.MOONRIVER, | ||
// ChainId.HARMONY, | ||
// ChainId.FANTOM, | ||
// ChainId.POLYGON, | ||
] | ||
|
||
const GRAPH_HOST_ENDPOINT = 'api.thegraph.com/subgraphs/name' | ||
|
||
export const EXCHANGE_SUBGRAPH_NAME: Record<number | string, string> = { | ||
[ChainId.ETHEREUM]: 'sushiswap/sushiswap-ethereum', | ||
[ChainId.AVALANCHE]: 'sushiswap/sushiswap-avalanche', | ||
[ChainId.ARBITRUM]: 'sushiswap/sushiswap-arbitrum', | ||
[ChainId.BSC]: 'sushiswap/sushiswap-bsc', | ||
[ChainId.CELO]: 'sushiswap/sushiswap-celo', | ||
[ChainId.FANTOM]: 'sushiswap/sushiswap-fantom', | ||
[ChainId.FUSE]: 'sushiswap/sushiswap-fuse', | ||
[ChainId.GNOSIS]: 'sushiswap/sushiswap-gnosis', | ||
[ChainId.MOONBEAM]: 'sushiswap/sushiswap-moonbeam', | ||
[ChainId.MOONRIVER]: 'sushiswap/sushiswap-moonriver', | ||
[ChainId.HARMONY]: 'sushiswap/sushiswap-harmony', | ||
[ChainId.FANTOM]: 'sushiswap/sushiswap-fantom', | ||
[ChainId.POLYGON]: 'sushiswap/sushiswap-polygon', | ||
} | ||
|
||
export const GRAPH_HOST = { | ||
[ChainId.ETHEREUM]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.AVALANCHE]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.ARBITRUM]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.BSC]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.CELO]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.FANTOM]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.FUSE]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.GNOSIS]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.MOONBEAM]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.MOONRIVER]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.HARMONY]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.FANTOM]: GRAPH_HOST_ENDPOINT, | ||
[ChainId.POLYGON]: GRAPH_HOST_ENDPOINT, | ||
} |
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
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,11 +1,10 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next' | ||
|
||
import { getPairs } from '../../lib/api' | ||
import { QuerypairsArgs } from '.graphclient' | ||
import { getPairs, GetPairsQuery } from '../../lib/api' | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
res.setHeader('Cache-Control', 'public, s-maxage=10, stale-while-revalidate=59') | ||
const { query } = req | ||
const pairs = await getPairs(query as unknown as QuerypairsArgs & { networks: string }) | ||
res.setHeader('Cache-Control', 'public, s-maxage=900, stale-while-revalidate=3600') | ||
const query = req.query as unknown | ||
const pairs = await getPairs(query as GetPairsQuery) | ||
res.status(200).send(JSON.stringify(pairs)) | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @ts-check | ||
/** @type {import('next-seo').DefaultSeoProps} */ | ||
export default { | ||
titleTemplate: '%s | Furo', | ||
defaultTitle: 'Furo', | ||
description: 'Earn, stream and automate your DAO salaries and token vesting with Furo.', | ||
// canonical: 'https://sushi.com/furo', | ||
// mobileAlternate: { | ||
// media: '', | ||
// href: '', | ||
// }, | ||
// languageAlternates: [{ hrefLang: "en", href: "https://sushi.com/furo" }], | ||
twitter: { | ||
handle: '@sushiswap', | ||
site: '@sushiswap', | ||
cardType: 'summary_large_image', | ||
}, | ||
openGraph: { | ||
// url: 'https://sushi.com/furo', | ||
type: 'website', | ||
title: 'Furo', | ||
description: 'and token vesting with Furo. and token vesting with Furo.', | ||
// images: [], | ||
// videos: [], | ||
// locale: 'en_IE', | ||
site_name: 'Sushi', | ||
}, | ||
} |
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
Oops, something went wrong.