Skip to content
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
15 changes: 11 additions & 4 deletions lib/usd-price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,24 @@ export async function getPlotUsdPrice(
async function fetchPlotUsdPrice(): Promise<number | null> {
const start = Date.now();

// Try all external sources in parallel — use whichever responds first
// Prefer Mint Club SDK (on-chain read, matches /token page price source)
// Only fall back to API aggregators if on-chain fails
try {
const price = await fetchFromMintClub();
console.info(`[USD Price] result=hit price=${price} elapsed=${Date.now() - start}ms`);
return price;
} catch {
// Mint Club SDK failed — try API aggregators
}

try {
const price = await Promise.any([
fetchFromMintClub(),
fetchFromGeckoTerminal(),
fetchFromCoinGecko(),
]);
console.info(`[USD Price] result=hit price=${price} elapsed=${Date.now() - start}ms`);
console.info(`[USD Price] result=hit price=${price} elapsed=${Date.now() - start}ms (api fallback)`);
return price;
} catch {
// All sources failed — AggregateError
console.warn(`[USD Price] All external sources failed, elapsed=${Date.now() - start}ms`);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plotlink",
"version": "0.1.42",
"version": "0.1.43",
"private": true,
"workspaces": [
"packages/*"
Expand Down
Loading
Loading