User Lifecycle
1. Open account
AccountManager.openAccount(owner) -> accountIdinitialize owner permissions
2. Deposit collateral
Flow:
user approves adapter
AccountManager.deposit(accountId, profileId, amount)adapter pulls token into custody
adapter notifies Ledger:
lock(profileId, accountId, amount)
Requirements:
deposits allowed even if oracle is stale (depositing reduces risk)
collateral enabled flag must be true
3. Mint rwaUSD
Flow:
AccountManager.mint(accountId, profileId, amtRwaUsd, to)FeeAccumulator.accrue(profileId)updates indexLedger computes new principal delta corresponding to desired minted amount (or mints in principal units directly; pick one and keep consistent)
Ledger checks:
oracle status
OKcap not exceeded
post-mint safety check passes
min position threshold satisfied
Ledger:
increases principal
mints rwaUSD to
to
Note on units: The cleanest approach is to mint in current-liability units (what user sees), then convert to principal internally using the current index. That prevents user confusion and keeps UI consistent.
4. Repay (burn rwaUSD)
Flow:
user approves rwaUSD spending
AccountManager.repay(accountId, profileId, amtRwaUsd, from)accrue index
Ledger reduces liability by burning rwaUSD
principal decreases accordingly
if principal hits zero, account is debt-free for that profile
Repayments must always be allowed, even in restricted mode.
5. Withdraw collateral
Flow:
AccountManager.withdraw(accountId, profileId, amount, to)accrue index
Ledger checks post-withdraw safety
Ledger decreases locked collateral
adapter transfers tokens to
to
Withdrawals are risk-increasing and must be blocked when:
oracle status not
OK(policy choice: either block or require higher margin)system is paused
account is under unwind
Last updated