This document provides an overview of all smart contracts in the ACBU ecosystem.
make buildcargo test --workspacecargo test -p <contract_name>See DEPLOYMENT.md for deployment instructions.
Handles conversion of USDC and fiat deposits into ACBU tokens.
initialize: Configure admin, oracle, reserve tracker, tokens, and feesmint_from_usdc: Mint ACBU from USDC depositmint_from_fiat: Mint ACBU from fiat deposit via fintech partnermint_from_basket: Mint ACBU by depositing S-tokens in basket proportionsmint_from_single: Mint ACBU by depositing single S-tokenpause/unpause: Emergency pause mechanismset_fee_rate: Update fee rates
- Uses push model: users transfer tokens into the minting contract
- Does not rely on
approve/transfer_fromallowances
- Oracle Contract: ACBU/USD and currency/USD rates
- Reserve Tracker: Reserve verification
- ACBU Token: Minting tokens
- USDC Token: Receiving deposits
Handles ACBU token redemption and triggers fiat withdrawals.
initialize: Configure admin, oracle, reserve tracker, tokens, and feesburn_for_currency: Burn ACBU for single currency redemptionburn_for_basket: Burn ACBU for proportional basket redemptionredeem_single: Redeem ACBU for single S-tokenredeem_basket: Redeem ACBU for basket of S-tokenspause/unpause: Emergency pause mechanismset_fee_rate: Update fee rates
- Uses pull model for S-token redemption
- Vault must grant contract allowance via
approve - Contract uses
transfer_fromto move tokens
- Oracle Contract: Currency/USD rates
- Reserve Tracker: Reserve verification
- ACBU Token: Burning tokens
- Backend: Processing withdrawals via events
Aggregates exchange rates from multiple validators and provides rate data.
initialize: Set up validators, currencies, and basket weightsupdate_rate: Update exchange rate (validator function)get_rate: Get current rate for a currencyget_acbu_usd_rate: Get ACBU/USD rate (basket-weighted)add_validator/remove_validator: Manage validators
- Median of 3 source rates
- Outlier detection (>3% deviation)
- Emergency updates (>5% moves)
- Basket-weighted ACBU/USD rate
- Update rates: Validators only (multisig)
- Read rates: Public
- Manage validators: Admin only
Tracks total reserves backing ACBU tokens across multiple currencies.
initialize: Configure admin and oracleadd_reserve: Record reserve depositsremove_reserve: Record reserve withdrawalsis_sufficient: Check if reserves are sufficient for supplyget_total_reserves_usd: Get total reserves in USD
- Used by Minting and Burning contracts for reserve verification
- Queries Oracle for currency rates
Provides multi-signature authorization for administrative actions.
initialize: Set up signers and thresholdpropose(target, action): Create a proposal authorising a typed action on a specific contractapprove: Approve proposal (signer function)execute: Execute the approved proposal, invoking exactly the stored target and actionpropose_update_config: Propose a new signer set and thresholdpropose_upgrade: Propose a WASM upgrade of the multisig itself
- M-of-N threshold signatures
- Proposal expiry
- Approvals and execution are bound to a typed
MultisigActionand target, so a proposal can only ever perform the action the signers approved
Manages escrowed funds for various use cases.
initialize: Configure admin and tokencreate_escrow: Create new escrowrelease_escrow: Release funds to beneficiarycancel_escrow: Cancel and refund escrowget_escrow: Query escrow details
- Payment escrow
- Conditional transfers
- Time-locked funds
Provides peer-to-peer lending functionality for ACBU tokens.
initialize: Configure admin and tokendeposit: Deposit ACBU into lending poolwithdraw: Withdraw ACBU from lending poolborrow: Borrow ACBU from a specific lender's liquidity (borrower and lender must both authorize)repay: Repay borrowed ACBUliquidate: Write off an overdue loan (lender only)
- Uncollateralized, single-asset lending: liquidity and principal are both ACBU
- Interest accrual
- Pool balance tracking
The pool takes no collateral. Posting ACBU against an ACBU loan locks at least as
much of the borrowed asset as it releases, so it extends no purchasing power and
gives the lender no protection; the earlier collateral_amount >= amount check
has been removed. Because the loan is unsecured, the lender bears the full credit
risk and must authorize each individual loan alongside the borrower.
LoanData.collateral_amount (always 0) and error code 2014
(InsufficientCollateral) are reserved for a future distinct-asset collateral
extension, which also requires oracle pricing. An overdue loan can be written off
by its lender via liquidate(), which removes the principal from the lender's
tracked balance and marks the loan as LoanStatus::Defaulted.
Provides interest-bearing savings accounts for ACBU tokens.
initialize: Configure admin, token, and interest ratedeposit: Deposit ACBU to earn interestwithdraw: Withdraw ACBU and accrued interestlock: Lock deposits for higher interest ratesget_balance: Query balance and accrued interest
- Automatic interest accrual
- Lock periods for higher rates
- Emergency withdrawal with penalties
Common types, utilities, and constants used across all contracts.
ContractError: Standard error enumCurrencyCode: Currency typeDataKey: Common storage keysreentrancy_guard: Re-entrancy protection- Constants:
DECIMALS,BASIS_POINTS, etc.
All contracts include comprehensive test suites covering:
- Happy path scenarios
- Error conditions
- Edge cases
- Access control
- Reentrancy protection
Run tests with:
cargo test --workspace -- --nocaptureSee threat-model.md and reentrancy-audit-c036.md for security documentation.