# Onboard an asset

> How to let a live vault hold a new asset, from binding its price adapter to registering it on a sub-account and raising its limits.

Source: https://docs.trusslabs.io/vaults/guides/onboard-an-asset

A tracked sub-account holds only assets registered on it, and only assets the vault can price. Onboarding one takes
three changes: a price adapter, a registration, and limits. The first two wait the CRITICAL tier, so holders see a
new asset coming before the vault can buy it.

> **Key points**
>
> - The price adapter comes first, because registering an asset checks its price.
> - Binding the adapter and registering the asset each wait CRITICAL, and are the VaultAdmin's alone.
> - Nothing can be bought until the asset's limits are raised, which waits HIGH.
> - The number of assets and positions a vault can hold is fixed at deployment.

## Before you start

1. Check there is room. The asset must fit under the most assets per sub-account, USDC not counted, and the
   most positions across all sub-accounts. Both are fixed at deployment. On the asset registry, compare
   `totalPositions()` with `maxTotalPositions()`.
2. Check a price adapter exists for the asset on this network.
3. For a lending venue, review it before admitting it. The vault values venue shares at the venue's own
   reported conversion, so know how it records a loss and confirm it charges no withdrawal fee.

## Steps

The VaultAdmin holds every lever below. With timelocks on, schedule them all for the same moment, at least the
CRITICAL tier away. A scheduled call expires a week after it becomes ready, so a HIGH raise scheduled for its own
earliest moment could expire before the CRITICAL steps can run. Then send the steps as one batch through the
AccessManager, so all of them land or none do.

1. Bind its price adapter with `setOracleAdapterForAsset(asset, adapter, params)` on the price oracle (CRITICAL).
   The oracle prices one whole unit through the new adapter first, and refuses an adapter that cannot price it.
2. Register it on the sub-account with `registerAsset(subAccount, asset)` on the asset registry (CRITICAL).
3. Raise its limits (HIGH). For a token bought by swapping, raise its inbound swap limit, and its outbound limit
   for selling, with `raiseRateLimitCapacity(subAccount, asset, inbound, capacity)` and `raiseRateLimitRefillRate`
   on the swap policy. For a lending venue, raise its supply limit with
   `raiseRateLimitCapacity(subAccount, venue, capacity)` on the lend policy.
4. Buy it in the same batch, if wanted, with a swap through the sub-account's `executeModule`. The swap is held to
   its tolerance against the new adapter's price.

## A permissioned token

A token only allowlisted holders may hold goes in an attested sub-account, which holds and moves it itself. The
issuer allowlists that account's address, and the VaultAdmin admits each call to the issuer as a call shape. See
[Add a sub-account](https://docs.trusslabs.io/vaults/guides/add-a-sub-account.md).

## Removing an asset later

A vault manager or the VaultAdmin calls `initiateDeregistration(subAccount, asset)`, which stops anything adding to
the asset, then `finalizeDeregistration` once the sub-account holds none. Both are immediate. For an asset also
held through a lending venue, deregister the venue's shares first. `OracleAdapterSet`, `AssetRegistered`,
`RateLimitCapacityRaised` and `DeregistrationInitiated` record each step.

## Where to read more

| Page | What it covers |
|---|---|
| [Tracked sub-accounts](https://docs.trusslabs.io/vaults/architecture/tracked-sub-accounts.md) | How holdings are valued |
| [Rate limits](https://docs.trusslabs.io/vaults/architecture/rate-limits.md) | Swap and lend limits |
| [Running a vault](https://docs.trusslabs.io/vaults/guides/running-a-vault.md) | Scheduling delayed changes |
