> For the complete documentation index, see [llms.txt](https://docs.zivoe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zivoe.com/developer-docs/lockers/ocr_modular.sol.md).

# OCR\_Modular.sol

OCR -> On-Chain Redemption

## Introduction

OCR stands for "On-Chain Redemption".

This locker is responsible for handling redemptions of tranche tokens to stablecoins.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-550&t=uVYkxvhAjxnKHa2E-4>" %}

#### State Variables

<table><thead><tr><th width="182.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>stablecoin</td><td>The stablecoin redeemable in this contract.</td></tr><tr><td>uint256</td><td>epoch</td><td>The timestamp of current epoch.</td></tr><tr><td>uint256</td><td>epochDiscountJunior</td><td>Redemption discount for $zJTT (junior tranche).</td></tr><tr><td>uint256</td><td>epochDiscountSenior</td><td>Redemption discount for $zSTT (senior tranche).</td></tr><tr><td>uint256</td><td>redemptionsAllowedJunior</td><td>Redemptions allowed for $zJTT (junior tranche).</td></tr><tr><td>uint256</td><td>redemptionsAllowedSenior</td><td>Redemptions allowed for $zSTT (senior tranche).</td></tr><tr><td>uint256</td><td>redemptionsFeeBIPS</td><td>Fee for redemptions (in BIPS).</td></tr><tr><td>uint256</td><td>redemptionsQueuedJunior</td><td>Redemptions queued for $zJTT (junior tranche).</td></tr><tr><td>uint256</td><td>redemptionsQueuedSenior</td><td>Redemptions queued for $zSTT (senior tranche).</td></tr><tr><td>uint256</td><td>requestCounter</td><td>Increments with new requests.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr><tr><td>uint256</td><td>RAY</td><td>Private constant, <code>10**27</code></td></tr><tr><td>mapping(uint256 => <a data-mention href="#request">#request</a>)</td><td>requests</td><td>Mapping of all requests.</td></tr></tbody></table>

#### Request

This struct stores information for redemptions requests.

<table><thead><tr><th width="137.33333333333331">Type</th><th width="206">Variable</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account making the request</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of the request ($zSTT and $zJTT)</td></tr><tr><td>uint256</td><td>unlocks</td><td>The timestamp after which this request may be processed</td></tr><tr><td>bool</td><td>seniorElseJunior</td><td>The tranche this request is for (true = Senior, false = Junior)</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol.md)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol.md)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol.md)

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - This pulls capital from the DAO.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to `owner()`.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to `owner()`.
* [#createrequest](#createrequest "mention") - Creates a redemptions request.
* [#destroyrequest](#destroyrequest "mention") - Destroys a redemption request.
* [#processrequest](#processrequest "mention") - Processes a redemption request.
* [#tickepoch](#tickepoch "mention") - This function will start a new epoch.
* [#updateredemptionsfeebips](#updateredemptionsfeebips "mention") - Updates the state variable "redemptionFeeBips".

[#events](#events "mention")

* [#epochticked](#epochticked "mention")
* [#requestcreated](#requestcreated "mention")
* [#requestdestroyed](#requestdestroyed "mention")
* [#requestprocessed](#requestprocessed "mention")
* [#updatedredemptionsfeebips](#updatedredemptionsfeebips "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol.md)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol.md)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol.md)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`pushToLocker()`**

This pulls capital from the DAO.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override _tickEpoch onlyOwner nonReentrant;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to pull from the DAO.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of asset to pull from the DAO.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLocker()`**

Migrates entire ERC20 balance from locker to `owner()`.

```solidity
function pullFromLocker(address asset, bytes calldata data) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLockerPartial()`**

Migrates specific amount of ERC20 from locker to `owner()`.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external;

```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`createRequest()`**

Creates a redemptions request.

```solidity
function createRequest(
    uint256 amount, 
    bool seniorElseJunior
) external _tickEpoch nonReentrant;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit for the request.</td></tr><tr><td>uint256</td><td>seniorElseJunior</td><td>he tranche to deposit for (true = Senior, false = Junior).</td></tr></tbody></table>

Emits the [#requestcreated](#requestcreated "mention") event

#### **`destroyRequest()`**

Destroys a redemption request.

```solidity
function destroyRequest(uint256 id) external _tickEpoch nonReentrant;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the request to destroy.</td></tr></tbody></table>

Emits the [#requestdestroyed](#requestdestroyed "mention") event

#### **`processRequest()`**

Processes a redemption request.

```solidity
function processRequest(uint256 id) external _tickEpoch nonReentrant;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the request to process.</td></tr></tbody></table>

Emits the [#requestprocessed](#requestprocessed "mention") event

#### **`tickEpoch()`**

This function will start a new epoch.

```solidity
function tickEpoch() public;
```

Emits the [#epochticked](#epochticked "mention") event

#### **`updateRedemptionsFeeBIPS()`**

Updates the state variable "redemptionFeeBips".

```solidity
function updateRedemptionsFeeBIPS(
    uint256 _redemptionsFeeBIPS
) external _tickEpoch;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_redemptionsFee</td><td>The new value for redemptionsFeeBIPS (in BIPS).</td></tr></tbody></table>

Emits the [#updatedredemptionsfeebips](#updatedredemptionsfeebips "mention") event

## Events

#### **`EpochTicked()`**

Emitted during [#tickepoch](#tickepoch "mention")

```solidity
event EpochTicked(
    uint256 epoch, 
    uint256 redemptionsAllowedJunior, 
    uint256 redemptionsAllowedSenior,
    uint256 epochDiscountJunior, 
    uint256 epochDiscountSenior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="238">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>epoch</td><td>The timestamp of the start of this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>redemptionsAllowedJunior</td><td>Redemptions allowed for $zJTT (junior tranche) for this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>redemptionsAllowedSenior</td><td>Redemptions allowed for $zSTT (senior tranche) for this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>epochDiscountJunior</td><td>Redemption discount for $zJTT (junior tranche) for this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>epochDiscountSenior</td><td>Redemption discount for $zSTT (senior tranche) for this epoch.</td></tr></tbody></table>

#### **`RequestCreated()`**

Emitted during [#createrequest](#createrequest "mention")

```solidity
event RequestCreated(
    uint256 indexed id, 
    address indexed account, 
    uint256 amount, 
    bool indexed seniorElseJunior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="170">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the request created.</td></tr><tr><td>address</td><td>True</td><td>account</td><td>The account creating a request.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount deposited for the request ($zJTT or $zSTT).</td></tr><tr><td>bool</td><td>True</td><td>seniorElseJunior</td><td>The tranche deposited for (true = Senior, false = Junior).</td></tr></tbody></table>

#### **`RequestDestroyed()`**

Emitted during [#destroyrequest](#destroyrequest "mention")

```solidity
event RequestDestroyed(
    uint256 indexed id, 
    address indexed account, 
    uint256 amount, 
    bool indexed seniorElseJunior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="170">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the request destroyed.</td></tr><tr><td>address</td><td>True</td><td>account</td><td>The account destroying the request.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount returned from the request ($zJTT or $zSTT).</td></tr><tr><td>bool</td><td>True</td><td>seniorElseJunior</td><td>The tranche deposited for (true = Senior, false = Junior).</td></tr></tbody></table>

#### **`RequestProcessed()`**

Emitted during [#processrequest](#processrequest "mention")

```solidity
event RequestProcessed(
    uint256 indexed id, 
    address indexed account, 
    uint256 burnAmount, 
    uint256 redeemAmount, 
    bool indexed seniorElseJunior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="170">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the request processed.</td></tr><tr><td>address</td><td>True</td><td>account</td><td>The account receiving the redeemed tokens.</td></tr><tr><td>uint256</td><td>False</td><td>burnAmount</td><td>The amount of tranche tokens ($zJTT or $zSTT) burned from the request.</td></tr><tr><td>uint256</td><td>False</td><td>redeemAmount</td><td>The amount reddeemed from the processed request.</td></tr><tr><td>bool</td><td>True</td><td>seniorElseJunior</td><td>The tranche deposited for (true = Senior, false = Junior).</td></tr></tbody></table>

#### **`UpdatedRedemptionsFeeBIPS()`**

Emitted during [#updateredemptionsfee](#updateredemptionsfee "mention")&#x20;

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.zivoe.com/developer-docs/lockers/ocr_modular.sol.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
