# Architecture Overview

<figure><img src="/files/eo8R7Vn8IvZX4eU1YePp" alt=""><figcaption></figcaption></figure>

## Introduction

DEXE contracts offer a strong and effective structure for making and communicating with DAOs. The system features multiple contracts divided into three key groups including `core`, `gov`, and `factory`.

## Components

#### Core contracts

The core contracts play a crucial role in the functionality of the platform. The `ContractsRegistry` contract acts as a central hub, keeping track of all the essential contracts, ensuring the system can be upgraded easily, and allowing for the smooth integration of necessary tools. The another core contract called `CoreProperties` is responsible for storing universal system constants that all modules comply with. When a new DAO is established, it uses these set values to guarantee consistency and reliability across the complete DEXE ecosystem.

In basic terms, the core contracts make sure that all vital rules and tools are well-kept, whether you are upgrading the system or creating a new DAO.

#### Factory contracts

The factory contracts do several important things. Firstly, the `PoolRegistry` keeps a list of all the pools that people created, and allows all of them to be upgraded in the same transaction using the [Beacon Proxy pattern](https://docs.openzeppelin.com/contracts/3.x/api/proxy#BeaconProxy). The `PoolFactory` contract enables anyone to deploy a pool. Once you create a pool using this contract, it is automatically added to the registry. This makes the process simple and anyone can easily participate in creating and managing pools in the system.

#### Gov contracts

Each DAO comprises four distinct governance contracts, which perform specific roles.

The `GovPool` contract operates as a shared space where users participate in the governance process. They may suggest ideas, vote on proposals, earn rewards for their involvement and observe decisions being put into action. Furthermore, governance pools offer a diverse set of useful features:

* Within the DAO pool, users have the ability to delegate voting assets to one another. It is also possible to achieve the status of an expert by possessing a unique `ERC721Expert` NFT, allowing direct delegation from the pool treasury.
* Users can gain extra votes through the ownership of a specific `ERC721Multiplier` NFT, which functions like a coupon and expires after a certain period.
* The `VotePower` contract allows users to transform their votes. In its basic variant, it adjusts the user's vote power based on factors such as whether the user is an expert and the number of delegated treasury assets. This empowers users to amplify their votes and consequently earn greater rewards.
* Users have the option to submit specific proposals, such as the `DistributionProposal`, which distributes sent rewards among the voters based on their number of votes, and the `TokenSaleProposal`, enabling users to create token sales with certain parameters.

The `GovUserKeeper` contract acts as a secure custodian safeguarding users' funds during the voting process. It ensures the secure storage of funds and their judicious use exclusively for voting purposes. The system supports four token standards available for users to deposit and vote with: `ERC20`, `ERC721`, `ERC721Enumerable` and `ERC721Power` which is a unique token standard wherein each NFT has its own power that changes dynamically based on collateralization and time.

The `GovValidator` contract is mandatory for proposals that require a two-stage voting. After achieving quorum in the first stage, such proposals are moved to the validators voting. The validators list is managed by the each DAO itself. Validators use a specific `GovValidatorsToken` that incorporates a snapshot logic.

The `GovSettings` contract stores configuration settings defining how proposals are handled within the governance pool.


# Glossary

Glossary of technical terms you may encounter in this documentation.

| Term                            | Definition                                                                                                                                          |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| DAO pool, Governance pool, Pool | The `GovPool` contract, which is an entry point to interact with one of the DAOs deployed on the protocol.                                          |
| Proposal                        | The operation that can be executed on behalf of the `GovPool` contract if the voting is successful.                                                 |
| Quorum                          | The minimum number of votes required for a proposal to be considered executable.                                                                    |
| Actions for, Actions against    | Lists of operations to be executed if the proposal reaches the for or against quorum respectively.                                                  |
| Executor                        | The contract or EOA that will be called on behalf of the `GovPool` contract during proposal execution. Each action is associated with one executor. |
| Main executor                   | The executor of the last action in the list.                                                                                                        |
| Delegator                       | The user delegating assets to another user.                                                                                                         |
| Delegatee, Micropool            | The user receiving delegated tokens.                                                                                                                |
| Treasury                        | The balance of the `GovPool` contract.                                                                                                              |
| Personal balance                | The user's balance, which consists of assets deposited by themselves.                                                                               |
| Micropool balance               | The user's balance, which consists of assets delegated by other users.                                                                              |
| Treasury balance                | The user's balance, which consists of assets delegated from treasury.                                                                               |
| Metagovernance                  | The hierarchical structure where one DAO's vote influences decisions in another DAO.                                                                |
| Proposal settings               | Specific parameters set for each proposal by its main executor (`duration`, `quorum`, etc.).                                                        |
| NFT power                       | The quantity of votes given by certain NFT.                                                                                                         |
| Raw power                       | The total number of user votes before applying any transformation, calculated as the sum of the number of tokens and NFT powers user voted with.    |
| Voting power, Power             | The raw power after transformation directly involved in achieving quorum.                                                                           |
| Validators                      | Trusted addresses voting on the second stage of voting. `GovValidatorsToken` holders.                                                               |
| Tier                            | The token sale within the `TokenSaleProposal`.                                                                                                      |


# Creating DAO


# Deploying DAO

This page explains how to deploy your own DAO pool and retrieve its on-chain address for further interactions.

First, find the `PoolFactory` contract address on the chain you are using. Once found, simply call the `PoolFactory.deployGovPool` method with the appropriate parameters.

<pre class="language-solidity"><code class="lang-solidity"><strong>contract CreateDAO {
</strong>    IPoolFactory public immutable poolFactory;

    // ...

    constructor(address _poolFactory) {
        poolFactory = IPoolFactory(_poolFactory);
    }

    function createDAO() external {
        IPoolFactory.GovPoolDeployParams memory poolParameters = _getPoolParameters();

        poolFactory.deployGovPool(poolParameters);

        // ...
    }

    function _getPoolParameters()
        internal
        pure
        returns (IPoolFactory.GovPoolDeployParams memory poolParameters)
    {
        // ...
    }
}

</code></pre>

The factory under the hood uses the create2 mechanism to predict the pool address. It can be predicted either before or after the deployment itself, using the deployer's address `tx.origin` and the pool name `poolParameters.name`. With this knowledge, let's calculate the deployed GovPool address and, to see if it works, get the `GovUserKeeper` contract by calling the `GovPool.getHelperContracts` method.

{% code fullWidth="false" %}

```solidity
contract CreateDAO {
    IPoolFactory public immutable poolFactory;

    IGovPool public govPool;
    IGovUserKeeper public govUserKeeper;

    constructor(address _poolFactory) {
        poolFactory = IPoolFactory(_poolFactory);
    }

    function createDAO() external {
        IPoolFactory.GovPoolDeployParams memory poolParameters = _getPoolParameters();

        poolFactory.deployGovPool(poolParameters);

        IPoolFactory.GovPoolPredictedAddresses memory predictedAddresses = poolFactory
            .predictGovAddresses(tx.origin, poolParameters.name);

        govPool = IGovPool(predictedAddresses.govPool);

        (, address govUserKeeperAddress, , , ) = govPool.getHelperContracts();
        govUserKeeper = IGovUserKeeper(govUserKeeperAddress);
    }

    function _getPoolParameters()
        internal
        pure
        returns (IPoolFactory.GovPoolDeployParams memory poolParameters)
    {
        // ...
    }
}
```

{% endcode %}

Now, the only task remaining is to implement the `_getPoolParameters` method. This task is not trivial, so let's break it down step by step. Initially, we'll configure the proposal settings. Assuming our DAO has no validator voting, the reward token is the native currency, and proposals require 25% of the total votes for execution, the following settings should be configured. It's worth noting that constants from the listing can be imported from `core/Globals.sol`.

```solidity
contract CreateDAO {
    uint256 constant PERCENTAGE_100 = 10 ** 27;
    uint256 constant PRECISION = 10 ** 25;
    address constant ETHEREUM_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    
    // ...
    
    function _getProposalSettings() internal pure returns (IGovSettings.ProposalSettings memory) {
        return
            IGovSettings.ProposalSettings({
                earlyCompletion: true,
                delegatedVotingAllowed: true,
                validatorsVote: false,
                duration: 7 days,
                durationValidators: 7 days,
                executionDelay: 0,
                quorum: uint128(PERCENTAGE_100 / 4),
                quorumValidators: 0,
                minVotesForVoting: 0,
                minVotesForCreating: 0,
                rewardsInfo: IGovSettings.RewardsInfo({
                    rewardToken: ETHEREUM_ADDRESS,
                    creationReward: 0.005 ether,
                    executionReward: 0.001 ether,
                    voteRewardsCoefficient: PRECISION
                }),
                executorDescription: ""
            });
    }
}
```

To configure `GovSettings`, it is necessary to match the executors to their respective settings. In this context, an executor refers to a contract called during the execution of a proposal, and each executor can have its own settings. The protocol will choose the appropriate settings based on the executors associated with the proposal. If there is more than one executor, the settings of the main executor will be considered (the last one in the list).

By default, there are three types of executor settings that must be defined: `DEFAULT` (for executors without specific settings), `INTERNAL` (for contracts such as `GovPool`, `GovSettings`, `GovUserKeeper`), and `VALIDATORS` (for the `GovValidators` contract). Additionally, special settings are set for an executor at the `address(1337)`, which can represent any desired contract. For example, if the main executor is set to `address(1337)`, a 10% quorum validator voting will be activated, unlike other executors.

```solidity
function _getSettingsParams()
    internal
    pure
    returns (IPoolFactory.SettingsDeployParams memory)
{
    IGovSettings.ProposalSettings[]
        memory proposalSettings = new IGovSettings.ProposalSettings[](4);

    proposalSettings[uint256(IGovSettings.ExecutorType.DEFAULT)] = _getProposalSettings();
    proposalSettings[uint256(IGovSettings.ExecutorType.INTERNAL)] = _getProposalSettings();
    proposalSettings[uint256(IGovSettings.ExecutorType.VALIDATORS)] = _getProposalSettings();

    proposalSettings[3] = _getProposalSettings();
    proposalSettings[3].validatorsVote = true;
    proposalSettings[3].quorumValidators = uint128(PERCENTAGE_100 / 10);

    address[] memory additionalProposalExecutors = new address[](1);
    additionalProposalExecutors[0] = address(1337);

    return IPoolFactory.SettingsDeployParams(proposalSettings, additionalProposalExecutors);
}
```

Setting up `GovUserKeeper` is straightforward. We just need to specify the tokens with which users will vote (use the `address(0)` if no token is required). If the NFT is used, it should support the [ERC165 standard](https://eips.ethereum.org/EIPS/eip-165), and individual voting power should be set unless it supports `IERC721Power`. If the NFT doesn't support `IERC721Enumerable`, the total supply of NFTs should be manually specified. Note that at least one token (`tokenAddress` or `nftAddress`) must be set. Suppose that in the listing below, `address(2)` is the address of the `IERC721Enumerable`.

```solidity
function _getUserKeeper() internal pure returns (IPoolFactory.UserKeeperDeployParams memory) {
    return
        IPoolFactory.UserKeeperDeployParams({
            tokenAddress: address(1),
            nftAddress: address(2),
            individualPower: 10 ** 18,
            nftsTotalSupply: 0
        });
}
```

Validators vote on two types of proposals within the `GovValidators` contract. The first type, external proposals, are moved from the `GovPool` to the second level of voting. The second type, internal proposals, involve changes to the `GovValidators` state and require special `proposalSettings`. Validators use a special `ERC20Snapshot` token that is deployed with the pool. Therefore, it is important to set the initial validator addresses and their balances to be minted.

```solidity
function _getValidatorsParams()
    internal
    pure
    returns (IPoolFactory.ValidatorsDeployParams memory)
{
    address[] memory validators = new address[](2);
    validators[0] = address(0xaa);
    validators[1] = address(0xbb);

    uint256[] memory balances = new uint256[](2);
    balances[0] = 1 ether;
    balances[1] = 2 ether;

    return
        IPoolFactory.ValidatorsDeployParams({
            name: "GovValidatorToken",
            symbol: "GVT",
            proposalSettings: IGovValidators.ProposalSettings({
                duration: 7 days,
                executionDelay: 0,
                quorum: uint128(PERCENTAGE_100 / 10)
            }),
            validators: validators,
            balances: balances
        });
}
```

The `ERC20Gov` token is also deployed with the pool and serves as a token that can be minted, burned, paused, and has a cap. Its management is handled by the DAO. Initial holders can be established. The difference between `mintedTotal` and `amounts` will be sent to the DAO. This token can also be sold in the `TokenSaleProposal`.

```solidity
function _getGovTokenParams() internal pure returns (IERC20Gov.ConstructorParams memory) {
    return
        IERC20Gov.ConstructorParams({
            name: "GovToken",
            symbol: "GT",
            users: new address[](0),
            cap: 100 ether,
            mintedTotal: 10 ether,
            amounts: new uint256[](0)
        });
}
```

The user votes can be transformed based on specific rules set by the `VotePower` contract. There are two options available for deployment:

1. Deploy our `VotePower` contract, supporting one of two types of voting: `LINEAR_VOTES`, where the vote power equals the exact number of tokens, and `POLYNOMIAL_VOTES`, where the vote power is calculated using a polynomial formula. In this case, `initData` is expected to be passed.
2. Customize and deploy your own `VotePower` contract, then pass the `presetAddress`.

```solidity
function _getVotePowerParams()
    internal
    pure
    returns (IPoolFactory.VotePowerDeployParams memory)
{
    return
        IPoolFactory.VotePowerDeployParams({
            voteType: IPoolFactory.VotePowerType.LINEAR_VOTES,
            initData: abi.encodeWithSelector(LinearPower.__LinearPower_init.selector),
            presetAddress: address(0)
        });
}
```

Let's finally consolidate all the parameters and implement the `_getPoolParameters` method. The parameter `onlyBABTHolders` indicates that only holders of Binance's SBT token can participate in the DAO.

```solidity
function _getPoolParameters()
    internal
    pure
    returns (IPoolFactory.GovPoolDeployParams memory poolParameters)
{
    return
        IPoolFactory.GovPoolDeployParams({
            settingsParams: _getSettingsParams(),
            validatorsParams: _getValidatorsParams(),
            userKeeperParams: _getUserKeeperParams(),
            tokenParams: _getGovTokenParams(),
            votePowerParams: _getVotePowerParams(),
            verifier: address(0),
            onlyBABTHolders: true,
            descriptionURL: "",
            name: "ExampleDAO"
        });
}
```


# Customizing DAO


# VotePower

When casting your vote, all the tokens you voted with are combined into a singular voting power, possibly adjusted by the `VotePower` contract. By default, it does nothing or uses a polynomial formula that takes into account the user's expert status and treasury balance.

Suppose we aim to customize this contract's logic: if a user is on the whitelist, we will square its vote power; otherwise, it remains unchanged. In the example below, you'll find such a contract with two methods managing the whitelist, while other methods implement the `IVotePower` interface. Currently, there is no need to modify the`transformVotesFull` and `getVotesRatio` methods. The `transformVotes` function is responsible for the vote power adjustment.

```solidity
contract SquareWhitelistPower is IVotePower, OwnableUpgradeable {
    mapping(address => bool) public whitelist;

    function __SquareWhitelistPower_init() external initializer {
        __Ownable_init();
    }

    function transformVotes(
        address user,
        uint256 votes
    ) public view override returns (uint256 resultingVotes) {
        return whitelist[user] ? votes * votes : votes;
    }

    function transformVotesFull(
        address user,
        uint256 votes,
        uint256,
        uint256,
        uint256
    ) external view override returns (uint256 resultingVotes) {
        return transformVotes(user, votes);
    }

    function addToWhitelist(address user) external onlyOwner {
        whitelist[user] = true;
    }

    function removeFromWhitelist(address user) external onlyOwner {
        delete whitelist[user];
    }

    function getVotesRatio(address) external pure override returns (uint256 votesRatio) {
        return PRECISION;
    }
}
```

Similar to the `ERC721Power`, you need to deploy and initialize your custom `VotePower` contract on your own. Then, there are two ways to integrate it into the DAO. The first method is to pass its address along with the `poolParameters` during the deployment of your DAO.

```solidity
function createDAO(IVotePower votePower) external {
    IPoolFactory.GovPoolDeployParams memory poolParameters = _getPoolParameters();

    poolParameters.votePowerParams = IPoolFactory.VotePowerDeployParams({
        voteType: IPoolFactory.VotePowerType.CUSTOM_VOTES,
        initData: "",
        presetAddress: address(votePower)
    });

    poolFactory.deployGovPool(poolParameters);
}
```

The other way is to change `VotePower` via the voting. Unlike `ERC721Power`, `VotePower` can be modified multiple times.

```solidity
function setVotePower(IVotePower votePower) external {
    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(govPool),
        value: 0,
        data: abi.encodeWithSelector(IGovPool.changeVotePower.selector, votePower)
    });
    
    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("Set VotePower", actionsFor, actionsAgainst);
}
```


# ERC721Power

The `ERC721Power` contract is designed to enhance the functionalities of `ERC721` through the introduction of a dynamic NFT power mechanism based on collateralization and time. This token can be selected for voting in proposals over the typical `ERC721/ERC721Enumerable` that have the same power for each NFT called `individualPower`. The protocol provides two `ERC721Power` contracts: `ERC721EquivalentPower`, in which the `nftPower` is determined by multiplying `powerEquivalent` with the ratio of `nftRawPower` to the `totalRawPower`; and `ERC721RawPower`, where the power of NFTs corresponds directly to their individual `nftRawPower`.

It's important to note that this contract is not deployed by the factory, so you must either have the existent contract address or deploy it independently. There are two ways to integrate it into the DAO. The simpler approach involves passing it along with the `poolParameters` during the deployment of your DAO.

```solidity
function createDAO(IERC721Power nftPower) external {
    IPoolFactory.GovPoolDeployParams memory poolParameters = _getPoolParameters();

    require(nftPower.supportsInterface(type(IERC721Power).interfaceId), "Not a ERC721Power");

    poolParameters.userKeeperParams.nftAddress = address(nftPower);

    poolFactory.deployGovPool(poolParameters);
}
```

An alternative way for configuring the custom NFT address is to deploy a pool with a zero `nftAddress` and then initiate a proposal for the change.

```solidity
function setERC721Address(IERC721Power nftPower) external {
    require(nftPower.supportsInterface(type(IERC721Power).interfaceId), "Not a ERC721Power");

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(govUserKeeper),
        value: 0,
        data: abi.encodeWithSelector(IGovUserKeeper.setERC721Address.selector, nftPower)
    });
    
    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("Set ERC721Power", actionsFor, actionsAgainst);
}
```

:warning: *Once the `nftAddress` is set during pool deployment or by the voting, it becomes unchangeable.*


# ERC721Multiplier

With the exception of the `VotePower` contract, the `ERC721Multiplier` does not increase voting power, but rather directly boosts your rewards. The `ERC721Multiplier` contract allows users to lock and unlock their NFTs, each of which is associated with a specific duration and multiplier, much like a coupon. If a user locks an NFT before claiming rewards, they will receive additional rewards based on the multiplier of the locked NFT.

Not all DAOs follow the same logic for `ERC721Multiplier`. In the case of DEXE DAO, it employs a custom contract called `DexeERC721Multiplier`. This implementation reduces the multiplier by 10% each time the token is unlocked. Additionally, it considers the average user balance when calculating extra rewards. You can deploy your own version of `ERC721Multiplier` by implementing the `IAbstractERC721Multiplier` interface. Following that, you can create a proposal to change the `ERC721Multiplier` in the DAO as in the example below.

```solidity
function setNftMultiplierAddress(IAbstractERC721Multiplier nftMultiplier) external {
    require(
        nftMultiplier.supportsInterface(type(IAbstractERC721Multiplier).interfaceId),
        "Not a ERC721Multiplier"
    );

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(govPool),
        value: 0,
        data: abi.encodeWithSelector(IGovPool.setNftMultiplierAddress.selector, nftMultiplier)
    });

    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("Set ERC721Multiplier", actionsFor, actionsAgainst);
}
```


# Interacting with DAO


# Deposit/Withdraw

The initial step to interact with the DAO involves depositing your assets. Initially, you must grant approval for the transfer of your funds by the `GovUserKeeper` contract. For simplicity, all funds are approved for transfer. Subsequently, the deposit method on `GovPool` is invoked, crediting your funds to the internal personal balance, thereby enabling you to utilize them within the DAO.

:warning: *All token amounts related inputs and outputs are expected to be in 18 decimals, regardless of the actual token's decimals.*

```solidity
function deposit(IGovPool govPool) external {
    (, address govUserKeeperAddress, , , ) = govPool.getHelperContracts();
    IGovUserKeeper govUserKeeper = IGovUserKeeper(govUserKeeperAddress);

    IERC20(govUserKeeper.tokenAddress()).approve(govUserKeeperAddress, type(uint256).max);
    IERC721(govUserKeeper.nftAddress()).setApprovalForAll(govUserKeeperAddress, true);

    uint256 amount = 10 ether;
    uint256[] memory nftIds = new uint256[](3);
    nftIds[0] = 1;
    nftIds[1] = 2;
    nftIds[3] = 3;

    govPool.deposit(amount, nftIds);
}
```

:warning: *Both `tokenAddress` and `nftAddress` can possibly be zero.*

To refund your assets, you can simply call the reverse `withdraw` method, passing the receiver as the first parameter. You can only withdraw assets that aren't locked in proposals or delegated to anyone. To withdraw such funds, you must first cancel your vote or undelegate, respectively

```solidity
    function withdraw(IGovPool govPool) external {
        (uint256 amount, uint256[] memory nftIds) = govPool.getWithdrawableAssets(address(this));

        govPool.withdraw(address(this), amount, nftIds);
    }
```

:warning: Deposits and withdrawals cannot be made within the same block (via multicall). This is done to prevent possible flashloan attacks.


# Delegations

#### Regular Delegations

If you prefer not to participate directly in the voting process but trust a specific individual within the DAO, you have the option to delegate your funds to them. By doing so, the tokens you delegate are added to the total voting power of the delegatee (a.k.a. micropool). When the proposal that the delegatee voted on is executed, a specific percentage of rewards is directed to the delegatee, while the remaining portion is distributed proportionally among all delegators. This distribution of rewards takes into account the delegated amounts, ensuring a fair distribution among delegators based on their delegation amounts. When you delegate your assets, the delegatee's voting power increases in active proposals. This means there will be a revote that takes your delegated assets into consideration.&#x20;

It's important to note that users can only vote using their entire delegated assets. Even if you vote with personal assets, the assets delegated to you will be automatically added to your votes.  If the `delegatedVotingAllowed` parameter in proposal settings is set to false, then delegated to you assets won't be added to your vote. However, you will be able to vote with the assets you have delegated to someone else.&#x20;

Below is an example illustrating how to delegate all available assets.&#x20;

```solidity
function delegate(IGovPool govPool) external {
    (uint256 amount, uint256[] memory nftIds) = govPool.getWithdrawableAssets(address(this));
    address delegatee = address(1);
    
    govPool.delegate(delegatee, amount, nftIds);
}
```

You also have the option to undelegate assets at any time. In this scenario, the delegatee will automatically revote in active proposals, excluding your assets.

```solidity
function undelegate(IGovPool govPool) external {
    (, address govUserKeeperAddress, , , ) = govPool.getHelperContracts();
    IGovUserKeeper govUserKeeper = IGovUserKeeper(govUserKeeperAddress);

    (, IGovUserKeeper.DelegationInfoView[] memory delegationsInfo) = govUserKeeper.delegations(
        address(this),
        false
    );

    for (uint256 i = 0; i < delegationsInfos.length; ++i) {
        govPool.undelegate(
            delegationsInfos[i].delegatee,
            delegationsInfos[i].delegatedTokens,
            delegationsInfos[i].delegatedNfts
        );
    }
}
```

:warning: *Delegate and undelegate cannot be made within the same block (via multicall). This is done to prevent possible flash-loan attacks.*

#### Treasury Delegations

Additionally, you can request delegation directly from the `GovPool` contract's balance, which is commonly known as the treasury. This can be done through the voting process (proposal). Treasury delegations work similarly to standard delegations except that they can only be issued to experts (`ERC721Expert` holders). When treasury is delegated or undelegated to you, its entire amount will be automatically added or removed from all your votes in active proposals. Moreover, you will receive a certain percentage of rewards if proposal is successfully executed. Here are some examples of creating proposals for treasury delegation and undelegation. We'll cover voting and executing proposals in the next chapter about the proposal life cycle. Please refer to the example below for further clarification.

<pre class="language-solidity"><code class="lang-solidity">function delegateTreasury(IGovPool govPool) external {
    (, address govUserKeeperAddress, , , ) = govPool.getHelperContracts();
    IGovUserKeeper govUserKeeper = IGovUserKeeper(govUserKeeperAddress);

    address delegatee = address(1);
    uint256 amount = 1 ether;
    uint256[] memory nftIds = new uint256[](1);
    nftIds[0] = 1;

<strong>    require(govPool.getExpertStatus(delegatee), "Not an expert");
</strong>    require(
        IERC20(govUserKeeper.tokenAddress()).balanceOf(address(govPool)) >= amount,
        "GovPool has insufficient ERC20 balance"
    );
    require(
        IERC721(govUserKeeper.nftAddress()).ownerOf(nftIds[0]) == address(govPool),
        "GovPool has insufficient ERC721 balance"
    );

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(govPool),
        value: 0,
        data: abi.encodeWithSelector(
            IGovPool.delegateTreasury.selector,
            delegatee,
            amount,
            nftIds
        )
    });

    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("DelegateTreasury", actionsFor, actionsAgainst);
}

