Skip to content

Commit

Permalink
chore: sweep swoop
Browse files Browse the repository at this point in the history
  • Loading branch information
LufyCZ committed Sep 29, 2024
1 parent ad32687 commit aa9f156
Show file tree
Hide file tree
Showing 189 changed files with 125 additions and 13,644 deletions.
2 changes: 0 additions & 2 deletions apis/tokens/api/v1/[chainId]/[address].ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const handler = async (request: VercelRequest, response: VercelResponse) => {

const tokenList = await fetchTokensFromLists(chainId)

// const result = await fetch(`https://tokens.sushi.com/v1/${chainId}`)
// const tokenList = (await result.json()) as TokenInfo[]
const json = tokenList.find(
(t) => t.address.toLowerCase() === address.toLowerCase(),
)
Expand Down
3 changes: 0 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
"@rise-wallet/wallet-adapter": "^0.1.2",
"@sentry/nextjs": "8.30.0",
"@snapshot-labs/snapshot.js": "^0.9.8",
"@sushiswap/bonds-sdk": "workspace:*",
"@sushiswap/client": "workspace:*",
"@sushiswap/database": "workspace:*",
"@sushiswap/graph-client": "workspace:*",
"@sushiswap/hooks": "workspace:*",
"@sushiswap/nextjs-config": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client'

import { parseArgs } from '@sushiswap/client'
import { useRouter } from 'next/navigation'
import {
Dispatch,
Expand All @@ -13,6 +12,7 @@ import {
} from 'react'
import { z } from 'zod'

import { parseArgs } from 'src/lib/functions'
import { useTypedSearchParams } from 'src/lib/hooks'

type FilterContext = z.TypeOf<typeof academySearchSchema>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client'

import { parseArgs } from '@sushiswap/client'
import { useRouter } from 'next/navigation'
import {
Dispatch,
Expand All @@ -13,6 +12,7 @@ import {
} from 'react'
import { z } from 'zod'

import { parseArgs } from 'src/lib/functions'
import { useTypedSearchParams } from 'src/lib/hooks'

type FilterContext = z.TypeOf<typeof blogSearchSchema>
Expand Down
77 changes: 0 additions & 77 deletions apps/web/src/app/(evm)/api/balance/v0/[chainId]/[address]/route.ts

This file was deleted.

58 changes: 21 additions & 37 deletions apps/web/src/app/(evm)/api/stable/v1/pool-list/route.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
import { Protocol } from '@sushiswap/client'
import { createClient } from '@sushiswap/database'
import {
PoolChainId,
getPoolAddresses,
isPoolChainId,
} from '@sushiswap/graph-client/data-api'
import { Ratelimit } from '@upstash/ratelimit'
import { NextRequest, NextResponse } from 'next/server'
import { rateLimit } from 'src/lib/rate-limit'
import { SushiSwapProtocol } from 'sushi'
import { ChainId } from 'sushi/chain'
import { isBentoBoxChainId } from 'sushi/config'
import { isSushiSwapV2ChainId, isSushiSwapV3ChainId } from 'sushi/config'
import { z } from 'zod'
import { CORS } from '../../cors'

const schema = z.object({
chainId: z.coerce
.number()
.refine(
(chainId) =>
isSushiSwapV2ChainId(chainId as ChainId) ||
isSushiSwapV3ChainId(chainId as ChainId) ||
isBentoBoxChainId(chainId as ChainId),
{ message: 'Invalid chainId' },
)
.refine((chainId) => isPoolChainId(chainId as ChainId), {
message: 'Invalid chainId',
})
.transform((chainId) => {
return chainId as ChainId
return chainId as PoolChainId
}),
protocol: z
.string()
.refine(
(protocol) => Object.values(Protocol).includes(protocol as Protocol),
(protocol) =>
Object.values(SushiSwapProtocol).includes(
protocol as SushiSwapProtocol,
),
{
message: `Invalid protocol, valid values are: ${Object.values(
Protocol,
SushiSwapProtocol,
).join(', ')}`,
},
)
.transform((protocol) => protocol as Protocol),
.transform((protocol) => protocol as SushiSwapProtocol),
isApproved: z.coerce
.string()
.default('true')
Expand All @@ -44,7 +45,7 @@ const schema = z.object({
})

export const revalidate = 300
export const maxDuration = 10
export const maxDuration = 30

export async function GET(request: NextRequest) {
const ratelimit = rateLimit(Ratelimit.slidingWindow(200, '1 h'))
Expand All @@ -64,27 +65,10 @@ export async function GET(request: NextRequest) {

const args = result.data

const approval = args.isApproved
? ({
token0: { status: 'APPROVED' },
token1: { status: 'APPROVED' },
} as const)
: {}

const client = await createClient()
const data = await client.sushiPool
.findMany({
select: {
address: true,
},
where: {
chainId: args.chainId,
protocol: args.protocol,
...approval,
},
})
.then((pools) => pools.map((pool) => pool.address))
await client.$disconnect()
const data = await getPoolAddresses({
chainId: args.chainId,
protocols: [args.protocol],
})

return NextResponse.json(data, { headers: CORS })
}
12 changes: 6 additions & 6 deletions apps/web/src/app/(evm)/api/stable/v1/position-info/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTokenList } from '@sushiswap/graph-client/data-api'
import { Ratelimit } from '@upstash/ratelimit'
import { NextRequest, NextResponse } from 'next/server'
import { getToken } from 'src/lib/db'
import { rateLimit } from 'src/lib/rate-limit'
import { Position, formatPercent } from 'sushi'
import { ChainId } from 'sushi/chain'
Expand Down Expand Up @@ -70,16 +70,16 @@ export async function GET(request: NextRequest) {
tokenId: args.positionId,
})

const [token0, token1] = await Promise.all([
getToken(args.chainId, position.token0),
getToken(args.chainId, position.token1),
const [[token0], [token1]] = await Promise.all([
getTokenList({ chainId: args.chainId, search: position.token0 }),
getTokenList({ chainId: args.chainId, search: position.token1 }),
])

const [{ pool, poolAddress }, prices] = await Promise.all([
getPool({
chainId: args.chainId,
token0: new Token({ chainId: args.chainId, ...token0 }),
token1: new Token({ chainId: args.chainId, ...token1 }),
token0: new Token(token0),
token1: new Token(token1),
feeAmount: position.fee as SushiSwapV3FeeAmount,
}),
getPrices({ chainId: args.chainId }),
Expand Down
7 changes: 0 additions & 7 deletions apps/web/src/app/(evm)/bonds/(landing)/(bonds)/layout.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions apps/web/src/app/(evm)/bonds/(landing)/(bonds)/page.tsx

This file was deleted.

58 changes: 0 additions & 58 deletions apps/web/src/app/(evm)/bonds/(landing)/layout.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions apps/web/src/app/(evm)/bonds/(landing)/my-bonds/layout.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions apps/web/src/app/(evm)/bonds/(landing)/my-bonds/page.tsx

This file was deleted.

Loading

0 comments on commit aa9f156

Please sign in to comment.