Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mfi-v2-ui): be edge functions v2 #1002

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apps/marginfi-v2-ui/src/pages/api/oracle/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,20 @@ async function fetchMultiPrice(tokens: string[]): Promise<BirdeyePriceResponse>
throw new Error("No tokens provided");
}

// use abort controller to restrict fetch to 10 seconds
const controller = new AbortController();
const timeoutId = setTimeout(() => {
controller.abort();
}, 5000);

// Fetch from API and update cache
try {
const response = await fetch(`${BIRDEYE_API}/defi/multi_price?list_address=${tokens.join("%2C")}`, {
headers: {
Accept: "application/json",
"x-chain": "solana",
"X-Api-Key": process.env.BIRDEYE_API_KEY || "",
},
const baseUrl =
process.env.VERCEL_ENV === "production" && process.env.VERCEL_PROJECT_PRODUCTION_URL
? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`
: process.env.VERCEL_BRANCH_URL
? `https://${process.env.VERCEL_BRANCH_URL}`
: "localhost:3004";

const response = await fetch(`${baseUrl}/api/tokens/multi?mintList=${tokens.join(",")}`, {
signal: controller.signal,
});
clearTimeout(timeoutId);
Expand Down
5 changes: 4 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
"NEXT_PUBLIC_RPC_PROXY_KEY",
"NEXT_PUBLIC_TX_SINGLE_BROADCAST_TYPE",
"NEXT_PUBLIC_TX_MULTI_BROADCAST_TYPE",
"NEXT_PUBLIC_TX_FALLBACK_SEQUENCE"
"NEXT_PUBLIC_TX_FALLBACK_SEQUENCE",
"VERCEL_ENV",
"VERCEL_BRANCH_URL",
"VERCEL_PROJECT_PRODUCTION_URL"
]
}
Loading