> For the complete documentation index, see [llms.txt](https://developers.term.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.term.finance/periphery-contracts/blue-sheets/core-architecture.md).

# 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.
