HoneyFactory
This is the factory contract for minting and redeeming Honey. It manages collateral vaults, handles basket mode operations, and provides liquidation functionality.
Inherits: IHoneyFactory, VaultAdmin
State Variables
honey
The Honey token contract.
Honey public honey;forcedBasketMode
Whether basket mode is forced regardless of price oracle.
bool public forcedBasketMode;liquidationEnabled
Whether liquidation is enabled.
bool public liquidationEnabled;priceOracle
The price oracle contract.
IPriceOracle public priceOracle;priceFeedMaxDelay
Maximum number of seconds of tolerated staleness for price feeds.
uint256 public priceFeedMaxDelay;View Functions
getWeights
Returns weights of all registered assets except for paused ones.
function getWeights() external view returns (uint256[] memory weights);isPegged
Checks if an asset is pegged within its allowed range.
function isPegged(address asset) public view returns (bool);isBasketModeEnabled
Gets the status of basket mode. For minting, enabled if all collaterals are depegged or bad. For redeeming, enabled if at least one non-liquidated asset is depegged.
function isBasketModeEnabled(bool isMint) public view returns (bool basketMode);Functions
mint
Mints Honey by depositing collateral assets.
Parameters:
asset: The collateral asset to depositamount: Amount of collateral to depositreceiver: Address to receive minted HoneyexpectBasketMode: Expected basket mode status
Errors:
NotPegged: If asset is not pegged and basket mode is disabledUnexpectedBasketModeStatus: If basket mode status doesn't match expectationExceedGlobalCap: If mint would exceed global capExceedRelativeCap: If mint would exceed relative capZeroWeight: If asset has zero weight in basket mode
function mint(
address asset,
uint256 amount,
address receiver,
bool expectBasketMode
) external returns (uint256);redeem
Redeems Honey for collateral assets.
Parameters:
asset: The collateral asset to receivehoneyAmount: Amount of Honey to redeemreceiver: Address to receive collateralexpectBasketMode: Expected basket mode status
Errors:
UnexpectedBasketModeStatus: If basket mode status doesn't match expectationExceedGlobalCap: If redeem would exceed global capExceedRelativeCap: If redeem would exceed relative cap
function redeem(
address asset,
uint256 honeyAmount,
address receiver,
bool expectBasketMode
) external returns (uint256[] memory);liquidate
Liquidates a bad collateral asset for a good one.
Parameters:
badCollateral: The asset to liquidategoodCollateral: The asset to receivegoodAmount: Amount of good collateral to provide
Errors:
LiquidationDisabled: If liquidation is not enabledAssetIsNotBadCollateral: If bad collateral is not marked as badLiquidationWithReferenceCollateral: If trying to liquidate reference collateralExceedRelativeCap: If liquidation would exceed relative capExceedGlobalCap: If liquidation would exceed global capZeroAmount: If liquidation amount is zero
function liquidate(
address badCollateral,
address goodCollateral,
uint256 goodAmount
) external returns (uint256 badAmount);recapitalize
Recapitalizes a collateral vault.
Parameters:
asset: The asset to recapitalizeamount: Amount to provide
Errors:
RecapitalizeNotNeeded: If vault doesn't need recapitalizationNotPegged: If asset is not peggedInsufficientRecapitalizeAmount: If amount is below minimumExceedRelativeCap: If recapitalization would exceed relative capExceedGlobalCap: If recapitalization would exceed global cap
function recapitalize(address asset, uint256 amount) external;Events
HoneyMinted
event HoneyMinted(
address indexed from,
address indexed to,
address indexed asset,
uint256 assetAmount,
uint256 mintAmount
);Emitted when Honey is minted.
HoneyRedeemed
event HoneyRedeemed(
address indexed from,
address indexed to,
address indexed asset,
uint256 assetAmount,
uint256 redeemAmount
);Emitted when Honey is redeemed.
Liquidated
event Liquidated(
address badAsset,
address goodAsset,
uint256 amount,
address sender
);Emitted when liquidation is performed.
Recapitalized
event Recapitalized(address asset, uint256 amount, address sender);Emitted when vault is recapitalized.