
Compound is a decentralized lending protocol built on Ethereum that allows users to lend and borrow cryptocurrencies.
Compound's unique feature is its ability to automatically adjust interest rates based on supply and demand.
It's like a dynamic pricing system, where the interest rate changes in real-time to ensure that there's always a balance between borrowers and lenders.
The protocol uses a token called COMP, which is used to govern the system and provide incentives for liquidity providers.
Compound's algorithm ensures that the system remains stable and liquid, even in times of high volatility.
The platform has gained significant traction in the crypto space, with millions of dollars in assets locked up in the protocol.
Users can lend their Ethereum to earn interest, or borrow Ethereum to access liquidity.
Compound Basics
Compound incentivises liquidity, but it doesn't guarantee it. The protocol uses a simple rule to discourage excess borrowing: the less liquidity there is, the higher the interest rate will be.
The Compound team has built a web of digital programs that can function as a decentralized money market on the Ethereum network. Ethereum asset holders can supply their assets to the protocol, earn interest on them, and borrow assets.
The interest rate aims to find an equilibrium between pooled assets and borrowed amount, ensuring a balance between the two.
Abi
The Abi is a crucial part of the Compound protocol, and it's what allows us to interact with the smart contract.
The Abi is made up of several functions, including DEFAULT_ADMIN_ROLE, which returns the bytes32 representation of the default admin role.
There's also FEE_ACCOUNT, which returns the address of the fee account. This is an important function, as it's used to manage fees for various operations within the protocol.
The getBalance function returns the balance of a specific asset address. This is useful for checking the current balance of a particular asset.
The getRoleAdmin function returns the admin role for a specific role. This is used to determine who has the authority to manage a particular role within the protocol.
The hasRole function checks if an account has a specific role. This is useful for determining whether an account has the necessary permissions to perform a particular action.
The MAX_SWAPS_PER_BLOCK function returns the maximum number of swaps allowed per block. This is an important function, as it helps prevent abuse of the protocol.
The supportsNativeAssets function returns a boolean indicating whether the protocol supports native assets. This is useful for determining whether an asset is supported by the protocol.
The unclaimedRewards function returns an array of reward tokens and their corresponding earned amounts. This is useful for determining which rewards are available to be claimed.
The WRAPPED_NATIVE_ASSET_ADDRESS function returns the address of the wrapped native asset. This is an important function, as it's used to interact with the wrapped native asset within the protocol.
The enableSwapHandlers function allows us to enable swap handlers for the protocol. This is useful for setting up swap handlers for specific assets.
The enableSwapOutputTokens function allows us to enable swap output tokens for the protocol. This is useful for setting up swap output tokens for specific assets.
The enableSwapTokens function allows us to enable swap tokens for the protocol. This is useful for setting up swap tokens for specific assets.
The executeOperation function allows us to execute an operation on a specific target address. This is useful for performing various operations within the protocol.
The exitMulticall function allows us to exit a multicall operation. This is useful for managing multicall operations within the protocol.
The grantRole function grants a specific role to an account. This is useful for assigning permissions to accounts within the protocol.
The multicall function allows us to call multiple functions within the protocol. This is useful for performing multiple operations within a single transaction.
The receiveFlashLoan function allows us to receive a flash loan from the protocol. This is useful for borrowing assets from the protocol.
The renounceRole function renounces a specific role for an account. This is useful for revoking permissions from accounts within the protocol.