function undelegateTreasury(IGovPool govPool) external {
    address delegatee = address(1);
    uint256 amount = 1 ether;
    uint256[] memory nftIds = new uint256[](1);
    nftIds[0] = 1;

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(govPool),
        value: 0,
        data: abi.encodeWithSelector(
            IGovPool.undelegateTreasury.selector,
            delegatee,
            amount,
            nftIds
        )
    });

    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("UndelegateTreasury", actionsFor, actionsAgainst);
}
</code></pre>

:warning: *Treasury balance won't be added to your vote in* `delegateTreasury` *and* `undelegateTreasury` *proposals concerning you as a delegatee.*


# Proposal life cycle

In the proposal life cycle, the initial step is its creation. We have previously discussed the creation of proposals that alter the state of system contracts, but it's important to note that the executor can be any contract. Suppose we have the `UnknownToken` token, and ownership of this token has been transferred to the DAO.

<pre class="language-solidity"><code class="lang-solidity"><strong>contract UnknownToken is ERC20, Ownable {
</strong>    constructor(string memory name, string memory symbol) ERC20(name, symbol) {}

    function mint(address to, uint256 amount) external onlyOwner {
        _mint(to, amount);
    }
}
</code></pre>

Now, let's consider a scenario where we want to execute the `mint` function of this token via a proposal.

```solidity
function createProposal(GovPool govPool, IERC20 token) external returns (uint256 proposalId) {
    address receiver = address(this);
    uint256 amount = 1 ether;

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(token),
        value: 0,
        data: abi.encodeWithSelector(UnknownToken.mint.selector, receiver, amount)
    });

    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("Mint token", actionsFor, actionsAgainst);

    return GovPool(govPool).latestProposalId();
}
```

You can also add specific validations that will be passed each time you create a proposal with your contract functioning as the main executor. To achieve this, you should implement the `IProposalValidator` interface. In this particular case, the validation ensures that the only action within the proposal is the minting of some amount of tokens. If the `validate` method returns false, the creation of the proposal will be reverted.

```solidity
contract UnknownToken is IProposalValidator {
    function validate(
        IGovPool.ProposalAction[] calldata actions
    ) external view override returns (bool valid) {
        return actions.length == 1 && bytes4(actions[0].data[0:4]) == UnknownToken.mint.selector;
    }
}
```

Once created, a proposal initially enters the `Voting` state, making it available for user to cast their votes. The voting period remains open as long as the quorum is not reached or the voting time hasn't elapsed. Users may also vote against proposals. If votes against the proposal reach a quorum, the status of the proposal becomes `Defeated`. Now we can pass the `proposalId` from the just-created proposal to the voting function and cast a vote in favor of it.

```solidity
function vote(IGovPool govPool, uint256 proposalId) external {
    require(
        govPool.getProposalState(proposalId) == IGovPool.ProposalState.Voting,
        "Not voting state"
    );

    bool isVoteFor = true;
    uint256 amount = 1 ether;
    uint256[] memory nftIds = new uint256[](1);

    govPool.vote(proposalId, isVoteFor, amount, nftIds);
}
```

To save on gas, consider utilizing the `createProposalAndVote` function.

```solidity
function createProposalAndVote(IGovPool govPool) external {
    // ...
    
    govPool.createProposalAndVote("MintToken", actionsFor, actionsAgainst, amount, nftIds);
}
```

It's possible to cancel your entire vote on the proposal, including the delegated power, by simply calling the `cancelVote` method. After that, your assets will no longer be locked and you can withdraw them.

```solidity
function cancelVote(IGovPool govPool, uint256 proposalId) external {
    require(
        govPool.getProposalState(proposalId) == IGovPool.ProposalState.Voting,
        "Not voting state"
    );

    govPool.cancelVote(proposalId);
}
```

Assuming our proposal has reached the quorum and has exceeded `duration` if `earlyCompletion` is false, it can exist in one of three possible states. The first state is `Locked` in which case we only need to wait for the `executionDelay`. The second state is `SucceededFor` or `SucceededAgainst` indicating that it is ready for execution. In this case, we can simply call the `execute` method.

```solidity
function execute(IGovPool govPool, uint256 proposalId) external {
    IGovPool.ProposalState proposalState = govPool.getProposalState(proposalId);

    require(
        proposalState == IGovPool.ProposalState.SucceededFor ||
            proposalState == IGovPool.ProposalState.SucceededAgainst,
        "Not succeeded state"
    );

    govPool.execute(proposalId);
}
```

:warning: *SucceededAgainst status is reachable only in meta-governance proposals not covered in this chapter.*

The `WaitingForVotingTransfer` state, indicating that `validatorsVote` is true, signifies that the proposal is ready to be moved to the second stage of voting. To initiate this, the `moveProposalToValidators` method should be called by any user. This method triggers the creation of the corresponding external proposal in the `GovValidators` contract. External proposals for the `GovValidators` contract have the same ids as those on the `GovPool` contract.

```solidity
function moveProposalToValidators(IGovPool govPool, uint256 proposalId) external {
    require(
        govPool.getProposalState(proposalId) ==
            IGovPool.ProposalState.WaitingForVotingTransfer,
        "Not waiting for transfer state"
    );

    govPool.moveProposalToValidators(proposalId);
}
```

Following the transition of the proposal to the validators, the validators will have the ability to cast their votes for it.

```solidity
function validatorVote(IGovPool govPool, uint256 proposalId) external {
    (, , address govValidatorsAddress, , ) = govPool.getHelperContracts();
    IGovValidators govValidators = IGovValidators(govValidatorsAddress);

    bool isInternal = false;
    require(
        govValidators.getProposalState(proposalId, isInternal) ==
            IGovValidators.ProposalState.Voting,
        "Not voting state"
    );

    uint256 amount = 1 ether;
    bool isVoteFor = true;

    govValidators.voteExternalProposal(proposalId, amount, isVoteFor);
}
```

Once the external proposal has the `Succeeded` status on the `GovValidators` contract, it will also attain the `SucceededFor` or `SucceededAgainst` status on the `GovPool` contract, allowing it to be executed in the usual manner.

```solidity
function executeAfterValidators(IGovPool govPool, uint256 proposalId) external {
    (, , address govValidatorsAddress, , ) = govPool.getHelperContracts();
    IGovValidators govValidators = IGovValidators(govValidatorsAddress);

    bool isInternal = false;
    require(
        govValidators.getProposalState(proposalId, isInternal) ==
            IGovValidators.ProposalState.Succeeded,
        "Not succeeded state"
    );

    IGovPool.ProposalState proposalState = govPool.getProposalState(proposalId);

    assert(
        proposalState == IGovPool.ProposalState.SucceededFor ||
            proposalState == IGovPool.ProposalState.SucceededAgainst
    );

    govPool.execute(proposalId);
}
```

Well done! When you call the `execute` method, the tokens are minted to the address specified in the proposal. You can verify this by simply calling the `balanceOf` method on the token contract.


# Rewards

For most actions in the DAO, users receive rewards that are categorized into static and voting ones. Upon receiving a static reward, users can claim it definitively if the proposal is successfully executed. One such static reward is the reward for the proposal creation, which is determined by the `creationReward` parameter. When a user `moveProposalToValidators` or `execute` a proposal, they earn another static reward set by the `executionReward` parameter. In contrast, voting rewards are not fixed. The protocol allows users to `cancelVote` or `undelegate` assets, which may result in the "burning" of potential rewards.

It's important to note that micropool rewards bear a resemblance to voting rewards, although they can be retrieved and claimed through different methods. When you delegate your assets to someone, it involves a complex staking-like mechanism. For example, with multiple delegators and one delegatee, when the delegatee votes, all delegators' votes are automatically aggregated with his own. The delegatee then receives rewards for the delegated power of all delegators. A certain percentage is claimed by the delegatee, while the remaining rewards are distributed proportionally among the delegators, as in the common staking.

Consider three proposals have been executed within our DAO. Preceding these events, we delegated assets to `address(1)` and actively engaged in these proposals using methods like `createProposal`, `moveProposalToValidators`, `execute`, and `vote`. Furthermore, our delegatee voted in these proposals as well, entitling us to a share of the rewards. Now, our objective is to determine our rewards.&#x20;

```solidity
function getRewards(IGovPool govPool) external view {
    address user = address(this);
    address delegatee = address(1);
    uint256[] memory proposalIds = new uint256[](3);
    proposalIds[0] = 1;
    proposalIds[1] = 2;
    proposalIds[2] = 3;

    IGovPool.PendingRewardsView memory pendingRewards = govPool.getPendingRewards(
        user,
        proposalIds
    );

    IGovPool.DelegatorRewards memory delegatorRewards = govPool.getDelegatorRewards(
        proposalIds,
        user,
        delegatee
    );

    /// ...
}
```

After obtaining the rewards, you can withdraw them using the corresponding claim methods.

```solidity
function claimRewards(IGovPool govPool) external {
    address user = address(this);
    address delegatee = address(1);
    uint256[] memory proposalIds = new uint256[](3);
    proposalIds[0] = 1;
    proposalIds[1] = 2;
    proposalIds[2] = 3;

    govPool.claimRewards(proposalIds, user);
    govPool.claimMicropoolRewards(proposalIds, user, delegatee);
}
```


# Metagovernance

Consider a scenario in which we have some master organization with its own DAO, further subdivided into several slave organizations, each equipped with an independent DAO. In this setup, only the slave DAOs have the ability to vote in the master one. Such a hierarchical structure is called metagovernance and can be established using our protocol.

To make this happen, metagovernance proposals allow you to vote in one DAO on behalf of another. It's achievable by the limiting the executor to one of the deployed DAO pools, specifically the master DAO. The data included is restricted to the deposit and approval of funds, and the last action is exclusively a vote for the proposal in the master DAO (in the `actionsFor` list) and a vote against it (in the `actionsAgainst` list).

It's important to note that the `actionsAgainst` parameter is only non-empty in metagovernance proposals. The `GovPool` contract enforces a validation process to ensure that proposals specifying `actionsAgainst` adhere to the established criteria for metagovernance proposals. Specifically, `actionsFor` and `actionsAgainst` should have the same length and parameters, except for the last one, where the `isVoteFor` parameter differs.

Apart from ordinary proposals, metagovernance proposals can be executed if the quorum against is reached. In such cases, the proposal status will change to `ExecutedAgainst`, and all users who voted against will receive rewards.

Here's an example of creating a proposal that votes in the master DAO on behalf of the slave DAO.

```solidity
function metagovernanceProposal(IGovPool masterGovPool, IGovPool slaveGovPool) external {
    (, address masterUserKeeperAddress, , , ) = masterGovPool.getHelperContracts();
    address tokenAddress = IGovUserKeeper(masterUserKeeperAddress).tokenAddress();

    require(tokenAddress != address(0), "Zero token");

    uint256 proposalId = 1;
    uint256 amount = 10 ether;
    uint256[] memory nftIds = new uint256[](0);

    require(
        IERC20(tokenAddress).balanceOf(address(slaveGovPool)) >= amount,
        "Insufficient balance"
    );
    require(
        masterGovPool.getProposalState(proposalId) == IGovPool.ProposalState.Voting,
        "Not voting state"
    );

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](3);
    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](3);

    actionsFor[0] = actionsAgainst[0] = IGovPool.ProposalAction({
        executor: tokenAddress,
        value: 0,
        data: abi.encodeWithSelector(IERC20.approve.selector, masterUserKeeperAddress, amount)
    });
    actionsFor[1] = actionsAgainst[1] = IGovPool.ProposalAction({
        executor: address(masterGovPool),
        value: 0,
        data: abi.encodeWithSelector(IGovPool.deposit.selector, amount, nftIds)
    });

    /// @dev vote for the proposal in the master DAO
    actionsFor[2] = IGovPool.ProposalAction({
        executor: address(masterGovPool),
        value: 0,
        data: abi.encodeWithSelector(IGovPool.vote.selector, proposalId, true, amount, nftIds)
    });

    /// @dev vote against the proposal in the master DAO
    actionsAgainst[2] = IGovPool.ProposalAction({
        executor: address(masterGovPool),
        value: 0,
        data: abi.encodeWithSelector(IGovPool.vote.selector, proposalId, false, amount, nftIds)
    });

    slaveGovPool.createProposal("Metagovernance proposal", actionsFor, actionsAgainst);
}
```


# Internal validator proposals

There are four special internal validator proposals responsible for managing the validator-related storage: `ChangeSettings`, `ChangeBalances`, `MonthlyWithdraw`, and `OffchainProposal`. These proposals have the privilege to skip the first voting stage on the `GovPool` contract and can be directly created on the `GovValidators` contract. Take a look at the example below, where we create an internal proposal to modify `GovValidatorsToken` balances.

```solidity
function validatorsInternalProposals(IGovPool govPool) external {
    (, , address govValidatorsAddress, , ) = govPool.getHelperContracts();
    IGovValidators govValidators = IGovValidators(govValidatorsAddress);

    uint256[] memory balances = new uint256[](2);
    balances[0] = 10 ether;
    balances[1] = 20 ether;

    address[] memory validators = new address[](2);
    validators[0] = address(1);
    validators[1] = address(2);

    govValidators.createInternalProposal(
        IGovValidators.ProposalType.ChangeBalances,
        "Change Validators balances",
        abi.encodeWithSelector(IGovValidators.changeBalances.selector, balances, validators)
    );

    uint256 proposalId = GovValidators(payable(govValidatorsAddress))
        .latestInternalProposalId();

    // ...
}
```

Once you have the internal proposal ID, you can invoke the `voteInternalProposal`, `executeInternalProposal`, and `getProposalState` methods on the `GovValidators` contract, similar to what was done on the `GovPool` contract.


# Special proposals


# Distribution proposal

You can create a special proposal called a distribution proposal that distributes tokens proportionally based on the personal votes casted by users in this proposal. To create it, you need to set the main executor to the `DistributionProposal` contract, which is unique for each DAO and can be either predicted by calling the `PoolFactory`'s method or obtained from a third-party source. Now let's create a proposal that distributes 10 ETH.

```solidity
function createDistributionProposal(
    IGovPool govPool,
    IDistributionProposal distributionProposal
) external {
    uint256 proposalId = GovPool(payable(address(govPool))).latestProposalId();
    uint256 amount = 10 ether;

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](1);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(distributionProposal),
        value: 0,
        data: abi.encodeWithSelector(
            IDistributionProposal.execute.selector,
            proposalId,
            ETHEREUM_ADDRESS,
            amount
        )
    });

    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("Distribution proposal", actionsFor, actionsAgainst);
}
```

:warning: *Votes against the distribution proposal are subtracted from the overall pool, and voters who do so are not eligible for rewards.*

Please take note that you need to manually pass the ID of the proposal you create as a parameter to the `execute` function. If an incorrect ID is passed, the creation will be reverted, as the `DistributionProposal` contract implements the `IProposalValidator.validate` hook.

```solidity
contract DistributionProposal is IProposalValidator, /* ... */ {
    /// ...
    
    function validate(
        IGovPool.ProposalAction[] calldata actions
    ) external view override returns (bool valid) {
        uint256 proposalId = uint256(bytes32(actions[actions.length - 1].data[4:36]));

        return proposalId == GovPool(payable(govAddress)).latestProposalId();
    }
}
```

Once the distribution proposal has been executed, voters can claim their rewards by calling the `claim` method on the `DistributionProposal` contract.


# Token sale proposal

Another interesting proposal that can be created within a DAO is the `TokenSaleProposal`. This proposal enables the initiation of token sales (a.k.a. tiers) according to certain rules. The main executor should be the `TokenSaleProposal` contract, which retains all the created tiers within a DAO it deployed alongside with. Both custom tokens and `ERC20Gov` tokens can be sold in tiers. Upon the creation of tiers, sale token amounts are transferred from the treasury to the `TokenSaleProposal` contract, so it's necessary to approve this transfer beforehand. Let's create a tier that will sell `ERC20Gov` tokens in exchange for the native currency.

```solidity
function createTier(
    IGovPool govPool,
    ITokenSaleProposal tokenSaleProposal,
    IERC20Gov govToken
) external {
    address[] memory purchaseTokenAddresses = new address[](1);
    uint256[] memory exchangeRates = new uint256[](1);

    /// @dev 1 GovToken = 2 ETH
    purchaseTokenAddresses[0] = ETHEREUM_ADDRESS;
    exchangeRates[0] = 2 * PRECISION;

    uint256 totalTokenProvided = 100 ether;

    ITokenSaleProposal.TierInitParams memory _tierInitParams = ITokenSaleProposal
        .TierInitParams({
            metadata: ITokenSaleProposal.TierMetadata({name: "", description: ""}),
            totalTokenProvided: totalTokenProvided,
            saleStartTime: uint64(block.timestamp + 2 days),
            saleEndTime: uint64(block.timestamp + 9 days),
            claimLockDuration: 0,
            saleTokenAddress: address(govToken),
            purchaseTokenAddresses: purchaseTokenAddresses,
            exchangeRates: exchangeRates,
            minAllocationPerUser: 0,
            maxAllocationPerUser: 0,
            vestingSettings: ITokenSaleProposal.VestingSettings({
                vestingPercentage: 0,
                vestingDuration: 0,
                cliffPeriod: 0,
                unlockStep: 0
            }),
            participationDetails: new ITokenSaleProposal.ParticipationDetails[](0)
        });

    ITokenSaleProposal.TierInitParams[]
        memory tierInitParams = new ITokenSaleProposal.TierInitParams[](1);
    tierInitParams[0] = _tierInitParams;

    IGovPool.ProposalAction[] memory actionsFor = new IGovPool.ProposalAction[](2);
    actionsFor[0] = IGovPool.ProposalAction({
        executor: address(govToken),
        value: 0,
        data: abi.encodeWithSelector(
            IERC20.approve.selector,
            address(tokenSaleProposal),
            totalTokenProvided
        )
    });
    actionsFor[1] = IGovPool.ProposalAction({
        executor: address(tokenSaleProposal),
        value: 0,
        data: abi.encodeWithSelector(ITokenSaleProposal.createTiers.selector, tierInitParams)
    });

    IGovPool.ProposalAction[] memory actionsAgainst = new IGovPool.ProposalAction[](0);

    govPool.createProposal("Create tier", actionsFor, actionsAgainst);
}
```

In this tier, all optional parameters are configured with zero values. In addition, your proposal has the flexibility to combine different types of whitelists within the `participationDetails` parameter, allowing you to restrict certain addresses from participating in a tier, or to set `vestingSettings` to provide a gradual withdrawal of tokens for customers, etc.

:warning: *The `claimLockDuration` should be less than or equal to the `cliffPeriod`.*

Once the `createTier` proposal is successfully executed, users are given the ability to purchase tokens in this tier by calling the `buy` method on the `TokenSaleProposal` contract. After the `saleEndTime`, they should also use the `claim` and `vestingWithdraw` methods to withdraw purchased tokens.

The proposals in the `GovPool` also allow you to call several useful methods on the `TokenSaleProposal` contract. For instance, you can use `offTiers` to halt sales in certain tiers, `addToWhitelist` if `participationDetails` contains `ParticipationType.Whitelist`, and `recover` to transfer unsold tokens back to the treasury.


# Usage of subgraphs

Sometimes, there is a need to acquire complex data from contracts, making it impractical to create view functions for all cases. This is where subgraphs, leveraging The Graph technology, come into play. DeXe has three subgraphs that listen to contract events and aggregate data from them. You can easily query the desired data by sending GraphQL-like requests to our subgraphs.

### The All Interactions subgraph

The All Interactions subgraph stores information about each user or validator interaction with protocol smart contracts.

#### Examples

We can get user interactions with proposals in the specific DAO pool by the user transaction (there can be many interactions in one transaction). To do this, we need to get the transaction by its hash and filter interactions by the DAO pool contract address.

```graphql
{
  transactions(where: {id: "<tx hash>"}) {
    daoPoolProposalInteraction(where: {pool: "<pool address>"}) {
      interactionType
      totalVote
    }
  }
}
```

Or we can get all vests (deposits/withdrawals) from all users.

```graphql
{
  daoPoolVests {
    amount
    nfts
    transaction {
      id
      user
    }
  }
}
```

## The DAO Pools subgraph

The DAO Pools subgraph stores information about each DAO Pool. In this subgraph, you can find detailed information about pools, proposals, voters, voter delegation history, etc.

#### Examples

We can retrieve all unexecuted proposals. To do this, we need to filter out records where the execution time is not equal to 0.

```graphql
{
  proposals(where: {executionTimestamp_not: 0}) {
    proposalId
    quorum
    isFor
    currentVotesFor
    currentVotesAgainst
    description
    voters {
      totalVotes
      totalVotedProposals
      totalProposalsCreated
      totalMicropoolRewardUSD
      totalLockedFundsUSD
      totalDelegatedUSD
      totalClaimedUSD
      delegatorsCount
      delegateesCount
      currentVotesReceived
      currentVotesDelegated
    }
  }
}
```

Or we can get the delegation history in the specific DAO pool with delegated assets by the delegator's address.

```graphql
{
  voterInPoolPairs(
    where: {delegator_: {voter: "<user address>"}}
  ) {
    delegatedAmount
    delegatedNfts
    delegatedUSD
    delegatedVotes
    delegatee {
      voter {
        id
      }
    }
  }
}
```

## The DAO Validators subgraph

The DAO Validators subgraph contains details of each validator in the DAO Pool, along with their proposals and other information.

#### Examples

We can retrieve all internal validator proposals that a certain validator has voted on by filtering proposals based on the `isInternal` flag.

```graphql
{
  proposals(
    where: {voters_: {validator_: {validatorAddress: "<validator address>"}}, isInternal: true}
  ) {
    isInternal
    proposalId
    quorum
    totalVoteAgainst
    totalVoteFor
    voters {
      totalVoteAgainst
      totalVoteFor
      validator {
        validatorAddress
        balance
      }
    }
  }
}
```


# Core contracts


# IPriceFeed

## Interface Description

License: MIT

##

```solidity
interface IPriceFeed
```

This is the price feed contract which is used to fetch the spot prices from the UniswapV2 protocol. There also is a pathfinder built into the contract to find the optimal\* path between the pairs

## Enums info

### PoolInterfaceType

```solidity
enum PoolInterfaceType {
	 UniswapV2Interface,
	 UniswapV3Interface
}
```

The enum that holds information about the router type

Parameters:

| Name               | Description                    |
| ------------------ | ------------------------------ |
| UniswapV2Interface | the Uniswap V2 router V2 type  |
| UniswapV3Interface | the Uniswap V3 quouter V2 type |

## Structs info

### PoolType

```solidity
struct PoolType {
	IPriceFeed.PoolInterfaceType poolType;
	address router;
	uint24 fee;
}
```

A struct describing single swapping pool parameters

Parameters:

| Name     | Type                              | Description                         |
| -------- | --------------------------------- | ----------------------------------- |
| poolType | enum IPriceFeed.PoolInterfaceType | the interface type of the router    |
| router   | address                           | the address of the router or quoter |
| fee      | uint24                            | the pool fee (in case of V3 pools)  |

### SwapPath

```solidity
struct SwapPath {
	address[] path;
	uint8[] poolTypes;
}
```

A struct describing a swap path

Parameters:

