This document identifies all locations in the codebase where hardcoded token symbols like "SDAI", "GNO", "xDAI", etc. need to be replaced with dynamic values from the contract configuration using useContractConfig.js.
The useContractConfig hook already provides the proper structure:
const config = useContractConfig(proposalId);
// config.BASE_TOKENS_CONFIG.company.symbol (e.g., "PNK")
// config.BASE_TOKENS_CONFIG.currency.symbol (e.g., "sDAI")The config returns:
{
BASE_TOKENS_CONFIG: {
currency: {
symbol: metadata.currencyTokens?.base?.tokenSymbol || 'sDAI',
address: '0x...',
name: '...',
decimals: 18
},
company: {
symbol: metadata.companyTokens?.base?.tokenSymbol || 'GNO',
address: '0x...',
name: '...',
decimals: 18
}
}
}Current Issue: Component doesn't use the contract config Action: Add at the top of the component:
const config = useContractConfig(proposalId); // proposalId needs to be passed as propCurrent Issue: Hardcoded balance property references
sdaiBalance: '0',
wxdaiBalance: '0',Action: These property names should be dynamic or the balance structure should be updated.
Current Issue: Hardcoded 'SDAI' string and sdaiBalance property
if (selectedCurrency === 'SDAI') {
// SDAI mode: Sum position tokens + SDAI balance
const baseBalance = balances?.sdaiBalance || '0';Action: Replace with:
if (selectedCurrency === config?.BASE_TOKENS_CONFIG?.currency?.symbol) {
// Currency mode: Sum position tokens + currency balance
const baseBalance = balances?.currencyBalance || '0'; // Update balance structureCurrent Issue: Hardcoded "SDAI" symbol
amount: `${amount} SDAI`,Action: Replace with:
amount: `${amount} ${config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY'}`,Current Issue: Hardcoded fallback symbols
? `${amount} ${BASE_TOKENS_CONFIG?.company?.symbol || 'GNO_FALLBACK'}`
: `${amount} ${BASE_TOKENS_CONFIG?.currency?.symbol || 'SDAI_FALLBACK'}`,Action: Replace BASE_TOKENS_CONFIG with config.BASE_TOKENS_CONFIG:
? `${amount} ${config?.BASE_TOKENS_CONFIG?.company?.symbol || 'COMPANY_TOKEN'}`
: `${amount} ${config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY_TOKEN'}`,Current Issue: Hardcoded 'SDAI' and 'GNO' in error messages
throw new Error(`Insufficient ${tokenType === 'currency' ? 'SDAI' : 'GNO'} balance.`);Action: Replace with:
throw new Error(`Insufficient ${tokenType === 'currency' ? config?.BASE_TOKENS_CONFIG?.currency?.symbol : config?.BASE_TOKENS_CONFIG?.company?.symbol} balance.`);Current Issue: Hardcoded 'SDAI' fallback
symbol = BASE_TOKENS_CONFIG?.currency?.symbol || 'SDAI';Action: Replace BASE_TOKENS_CONFIG with config.BASE_TOKENS_CONFIG:
symbol = config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY';Current Issue: Generic 'TOKEN' fallback
symbol = BASE_TOKENS_CONFIG?.company?.symbol || 'TOKEN';Action: Replace with:
symbol = config?.BASE_TOKENS_CONFIG?.company?.symbol || 'COMPANY';Current Issue: BASE_TOKENS_CONFIG references
formatBalance((inputAmount / price).toString(), BASE_TOKENS_CONFIG.company.symbol)
formatBalance((inputAmount * price).toString(), BASE_TOKENS_CONFIG.currency.symbol)Action: Replace with config.BASE_TOKENS_CONFIG:
formatBalance((inputAmount / price).toString(), config?.BASE_TOKENS_CONFIG?.company?.symbol)
formatBalance((inputAmount * price).toString(), config?.BASE_TOKENS_CONFIG?.currency?.symbol)Current Issue: BASE_TOKENS_CONFIG references
? BASE_TOKENS_CONFIG.currency.symbol
: BASE_TOKENS_CONFIG.company.symbolAction: Replace with config.BASE_TOKENS_CONFIG:
? config?.BASE_TOKENS_CONFIG?.currency?.symbol
: config?.BASE_TOKENS_CONFIG?.company?.symbolCurrent Issue: Component doesn't use the contract config Action: Add at the top of the component:
const config = useContractConfig(proposalId); // proposalId needs to be passed as propCurrent Issue: Hardcoded "SDAI" and "GNO" labels
SDAI
GNOAction: Replace with:
{config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY'}
{config?.BASE_TOKENS_CONFIG?.company?.symbol || 'COMPANY'}Current Issue: Hardcoded wxdai and faot property names
selectedTokenType === "currency" ? balances?.wxdai : balances?.faot;Action: Replace with dynamic property names or update balance structure to use consistent naming.
Current Issue: Hardcoded token symbols in URLs
? tokenConfig.company.getTokenUrl || "https://swap.cow.fi/#/100/swap/sDAI/GNO"
: tokenConfig.currency.getTokenUrl || "https://swap.cow.fi/#/100/swap/xdai/sdai"Action: Update URLs to use dynamic token symbols if needed, or keep as fallbacks.
Current Issue: Hardcoded "xDAI" references
{tokenConfig.nativeCoin?.symbol || "xDAI"} Balance
tokenConfig.nativeCoin?.symbol || "xDAI"Action: These can stay as "xDAI" since it's the native chain token, but should ideally be configurable.
Current Issue: Hardcoded "SDAI" and "GNO" in formatBalance calls
selectedTokenType === "currency" ? "SDAI" : "GNO"Action: Replace with:
selectedTokenType === "currency"
? config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY'
: config?.BASE_TOKENS_CONFIG?.company?.symbol || 'COMPANY'Current Issue: Component may not be using the contract config consistently Action: Ensure the component has:
const config = useContractConfig(proposalId);Current Issue: Hardcoded "GNO" in market title template
const rawMarketTitle = config?.marketInfo?.title || "What will be the impact on GNO price if GnosisPay reaches $5mil weekly volume?";Action: Replace with dynamic token symbol:
const rawMarketTitle = config?.marketInfo?.title || `What will be the impact on ${config?.BASE_TOKENS_CONFIG?.company?.symbol || 'TOKEN'} price if...`;Current Issue: Hardcoded "GNO" references in title parsing
const marketTitlePrefix = "What will be the impact on GNO price if";Action: Make this dynamic based on config.
Current Issue: Comments mention specific tokens
wxdai: rawBalances.currency, // SDAI balance for compatibility
faot: rawBalances.company, // GNO balance for compatibilityAction: Update comments to be generic or use dynamic symbols.
Current Issue: Hardcoded GNO and sDAI references in default data
display_title_0: "What will be the impact on GNO price",
description: "...using wrapped GNO and sDAI to speculate..."Action: Make these dynamic or keep as fallback defaults.
Current Issue: Hardcoded 'WXDAI' string in approval call
'WXDAI'Action: Replace with:
config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY'Current Issue: Hardcoded WXDAI in error message
throw new Error(`Insufficient WXDAI balance. You have ${ethers.utils.formatEther(balance)} WXDAI but need 0.01 WXDAI`);Action: Replace with dynamic token symbol from config.
The useContractConfig.js hook already returns the proper structure with BASE_TOKENS_CONFIG. No changes needed to the hook itself.
Add useContractConfig hook to each component that needs it:
ShowcaseSwapComponent.jsx:
const ShowcaseSwapComponent = ({ positions, prices, walletBalances, isLoadingBalances, account, isConnected, onConnectWallet, proposalId }) => {
const config = useContractConfig(proposalId);
// ... rest of componentCollateralModal.jsx:
const CollateralModal = ({ title, supportText, handleClose, handleActionButtonClick, connectedWalletAddress, proposalId, ... }) => {
const config = useContractConfig(proposalId);
// ... rest of componentFor cleaner code, create utility functions:
const getCurrencySymbol = () => config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY';
const getCompanySymbol = () => config?.BASE_TOKENS_CONFIG?.company?.symbol || 'COMPANY';Replace all imported BASE_TOKENS_CONFIG references with config.BASE_TOKENS_CONFIG:
// OLD:
import { BASE_TOKENS_CONFIG } from './constants/contracts';
symbol = BASE_TOKENS_CONFIG?.currency?.symbol || 'SDAI';
// NEW:
symbol = config?.BASE_TOKENS_CONFIG?.currency?.symbol || 'CURRENCY';Consider updating the balance structure to be more generic:
// Instead of:
balances: { sdaiBalance, wxdaiBalance, faot }
// Use:
balances: { currencyBalance, companyBalance, nativeBalance }Status: Component already imports and uses useContractConfig() on line 424:
const { config, loading: configLoading, error: configError } = useContractConfig();Current Issue: Uses imported DEFAULT_BASE_TOKENS_CONFIG as fallback
BASE_TOKENS_CONFIG = DEFAULT_BASE_TOKENS_CONFIG,Action: The fallback is appropriate, but ensure all usage points use the config version.
Current Issue: Hardcoded token symbols in existing balance display
{existingBalance} {transactionData.action === 'Buy' ? 'SDAI' : 'GNO'}
{additionalCollateralNeeded} {transactionData.action === 'Buy' ? 'SDAI' : 'GNO'}Action: Replace with:
{existingBalance} {transactionData.action === 'Buy'
? (BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG).currency.symbol
: (BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG).company.symbol}
{additionalCollateralNeeded} {transactionData.action === 'Buy'
? (BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG).currency.symbol
: (BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG).company.symbol}Current Issue: Multiple BASE_TOKENS_CONFIG references that should be consistent
Status: ✅ Already using dynamic BASE_TOKENS_CONFIG properly with fallbacks
Note: These are correctly implemented and don't need changes.
Current Issue: Uses BASE_TOKENS_CONFIG properly but should ensure consistency Status: ✅ Already properly implemented:
(BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG).currency.symbol
(BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG).company.symbolCurrent Issue: Error messages may contain hardcoded token references Action: Review any error messages that might contain hardcoded 'SDAI', 'GNO', etc.
Summary for ConfirmSwapModal.jsx:
- ✅ Already uses
useContractConfig()hook properly - ✅ Most token symbol usage is already dynamic
⚠️ Only lines 1755 and 1761 need updates for the collateral display section- ✅ Transaction summary section already properly uses dynamic config
Current Issue: Comments mention specific tokens
// Always recover/redeem from position token to native token (sDAI)
// Get SDAI token address for tokenOut (the redemption target)
console.log('Redemption tokenOut (SDAI):', tokenOut);Action: Update comments to be generic or use dynamic references:
// Always recover/redeem from position token to native currency token
// Get currency token address for tokenOut (the redemption target)
console.log('Redemption tokenOut (Currency):', tokenOut);Current Status: This file contains hardcoded token symbols and addresses:
export const BASE_TOKENS_CONFIG = {
currency: {
address: "0xaf204776c7245bF4147c2612BF6e5972Ee483701",
symbol: "SDAI",
name: "SDAI",
decimals: 18
},
company: {
address: "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb",
symbol: "GNO",
name: "Gnosis",
decimals: 18
}
};Action: ✅ No changes needed
Reason: This file serves as a fallback/default configuration when the dynamic config from useContractConfig is not available. The hardcoded values here are appropriate as they ensure the application continues to work even when the API is down or the proposal config is missing.
Note: Components should use the pattern:
const config = useContractConfig();
const baseTokens = config?.BASE_TOKENS_CONFIG || DEFAULT_BASE_TOKENS_CONFIG;Components need to accept proposalId as a prop. Update PropTypes:
ShowcaseSwapComponent.jsx:
ShowcaseSwapComponent.propTypes = {
positions: PropTypes.object,
prices: PropTypes.object,
walletBalances: PropTypes.object,
isLoadingBalances: PropTypes.bool,
account: PropTypes.string,
isConnected: PropTypes.bool,
onConnectWallet: PropTypes.func,
proposalId: PropTypes.string.isRequired, // Add this
};CollateralModal.jsx:
CollateralModal.propTypes = {
// ... existing props ...
proposalId: PropTypes.string.isRequired, // Add this
};Parent components need to pass the proposalId:
Example in MarketPageShowcase.jsx:
<ShowcaseSwapComponent
positions={positions}
prices={prices}
walletBalances={walletBalances}
isLoadingBalances={isLoadingBalances}
account={account}
isConnected={isConnected}
onConnectWallet={handleConnectWallet}
proposalId={config?.proposalId || proposalId} // Add this
/>ShowcaseSwapComponent.jsx:
- Balance display shows dynamic token symbols instead of hardcoded 'SDAI'/'GNO'
- Error messages use dynamic token names (line 571)
- formatBalance calls use config-based symbols (lines 1053-1054, 1095-1096)
- Recovery amount display uses dynamic symbols (lines 1067-1068, 1109-1110)
- propId is passed correctly to enable config loading
CollateralModal.jsx:
- TokenToggle buttons show dynamic currency/company symbols instead of 'SDAI'/'GNO'
- formatBalance calls use config-based symbols (lines 1054, 1063)
- Balance display sections show correct token symbols
- proposalId is passed correctly to enable config loading
ConfirmSwapModal.jsx:
- ✅ Already correctly implemented (most features)
- Collateral display section uses dynamic symbols (lines 1755, 1761)
- Comments updated to use generic references (lines 809, 876, 882)
MarketPageShowcase.jsx:
- Market title templates use dynamic token symbols
- Error messages use dynamic token names
- Comments updated to use generic token references
- All token symbols display correctly when config loads successfully
- Fallback values work when config API is unavailable
- Balance calculations use correct token symbols from different proposals
- Components work with different token configurations (PNK/sDAI vs GNO/sDAI)
- Error messages show correct token names for different proposals
- Transaction confirmations use correct symbols
- "Get Token" links use correct symbols and URLs
- ShowcaseSwapComponent.jsx: Lines 173-178, 244, 267-268, 571, 928, 946, 986, 1053-1054, 1095-1096, 1067-1068, 1109-1110
- CollateralModal.jsx: Lines 51, 60, 1054, 1063
- ConfirmSwapModal.jsx: Lines 1755, 1761
- MarketPageShowcase.jsx: Lines 1013, 1018-1019, 1350, 2315
- Comments and logging: Update hardcoded token references in comments
- Update balance structure to use generic property names
- Add TypeScript interfaces for better type safety
- Fallback Strategy: Always provide fallback values in case config is not loaded
- Loading States: Consider loading states while config is being fetched
- Type Safety: Consider adding TypeScript interfaces for the config structure
- Caching: The config should be cached to avoid repeated API calls
- Error Handling: Handle cases where token information is missing from config
- Constants File: The
constants/contracts.jsfile should remain unchanged as it provides appropriate fallback values