# FeesEscrow

The *FeesEscrow* contract is a very short contract that has only one function: to temporarily store execution layer rewards.&#x20;

Each time one of the validators in the LEEQUID protocol proposes a block, it benefits from transaction ordering tips, also called MEV or execution layer rewards. It does so by prioritizing transactions that offer a tip, which goes to an address called the "fee recipient". This address is set in *fee\_recipient* attribute of the block's header and, expectedly, the LEEQUID protocol's validators are configured to set it to the *FeesEscrow* contract's address on mainnet. You can learn more about the block structure of EVM based blockchains in the [Ethereum official docs](https://ethereum.org/en/developers/docs/blocks/).

Each time the [Oracles ](/leequid/leequid-in-depth/smart-contracts/oracles.md)in LEEQUID update the reward balance of the protocol (which happens roughly twice a day) they sweep the fees accumulated in the *FeesEscrow* contract and transfer them to the Rewards contract. That's the purpose of the *transferToRewards* function as seen below:

```solidity
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity ^0.8.20;

import {IFeesEscrow} from "../interfaces/IFeesEscrow.sol";

/**
 * @title FeesEscrow
 *
 * @dev FeesEscrow contract is used to receive tips from validators and transfer
 * them to the Rewards contract via a call to the transferToRewards method by the Rewards contract.
 */
contract FeesEscrow is IFeesEscrow {
    // @dev Rewards contract's address.
    address payable private immutable rewards;

    constructor(address _rewards) {
        rewards = payable(_rewards);
    }

    /**
     * @dev See {IFeesEscrow-transferToRewards}.
     */
    function transferToRewards() external override returns (uint256) {
        require(msg.sender == rewards, "FeesEscrow: invalid caller");

        uint256 balance = address(this).balance;

        if (balance == 0) {
            return balance;
        }

        rewards.transfer(balance);

        emit FeesTransferred(balance);

        return balance;
    }

    /**
     * @dev Allows FeesEscrow contract to receive execution layer tips. Later these rewards will be transferred
     * to the `Rewards` contract by `FeesEscrow.transferToRewards` method which is called by the `Rewards` contract.
     */
    receive() external payable {}
}
```


---

# 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.leequid.io/leequid/leequid-in-depth/smart-contracts/feesescrow.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.
