-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1088500
commit c849c67
Showing
74 changed files
with
6,053 additions
and
3,560 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
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,19 +1,41 @@ | ||
interface PriceEngineResponse { | ||
eth_usd: number; | ||
strk_usd: number; | ||
} | ||
import { env } from "~/env"; | ||
import { Mobula } from "mobula-sdk"; | ||
|
||
export async function GET() { | ||
const response = await fetch("https://price-engine.arkproject.dev"); | ||
const mobula = new Mobula({ | ||
apiKeyAuth: env.NEXT_PUBLIC_MOBULA_API_KEY, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to fetch price data"); | ||
} | ||
const defaultResponse = { | ||
ethereum: { price: 0 }, | ||
starknet: { price: 0 }, | ||
lords: { price: 0 }, | ||
}; | ||
export async function GET() { | ||
try { | ||
const { multiDataResponse } = await mobula.fetchMultipleAssetMarketData({ | ||
assets: "ethereum,starknet,lords", | ||
}); | ||
|
||
const data = (await response.json()) as PriceEngineResponse; | ||
if (multiDataResponse?.data === undefined) { | ||
return Response.json(defaultResponse); | ||
} | ||
|
||
return Response.json({ | ||
ethereum: { price: data.eth_usd }, | ||
starknet: { price: data.strk_usd }, | ||
}); | ||
return Response.json({ | ||
ethereum: { | ||
// @ts-expect-error trust me compiler | ||
price: multiDataResponse.data.ethereum.price as number, | ||
}, | ||
starknet: { | ||
// @ts-expect-error It's ok compiler | ||
price: multiDataResponse.data.starknet.price as number, | ||
}, | ||
lords: { | ||
// @ts-expect-error It's ok compiler | ||
price: multiDataResponse.data.lords.price as number, | ||
} | ||
}) | ||
} catch (error) { | ||
console.error("Failed to fetch prices", error); | ||
return Response.json(defaultResponse); | ||
} | ||
} |
Empty file.
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
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
Oops, something went wrong.