Skip to content

VaultV5

VaultV5 is the LP token management and betting contract system of Chaos Protocol, allowing users to bet on token price movements.

Basic Information

PropertyValue
Contract TypeUUPS Upgradeable
Core FunctionsLP Management + Betting Contracts
Contract Lock Time3 days
LP Transfer Fee10%
Cancellation Fee Rate1%-5% (Dynamic)

Core Functions

1. LP Token Management

VaultV5 manages all LP tokens generated through BurnPoolV2.

LP Sources

solidity
// Record via BurnPoolV2
function recordLpDeposit(
    address user,
    uint256 lpAmount
) external onlyBurnPool;

// Direct deposit
function depositLp(uint256 lpAmount) external;

LP Query

solidity
// Query user LP balance
function getUserLpBalance(address user) external view returns (uint256);

// Query LP value in USDT
function getUserUsdtBalance(address user) external view returns (uint256);

LP Transfer

Users can transfer LP tokens to other addresses:

solidity
function transferLpToken(
    address to,
    uint256 lpAmount
) external;

Fee Mechanism:

  • 10% fee on transfers
  • LP tokens corresponding to the fee are burned (sent to dead address)
solidity
uint256 fee = lpAmount * 10 / 100;
uint256 netAmount = lpAmount - fee;
// fee portion is burned

2. Betting Contract System

The core innovation of VaultV5 is the betting contract system, allowing users to bet on Chaos token price movements.

Contract Status Flow

Create Contract → Locked (30 min) → Waiting for Taker → Active (3 days) → Settle/Cancel
      ↓               ↓                   ↓                 ↓              ↓
    USDT Locked    Cannot Cancel      Can Take Contract   Price Movement  P&L Distribution

Create Contract (Creator)

solidity
function createContract(
    uint256 usdtAmount
) external returns (uint256 contractId);

Creation Conditions:

  • Use USDT to create
  • Cannot cancel within 30-minute lock period
  • Creation limit based on burn amount:
    • Base: 10% of total burn amount
    • With referral: Additional +2%
  • Minimum 30 USDT

Take Contract (Taker)

solidity
function takeContract(
    uint256 contractId,
    uint256 lpAmount
) external;

Taking Flow:

  1. Use equivalent LP tokens to take contract
  2. Contract splits LP into USDT and tokens
  3. Token portion is sold back for USDT
  4. Forms a betting position based on current price

Settle/Cancel

solidity
function cancelContract(uint256 contractId) external;

Settlement Rules:

SituationCreatorTaker
Token DepreciatesGets back principalLP processed according to loss ratio
Token AppreciatesGets 50% of profitGets 50% of profit

Limitations:

  • Maximum profit cannot exceed 2x investment
  • Cannot cancel during lock period (30 minutes)

Cancellation Fee

Fee dynamically adjusts based on LP token burn ratio:

solidity
function getCancelFeeRate(
    uint256 contractId
) external view returns (uint256);
Burn RatioFee Rate
≥ 90%1%
≥ 50%1% - 5% (Linear decrease)
< 50%5%

3. Price Benchmark

Betting contracts use the price at creation as the benchmark:

solidity
struct Contract {
    uint256 benchmarkPrice;  // Price at creation
    uint256 creatorAmount;   // Creator's USDT investment
    uint256 takerAmount;     // Taker's LP value
    uint256 createdAt;       // Creation time
    uint256 lockedUntil;     // Lock deadline
    ContractStatus status;   // Contract status
}

User Operations

Query Contracts

solidity
// Query single contract
function getContract(uint256 contractId) external view returns (Contract memory);

// Query all open contracts
function getOpenContractsV2() external view returns (uint256[] memory);

// Query user's created contracts
function getUserCreatedContracts(address user) external view returns (uint256[] memory);

// Query user's taken contracts
function getUserTakenContracts(address user) external view returns (uint256[] memory);

Preview Cancellation

solidity
// Preview cancellation P&L
function previewCancellation(
    uint256 contractId
) external view returns (
    int256 creatorPnl,
    int256 takerPnl,
    uint256 fee
);

Permit2 Support

solidity
function createContractWithPermit(
    uint256 usdtAmount,
    Permit2Data calldata permit2Data
) external returns (uint256 contractId);

Security Features

  1. UUPS Upgradeable: Supports contract upgrade
  2. Time Lock: 30-minute lock period prevents instant cancellation
  3. Dynamic Fee: Incentivizes long-term LP holding
  4. Profit Cap: Maximum 2x profit limit
  5. Owner Withdrawal: Emergency token extraction

Events

solidity
event ContractCreated(uint256 indexed contractId, address indexed creator, uint256 amount);
event ContractTaken(uint256 indexed contractId, address indexed taker, uint256 lpAmount);
event ContractCancelled(uint256 indexed contractId, int256 creatorPnl, int256 takerPnl);
event LpTransferred(address indexed from, address indexed to, uint256 amount, uint256 fee);

Chaos Protocol Documentation