Multi-Token Support

The GasCreditVault contract supports multiple ERC-20 tokens as collateral for gas credits, enabling users to pay for transaction fees using their preferred tokens. This flexible system integrates with Chainlink price feeds to ensure fair and accurate conversion rates across different tokens.

Overview

Multi-token support in GasCreditVault provides:

  • Flexible token options for gas credit deposits

  • Real-time price conversion using Chainlink oracles

  • Secure token management with proper validation

  • Dynamic token addition/removal by administrators

  • Per-token configuration for limits and parameters

Architecture

Token Configuration

Supported Token Structure

struct TokenInfo {
    AggregatorV3Interface priceFeed;
    bool isStablecoin;
}

// Storage mapping
mapping(address => TokenInfo) public tokenInfo;
mapping(address => uint256) public credits;

function isTokenWhitelisted(address token) external view returns (bool);

Price Conversion Logic

Deposit Management

Multi-Token Deposits

Withdrawal Management

Token-Specific Withdrawals

Transfer Credits

Administrative Functions

Token Management

Emergency Functions

View Functions

Token Information

User Balances

Events

Best Practices

For Administrators

  1. Validate price feeds thoroughly before adding tokens

  2. Set appropriate limits based on token volatility

  3. Monitor daily deposits for unusual activity

  4. Keep fallback oracles for critical tokens

  5. Regular security audits of token contracts

For Users

  1. Check token prices before large deposits

  2. Understand conversion fees for each token

  3. Monitor price staleness indicators

  4. Use batch deposits for multiple tokens

  5. Keep diversified token holdings for flexibility

For Developers

  1. Handle price feed failures gracefully

  2. Implement proper slippage protection

  3. Cache token information for better UX

  4. Monitor gas costs for multi-token operations

  5. Test with various token configurations


Related Topics:

Last updated