The setFlashloanProvider function allows us to set a new flash loan provider for the protocol. This is useful for setting up a new provider for flash loans.
The swap function allows us to swap assets within the protocol. This is useful for exchanging assets for other assets.
The unwrap function allows us to unwrap a specific amount of assets. This is useful for converting wrapped assets back to their native form.
The updateFeeAccount function allows us to update the fee account for the protocol. This is useful for managing fees for various operations within the protocol.
The withdrawAllTo function allows us to withdraw all assets to a specific address. This is useful for withdrawing assets from the protocol.
The Deposit event is triggered when assets are deposited into the protocol. This is useful for tracking asset deposits within the protocol.
The Enter event is triggered when an account enters a multicall operation. This is useful for tracking multicall operations within the protocol.
The Exit event is triggered when an account exits a multicall operation. This is useful for tracking multicall operations within the protocol.
The FeeAccountUpdated event is triggered when the fee account is updated. This is useful for tracking fee account updates within the protocol.
The NativeAssetWrap event is triggered when an asset is wrapped or unwrapped. This is useful for tracking asset wraps and unwraps within the protocol.
The RewardsClaimed event is triggered when rewards are claimed by an account. This is useful for tracking rewards claims within the protocol.
The RoleAdminChanged event is triggered when the admin role for a specific role is changed. This is useful for tracking changes to admin roles within the protocol.
The RoleGranted event is triggered when a role is granted to an account. This is useful for tracking role assignments within the protocol.
The RoleRevoked event is triggered when a role is revoked from an account. This is useful for tracking role revocations within the protocol.
The SafeHarborModeUpdate event is triggered when the safe harbor mode is updated. This is useful for tracking safe harbor mode updates within the protocol.
The StopGuardianUpdate event is triggered when the stop guardian mode is updated. This is useful for tracking stop guardian mode updates within the protocol.

The SwapHandled event is triggered when a swap is handled by the protocol. This is useful for tracking swaps within the protocol.
The SwapHandlerUpdate event is triggered when a swap handler is updated. This is useful for tracking swap handler updates within the protocol.
The SwapOutputTokenUpdate event is triggered when a swap output token is updated. This is useful for tracking swap output token updates within the protocol.
The SwapTokenUpdate event is triggered when a swap token is updated. This is useful for tracking swap token updates within the protocol.
The Withdrawal event is triggered when assets are withdrawn from the protocol. This is useful for tracking asset withdrawals within the protocol.
The AccountMissingRole error is triggered when an account is missing a specific role. This is useful for tracking role assignments within the protocol.
The AccountNotAdmin error is triggered when an account is not an admin. This is useful for tracking admin roles within the protocol.
The InvalidSwapPayload error is triggered when an invalid swap payload is detected. This is useful for tracking swap payloads within the protocol.
The SlippageExceeded error is triggered when slippage is exceeded during a swap. This is useful for tracking slippage within the protocol.
The UntrustedFlashLoanSender error is triggered when an untrusted flash loan sender is detected. This is useful for tracking flash loan senders within the protocol.
Governance
Governance is a crucial aspect of smart contract systems, and Compound's governance model is designed to be decentralized and community-driven. Compound's governance token, COMP, is a game-changer in this regard.
The Comptroller is the risk management layer of the Compound protocol, but it's not the only contract involved in governance. The Unitroller, an upgradable proxy, delegates calls to the Comptroller and has additional methods for changing the implementation contract and admin.
If someone upgrades the implementation contract to a malicious address and changes the admin, all user's funds will be lost. This is why governance is so important.
The governance process on Compound works by proposing a proposal, voting (favour or against), and executing the proposal if succeeded. This is a three-day voting period, and proposals are executable code.
A decentralized voting process is used, where anyone who owns at least 1% of the total COMP supply can vote for proposals. One token represents one vote. This is a significant step towards self-governance.
Initially, Compound will distribute the COMP tokens among its shareholders, but it's unclear what percentage of the total amount they will get and what percentage will be left to the public.
Frequently Asked Questions
What is Ethereum solution?
Ethereum is a decentralized platform that enables secure, peer-to-peer transactions through smart contracts. It's a trustless system that lets people transact directly, without needing a central authority.
Sources
- https://www.codeslaw.app/contracts/ethereum/0x4886464860336a94c4f18291d76179e654569a50
- https://betterprogramming.pub/compound-v2-in-depth-6227c0528b5
- https://etherscan.io/token/0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9
- https://blog.kalinoff.com/compound-finance-explained/
- https://edge.app/blog/crypto-basics/de-fi-compound-finance/
Featured Images: pexels.com