-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add API3 oracle feed support #408
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
Changes from all commits
9a093fa
a86d8e5
9761b38
b75bbe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import Image from 'next/image'; | ||
| import Link from 'next/link'; | ||
| import type { Address } from 'viem'; | ||
| import etherscanLogo from '@/imgs/etherscan.png'; | ||
| import { getExplorerURL } from '@/utils/external'; | ||
| import { OracleVendorIcons, PriceFeedVendors, type FeedData, type FeedFreshnessStatus } from '@/utils/oracle'; | ||
| import type { OracleFeed } from '@/utils/types'; | ||
| import { FeedFreshnessSection } from './FeedFreshnessSection'; | ||
|
|
||
| type API3FeedTooltipProps = { | ||
| feed: OracleFeed; | ||
| feedData?: FeedData | null; | ||
| chainId: number; | ||
| feedFreshness?: FeedFreshnessStatus; | ||
| }; | ||
|
|
||
| export function API3FeedTooltip({ feed, feedData, chainId, feedFreshness }: API3FeedTooltipProps) { | ||
| const baseAsset = feed.pair?.[0] ?? feedData?.pair[0] ?? 'Unknown'; | ||
| const quoteAsset = feed.pair?.[1] ?? feedData?.pair[1] ?? 'Unknown'; | ||
|
|
||
| const vendorIcon = OracleVendorIcons[PriceFeedVendors.API3]; | ||
|
|
||
| return ( | ||
| <div className="flex w-fit max-w-[22rem] flex-col gap-3"> | ||
| {/* Header with icon and title */} | ||
| <div className="flex items-center gap-2"> | ||
| {vendorIcon && ( | ||
| <div className="flex-shrink-0"> | ||
| <Image | ||
| src={vendorIcon} | ||
| alt="API3" | ||
| width={16} | ||
| height={16} | ||
| /> | ||
| </div> | ||
| )} | ||
| <div className="font-zen font-bold">API3 Data Feed</div> | ||
| </div> | ||
|
|
||
| {/* Feed pair name */} | ||
| <div className="flex items-center gap-2"> | ||
| <div className="font-zen text-base font-semibold text-gray-800 dark:text-gray-200"> | ||
| {baseAsset} / {quoteAsset} | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Description */} | ||
| {feedData?.description && ( | ||
| <div className="border-t border-gray-200/30 pt-3 dark:border-gray-600/20"> | ||
| <div className="font-zen text-xs text-gray-600 dark:text-gray-400">{feedData.description}</div> | ||
| </div> | ||
| )} | ||
|
|
||
| <FeedFreshnessSection feedFreshness={feedFreshness} /> | ||
|
|
||
| {/* External Links */} | ||
| <div className="border-t border-gray-200/30 pt-3 dark:border-gray-600/20"> | ||
| <div className="mb-2 font-zen text-sm font-medium text-gray-700 dark:text-gray-300">View on:</div> | ||
| <div className="flex items-center gap-2"> | ||
| <Link | ||
| href={getExplorerURL(feed.address as Address, chainId)} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find SupportedNetworks definition
echo "=== SupportedNetworks type definition ==="
rg -n "type SupportedNetworks|enum SupportedNetworks" --type=ts -A 3
# Check getExplorerURL signature
echo "=== getExplorerURL function signature ==="
rg -n "getExplorerURL" --type=ts -B 2 -A 5 | head -50
# Check Address import and all uses in the file
echo "=== Address import and usage in API3FeedTooltip.tsx ==="
rg -n "Address" src/features/markets/components/oracle/MarketOracle/API3FeedTooltip.tsx
# Inspect the exact line 61 and context
echo "=== Context around line 61 ==="
sed -n '55,65p' src/features/markets/components/oracle/MarketOracle/API3FeedTooltip.tsx
# Check imports at the top of the file
echo "=== Imports in API3FeedTooltip.tsx ==="
head -20 src/features/markets/components/oracle/MarketOracle/API3FeedTooltip.tsxRepository: antoncoding/monarch Length of output: 13627 Drop the redundant
🤖 Prompt for AI Agents🧩 Analysis chain🏁 Script executed: # Find and inspect SupportedNetworks type definition
rg "type SupportedNetworks|enum SupportedNetworks" --type=ts --type=tsx -A 10Repository: antoncoding/monarch Length of output: 90 🏁 Script executed: # Find getExplorerURL function signature
rg "export.*getExplorerURL|function getExplorerURL" --type=ts --type=tsx -B 2 -A 5Repository: antoncoding/monarch Length of output: 90 🏁 Script executed: # Check other calls to getExplorerURL to understand the pattern
rg "getExplorerURL" --type=ts --type=tsx -B 1 -A 1Repository: antoncoding/monarch Length of output: 90 🏁 Script executed: # Find SupportedNetworks definition
rg "SupportedNetworks" -A 10 | head -50Repository: antoncoding/monarch Length of output: 3071 🏁 Script executed: # Find getExplorerURL function
rg "getExplorerURL" -B 2 -A 8 | head -80Repository: antoncoding/monarch Length of output: 7972 🏁 Script executed: # Find the networks file and get SupportedNetworks definition
fd "networks" -type f | grep -E "\.(ts|js)$"Repository: antoncoding/monarch Length of output: 233 🏁 Script executed: # Check the networks file directly
cat src/utils/networks.ts | head -100Repository: antoncoding/monarch Length of output: 3237 Remove the redundant
🤖 Prompt for AI Agents |
||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| className="bg-hovered flex items-center gap-1 rounded-sm px-3 py-2 text-xs font-medium text-primary no-underline transition-all duration-200 hover:bg-opacity-80" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, check the Tailwind version in the project
find . -name "package.json" -o -name "package-lock.json" | head -5Repository: antoncoding/monarch Length of output: 77 🏁 Script executed: # Find and examine the API3FeedTooltip.tsx file
fd -t f "API3FeedTooltip.tsx"Repository: antoncoding/monarch Length of output: 134 🏁 Script executed: # Find FeedEntry.tsx mentioned in the comment
fd -t f "FeedEntry.tsx"Repository: antoncoding/monarch Length of output: 128 🏁 Script executed: # Search for all instances of bg-opacity in the codebase
rg "bg-opacity" -t tsx -t ts -t jsx -t jsRepository: antoncoding/monarch Length of output: 90 🏁 Script executed: # Check Tailwind version in package.json
cat package.json | grep -A 2 -B 2 "tailwind"Repository: antoncoding/monarch Length of output: 601 🏁 Script executed: # Read API3FeedTooltip.tsx to see lines around 69 and 84
cat -n src/features/markets/components/oracle/MarketOracle/API3FeedTooltip.tsx | sed -n '65,90p'Repository: antoncoding/monarch Length of output: 1242 🏁 Script executed: # Read FeedEntry.tsx to see line 191
cat -n src/features/markets/components/oracle/MarketOracle/FeedEntry.tsx | sed -n '185,195p'Repository: antoncoding/monarch Length of output: 621 🏁 Script executed: # Search for bg-opacity usage
rg "bg-opacity"Repository: antoncoding/monarch Length of output: 3237 🏁 Script executed: # Find Tailwind config
fd -t f "tailwind.config"Repository: antoncoding/monarch Length of output: 81 🏁 Script executed: # Check Tailwind config for bg-hovered definition
cat tailwind.config.jsRepository: antoncoding/monarch Length of output: 245 🏁 Script executed: # Search for bg-hovered definition in CSS files
rg "bg-hovered" --type-list | head -20Repository: antoncoding/monarch Length of output: 452 🏁 Script executed: # Search for CSS/style files that might define bg-hovered
fd -e css -e scss -e postcssRepository: antoncoding/monarch Length of output: 77 🏁 Script executed: # Search for bg-hovered in all files to find its definition
rg "\.bg-hovered" -g "*.css" -g "*.scss" -g "*.postcss"Repository: antoncoding/monarch Length of output: 91 🏁 Script executed: # Look for where bg-hovered might be defined as a class
rg "@apply.*bg-hovered|bg-hovered.*{|\.bg-hovered"Repository: antoncoding/monarch Length of output: 222 🏁 Script executed: # Read global.css to see how bg-hovered is defined
cat app/global.cssRepository: antoncoding/monarch Length of output: 12360 Remove The Also applies to: 84-84 — also found in FeedEntry.tsx:191 and other tooltip components. 🤖 Prompt for AI Agents |
||
| > | ||
| <Image | ||
| src={etherscanLogo} | ||
| alt="Etherscan" | ||
| width={12} | ||
| height={12} | ||
| className="rounded-sm" | ||
| /> | ||
| Explorer | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.