| Name      | Type       | Description                             |
| --------- | ---------- | --------------------------------------- |
| path      | address\[] | the tokens swapped alongside the path   |
| poolTypes | uint8\[]   | the v2/v3 pool types alongside the path |

## Functions info

### addPathTokens (0xf973dc01)

```solidity
function addPathTokens(address[] calldata pathTokens) external
```

This function sets path tokens that will be used in the pathfinder

Parameters:

| Name       | Type       | Description                                          |
| ---------- | ---------- | ---------------------------------------------------- |
| pathTokens | address\[] | the array of tokens to be added into the path finder |

### removePathTokens (0x5de49e39)

```solidity
function removePathTokens(address[] calldata pathTokens) external
```

This function removes path tokens from the pathfinder

Parameters:

| Name       | Type       | Description                                           |
| ---------- | ---------- | ----------------------------------------------------- |
| pathTokens | address\[] | the array of tokens to be removed from the pathfinder |

### setPoolTypes (0x3cbc6757)

```solidity
function setPoolTypes(IPriceFeed.PoolType[] calldata poolTypes) external
```

This function sets pool types that will be used in the pathfinder

Parameters:

| Name      | Type                          | Description             |
| --------- | ----------------------------- | ----------------------- |
| poolTypes | struct IPriceFeed.PoolType\[] | the array of pool types |

### getPriceOut (0x70e48e96)

```solidity
function getPriceOut(
    address inToken,
    address outToken,
    uint256 amountIn
) external returns (uint256 amountOut, IPriceFeed.SwapPath memory path)
```

Shares the same functionality as "getExtendedPriceOut" function with an empty optionalPath. It accepts and returns amounts with 18 decimals regardless of the inToken and outToken decimals

Parameters:

| Name     | Type    | Description                                              |
| -------- | ------- | -------------------------------------------------------- |
| inToken  | address | the token to exchange from                               |
| outToken | address | the token to exchange to                                 |
| amountIn | uint256 | the amount of inToken to be exchanged (with 18 decimals) |

Return values:

| Name      | Type                       | Description                                                       |
| --------- | -------------------------- | ----------------------------------------------------------------- |
| amountOut | uint256                    | the received amount of outToken after the swap (with 18 decimals) |
| path      | struct IPriceFeed.SwapPath | the tokens and pools path that will be used during the swap       |

### getPriceIn (0xd48c3202)

```solidity
function getPriceIn(
    address inToken,
    address outToken,
    uint256 amountOut
) external returns (uint256 amountIn, IPriceFeed.SwapPath memory path)
```

Shares the same functionality as "getExtendedPriceIn" function with with an empty optionalPath. It accepts and returns amounts with 18 decimals regardless of the inToken and outToken decimals

Parameters:

| Name      | Type    | Description                                              |
| --------- | ------- | -------------------------------------------------------- |
| inToken   | address | the token to exchange from                               |
| outToken  | address | the token to exchange to                                 |
| amountOut | uint256 | the amount of outToken to be received (with 18 decimals) |

Return values:

| Name     | Type                       | Description                                                       |
| -------- | -------------------------- | ----------------------------------------------------------------- |
| amountIn | uint256                    | required amount of inToken to execute the swap (with 18 decimals) |
| path     | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                 |

### getNormalizedPriceOutUSD (0xb4c05b8c)

```solidity
function getNormalizedPriceOutUSD(
    address inToken,
    uint256 amountIn
) external returns (uint256 amountOut, IPriceFeed.SwapPath memory path)
```

The same as "getPriceOut" with "outToken" being native USD token

Parameters:

| Name     | Type    | Description                                          |
| -------- | ------- | ---------------------------------------------------- |
| inToken  | address | the token to be exchanged from                       |
| amountIn | uint256 | the amount of inToken to exchange (with 18 decimals) |

Return values:

| Name      | Type                       | Description                                                                |
| --------- | -------------------------- | -------------------------------------------------------------------------- |
| amountOut | uint256                    | the received amount of native USD tokens after the swap (with 18 decimals) |
| path      | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                          |

### getNormalizedPriceInUSD (0x715c6baf)

```solidity
function getNormalizedPriceInUSD(
    address inToken,
    uint256 amountOut
) external returns (uint256 amountIn, IPriceFeed.SwapPath memory path)
```

The same as "getPriceIn" with "outToken" being USD token

Parameters:

| Name      | Type    | Description                                         |
| --------- | ------- | --------------------------------------------------- |
| inToken   | address | the token to get the price of                       |
| amountOut | uint256 | the amount of USD to be received (with 18 decimals) |

Return values:

| Name     | Type                       | Description                                                           |
| -------- | -------------------------- | --------------------------------------------------------------------- |
| amountIn | uint256                    | the required amount of inToken to execute the swap (with 18 decimals) |
| path     | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                     |

### getNormalizedPriceOutDEXE (0x291bcd52)

```solidity
function getNormalizedPriceOutDEXE(
    address inToken,
    uint256 amountIn
) external returns (uint256 amountOut, IPriceFeed.SwapPath memory path)
```

The same as "getPriceOut" with "outToken" being DEXE token

Parameters:

| Name     | Type    | Description                                          |
| -------- | ------- | ---------------------------------------------------- |
| inToken  | address | the token to be exchanged from                       |
| amountIn | uint256 | the amount of inToken to exchange (with 18 decimals) |

Return values:

| Name      | Type                       | Description                                                          |
| --------- | -------------------------- | -------------------------------------------------------------------- |
| amountOut | uint256                    | the received amount of DEXE tokens after the swap (with 18 decimals) |
| path      | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                    |

### getNormalizedPriceInDEXE (0x9180f690)

```solidity
function getNormalizedPriceInDEXE(
    address inToken,
    uint256 amountOut
) external returns (uint256 amountIn, IPriceFeed.SwapPath memory path)
```

The same as "getPriceIn" with "outToken" being DEXE token

Parameters:

| Name      | Type    | Description                                          |
| --------- | ------- | ---------------------------------------------------- |
| inToken   | address | the token to get the price of                        |
| amountOut | uint256 | the amount of DEXE to be received (with 18 decimals) |

Return values:

| Name     | Type                       | Description                                                           |
| -------- | -------------------------- | --------------------------------------------------------------------- |
| amountIn | uint256                    | the required amount of inToken to execute the swap (with 18 decimals) |
| path     | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                     |

### totalPathTokens (0x9f2f8ce1)

```solidity
function totalPathTokens() external view returns (uint256)
```

The function that returns the total number of path tokens (tokens used in the pathfinder)

Return values:

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| \[0] | uint256 | the number of path tokens |

### getPathTokens (0x547c176b)

```solidity
function getPathTokens() external view returns (address[] memory)
```

The function to get the list of path tokens

Return values:

| Name | Type       | Description             |
| ---- | ---------- | ----------------------- |
| \[0] | address\[] | the list of path tokens |

### getPoolTypesLength (0x14980a8d)

```solidity
function getPoolTypesLength() external view returns (uint256)
```

The function that returns the total number of pool types used in the pathfinder

Return values:

| Name | Type    | Description              |
| ---- | ------- | ------------------------ |
| \[0] | uint256 | the number of pool types |

### getPoolTypes (0x2fbc3b93)

```solidity
function getPoolTypes() external view returns (IPriceFeed.PoolType[] memory)
```

The function to return the list of pool types used in the pathfinder

Return values:

| Name | Type                          | Description            |
| ---- | ----------------------------- | ---------------------- |
| \[0] | struct IPriceFeed.PoolType\[] | the list of pool types |

### isSupportedPathToken (0xa5b0de41)

```solidity
function isSupportedPathToken(address token) external view returns (bool)
```

This function checks if the provided token is used by the pathfinder

Parameters:

| Name  | Type    | Description             |
| ----- | ------- | ----------------------- |
| token | address | the token to be checked |

Return values:

| Name | Type | Description                                                  |
| ---- | ---- | ------------------------------------------------------------ |
| \[0] | bool | true if the token is used by the pathfinder, false otherwise |

### getExtendedPriceOut (0x054889da)

```solidity
function getExtendedPriceOut(
    address inToken,
    address outToken,
    uint256 amountIn,
    IPriceFeed.SwapPath memory optionalPath
) external returns (uint256 amountOut, IPriceFeed.SwapPath memory path)
```

This function tries to find the optimal exchange rate (the price) between "inToken" and "outToken" using custom pathfinder and optional specified path. The optimality is reached when the amount of outTokens is maximal

Parameters:

| Name         | Type                       | Description                                                                        |
| ------------ | -------------------------- | ---------------------------------------------------------------------------------- |
| inToken      | address                    | the token to exchange from                                                         |
| outToken     | address                    | the received token                                                                 |
| amountIn     | uint256                    | the amount of inToken to be exchanged (in inToken decimals)                        |
| optionalPath | struct IPriceFeed.SwapPath | the optional path between inToken and outToken that will be used in the pathfinder |

Return values:

| Name      | Type                       | Description                                              |
| --------- | -------------------------- | -------------------------------------------------------- |
| amountOut | uint256                    | amount of outToken after the swap (in outToken decimals) |
| path      | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap        |

### getExtendedPriceIn (0x76707b6b)

```solidity
function getExtendedPriceIn(
    address inToken,
    address outToken,
    uint256 amountOut,
    IPriceFeed.SwapPath memory optionalPath
) external returns (uint256 amountIn, IPriceFeed.SwapPath memory path)
```

This function tries to find the optimal exchange rate (the price) between "inToken" and "outToken" using custom pathfinder and optional specified path. The optimality is reached when the amount of inTokens is minimal

Parameters:

| Name         | Type                       | Description                                                                        |
| ------------ | -------------------------- | ---------------------------------------------------------------------------------- |
| inToken      | address                    | the token to exchange from                                                         |
| outToken     | address                    | the received token                                                                 |
| amountOut    | uint256                    | the amount of outToken to be received (in inToken decimals)                        |
| optionalPath | struct IPriceFeed.SwapPath | the optional path between inToken and outToken that will be used in the pathfinder |

Return values:

| Name     | Type                       | Description                                                |
| -------- | -------------------------- | ---------------------------------------------------------- |
| amountIn | uint256                    | amount of inToken to execute a swap (in outToken decimals) |
| path     | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap          |

### getNormalizedExtendedPriceOut (0x62d78340)

```solidity
function getNormalizedExtendedPriceOut(
    address inToken,
    address outToken,
    uint256 amountIn,
    IPriceFeed.SwapPath memory optionalPath
) external returns (uint256 amountOut, IPriceFeed.SwapPath memory path)
```

Shares the same functionality as "getExtendedPriceOut" function. It accepts and returns amounts with 18 decimals regardless of the inToken and outToken decimals

Parameters:

| Name         | Type                       | Description                                                                        |
| ------------ | -------------------------- | ---------------------------------------------------------------------------------- |
| inToken      | address                    | the token to exchange from                                                         |
| outToken     | address                    | the token to exchange to                                                           |
| amountIn     | uint256                    | the amount of inToken to be exchanged (with 18 decimals)                           |
| optionalPath | struct IPriceFeed.SwapPath | the optional path between inToken and outToken that will be used in the pathfinder |

Return values:

| Name      | Type                       | Description                                                       |
| --------- | -------------------------- | ----------------------------------------------------------------- |
| amountOut | uint256                    | the received amount of outToken after the swap (with 18 decimals) |
| path      | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                 |

### getNormalizedExtendedPriceIn (0x9ebb6389)

```solidity
function getNormalizedExtendedPriceIn(
    address inToken,
    address outToken,
    uint256 amountOut,
    IPriceFeed.SwapPath memory optionalPath
) external returns (uint256 amountIn, IPriceFeed.SwapPath memory path)
```

Shares the same functionality as "getExtendedPriceIn" function. It accepts and returns amounts with 18 decimals regardless of the inToken and outToken decimals

Parameters:

| Name         | Type                       | Description                                                                        |
| ------------ | -------------------------- | ---------------------------------------------------------------------------------- |
| inToken      | address                    | the token to exchange from                                                         |
| outToken     | address                    | the token to exchange to                                                           |
| amountOut    | uint256                    | the amount of outToken to be received (with 18 decimals)                           |
| optionalPath | struct IPriceFeed.SwapPath | the optional path between inToken and outToken that will be used in the pathfinder |

Return values:

| Name     | Type                       | Description                                                           |
| -------- | -------------------------- | --------------------------------------------------------------------- |
| amountIn | uint256                    | the required amount of inToken to execute the swap (with 18 decimals) |
| path     | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                     |

### getNormalizedPriceOut (0xb6ccb44d)

```solidity
function getNormalizedPriceOut(
    address inToken,
    address outToken,
    uint256 amountIn
) external returns (uint256 amountOut, IPriceFeed.SwapPath memory path)
```

Shares the same functionality as "getExtendedPriceOut" function with an empty optionalPath. It accepts and returns amounts with 18 decimals regardless of the inToken and outToken decimals

Parameters:

| Name     | Type    | Description                                              |
| -------- | ------- | -------------------------------------------------------- |
| inToken  | address | the token to exchange from                               |
| outToken | address | the token to exchange to                                 |
| amountIn | uint256 | the amount of inToken to be exchanged (with 18 decimals) |

Return values:

| Name      | Type                       | Description                                                       |
| --------- | -------------------------- | ----------------------------------------------------------------- |
| amountOut | uint256                    | the received amount of outToken after the swap (with 18 decimals) |
| path      | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                 |

### getNormalizedPriceIn (0x2bcbc598)

```solidity
function getNormalizedPriceIn(
    address inToken,
    address outToken,
    uint256 amountOut
) external returns (uint256 amountIn, IPriceFeed.SwapPath memory path)
```

Shares the same functionality as "getExtendedPriceIn" function with an empty optionalPath. It accepts and returns amounts with 18 decimals regardless of the inToken and outToken decimals

Parameters:

| Name      | Type    | Description                                              |
| --------- | ------- | -------------------------------------------------------- |
| inToken   | address | the token to exchange from                               |
| outToken  | address | the token to exchange to                                 |
| amountOut | uint256 | the amount of outToken to be received (with 18 decimals) |

Return values:

| Name     | Type                       | Description                                                       |
| -------- | -------------------------- | ----------------------------------------------------------------- |
| amountIn | uint256                    | required amount of inToken to execute the swap (with 18 decimals) |
| path     | struct IPriceFeed.SwapPath | the tokens path that will be used during the swap                 |


# IContractsRegistry

## Interface Description

License: MIT

##

```solidity
interface IContractsRegistry
```

This is the registry contract of DEXE platform that stores information about the other contracts used by the protocol. Its purpose is to keep track of the propotol's contracts, provide upgradeability mechanism and dependency injection mechanism.

## Functions info

### getUserRegistryContract (0x435403b4)

```solidity
function getUserRegistryContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                   |
| ---- | ------- | ----------------------------- |
| \[0] | address | UserRegistry contract address |

### getPoolFactoryContract (0x475c5bc6)

```solidity
function getPoolFactoryContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                  |
| ---- | ------- | ---------------------------- |
| \[0] | address | PoolFactory contract address |

### getPoolRegistryContract (0x892dd52a)

```solidity
function getPoolRegistryContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                   |
| ---- | ------- | ----------------------------- |
| \[0] | address | PoolRegistry contract address |

### getDEXEContract (0x9fc64f57)

```solidity
function getDEXEContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                 |
| ---- | ------- | --------------------------- |
| \[0] | address | DEXE token contract address |

### getUSDContract (0xa5bac943)

```solidity
function getUSDContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                                                                      |
| ---- | ------- | -------------------------------------------------------------------------------- |
| \[0] | address | Platform's native USD token contract address. This may be USDT/BUSD/USDC/DAI/FEI |

### getPriceFeedContract (0x9bc0c5d2)

```solidity
function getPriceFeedContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                |
| ---- | ------- | -------------------------- |
| \[0] | address | PriceFeed contract address |

### getTreasuryContract (0x26c74fc3)

```solidity
function getTreasuryContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                      |
| ---- | ------- | -------------------------------- |
| \[0] | address | Treasury contract/wallet address |

### getCorePropertiesContract (0xc1ff8103)

```solidity
function getCorePropertiesContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                     |
| ---- | ------- | ------------------------------- |
| \[0] | address | CoreProperties contract address |

### getBABTContract (0x05a1b626)

```solidity
function getBABTContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description           |
| ---- | ------- | --------------------- |
| \[0] | address | BABT contract address |

### getDexeExpertNftContract (0x029f708b)

```solidity
function getDexeExpertNftContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \[0] | address | DexeExpertNft contract address |

### getPoolSphereXEngineContract (0x93446644)

```solidity
function getPoolSphereXEngineContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| \[0] | address | SphereX engine for DAOs |

### getSphereXEngineContract (0xb5ec48a4)

```solidity
function getSphereXEngineContract() external view returns (address)
```

Used in dependency injection mechanism

Return values:

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| \[0] | address | SphereX engine for global entities |


# ICoreProperties

## Interface Description

License: MIT

##

```solidity
interface ICoreProperties
```

This is the central contract of the protocol which stores the parameters that may be modified by the DAO. These are commissions percentages and pools parameters

## Structs info

### CoreParameters

```solidity
struct CoreParameters {
	uint128 govVotesLimit;
	uint128 govCommissionPercentage;
	uint128 tokenSaleProposalCommissionPercentage;
	uint128 micropoolVoteRewardsPercentage;
	uint128 treasuryVoteRewardsPercentage;
}
```

The struct that stores vital platform's parameters that may be modified by the OWNER The struct that stores GovPool parameters

Parameters:

| Name                                  | Type    | Description                                            |
| ------------------------------------- | ------- | ------------------------------------------------------ |
| govVotesLimit                         | uint128 | the maximum number of simultaneous votes of the voter  |
| tokenSaleProposalCommissionPercentage | uint128 | the commission percentage for the token sale proposal  |
| micropoolVoteRewardsPercentage        | uint128 | the percentage of the rewards for the micropool voters |
| treasuryVoteRewardsPercentage         | uint128 | the percentage of the rewards for the treasury voters  |

## Functions info

### setCoreParameters (0xc4b85e4c)

```solidity
function setCoreParameters(
    ICoreProperties.CoreParameters calldata _coreParameters
) external
```

The function to set CoreParameters

Parameters:

| Name             | Type                                  | Description    |
| ---------------- | ------------------------------------- | -------------- |
| \_coreParameters | struct ICoreProperties.CoreParameters | the parameters |

### setDEXECommissionPercentages (0x7f5070fa)

```solidity
function setDEXECommissionPercentages(uint128 govCommission) external
```

The function to modify the platform's commission percentages

Parameters:

| Name          | Type    | Description                                                     |
| ------------- | ------- | --------------------------------------------------------------- |
| govCommission | uint128 | the gov percentage commission. Should be multiplied by 10\*\*25 |

### setTokenSaleProposalCommissionPercentage (0x07914c59)

```solidity
function setTokenSaleProposalCommissionPercentage(
    uint128 tokenSaleProposalCommissionPercentage
) external
```

The function to set new token sale proposal commission percentage

Parameters:

| Name                                  | Type    | Description                   |
| ------------------------------------- | ------- | ----------------------------- |
| tokenSaleProposalCommissionPercentage | uint128 | the new commission percentage |

### setVoteRewardsPercentages (0x2bc88373)

```solidity
function setVoteRewardsPercentages(
    uint128 micropoolVoteRewardsPercentage,
    uint128 treasuryVoteRewardsPercentage
) external
```

The function to set new vote rewards percentages

Parameters:

| Name                           | Type    | Description                                            |
| ------------------------------ | ------- | ------------------------------------------------------ |
| micropoolVoteRewardsPercentage | uint128 | the percentage of the rewards for the micropool voters |
| treasuryVoteRewardsPercentage  | uint128 | the percentage of the rewards for the treasury voters  |

### setGovVotesLimit (0xd4a4bea5)

```solidity
function setGovVotesLimit(uint128 newVotesLimit) external
```

The function to set new gov votes limit

Parameters:

| Name          | Type    | Description         |
| ------------- | ------- | ------------------- |
| newVotesLimit | uint128 | new gov votes limit |

### getDEXECommissionPercentages (0x9834ceac)

```solidity
function getDEXECommissionPercentages()
    external
    view
    returns (uint128 govPercentage, address treasuryAddress)
```

The function to get commission percentage and receiver

Return values:

| Name            | Type    | Description                            |
| --------------- | ------- | -------------------------------------- |
| govPercentage   | uint128 | the overall gov commission percentage  |
| treasuryAddress | address | the address of the treasury commission |

### getTokenSaleProposalCommissionPercentage (0xdcce18e7)

```solidity
function getTokenSaleProposalCommissionPercentage()
    external
    view
    returns (uint128)
