Treasury System

The treasury system manages platform funds through four specialized treasuries, each dedicated to specific purposes within the Looping Binary ecosystem.

What are Treasuries?

Treasuries are system-controlled wallets that hold and manage coins for specific platform purposes. They enable organized fund management, transparent accounting, and secure payment processing across all connected platforms.

The Four Treasuries

Each treasury serves a distinct purpose in the ecosystem:

Course Treasury

COURSE

Manages payments for educational courses and learning materials on the LMS platform (Intellex).

Use Cases:

  • Course enrollment payments
  • Learning material purchases
  • Certification fees
  • Workshop and training sessions

Subscription Treasury

SUBSCRIPTION

Handles recurring subscription payments for premium features and services across all platforms.

Use Cases:

  • Monthly/annual memberships
  • Premium platform features
  • Ad-free experiences
  • Exclusive community access

Reward Treasury

REWARD

Dedicated to distributing prizes, bonuses, and incentives to users across all platforms.

Use Cases:

  • Tournament prize pools
  • Achievement rewards
  • Referral bonuses
  • Promotional giveaways

General Treasury

GENERAL

Multi-purpose treasury for miscellaneous transactions and platform operations not covered by other treasuries.

Use Cases:

  • E-commerce purchases
  • General service payments
  • Platform fees
  • Operational expenses

Treasury Operations

Get Treasury Balance

Check the current balance of any treasury:

GET /api/admin/treasury/:type/balance
fetch('https://api.loopingbinary.com/api/admin/treasury/COURSE/balance', {
  headers: {
    'x-api-key': process.env.LB_API_KEY,
    'Authorization': 'Bearer ' + token
  }
})

Response:

{
  "treasuryType": "COURSE",
  "balance": 45780.50,
  "lastUpdated": "2025-10-02T17:45:00Z"
}

Transfer to Treasury

Users can transfer coins to treasuries for purchases:

POST /api/coins/transfer-to-treasury
fetch('https://api.loopingbinary.com/api/coins/transfer-to-treasury', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + token
  },
  body: JSON.stringify(({
    treasuryType: 'COURSE',
    amount: 50,
    reason: 'Purchase: Advanced JavaScript Course'
  })
})

Transfer from Treasury

Admins can transfer coins from treasuries to users (payouts, refunds):

POST /api/admin/treasury/transfer
fetch('https://api.loopingbinary.com/api/admin/treasury/transfer', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.LB_API_KEY,
    'Authorization': 'Bearer ' + token
  },
  body: JSON.stringify(({
    fromTreasury: 'REWARD',
    toUserId: 123,
    amount: 500,
    reason: 'Tournament 1st place prize'
  })
})

Treasury Types Reference

Use these exact values when specifying treasury types in API calls:

TypeValuePurpose
Course TreasuryCOURSELMS platform payments
Subscription TreasurySUBSCRIPTIONRecurring memberships
Reward TreasuryREWARDPrizes and incentives
General TreasuryGENERALMiscellaneous transactions

Security & Access Control

  • Only admins with proper API keys can check treasury balances
  • Treasury-to-user transfers require admin permissions
  • All treasury operations are logged with complete audit trails
  • Treasuries cannot have negative balances
  • Transfer limits can be configured per treasury type

Common Use Cases

Course Purchase Flow

  1. User selects a course on LMS platform
  2. User transfers coins to COURSE treasury
  3. Platform grants course access to user
  4. Treasury balance increases

Tournament Prize Distribution

  1. Tournament ends with winners determined
  2. Admin transfers from REWARD treasury to winners
  3. Winners receive coins in their wallets
  4. REWARD treasury balance decreases

Subscription Renewal

  1. Monthly subscription comes due
  2. System automatically transfers from user to SUBSCRIPTION treasury
  3. If successful, subscription remains active
  4. If insufficient balance, subscription is paused