Solidity Solidity DeFi and Token Standards 2 — Questions and Answers
Question 1: What is a Chainlink oracle and why is it important for smart contracts?
- A decentralized data feed network that provides tamper-resistant external data (like price feeds) to smart contracts (Correct answer)
- A Solidity compiler plugin for checking contract security
- A Layer 2 scaling solution for Ethereum
- A token bridge between EVM-compatible chains
Correct answer: A decentralized data feed network that provides tamper-resistant external data (like price feeds) to smart contracts
Chainlink aggregates data from multiple independent nodes and on-chain verification, providing smart contracts with reliable price feeds and off-chain data without trusting a single source.
Question 2: What is a 'price oracle manipulation' attack in DeFi?
- Using flash loans or large trades to temporarily distort a price source that a vulnerable contract trusts for liquidations or borrowing (Correct answer)
- Replacing the oracle contract address via a governance vote
- Overflowing the oracle's price accumulator variable
- Submitting false data to a Chainlink node
Correct answer: Using flash loans or large trades to temporarily distort a price source that a vulnerable contract trusts for liquidations or borrowing
Attackers use large capital (often flash loans) to move prices on a DEX that a protocol uses as an oracle, triggering profitable liquidations or under-collateralized borrows.
Question 3: What is the difference between over-collateralized and under-collateralized lending in DeFi smart contracts?
- Over-collateralized requires depositing collateral worth more than the loan; under-collateralized (like flash loans) relies on atomic repayment (Correct answer)
- Over-collateralized lending uses ERC-20; under-collateralized uses ETH only
- Under-collateralized lending charges higher fees stored in contract storage
- Over-collateralized lending requires KYC verified addresses
Correct answer: Over-collateralized requires depositing collateral worth more than the loan; under-collateralized (like flash loans) relies on atomic repayment
Over-collateralized lending (Aave, Compound) requires collateral exceeding loan value for safety; flash loans are under-collateralized but must be repaid within the same transaction.
Question 4: What does the `health factor` represent in Aave's Solidity lending contracts?
- A ratio above 1 meaning collateral exceeds borrowed value; when it drops below 1, the position can be liquidated (Correct answer)
- The percentage of supplied liquidity actively borrowed
- The gas efficiency ratio of the contract's storage reads
- The ratio of protocol fees to user earnings
Correct answer: A ratio above 1 meaning collateral exceeds borrowed value; when it drops below 1, the position can be liquidated
Health factor = (collateral in ETH × liquidation threshold) / (total borrows in ETH); below 1 means undercollateralized and the position is eligible for liquidation.
Question 5: What is 'liquidity mining' in the context of DeFi smart contract design?
- Distributing governance or reward tokens to users who provide liquidity to a protocol, incentivized via staking contracts (Correct answer)
- Mining ETH by solving proof-of-work inside a smart contract
- Using Chainlink to mine on-chain lottery numbers
- Creating synthetic liquidity by deploying dummy contracts
Correct answer: Distributing governance or reward tokens to users who provide liquidity to a protocol, incentivized via staking contracts
Liquidity mining programs distribute protocol tokens to liquidity providers as yield, using staking contracts that track deposited LP tokens and accrue rewards over time.
Question 6: What is the constant product formula used by Uniswap V2 AMMs?
- x * y = k, where x and y are token reserve amounts and k remains constant through every swap (Correct answer)
- x + y = k, where the sum of reserves is constant
- x^2 + y^2 = k, using a stableswap invariant
- x / y = k, where the price ratio is fixed
Correct answer: x * y = k, where x and y are token reserve amounts and k remains constant through every swap
Uniswap V2 maintains x × y = k; swapping ΔX tokens in gives ΔY tokens out such that (x + ΔX) × (y - ΔY) = k, keeping the product constant.
What is a Chainlink oracle and why is it important for smart contracts?