From efd555b4443c6752d5aaa9b107760d4e400821ea Mon Sep 17 00:00:00 2001 From: antoncoding Date: Wed, 24 Sep 2025 15:54:58 +0800 Subject: [PATCH 1/7] feat: arbitrum --- app/api/README.md | 25 - app/api/balances/route.ts | 10 +- app/api/chains/supported/route.ts | 20 - src/components/Input/Input.tsx | 2 +- src/components/SupplyModalContent.tsx | 2 +- src/components/providers/TokenProvider.tsx | 18 +- src/config/dataSources.ts | 4 +- .../oracle/chainlink-data/arbitrum.json | 74881 ++++++++++++++++ src/constants/oracle/chainlink-data/index.ts | 2 + src/contexts/MarketsContext.tsx | 1 + src/hooks/useLiquidations.ts | 1 + src/hooks/useSupplyMarket.ts | 2 +- src/hooks/useUserBalances.ts | 12 +- src/imgs/chains/arbitrum.png | Bin 0 -> 111940 bytes src/imgs/tokens/syrupUSDC.svg | 21 + src/store/createWagmiConfig.ts | 8 +- src/store/supportedChains.ts | 22 +- src/store/test/createWagmiConfig.test.ts | 29 - src/store/test/supportedChains.test.ts | 29 - src/utils/external.ts | 16 +- src/utils/morpho.ts | 4 + src/utils/networks.ts | 6 + src/utils/rpc.ts | 13 +- src/utils/subgraph-urls.ts | 5 + src/utils/tokens.ts | 18 +- 25 files changed, 74997 insertions(+), 154 deletions(-) delete mode 100644 app/api/README.md delete mode 100644 app/api/chains/supported/route.ts create mode 100644 src/constants/oracle/chainlink-data/arbitrum.json create mode 100644 src/imgs/chains/arbitrum.png create mode 100644 src/imgs/tokens/syrupUSDC.svg delete mode 100644 src/store/test/createWagmiConfig.test.ts delete mode 100644 src/store/test/supportedChains.test.ts diff --git a/app/api/README.md b/app/api/README.md deleted file mode 100644 index 6b96f964..00000000 --- a/app/api/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Build Onchain API Routes - -## Supported Chains /api/chains/supported - -**Method**: GET - -**Response**: JSON encoded viem chain object - -```json -[{"id":5,"network":"sepolia","name":"Sepolia"] -``` - -## Current Block Number /api/chain/blockNumber?chainId=5 - -Gets the current blocknumber from the backend. This might be used to ensure -your frontend has consistency with the backend (e.g what if the drift -between FE and BE). - -**Method**: GET - -**Response**: JSON encoded block number - -```json -{ "block": "13948678" } -``` diff --git a/app/api/balances/route.ts b/app/api/balances/route.ts index c4e6dfe9..afb1d508 100644 --- a/app/api/balances/route.ts +++ b/app/api/balances/route.ts @@ -1,12 +1,8 @@ +import { SupportedNetworks } from '@/utils/networks'; +import { DEFAULT_RPC_URLS } from '@/utils/rpc'; import { NextRequest, NextResponse } from 'next/server'; const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY; -const ALCHEMY_URLS = { - '1': `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, - '8453': `https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, - '137': `https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, - '130': `https://unichain-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, -}; type TokenBalance = { contractAddress: string; @@ -23,7 +19,7 @@ export async function GET(req: NextRequest) { } try { - const alchemyUrl = ALCHEMY_URLS[chainId as keyof typeof ALCHEMY_URLS]; + const alchemyUrl = DEFAULT_RPC_URLS[Number(chainId) as SupportedNetworks]; if (!alchemyUrl) { throw new Error(`Chain ${chainId} not supported`); } diff --git a/app/api/chains/supported/route.ts b/app/api/chains/supported/route.ts deleted file mode 100644 index aac43946..00000000 --- a/app/api/chains/supported/route.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NextResponse } from 'next/server'; -import { getChainsForEnvironment } from '@/store/supportedChains'; - -/** - * Handler for the /api/chains/supported route, this route will return all the supported - * chains for this application. - * @param req - * @param res - */ -export async function GET(): Promise { - try { - const chains = getChainsForEnvironment(); - return NextResponse.json(chains, { status: 200 }); - } catch (error) { - console.error('Error fetching chains:', error); - return NextResponse.json({}, { status: 500, statusText: 'Internal Server Error' }); - } -} - -export const dynamic = 'force-dynamic'; diff --git a/src/components/Input/Input.tsx b/src/components/Input/Input.tsx index 4a3e784e..b15fd564 100644 --- a/src/components/Input/Input.tsx +++ b/src/components/Input/Input.tsx @@ -83,7 +83,7 @@ export default function Input({ onChange={onInputChange} className="bg-hovered h-10 w-full rounded p-2 focus:border-primary focus:outline-none" /> - {max && ( + {(max !== undefined && max !== BigInt(0)) && ( - ) : (!permit2Authorized && !useEth) || (!usePermit2Setting && !isApproved) ? ( + ) : ((!permit2Authorized && !useEth) || (!usePermit2Setting && !isApproved)) ? (