Smart Contracts
Description: Core decentralized exchange contract handling all trading operations, liquidity management, and cross-chain bridging functionality.
Key Functions:
swap_eth_for_usdc(amount: Field) -> Field
swap_usdc_for_eth(amount: Field) -> Field
add_liquidity(eth_amount: Field, usdc_amount: Field) -> Field
remove_liquidity(lp_tokens: Field) -> (Field, Field)
get_pool_reserves() -> (Field, Field)
π Network Configuration
Aztec Network
{
"network": "aztec-alpha-testnet",
"node_url": "https://aztec-alpha-testnet-fullnode.zkv.xyz",
"chain_id": "31337",
"contract_address": "0x1330e47d59fdb85ab38240724c960353ed693aae6c6c102e763a656ba4b67321"
}
Ethereum Sepolia Testnet
{
"network": "sepolia",
"rpc_url": "https://ethereum-rpc.publicnode.com",
"chain_id": "11155111",
"eth_contract": "0x...",
"usdc_contract": "0x..."
}
π Price Oracle Integration
Chainlink Price Feeds
ETH/USD Feed: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 USDC/USD Feed: 0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6 Network: Ethereum Mainnet (via Sepolia for testing) Update Frequency: Real-time
Implementation:
// Price oracle integration in Noir
struct PriceOracle {
eth_usd_feed: Field,
usdc_usd_feed: Field,
last_update: Field,
}
fn get_exchange_rate(
oracle: PriceOracle,
from_token: TokenType,
to_token: TokenType
) -> Field {
// Secure price calculation using Chainlink feeds
}
π Contract Security Features
Access Control
// Admin functions with multi-sig protection
fn update_oracle_feeds(
new_eth_feed: Field,
new_usdc_feed: Field,
admin_proof: AdminProof
) {
assert(verify_admin_signature(admin_proof));
// Update oracle feeds
}
Slippage Protection
fn execute_swap_with_slippage(
input_amount: Field,
min_output: Field,
max_slippage: Field
) -> Field {
let estimated_output = calculate_swap_output(input_amount);
assert(estimated_output >= min_output);
// Execute swap with protection
}
π Bridge Contracts
Cross-Chain Asset Bridge
Purpose: Secure asset transfers between Ethereum and Aztec networks Security Model: Lock-and-mint with zero-knowledge proofs Supported Assets: ETH, USDC Bridge Workflow:
Lock Phase: Assets locked on source chain with proof generation
Proof Verification: Zero-knowledge proof verified on destination
Mint Phase: Equivalent assets minted on destination chain
Confirmation: Multi-step confirmation process for security
π Liquidity Pool Architecture
AMM Implementation
struct LiquidityPool {
eth_reserve: Field,
usdc_reserve: Field,
total_supply: Field,
fee_rate: Field, // 0.3% = 3000
}
fn constant_product_formula(
input_amount: Field,
input_reserve: Field,
output_reserve: Field
) -> Field {
// x * y = k implementation with fees
}
βοΈ Contract Deployment Info
Compiler Version
Noir 0.34.0+
Deployment Date
December 2024
Gas Optimization
β Optimized
Upgradeable
β Proxy Pattern
Multi-Sig
β 3/5 Admin Keys
Emergency Pause
β Implemented
π Contract Verification
Source Code
Repository: GitHub - Aztecas Contracts
License: MIT
Documentation: Comprehensive inline documentation
Tests: 100% test coverage
Formal Verification Status
β Arithmetic Safety: No overflow/underflow vulnerabilities
β Access Control: Proper permission management
β State Consistency: All state transitions verified
β Economic Security: MEV protection and fair pricing
All contracts are designed with security-first principles and undergo continuous monitoring for optimal performance.
Last updated