```

The function to get the token sale proposal commission percentage

Return values:

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| \[0] | uint128 | the commission percentage |

### getVoteRewardsPercentages (0x43570d3a)

```solidity
function getVoteRewardsPercentages() external view returns (uint128, uint128)
```

The function to get the vote rewards percentages

Return values:

| Name | Type    | Description                                                                           |
| ---- | ------- | ------------------------------------------------------------------------------------- |
| \[0] | uint128 | micropoolVoteRewardsPercentage the percentage of the rewards for the micropool voters |
| \[1] | uint128 | treasuryVoteRewardsPercentage the percentage of the rewards for the treasury voters   |

### getGovVotesLimit (0x47dd039f)

```solidity
function getGovVotesLimit() external view returns (uint128 votesLimit)
```

The function to get max votes limit of the gov pool

Return values:

| Name       | Type    | Description     |
| ---------- | ------- | --------------- |
| votesLimit | uint128 | the votes limit |


# Factory contracts


# IPoolRegistry

## Interface Description

License: MIT

##

```solidity
interface IPoolRegistry
```

This is the PoolRegistry contract, a tuned ContractsRegistry contract. Its purpose is the management of proposal pools, GovPools and contracts related to GovPools. The owner of this contract is capable of upgrading pools' implementation via the ProxyBeacon pattern

## Functions info

### addProxyPool (0x09ae152b)

```solidity
function addProxyPool(string calldata name, address poolAddress) external
```

The function to add the pool proxy to the registry (called by the PoolFactory)

Parameters:

| Name        | Type    | Description                    |
| ----------- | ------- | ------------------------------ |
| name        | string  | the type of the pool           |
| poolAddress | address | the address of the pool to add |

### isGovPool (0x9e475551)

```solidity
function isGovPool(address potentialPool) external view returns (bool)
```

The function to check if the given address is a valid GovPool

Parameters:

| Name          | Type    | Description            |
| ------------- | ------- | ---------------------- |
| potentialPool | address | the address to inspect |

Return values:

| Name | Type | Description                                       |
| ---- | ---- | ------------------------------------------------- |
| \[0] | bool | true if the address is a GovPool, false otherwise |


# IPoolFactory

## Interface Description

License: MIT

##

```solidity
interface IPoolFactory
```

This is the Factory contract for the gov pools. Anyone can create a pool for themselves to become a governance owner (GovPool)

## Enums info

### VotePowerType

```solidity
enum VotePowerType {
	 LINEAR_VOTES,
	 POLYNOMIAL_VOTES,
	 CUSTOM_VOTES
}
```

The enum that holds information about calculating vote power

Parameters:

| Name              | Description                                       |
| ----------------- | ------------------------------------------------- |
| LINEAR\_VOTES     | the vote power = number of tokens                 |
| POLYNOMIAL\_VOTES | the vote power calculated with polynomial formula |
| CUSTOM\_VOTES     | the vote type defined by a customer               |

## Structs info

### SettingsDeployParams

```solidity
struct SettingsDeployParams {
	IGovSettings.ProposalSettings[] proposalSettings;
	address[] additionalProposalExecutors;
}
```

General settings of the pool

Parameters:

| Name                        | Type                                    | Description                                     |
| --------------------------- | --------------------------------------- | ----------------------------------------------- |
| proposalSettings            | struct IGovSettings.ProposalSettings\[] | list of infos about settings for proposal types |
| additionalProposalExecutors | address\[]                              | list of additional proposal executors           |

### ValidatorsDeployParams

```solidity
struct ValidatorsDeployParams {
	string name;
	string symbol;
	IGovValidators.ProposalSettings proposalSettings;
	address[] validators;
	uint256[] balances;
}
```

Parameters of validators

Parameters:

| Name             | Type                                   | Description                                      |
| ---------------- | -------------------------------------- | ------------------------------------------------ |
| name             | string                                 | the name of a token used by validators           |
| symbol           | string                                 | the symbol of a token used by validators         |
| proposalSettings | struct IGovValidators.ProposalSettings | struct with settings for proposals               |
| validators       | address\[]                             | list of the validator addresses                  |
| balances         | uint256\[]                             | list of initial token balances of the validators |

### UserKeeperDeployParams

```solidity
struct UserKeeperDeployParams {
	address tokenAddress;
	address nftAddress;
	uint256 individualPower;
	uint256 nftsTotalSupply;
}
```

Parameters of the user keeper

Parameters:

| Name            | Type    | Description                           |
| --------------- | ------- | ------------------------------------- |
| tokenAddress    | address | address of the tokens used for voting |
| nftAddress      | address | address of the NFT used for voting    |
| individualPower | uint256 | the voting power of an NFT            |
| nftsTotalSupply | uint256 | the NFT collection size               |

### VotePowerDeployParams

```solidity
struct VotePowerDeployParams {
	IPoolFactory.VotePowerType voteType;
	bytes initData;
	address presetAddress;
}
```

The voting power parameters

Parameters:

| Name          | Type                            | Description                                                   |
| ------------- | ------------------------------- | ------------------------------------------------------------- |
| voteType      | enum IPoolFactory.VotePowerType | type of algorythm to calculate votes number from token number |
| initData      | bytes                           | initialization data for standard contract types               |
| presetAddress | address                         | address of custom contract (for custom voteType)              |

### GovPoolDeployParams

```solidity
struct GovPoolDeployParams {
	IPoolFactory.SettingsDeployParams settingsParams;
	IPoolFactory.ValidatorsDeployParams validatorsParams;
	IPoolFactory.UserKeeperDeployParams userKeeperParams;
	IERC20Gov.ConstructorParams tokenParams;
	IPoolFactory.VotePowerDeployParams votePowerParams;
	address verifier;
	bool onlyBABTHolders;
	string descriptionURL;
	string name;
}
```

The pool deploy parameters

Parameters:

| Name             | Type                                       | Description                                                         |
| ---------------- | ------------------------------------------ | ------------------------------------------------------------------- |
| settingsParams   | struct IPoolFactory.SettingsDeployParams   | general settings of the pool                                        |
| validatorsParams | struct IPoolFactory.ValidatorsDeployParams | parameters of validators                                            |
| userKeeperParams | struct IPoolFactory.UserKeeperDeployParams | parameters of the user keeper                                       |
| tokenParams      | struct IERC20Gov.ConstructorParams         | the gov token parameters                                            |
| votePowerParams  | struct IPoolFactory.VotePowerDeployParams  | vote power parameters                                               |
| verifier         | address                                    | the address of the verifier                                         |
| onlyBABTHolders  | bool                                       | if true, only KYCed users will be allowed to interact with the pool |
| descriptionURL   | string                                     | the description of the pool                                         |
| name             | string                                     | the name of the pool                                                |

### GovPoolPredictedAddresses

```solidity
struct GovPoolPredictedAddresses {
	address govPool;
	address govTokenSale;
	address govToken;
	address distributionProposal;
	address expertNft;
	address nftMultiplier;
}
```

The predicted pool addresses given tx.origin and GovPool name

Parameters:

| Name                 | Type    | Description                                |
| -------------------- | ------- | ------------------------------------------ |
| govPool              | address | the predicted govPool address              |
| govTokenSale         | address | the predicted govTokenSale address         |
| govToken             | address | the predicted govToken address             |
| distributionProposal | address | the predicted distributionProposal address |
| expertNft            | address | the predicted expertNft address            |
| nftMultiplier        | address | the predicted nftMultiplier address        |

## Functions info

### deployGovPool (0x0cc3c11c)

```solidity
function deployGovPool(
    IPoolFactory.GovPoolDeployParams calldata parameters
) external
```

This function is used to deploy DAO Pool with TokenSale proposal

Parameters:

| Name       | Type                                    | Description                |
| ---------- | --------------------------------------- | -------------------------- |
| parameters | struct IPoolFactory.GovPoolDeployParams | the pool deploy parameters |

### predictGovAddresses (0x17278f74)

```solidity
function predictGovAddresses(
    address deployer,
    string calldata poolName
) external view returns (IPoolFactory.GovPoolPredictedAddresses memory)
```

The view function that predicts the addresses where the gov pool proxy, the gov token sale proxy and the gov token will be stored

Parameters:

| Name     | Type    | Description                                    |
| -------- | ------- | ---------------------------------------------- |
| deployer | address | the user that deploys the gov pool (tx.origin) |
| poolName | string  | the name of the pool which is part of the salt |

Return values:

| Name | Type                                          | Description             |
| ---- | --------------------------------------------- | ----------------------- |
| \[0] | struct IPoolFactory.GovPoolPredictedAddresses | the predicted addresses |


# Gov contracts


# ERC20


# IERC20Gov

## Interface Description

License: MIT

##

```solidity
interface IERC20Gov
```

DAO pools could issue their own ERC20 token and sell it to investors with custom sale logic

## Structs info

### ConstructorParams

```solidity
struct ConstructorParams {
	string name;
	string symbol;
	address[] users;
	uint256 cap;
	uint256 mintedTotal;
	uint256[] amounts;
}
```

Initial ERC20Gov parameters. This struct is used as an input argument in the contract constructor

Parameters:

| Name        | Type       | Description                                                              |
| ----------- | ---------- | ------------------------------------------------------------------------ |
| name        | string     | the name of the token                                                    |
| symbol      | string     | the symbol of the token                                                  |
| users       | address\[] | the list of users for which tokens are needed to be minted               |
| cap         | uint256    | cap on the token's total supply                                          |
| mintedTotal | uint256    | the total amount of tokens to be minted with the contract creation       |
| amounts     | uint256\[] | the list of token amounts which should be minted to the respective users |

## Functions info

### mint (0x40c10f19)

```solidity
function mint(address account, uint256 amount) external
```

This function is used to mint tokens

Parameters:

| Name    | Type    | Description                                  |
| ------- | ------- | -------------------------------------------- |
| account | address | the address to which tokens should be minted |
| amount  | uint256 | the token amount to be minted                |

### pause (0x8456cb59)

```solidity
function pause() external
```

This function is used to trigger stopped contract state

### unpause (0x3f4ba83a)

```solidity
function unpause() external
```

This function is used to return default contract state

### blacklist (0xc997eb8d)

```solidity
function blacklist(address[] calldata accounts, bool value) external
```

This function is used to blacklist the addresses

Parameters:

| Name     | Type       | Description                     |
| -------- | ---------- | ------------------------------- |
| accounts | address\[] | the addresses to be blacklisted |
| value    | bool       | the blacklist status            |

### totalBlacklistAccounts (0xa33556f1)

```solidity
function totalBlacklistAccounts() external view returns (uint256)
```

This function is used to get the total amount of blacklisted accounts

### getBlacklistAccounts (0x59f017ed)

```solidity
function getBlacklistAccounts(
    uint256 offset,
    uint256 limit
) external view returns (address[] memory)
```

The paginated function to get addresses of blacklisted accounts

Parameters:

| Name   | Type    | Description                              |
| ------ | ------- | ---------------------------------------- |
| offset | uint256 | the starting index of the accounts array |
| limit  | uint256 | the length of the array to observe       |

Return values:

| Name | Type       | Description               |
| ---- | ---------- | ------------------------- |
| \[0] | address\[] | requested blacklist array |


# ERC721


# experts


# IERC721Expert

## Interface Description

License: MIT

##

```solidity
interface IERC721Expert is IERC721Upgradeable
```

The ERC721 token that implements experts functionality, follows EIP-5484

## Enums info

### BurnAuth

```solidity
enum BurnAuth {
	 IssuerOnly,
	 OwnerOnly,
	 Both,
	 Neither
}
```

## Events info

### Issued

```solidity
event Issued(address indexed from, address indexed to, uint256 indexed tokenId, IERC721Expert.BurnAuth burnAuth)
```

Emitted when a soulbound token is issued.

Parameters:

| Name     | Type                        | Description                |
| -------- | --------------------------- | -------------------------- |
| from     | address                     | The issuer                 |
| to       | address                     | The receiver               |
| tokenId  | uint256                     | The id of the issued token |
| burnAuth | enum IERC721Expert.BurnAuth | the BurnAuth struct        |

### TagsAdded

```solidity
event TagsAdded(uint256 indexed tokenId, string[] tags)
```

Emitted when tags are added to the SBT

Parameters:

| Name    | Type      | Description                        |
| ------- | --------- | ---------------------------------- |
| tokenId | uint256   | the token where the tags are added |
| tags    | string\[] | the list of tags                   |

## Functions info

### burn (0x89afcb44)

```solidity
function burn(address from) external
```

The function to burn the token

Parameters:

| Name | Type    | Description                                |
| ---- | ------- | ------------------------------------------ |
| from | address | the address to burn from (1 to 1 relation) |

### isExpert (0x76c535ae)

```solidity
function isExpert(address expert) external view returns (bool)
```

The function to check of a user is an expert

Parameters:

| Name   | Type    | Description       |
| ------ | ------- | ----------------- |
| expert | address | the user to check |

Return values:

| Name | Type | Description               |
| ---- | ---- | ------------------------- |
| \[0] | bool | true if user is an expert |

### getIdByExpert (0x6047fb89)

```solidity
function getIdByExpert(address expert) external view returns (uint256)
```

The function to get the SBT id of an expert

Parameters:

| Name   | Type    | Description                   |
| ------ | ------- | ----------------------------- |
| expert | address | the user to get the SBT id of |

Return values:

| Name | Type    | Description        |
| ---- | ------- | ------------------ |
| \[0] | uint256 | SBT id of the user |

### burnAuth (0x0489b56f)

```solidity
function burnAuth(
    uint256 tokenId
) external view returns (IERC721Expert.BurnAuth)
```

provides burn authorization of the token id

Parameters:

| Name    | Type    | Description                |
| ------- | ------- | -------------------------- |
| tokenId | uint256 | The identifier for a token |

Return values:

| Name | Type                        | Description |
| ---- | --------------------------- | ----------- |
| \[0] | enum IERC721Expert.BurnAuth | the auth    |


# multipliers


# IAbstractERC721Multiplier

## Interface Description

License: MIT

##

```solidity
interface IAbstractERC721Multiplier is IERC721EnumerableUpgradeable
```

This is the special NFT contract which behaves like a coupon that can be locked to receive certain extra rewards proportional to the rewards in the Governance pool contract

## Structs info

### NftInfo

```solidity
struct NftInfo {
	uint256 multiplier;
	uint64 duration;
	uint64 mintedAt;
}
```

This struct holds NFT Multiplier parameters

Parameters:

| Name       | Type    | Description                             |
| ---------- | ------- | --------------------------------------- |
| multiplier | uint256 | the basic rewards multiplier            |
| duration   | uint64  | the time for which an nft can be locked |
| mintedAt   | uint64  | the time nft was minter                 |

## Functions info

### lock (0xdd467064)

```solidity
function lock(uint256 tokenId) external
```

This function is used to lock an nft (enable corresponding basic rewards multiplier). Only one NFT for each address can be locked at the same time

Parameters:

| Name    | Type    | Description                    |
| ------- | ------- | ------------------------------ |
| tokenId | uint256 | the id of the nft to be locked |

### unlock (0xa69df4b5)

```solidity
function unlock() external
```

This function is used to unlock an nft (disable corresponding basic rewards multiplier)

### getExtraRewards (0x1429683b)

```solidity
function getExtraRewards(
    address whose,
    uint256 rewards
) external view returns (uint256)
```

This function is used to calculate extra rewards

Parameters:

| Name    | Type    | Description                                             |
| ------- | ------- | ------------------------------------------------------- |
| whose   | address | the address of the user who is to receive extra rewards |
| rewards | uint256 | basic rewards to be multiplied                          |

Return values:

| Name | Type    | Description   |
| ---- | ------- | ------------- |
| \[0] | uint256 | extra rewards |

### isLocked (0xf6aacfb1)

```solidity
function isLocked(uint256 tokenId) external view returns (bool)
```

This function is used to check whether the passed nft id is locked

Parameters:

| Name    | Type    | Description       |
| ------- | ------- | ----------------- |
| tokenId | uint256 | the id of the nft |

Return values:

| Name | Type | Description                                                        |
| ---- | ---- | ------------------------------------------------------------------ |
| \[0] | bool | false if nft has expired or hasn't yet been locked, otherwise true |


# IERC721Multiplier

## Interface Description

License: MIT

##

```solidity
interface IERC721Multiplier is IAbstractERC721Multiplier
```

## Functions info

### changeToken (0x4ccc2757)

```solidity
function changeToken(
    uint256 tokenId,
    uint256 multiplier,
    uint64 duration
) external
```

This function is used to change the basic rewards multiplier and the time for which the current nft will be locked

Parameters:

| Name       | Type    | Description                             |
| ---------- | ------- | --------------------------------------- |
| tokenId    | uint256 | the id of the nft to be changed         |
| multiplier | uint256 | the basic rewards multiplier            |
| duration   | uint64  | the time for which an nft can be locked |

### getCurrentMultiplier (0x0aebf7d2)

```solidity
function getCurrentMultiplier(
    address whose
) external view returns (uint256 multiplier, uint256 timeLeft)
```

This function is used to get the current basic rewards multiplier and the time for which the current nft will be locked

Parameters:

| Name  | Type    | Description                           |
| ----- | ------- | ------------------------------------- |
| whose | address | the address of the user to be checked |

Return values:

| Name       | Type    | Description                                             |
| ---------- | ------- | ------------------------------------------------------- |
| multiplier | uint256 | the basic rewards multiplier                            |
| timeLeft   | uint256 | seconds remaining before the current locked nft expires |


# IDexeERC721Multiplier

## Interface Description

License: MIT

##

```solidity
interface IDexeERC721Multiplier is IAbstractERC721Multiplier
```

## Functions info

### changeToken (0xa0545331)

```solidity
function changeToken(
    uint256 tokenId,
    uint256 multiplier,
    uint64 duration,
    uint256 averageBalance
) external
```

This function is used to change the basic rewards multiplier and the time for which the current nft will be locked

Parameters:

| Name           | Type    | Description                              |
| -------------- | ------- | ---------------------------------------- |
| tokenId        | uint256 | the id of the nft to be changed          |
| multiplier     | uint256 | the basic rewards multiplier             |
| duration       | uint64  | the time for which an nft can be locked  |
| averageBalance | uint256 | the average balance of the user's tokens |

### getCurrentMultiplier (0xc914c789)

```solidity
function getCurrentMultiplier(
    address whose,
    uint256 rewards
) external view returns (uint256 multiplier, uint256 timeLeft)
```

This function is used to get the current rewards multiplier and the time for which the current nft will be locked

Parameters:

| Name    | Type    | Description                           |
| ------- | ------- | ------------------------------------- |
| whose   | address | the address of the user to be checked |
| rewards | uint256 | basic rewards to be multiplied        |

Return values:

| Name       | Type    | Description                                             |
| ---------- | ------- | ------------------------------------------------------- |
| multiplier | uint256 | the rewards multiplier                                  |
| timeLeft   | uint256 | seconds remaining before the current locked nft expires |


# powers


# IERC721Power

## Interface Description

License: MIT

##

```solidity
interface IERC721Power is IERC721EnumerableUpgradeable
```

This is the custom NFT contract with voting power

## Structs info

### NftInfo

```solidity
struct NftInfo {
	uint64 lastUpdate;
	uint256 maxRawPower;
	uint256 currentRawPower;
	uint256 requiredCollateral;
	uint256 currentCollateral;
}
```

This struct holds NFT Power parameters. These parameters are used to recalculate nft power

Parameters:

| Name               | Type    | Description                                   |
| ------------------ | ------- | --------------------------------------------- |
| lastUpdate         | uint64  | the last time when the power was recalculated |
| maxRawPower        | uint256 | the maximum raw nft power limit               |
| currentRawPower    | uint256 | the current raw nft power                     |
| requiredCollateral | uint256 | the required collateral amount                |
| currentCollateral  | uint256 | the current nft collateral                    |

### NftInfoView

```solidity
struct NftInfoView {
	IERC721Power.NftInfo rawInfo;
	uint256 maxPower;
	uint256 minPower;
	uint256 currentPower;
}
```

The struct to get info about the NFT

Parameters:

| Name         | Type                        | Description        |
| ------------ | --------------------------- | ------------------ |
| rawInfo      | struct IERC721Power.NftInfo | the raw NFT info   |
| maxPower     | uint256                     | real max nft power |
| minPower     | uint256                     | real min nft power |
| currentPower | uint256                     | real nft power     |

## Functions info

### addCollateral (0xa8f35adf)

```solidity
function addCollateral(uint256 amount, uint256 tokenId) external
```

Add collateral amount to certain nft

Parameters:

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| amount  | uint256 | Wei         |
| tokenId | uint256 | Nft number  |

### removeCollateral (0x6a9b1891)

```solidity
function removeCollateral(uint256 amount, uint256 tokenId) external
```

Remove collateral amount from certain nft

Parameters:

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| amount  | uint256 | Wei         |
| tokenId | uint256 | Nft number  |

### recalculateNftPowers (0xa79b53d5)

```solidity
function recalculateNftPowers(uint256[] calldata tokenIds) external
```

Recalculate nft power (coefficient)

Parameters:

| Name     | Type       | Description |
| -------- | ---------- | ----------- |
| tokenIds | uint256\[] | Nft numbers |

### totalPower (0xdb3ad22c)

```solidity
function totalPower() external view returns (uint256)
```

Get total power

Return values:

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \[0] | uint256 | totalPower  |

### getNftMaxPower (0x6c889f41)

```solidity
function getNftMaxPower(uint256 tokenId) external view returns (uint256)
```

Return max possible power (coefficient) for nft

Parameters:

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| tokenId | uint256 | Nft number  |

Return values:

| Name | Type    | Description       |
| ---- | ------- | ----------------- |
| \[0] | uint256 | max power for Nft |

### getNftMinPower (0x7c24b33a)

```solidity
function getNftMinPower(uint256 tokenId) external view returns (uint256)
```

Return min possible power (coefficient) for nft

Parameters:

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| tokenId | uint256 | Nft number  |

Return values:

| Name | Type    | Description       |
| ---- | ------- | ----------------- |
| \[0] | uint256 | min power for Nft |

### getNftPower (0x412e8a29)

```solidity
function getNftPower(uint256 tokenId) external view returns (uint256)
```

The function to get current NFT power

Parameters:

| Name    | Type    | Description    |
| ------- | ------- | -------------- |
| tokenId | uint256 | the Nft number |

Return values:

| Name | Type    | Description              |
| ---- | ------- | ------------------------ |
| \[0] | uint256 | current power of the Nft |

### getNftRequiredCollateral (0xcbf208a7)

```solidity
function getNftRequiredCollateral(
    uint256 tokenId
) external view returns (uint256)
```

Return required collateral amount for nft

Parameters:

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| tokenId | uint256 | Nft number  |

Return values:

| Name | Type    | Description                 |
| ---- | ------- | --------------------------- |
| \[0] | uint256 | required collateral for Nft |


# proposals


# IProposalValidator

## Interface Description

License: MIT

##

```solidity
interface IProposalValidator
```

The hook contract that proposals may inherit in order to implement extra validation

## Functions info

### validate (0x4216fc04)

```solidity
function validate(
    IGovPool.ProposalAction[] calldata actions
) external view returns (bool valid)
```

The hook function

Parameters:

| Name    | Type                              | Description                |
| ------- | --------------------------------- | -------------------------- |
| actions | struct IGovPool.ProposalAction\[] | the proposal "for" actions |

Return values:

| Name  | Type | Description                                                         |
| ----- | ---- | ------------------------------------------------------------------- |
| valid | bool | "true" if everything is ok, "false" to revert the proposal creation |


# IDistributionProposal

## Interface Description

License: MIT

##

```solidity
interface IDistributionProposal
```

This is the contract the governance can execute in order to distribute rewards proportionally among all the voters who participated in the certain proposal

## Structs info

### DPInfo

```solidity
struct DPInfo {
	address rewardAddress;
	uint256 rewardAmount;
	mapping(address => bool) claimed;
}
```

The struct holds information about distribution proposal

Parameters:

| Name          | Type                     | Description                                                      |
| ------------- | ------------------------ | ---------------------------------------------------------------- |
| rewardAddress | address                  | the address of reward token                                      |
| rewardAmount  | uint256                  | the total amount of rewards                                      |
| claimed       | mapping(address => bool) | mapping, that indicates whether the user has claimed the rewards |

## Functions info

### execute (0xc45e0ae6)

```solidity
function execute(
    uint256 proposalId,
    address token,
    uint256 amount
) external payable
```

Executed by `Gov` contract, creates a DP

Parameters:

| Name       | Type    | Description                                 |
| ---------- | ------- | ------------------------------------------- |
| proposalId | uint256 | the id of distribution proposal in Gov pool |
| token      | address | the rewards token address                   |
| amount     | uint256 | the total amount of rewards                 |

### claim (0x45718278)

```solidity
function claim(address voter, uint256[] calldata proposalIds) external
```

Claims distribution proposal rewards

Parameters:

| Name        | Type       | Description               |
| ----------- | ---------- | ------------------------- |
| voter       | address    | Voter address             |
| proposalIds | uint256\[] | the array of proposal ids |

### isClaimed (0xd2ef0795)

```solidity
function isClaimed(
    uint256 proposalId,
    address voter
) external view returns (bool)
```

Function to check if voter claimed their reward

Parameters:

| Name       | Type    | Description                  |
| ---------- | ------- | ---------------------------- |
| proposalId | uint256 | the distribution proposal id |
| voter      | address | the user to check            |

Return values:

| Name | Type | Description               |
| ---- | ---- | ------------------------- |
| \[0] | bool | true if reward is claimed |

### getPotentialReward (0xfe32b0ba)

```solidity
function getPotentialReward(
    uint256 proposalId,
    address voter
) external view returns (uint256)
```

Return potential reward. If user hasn't voted, or `getTotalVotesWeight` is zero, return zero

Parameters:

| Name       | Type    | Description     |
| ---------- | ------- | --------------- |
| proposalId | uint256 | the proposal id |
| voter      | address | Voter address   |


# ITokenSaleProposal

## Interface Description

License: MIT

##

```solidity
interface ITokenSaleProposal
```

The contract for the additional proposal with custom settings. This contract acts as a marketplace to provide DAO pools with the ability to sell their own ERC20 tokens.

## Enums info

### ParticipationType

```solidity
enum ParticipationType {
	 DAOVotes,
	 Whitelist,
	 BABT,
	 TokenLock,
	 NftLock
}
```

The enum that represents the type of requirements to participate in the tier

Parameters:

| Name      | Description                                                               |
| --------- | ------------------------------------------------------------------------- |
| DAOVotes  | indicates that the user must have the required voting power               |
| Whitelist | indicates that the user must be included in the whitelist of the tier     |
| BABT      | indicates that the user must own the BABT token                           |
| TokenLock | indicates that the user must lock a specific amount of tokens in the tier |
| NftLock   | indicates that the user must lock an nft in the tier                      |

## Structs info

### TierMetadata

```solidity
struct TierMetadata {
	string name;
	string description;
}
```

Metadata of the tier that is part of the initial tier parameters

Parameters:

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| name        | string | the name of the tier        |
| description | string | the description of the tier |

### VestingSettings

```solidity
struct VestingSettings {
	uint256 vestingPercentage;
	uint64 vestingDuration;
	uint64 cliffPeriod;
	uint64 unlockStep;
}
```

Vesting parameters that are part of the initial tier parameters

Parameters:

| Name              | Type    | Description                                                                            |
| ----------------- | ------- | -------------------------------------------------------------------------------------- |
| vestingPercentage | uint256 | percentage of the purchased token amount that goes to vesting                          |
| vestingDuration   | uint64  | how long vesting lasts from the time of the token purchase                             |
| cliffPeriod       | uint64  | how long the user cannot make a vesting withdrawal from the time of the token purchase |
| unlockStep        | uint64  | the tick step with which funds from the vesting are given to the buyer                 |

### ParticipationDetails

```solidity
struct ParticipationDetails {
	ITokenSaleProposal.ParticipationType participationType;
	bytes data;
}
```

Participation details that are part of the initial tier parameters

Parameters:

| Name              | Type                                      | Description                                                        |
| ----------------- | ----------------------------------------- | ------------------------------------------------------------------ |
| participationType | enum ITokenSaleProposal.ParticipationType | the type of requirements to participate in the tier                |
| data              | bytes                                     | the additional data associated with the participation requirements |

### TierInitParams

```solidity
struct TierInitParams {
	ITokenSaleProposal.TierMetadata metadata;
	uint256 totalTokenProvided;
	uint64 saleStartTime;
	uint64 saleEndTime;
	uint64 claimLockDuration;
	address saleTokenAddress;
	address[] purchaseTokenAddresses;
	uint256[] exchangeRates;
	uint256 minAllocationPerUser;
	uint256 maxAllocationPerUser;
	ITokenSaleProposal.VestingSettings vestingSettings;
	ITokenSaleProposal.ParticipationDetails[] participationDetails;
}
```

Initial tier parameters

Parameters:

| Name                   | Type                                              | Description                                                                                                                                                            |
| ---------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| metadata               | struct ITokenSaleProposal.TierMetadata            | metadata of the tier (see TierMetadata)                                                                                                                                |
| totalTokenProvided     | uint256                                           | total supply of tokens provided for the tier                                                                                                                           |
| saleStartTime          | uint64                                            | start time of token sales                                                                                                                                              |
| saleEndTime            | uint64                                            | end time of token sales                                                                                                                                                |
| claimLockDuration      | uint64                                            | the period of time between the end of the token sale and the non-vesting tokens claiming                                                                               |
| saleTokenAddress       | address                                           | address of the token being sold                                                                                                                                        |
| purchaseTokenAddresses | address\[]                                        | tokens, that can be used for purchasing token of the proposal                                                                                                          |
| exchangeRates          | uint256\[]                                        | exchange rates of other tokens to the token of TokenSaleProposal. Must disregard tokens decimals. If you want to sell 1 BTC for 1 ETH, exchangeRate has to be 10\*\*25 |
| minAllocationPerUser   | uint256                                           | minimal allocation of tokens per one user                                                                                                                              |
| maxAllocationPerUser   | uint256                                           | maximal allocation of tokens per one user                                                                                                                              |
| vestingSettings        | struct ITokenSaleProposal.VestingSettings         | settings for managing tokens vesting (unlocking). While tokens are locked investors won\`t be able to withdraw them                                                    |
| participationDetails   | struct ITokenSaleProposal.ParticipationDetails\[] | the list of participation requirement parameters                                                                                                                       |

### VestingTierInfo

```solidity
struct VestingTierInfo {
	uint64 vestingStartTime;
	uint64 vestingEndTime;
}
```

Vesting tier-related parameters

Parameters:

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| vestingStartTime | uint64 | the start time of the vesting when the cliff period ends |
| vestingEndTime   | uint64 | the end time of the vesting                              |

### TierInfo

```solidity
struct TierInfo {
	bool isOff;
	uint256 totalSold;
	string uri;
	ITokenSaleProposal.VestingTierInfo vestingTierInfo;
}
```

Dynamic tier parameters

Parameters:

| Name            | Type                                      | Description                 |
| --------------- | ----------------------------------------- | --------------------------- |
| isOff           | bool                                      | whether the tier is off     |
| totalSold       | uint256                                   | how many tokens were sold   |
| uri             | string                                    | whitelist uri               |
| vestingTierInfo | struct ITokenSaleProposal.VestingTierInfo | vesting tier-related params |

### PurchaseInfo

```solidity
struct PurchaseInfo {
	EnumerableMap.AddressToUintMap spentAmounts;
	uint256 claimTotalAmount;
	bool isClaimed;
	EnumerableMap.AddressToUintMap lockedTokens;
	EnumerableSet.AddressSet lockedNftAddresses;
	mapping(address => EnumerableSet.UintSet) lockedNfts;
}
```

Purchase parameters

Parameters:

| Name               | Type                                             | Description                                                         |
| ------------------ | ------------------------------------------------ | ------------------------------------------------------------------- |
| spentAmounts       | struct EnumerableMap.AddressToUintMap            | matching purchase token addresses with spent amounts                |
| claimTotalAmount   | uint256                                          | the total amount to be claimed                                      |
| isClaimed          | bool                                             | the boolean indicating whether the purchase has been claimed or not |
| lockedTokens       | struct EnumerableMap.AddressToUintMap            | matching user locked tokens to locked amounts                       |
| lockedNftAddresses | struct EnumerableSet.AddressSet                  | the list of nft addresses locked by the user                        |
| lockedNfts         | mapping(address => struct EnumerableSet.UintSet) | the list of nft ids locked by the user                              |

### PurchaseView

```solidity
struct PurchaseView {
	bool isClaimed;
	bool canClaim;
	uint64 claimUnlockTime;
	uint256 claimTotalAmount;
	uint256 boughtTotalAmount;
	address[] lockedTokenAddresses;
	uint256[] lockedTokenAmounts;
	address[] lockedNftAddresses;
	uint256[][] lockedNftIds;
	address[] purchaseTokenAddresses;
	uint256[] purchaseTokenAmounts;
}
```

Purchase parameters. This struct is used in view functions as part of a return argument

Parameters:

| Name                   | Type          | Description                                                                     |
| ---------------------- | ------------- | ------------------------------------------------------------------------------- |
| isClaimed              | bool          | the boolean indicating whether non-vesting tokens have been claimed or not      |
| canClaim               | bool          | the boolean indication whether the user can claim non-vesting tokens            |
| claimUnlockTime        | uint64        | the time the user can claim its non-vesting tokens                              |
| claimTotalAmount       | uint256       | the total amount of tokens to be claimed                                        |
| boughtTotalAmount      | uint256       | the total amount of tokens user bought including vesting and non-vesting tokens |
| lockedTokenAddresses   | address\[]    | the list of locked token addresses                                              |
| lockedTokenAmounts     | uint256\[]    | the list of locked token amounts                                                |
| lockedNftAddresses     | address\[]    | the list of locked nft addresses                                                |
| lockedNftIds           | uint256\[]\[] | the list of locked nft ids                                                      |
| purchaseTokenAddresses | address\[]    | the list of purchase token addresses                                            |
| purchaseTokenAmounts   | uint256\[]    | the list of purchase token amounts                                              |

### VestingUserInfo

```solidity
struct VestingUserInfo {
	uint64 latestVestingWithdraw;
	uint256 vestingTotalAmount;
	uint256 vestingWithdrawnAmount;
}
```

Vesting user-related parameters

Parameters:

| Name                   | Type    | Description                                                |
| ---------------------- | ------- | ---------------------------------------------------------- |
| latestVestingWithdraw  | uint64  | the latest timestamp of the vesting withdrawal             |
| vestingTotalAmount     | uint256 | the total amount of user vesting tokens                    |
| vestingWithdrawnAmount | uint256 | the total amount of tokens user has withdrawn from vesting |

### VestingUserView

```solidity
struct VestingUserView {
	uint64 latestVestingWithdraw;
	uint64 nextUnlockTime;
	uint256 nextUnlockAmount;
	uint256 vestingTotalAmount;
	uint256 vestingWithdrawnAmount;
	uint256 amountToWithdraw;
	uint256 lockedAmount;
}
```

Vesting user-related parameters. This struct is used in view functions as part of a return argument

Parameters:

| Name                   | Type    | Description                                                                                      |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------ |
| latestVestingWithdraw  | uint64  | the latest timestamp of the vesting withdrawal                                                   |
| nextUnlockTime         | uint64  | the next time the user will receive vesting funds. It is zero if there are no more locked tokens |
| nextUnlockAmount       | uint256 | the token amount which will be unlocked in the next unlock time                                  |
| vestingTotalAmount     | uint256 | the total amount of user vesting tokens                                                          |
| vestingWithdrawnAmount | uint256 | the total amount of tokens user has withdrawn from vesting                                       |
| amountToWithdraw       | uint256 | the vesting token amount which can be withdrawn in the current time                              |
| lockedAmount           | uint256 | the vesting token amount which is locked in the current time                                     |

### ParticipationInfo

```solidity
struct ParticipationInfo {
	bool isWhitelisted;
	bool isBABTed;
	uint256 requiredDaoVotes;
	EnumerableMap.AddressToUintMap requiredTokenLock;
	EnumerableMap.AddressToUintMap requiredNftLock;
}
```

Participation parameters. Users should meet all the requirements in order to participate in the tier

Parameters:

| Name              | Type                                  | Description                                                 |
| ----------------- | ------------------------------------- | ----------------------------------------------------------- |
| isWhitelisted     | bool                                  | the boolean indicating whether the tier requires whitelist  |
| isBABTed          | bool                                  | the boolean indicating whether the tier requires BABT token |
| requiredDaoVotes  | uint256                               | the required amount of DAO votes                            |
| requiredTokenLock | struct EnumerableMap.AddressToUintMap | matching token address to required lock amounts             |
| requiredNftLock   | struct EnumerableMap.AddressToUintMap | matching nft address to required lock amounts               |

### UserInfo

```solidity
struct UserInfo {
	ITokenSaleProposal.PurchaseInfo purchaseInfo;
	ITokenSaleProposal.VestingUserInfo vestingUserInfo;
}
```

User parameters

Parameters:

| Name            | Type                                      | Description                             |
| --------------- | ----------------------------------------- | --------------------------------------- |
| purchaseInfo    | struct ITokenSaleProposal.PurchaseInfo    | the information about the user purchase |
| vestingUserInfo | struct ITokenSaleProposal.VestingUserInfo | the information about the user vesting  |

### UserView

```solidity
struct UserView {
	bool canParticipate;
	ITokenSaleProposal.PurchaseView purchaseView;
	ITokenSaleProposal.VestingUserView vestingUserView;
}
```

User parameters. This struct is used in view functions as a return argument

Parameters:

| Name            | Type                                      | Description                                                                      |
| --------------- | ----------------------------------------- | -------------------------------------------------------------------------------- |
| canParticipate  | bool                                      | the boolean indicating whether the user is whitelisted in the corresponding tier |
| purchaseView    | struct ITokenSaleProposal.PurchaseView    | the information about the user purchase                                          |
| vestingUserView | struct ITokenSaleProposal.VestingUserView | the information about the user vesting                                           |

### Tier

```solidity
struct Tier {
	ITokenSaleProposal.TierInitParams tierInitParams;
	ITokenSaleProposal.TierInfo tierInfo;
	ITokenSaleProposal.ParticipationInfo participationInfo;
	mapping(address => uint256) rates;
	mapping(address => ITokenSaleProposal.UserInfo) users;
}
```

Tier parameters

Parameters:

| Name              | Type                                                   | Description                                            |
| ----------------- | ------------------------------------------------------ | ------------------------------------------------------ |
| tierInitParams    | struct ITokenSaleProposal.TierInitParams               | the initial tier parameters                            |
| tierInfo          | struct ITokenSaleProposal.TierInfo                     | the information about the tier                         |
| participationInfo | struct ITokenSaleProposal.ParticipationInfo            | the information about participation requirements       |
| rates             | mapping(address => uint256)                            | the mapping of token addresses to their exchange rates |
| users             | mapping(address => struct ITokenSaleProposal.UserInfo) | the mapping of user addresses to their infos           |

### TierView

```solidity
struct TierView {
	ITokenSaleProposal.TierInitParams tierInitParams;
	ITokenSaleProposal.TierInfo tierInfo;
}
```

Tier parameters. This struct is used in view functions as a return argument

Parameters:

| Name           | Type                                     | Description                    |
| -------------- | ---------------------------------------- | ------------------------------ |
| tierInitParams | struct ITokenSaleProposal.TierInitParams | the initial tier parameters    |
| tierInfo       | struct ITokenSaleProposal.TierInfo       | the information about the tier |

### WhitelistingRequest

```solidity
struct WhitelistingRequest {
	uint256 tierId;
	address[] users;
	string uri;
}
```

Whitelisting request parameters. This struct is used as an input parameter to the whitelist update function

Parameters:

| Name   | Type       | Description                             |
| ------ | ---------- | --------------------------------------- |
| tierId | uint256    | the id of the tier                      |
| users  | address\[] | the list of the users to be whitelisted |
| uri    | string     | tokens metadata uri                     |

## Functions info

### latestTierId (0x83d36375)

```solidity
function latestTierId() external view returns (uint256)
```

This function is used to get id (index) of the latest tier of the token sale

Return values:

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| \[0] | uint256 | the id of the latest tier |

### createTiers (0x6a6effda)

```solidity
function createTiers(
    ITokenSaleProposal.TierInitParams[] calldata tiers
) external
```

This function is used for tiers creation

Parameters:

| Name  | Type                                        | Description         |
| ----- | ------------------------------------------- | ------------------- |
| tiers | struct ITokenSaleProposal.TierInitParams\[] | parameters of tiers |

### addToWhitelist (0xce6c2d91)

```solidity
function addToWhitelist(
    ITokenSaleProposal.WhitelistingRequest[] calldata requests
) external
```

This function is used to add users to the whitelist of tier

Parameters:

| Name     | Type                                             | Description                                |
| -------- | ------------------------------------------------ | ------------------------------------------ |
| requests | struct ITokenSaleProposal.WhitelistingRequest\[] | requests for adding users to the whitelist |

### offTiers (0x20274396)

```solidity
function offTiers(uint256[] calldata tierIds) external
```

This function is used to set given tiers inactive

Parameters:

| Name    | Type       | Description              |
| ------- | ---------- | ------------------------ |
| tierIds | uint256\[] | tier ids to set inactive |

### recover (0xc59b695a)

```solidity
function recover(uint256[] calldata tierIds) external
```

This function is used to return to the DAO treasury tokens that have not been purchased during sale

Parameters:

| Name    | Type       | Description              |
| ------- | ---------- | ------------------------ |
| tierIds | uint256\[] | tier ids to recover from |

### claim (0x6ba4c138)

```solidity
function claim(uint256[] calldata tierIds) external
```

This function is used to withdraw non-vesting tokens from given tiers

Parameters:

| Name    | Type       | Description                       |
| ------- | ---------- | --------------------------------- |
| tierIds | uint256\[] | tier ids to make withdrawals from |

### vestingWithdraw (0xe2bdc496)

```solidity
function vestingWithdraw(uint256[] calldata tierIds) external
```

This function is used to withdraw vesting tokens from given tiers

Parameters:

| Name    | Type       | Description                       |
| ------- | ---------- | --------------------------------- |
| tierIds | uint256\[] | tier ids to make withdrawals from |

### buy (0x2afaca20)

```solidity
function buy(
    uint256 tierId,
    address tokenToBuyWith,
    uint256 amount
) external payable
```

This function is used to purchase tokens in the given tier

Parameters:

| Name           | Type    | Description                                                                 |
| -------------- | ------- | --------------------------------------------------------------------------- |
| tierId         | uint256 | the id of the tier where tokens will be purchased                           |
| tokenToBuyWith | address | the token that will be used (exchanged) to purchase token on the token sale |
| amount         | uint256 | the amount of the token to be used for this exchange                        |

### lockParticipationTokens (0x66813a3b)

```solidity
function lockParticipationTokens(
    uint256 tierId,
    address tokenToLock,
    uint256 amountToLock
) external payable
```

This function is used to lock the specified amount of tokens to participate in the given tier

Parameters:

| Name         | Type    | Description                               |
| ------------ | ------- | ----------------------------------------- |
| tierId       | uint256 | the id of the tier to lock the tokens for |
| tokenToLock  | address | the address of the token to be locked     |
| amountToLock | uint256 | the number of tokens to be locked         |

### lockParticipationNft (0x1ec3f9b7)

```solidity
function lockParticipationNft(
    uint256 tierId,
    address nftToLock,
    uint256[] calldata nftIdsToLock
) external
```

This function is used to lock the specified nft to participate in the given tier

Parameters:

| Name         | Type       | Description                            |
| ------------ | ---------- | -------------------------------------- |
| tierId       | uint256    | the id of the tier to lock the nft for |
| nftToLock    | address    | the address of nft to be locked        |
| nftIdsToLock | uint256\[] | the list of nft ids to be locked       |

### unlockParticipationTokens (0x78ee27d7)

```solidity
function unlockParticipationTokens(
    uint256 tierId,
    address tokenToUnlock,
    uint256 amountToUnlock
) external
```

This function is used to unlock participation tokens

Parameters:

| Name           | Type    | Description                                 |
| -------------- | ------- | ------------------------------------------- |
| tierId         | uint256 | the id of the tier to unlock the tokens for |
| tokenToUnlock  | address | the address of the token to be unlocked     |
| amountToUnlock | uint256 | the number of tokens to be unlocked         |

### unlockParticipationNft (0x9471f309)

```solidity
function unlockParticipationNft(
    uint256 tierId,
    address nftToUnlock,
    uint256[] calldata nftIdsToUnlock
) external
```

This function is used to unlock the participation nft

Parameters:

| Name           | Type       | Description                              |
| -------------- | ---------- | ---------------------------------------- |
| tierId         | uint256    | the id of the tier to unlock the nft for |
| nftToUnlock    | address    | the address of nft to be unlocked        |
| nftIdsToUnlock | uint256\[] | the list of nft ids to be unlocked       |

### getSaleTokenAmount (0xceded63c)

```solidity
function getSaleTokenAmount(
    address user,
    uint256 tierId,
    address tokenToBuyWith,
    uint256 amount
) external view returns (uint256)
```

This function is used to get amount of `TokenSaleProposal` tokens that can be purchased

Parameters:

| Name           | Type    | Description                                      |
| -------------- | ------- | ------------------------------------------------ |
| user           | address | the address of the user that purchases tokens    |
| tierId         | uint256 | the id of the tier in which tokens are purchased |
| tokenToBuyWith | address | the token which is used for exchange             |
| amount         | uint256 | the token amount used for exchange               |

Return values:

| Name | Type    | Description                |
| ---- | ------- | -------------------------- |
| \[0] | uint256 | expected sale token amount |

### getClaimAmounts (0xd6e93fb2)

```solidity
function getClaimAmounts(
    address user,
    uint256[] calldata tierIds
) external view returns (uint256[] memory claimAmounts)
```

This function is used to get information about the amount of non-vesting tokens that user can withdraw (that are unlocked) from given tiers

Parameters:

| Name    | Type       | Description             |
| ------- | ---------- | ----------------------- |
| user    | address    | the address of the user |
| tierIds | uint256\[] | the array of tier ids   |

Return values:

| Name         | Type       | Description                                                     |
| ------------ | ---------- | --------------------------------------------------------------- |
| claimAmounts | uint256\[] | the array of token amounts that can be withdrawn from each tier |

### getVestingWithdrawAmounts (0x47d436f7)

```solidity
function getVestingWithdrawAmounts(
    address user,
    uint256[] calldata tierIds
) external view returns (uint256[] memory vestingWithdrawAmounts)
```

This function is used to get information about the amount of vesting tokens that user can withdraw (that are unlocked) from given tiers

Parameters:

| Name    | Type       | Description             |
| ------- | ---------- | ----------------------- |
| user    | address    | the address of the user |
| tierIds | uint256\[] | the array of tier ids   |

Return values:

| Name                   | Type       | Description                                                     |
| ---------------------- | ---------- | --------------------------------------------------------------- |
| vestingWithdrawAmounts | uint256\[] | the array of token amounts that can be withdrawn from each tier |

### getRecoverAmounts (0x69bc02d5)

```solidity
function getRecoverAmounts(
    uint256[] calldata tierIds
) external view returns (uint256[] memory recoveringAmounts)
```

This function is used to get amount of tokens that have not been purchased during sale in given tiers and can be returned to DAO treasury

Parameters:

| Name    | Type       | Description           |
| ------- | ---------- | --------------------- |
| tierIds | uint256\[] | the array of tier ids |

Return values:

| Name              | Type       | Description                                                                  |
| ----------------- | ---------- | ---------------------------------------------------------------------------- |
| recoveringAmounts | uint256\[] | the array of token amounts that can be returned to DAO treasury in each tier |

### getTierViews (0x884ce0bd)

```solidity
function getTierViews(
    uint256 offset,
    uint256 limit
) external view returns (ITokenSaleProposal.TierView[] memory tierViews)
```

This function is used to get a list of tiers

Parameters:

| Name   | Type    | Description                                  |
| ------ | ------- | -------------------------------------------- |
| offset | uint256 | the offset of the list                       |
| limit  | uint256 | the limit for amount of elements in the list |

Return values:

| Name      | Type                                  | Description            |
| --------- | ------------------------------------- | ---------------------- |
| tierViews | struct ITokenSaleProposal.TierView\[] | the list of tier views |

### getUserViews (0xb27f37a2)

```solidity
function getUserViews(
    address user,
    uint256[] calldata tierIds
) external view returns (ITokenSaleProposal.UserView[] memory userViews)
```

This function is used to get user's infos from tiers

Parameters:

| Name    | Type       | Description                                      |
| ------- | ---------- | ------------------------------------------------ |
| user    | address    | the address of the user whose infos are required |
| tierIds | uint256\[] | the list of tier ids to get infos from           |

Return values:

| Name      | Type                                  | Description            |
| --------- | ------------------------------------- | ---------------------- |
| userViews | struct ITokenSaleProposal.UserView\[] | the list of user views |


# settings


# IGovSettings

## Interface Description

License: MIT

##

```solidity
interface IGovSettings
```

This is the contract that stores proposal settings that will be used by the governance pool

## Enums info

### ExecutorType

```solidity
enum ExecutorType {
	 DEFAULT,
	 INTERNAL,
	 VALIDATORS
}
```

## Structs info

### ProposalSettings

```solidity
struct ProposalSettings {
	bool earlyCompletion;
	bool delegatedVotingAllowed;
	bool validatorsVote;
	uint64 duration;
	uint64 durationValidators;
	uint64 executionDelay;
	uint128 quorum;
	uint128 quorumValidators;
	uint256 minVotesForVoting;
	uint256 minVotesForCreating;
	IGovSettings.RewardsInfo rewardsInfo;
	string executorDescription;
}
```

The struct holds information about settings for proposal type

Parameters:

| Name                   | Type                            | Description                                                                                                     |
| ---------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| earlyCompletion        | bool                            | the boolean flag, if true the voting completes as soon as the quorum is reached                                 |
| delegatedVotingAllowed | bool                            | the boolean flag, if true then delegators can vote with their own delegated tokens, else micropool vote allowed |
| validatorsVote         | bool                            | the boolean flag, if true then voting will have an additional validators step                                   |
| duration               | uint64                          | the duration of voting in seconds                                                                               |
| durationValidators     | uint64                          | the duration of validators voting in seconds                                                                    |
| executionDelay         | uint64                          | the delay in seconds before the proposal can be executed                                                        |
| quorum                 | uint128                         | the percentage of total votes supply (erc20 + nft) to confirm the proposal                                      |
| quorumValidators       | uint128                         | the percentage of total validator token supply to confirm the proposal                                          |
| minVotesForVoting      | uint256                         | the minimal needed voting power to vote for the proposal                                                        |
| minVotesForCreating    | uint256                         | the minimal needed voting power to create the proposal                                                          |
| rewardsInfo            | struct IGovSettings.RewardsInfo | the reward info for proposal creation and execution                                                             |
| executorDescription    | string                          | the settings description string                                                                                 |

### RewardsInfo

```solidity
struct RewardsInfo {
	address rewardToken;
	uint256 creationReward;
	uint256 executionReward;
	uint256 voteRewardsCoefficient;
}
```

The struct holds information about rewards for proposals

Parameters:

| Name                   | Type    | Description                                       |
| ---------------------- | ------- | ------------------------------------------------- |
| rewardToken            | address | the reward token address                          |
| creationReward         | uint256 | the amount of reward for proposal creation        |
| executionReward        | uint256 | the amount of reward for proposal execution       |
| voteRewardsCoefficient | uint256 | the reward multiplier for voting for the proposal |

## Functions info

### executorToSettings (0x793e1468)

```solidity
function executorToSettings(address executor) external view returns (uint256)
```

The function to get settings of this executor

Parameters:

| Name     | Type    | Description  |
| -------- | ------- | ------------ |
| executor | address | the executor |

Return values:

| Name | Type    | Description                |
| ---- | ------- | -------------------------- |
| \[0] | uint256 | setting id of the executor |

### addSettings (0x6a11e769)

```solidity
function addSettings(
    IGovSettings.ProposalSettings[] calldata _settings
) external
```

Add new types to contract

Parameters:

| Name       | Type                                    | Description  |
| ---------- | --------------------------------------- | ------------ |
| \_settings | struct IGovSettings.ProposalSettings\[] | New settings |

### editSettings (0x2d141cdd)

```solidity
function editSettings(
    uint256[] calldata settingsIds,
    IGovSettings.ProposalSettings[] calldata _settings
) external
```

Edit existed type

Parameters:

| Name        | Type                                    | Description          |
| ----------- | --------------------------------------- | -------------------- |
| settingsIds | uint256\[]                              | Existed settings IDs |
| \_settings  | struct IGovSettings.ProposalSettings\[] | New settings         |

### changeExecutors (0xf7e1ef01)

```solidity
function changeExecutors(
    address[] calldata executors,
    uint256[] calldata settingsIds
) external
```

Change executors association

Parameters:

| Name        | Type       | Description |
| ----------- | ---------- | ----------- |
| executors   | address\[] | Addresses   |
| settingsIds | uint256\[] | New types   |

### getDefaultSettings (0x00d04976)

```solidity
function getDefaultSettings()
    external
    view
    returns (IGovSettings.ProposalSettings memory)
