# Core Architecture

### Contract Structure

The system consists of two main contracts:

* [`RepoTokenLinkedListStorageV1`](/periphery-contracts/blue-sheets/solidity-api-latest/repotokenlinkedlist.sol-repotokenlinkedliststoragev1.md): Defines the storage layout
* [`RepoTokenLinkedList`](/periphery-contracts/blue-sheets/solidity-api-latest/repotokenlinkedlist.sol-repotokenlinkedlist.md): Implements the core trading logic and access control

#### Key Dependencies

* OpenZeppelin Upgradeable contracts for:
  * Access Control
  * Pausable functionality
  * Reentrancy protection
  * UUPS upgradeability pattern
* Integration with Term Protocol contracts:
  * [`TermController`](/latest/protocol-class/termcontroller.md)
  * [`TermDiscountRateAdapter`](/periphery-contracts/blue-sheets/solidity-api-latest/termdiscountrateadapter.sol.md)
  * [`TermRepoServicer`](/latest/term-repo-class/term-servicer-group/termreposervicer.md)

### Storage Structure

#### Listing Management

```solidity
struct Listing {
    address seller;
    address token;
    uint256 amount;
    uint256 next;
    uint256 prev;
}

struct Queue {
    uint256 head;
    uint256 tail;
}
```

The contract uses a linked list implementation for efficient listing management, with separate queues for each RepoToken.


---

# 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://developers.term.finance/periphery-contracts/blue-sheets/core-architecture.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.
