Hooks Overview
Overview of the React hooks provided by Compound React
Compound React provides a comprehensive set of React hooks for interacting with the Compound III protocol. These hooks are organized into categories based on their functionality.
Account Management Hooks
Hooks for managing user accounts and permissions:
useAllow
- Allow or disallow another address to withdraw or transfer on behalf of the senderuseAllowBySig
- Similar to useAllow but uses EIP-712 signatures for gasless approvalsuseUserNonce
- Get the current nonce for a user, used for signed transactionsuseVersion
- Get the current version of the Comet contractuseHasPermission
- Check if an account has permission to act on behalf of another accountuseTransfer
- Transfer base tokens from the sender to another account
Collateral and Borrowing Hooks
Hooks for supplying collateral and borrowing assets:
useSupply
- Supply base tokens to the protocoluseWithdraw
- Withdraw base tokens from the protocoluseCollateralBalance
- Get the collateral balance of an account for a specific assetuseIsBorrowCollateralized
- Check if an account has enough collateral for borrowinguseBaseBorrowMin
- Get the minimum borrow amount for the base asset
Helper Hooks
Utility hooks for retrieving protocol data:
useTotalSupply
- Get the total supply of the base asset in the protocoluseTotalBorrow
- Get the total amount borrowed from the protocoluseTotalCollateral
- Get the total collateral for a specific asset in the protocoluseSuppliedBaseBalance
- Get the supplied base token balance for an accountuseBorrowBalance
- Get the borrow balance for an accountuseUserBasic
- Get basic information about a user’s accountuseGetAssetInfo
- Get information about a specific asset by symboluseGetAssetInfoByAddress
- Get information about an asset by its addressuseGetPrice
- Get the price of an assetuseAccrueAccount
- Accrue interest to an accountuseGetBaseAssetMarketInfo
- Get market information for the base assetuseGetBaseAccrualScale
- Get the base accrual scaleuseGetBaseIndexScale
- Get the base index scaleuseGetFactorScale
- Get the factor scale used for calculationsuseGetPriceScale
- Get the price scale used for calculationsuseGetMaxAssets
- Get the maximum number of assets supported by the protocol
Interest Rate Hooks
Hooks for getting interest rate information:
useGetSupplyRate
- Get the supply rate for the base assetuseGetBorrowRate
- Get the borrow rate for the base assetuseGetUtilization
- Get the utilization rate of the protocol
Liquidation Hooks
Hooks for liquidation-related functionality:
useIsLiquidatable
- Check if an account can be liquidateduseAbsorb
- Absorb (liquidate) an underwater accountuseBuyCollateral
- Buy collateral from the protocol during liquidationuseGetAskPrice
- Get the ask price for collateral during liquidationuseGetLiquidatorPoints
- Get the liquidator points for an accountuseGetReserves
- Get the reserves of the protocoluseGetCollateralReserves
- Get the collateral reserves for a specific assetuseGetTargetReserves
- Get the target reserves for the protocol
Protocol Rewards Hooks
Hooks for managing protocol rewards:
useBaseTrackingAccrued
- Track accrued rewards for the base assetuseGetRewardOwed
- Get the amount of reward token accrued but not yet claimeduseClaimReward
- Claim accrued rewards