```

The function to get default settings

Return values:

| Name | Type                                 | Description     |
| ---- | ------------------------------------ | --------------- |
| \[0] | struct IGovSettings.ProposalSettings | default setting |

### getInternalSettings (0x79dcff40)

```solidity
function getInternalSettings()
    external
    view
    returns (IGovSettings.ProposalSettings memory)
```

The function to get internal settings

Return values:

| Name | Type                                 | Description      |
| ---- | ------------------------------------ | ---------------- |
| \[0] | struct IGovSettings.ProposalSettings | internal setting |

### getExecutorSettings (0x57404769)

```solidity
function getExecutorSettings(
    address executor
) external view returns (IGovSettings.ProposalSettings memory)
```

The function the get the settings of the executor

Parameters:

| Name     | Type    | Description      |
| -------- | ------- | ---------------- |
| executor | address | Executor address |

Return values:

| Name | Type                                 | Description                              |
| ---- | ------------------------------------ | ---------------------------------------- |
| \[0] | struct IGovSettings.ProposalSettings | `ProposalSettings` by `executor` address |


# user-keeper


# IGovUserKeeper

## Interface Description

License: MIT

##

```solidity
interface IGovUserKeeper
```

This contract is responsible for securely storing user's funds that are used during the voting. These are either ERC20 tokens or NFTs

## Structs info

### BalanceInfo

```solidity
struct BalanceInfo {
	uint256 tokens;
	EnumerableSet.UintSet nfts;
}
```

The struct holds information about user deposited tokens

Parameters:

| Name   | Type                         | Description                    |
| ------ | ---------------------------- | ------------------------------ |
| tokens | uint256                      | the amount of deposited tokens |
| nfts   | struct EnumerableSet.UintSet | the array of deposited nfts    |

### UserInfo

```solidity
struct UserInfo {
	mapping(IGovPool.VoteType => struct IGovUserKeeper.BalanceInfo) balances;
	mapping(IGovPool.VoteType => uint256) nftsPowers;
	mapping(address => IGovUserKeeper.BalanceInfo) delegatedBalances;
	mapping(address => uint256) delegatedNftPowers;
	IGovUserKeeper.BalanceInfo allDelegatedBalance;
	EnumerableSet.AddressSet delegatees;
	uint256 maxTokensLocked;
	mapping(uint256 => uint256) lockedInProposals;
}
```

The struct holds information about user balances

Parameters:

| Name                | Type                                                                 | Description                                        |
| ------------------- | -------------------------------------------------------------------- | -------------------------------------------------- |
| balances            | mapping(enum IGovPool.VoteType => struct IGovUserKeeper.BalanceInfo) | matching vote types with balance infos             |
| nftsPowers          | mapping(enum IGovPool.VoteType => uint256)                           | matching vote types with cached nfts powers        |
| delegatedBalances   | mapping(address => struct IGovUserKeeper.BalanceInfo)                | matching delegatees with balances infos            |
| delegatedNftPowers  | mapping(address => uint256)                                          | matching delegatees with delegated nft powers      |
| allDelegatedBalance | struct IGovUserKeeper.BalanceInfo                                    | the balance info of all delegated assets           |
| delegatees          | struct EnumerableSet.AddressSet                                      | the array of delegatees                            |
| maxTokensLocked     | uint256                                                              | the upper bound of currently locked tokens         |
| lockedInProposals   | mapping(uint256 => uint256)                                          | the amount of deposited tokens locked in proposals |

### NFTInfo

```solidity
struct NFTInfo {
	address nftAddress;
	bool isSupportPower;
	uint256 individualPower;
	uint256 totalSupply;
	mapping(uint256 => uint256) nftMinPower;
}
```

The struct holds information about nft contract

Parameters:

| Name            | Type                        | Description                                            |
| --------------- | --------------------------- | ------------------------------------------------------ |
| nftAddress      | address                     | the address of the nft                                 |
| isSupportPower  | bool                        | boolean flag, if true then nft contract supports power |
| individualPower | uint256                     | the voting power an nft                                |
| totalSupply     | uint256                     | the total supply of nfts that are not enumerable       |
| nftMinPower     | mapping(uint256 => uint256) | matching nft ids to their minimal powers               |

### VotingPowerView

```solidity
struct VotingPowerView {
	uint256 power;
	uint256 rawPower;
	uint256 nftPower;
	uint256 rawNftPower;
	uint256[] perNftPower;
	uint256 ownedBalance;
	uint256 ownedLength;
	uint256[] nftIds;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name         | Type       | Description                                             |
| ------------ | ---------- | ------------------------------------------------------- |
| power        | uint256    | the total vote power of a user                          |
| rawPower     | uint256    | the total deposited assets power of a user              |
| nftPower     | uint256    | the total nft power of a user                           |
| rawNftPower  | uint256    | the total deposited nft power of a user                 |
| perNftPower  | uint256\[] | the power of every nft, bounded by index with nftIds    |
| ownedBalance | uint256    | the owned erc20 balance, decimals = 18                  |
| ownedLength  | uint256    | the amount of owned nfts                                |
| nftIds       | uint256\[] | the array of nft ids, bounded by index with perNftPower |

### DelegationInfoView

```solidity
struct DelegationInfoView {
	address delegatee;
	uint256 delegatedTokens;
	uint256[] delegatedNfts;
	uint256 nftPower;
	uint256[] perNftPower;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name            | Type       | Description                                                    |
| --------------- | ---------- | -------------------------------------------------------------- |
| delegatee       | address    | the address of delegatee (person who gets delegation)          |
| delegatedTokens | uint256    | the amount of delegated tokens                                 |
| delegatedNfts   | uint256\[] | the array of delegated nfts, bounded by index with perNftPower |
| nftPower        | uint256    | the total power of delegated nfts                              |
| perNftPower     | uint256\[] | the array of nft power, bounded by index with delegatedNfts    |

## Functions info

### depositTokens (0x39dc5ef2)

```solidity
function depositTokens(
    address payer,
    address receiver,
    uint256 amount
) external
```

The function for depositing tokens

Parameters:

| Name     | Type    | Description                  |
| -------- | ------- | ---------------------------- |
| payer    | address | the address of depositor     |
| receiver | address | the deposit receiver address |
| amount   | uint256 | the erc20 deposit amount     |

### withdrawTokens (0x5e35359e)

```solidity
function withdrawTokens(
    address payer,
    address receiver,
    uint256 amount
) external
```

The function for withdrawing tokens

Parameters:

| Name     | Type    | Description                                  |
| -------- | ------- | -------------------------------------------- |
| payer    | address | the address from whom to withdraw the tokens |
| receiver | address | the withdrawal receiver address              |
| amount   | uint256 | the erc20 withdrawal amount                  |

### delegateTokens (0x9161babb)

```solidity
function delegateTokens(
    address delegator,
    address delegatee,
    uint256 amount
) external
```

The function for delegating tokens

Parameters:

| Name      | Type    | Description                 |
| --------- | ------- | --------------------------- |
| delegator | address | the address of delegator    |
| delegatee | address | the address of delegatee    |
| amount    | uint256 | the erc20 delegation amount |

### delegateTokensTreasury (0x69b5330b)

```solidity
function delegateTokensTreasury(address delegatee, uint256 amount) external
```

The function for delegating tokens from Treasury

Parameters:

| Name      | Type    | Description                 |
| --------- | ------- | --------------------------- |
| delegatee | address | the address of delegatee    |
| amount    | uint256 | the erc20 delegation amount |

### undelegateTokens (0x0ae1398e)

```solidity
function undelegateTokens(
    address delegator,
    address delegatee,
    uint256 amount
) external
```

The function for undelegating tokens

Parameters:

| Name      | Type    | Description                   |
| --------- | ------- | ----------------------------- |
| delegator | address | the address of delegator      |
| delegatee | address | the address of delegatee      |
| amount    | uint256 | the erc20 undelegation amount |

### undelegateTokensTreasury (0x86be8d2d)

```solidity
function undelegateTokensTreasury(address delegatee, uint256 amount) external
```

The function for undelegating tokens from Treasury

Parameters:

| Name      | Type    | Description                   |
| --------- | ------- | ----------------------------- |
| delegatee | address | the address of delegatee      |
| amount    | uint256 | the erc20 undelegation amount |

### depositNfts (0x9693caad)

```solidity
function depositNfts(
    address payer,
    address receiver,
    uint256[] calldata nftIds
) external
```

The function for depositing nfts

Parameters:

| Name     | Type       | Description                    |
| -------- | ---------- | ------------------------------ |
| payer    | address    | the address of depositor       |
| receiver | address    | the deposit receiver address   |
| nftIds   | uint256\[] | the array of deposited nft ids |

### withdrawNfts (0x1f96f376)

```solidity
function withdrawNfts(
    address payer,
    address receiver,
    uint256[] calldata nftIds
) external
```

The function for withdrawing nfts

Parameters:

| Name     | Type       | Description                                |
| -------- | ---------- | ------------------------------------------ |
| payer    | address    | the address from whom to withdraw the nfts |
| receiver | address    | the withdrawal receiver address            |
| nftIds   | uint256\[] | the withdrawal nft ids                     |

### delegateNfts (0xbfb1a57d)

```solidity
function delegateNfts(
    address delegator,
    address delegatee,
    uint256[] calldata nftIds
) external
```

The function for delegating nfts

Parameters:

| Name      | Type       | Description                    |
| --------- | ---------- | ------------------------------ |
| delegator | address    | the address of delegator       |
| delegatee | address    | the address of delegatee       |
| nftIds    | uint256\[] | the array of delegated nft ids |

### delegateNftsTreasury (0x6ad6d3c1)

```solidity
function delegateNftsTreasury(
    address delegatee,
    uint256[] calldata nftIds
) external
```

The function for delegating nfts from Treasury

Parameters:

| Name      | Type       | Description                    |
| --------- | ---------- | ------------------------------ |
| delegatee | address    | the address of delegatee       |
| nftIds    | uint256\[] | the array of delegated nft ids |

### undelegateNfts (0x37267d4c)

```solidity
function undelegateNfts(
    address delegator,
    address delegatee,
    uint256[] calldata nftIds
) external
```

The function for undelegating nfts

Parameters:

| Name      | Type       | Description                      |
| --------- | ---------- | -------------------------------- |
| delegator | address    | the address of delegator         |
| delegatee | address    | the address of delegatee         |
| nftIds    | uint256\[] | the array of undelegated nft ids |

### undelegateNftsTreasury (0x39be038b)

```solidity
function undelegateNftsTreasury(
    address delegatee,
    uint256[] calldata nftIds
) external
```

The function for undelegating nfts from Treasury

Parameters:

| Name      | Type       | Description                      |
| --------- | ---------- | -------------------------------- |
| delegatee | address    | the address of delegatee         |
| nftIds    | uint256\[] | the array of undelegated nft ids |

### updateMaxTokenLockedAmount (0x5f884296)

```solidity
function updateMaxTokenLockedAmount(
    uint256[] calldata lockedProposals,
    address voter
) external
```

The function for recalculating max token locked amount of a user

Parameters:

| Name            | Type       | Description                                 |
| --------------- | ---------- | ------------------------------------------- |
| lockedProposals | uint256\[] | the array of proposal ids for recalculation |
| voter           | address    | the address of voter                        |

### lockTokens (0x154b3db0)

```solidity
function lockTokens(uint256 proposalId, address voter, uint256 amount) external
```

The function for locking tokens in a proposal

Parameters:

| Name       | Type    | Description                  |
| ---------- | ------- | ---------------------------- |
| proposalId | uint256 | the id of proposal           |
| voter      | address | the address of voter         |
| amount     | uint256 | the amount of tokens to lock |

### unlockTokens (0x7fde4424)

```solidity
function unlockTokens(uint256 proposalId, address voter) external
```

The function for unlocking tokens in proposal

Parameters:

| Name       | Type    | Description          |
| ---------- | ------- | -------------------- |
| proposalId | uint256 | the id of proposal   |
| voter      | address | the address of voter |

### lockNfts (0x3b389164)

```solidity
function lockNfts(
    address voter,
    IGovPool.VoteType voteType,
    uint256[] calldata nftIds
) external
```

The function for locking nfts

Parameters:

| Name     | Type                   | Description                  |
| -------- | ---------------------- | ---------------------------- |
| voter    | address                | the address of voter         |
| voteType | enum IGovPool.VoteType | the type of vote             |
| nftIds   | uint256\[]             | the array of nft ids to lock |

### unlockNfts (0x7be49fe3)

```solidity
function unlockNfts(uint256[] calldata nftIds) external
```

The function for unlocking nfts

Parameters:

| Name   | Type       | Description                    |
| ------ | ---------- | ------------------------------ |
| nftIds | uint256\[] | the array of nft ids to unlock |

### updateNftPowers (0x30132f5e)

```solidity
function updateNftPowers(uint256[] calldata nftIds) external
```

The function for recalculating power of nfts

Parameters:

| Name   | Type       | Description                                       |
| ------ | ---------- | ------------------------------------------------- |
| nftIds | uint256\[] | the array of nft ids to recalculate the power for |

### setERC20Address (0x41bec0d2)

```solidity
function setERC20Address(address _tokenAddress) external
```

The function for setting erc20 address

Parameters:

| Name           | Type    | Description       |
| -------------- | ------- | ----------------- |
| \_tokenAddress | address | the erc20 address |

### setERC721Address (0x37e5e863)

```solidity
function setERC721Address(
    address _nftAddress,
    uint256 individualPower,
    uint256 nftsTotalSupply
) external
```

The function for setting erc721 address

Parameters:

| Name            | Type    | Description                      |
| --------------- | ------- | -------------------------------- |
| \_nftAddress    | address | the erc721 address               |
| individualPower | uint256 | the voting power of an nft       |
| nftsTotalSupply | uint256 | the total supply of nft contract |

### tokenAddress (0x9d76ea58)

```solidity
function tokenAddress() external view returns (address)
```

The function for getting erc20 address

Return values:

| Name | Type    | Description                      |
| ---- | ------- | -------------------------------- |
| \[0] | address | `tokenAddress` the erc20 address |

### nftAddress (0x5bf8633a)

```solidity
function nftAddress() external view returns (address)
```

The function for getting erc721 address

Return values:

| Name | Type    | Description                     |
| ---- | ------- | ------------------------------- |
| \[0] | address | `nftAddress` the erc721 address |

### getNftInfo (0x7ca5685f)

```solidity
function getNftInfo()
    external
    view
    returns (bool isSupportPower, uint256 individualPower, uint256 totalSupply)
```

The function for getting nft info

Return values:

| Name            | Type    | Description                                            |
| --------------- | ------- | ------------------------------------------------------ |
| isSupportPower  | bool    | boolean flag, if true then nft contract supports power |
| individualPower | uint256 | the voting power an nft                                |
| totalSupply     | uint256 | the total supply of nfts that are not enumerable       |

### maxLockedAmount (0x3b3707a3)

```solidity
function maxLockedAmount(address voter) external view returns (uint256)
```

The function for getting max locked amount of a user

Parameters:

| Name  | Type    | Description          |
| ----- | ------- | -------------------- |
| voter | address | the address of voter |

Return values:

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| \[0] | uint256 | `max locked amount` |

### tokenBalance (0xe94e3c67)

```solidity
function tokenBalance(
    address voter,
    IGovPool.VoteType voteType
) external view returns (uint256 balance, uint256 ownedBalance)
```

The function for getting token balance of a user

Parameters:

| Name     | Type                   | Description          |
| -------- | ---------------------- | -------------------- |
| voter    | address                | the address of voter |
| voteType | enum IGovPool.VoteType | the type of vote     |

Return values:

| Name         | Type    | Description                                            |
| ------------ | ------- | ------------------------------------------------------ |
| balance      | uint256 | the total balance with delegations                     |
| ownedBalance | uint256 | the user balance that is not deposited to the contract |

### nftBalance (0x26836340)

```solidity
function nftBalance(
    address voter,
    IGovPool.VoteType voteType
) external view returns (uint256 balance, uint256 ownedBalance)
```

The function for getting nft balance of a user

Parameters:

| Name     | Type                   | Description          |
| -------- | ---------------------- | -------------------- |
| voter    | address                | the address of voter |
| voteType | enum IGovPool.VoteType | the type of vote     |

Return values:

| Name         | Type    | Description                                               |
| ------------ | ------- | --------------------------------------------------------- |
| balance      | uint256 | the total balance with delegations                        |
| ownedBalance | uint256 | the number of nfts that are not deposited to the contract |

### nftExactBalance (0x3bea071d)

```solidity
function nftExactBalance(
    address voter,
    IGovPool.VoteType voteType
) external view returns (uint256[] memory nfts, uint256 ownedLength)
```

The function for getting nft ids of a user

Parameters:

| Name     | Type                   | Description          |
| -------- | ---------------------- | -------------------- |
| voter    | address                | the address of voter |
| voteType | enum IGovPool.VoteType | the type of vote     |

Return values:

| Name        | Type       | Description                                               |
| ----------- | ---------- | --------------------------------------------------------- |
| nfts        | uint256\[] | the array of owned nft ids                                |
| ownedLength | uint256    | the number of nfts that are not deposited to the contract |

### getTotalNftsPower (0x4a5f293c)

```solidity
function getTotalNftsPower(
    uint256[] memory nftIds,
    IGovPool.VoteType voteType,
    address voter,
    bool perNftPowerArray
) external view returns (uint256 nftPower, uint256[] memory perNftPower)
```

The function for getting total power of nfts by ids

Parameters:

| Name             | Type                   | Description                                 |
| ---------------- | ---------------------- | ------------------------------------------- |
| nftIds           | uint256\[]             | the array of nft ids                        |
| voteType         | enum IGovPool.VoteType | the type of vote                            |
| voter            | address                | the address of user                         |
| perNftPowerArray | bool                   | should the nft raw powers array be returned |

Return values:

| Name        | Type       | Description                                           |
| ----------- | ---------- | ----------------------------------------------------- |
| nftPower    | uint256    | the total total power of nfts                         |
| perNftPower | uint256\[] | the array of nft powers, bounded with nftIds by index |

### getTotalPower (0x53976a26)

```solidity
function getTotalPower() external view returns (uint256 power)
```

The function for getting total voting power of the contract

Return values:

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| power | uint256 | total power |

### canCreate (0x6f123e76)

```solidity
function canCreate(
    address voter,
    IGovPool.VoteType voteType,
    uint256 requiredVotes
) external view returns (bool)
```

The function to define if voter is able to create a proposal. Includes micropool balance

Parameters:

| Name          | Type                   | Description               |
| ------------- | ---------------------- | ------------------------- |
| voter         | address                | the address of voter      |
| voteType      | enum IGovPool.VoteType | the type of vote          |
| requiredVotes | uint256                | the required voting power |

Return values:

| Name | Type | Description                                           |
| ---- | ---- | ----------------------------------------------------- |
| \[0] | bool | `true` - can participate, `false` - can't participate |

### votingPower (0xae987229)

```solidity
function votingPower(
    address[] calldata users,
    IGovPool.VoteType[] calldata voteTypes,
    bool perNftPowerArray
) external view returns (IGovUserKeeper.VotingPowerView[] memory votingPowers)
```

The function for getting voting power of users

Parameters:

| Name             | Type                      | Description                               |
| ---------------- | ------------------------- | ----------------------------------------- |
| users            | address\[]                | the array of users addresses              |
| voteTypes        | enum IGovPool.VoteType\[] | the array of vote types                   |
| perNftPowerArray | bool                      | should the nft powers array be calculated |

Return values:

| Name         | Type                                     | Description                          |
| ------------ | ---------------------------------------- | ------------------------------------ |
| votingPowers | struct IGovUserKeeper.VotingPowerView\[] | the array of VotingPowerView structs |

### transformedVotingPower (0x375b592e)

```solidity
function transformedVotingPower(
    address voter,
    uint256 amount,
    uint256[] calldata nftIds
) external view returns (uint256 personalPower, uint256 fullPower)
```

The function for getting voting power after the formula

Parameters:

| Name   | Type       | Description              |
| ------ | ---------- | ------------------------ |
| voter  | address    | the address of the voter |
| amount | uint256    | the amount of tokens     |
| nftIds | uint256\[] | the array of nft ids     |

Return values:

| Name          | Type    | Description                                                |
| ------------- | ------- | ---------------------------------------------------------- |
| personalPower | uint256 | the personal voting power after the formula                |
| fullPower     | uint256 | the personal plus delegated voting power after the formula |

### delegations (0x4d123d7e)

```solidity
function delegations(
    address user,
    bool perNftPowerArray
)
    external
    view
    returns (
        uint256 power,
        IGovUserKeeper.DelegationInfoView[] memory delegationsInfo
    )
```

The function for getting information about user's delegations

Parameters:

| Name             | Type    | Description                               |
| ---------------- | ------- | ----------------------------------------- |
| user             | address | the address of user                       |
| perNftPowerArray | bool    | should the nft powers array be calculated |

Return values:

| Name            | Type                                        | Description                             |
| --------------- | ------------------------------------------- | --------------------------------------- |
| power           | uint256                                     | the total delegated power               |
| delegationsInfo | struct IGovUserKeeper.DelegationInfoView\[] | the array of DelegationInfoView structs |

### getWithdrawableAssets (0x221c0fd6)

```solidity
function getWithdrawableAssets(
    address voter,
    uint256[] calldata lockedProposals,
    uint256[] calldata unlockedNfts
)
    external
    view
    returns (uint256 withdrawableTokens, uint256[] memory withdrawableNfts)
```

The function for getting information about funds that can be withdrawn

Parameters:

| Name            | Type       | Description                          |
| --------------- | ---------- | ------------------------------------ |
| voter           | address    | the address of voter                 |
| lockedProposals | uint256\[] | the array of ids of locked proposals |
| unlockedNfts    | uint256\[] | the array of unlocked nfts           |

Return values:

| Name               | Type       | Description                             |
| ------------------ | ---------- | --------------------------------------- |
| withdrawableTokens | uint256    | the tokens that can we withdrawn        |
| withdrawableNfts   | uint256\[] | the array of nfts that can we withdrawn |

### getDelegatedAssetsPower (0x8a3ca923)

```solidity
function getDelegatedAssetsPower(
    address delegator,
    address delegatee
) external view returns (uint256 delegatedPower)
```

The function for getting the total delegated power by the delegator and the delegatee

Parameters:

| Name      | Type    | Description                  |
| --------- | ------- | ---------------------------- |
| delegator | address | the address of the delegator |
| delegatee | address | the address of the delegatee |

Return values:

| Name           | Type    | Description               |
| -------------- | ------- | ------------------------- |
| delegatedPower | uint256 | the total delegated power |


# validators


# IGovValidators

## Interface Description

License: MIT

##

```solidity
interface IGovValidators
```

This is the voting contract that is queried on the proposal's second voting stage

## Enums info

### ProposalState

```solidity
enum ProposalState {
	 Voting,
	 Defeated,
	 Succeeded,
	 Locked,
	 Executed,
	 Undefined
}
```

### ProposalType

```solidity
enum ProposalType {
	 ChangeSettings,
	 ChangeBalances,
	 MonthlyWithdraw,
	 OffchainProposal
}
```

## Structs info

### ProposalSettings

```solidity
struct ProposalSettings {
	uint64 duration;
	uint64 executionDelay;
	uint128 quorum;
}
```

The struct holds information about settings for validators proposal

Parameters:

| Name           | Type    | Description                                                       |
| -------------- | ------- | ----------------------------------------------------------------- |
| duration       | uint64  | the duration of voting                                            |
| executionDelay | uint64  | the delay in seconds after voting end                             |
| quorum         | uint128 | the percentage of validators token supply to confirm the proposal |

### ProposalCore

```solidity
struct ProposalCore {
	bool executed;
	uint56 snapshotId;
	uint64 voteEnd;
	uint64 executeAfter;
	uint128 quorum;
	uint256 votesFor;
	uint256 votesAgainst;
}
```

The struct holds core properties of a proposal

Parameters:

| Name         | Type    | Description                                                             |
| ------------ | ------- | ----------------------------------------------------------------------- |
| executed     | bool    | the boolean flag that indicates whether the proposal is executed or not |
| snapshotId   | uint56  | the id of snapshot                                                      |
| voteEnd      | uint64  | the timestamp of voting end of the proposal                             |
| executeAfter | uint64  | the timestamp of execution in seconds after voting end                  |
| quorum       | uint128 | the percentage of validators token supply to confirm the proposal       |
| votesFor     | uint256 | the total number of votes in proposal from all voters                   |
| votesAgainst | uint256 | the total number of votes against proposal from all voters              |

### InternalProposal

```solidity
struct InternalProposal {
	IGovValidators.ProposalType proposalType;
	IGovValidators.ProposalCore core;
	string descriptionURL;
	bytes data;
}
```

The struct holds information about the internal proposal

Parameters:

| Name           | Type                               | Description                                                             |
| -------------- | ---------------------------------- | ----------------------------------------------------------------------- |
| proposalType   | enum IGovValidators.ProposalType   | the `ProposalType` enum                                                 |
| core           | struct IGovValidators.ProposalCore | the struct that holds information about core properties of the proposal |
| descriptionURL | string                             | the string with link to IPFS doc with proposal description              |
| data           | bytes                              | the data to be executed                                                 |

### ExternalProposal

```solidity
struct ExternalProposal {
	IGovValidators.ProposalCore core;
}
```

The struct holds information about the external proposal

Parameters:

| Name | Type                               | Description                                                           |
| ---- | ---------------------------------- | --------------------------------------------------------------------- |
| core | struct IGovValidators.ProposalCore | the struct that holds information about core properties of a proposal |

### InternalProposalView

```solidity
struct InternalProposalView {
	IGovValidators.InternalProposal proposal;
	IGovValidators.ProposalState proposalState;
	uint256 requiredQuorum;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name           | Type                                   | Description                                                       |
| -------------- | -------------------------------------- | ----------------------------------------------------------------- |
| proposal       | struct IGovValidators.InternalProposal | the `InternalProposal` struct                                     |
| proposalState  | enum IGovValidators.ProposalState      | the `ProposalState` enum                                          |
| requiredQuorum | uint256                                | the percentage of validators token supply to confirm the proposal |

## Functions info

### validatorsCount (0xed612f8c)

```solidity
function validatorsCount() external view returns (uint256)
```

The function for getting current number of validators

Return values:

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| \[0] | uint256 | `number` of validators |

### createInternalProposal (0x9661803d)

```solidity
function createInternalProposal(
    IGovValidators.ProposalType proposalType,
    string calldata descriptionURL,
    bytes calldata data
) external
```

Create internal proposal for changing validators balances, base quorum, base duration

Parameters:

| Name         | Type                             | Description                                                                                                                                                                                                              |
| ------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| proposalType | enum IGovValidators.ProposalType | `ProposalType` 0 - `ChangeInternalDurationAndQuorum`, change base duration and quorum 1 - `ChangeBalances`, change address balance 2 - `MonthlyWithdraw`, monthly token withdraw 3 - `OffchainProposal`, offchain action |
| data         | bytes                            | New packed data, depending on proposal type                                                                                                                                                                              |

### createExternalProposal (0xdc2a7714)

```solidity
function createExternalProposal(
    uint256 proposalId,
    IGovValidators.ProposalSettings calldata proposalSettings
) external
```

Create external proposal. This function can call only `Gov` contract

Parameters:

| Name             | Type                                   | Description                     |
| ---------------- | -------------------------------------- | ------------------------------- |
| proposalId       | uint256                                | Proposal ID from `Gov` contract |
| proposalSettings | struct IGovValidators.ProposalSettings | `ProposalSettings` struct       |

### voteInternalProposal (0x5a34c7e1)

```solidity
function voteInternalProposal(
    uint256 proposalId,
    uint256 amount,
    bool isVoteFor
) external
```

### voteExternalProposal (0xba877b80)

```solidity
function voteExternalProposal(
    uint256 proposalId,
    uint256 amount,
    bool isVoteFor
) external
```

### cancelVoteInternalProposal (0x5478197e)

```solidity
function cancelVoteInternalProposal(uint256 proposalId) external
```

### cancelVoteExternalProposal (0xea1941d0)

```solidity
function cancelVoteExternalProposal(uint256 proposalId) external
```

### executeInternalProposal (0x65f3f23f)

```solidity
function executeInternalProposal(uint256 proposalId) external
```

Only for internal proposals. External proposals should be executed from governance.

Parameters:

| Name       | Type    | Description          |
| ---------- | ------- | -------------------- |
| proposalId | uint256 | Internal proposal ID |

### executeExternalProposal (0x430c885a)

```solidity
function executeExternalProposal(uint256 proposalId) external
```

The function called by governance that marks the external proposal as executed

Parameters:

| Name       | Type    | Description          |
| ---------- | ------- | -------------------- |
| proposalId | uint256 | External proposal ID |

### changeSettings (0xb395fec0)

```solidity
function changeSettings(
    uint64 duration,
    uint64 executionDelay,
    uint128 quorum
) external
```

### changeBalances (0x62a4107d)

```solidity
function changeBalances(
    uint256[] calldata newValues,
    address[] calldata userAddresses
) external
```

The function for changing validators balances

Parameters:

| Name          | Type       | Description                    |
| ------------- | ---------- | ------------------------------ |
| newValues     | uint256\[] | the array of new balances      |
| userAddresses | address\[] | the array validators addresses |

### monthlyWithdraw (0x3271f009)

```solidity
function monthlyWithdraw(
    address[] calldata tokens,
    uint256[] calldata amounts,
    address destination
) external
```

### getExternalProposal (0xe14ea231)

```solidity
function getExternalProposal(
    uint256 index
) external view returns (IGovValidators.ExternalProposal memory)
```

The function for getting information about the external proposals

Parameters:

| Name  | Type    | Description           |
| ----- | ------- | --------------------- |
| index | uint256 | the index of proposal |

Return values:

| Name | Type                                   | Description               |
| ---- | -------------------------------------- | ------------------------- |
| \[0] | struct IGovValidators.ExternalProposal | `ExternalProposal` struct |

### getInternalProposals (0x8a847ae4)

```solidity
function getInternalProposals(
    uint256 offset,
    uint256 limit
) external view returns (IGovValidators.InternalProposalView[] memory)
```

The function for getting information about internal proposals

Parameters:

| Name   | Type    | Description                          |
| ------ | ------- | ------------------------------------ |
| offset | uint256 | the starting proposal index          |
| limit  | uint256 | the length of the observed proposals |

Return values:

| Name | Type                                          | Description                         |
| ---- | --------------------------------------------- | ----------------------------------- |
| \[0] | struct IGovValidators.InternalProposalView\[] | `InternalProposalView` struct array |

### getProposalState (0x7b839d93)

```solidity
function getProposalState(
    uint256 proposalId,
    bool isInternal
) external view returns (IGovValidators.ProposalState)
```

Return proposal state

Options: `Voting` - proposal where addresses can vote. `Defeated` - proposal where voting time is over and proposal defeated. `Succeeded` - proposal with the required number of votes. `Executed` - executed proposal (only for internal proposal). `Undefined` - nonexistent proposal.

### getProposalRequiredQuorum (0xbd7782fc)

```solidity
function getProposalRequiredQuorum(
    uint256 proposalId,
    bool isInternal
) external view returns (uint256)
```

The function for getting proposal required quorum

Parameters:

| Name       | Type    | Description                                         |
| ---------- | ------- | --------------------------------------------------- |
| proposalId | uint256 | the id of proposal                                  |
| isInternal | bool    | the boolean flag, if true then proposal is internal |

Return values:

| Name | Type    | Description                             |
| ---- | ------- | --------------------------------------- |
| \[0] | uint256 | the number of votes to reach the quorum |

### isValidator (0xfacd743b)

```solidity
function isValidator(address user) external view returns (bool)
```

The function that checks if a user is a validator

Parameters:

| Name | Type    | Description           |
| ---- | ------- | --------------------- |
| user | address | the address of a user |

Return values:

| Name | Type | Description                               |
| ---- | ---- | ----------------------------------------- |
| \[0] | bool | `flag`, if true, than user is a validator |


# IGovValidatorsToken

## Interface Description

License: MIT

##

```solidity
interface IGovValidatorsToken is IERC20
```

This is the contract that determines the validators

## Functions info

### mint (0x40c10f19)

```solidity
function mint(address account, uint256 amount) external
```

Mint new tokens, available only from `Validators` contract

Parameters:

| Name    | Type    | Description               |
| ------- | ------- | ------------------------- |
| account | address | Address                   |
| amount  | uint256 | Token amount to mint. Wei |

### burn (0x9dc29fac)

```solidity
function burn(address account, uint256 amount) external
```

Burn tokens, available only from `Validators` contract

Parameters:

| Name    | Type    | Description               |
| ------- | ------- | ------------------------- |
| account | address | Address                   |
| amount  | uint256 | Token amount to burn. Wei |

### snapshot (0x9711715a)

```solidity
function snapshot() external returns (uint256)
```

Create tokens snapshot

Return values:

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \[0] | uint256 | Snapshot ID |


# voting


# IVotePower

## Interface Description

License: MIT

##

```solidity
interface IVotePower
```

## Functions info

### transformVotes (0x41cb09cc)

```solidity
function transformVotes(
    address voter,
    uint256 votes
) external view returns (uint256 resultingVotes)
```

The function for transforming token and nft power to voting power

Parameters:

| Name  | Type    | Description                   |
| ----- | ------- | ----------------------------- |
| voter | address | the voter address             |
| votes | uint256 | the total token and nft power |

Return values:

| Name           | Type    | Description  |
| -------------- | ------- | ------------ |
| resultingVotes | uint256 | voting power |

### transformVotesFull (0x13f60dc5)

```solidity
function transformVotesFull(
    address voter,
    uint256 votes,
    uint256 personalPower,
    uint256 micropoolPower,
    uint256 treasuryPower
) external view returns (uint256 resultingVotes)
```

The function for transforming token and nft power to voting power

Parameters:

| Name           | Type    | Description                      |
| -------------- | ------- | -------------------------------- |
| voter          | address | the voter address                |
| votes          | uint256 | the total token and nft power    |
| personalPower  | uint256 | the user's total personal power  |
| micropoolPower | uint256 | the user's total micropool power |
| treasuryPower  | uint256 | the user's total treasury power  |

Return values:

| Name           | Type    | Description  |
| -------------- | ------- | ------------ |
| resultingVotes | uint256 | voting power |

### getVotesRatio (0xf5ca7490)

```solidity
function getVotesRatio(
    address voter
) external view returns (uint256 votesRatio)
```

The function for getting voting coefficient

Parameters:

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| voter | address | the address of the voter |

Return values:

| Name       | Type    | Description                           |
| ---------- | ------- | ------------------------------------- |
| votesRatio | uint256 | the ration with 25 decimals precision |


# IGovPool

## Interface Description

License: MIT

##

```solidity
interface IGovPool
```

This is the Governance pool contract. This contract is the third contract the user can deploy through the factory. The users can participate in proposal's creation, voting and execution processes

## Enums info

### ProposalState

```solidity
enum ProposalState {
	 Voting,
	 WaitingForVotingTransfer,
	 ValidatorVoting,
	 Defeated,
	 SucceededFor,
	 SucceededAgainst,
	 Locked,
	 ExecutedFor,
	 ExecutedAgainst,
	 Undefined
}
```

The enum that holds information about proposal state

Parameters:

| Name                     | Description                                                              |
| ------------------------ | ------------------------------------------------------------------------ |
| Voting                   | the proposal is in voting state                                          |
| WaitingForVotingTransfer | the proposal is approved and waiting for transfer to validators contract |
| ValidatorVoting          | the proposal is in validators voting state                               |
| Defeated                 | the proposal is defeated                                                 |
| SucceededFor             | the proposal is succeeded on for step                                    |
| SucceededAgainst         | the proposal is succeeded on against step                                |
| Locked                   | the proposal is locked                                                   |
| ExecutedFor              | the proposal is executed on for step                                     |
| ExecutedAgainst          | the proposal is executed on against step                                 |
| Undefined                | the proposal is undefined                                                |

### RewardType

```solidity
enum RewardType {
	 Create,
	 Vote,
	 Execute,
	 SaveOffchainResults
}
```

The enum that holds information about reward type

Parameters:

| Name                | Description                                  |
| ------------------- | -------------------------------------------- |
| Create              | the reward type for proposal creation        |
| Vote                | the reward type for voting for proposal      |
| Execute             | the reward type for proposal execution       |
| SaveOffchainResults | the reward type for saving off-chain results |

### VoteType

```solidity
enum VoteType {
	 PersonalVote,
	 MicropoolVote,
	 DelegatedVote,
	 TreasuryVote
}
```

The enum that holds information about vote type

Parameters:

| Name          | Description                        |
| ------------- | ---------------------------------- |
| PersonalVote  | the vote type for personal voting  |
| MicropoolVote | the vote type for micropool voting |
| DelegatedVote | the vote type for delegated voting |
| TreasuryVote  | the vote type for treasury voting  |

## Structs info

### Dependencies

```solidity
struct Dependencies {
	address settingsAddress;
	address userKeeperAddress;
	address payable validatorsAddress;
	address expertNftAddress;
	address nftMultiplierAddress;
	address votePowerAddress;
}
```

The struct that holds information about dependencies

Parameters:

| Name                 | Type            | Description                            |
| -------------------- | --------------- | -------------------------------------- |
| settingsAddress      | address         | the address of settings contract       |
| userKeeperAddress    | address         | the address of user keeper contract    |
| validatorsAddress    | address payable | the address of validators contract     |
| expertNftAddress     | address         | the address of expert nft contract     |
| nftMultiplierAddress | address         | the address of nft multiplier contract |
| votePowerAddress     | address         | the address of vote power contract     |

### ProposalCore

```solidity
struct ProposalCore {
	IGovSettings.ProposalSettings settings;
	uint64 voteEnd;
	uint64 executeAfter;
	bool executed;
	uint256 votesFor;
	uint256 votesAgainst;
	uint256 rawVotesFor;
	uint256 rawVotesAgainst;
	uint256 givenRewards;
}
```

The struct holds core properties of proposal

Parameters:

| Name            | Type                                 | Description                                                                       |
| --------------- | ------------------------------------ | --------------------------------------------------------------------------------- |
| settings        | struct IGovSettings.ProposalSettings | the struct that holds information about settings of the proposal                  |
| voteEnd         | uint64                               | the timestamp of voting end for the proposal                                      |
| executeAfter    | uint64                               | the timestamp of execution in seconds after voting end                            |
| executed        | bool                                 | the boolean indicating whether the proposal has been executed                     |
| votesFor        | uint256                              | the total number of votes for the proposal from all voters                        |
| votesAgainst    | uint256                              | the total number of votes against the proposal from all voters                    |
| rawVotesFor     | uint256                              | the total number of votes for the proposal from all voters before the formula     |
| rawVotesAgainst | uint256                              | the total number of votes against the proposal from all voters before the formula |
| givenRewards    | uint256                              | the amount of rewards payable after the proposal execution                        |

### ProposalAction

```solidity
struct ProposalAction {
	address executor;
	uint256 value;
	bytes data;
}
```

The struct holds information about proposal action

Parameters:

| Name     | Type    | Description                                                            |
| -------- | ------- | ---------------------------------------------------------------------- |
| executor | address | the address of call's target, bounded by index with `value` and `data` |
| value    | uint256 | the eth value for call, bounded by index with `executor` and `data`    |
| data     | bytes   | the of call data, bounded by index with `executor` and `value`         |

### Proposal

```solidity
struct Proposal {
	IGovPool.ProposalCore core;
	string descriptionURL;
	IGovPool.ProposalAction[] actionsOnFor;
	IGovPool.ProposalAction[] actionsOnAgainst;
}
```

The struct holds all information about proposal

Parameters:

| Name             | Type                              | Description                                                         |
| ---------------- | --------------------------------- | ------------------------------------------------------------------- |
| core             | struct IGovPool.ProposalCore      | the struct that holds information about core properties of proposal |
| descriptionURL   | string                            | the string with link to IPFS doc with proposal description          |
| actionsOnFor     | struct IGovPool.ProposalAction\[] | the array of structs with information about actions on for step     |
| actionsOnAgainst | struct IGovPool.ProposalAction\[] | the array of structs with information about actions on against step |

### ProposalView

```solidity
struct ProposalView {
	IGovPool.Proposal proposal;
	IGovValidators.ExternalProposal validatorProposal;
	IGovPool.ProposalState proposalState;
	uint256 requiredQuorum;
	uint256 requiredValidatorsQuorum;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name                     | Type                                   | Description                                                                    |
| ------------------------ | -------------------------------------- | ------------------------------------------------------------------------------ |
| proposal                 | struct IGovPool.Proposal               | the `Proposal` struct                                                          |
| validatorProposal        | struct IGovValidators.ExternalProposal | the `ExternalProposal` struct                                                  |
| proposalState            | enum IGovPool.ProposalState            | the value from enum `ProposalState`, that shows proposal state at current time |
| requiredQuorum           | uint256                                | the required votes amount to confirm the proposal                              |
| requiredValidatorsQuorum | uint256                                | the the required validator votes to confirm the proposal                       |

### RawVote

```solidity
struct RawVote {
	uint256 tokensVoted;
	uint256 totalVoted;
	uint256 nftsAmount;
	EnumerableSet.UintSet nftsVoted;
}
```

The struct that holds information about the typed vote (only for internal needs)

Parameters:

| Name        | Type                         | Description                                                                      |
| ----------- | ---------------------------- | -------------------------------------------------------------------------------- |
| tokensVoted | uint256                      | the total erc20 amount voted from one user for the proposal before the formula   |
| totalVoted  | uint256                      | the total power of typed votes from one user for the proposal before the formula |
| nftsAmount  | uint256                      | the amount of nfts participating in the vote                                     |
| nftsVoted   | struct EnumerableSet.UintSet | the set of ids of nfts voted from one user for the proposal                      |

### VoteInfo

```solidity
struct VoteInfo {
	mapping(IGovPool.VoteType => struct IGovPool.RawVote) rawVotes;
	bool isVoteFor;
	uint256 totalVoted;
	uint256 totalRawVoted;
}
```

The struct that holds information about the global vote properties (only for internal needs)

Parameters:

| Name          | Type                                                       | Description                                                                |
| ------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------- |
| rawVotes      | mapping(enum IGovPool.VoteType => struct IGovPool.RawVote) | matching vote types with their infos                                       |
| isVoteFor     | bool                                                       | the boolean flag that indicates whether the vote is "for" the proposal     |
| totalVoted    | uint256                                                    | the total power of votes from one user for the proposal after the formula  |
| totalRawVoted | uint256                                                    | the total power of votes from one user for the proposal before the formula |

### VoteInfoView

```solidity
struct VoteInfoView {
	bool isVoteFor;
	uint256 totalVoted;
	uint256 tokensVoted;
	uint256 totalRawVoted;
	uint256[] nftsVoted;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name          | Type       | Description                                                                      |
| ------------- | ---------- | -------------------------------------------------------------------------------- |
| isVoteFor     | bool       | the boolean flag that indicates whether the vote is "for" the proposal           |
| totalVoted    | uint256    | the total power of votes from one user for the proposal after the formula        |
| tokensVoted   | uint256    | the total erc20 amount voted from one user for the proposal before the formula   |
| totalRawVoted | uint256    | the total power of typed votes from one user for the proposal before the formula |
| nftsVoted     | uint256\[] | the set of ids of nfts voted from one user for the proposal                      |

### DelegatorRewards

```solidity
struct DelegatorRewards {
	address[] rewardTokens;
	bool[] isVoteFor;
	bool[] isClaimed;
	uint256[] expectedRewards;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name            | Type       | Description                                                         |
| --------------- | ---------- | ------------------------------------------------------------------- |
| rewardTokens    | address\[] | the list of reward tokens                                           |
| isVoteFor       | bool\[]    | the list of flags indicating whether the vote is "for" the proposal |
| isClaimed       | bool\[]    | the list of flags indicating whether the rewards have been claimed  |
| expectedRewards | uint256\[] | the list of expected rewards to be claimed                          |

### DelegatorInfo

```solidity
struct DelegatorInfo {
	uint256[] delegationTimes;
	uint256[] delegationPowers;
	mapping(uint256 => bool) isClaimed;
}
```

The struct that holds information about the delegator (only for internal needs)

Parameters:

| Name             | Type                     | Description                                                                    |
| ---------------- | ------------------------ | ------------------------------------------------------------------------------ |
| delegationTimes  | uint256\[]               | the list of timestamps when delegated amount was changed                       |
| delegationPowers | uint256\[]               | the list of delegated assets powers                                            |
| isClaimed        | mapping(uint256 => bool) | matching proposals ids with flags indicating whether rewards have been claimed |

### PendingRewards

```solidity
struct PendingRewards {
	mapping(uint256 => bool) areVotingRewardsSet;
	mapping(uint256 => uint256) staticRewards;
	mapping(uint256 => IGovPool.VotingRewards) votingRewards;
	mapping(address => uint256) offchainRewards;
	EnumerableSet.AddressSet offchainTokens;
}
```

The struct that holds reward properties (only for internal needs)

Parameters:

| Name                | Type                                              | Description                                                                                                              |
| ------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| areVotingRewardsSet | mapping(uint256 => bool)                          | matching proposals ids with flags indicating whether voting rewards have been set during the personal or micropool claim |
| staticRewards       | mapping(uint256 => uint256)                       | matching proposal ids to their static rewards                                                                            |
| votingRewards       | mapping(uint256 => struct IGovPool.VotingRewards) | matching proposal ids to their voting rewards                                                                            |
| offchainRewards     | mapping(address => uint256)                       | matching off-chain token addresses to their rewards                                                                      |
| offchainTokens      | struct EnumerableSet.AddressSet                   | the list of off-chain token addresses                                                                                    |

### UserInfo

```solidity
struct UserInfo {
	mapping(uint256 => IGovPool.VoteInfo) voteInfos;
	IGovPool.PendingRewards pendingRewards;
	mapping(address => IGovPool.DelegatorInfo) delegatorInfos;
	EnumerableSet.UintSet votedInProposals;
	EnumerableSet.UintSet treasuryExemptProposals;
}
```

The struct that holds the user info (only for internal needs)

Parameters:

| Name                    | Type                                              | Description                                            |
| ----------------------- | ------------------------------------------------- | ------------------------------------------------------ |
| voteInfos               | mapping(uint256 => struct IGovPool.VoteInfo)      | matching proposal ids to their infos                   |
| pendingRewards          | struct IGovPool.PendingRewards                    | user's pending rewards                                 |
| delegatorInfos          | mapping(address => struct IGovPool.DelegatorInfo) | matching delegators to their infos                     |
| votedInProposals        | struct EnumerableSet.UintSet                      | the list of active proposals user voted in             |
| treasuryExemptProposals | struct EnumerableSet.UintSet                      | the list of proposals user's treasury is exempted from |

### VotingRewards

```solidity
struct VotingRewards {
	uint256 personal;
	uint256 micropool;
	uint256 treasury;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name      | Type    | Description                      |
| --------- | ------- | -------------------------------- |
| personal  | uint256 | rewards for the personal voting  |
| micropool | uint256 | rewards for the micropool voting |
| treasury  | uint256 | rewards for the treasury voting  |

### PendingRewardsView

```solidity
struct PendingRewardsView {
	address[] onchainTokens;
	uint256[] staticRewards;
	IGovPool.VotingRewards[] votingRewards;
	uint256[] offchainRewards;
	address[] offchainTokens;
}
```

The struct that is used in view functions of contract as a return argument

Parameters:

| Name            | Type                             | Description                           |
| --------------- | -------------------------------- | ------------------------------------- |
| onchainTokens   | address\[]                       | the list of on-chain token addresses  |
| staticRewards   | uint256\[]                       | the list of static rewards            |
| votingRewards   | struct IGovPool.VotingRewards\[] | the list of voting rewards            |
| offchainRewards | uint256\[]                       | the list of off-chain rewards         |
| offchainTokens  | address\[]                       | the list of off-chain token addresses |

### CreditInfo

```solidity
struct CreditInfo {
	address[] tokenList;
	mapping(address => IGovPool.TokenCreditInfo) tokenInfo;
}
```

The struct is used to hold info about validators monthly withdrawal credit

Parameters:

| Name      | Type                                                | Description                                         |
| --------- | --------------------------------------------------- | --------------------------------------------------- |
| tokenList | address\[]                                          | the list of token allowed to withdraw               |
| tokenInfo | mapping(address => struct IGovPool.TokenCreditInfo) | the mapping token => withdrawals history and limits |

### TokenCreditInfo

```solidity
struct TokenCreditInfo {
	uint256 monthLimit;
	uint256[] cumulativeAmounts;
	uint256[] timestamps;
}
```

The struct is used to hold info about limits and withdrawals history

Parameters:

| Name              | Type       | Description                              |
| ----------------- | ---------- | ---------------------------------------- |
| monthLimit        | uint256    | the monthly withdraw limit for the token |
| cumulativeAmounts | uint256\[] | the list of amounts withdrawn            |
| timestamps        | uint256\[] | the list of timestamps of withdraws      |

### CreditInfoView

```solidity
struct CreditInfoView {
	address token;
	uint256 monthLimit;
	uint256 currentWithdrawLimit;
}
```

The struct is used to return info about current credit state

Parameters:

| Name                 | Type    | Description                                      |
| -------------------- | ------- | ------------------------------------------------ |
| token                | address | the token address                                |
| monthLimit           | uint256 | the amount that validator could withdraw monthly |
| currentWithdrawLimit | uint256 | the amount that validators could withdraw now    |

### OffChain

```solidity
struct OffChain {
	address verifier;
	string resultsHash;
	mapping(bytes32 => bool) usedHashes;
}
```

The struct that holds off-chain properties (only for internal needs)

Parameters:

| Name        | Type                     | Description                          |
| ----------- | ------------------------ | ------------------------------------ |
| verifier    | address                  | the off-chain verifier address       |
| resultsHash | string                   | the ipfs results hash                |
| usedHashes  | mapping(bytes32 => bool) | matching hashes to their usage state |

## Functions info

### getHelperContracts (0x485f4044)

```solidity
function getHelperContracts()
    external
    view
    returns (
        address settings,
        address userKeeper,
        address validators,
        address poolRegistry,
        address votePower
    )
```

The function to get helper contract of this pool

Return values:

| Name         | Type    | Description           |
| ------------ | ------- | --------------------- |
| settings     | address | settings address      |
| userKeeper   | address | user keeper address   |
| validators   | address | validators address    |
| poolRegistry | address | pool registry address |
| votePower    | address | vote power address    |

### getNftContracts (0x80326e95)

```solidity
function getNftContracts()
    external
    view
    returns (
        address nftMultiplier,
        address expertNft,
        address dexeExpertNft,
        address babt
    )
```

The function to get the nft contracts of this pool

Return values:

| Name          | Type    | Description                     |
| ------------- | ------- | ------------------------------- |
| nftMultiplier | address | rewards multiplier nft contract |
| expertNft     | address | local expert nft contract       |
| dexeExpertNft | address | global expert nft contract      |
| babt          | address | binance bound token             |

### createProposal (0xda1c6cfa)

```solidity
function createProposal(
    string calldata descriptionURL,
    IGovPool.ProposalAction[] calldata actionsOnFor,
    IGovPool.ProposalAction[] calldata actionsOnAgainst
) external
```

Create proposal

Parameters:

| Name             | Type                              | Description                                                         |
| ---------------- | --------------------------------- | ------------------------------------------------------------------- |
| descriptionURL   | string                            | IPFS url to the proposal's description                              |
| actionsOnFor     | struct IGovPool.ProposalAction\[] | the array of structs with information about actions on for step     |
| actionsOnAgainst | struct IGovPool.ProposalAction\[] | the array of structs with information about actions on against step |

### createProposalAndVote (0xee0e5215)

```solidity
function createProposalAndVote(
    string calldata descriptionURL,
    IGovPool.ProposalAction[] calldata actionsOnFor,
    IGovPool.ProposalAction[] calldata actionsOnAgainst,
    uint256 voteAmount,
    uint256[] calldata voteNftIds
) external
```

Create and vote for on the proposal

Parameters:

| Name             | Type                              | Description                                                         |
| ---------------- | --------------------------------- | ------------------------------------------------------------------- |
| descriptionURL   | string                            | IPFS url to the proposal's description                              |
| actionsOnFor     | struct IGovPool.ProposalAction\[] | the array of structs with information about actions on for step     |
| actionsOnAgainst | struct IGovPool.ProposalAction\[] | the array of structs with information about actions on against step |
| voteAmount       | uint256                           | the erc20 vote amount                                               |
| voteNftIds       | uint256\[]                        | the nft ids that will be used in voting                             |

### moveProposalToValidators (0x2db47bdd)

```solidity
function moveProposalToValidators(uint256 proposalId) external
```

Move proposal from internal voting to `Validators` contract

Parameters:

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| proposalId | uint256 | Proposal ID |

### vote (0x544df02c)

```solidity
function vote(
    uint256 proposalId,
    bool isVoteFor,
    uint256 voteAmount,
    uint256[] calldata voteNftIds
) external
```

The function for voting for proposal with own tokens

Parameters:

| Name       | Type       | Description                                          |
| ---------- | ---------- | ---------------------------------------------------- |
| proposalId | uint256    | the id of the proposal                               |
| isVoteFor  | bool       | the bool flag for voting for or against the proposal |
| voteAmount | uint256    | the erc20 vote amount                                |
| voteNftIds | uint256\[] | the nft ids that will be used in voting              |

### cancelVote (0xbacbe2da)

```solidity
function cancelVote(uint256 proposalId) external
```

The function for canceling vote

Parameters:

| Name       | Type    | Description                                           |
| ---------- | ------- | ----------------------------------------------------- |
| proposalId | uint256 | the id of the proposal to cancel all votes from which |

### deposit (0xde3ab781)

```solidity
function deposit(uint256 amount, uint256[] calldata nftIds) external
```

The function for depositing tokens to the pool

Parameters:

| Name   | Type       | Description                     |
| ------ | ---------- | ------------------------------- |
| amount | uint256    | the erc20 deposit amount        |
| nftIds | uint256\[] | the array of nft ids to deposit |

### withdraw (0xfb8c5ef0)

```solidity
function withdraw(
    address receiver,
    uint256 amount,
    uint256[] calldata nftIds
) external
```

The function for withdrawing deposited tokens

Parameters:

| Name     | Type       | Description                      |
| -------- | ---------- | -------------------------------- |
| receiver | address    | the withdrawal receiver address  |
| amount   | uint256    | the erc20 withdrawal amount      |
| nftIds   | uint256\[] | the array of nft ids to withdraw |

### delegate (0x46d0b0b9)

```solidity
function delegate(
    address delegatee,
    uint256 amount,
    uint256[] calldata nftIds
) external
```

The function for delegating tokens

Parameters:

| Name      | Type       | Description                                                                |
| --------- | ---------- | -------------------------------------------------------------------------- |
| delegatee | address    | the target address for delegation (person who will receive the delegation) |
| amount    | uint256    | the erc20 delegation amount                                                |
| nftIds    | uint256\[] | the array of nft ids to delegate                                           |

### delegateTreasury (0x39588f1e)

```solidity
function delegateTreasury(
    address delegatee,
    uint256 amount,
    uint256[] calldata nftIds
) external
```

The function for delegating tokens from treasury

Parameters:

| Name      | Type       | Description                                                                |
| --------- | ---------- | -------------------------------------------------------------------------- |
| delegatee | address    | the target address for delegation (person who will receive the delegation) |
| amount    | uint256    | the erc20 delegation amount                                                |
| nftIds    | uint256\[] | the array of nft ids to delegate                                           |

### undelegate (0x7810436a)

```solidity
function undelegate(
    address delegatee,
    uint256 amount,
    uint256[] calldata nftIds
) external
```

The function for undelegating delegated tokens

Parameters:

| Name      | Type       | Description                                                      |
| --------- | ---------- | ---------------------------------------------------------------- |
| delegatee | address    | the undelegation target address (person who will be undelegated) |
| amount    | uint256    | the erc20 undelegation amount                                    |
| nftIds    | uint256\[] | the array of nft ids to undelegate                               |

### undelegateTreasury (0xb6b90df4)

```solidity
function undelegateTreasury(
    address delegatee,
    uint256 amount,
    uint256[] calldata nftIds
) external
```

The function for undelegating delegated tokens from treasury

Parameters:

| Name      | Type       | Description                                                      |
| --------- | ---------- | ---------------------------------------------------------------- |
| delegatee | address    | the undelegation target address (person who will be undelegated) |
| amount    | uint256    | the erc20 undelegation amount                                    |
| nftIds    | uint256\[] | the array of nft ids to undelegate                               |

### unlock (0x2f6c493c)

```solidity
function unlock(address user) external
```

The function that unlocks user funds in completed proposals

Parameters:

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| user | address | the user whose funds to unlock |

### execute (0xfe0d94c1)

```solidity
function execute(uint256 proposalId) external
```

Execute proposal

Parameters:

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| proposalId | uint256 | Proposal ID |

### claimRewards (0x0520537f)

```solidity
function claimRewards(uint256[] calldata proposalIds, address user) external
```

The function for claiming rewards from executed proposals

Parameters:

| Name        | Type       | Description               |
| ----------- | ---------- | ------------------------- |
| proposalIds | uint256\[] | the array of proposal ids |
| user        | address    | the address of the user   |

### claimMicropoolRewards (0x7b0e1203)

```solidity
function claimMicropoolRewards(
    uint256[] calldata proposalIds,
    address delegator,
    address delegatee
) external
```

The function for claiming micropool rewards from executed proposals

Parameters:

| Name        | Type       | Description                  |
| ----------- | ---------- | ---------------------------- |
| proposalIds | uint256\[] | the array of proposal ids    |
| delegator   | address    | the address of the delegator |
| delegatee   | address    | the address of the delegatee |

### changeVotePower (0xcfd9c3c3)

```solidity
function changeVotePower(address votePower) external
```

The function to change vote power contract

Parameters:

| Name      | Type    | Description                               |
| --------- | ------- | ----------------------------------------- |
| votePower | address | new contract for the voting power formula |

### editDescriptionURL (0x0dbf1c47)

```solidity
function editDescriptionURL(string calldata newDescriptionURL) external
```

The function for changing description url

Parameters:

| Name              | Type   | Description             |
| ----------------- | ------ | ----------------------- |
| newDescriptionURL | string | the string with new url |

### changeVerifier (0xcf04fb94)

```solidity
function changeVerifier(address newVerifier) external
```

The function for changing verifier address

Parameters:

| Name        | Type    | Description             |
| ----------- | ------- | ----------------------- |
| newVerifier | address | the address of verifier |

### setCreditInfo (0xbaa7652f)

```solidity
function setCreditInfo(
    address[] calldata tokens,
    uint256[] calldata amounts
) external
```

The function for setting validators credit limit

Parameters:

| Name    | Type       | Description                             |
| ------- | ---------- | --------------------------------------- |
| tokens  | address\[] | the list of tokens to credit            |
| amounts | uint256\[] | the list of amounts to credit per month |

### transferCreditAmount (0xc1e09f97)

```solidity
function transferCreditAmount(
    address[] memory tokens,
    uint256[] memory amounts,
    address destination
) external
```

The function for fulfilling transfer request from validators

Parameters:

| Name        | Type       | Description                 |
| ----------- | ---------- | --------------------------- |
| tokens      | address\[] | the list of tokens to send  |
| amounts     | uint256\[] | the list of amounts to send |
| destination | address    | the address to send tokens  |

### changeBABTRestriction (0x2050a31b)

```solidity
function changeBABTRestriction(bool onlyBABT) external
```

The function for changing the KYC restriction

Parameters:

| Name     | Type | Description                   |
| -------- | ---- | ----------------------------- |
| onlyBABT | bool | true id restriction is needed |

### setNftMultiplierAddress (0xa43040eb)

```solidity
function setNftMultiplierAddress(address nftMultiplierAddress) external
```

The function for setting address of nft multiplier contract

Parameters:

| Name                 | Type    | Description                   |
| -------------------- | ------- | ----------------------------- |
| nftMultiplierAddress | address | the address of nft multiplier |

### saveOffchainResults (0x41c47e3e)

```solidity
function saveOffchainResults(
    string calldata resultsHash,
    bytes calldata signature
) external
```

The function for saving ipfs hash of off-chain proposal results

Parameters:

| Name        | Type   | Description                 |
| ----------- | ------ | --------------------------- |
| resultsHash | string | the ipfs results hash       |
| signature   | bytes  | the signature from verifier |

### getProposals (0x5e3b4365)

```solidity
function getProposals(
    uint256 offset,
    uint256 limit
) external view returns (IGovPool.ProposalView[] memory)
```

The paginated function for getting proposal info list

Parameters:

| Name   | Type    | Description                        |
| ------ | ------- | ---------------------------------- |
| offset | uint256 | the proposal starting index        |
| limit  | uint256 | the number of proposals to observe |

Return values:

| Name | Type                            | Description          |
| ---- | ------------------------------- | -------------------- |
| \[0] | struct IGovPool.ProposalView\[] | `ProposalView` array |

### getProposalState (0x9080936f)

```solidity
function getProposalState(
    uint256 proposalId
) external view returns (IGovPool.ProposalState)
```

Parameters:

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| proposalId | uint256 | Proposal ID |

Return values:

| Name | Type                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| \[0] | enum IGovPool.ProposalState | `ProposalState`: 0 -`Voting`, proposal where addresses can vote 1 -`WaitingForVotingTransfer`, approved proposal that waiting `moveProposalToValidators()` call 2 -`ValidatorVoting`, validators voting 3 -`Defeated`, proposal where voting time is over and proposal defeated on first or second step 4 -`SucceededFor`, successful proposal with votes for but not executed yet 5 -`SucceededAgainst`, successful proposal with votes against but not executed yet 6 -`Locked`, successful proposal but temporarily locked for execution 7 -`ExecutedFor`, executed proposal with the required number of votes on for step 8 -`ExecutedAgainst`, executed proposal with the required number of votes on against step 9 -`Undefined`, nonexistent proposal |

### getUserActiveProposalsCount (0x38fa211c)

```solidity
function getUserActiveProposalsCount(
    address user
) external view returns (uint256)
```

The function for getting user's active proposals count

Parameters:

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| user | address | the address of user |

Return values:

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \[0] | uint256 | the number of active proposals |

### getTotalVotes (0x6545ea83)

```solidity
function getTotalVotes(
    uint256 proposalId,
    address voter,
    IGovPool.VoteType voteType
) external view returns (uint256, uint256, uint256, bool)
```

The function for getting total raw votes in the proposal by one voter

Parameters:

| Name       | Type                   | Description          |
| ---------- | ---------------------- | -------------------- |
| proposalId | uint256                | the id of proposal   |
| voter      | address                | the address of voter |
| voteType   | enum IGovPool.VoteType | the type of vote     |

Return values:

| Name | Type    | Description                                                                                          |
| ---- | ------- | ---------------------------------------------------------------------------------------------------- |
| \[0] | uint256 | `Arguments`: core raw votes for, core raw votes against, user typed raw votes, is vote for indicator |

### getProposalRequiredQuorum (0xda437f37)

```solidity
function getProposalRequiredQuorum(
    uint256 proposalId
) external view returns (uint256)
```

The function to get required quorum of proposal

Parameters:

| Name       | Type    | Description        |
| ---------- | ------- | ------------------ |
| proposalId | uint256 | the id of proposal |

Return values:

| Name | Type    | Description                                       |
| ---- | ------- | ------------------------------------------------- |
| \[0] | uint256 | the required number for votes to reach the quorum |

### getUserVotes (0x466d7af2)

```solidity
function getUserVotes(
    uint256 proposalId,
    address voter,
    IGovPool.VoteType voteType
) external view returns (IGovPool.VoteInfoView memory)
```

The function to get information about user's votes

Parameters:

| Name       | Type                   | Description          |
| ---------- | ---------------------- | -------------------- |
| proposalId | uint256                | the id of proposal   |
| voter      | address                | the address of voter |
| voteType   | enum IGovPool.VoteType | the type of vote     |

Return values:

| Name | Type                         | Description          |
| ---- | ---------------------------- | -------------------- |
| \[0] | struct IGovPool.VoteInfoView | `VoteInfoView` array |

### getWithdrawableAssets (0x7ecd20bb)

```solidity
function getWithdrawableAssets(
    address delegator
) external view returns (uint256, uint256[] memory)
```

The function to get withdrawable assets

Parameters:

| Name      | Type    | Description           |
| --------- | ------- | --------------------- |
| delegator | address | the delegator address |

Return values:

| Name | Type    | Description                              |
| ---- | ------- | ---------------------------------------- |
| \[0] | uint256 | `Arguments`: erc20 amount, array nft ids |

### getPendingRewards (0x566aff6a)

```solidity
function getPendingRewards(
    address user,
    uint256[] calldata proposalIds
) external view returns (IGovPool.PendingRewardsView memory)
```

The function to get on-chain and off-chain rewards

Parameters:

| Name        | Type       | Description                                        |
| ----------- | ---------- | -------------------------------------------------- |
| user        | address    | the address of the user whose rewards are required |
| proposalIds | uint256\[] | the list of proposal ids                           |

Return values:

| Name | Type                               | Description         |
| ---- | ---------------------------------- | ------------------- |
| \[0] | struct IGovPool.PendingRewardsView | the list of rewards |

### getDelegatorRewards (0x529285af)

```solidity
function getDelegatorRewards(
    uint256[] calldata proposalIds,
    address delegator,
    address delegatee
) external view returns (IGovPool.DelegatorRewards memory)
```

The function to get delegator staking rewards from all micropools

Parameters:

| Name        | Type       | Description                  |
| ----------- | ---------- | ---------------------------- |
| proposalIds | uint256\[] | the list of proposal ids     |
| delegator   | address    | the address of the delegator |
| delegatee   | address    | the address of the delegatee |

Return values:

| Name | Type                             | Description               |
| ---- | -------------------------------- | ------------------------- |
| \[0] | struct IGovPool.DelegatorRewards | rewards delegator rewards |

### getCreditInfo (0xf06817cf)

```solidity
function getCreditInfo()
    external
    view
    returns (IGovPool.CreditInfoView[] memory)
```

The function to get info about validators credit limit

Return values:

| Name | Type                              | Description              |
| ---- | --------------------------------- | ------------------------ |
| \[0] | struct IGovPool.CreditInfoView\[] | the list of credit infos |

### getOffchainInfo (0xb3a72fc4)

```solidity
function getOffchainInfo()
    external
    view
    returns (address validator, string memory resultsHash)
```

The function to get off-chain info

Return values:

| Name        | Type    | Description          |
| ----------- | ------- | -------------------- |
| validator   | address | the verifier address |
| resultsHash | string  | the ipfs hash        |

### getOffchainSignHash (0x8e19ade9)

```solidity
function getOffchainSignHash(
    string calldata resultsHash,
    address user
) external view returns (bytes32)
```

The function to get the sign hash from string resultsHash, chainid, govPool address

Parameters:

| Name        | Type    | Description                         |
| ----------- | ------- | ----------------------------------- |
| resultsHash | string  | the ipfs hash                       |
| user        | address | the user who requests the signature |

Return values:

| Name | Type    | Description  |
| ---- | ------- | ------------ |
| \[0] | bytes32 | bytes32 hash |

### getExpertStatus (0x0660b478)

```solidity
function getExpertStatus(address user) external view returns (bool)
```

The function to get expert status of a voter

Return values:

| Name | Type | Description                    |
| ---- | ---- | ------------------------------ |
| \[0] | bool | address of a person, who votes |

### coreProperties (0xe9bbc80c)

```solidity
function coreProperties() external view returns (ICoreProperties)
```

The function to get core properties

Return values:

| Name | Type                     | Description                 |
| ---- | ------------------------ | --------------------------- |
| \[0] | contract ICoreProperties | `ICoreProperties` interface |


# Prod (BSC/ETH)

| Name                 | Address                                    |
| -------------------- | ------------------------------------------ |
| DeXe DAO             | 0xB562127efDC97B417B3116efF2C23A29857C0F0B |
| DeXe DAO Token (BSC) | 0x6E88056E8376AE7709496BA64D37FA2F8015CE3E |
| DeXe DAO Token (ETH) | 0xde4EE8057785A7e8e800Db58F9784845A5C2Cbd6 |
| ContractsRegistry    | 0x46B46629B674b4C0b48B111DEeB0eAfd9F84A1c0 |
| UserRegistry         | 0x427a1214f12117b1AD48C817c203c5CF3Eb7E7C4 |
| CoreProperties       | 0xaB9d2a2347D5fF5B760C0226C52d5C673b8D9e44 |
| PriceFeed            | 0xc7730074736c10ed0d3F928A10Ee4162DA9a7983 |
| ERC721Expert         | 0x892B3292cF80CB298b7fA20D04EF4732640db404 |
| PoolFactory          | 0x85f86ef7E72e86BdEAb5F65e2B76A2c551f22109 |
| PoolRegistry         | 0xFEB26AAB75638440B3CEFe8B10de6118972f9C6B |


# Stage (BSC Testnet/Sepolia)

| Name                     | Address                                    |
| ------------------------ | ------------------------------------------ |
| DeXe DAO                 | 0xB562127efDC97B417B3116efF2C23A29857C0F0B |
| DeXe DAO Token (BSC)     | 0xf42F27612af98F40865Dc3CB8531d3aa4C44A8E5 |
| DeXe DAO Token (Sepolia) | 0xC65901190eC6727f979C995EC718e28BFF74563a |
| ContractsRegistry        | 0x46B46629B674b4C0b48B111DEeB0eAfd9F84A1c0 |
| UserRegistry             | 0x427a1214f12117b1AD48C817c203c5CF3Eb7E7C4 |
| CoreProperties           | 0xaB9d2a2347D5fF5B760C0226C52d5C673b8D9e44 |
| PriceFeed                | 0xc7730074736c10ed0d3F928A10Ee4162DA9a7983 |
| ERC721Expert             | 0x892B3292cF80CB298b7fA20D04EF4732640db404 |
| PoolFactory              | 0x85f86ef7E72e86BdEAb5F65e2B76A2c551f22109 |
| PoolRegistry             | 0xFEB26AAB75638440B3CEFe8B10de6118972f9C6B |
| SphereXEngine            | 0x41260f637a993ce714Ece1ee9875F489e483e9b3 |
| PoolSphereXEngine        | 0x4fa2092E32934Dd3823E58C79ceD0e410a5B0D4b |


# Prod (BSC)

| Graph Name       | Link to Graph                                                                                      |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| All Interactions | [Click here](https://thegraph.com/explorer/subgraphs/CPsXn5AcuVTd48sb3uRuPbxcheLEnWCeoXJkARDoWxoP) |
| DAO Validators   | [Click here](https://thegraph.com/explorer/subgraphs/9xpPF9EWtSJJUwVYZb7f6D1xcMCyLbmR6ujgnYG8fbQA) |
| DAO Pools        | [Click here](https://thegraph.com/explorer/subgraphs/2XDP2ZxHc25n4xeDqKWTGBy5FJojS6dw4WM79oof2YLn) |


# Prod (ETH)

| Graph Name       | Link to Graph                                                                                      |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| All Interactions | [Click here](https://thegraph.com/explorer/subgraphs/7tJKp4ZzuJtjUKazN8w3SG5PbUmo7acf8yNSPL3havbb) |
| DAO Validators   | [Click here](https://thegraph.com/explorer/subgraphs/5n4RMTMafKATjeET23JVPKDkZ9X96XMz4bUaw8Tp3uQz) |
| DAO Pools        | [Click here](https://thegraph.com/explorer/subgraphs/HDxm8ch7G64UyLhYzg41tBhzW5RavGo7E1dfqHJUA732) |


# Stage (BSC Testnet)

| Graph Name       | Link to Graph                                                                            |
| ---------------- | ---------------------------------------------------------------------------------------- |
| All Interactions | [Click here](https://api.thegraph.com/subgraphs/name/vitaliimaistrenko/all-interactions) |
| DAO Validators   | [Click here](https://api.thegraph.com/subgraphs/name/vitaliimaistrenko/dao-validators)   |
| DAO Pools        | [Click here](https://api.thegraph.com/subgraphs/name/vitaliimaistrenko/dao-pools)        |


