From 263a089b972fe69499760fa9ee06235a53eca9ae Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 30 Mar 2024 15:49:14 +0000 Subject: [PATCH] new quote fetching --- app/api/quote/route.ts | 15 +++++++-------- app/page.tsx | 2 +- components/Content/Content.tsx | 3 ++- components/Prices.tsx | 33 ++++++++++++++------------------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/app/api/quote/route.ts b/app/api/quote/route.ts index 373d5ce..ac06e35 100644 --- a/app/api/quote/route.ts +++ b/app/api/quote/route.ts @@ -2,28 +2,27 @@ import { type NextRequest } from 'next/server' export const runtime = 'edge' -const apiUrl = 'https://api.1inch.dev/swap/v6.0/1/quote' +const apiUrl = process.env.WEB3_API_URL const config: RequestInit = { headers: { - Authorization: `Bearer ${process.env.ONEINCH_API_KEY}`, 'content-type': 'application/json' }, method: 'GET', - next: { revalidate: 60 } + next: { revalidate: 30 } } export async function GET(request: NextRequest) { const searchParams = request?.nextUrl?.searchParams - const src = searchParams?.get('src') - const dst = searchParams?.get('dst') - const amount = searchParams?.get('amount') + const tokenIn = searchParams?.get('tokenIn') + const tokenOut = searchParams?.get('tokenOut') + const amountIn = searchParams?.get('amountIn') - if (!src || !dst || !amount) { + if (!tokenIn || !tokenOut || !amountIn) { return Response.json(null, { status: 400 }) } - const url = `${apiUrl}/?src=${src}&dst=${dst}&amount=${amount}&includeTokensInfo=true&includeProtocols=true` + const url = `${apiUrl}/quote?tokenIn=${tokenIn}&tokenOut=${tokenOut}&amountIn=${amountIn}` let data let status diff --git a/app/page.tsx b/app/page.tsx index 11463b9..2c7397e 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -13,7 +13,7 @@ export default function Home() {
- Send ❤️ & meme coins to krema.eth + Send ❤️ and memecoins to krema.eth
) diff --git a/components/Content/Content.tsx b/components/Content/Content.tsx index 50d17f3..398cdc7 100644 --- a/components/Content/Content.tsx +++ b/components/Content/Content.tsx @@ -16,7 +16,8 @@ export function Content({ prices }: Props) { fixed ASI exchange rate , the fluctuating fiat values fetched from Coingecko, and - token swap quotes from 1inch. + token swap quotes from Uniswap v3 + routes.