Lux Standard

Loans

Collateralized borrowing with yield-bearing collateral

Loans

Collateralized loans that allow borrowing against yield-bearing assets.

How It Works

  1. Deposit yield-bearing tokens (e.g., xLUX, staked assets)
  2. Borrow up to 50% of collateral value
  3. Yield accrues to your collateral position
  4. Withdraw collateral when debt is repaid

Key Concepts

Collateralization

  • Minimum 200% collateralization (50% LTV)
  • Healthy positions protected from liquidation

Supported Collateral

  • xLUX: LiquidLUX vault shares (protocol fee yield)
  • Staked assets: sLUX and other yield-bearing tokens

Functions

deposit

function deposit(
    address yieldToken,
    uint256 amount,
    address recipient
) external returns (uint256 shares)

Deposit yield-bearing tokens as collateral.

mint

function mint(
    uint256 amount,
    address recipient
) external

Borrow liquid tokens against your collateral.

burn

function burn(
    uint256 amount,
    address recipient
) external returns (uint256)

Repay debt by burning liquid tokens.

withdraw

function withdraw(
    address yieldToken,
    uint256 shares,
    address recipient
) external returns (uint256)

Withdraw collateral.

liquidate

function liquidate(
    address owner,
    uint256 shares,
    uint256 minimumAmountOut
) external returns (uint256)

Liquidate underwater positions (when debt exceeds collateral value).

Usage Example

import "@luxfi/contracts/markets/Markets.sol";

// Deposit xLUX as collateral
IERC20(xLUX).approve(address(loans), amount);
loans.deposit(xLUX, amount, msg.sender);

// Borrow (up to 50% of collateral value)
uint256 maxBorrow = loans.getBorrowLimit(msg.sender);
loans.borrow(maxBorrow / 2, msg.sender);

// Check position
(int256 debt, address[] memory tokens) = loans.accounts(msg.sender);

// Repay debt and withdraw collateral
loans.repay(debtAmount, msg.sender);
loans.withdraw(xLUX, shares, msg.sender);

Account Structure

struct Account {
    int256 debt;                                    // Positive = debt, negative = credit
    mapping(address => uint256) balances;           // Share balances per yield token
    mapping(address => uint256) lastAccruedWeights; // Last accrued weights
    Sets.AddressSet depositedTokens;                // Deposited yield tokens
}

Constants

NameValueDescription
BPS10000Basis points divisor
FIXED_POINT_SCALAR1e18Fixed point precision
minimumCollateralization2e18200% (2x collateral required)

Events

event Deposit(address indexed sender, address indexed yieldToken, uint256 amount, address recipient);
event Withdraw(address indexed sender, address indexed yieldToken, uint256 shares, address recipient);
event Mint(address indexed sender, uint256 amount, address recipient);
event Burn(address indexed sender, uint256 amount, address recipient);
event Liquidate(address indexed sender, address indexed owner, uint256 shares);

On this page