# Functions and Events

### Function index

**AccountManager**

* `openAccount(owner)`
* `setOperator(accountId, operator, permissions)`
* `deposit(accountId, profileId, amount)`
* `withdraw(accountId, profileId, amount, to)`
* `mint(accountId, profileId, amount, to)`
* `repay(accountId, profileId, amount, from)`
* `depositAndMint(...)`
* `repayAndWithdraw(...)`

**Ledger**

* `lock(profileId, accountId, amount)` (adapter only)
* `unlock(profileId, accountId, amount)` (adapter only)
* `increasePrincipal(profileId, accountId, principalDelta)` (AccountManager only)
* `decreasePrincipal(profileId, accountId, principalDelta)` (AccountManager only)
* `burnRwaUsd(from, amt)` / `mintRwaUsd(to, amt)`
* `markUnwinding(accountId)` (UnwindEngine only)
* `clearAfterAuction(...)` (AuctionHouse only)

**PriceRouter**

* `getPrice(profileId) -> (price, status, updatedAt)`

**UnwindEngine**

* `trigger(accountId, profileId) -> auctionId`

**AuctionHouse**

* `kick(profileId, accountId, collateralAmt, debtTarget) -> auctionId`
* `take(auctionId, collateralAmt, maxPrice)`
* `settle(auctionId)`

**PegRail**

* `swapIn(stableIn, to)`
* `swapOut(rwaUsdIn, to)`

***

### Events

A non-exhaustive set; emit these consistently:

* `AccountOpened(accountId, owner)`
* `OperatorSet(accountId, operator, permissions)`
* `CollateralDeposited(accountId, profileId, amount)`
* `CollateralWithdrawn(accountId, profileId, amount, to)`
* `RwaUsdMinted(accountId, profileId, amount, to)`
* `RwaUsdRepaid(accountId, profileId, amount, from)`
* `IndexAccrued(profileId, newIndex)`
* `PriceUpdated(profileId, price, status, updatedAt)`
* `UnwindTriggered(accountId, profileId, auctionId)`
* `AuctionKicked(auctionId, profileId, collateral, debtTarget)`
* `AuctionTaken(auctionId, buyer, collateralOut, rwaUsdIn, price)`
* `AuctionSettled(auctionId, clearedDebt, collateralReturned)`
* `DeficitRecorded(amount)`
* `Paused(flags)` / `Unpaused(flags)`
