Flux is a decentralized borrowing protocol built on the Radix Ledger using Scrypto. It allows users to mint fUSD, a stablecoin soft-pegged to the US Dollar, by depositing various accepted crypto assets as collateral into Collateralized Debt Positions (CDPs).
The core mechanism involves users locking collateral into a CDP and minting fUSD against it, provided the loan remains sufficiently overcollateralized according to the specific collateral's Minimum Collateral Ratio (MCR). Users can manage their CDPs by adding/removing collateral, borrowing more fUSD, or repaying their debt. The protocol includes mechanisms for liquidations (when CDPs become undercollateralized) and redemptions (allowing users to swap fUSD for underlying collateral at face value, helping maintain the peg) facilitated by Stability Pools.
- fUSD (
fUSD): The fungible stablecoin minted by the protocol. - CDP NFT (
fusdLOAN): A non-fungible token representing ownership and state of a specific Collateralized Debt Position. - Privileged Borrower NFT (
fusdPRIV): An optional non-fungible token that can grant special privileges to linked CDPs, such as redemption opt-outs or liquidation notice periods. - Controller Badge (
fusdCTRL): A fungible token used internally for authorization between protocol components.
The protocol is modular, consisting of several interacting components:
-
flux_component(src/flux_component.rs):- The core logic engine of the protocol.
- Manages accepted collateral types, their parameters (MCR, price), and storage vaults.
- Handles the creation, modification, and closing of CDPs (represented by NFTs).
- Controls the minting and burning of
fUSD. - Implements the core logic for liquidations and redemptions.
- Manages protocol parameters and operational stops.
- Handles interest rate calculations and CDP sorting based on collateral ratios.
- Manages Privileged Borrower NFTs and their linkage to CDPs.
-
proxy(src/proxy.rs):- The main user-facing entry point for the protocol.
- Routes user actions (like opening CDPs, borrowing, repaying) to the appropriate underlying components (
Flux,FlashLoans,StabilityPools). - Interacts with an external price Oracle component to fetch collateral prices needed for various operations.
- Manages controller badges to authorize calls between components.
- Handles user-provided proofs (e.g., for CDP ownership).
- Provides administrative functions for protocol management.
- Manages the protocol's DApp Definition.
-
flash_loans(src/flash_loans.rs):- Provides flash loan functionality for
fUSD. - Allows users (authorized via the
Proxy) to borrowfUSDthat must be repaid within the same transaction, plus a small interest fee. - Uses transient
LoanReceiptNFTs to track active flash loans within a transaction.
- Provides flash loan functionality for
-
stability_pools(src/stability_pools.rs):- Manages pools of
fUSDdeposited by users, specific to each collateral type. - Acts as the primary source of liquidity for liquidating undercollateralized CDPs.
fUSDfrom the pool covers the debt, and the pool receives the liquidated collateral (often at a discount). - Facilitates
fUSDredemptions by coordinating with theFluxcomponent. - Distributes rewards (from liquidations, fees) among pool depositors.
- Triggers periodic interest charging on CDPs via the
Fluxcomponent. - Implements a "Panic Mode" using centralized stablecoins for liquidations when a pool's
fUSDis depleted. - Manages reward distribution between stability pools, liquidity rewards, and the payout component.
- Manages pools of
-
payout_component(src/payout_component.rs):- Manages the distribution of accumulated
fUSDrewards from the protocol. - Receives a portion of protocol fees and rewards from stability pools.
- Allows users to claim rewards by providing a specified payment token.
- Supports configurable payment requirements and burning mechanisms.
- Provides administrative functions for managing reward distribution parameters.
- Emits events for tracking reward claims and parameter updates.
- Manages the distribution of accumulated
-
shared_structs(src/shared_structs.rs):- Defines common data structures used across multiple components, such as
Cdp,PrivilegedBorrowerData,CdpStatus, andCollateralInfoReturn.
- Defines common data structures used across multiple components, such as
-
events(src/events.rs):- Defines the event structs emitted by the components (e.g.,
EventNewCdp,EventLiquidateCdp) for off-ledger tracking and integration.
- Defines the event structs emitted by the components (e.g.,
This project uses the Scrypto toolchain.
- Install Scrypto: Follow the instructions at docs.radixdlt.com.
- Build: Navigate to the project root directory (
flux) and run:scrypto build
- Test: (Assuming tests are implemented)
scrypto test
Deploying the Flux protocol involves:
- Deploying dependent components (Oracle, Payout Component).
- Building the package (
scrypto build). - Publishing the package to the ledger.
- Instantiating the
Proxycomponent using theProxy::newfunction, providing the necessary addresses (Oracle, Payout, Owner Badge, initial Stablecoin). This function will automatically instantiate theFlux,FlashLoans, andStabilityPoolscomponents and link them together. - Configuring the protocol via the
Proxy's admin methods (e.g., adding collateral types usingProxy::new_collateral).
The protocol includes several configurable parameters that can be adjusted by the admin:
-
Stability Pool Parameters:
- Default payout split ratio
- Default liquidity rewards split ratio
- Default stability pool split ratio
- Pool buy price modifiers
- Contribution fees (flat and percentage)
- Lowest interest history length
-
Payout Component Parameters:
- Required payment token and amount for claiming rewards
- Burn mechanism configuration
- Reward distribution settings
-
General Protocol Parameters:
- Minimum Collateral Ratios (MCR) for each collateral type
- Liquidation parameters
- Interest rate settings
- Redemption fees and limits
-
Controller Badge System:
- Strict authorization controls between components
- Multi-signature requirements for critical operations
-
Panic Mode:
- Emergency liquidation mechanism using centralized stablecoins
- Configurable notice periods for privileged borrowers
-
Redemption Protection:
- Optional redemption opt-out for privileged borrowers
- Dynamic redemption fees based on protocol usage
- Website: https://flux.ilikeitstable.com
- Documentation: https://docs.ilikeitstable.com
- DAO: https://dao.ilikeitstable.com