# Assets

**Purpose:** Asset registry with oracle configuration. Maps asset addresses to IDs and stores oracle feed data per asset.

## List of Core Functions

Queries:

* get-nonce: Get total asset count
* get-reverse: Get asset ID by address
* find: Get asset details by address
* lookup: Get asset details by ID
* get-bitmap: Get enabled assets bitmask
* enabled: Check if assets are enabled
* get-status: Get asset status (collateral/debt enabled)
* get-asset-status: Get asset status by address
* status-multi: Get status for multiple assets

Admin:

* insert: Register new asset with oracle config
* update: Update asset oracle configuration
* enable: Enable asset for collateral or debt
* disable: Disable asset for collateral or debt

***

## Function Parameters

### get-nonce

Get total number of registered assets.

| Parameter | Type | Description   |
| --------- | ---- | ------------- |
| (none)    | -    | No parameters |

Returns: `(response uint uint)` - Asset count

***

### get-reverse

Get asset ID by contract address.

| Parameter | Type      | Description            |
| --------- | --------- | ---------------------- |
| asset     | principal | Asset contract address |

Returns: `(response (buff 1) uint)` - Asset ID buffer or error

***

### find

Get asset details by contract address.

| Parameter | Type      | Description            |
| --------- | --------- | ---------------------- |
| asset     | principal | Asset contract address |

Returns: `(response {...} uint)` - Asset details or error

Fields:

* `id`: (buff 1) - Asset ID
* `addr`: principal - Contract address
* `decimals`: uint - Token decimals
* `oracle`: {...} - Oracle configuration

***

### lookup

Get asset details by ID.

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| id        | uint | Asset ID    |

Returns: `(response {...} uint)` - Asset details or error

Fields:

* `id`: (buff 1) - Asset ID
* `addr`: principal - Contract address
* `decimals`: uint - Token decimals
* `oracle`: {...} - Oracle configuration (type, ident, callcode, max-staleness)

***

### get-bitmap

Get enabled assets bitmask. Bits 0-63 represent collateral, bits 64-127 represent debt.

| Parameter | Type | Description   |
| --------- | ---- | ------------- |
| (none)    | -    | No parameters |

Returns: `uint` - Enabled assets bitmask

***

### enabled

Check if asset mask is subset of enabled assets.

| Parameter | Type | Description         |
| --------- | ---- | ------------------- |
| mask      | uint | Asset mask to check |

Returns: `bool` - True if all assets in mask are enabled

***

### get-status

Get asset status including collateral/debt enabled flags.

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| id        | uint | Asset ID    |

Returns: `(response {...} uint)` - Asset status or error

Fields:

* All fields from lookup()
* `id`: uint - Asset ID
* `collateral`: bool - Collateral enabled
* `debt`: bool - Debt enabled

***

### get-asset-status

Get asset status by contract address.

| Parameter | Type      | Description            |
| --------- | --------- | ---------------------- |
| address   | principal | Asset contract address |

Returns: `(response {...} uint)` - Asset status or error

Fields: Same as get-status

***

### status-multi

Get status for multiple assets at once.

| Parameter | Type             | Description       |
| --------- | ---------------- | ----------------- |
| ids       | `(list 64 uint)` | List of asset IDs |

Returns: `(list 64 {...})` - List of asset statuses

***

### insert

Register new asset with oracle configuration. Asset IDs assigned sequentially.

| Parameter   | Type                                                                                       | Description          |
| ----------- | ------------------------------------------------------------------------------------------ | -------------------- |
| ft          | `<ft-trait>`                                                                               | Asset token contract |
| oracle-data | `{ type: (buff 1), ident: (buff 32), callcode: (optional (buff 1)), max-staleness: uint }` | Oracle configuration |

Returns: `(response uint uint)` - Assigned asset ID or error

Authorization: DAO executor only

Oracle fields:

* `type`: Oracle type (0x00=Pyth, 0x01=DIA, 0x02=Mock)
* `ident`: Oracle feed identifier (32 bytes)
* `callcode`: Optional price transformation (0x00=stSTX ratio, 0x01-0x06=zToken indexes)
* `max-staleness`: Maximum age in seconds before price considered stale

Note: Asset decimals auto-detected from token contract

***

### update

Update asset oracle configuration.

| Parameter   | Type                                                                                       | Description              |
| ----------- | ------------------------------------------------------------------------------------------ | ------------------------ |
| asset       | principal                                                                                  | Asset contract address   |
| oracle-data | `{ type: (buff 1), ident: (buff 32), callcode: (optional (buff 1)), max-staleness: uint }` | New oracle configuration |

Returns: `(response bool uint)` - Success or error

Authorization: DAO executor only

Note: Cannot change asset address or decimals, only oracle config

***

### enable

Enable asset for collateral or debt usage.

| Parameter  | Type      | Description                                           |
| ---------- | --------- | ----------------------------------------------------- |
| asset      | principal | Asset contract address                                |
| collateral | bool      | True to enable as collateral, false to enable as debt |

Returns: `(response bool uint)` - Success or error

Authorization: DAO executor only

Note: Updates bitmap: collateral uses bits 0-63, debt uses bits 64-127

***

### disable

Disable asset for collateral or debt usage.

| Parameter  | Type      | Description                                             |
| ---------- | --------- | ------------------------------------------------------- |
| asset      | principal | Asset contract address                                  |
| collateral | bool      | True to disable as collateral, false to disable as debt |

Returns: `(response bool uint)` - Success or error

Authorization: DAO executor only

Note: Updates bitmap to remove asset from enabled set


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zestprotocol.com/start/stacks-market-v2-smart-contracts-overview/v2-contracts/assets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
