What is Price?

Price is a permissionless and reliable oracle solution that leverages Uniswap V3 and automation to provide safe price quotes on any existing token.

Price is built on top of Uniswap V3, thus inheriting all its decentralization and sustainability but solving its main problems:

  • Trust issues: We make liquidity a trustworthy and predictable asset for the oracle's users.

  • Complexity: Neither the protocol nor the user need to handle anything. Contracts will manage positions, fees, pool parameters, and security.

  • Multi-block attack: We use automation to detect and correct price manipulations, including multi-block attacks. This correction will unlock the use of safe and precise price data.

WEN

Alpha will be live in early 2023.

How will Price work?

Price is built on top of Uniswap V3, thus inheriting all its decentralization and sustainability but solving its main problems:

  • Trust issues: We make liquidity a trustworthy and predictable asset for the oracle's users.
  • Complexity: Neither the protocol nor the user need to handle anything. Contracts will manage positions, fees, pool parameters, and security.
  • Multi-block attack: We use automation to detect and correct price manipulations, including multi-block attacks. This correction will unlock the use of safe and precise price data.

We plan on deploying all contracts on every Uniswap V3-supported network.

Any party that wishes to use Price for a specific TOKEN will have to seed WETH and TOKEN into a contract. This contract will initialize the WETH-TOKEN pool if it does not exist and then add liquidity as a full-range position. This liquidity will work as a security deposit for oracle's users and cannot be withdrawn by the depositing protocol, only migrated.

Part of the fees from this position will automatically improve the oracle's health by increasing cardinality, full-range liquidity, and paying for automation jobs that defend the oracle.

We will introduce an oracle contract, which lowers the cost of queries by performing shared and optimized computation. The oracle contract also introduces signal processing jobs that filter potential TWAP manipulations, including the notorious PoS multiblock attack.

This works by introducing a 2-minute delay that enables us to capture up to a 9-block manipulation. The automated job detects and corrects the observation array with the proper non-manipulated values in case of manipulation-like movements. The oracle contract is manipulation-cost agnostic. This change unlocks the safe use of higher precision queries (shorter TWAPs).

Protocols can further incentivize external lockers to concentrate liquidity on the pools, which Price will share and manage as a low-risk profile hedge fund. This liquidity will aim at increasing both the trading volume, which will increase the fees and the precision of the oracle.

Important disclaimers:

  • Price will not charge any fees for the service.
  • There will not be any Price ERC-20 at the moment. Any such listing is a scam.

One can think of the full-range liquidity with the TWAP length as the safety net against price manipulation and the concentrated liquidity to ensure trading volume, providing fees and improving oracle precision. The fees will increase the security and reliability of the oracle.

Why Price?

As we all know, oracles can make or break a DeFi protocol. They are a single point of failure for the biggest protocols out there. We think oracles are reliable until a black swan event happens. Unfortunately, crypto is a flock of black swans, so you've got to be prepared.

The main goal of an oracle is to deliver data that is as trustworthy as possible. To do this, it has to be:

  • Reliable: it must be challenging to manipulate.
  • Decentralized: it cannot depend on just a few participants.
  • Sustainable: it must be cheap to maintain and scale.

But current solutions are not able to deliver the three of these simultaneously.

The most widely used solutions in DeFi rely on nodes updating the prices from off-chain liquid sources. But these nodes must be somehow incentivized to do the work. The more nodes and data feeds in the system, and the more incentives are needed. This creates a scaling tension that current solutions solve by centralizing rewards and whitelisting incentivized feeds.

Uniswap V3 introduced a novel way of querying price data. It is decentralized and sustainable (thanks to swappers and LP's subsidies), but it is complicated to rely on due to liquidity's unpredictability.

Uniswap has the most decentralized and sustainable solution for oracles, but it also has a long track of exploits and manipulations. This issue improved after v3, but it's still happening. Additionally, with the switch to PoS consensus in Ethereum, a new attack vector was unlocked: the multi-block attack.

  • Trust issues: Oracle's quality depends on the pool's liquidity, but that depends on external providers. As a result, it is impossible to predict the future oracle's status.

  • Complexity: Concentrated liquidity is a double-edged sword. It enormously increases LPs' capital efficiency but also makes manipulation easier. Think of it as more capital being sold close to the current price.

    • Many protocols willing to have an oracle do not fully understand how Uniswap works. They either opt out or get rekt.
  • Multi-block attack: With the recent move from PoW to PoS consensus on Ethereum, predictability on block proposers was also introduced. Chances are that some big players will propose multiple blocks in a row with high frequency. A potential attack on Uniswap TWAP could consist of price manipulation while leaving out of the blocks any external arbitrage, reducing enormously an attack's cost.

Medians were suggested several times as an alternative to the standard TWAP to filter away multi-block attacks. But they are laggy, imprecise and would require a dedicated AMM.

The solution

Price is a permissionless and reliable oracle solution that leverages Uniswap V3 and automation to provide safe price quotes on any existing token.

Price is built on top of Uniswap V3, thus inheriting all its decentralization and sustainability but solving its main problems:

  • Trust issues: We make liquidity a trustworthy and predictable asset for the oracle's users.

  • Complexity: Neither the protocol nor the user need to handle anything. Contracts will manage positions, fees, pool parameters, and security.

  • Multi-block attack: We use automation to detect and correct price manipulations, including multi-block attacks. This correction will unlock the use of safe and precise price data.

Seeding

A protocol or any other interested party that wishes to use Price for a particular token will need to lock liquidity. This will

  1. Initialize the Uniswap V3 pool if it does not exist already
  2. Increase the observation array up to a safe length if not already there
  3. Add tokens to be used as a full-range position

We call this process seeding and the WETH/tokens provided to the full-range position seeded liquidity.

How do I seed?

Let's say I have a token called RICH and I need to build some smart contract that quotes 1 WETH to RICH tokens, using a 5-minute TWAP. I heard about Price and I wanna use it for my use case. As I have tons of money, I wouldn't have an issue seeding the liquidity myself. What steps should I follow, until I have everything I need to develop my smart contract?

  1. Visit the seeding page and create the price pool by seeding the minimum amount of liquidity. The transaction will take care of everything for the pool to be healthy, with a good liquidity positioning, and a bigger cardinality array
  2. Now your pair is officially supported by Price. You can double check it by querying PriceOracle.isPairSupported(WETH, RICH). The address of the oracle contract can be found in the contracts registry.
  3. It is as simple as that! Now, in your smart-contract you can utilize the PriceOracle functions in order to query safely. For example, PriceOracle.quotePeriod(1 ether, WETH, RICH, 10 minutes). If you want to cache the TWAP response, or look at other query possibilities, make sure to check the PriceOracle interface documentation.

Minimum liquidity requirement

The full-range liquidity and TWAP length are the primary safety net against price manipulation. A manipulation detection job makes sense only after meeting some basic security standards.

For the first deposit, we will require minimum total liquidity of 50 WETH, half in the specific token, half in WETH. This is a safe amount to justify the gas costs for maintenance. With this requirement, we want to make a manipulation extremely expensive, have a basic precision standard on the price (arbitrage) and generate enough fees to trigger the maintenance jobs with a target frequency. The minimum liquidity requirement will probably be fine-tuned in future versions.

If at some point the position's value drops significantly, the only net result will be a decline on the job's frequency. The protocol is designed to be sustainable independently of the trading volume or the locked value.

What happens if the pool already exists?

A pool might be already created by another user directly in Uniswap. We are not worried about this, and the contracts & UI will be able to recognize it. In this case, cardinality will be increased from the starting point onward, and the current price will be taken for reference. If a malicious user front-runs the pool creation with a bad price, they will get arbitraged. There will then be no incentive to do something like this.

Fee management

The fees from the full-range position will be automatically managed to improve the oracle's health.

The seeders can claim some of the fees as rewards but cannot withdraw the funds at will, making liquidity reliable for oracle's users. From the seeder's perspective, they commit the liquidity in exchange for trust from lending markets and other oracle's users, and fees. This trust will eventually translate into token usage and demand.

Unlocking

Seeders can vote to migrate funds, which might be necessary for moving the liquidity to future versions of Uniswap or Price. This could also be used as an escape hatch in case of protocol deprecation. Price can only propose a migration, which the seeders will vote on, and any liquidity movement will be protected with a long timelock.

For more details on this process, read Unlocking.

Locking

Any user can lock WETH to the seeded pools, this liquidity will automatically generate concentrated positions. The protocol can function without lockers, it's just an extra mechanism for improving the oracles.

Lockers will receive an ERC-20 lock token that will allow them to claim their corresponding fees. They will not be able to claim their WETH back immediately after locking, but they can collectively vote to close the position. If the majority votes in favor of it, all lockers can redeem their share of the position.

Locked liquidity will behave in a shared and predictable way. This liquidity will follow a low-risk profile in the alpha release, but we expect to develop different strategies that lockers can choose. Eventually, strategies should be open for anyone to create/integrate with existing Uniswap LP management strategies. See Strategy for more details.

If you want to lock liquidity, visit the pools page and choose the pool you're interested in.

How does concentrated liquidity improve an oracle?

As we mentioned in our blog posts, concentrated liquidity increases capital efficiency for LPs but makes manipulation easier. Think of it as selling more capital at an average lower price. Why do we need concentrated positions, then?

To answer that question, we must remember that arbitrage is at the core of the oracle, as it allows information to travel on-chain. Arbitrage is what ultimately replaces nodes from regular oracles. Even though the protocol could work perfectly fine without lockers, concentrated liquidity creates a crucial advantage: deeper liquidity close to the active range will make arbitrage more efficient as more volume is available. Having more liquidity will result in a more precise value for the oracle. This will incentivize seeders and oracle users to lock or further bribe the lockers.

Why would someone lock via Price instead of directly on Uniswap?

  1. All complexity from the concentrated positions will get abstracted away from the lockers. This includes fees, gas costs, and position management.
  2. Deploying liquidity into a specific position is a bet on the market which could be wrong. By creating several positions distributed in time, they're lowering their risk, effectively DCAing the LP.
  3. Additionally, we will introduce "bribe" contracts for anyone to give additional rewards to the lockers. Seeders that wish to have more concentrated liquidity are incentivized to "bribe" the lockers in this way.

Unlocking

Users cannot withdraw their WETH unless most lockers choose to do so. Users are gathering and joining a strategy we will manage in a predetermined way. Think of it like a hedge fund, where users give their capital to be managed by the fund. Sometimes individual users can not withdraw if the capital is deployed to a strategy, but they can if the majority wishes.

Each address is assigned to a boolean, signalling a stay-leave vote. This parameter defaults to stay but can be changed to leave at any time by the user. If more than X% of the users have voted to leave, the funds become available for claiming. No one else can add liquidity to this LockManager. A new LockManager is initialized for those who wish to remain in the pool.

To make on- and off-ramping easier, we will launch a secondary market for users to trade these lock tokens at a discount at any time. Sellers can exit their position with a profit if fees were larger than the discount, and buyers can get in with zero-risk leveraged exposure to fees.

More details here.

Unlocking liquidity

A core idea of Price is ensuring liquidity will behave predictably. The only way of doing this is by committing the liquidity under a series of locks, such as governance and timelock. That's why once seeders or lockers have provided liquidity for an oracle, they won't be able to claim it back immediately. Instead, they will have to go through the deprecation process for either PoolManager or LockManager. This will enable users to trust oracle long-term.

Seeders (PoolManager)

Once the seeder deposits their positions, there is an ownership change. This liquidity becomes protocol-owned, and thus we have permits to move the funds. We can only do so under the seeder's approval.

The process will be done manually, as each case must be properly investigated and discussed in Governance. It's not the same to unlock funds due to WETH depreciation, where we move the funds to a new contract to be claimed by the seeders, as moving liquidity to Uniswap v4 or Curve.

Once discussions have settled, we will propose a migration contract. Seeders will have time to vote and decide whether or not they accept the migration. If accepted, a long timelock will begin.

Lockers (LockManager)

LockManager will behave like a DAO which owns its funds.

As soon as a LockManager is deployed, a vote will be created to deprecated it. Initially lockers have no incentive to deprecate the LockManager but with time, in case the strategy becomes less efficient, they will vote in favor of exiting the lock and moving their funds to a new LockManager or somewhere else.

If more than 70% of the locked tokens are tuned into "leave", a timelock to unwind the position will be initialized. During this period, lockers can change their mind as many times as they wish. In the alpha version, new lockers will be accepted even after the timelock has started, but that will change in future releases.

If the LockManager is deprecated, the concentrated positions can be withdrawn from Uniswap. Then redeemed positions + non-deployed WETH + any fees left become claimable by the lockers. In parallel, a new LockManager for the pool will be initialized with a different lock ERC20, and the cycle will start again.

Fee Management

Seeders and lockers are eligible for the trading fees generated in the pool. Seeders will pay 50% of their fees as "taxes" and the lockers pay 20%. The rest of the fees will be claimable as rewards.

Price will use the taxes to improve the oracle quality and maintain the strategies. The taxes will be 100% reinvested in the system, and this reinvestment should come back to the users in the long term while improving the oracle quality in the short term. In no way the Price protocol will profit from the whole process.

Note that the tax percentage will probably get tuned in future versions.

How is Price using these fees?

fee-management.png

Taxes will go to a FeeManager, a hub for tax distribution, that will

  • Increase the full-range position
  • Pay keepers for automatic fee collection, position management, liquidity increases and manipulation detection, increasing the pool's cardinality

New pools will have their manipulation detection covered by other pools until they reach enough funds. Eventually, they will also help new pools to be safe after having enough.

Cardinality will not be increased forever, but only up to a point. After reaching this value, maintenance will use 100% of its capital for automation.

Fee collection will occur periodically upon job execution, and users can claim afterwards. As a result, users who lock between jobs will not see any difference at the time of deposit. Users could wait to see how many fees are due for the following collection before depositing, but they would risk being front-ran by the job.

As a pool generates more fees, these jobs will start paying for themselves. Fees will cover the IL of the credits and subsidize the jobs from other pools.

Strategy

Price will allow users to jump into a shared concentrated strategy. But what is the point of a concentrated position?

  • More liquidity means easier arbitrage and more precision for the oracle
  • Efficiently compete for fees against external liquidity providers

We plan on opening this part of the protocol so that users can participate using any Uniswap V3 position manager like Revert, Arrakis, etc. For the alpha launch, we will have our own strategy.

The strategy will only accept WETH deposits. We don't concentrate on the other token as well, because the parameters for setting the strategy triggers are computed based on gas costs. This is doable with WETH, but not so much for extremely volatile assets. Notice the protocol is fully permissionless.

When do we deploy the liquidity?

The total available WETH will not be deployed as users lock WETH, but it will be batched instead. This reduces the risk of misplacing liquidity and minimizes gas costs for liquidity providers. Each batch will deploy half of the available WETH: notice this is asymptotical, meaning the LockManager never runs out of WETH to deploy in extreme IL situations.

The liquidity will be deployed once a minimum amount of WETH is reached. This minimum amount is such that the gas costs of deploying and collecting fees are much smaller than the generated fees. In this way, positions never go at a loss due to gas management.

To trigger the maintenance jobs, excluding manipulation correction, the contract will check that the gas costs represent a fixed percentage of the total accused fees. The strategy also has a maximum amount of WETH defined, which can be deployed in each batch. This restriction, even if suboptimal from a gas perspective, is also necessary to minimize liquidity misplacement risk. As we are running the jobs only when enough fees have accrued, the protocol will be self-sufficient.

We're not using a time trigger because, while unlikely due to arbitrage, it might trigger even with 0 or almost 0 trading volume, and the protocol would be at a loss.

Another option would be to trigger at the edge of the current position. The problem with this approach is that fee collections would be much harder and that we would stop the price discovery mechanism by deploying liquidity in bad prices. Also, it might be invisible to large trades and it can be manipulated.

Dynamics

Price of WETH increases relative to the other token

A part of concentrated liquidity gets swapped for the other token. When the fee threshold is met, a new position gets deployed.

If we assume that WETH is token0 in the pool, then it can be pictured as being to the right of the current price (limit orders of WETH above the current price).

Position0 was deployed when price was \(P0\). Then, the price increased and position0 was partially turned into TOKEN. When the spot price reached \(P1\), the generated fees and the available WETH allowed for the deployment of position1.

positions-price-increase.png

Concentrated positions of TOKEN that became single-sided positions can be re-positioned close to the current price. We will not do it in the alpha version, since doing so assumes and closes IL, which would not happen with WETH.

Price of WETH decreases relative to the other token

When the price of WETH decreases relative to the other token, a new WETH position is deployed when generated fees reach the threshold. If a WETH position is too far from the current price, the position is burnt and the WETH goes back to the LockManager, ready to be deployed.

positions-price-decrease.png

The shape of the positions

We determined the width of the positions with a set of restrictions

  • The more assets to mint, the less percentage of risk. Big capital looks for safety and prefers wider positions, and small capital risks more.
  • Even if we are not running the job until having enough fees, each position should justify its minting cost without a doubt.
  • We want the position to be used as much as possible without resigning too much liquidity. Remember concentration effect on liquidity can be huge.
  • As a heuristic approach, positions will tend to the safer end in this release. In v2 we plan to introduce riskier takes, e.g. allowing several LockManager contracts to live in the same pool.

Note that we think of narrow positions as risky because in the worst-case scenario with high volatility, thin positions have the worst performance, generating zero fees.

A way to achieve these goals is to mint a fixed amount of liquidity and make the number of assets determine the width. The challenge here is determining the right amount of liquidity. Note that how we measure liquidity is not objective but changes from pool to pool. To define this liquidity, we can define a minimum amount of WETH and a min-width for it. This will be chosen such that positions are self-sustainable, and with the assumption that the position is used most of the time. This can be broadly estimated using some quantitative finance and historical volatility. Finally, we will assign an overestimated volatility that will determine this minimum width.

We will take a "linear strategy" as a function of assets that is simple to code. We will fix the values \(r_{min}\) and \(r_{max}\), \(Amount_{min}\) and \(Amount_{max}\), where \(r\) is defined as

\(r=\sqrt{\frac{p_{upper}}{p_{lower}}}\)

with \(p_{upper}\) and \(p_{lower}\) the upper and lower bounds of the position. Then, create a linear function such that

\(\sqrt{p_{upper}} = a*Amount+b\)

\(a\) and \(b\) can be found by simply making the line fit through the points \((\sqrt{p_{upper_min}},Amount_{min})\) and \((\sqrt{p_{upper_max}},Amount_{max})\)

\(\sqrt{p_u} = r_{min}\sqrt{P}\) and for amountMax \(\sqrt{p_u} =r_{max}\sqrt{P}\)

A line going through two given points is given by

\(\frac{y-y_2}{y_1-y_2}=\frac{x-x_2}{x_1-x_2}\)

\(\sqrt{p_u}=\)
\(\sqrt{P}\left[\left(\frac{r_{max}-r_{min}}{Amount_{max}-Amount_{min}}\right)(Amount-Amount_{min})+r_{min}\right] = \frac{\sqrt{p_{upper_max}}-\sqrt{p_{upper_min}}}{(Amount_{max}-Amount_{min})}(Amount-Amount_{min})+\sqrt{p_{upper_min}}\)

The same can be applied to the case of WETH being token1

\(\sqrt{p_{lower}} = a*Amount+b\)

\(a\) and \(b\) can be found by simply making the line fit through the points \((\sqrt{p_{lower_max}},Amount_{min})\) and \((\sqrt{p_{lower_min}},Amount_{max})\)

\(\sqrt{p_l}= \frac{\sqrt{p_{lower_min}}-\sqrt{p_{lower_max}}}{(Amount_{max}-Amount_{min})}(Amount-Amount_{min})+\sqrt{p_{lower_max}}\)

Oracle

Historically, oracles suffered from the security-precision tradeoff. Price comes to put an end to that discussion. With manipulation detection in place, the oracle is manipulation-cost agnostic. This paradigm shift unlocks the safe use of higher precision queries (shorter TWAPs). This point is crucial to many applications which are nowadays impossible to implement due to the lack of precision.

Price introduces signal processing jobs that filter potential TWAP manipulations, including the notorious PoS multi-block attack. As mentioned in the Fee Management section, the jobs are paid for automatically with the fees generated from the positions. Another convenient addition is a cache that enables shared gas cost for queries and reduces the cost for the most popular queried pools.

High-level overview

The oracle introduces a 2-minute delay that enables keepers to capture up to a 9-block manipulation pattern, which includes multi-block attacks. The automated job detects and corrects the observation array with the proper non-manipulated values in case of manipulation-like movements.

Corrections are designed to make false-positive triggers harmless and almost desirable as they erase spurious price data. Other protocols have suggested using medians as an alternative to the standard TWAP to filter away multi-block attacks. But

  • Median filters away fast movements but cannot differentiate manipulations from legitimate price swings.
  • Medians are always laggier and less precise than TWAPs.
  • Medians are not smooth, a desirable property for many use cases, for instance, Dutch auction liquidations.
  • It's expensive to implement as a standalone solution. To function with an acceptable cost, we would need a dedicated AMM with native support for medians.

How do you query the oracle for a certain token?

In order to get a quote from the oracle, you have to call the function quote. Refer to the docs to find out what arguments the function takes. It's worth nothing that you should be careful with the chosen TWAP length, because querying TWAP longer than 2 weeks may result in the manipulated vales being accounted for without any protection.

Also note that only pools supported by Price can be queries at the moment. If your project needs a price feed for a token that doesn't have an oracle yet, you can either seed the pool yourself or approach the protocol to ask them to create the oracle.

Manipulation correction

Protocols usually only check if TWAP has much difference from spot to revert. This approach has several issues:

  • It reverts (halts everything)
  • If it's not enough to revert, the manipulation can still lead to TWAPs having unreal values
  • It is not enough, for instance, an array of observations like [1, 100, 10] will have TWAP equal to spot and not revert
  • This type of check does not consider multiblock manipulations, which eventually expire partially and create imbalanced TWAPs

Our solution is to set up a Keep3r job that looks for clear manipulation patterns and corrects the queried data to ignore the attack completely. The job will be super well-paid to incentivize keepers.

The keeper running the job will have to provide the indexes of the manipulated observations.

Then for each manipulation index we check

  1. If the manipulated observation is considerably higher/lower than the one before it. We can compare the value of the tick before and at the manipulated observation, extracted from the accumulators and timestamps. A 10% price change is set as a threshold. This percentage will avoid a "staircase attack" that's distributed among several blocks to avoid being detected.

  2. If the manipulated observation is considerably higher/lower than the observation after the manipulation. Again, we use the 10% threshold.

  3. If the observations before and after the manipulation are similar. We will not be that rigorous here, as arbitrage might be slow, and will check the difference is smaller than 20% to leave more wiggle room for arbitrage.

  4. If the observation before and after the manipulation are not affected. Those values are in sync with the thresholds used for the previous checks, as the TWAP corrected will average the before and after values. We computed this to be 23.5%.

If the oracles's user queries a time that overlaps the manipulation indexes, we will automatically return a TWAP to exclude this manipulation. We don't care if observations in between edges are manipulated or not, the correction will be applied for the whole chunk where manipulated edges were detected.

Triggering false positives is not a problem. A false positive would occur if the price jumps discretely 10% in a block and then falls back strong this same percentage. Correcting these false positives will only improve precision and avoid triggering false positives.

Once detected, we will "patch" the accumulator using the average tick value surrounding the manipulation.

Addresses

The addresses of the contracts deployed on the Goerli test network.

ContractGoerli
PoolManagerFactory0x91eF05914cfc905cB5D72D3257E987e13c6660a3
LockManagerFactory0xEEF5BE6A6703FC742F301341801a5e594678d90A
PoolManagerDeployer0x4240D34eFd81b1a7feB8A72C6A233467a187e618
FeeManager0xC14006a30Bd95fC8d70E25a1023f785E65991Dfd
PriceOracle0x7Da39c3Bc8665D83408177C40149efD1F1EFa538
Strategy0x09B2C32BC63FFdcfbDA259232D132355bD2D50A5
CardinalityJob0x826C035E277EDE8740182d42597edE1556AC6966
FeeCollectorJob0xE0f4E20B535AF8dDF0DdB60f8C6B3eB5ba84ce6E
LiquidityIncreaserJob0x81f809273d8a3E94A8406650A3d7d0faD6481696
PositionMinterJob0x3813B1D692F9407bf8070CEC5756FC4e980ab875
PositionBurnerJob0x0f5C604855BB0b418EacFA83E43D770Cc6b1b1Eb

Contents

ICardinalityJob

Git Source

Inherits: IKeep3rJob

Functions

poolManagerFactory

Returns the pool manager factory

function poolManagerFactory() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

minCardinalityIncrease

Returns the minimum increase of cardinality allowed

function minCardinalityIncrease() external view returns (uint16 _minCardinalityIncrease);

Returns

NameTypeDescription
_minCardinalityIncreaseuint16The minimum number of slots increases allowed

work

The function worked by the keeper, which will increase the pool cardinality

Requires enough WETH deposited for this pool to reimburse the gas consumption to the keeper

function work(IPoolManager _poolManager, uint16 _increaseAmount) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager of the pool for which the cardinality will be increased
_increaseAmountuint16The amount by which the cardinality will be increased

isWorkable

Checks if the job can be worked in the current block

function isWorkable(IPoolManager _poolManager, uint16 _increaseAmount) external view returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager of the pool for which the cardinality will be increased
_increaseAmountuint16The increased amount of the pool cardinality

Returns

NameTypeDescription
_workableboolIf the job is workable with the given inputs

isWorkable

Checks if the job can be worked in the current block by a specific keeper

function isWorkable(IPoolManager _poolManager, uint16 _increaseAmount, address _keeper)
    external
    returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager of the pool for which the cardinality will be increased
_increaseAmountuint16The increased amount of the pool cardinality
_keeperaddressThe address of the keeper

Returns

NameTypeDescription
_workableboolIf the job is workable with the given inputs

setMinCardinalityIncrease

Changes the min amount of cardinality increase per work

function setMinCardinalityIncrease(uint16 _minCardinalityIncrease) external;

Parameters

NameTypeDescription
_minCardinalityIncreaseuint16The new minimum number of slots

setPoolManagerFactory

Changes the pool manager factory

function setPoolManagerFactory(IPoolManagerFactory _poolManagerFactory) external;

Parameters

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe address of the new pool manager factory

getMinCardinalityIncreaseForPool

Calculates the minimum possible cardinality increase for a pool

function getMinCardinalityIncreaseForPool(IPoolManager _poolManager)
    external
    view
    returns (uint256 _minCardinalityIncrease);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager of the pool for which the cardinality will be increased

Returns

NameTypeDescription
_minCardinalityIncreaseuint256The minimum possible cardinality increase for the pool

Events

MinCardinalityIncreaseChanged

Emitted when the minimum cardinality increase amount allowed is changed

event MinCardinalityIncreaseChanged(uint16 _minCardinalityIncrease);

PoolManagerFactoryChanged

Emitted when the pool manager factory is changed

event PoolManagerFactoryChanged(IPoolManagerFactory _poolManagerFactory);

Worked

Emitted when the job is worked

event Worked(IPoolManager _poolManager, uint16 _increaseAmount);

Errors

CardinalityJob_MinCardinality

Thrown when the proposed cardinality increase is too low

error CardinalityJob_MinCardinality();

CardinalityJob_InvalidPoolManager

Thrown when working with an invalid pool manager

error CardinalityJob_InvalidPoolManager();

ICorrectionsApplierJob

Git Source

Inherits: IKeep3rJob

Applies corrections to manipulated pools

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

PRICE_ORACLE

Returns the price oracle

function PRICE_ORACLE() external view returns (IPriceOracle _priceOracle);

Returns

NameTypeDescription
_priceOracleIPriceOracleThe price oracle

work

Removes the old corrections for a given pool

function work(IUniswapV3Pool _pool, uint16 _manipulatedIndex, uint16 _period) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool
_manipulatedIndexuint16
_perioduint16

Events

Worked

Emitted when then job is worked

event Worked(IUniswapV3Pool _pool, uint16 _manipulatedIndex, uint16 _period);

Errors

CorrectionsApplierJob_InvalidPool

Throws if we can't verify the pool

error CorrectionsApplierJob_InvalidPool(IUniswapV3Pool _pool);

ICorrectionsRemoverJob

Git Source

Inherits: IKeep3rJob

Removes the old corrections for a given pool

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

PRICE_ORACLE

Returns the price oracle

function PRICE_ORACLE() external view returns (IPriceOracle _priceOracle);

Returns

NameTypeDescription
_priceOracleIPriceOracleThe price oracle

work

Removes the old corrections for a given pool

function work(IUniswapV3Pool _pool) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool

isWorkable

Returns true if the oracle has old corrections for the specified pool

function isWorkable(IUniswapV3Pool _pool) external view returns (bool _workable);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool

Returns

NameTypeDescription
_workableboolTrue if the pool can be worked

isWorkable

Returns true if the oracle has old corrections for the specified pool

function isWorkable(IUniswapV3Pool _pool, address _keeper) external returns (bool _workable);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool
_keeperaddressThe address of the keeper

Returns

NameTypeDescription
_workableboolTrue if the pool can be worked

Events

Worked

Emitted when then job is worked

event Worked(IUniswapV3Pool _pool);

Errors

CorrectionsRemoverJob_InvalidPool

Throws if we can't verify the pool

error CorrectionsRemoverJob_InvalidPool(IUniswapV3Pool _pool);

IFeeCollectorJob

Git Source

Inherits: IKeep3rJob

Functions

collectMultiplier

Returns the collect multiplier

function collectMultiplier() external view returns (uint256 _collectMultiplier);

Returns

NameTypeDescription
_collectMultiplieruint256The collect multiplier

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

work

Collects the fees from the given positions and rewards the keeper

Will revert if the job is paused or if the keeper is not valid

function work(IPoolManager _poolManager, IStrategy.Position[] calldata _positions) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_positionsPosition.IStrategy[]The list of positions to collect the fees from

work

Collects the fees from the full range and rewards the keeper

Will revert if the job is paused or if the keeper is not valid

function work(IPoolManager _poolManager) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

setCollectMultiplier

Sets the collect multiplier

Only governance can change it

function setCollectMultiplier(uint256 _collectMultiplier) external;

Parameters

NameTypeDescription
_collectMultiplieruint256The collect multiplier

Events

WorkedLockManager

Emitted when the job is worked

event WorkedLockManager(ILockManager _lockManager, IStrategy.Position[] _positions);

WorkedPoolManager

Emitted when the job is worked

event WorkedPoolManager(IPoolManager _poolManager);

CollectMultiplierSet

Emitted when the collect multiplier has been set

event CollectMultiplierSet(uint256 _collectMultiplier);

Errors

FeeCollectorJob_InvalidPoolManager

Thrown when the pool manager cannot be verified

error FeeCollectorJob_InvalidPoolManager(IPoolManager _poolManager);

IKeep3rJob

Git Source

Inherits: IPausable

Functions

keep3r

The address of the Keep3r contract

function keep3r() external view returns (IKeep3r _keep3r);

Returns

NameTypeDescription
_keep3rIKeep3rThe address of the token

requiredBond

The address of the keeper bond token

function requiredBond() external view returns (IERC20 _requiredBond);

Returns

NameTypeDescription
_requiredBondIERC20The address of the token

requiredMinBond

The minimum amount of bonded token required to bond by the keeper

function requiredMinBond() external view returns (uint256 _requiredMinBond);

Returns

NameTypeDescription
_requiredMinBonduint256The required min amount bond

requiredEarnings

The required earnings of the keeper

function requiredEarnings() external view returns (uint256 _requiredEarnings);

Returns

NameTypeDescription
_requiredEarningsuint256The required earnings

requiredAge

The age of the keeper in the Keep3r network

function requiredAge() external view returns (uint256 _requiredAge);

Returns

NameTypeDescription
_requiredAgeuint256The age of the keeper, in seconds

setKeep3r

Sets the address of the keeper

function setKeep3r(IKeep3r _keep3r) external;

Parameters

NameTypeDescription
_keep3rIKeep3rThe address of the keeper to be set

setKeep3rRequirements

Sets the keeper requirements

function setKeep3rRequirements(IERC20 _bond, uint256 _minBond, uint256 _earnings, uint256 _age) external;

Parameters

NameTypeDescription
_bondIERC20The required token to bond by keepers
_minBonduint256The minimum amount bound
_earningsuint256The earnings of the keeper
_ageuint256The age of the keeper in the Keep3r network

Events

Keep3rSet

Emitted a new keeper is set

event Keep3rSet(IKeep3r _keep3r);

Keep3rRequirementsSet

Emitted when setting new keeper requirements

event Keep3rRequirementsSet(IERC20 _bond, uint256 _minBond, uint256 _earnings, uint256 _age);

Errors

InvalidKeeper

Thrown when the caller is not a valid keeper in the Keep3r network

error InvalidKeeper();

IKeep3rMeteredJob

Git Source

Inherits: IKeep3rJob

Functions

keep3rHelper

Returns the address of the Keep3r helper contract

function keep3rHelper() external view returns (IKeep3rHelper _keep3rHelper);

Returns

NameTypeDescription
_keep3rHelperIKeep3rHelperAddress of the Keep3r helper contract

gasMultiplier

Returns the multiplier that boosts gas record to calculate the keeper reward

function gasMultiplier() external view returns (uint256 _gasMultiplier);

Returns

NameTypeDescription
_gasMultiplieruint256Multiplier that boosts gas record to calculate the keeper reward

setKeep3rHelper

Allows governor to set a new Keep3r helper contract

function setKeep3rHelper(IKeep3rHelper _keep3rHelper) external;

Parameters

NameTypeDescription
_keep3rHelperIKeep3rHelperAddress of the new Keep3r helper contract

setGasMultiplier

Allows governor to set a new gas multiplier

function setGasMultiplier(uint256 _gasMultiplier) external;

Parameters

NameTypeDescription
_gasMultiplieruint256New multiplier that boosts gas record to calculate the keeper reward

Events

Keep3rHelperChanged

Emitted when a new Keep3rHelper contract is set

event Keep3rHelperChanged(IKeep3rHelper _keep3rHelper);

GasMultiplierChanged

Emitted when a new gas bonus multiplier is set

event GasMultiplierChanged(uint256 _gasMultiplier);

GasMetered

Emitted when a metered job is worked

event GasMetered(uint256 _initialGas, uint256 _gasAfterWork);

ILiquidityIncreaserJob

Git Source

Inherits: IKeep3rJob

Functions

WETH

Returns the WETH contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

minIncreaseWeth

Returns the WETH-denominated amount of liquidity that must be added to the full-range position

function minIncreaseWeth() external view returns (uint256 _minIncreaseWeth);

Returns

NameTypeDescription
_minIncreaseWethuint256The minimum WETH increase

work

Increases the full-range position of a given pool manager

Will revert if the job is paused or if the keeper is not valid

function work(IPoolManager _poolManager, uint256 _wethAmount, uint256 _tokenAmount) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager
_wethAmountuint256The amount of WETH to be inserted in the full-range position
_tokenAmountuint256The amount of non-WETH token to be inserted in the full-range position

isWorkable

Returns true if the specified pool manager can be worked

function isWorkable(IPoolManager _poolManager) external returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager

Returns

NameTypeDescription
_workableboolTrue if the pool manager can be worked

isWorkable

Returns true if the specified keeper can work with the selected pool manager

function isWorkable(IPoolManager _poolManager, address _keeper) external returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager
_keeperaddressThe address of the keeper

Returns

NameTypeDescription
_workableboolTrue if the pool manager can be worked

setMinIncreaseWeth

Sets the new min WETH increase

function setMinIncreaseWeth(uint256 _minIncreaseWeth) external;

Parameters

NameTypeDescription
_minIncreaseWethuint256The min WETH increase

Events

Worked

Emitted when a fee manager is worked

event Worked(IPoolManager _poolManager, uint256 _amountWeth, uint256 _amountToken);

MinIncreaseWethSet

Emitted when the min WETH increase is set

event MinIncreaseWethSet(uint256 _minIncreaseWeth);

Errors

LiquidityIncreaserJob_InvalidPoolManager

Thrown when an invalid pool manager was passed to the job

error LiquidityIncreaserJob_InvalidPoolManager();

LiquidityIncreaserJob_PoolManipulated

Thrown when the price oracle detects a manipulation

error LiquidityIncreaserJob_PoolManipulated();

LiquidityIncreaserJob_InsufficientIncrease

Thrown when the job transfers less WETH and non-WETH token amounts to the pool than min WETH increase

error LiquidityIncreaserJob_InsufficientIncrease();

IPositionBurnerJob

Git Source

Inherits: IKeep3rJob

Runs the job handling the position burning in WETH/TOKEN pools

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

work

Burn the position in the lock manager and reward the keeper for doing so

Will revert if the job is paused or if the keeper is not valid

function work(IPoolManager _poolManager, IStrategy.Position memory _position) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager
_positionPosition.IStrategyThe position to be burned

isWorkable

Return true if the specified position can be burned

function isWorkable(IPoolManager _poolManager, IStrategy.Position memory _position) external returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager
_positionPosition.IStrategyThe position to burn

Returns

NameTypeDescription
_workableboolTrue if the position can be burned

isWorkable

Return true if the specified pool manager can be worked by the specified keeper

function isWorkable(IPoolManager _poolManager, IStrategy.Position memory _position, address _keeper)
    external
    returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager
_positionPosition.IStrategyThe position to burn
_keeperaddressThe address of the keeper

Returns

NameTypeDescription
_workableboolTrue if the position can be burned

Events

Worked

Emitted when a position was burned

event Worked(ILockManager _lockManager, IStrategy.Position _position);

Errors

PositionBurnerJob_InvalidPoolManager

Thrown when we can't verify the pool manager

error PositionBurnerJob_InvalidPoolManager(IPoolManager _poolManager);

IPositionMinterJob

Git Source

Inherits: IKeep3rJob

Runs the job handling the position creation in WETH/TOKEN pools

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

work

Creates the needed positions in the target pool manager and rewards the keeper for doing so

Will revert if the job is paused or if the keeper is not valid

function work(IPoolManager _poolManager) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager

isWorkable

Returns true if the specified pool manager can be worked

function isWorkable(IPoolManager _poolManager) external returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager

Returns

NameTypeDescription
_workableboolTrue if the pool manager can be worked

isWorkable

Returns true if the specified keeper can work with the target pool manager

function isWorkable(IPoolManager _poolManager, address _keeper) external returns (bool _workable);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe address of the target pool manager
_keeperaddressThe address of the keeper

Returns

NameTypeDescription
_workableboolTrue if the pool manager can be worked

Events

Worked

Emitted when a pool manager is worked

event Worked(IPoolManager _poolManager);

Errors

PositionMinterJob_InvalidPoolManager

Thrown when the pool manager cannot be verified

error PositionMinterJob_InvalidPoolManager(IPoolManager _poolManager);

Contents

IBribe

Git Source

Functions

userLatestInteraction

Returns the period when the user last interacted with a specific LockManager Bribe

function userLatestInteraction(address _user, ILockManager _lockManager) external view returns (uint256 _period);

Parameters

NameTypeDescription
_useraddressThe address of the user to check
_lockManagerILockManagerThe LockManager to check

Returns

NameTypeDescription
_perioduint256The number of the period

POOL_MANAGER_FACTORY

Returns the contract PoolManagerFactory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe PoolManagerFactory

createBribe

Creates and initializes a Bribery for a given LockManager

When a bribe is created we need to check if the previous finished or not

If it didn't then we have to add the tokens and amount to nextBribe

function createBribe(ILockManager _lockManager, IERC20 _bribeToken, uint256 _bribeAmount) external;

Parameters

NameTypeDescription
_lockManagerILockManagerThe address of the LockManager token to create a Bribery for
_bribeTokenIERC20The address of the Token to provide for the Bribery
_bribeAmountuint256The total amount to provide for the Bribery

deposit

Deposits an amount of LockManager to earn bribes

function deposit(ILockManager _lockManager, uint256 _amount) external;

Parameters

NameTypeDescription
_lockManagerILockManagerThe address of the LockManager to deposit
_amountuint256The amount to deposit

withdraw

Withdraws LockManager tokens deposited by the user

function withdraw(ILockManager _lockManager, uint256 _amount) external;

Parameters

NameTypeDescription
_lockManagerILockManagerThe address of the LockManager token to withdraw
_amountuint256The amount to withdraw

updateUserBalanceFromLastInteractionTo

Updates the user's balance from the last time he interacted till the specified period

function updateUserBalanceFromLastInteractionTo(ILockManager _lockManager, uint256 _toPeriod) external;

Parameters

NameTypeDescription
_lockManagerILockManagerThe LockManager to target
_toPerioduint256The period to update up to

claimRewards

Transfers the rewards of the Bribery to the caller for the specified tokens

function claimRewards(ILockManager _lockManager, IERC20[] memory _tokens, uint256 _fromPeriod, uint256 _toPeriod)
    external;

Parameters

NameTypeDescription
_lockManagerILockManagerThe address of the LockManager that the Bribery targets
_tokensIERC20[]The array of tokens that the user wants to claim
_fromPerioduint256The period to start claiming rewards from
_toPerioduint256The period to end claiming rewards from

Events

CreatedBribe

Emitted when someone creates a Bribery

event CreatedBribe(ILockManager _lockManager, IERC20 _bribeToken, uint256 _bribeAmount);

Deposit

Emitted when someones deposits an amount of LockManager to earn Bribery rewards

event Deposit(address _caller, ILockManager _lockManager, uint256 _amount);

Withdraw

Emitted when someones withdraws their LockManager

event Withdraw(address _caller, ILockManager _lockManager, uint256 _amount);

ClaimedRewards

Emitted when someone claims the Bribery rewards

event ClaimedRewards(address _user, IERC20 _token, uint256 _amount);

UpdatedUserBalance

Emitted when someone updates manually their balances

event UpdatedUserBalance(address _user, ILockManager _lockManager, uint256 _toPeriod);

Errors

Bribe_InvalidPoolManager

Thrown when the PoolManager is invalid

error Bribe_InvalidPoolManager();

Bribe_InvalidLockManager

Thrown when the LockManager is invalid

error Bribe_InvalidLockManager();

Bribe_TokenZeroAddress

Throws when trying to create a Bribery with bribe Token having the zero address

error Bribe_TokenZeroAddress();

Bribe_AmountZero

Throws when trying to create a Bribery with 0 bribe amount

error Bribe_AmountZero();

Bribe_NothingToWithdraw

Throws when trying to withdraw but there is nothing deposited

error Bribe_NothingToWithdraw();

Bribe_InvalidPeriod

Throws when trying to claim or update a user's balance with an invalid period

error Bribe_InvalidPeriod();

Bribe_InvalidWithdrawAmount

Throws when trying to withdraw a bigger amount than deposited

error Bribe_InvalidWithdrawAmount();

Bribe_NothingToUpdate

Throws when trying to update a user's balance but there is nothing to update

error Bribe_NothingToUpdate();

Structs

PeriodRewards

The Bribery Rewards information for a certain period

struct PeriodRewards {
    uint256 start;
    uint256 end;
    uint256 totalDeposited;
    IERC20[] bribeTokens;
    mapping(IERC20 => uint256) totalBribeAmountPerToken;
    mapping(address => uint256) userBalance;
    mapping(address => mapping(IERC20 => bool)) userHasClaimedToken;
}

IGovernorMiniBravo

Git Source

Functions

QUORUM

Returns the needed quorum for a proposal to pass

function QUORUM() external view returns (uint256 _quorum);

Returns

NameTypeDescription
_quorumuint256The needed quorum percentage

votingPower

Returns the voting power of a particular user

function votingPower(address _user) external view returns (uint256 _balance);

Parameters

NameTypeDescription
_useraddressThe user whose voting power will be returned

Returns

NameTypeDescription
_balanceuint256The voting power of the user

totalVotes

Returns the total available votes

function totalVotes() external view returns (uint256 _totalVotes);

Returns

NameTypeDescription
_totalVotesuint256The total available votes

isExecutable

Returns true if the latest proposal for the target method is executable

function isExecutable(uint256 _method) external view returns (bool _availableToExecute);

Parameters

NameTypeDescription
_methoduint256The method of the proposal

Returns

NameTypeDescription
_availableToExecuteboolTrue if the proposal is executable

executionTimelock

Returns the tome lock to execute transactions

function executionTimelock() external view returns (uint256 _executionTimelock);

Returns

NameTypeDescription
_executionTimelockuint256The time lock to execute transactions

cancelVote

Cancels a vote by a user on a particular method

function cancelVote(uint256 _method) external;

Parameters

NameTypeDescription
_methoduint256The method to subtract the votes

execute

Executes a particular proposal if it reaches quorum

function execute(uint256 _method, bytes memory _parameters) external;

Parameters

NameTypeDescription
_methoduint256The target method
_parametersbytesThe proposal parameters

getLatest

Returns the latest proposal created for a method

function getLatest(uint256 _method) external view returns (Proposal memory _proposal);

Parameters

NameTypeDescription
_methoduint256The target method proposal

Returns

NameTypeDescription
_proposalProposalThe latest proposal for the method

cancelProposal

Cancels a proposal

Admin can only call

function cancelProposal(uint256 _method) external;

Parameters

NameTypeDescription
_methoduint256The method proposal to cancel

queue

Queue a particular proposal if it reaches the required quorum

function queue(uint256 _method, bytes memory _parameters) external;

Parameters

NameTypeDescription
_methoduint256The method to be called when executed
_parametersbytesThe parameters for the proposal

quorumReached

Returns true if proposal reached the required quorum

function quorumReached(uint256 _method) external view returns (bool _quorumReached);

Parameters

NameTypeDescription
_methoduint256The method to be called when executed

Returns

NameTypeDescription
_quorumReachedboolTrue if the proposal is executable

Events

NewProposal

Emitted when a new proposal is created

event NewProposal(uint256 _id, uint256 _method, bytes _params);

NewVote

Emitted when a user votes on a proposal

event NewVote(address _voter, uint256 _votes, uint256 _method, uint256 _id);

ProposalCancelled

Emitted when a proposal is canceled

event ProposalCancelled(uint256 _id, uint256 _method, bytes _params);

ProposalExecuted

Emitted when a new proposal is executed

event ProposalExecuted(uint256 _id, uint256 _method, bytes _params);

VoteCancelled

Emitted when a voter cancels their vote

event VoteCancelled(address _voter, uint256 _method, uint256 _id);

ProposalQueued

Emitted when a proposal is queued

event ProposalQueued(uint256 _id, uint256 _method, bytes _params);

Errors

ProposalAlreadyQueued

Thrown when trying to queue a proposal that was already queued

error ProposalAlreadyQueued(uint256 _method, uint256 _id);

QuorumNotReached

Thrown when trying to queue a proposal that has not reached quorum

error QuorumNotReached(uint256 _method, uint256 _id);

ProposalNotExecutable

Thrown when trying to execute a proposal that is canceled or not on quorum

error ProposalNotExecutable(uint256 _method, uint256 _id);

ParametersMismatch

Thrown when parameters inputted do not match the saved parameters

error ParametersMismatch(uint256 _method, bytes _expectedParameters, bytes _actualParameters);

ProposalClosed

Thrown when the proposal is in a closed state

error ProposalClosed(uint256 _method, uint256 _id);

AlreadyVoted

Thrown when the voter already voted

error AlreadyVoted(uint256 _method, uint256 _id);

NoVotes

Thrown when a user tries to cancel their vote with 0 votes

error NoVotes();

Structs

Proposal

A proposal for a particular method call

struct Proposal {
    uint256 id;
    bytes params;
    uint256 forVotes;
    bool open;
    uint256 timelockExpiry;
}

ILockedWethSecondaryMarket

Git Source

This contract manages LockedWeth tokens sell orders

Functions

WETH

Returns the WETH contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

POOL_MANAGER_FACTORY

Returns the pool manager factory contract

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

sellOrders

Returns a sell order

function sellOrders(uint256 _orderId)
    external
    view
    returns (ILockManager _lockedWethToken, uint256 _id, uint256 _amount, address _owner, uint16 _discount);

Parameters

NameTypeDescription
_orderIduint256The order id

sellOrdersCount

Returns the sell orders count

function sellOrdersCount() external view returns (uint256 _sellOrdersCount);

Returns

NameTypeDescription
_sellOrdersCountuint256The sell orders count

postOrder

Posts a LockedWeth sell limit order

The amount is represented in WETH tokens The LockedWeth tokens remain in the poster account The discount value must be less than the discount precision

function postOrder(ILockManager _lockedWethToken, uint256 _amount, uint16 _discount) external;

Parameters

NameTypeDescription
_lockedWethTokenILockManagerThe locked WETH
_amountuint256The amount of LockedWeth tokens to be sold
_discountuint16The discount value

buyOrder

Buys a sell order

The sell order is bought with WETH tokens and cannot be purchased partially

function buyOrder(uint256 _orderId) external;

Parameters

NameTypeDescription
_orderIduint256The id of the sell order to be bought

cancelOrder

Cancels a sell order

The caller must be the order owner

function cancelOrder(uint256 _orderId) external;

Parameters

NameTypeDescription
_orderIduint256The id of the order to be canceled

getSellOrders

Returns pagination of the orders posted

Minimum _startFrom is 1; ids start from 1

function getSellOrders(uint256 _startFrom, uint256 _amount) external returns (SellOrder[] memory _sellOrders);

Parameters

NameTypeDescription
_startFromuint256The index from where to start the pagination
_amountuint256The maximum amount of orders to retrieve

Returns

NameTypeDescription
_sellOrdersSellOrder[]The paginated orders posted

Events

SellOrderPosted

Emitted when a new LockedWeth sell order is posted

event SellOrderPosted(SellOrder _order);

SellOrderBought

Emitted when a sell order is bought

event SellOrderBought(SellOrder _order, address _buyer);

SellOrderCancelled

Emitted when a sell order is canceled

event SellOrderCancelled(SellOrder _order);

Errors

LockedWethSecondaryMarket_InvalidPoolManager

Thrown when the pool manager is invalid

error LockedWethSecondaryMarket_InvalidPoolManager(IPoolManager _poolManager);

LockedWethSecondaryMarket_InvalidLockManager

Thrown when the lock manager is invalid

error LockedWethSecondaryMarket_InvalidLockManager(ILockManager _lockManager);

LockedWethSecondaryMarket_ZeroAmount

Thrown when the order amount is zero

error LockedWethSecondaryMarket_ZeroAmount();

LockedWethSecondaryMarket_MaxDiscountExceeded

Thrown when the discount value exceeds the max discount

error LockedWethSecondaryMarket_MaxDiscountExceeded(uint16 _discount, uint16 _maxDiscount);

LockedWethSecondaryMarket_NotOrderOwner

Thrown when trying to delete an order and the caller is not the owner

error LockedWethSecondaryMarket_NotOrderOwner(uint256 _orderId);

LockedWethSecondaryMarket_OrderNotAvailable

Thrown when trying to buy a sell order whose amount is zero

The order could not be available because it was already sold or canceled

error LockedWethSecondaryMarket_OrderNotAvailable(uint256 _orderId);

Structs

SellOrder

The sell order

struct SellOrder {
    ILockManager lockedWethToken;
    uint256 id;
    uint256 amount;
    address owner;
    uint16 discount;
}

IPriceOracle

Git Source

This contract allows you to get the price of different assets through WETH pools

Functions

CORRECTION_DELAY

Returns the correction delay

The delay should be big enough for the attack to not be arbitraged and hence detected by the contract

function CORRECTION_DELAY() external view returns (uint32);

Returns

NameTypeDescription
<none>uint32The the correction delay

MIN_CORRECTION_PERIOD

Returns the minumum correction period

function MIN_CORRECTION_PERIOD() external view returns (uint32);

Returns

NameTypeDescription
<none>uint32The minumum correction period

MAX_CORRECTION_AGE

Returns the maximum correction age

function MAX_CORRECTION_AGE() external view returns (uint32);

Returns

NameTypeDescription
<none>uint32The maximum correction age

UPPER_TICK_DIFF_10

Returns the upper tick difference for the 10% price change

function UPPER_TICK_DIFF_10() external view returns (int24);

Returns

NameTypeDescription
<none>int24The upper tick difference for the 10% price change

LOWER_TICK_DIFF_10

Returns the lower tick difference for the 10% price change

function LOWER_TICK_DIFF_10() external view returns (int24);

Returns

NameTypeDescription
<none>int24The lower tick difference for the 10% price change

UPPER_TICK_DIFF_20

Returns the upper tick difference for the 20% price change

function UPPER_TICK_DIFF_20() external view returns (int24);

Returns

NameTypeDescription
<none>int24The upper tick difference for the 20% price change

LOWER_TICK_DIFF_20

Returns the lower tick difference for the 20% price change

function LOWER_TICK_DIFF_20() external view returns (int24);

Returns

NameTypeDescription
<none>int24The lower tick difference for the 20% price change

UPPER_TICK_DIFF_23_5

Returns the upper tick difference for the 23.5% price change

function UPPER_TICK_DIFF_23_5() external view returns (int24);

Returns

NameTypeDescription
<none>int24The upper tick difference for the 23.5% price change

LOWER_TICK_DIFF_23_5

Returns the lower tick difference for the 23.5% price change

function LOWER_TICK_DIFF_23_5() external view returns (int24);

Returns

NameTypeDescription
<none>int24The lower tick difference for the 23.5% price change

UPPER_TICK_DIFF_30

Returns the upper tick difference for the 30% price change

function UPPER_TICK_DIFF_30() external view returns (int24);

Returns

NameTypeDescription
<none>int24The upper tick difference for the 30% price change

LOWER_TICK_DIFF_30

Returns the lower tick difference for the 30% price change

function LOWER_TICK_DIFF_30() external view returns (int24);

Returns

NameTypeDescription
<none>int24The lower tick difference for the 30% price change

UNISWAP_V3_FACTORY

Returns the UniswapV3 factory contract

function UNISWAP_V3_FACTORY() external view returns (IUniswapV3Factory _uniswapV3Factory);

Returns

NameTypeDescription
_uniswapV3FactoryIUniswapV3FactoryThe UniswapV3 factory contract

POOL_BYTECODE_HASH

Returns the UniswapV3 pool bytecode hash

function POOL_BYTECODE_HASH() external view returns (bytes32 _poolBytecodeHash);

Returns

NameTypeDescription
_poolBytecodeHashbytes32The UniswapV3 pool bytecode hash

WETH

Returns the WETH token

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

isPairSupported

Returns true if a pair is supported on the oracle

function isPairSupported(IERC20 _tokenA, IERC20 _tokenB) external view returns (bool _isSupported);

Parameters

NameTypeDescription
_tokenAIERC20TokenA for the pair
_tokenBIERC20TokenB for the pair

Returns

NameTypeDescription
_isSupportedboolTrue if the pair is supported on the oracle

quoteCache

Returns the price of a given amount of tokenA quoted in tokenB using the cache if available

function quoteCache(uint256 _baseAmount, IERC20 _tokenA, IERC20 _tokenB, uint32 _period, uint24 _maxCacheAge)
    external
    returns (uint256 _quoteAmount);

Parameters

NameTypeDescription
_baseAmountuint256The amount of tokenA to quote
_tokenAIERC20Token to quote in tokenB
_tokenBIERC20The quote token
_perioduint32The period to quote
_maxCacheAgeuint24Ignore the cached quote if it's older than the max age, in seconds

Returns

NameTypeDescription
_quoteAmountuint256The quoted amount of tokenA in tokenB

applyCorrection

Applies a price correction to the pool

function applyCorrection(IUniswapV3Pool _pool, uint16 _manipulatedIndex, uint16 _period) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address
_manipulatedIndexuint16The index of the observation that will be corrected
_perioduint16How many observations the manipulation affected

removeOldCorrections

Removes old corrections to potentially increase gas efficiency on quote)

function removeOldCorrections(IUniswapV3Pool _pool) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address

poolCorrectionsCount

Returns the number of the corrections for a pool

function poolCorrectionsCount(IUniswapV3Pool _pool) external view returns (uint256 _correctionsCount);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address

Returns

NameTypeDescription
_correctionsCountuint256The number of the corrections for a pool

getOldestCorrectionTimestamp

Returns the timestamp of the oldest correction for a given pool

Returns 0 if there is no corrections for the pool

function getOldestCorrectionTimestamp(IUniswapV3Pool _pool) external view returns (uint256 _timestamp);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address

Returns

NameTypeDescription
_timestampuint256The timestamp of the oldest correction for a given pool

listPoolCorrections

Lists all corrections for a pool

function listPoolCorrections(IUniswapV3Pool _pool, uint256 _startFrom, uint256 _amount)
    external
    view
    returns (Correction[] memory _poolCorrections);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address
_startFromuint256Index from where to start the pagination
_amountuint256Maximum amount of corrections to retrieve

Returns

NameTypeDescription
_poolCorrectionsCorrection[]Paginated corrections of the pool

quote

Provides the quote taking into account any corrections happened during the provided period

function quote(uint256 _baseAmount, IERC20 _baseToken, IERC20 _quoteToken, uint32 _period)
    external
    view
    returns (uint256 _quoteAmount);

Parameters

NameTypeDescription
_baseAmountuint256The amount of base token
_baseTokenIERC20The base token address
_quoteTokenIERC20The quote token address
_perioduint32The TWAP period

Returns

NameTypeDescription
_quoteAmountuint256The quote amount

isManipulated

Return true if the pool was manipulated

function isManipulated(IUniswapV3Pool _pool) external view returns (bool _manipulated);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address

Returns

NameTypeDescription
_manipulatedboolWhether the pool is manipulated or not

isManipulated

Return true if the pool has been manipulated

function isManipulated(
    IUniswapV3Pool _pool,
    int24 _lowerTickDifference,
    int24 _upperTickDifference,
    uint32 _correctionPeriod
) external view returns (bool _manipulated);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address
_lowerTickDifferenceint24The maximum difference between the lower ticks before and after the correction
_upperTickDifferenceint24The maximum difference between the upper ticks before and after the correction
_correctionPerioduint32The correction period

Returns

NameTypeDescription
_manipulatedboolWhether the pool is manipulated or not

getPoolTickWithCorrections

Returns the TWAP for the given period taking into account any corrections happened during the period

function getPoolTickWithCorrections(IUniswapV3Pool _pool, uint32 _period)
    external
    view
    returns (int24 _arithmeticMeanTick);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe Uniswap V3 pool address
_perioduint32The TWAP period, in seconds

Returns

NameTypeDescription
_arithmeticMeanTickint24The TWAP

Errors

PriceOracle_ExceededVolatility

Thrown when volatility in period is higher than accepted

error PriceOracle_ExceededVolatility();

PriceOracleBase_TokenNotSupported

Throws if the token is not supported

error PriceOracleBase_TokenNotSupported();

PriceOracleCorrections_InvalidSecondsAgosOrder

Throws if the seconds ago order should be reversed

error PriceOracleCorrections_InvalidSecondsAgosOrder();

PriceOracleCorrections_BaseAmountOverflow

Throws if base amount overflows uint128

error PriceOracleCorrections_BaseAmountOverflow();

PriceOracleCorrections_EdgeTicksTooDifferent

Throws when edge ticks are not similar enough

error PriceOracleCorrections_EdgeTicksTooDifferent();

PriceOracleCorrections_EdgeTicksAverageTooDifferent

Throws when observations either before or after the manipulation were also manipulated

error PriceOracleCorrections_EdgeTicksAverageTooDifferent();

PriceOracleCorrections_TicksBeforeAndAtManipulationStartAreTooSimilar

Throws when the difference between the tick before manipulation and the tick at the start of manipulation is not big enough

error PriceOracleCorrections_TicksBeforeAndAtManipulationStartAreTooSimilar();

PriceOracleCorrections_TicksAfterAndAtManipulationStartAreTooSimilar

Throws when the difference between the tick after manipulation and the tick at the start of manipulation is not big enough

error PriceOracleCorrections_TicksAfterAndAtManipulationStartAreTooSimilar();

PriceOracleCorrections_TicksAfterAndAtManipulationEndAreTooSimilar

Throws when the difference between the tick after manipulation and the tick at the end of manipulation is not big enough

error PriceOracleCorrections_TicksAfterAndAtManipulationEndAreTooSimilar();

PriceOracleCorrections_PoolNotSupported

Throws when trying to apply the correction to a pool we didn't deploy

error PriceOracleCorrections_PoolNotSupported();

PriceOracleCorrections_ManipulationAlreadyProcessed

Throws when trying to correct a manipulation that was already corrected

error PriceOracleCorrections_ManipulationAlreadyProcessed();

PriceOracleCorrections_AfterObservationIsNotNewer

Throws when the observation after the manipulation observation has not yet happened

error PriceOracleCorrections_AfterObservationIsNotNewer();

PriceOracleCorrections_NoCorrectionsToRemove

Throws when there are no corrections for removal

error PriceOracleCorrections_NoCorrectionsToRemove();

PriceOracleCorrections_PeriodTooShort

Throws when an invalid period was supplied

error PriceOracleCorrections_PeriodTooShort();

PriceOracleCorrections_PeriodTooLong

Throws when the supplied period exceeds the maximum correction age

The danger of using a long period lies in the fact that obsolete corrections will eventually be removed. Thus the oracle would return un-corrected, possibly manipulated data.

error PriceOracleCorrections_PeriodTooLong();

PriceOracleCorrections_AfterObservationCannotBeCalculatedOnSameBlock

Throws when it's not possible to calculate the after observation, nor force it with burn1, just wait 1 block and retry

error PriceOracleCorrections_AfterObservationCannotBeCalculatedOnSameBlock();

Structs

QuoteCache

A quote saved in a particular timestamp to use as cache

struct QuoteCache {
    uint256 quote;
    uint256 timestamp;
}

Correction

The correction information

struct Correction {
    int56 amount;
    uint32 beforeTimestamp;
    uint32 afterTimestamp;
}

Observation

The observation information, copied from the Uniswap V3 oracle library

struct Observation {
    uint32 blockTimestamp;
    int56 tickCumulative;
    uint160 secondsPerLiquidityCumulativeX128;
    bool initialized;
}

CorrectionObservations

Keeps the list of the applied corrections

struct CorrectionObservations {
    Observation[] manipulated;
    Observation beforeManipulation;
    Observation afterManipulation;
    Observation postAfterManipulation;
}

Contents

IStrategy

Git Source

Functions

MIN_WETH_TO_MINT

The minimum amount of WETH that can be minted into a new position

Remember safe deployment for min width is 1 ETH these amounts are already considering the 1/2 minting

function MIN_WETH_TO_MINT() external view returns (uint256 _minWethToMint);

Returns

NameTypeDescription
_minWethToMintuint256The minimum amount of WETH that can be minted into a new position

MAX_WETH_TO_MINT

The maximum amount of WETH that can be minted into a new position

function MAX_WETH_TO_MINT() external view returns (uint256 _maxWethToMint);

Returns

NameTypeDescription
_maxWethToMintuint256The maximum amount of WETH that can be minted into a new position

PERCENT_WETH_TO_MINT

50% of idle WETH per mint is used

function PERCENT_WETH_TO_MINT() external view returns (uint256 _percentWethToMint);

Returns

NameTypeDescription
_percentWethToMintuint256What percentage of idle WETH to use for minting

LOWER_BURN_DIFF

How far to the right from the current tick a position should be in order to be burned

function LOWER_BURN_DIFF() external view returns (int24 _lowerBurnDiff);

Returns

NameTypeDescription
_lowerBurnDiffint24The tick difference

UPPER_BURN_DIFF

How far to the left from the current tick a position should be in order to be burned

function UPPER_BURN_DIFF() external view returns (int24 _upperBurnDiff);

Returns

NameTypeDescription
_upperBurnDiffint24The tick difference

VOLATILITY_SAFE_RANGE_MIN

The top of the safe range for volatility

function VOLATILITY_SAFE_RANGE_MIN() external view returns (uint256 _volatilitySafeRangeMin);

Returns

NameTypeDescription
_volatilitySafeRangeMinuint256_volatilitySafeRangeMin

VOLATILITY_SAFE_RANGE_MAX

The bottom of the safe range for volatility

function VOLATILITY_SAFE_RANGE_MAX() external view returns (uint256 _volatilitySafeRangeMax);

Returns

NameTypeDescription
_volatilitySafeRangeMaxuint256_volatilitySafeRangeMax

getPositionToMint

Returns the next position to mint

function getPositionToMint(IStrategy.LockManagerState calldata _lockManagerState)
    external
    view
    returns (IStrategy.LiquidityPosition memory _positionToMint);

Returns

NameTypeDescription
_positionToMintLiquidityPosition.IStrategyThe position

getPositionToBurn

Returns the next position to burn

function getPositionToBurn(
    IStrategy.Position calldata _position,
    uint128 _positionLiquidity,
    IStrategy.LockManagerState calldata _lockManagerState
) external view returns (IStrategy.LiquidityPosition memory _positionToBurn);

Parameters

NameTypeDescription
_positionPosition.IStrategyThe position to burn, without liquidity
_positionLiquidityuint128The liquidity in the position
_lockManagerStateLockManagerState.IStrategy

Returns

NameTypeDescription
_positionToBurnLiquidityPosition.IStrategyThe position to burn, with liquidity

Errors

Strategy_PoolManipulated

Thrown when the price oracle detects a manipulation

error Strategy_PoolManipulated();

Strategy_NotEnoughWeth

Thrown when minting a position requires more WETH than available in the lock manager

error Strategy_NotEnoughWeth();

Strategy_NotFarEnoughToLeft

Thrown when the position to burn is too close to the current tick

error Strategy_NotFarEnoughToLeft();

Strategy_NotFarEnoughToRight

Thrown when the position to burn is too close to the current tick

error Strategy_NotFarEnoughToRight();

Structs

LockManagerState

Lock manager variables needed for the strategy

struct LockManagerState {
    IPoolManager poolManager;
    IUniswapV3Pool pool;
    uint256 availableWeth;
    bool isWethToken0;
    int24 tickSpacing;
}

Position

UniswapV3 pool position

struct Position {
    int24 lowerTick;
    int24 upperTick;
}

LiquidityPosition

UniswapV3 pool position with the amount of liquidity

struct LiquidityPosition {
    int24 lowerTick;
    int24 upperTick;
    uint128 liquidity;
}

IFeeManager

Git Source

This contract accumulates the fees collected from UniswapV3 pools for later use

Functions

WETH

Returns the WETH token contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

poolManagerDeposits

Returns the amount of fees collected by a pool manager

function poolManagerDeposits(IPoolManager _poolManager)
    external
    view
    returns (uint256 wethForFullRange, uint256 tokenForFullRange);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Returns

NameTypeDescription
wethForFullRangeuint256The amount of WETH dedicated to increasing the full-range position
tokenForFullRangeuint256The amount of non-WETH tokens dedicated to increasing the full-range position

poolCardinality

Returns information about the pool cardinality

function poolCardinality(IPoolManager _poolManager)
    external
    view
    returns (uint256 weth, uint16 currentMax, uint16 customMax);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Returns

NameTypeDescription
wethuint256The amount of WETH to increase the cardinality
currentMaxuint16The maximum value of the cardinality in a pool
customMaxuint16The maximum value of the cardinality in a pool set by the governance

poolDistribution

Returns the distribution percentages in a pool

function poolDistribution(IPoolManager _poolManager)
    external
    view
    returns (uint256 wethForMaintenance, uint256 wethForCardinality, bool isInitialized);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Returns

NameTypeDescription
wethForMaintenanceuint256The WETH for maintenance fees percentage
wethForCardinalityuint256The WETH for cardinality fees percentage
isInitializedboolTrue if the pool is initialized

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

cardinalityJob

Returns the cardinality job

function cardinalityJob() external view returns (ICardinalityJob _cardinalityJob);

Returns

NameTypeDescription
_cardinalityJobICardinalityJobThe cardinality job

maintenanceGovernance

Returns the address that receives the maintenance fee in WETH

function maintenanceGovernance() external view returns (address _maintenanceGovernance);

Returns

NameTypeDescription
_maintenanceGovernanceaddressThe address that receives the maintenance fee in WETH

poolCardinalityMax

Returns the maximum value of cardinality

655 max cardinality array length

function poolCardinalityMax() external view returns (uint16 _poolCardinalityMax);

Returns

NameTypeDescription
_poolCardinalityMaxuint16The maximum value of cardinality

swapGasCostMultiplier

Returns the gas multiplier used to calculate the cost of swapping non-WETH token to WETH

This calculates whether the cost of the swap will be higher than the amount to be swapped

function swapGasCostMultiplier() external view returns (uint256 _swapGasCostMultiplier);

Returns

NameTypeDescription
_swapGasCostMultiplieruint256The value to calculate whether the swap is profitable

depositFromPoolManager

Updates the record for fees collected from the pool manager

Splits the deposited fees into parts for different purposes

The fees from concentrated and full-range positions are handled differently

function depositFromPoolManager(uint256 _wethFees, uint256 _tokenFees) external;

Parameters

NameTypeDescription
_wethFeesuint256The total amount of WETH fees collected from the pool
_tokenFeesuint256The total amount of non-WETH token fees collected from the pool

depositFromLockManager

Updates the record for fees collected from the lock manager

Splits the deposited fees into parts for different purposes

The fees from concentrated and full-range positions are handled differently

function depositFromLockManager(uint256 _wethFees, uint256 _tokenFees) external;

Parameters

NameTypeDescription
_wethFeesuint256The total amount of WETH fees collected from the pool
_tokenFeesuint256The total amount of non-WETH token fees collected from the pool

increaseFullRangePosition

Transfers the necessary amount of WETH and token to increase the full range of a specific pool

Update the balances of tokens intended to increase the full-range position

If necessary, it will swap tokens for WETH.

function increaseFullRangePosition(
    IUniswapV3Pool _pool,
    IERC20 _token,
    uint256 _neededWeth,
    uint256 _neededToken,
    bool _isWethToken0
) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe pool that needs to increase the full range
_tokenIERC20The token that corresponds to the pool that needs to increase the full range
_neededWethuint256The amount of WETH needed for increase the full range
_neededTokenuint256The amount of token needed for increase the full range
_isWethToken0boolTrue if WETH is token0 in the pool

fullRangeCallback

Transfers the necessary amount of WETH and token to increase the full range of a specific pool

Callback that is called after uniswapV3MintCallback from PoolManager if the donor is the FeeManager

Updates the balances of WETH and token intended to increase the full-range position

function fullRangeCallback(IUniswapV3Pool _pool, IERC20 _token, uint256 _neededWeth, uint256 _neededToken) external;

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe pool that need to increase the full range
_tokenIERC20The token that corresponds to the pool that needs to increase the full range
_neededWethuint256The amount of WETH needed to increase the full range
_neededTokenuint256The amount of token needed to increase the full range

uniswapV3SwapCallback

Callback that is called when calling the swap method in a UniswapV3 pool

It is only called when you need to swap non-WETH tokens for WETH

function uniswapV3SwapCallback(int256 _amount0Delta, int256 _amount1Delta, bytes calldata _data) external;

Parameters

NameTypeDescription
_amount0Deltaint256The amount of token0
_amount1Deltaint256The amount of token1
_databytesThe data that differentiates through an address whether to mint or transferFrom for the full range

increaseCardinality

Updates the cardinality in a pool

This method only can be called by the cardinality job

function increaseCardinality(IPoolManager _poolManager, uint256 _weth, uint16 _cardinality) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_wethuint256The amount of WETH
_cardinalityuint16The custom cardinality value

migrateTo

Migrates to a new fee manager

Should be called from a valid lock manager

function migrateTo(IFeeManager _newFeeManager) external;

Parameters

NameTypeDescription
_newFeeManagerIFeeManagerThe new fee manager

migrateFrom

Migrates from an old fee manager

Should be called from the old fee manager

Receives WETH and non-WETH tokens from the old fee manager

function migrateFrom(
    IPoolManager _poolManager,
    PoolCardinality memory _poolCardinality,
    FeeStore memory _poolManagerDeposits,
    PoolDistributionFees memory _poolDistributionFees
) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager that is migrating its fee manager
_poolCardinalityPoolCardinalityThe current pool cardinality
_poolManagerDepositsFeeStoreThe liquidity to deploy for the full range
_poolDistributionFeesPoolDistributionFeesThe distribution fees of the pool

setSwapGasCostMultiplier

Set the swap gas multiplier

This method only can be called by governance

function setSwapGasCostMultiplier(uint256 _swapGasCostMultiplier) external;

Parameters

NameTypeDescription
_swapGasCostMultiplieruint256The value of the gas multiplier that will be set

setCardinalityJob

Sets the cardinality job

function setCardinalityJob(ICardinalityJob _cardinalityJob) external;

Parameters

NameTypeDescription
_cardinalityJobICardinalityJobThe cardinality job

setPoolCardinalityMax

Sets the maximum value to increase the cardinality

function setPoolCardinalityMax(uint16 _poolCardinalityMax) external;

Parameters

NameTypeDescription
_poolCardinalityMaxuint16The maximum value

setPoolCardinalityTarget

Sets a custom maximum value to increase cardinality

function setPoolCardinalityTarget(IPoolManager _poolManager, uint16 _cardinality) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_cardinalityuint16The custom cardinality value

setMaintenanceGovernance

Sets maintenance governance address

function setMaintenanceGovernance(address _maintenanceGovernance) external;

Parameters

NameTypeDescription
_maintenanceGovernanceaddressThe address that has to receive the maintenance WETH

setWethForMaintenance

Sets the percentage of the WETH fees for maintenance

function setWethForMaintenance(IPoolManager _poolManager, uint256 _wethForMaintenance) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_wethForMaintenanceuint256The percentage of the WETH fees for maintenance

setWethForCardinality

Sets the percentage of the WETH fees for cardinality

function setWethForCardinality(IPoolManager _poolManager, uint256 _wethForCardinality) external;

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager
_wethForCardinalityuint256The percentage of the WETH fees for cardinality

getMaxCardinalityForPool

Returns the max cardinality for a pool

function getMaxCardinalityForPool(IPoolManager _poolManager) external view returns (uint256 _maxCardinality);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

Events

FeesDeposited

Emitted when the fees are deposited

event FeesDeposited(
    IPoolManager _poolManager,
    uint256 _wethFees,
    uint256 _tokenFees,
    uint256 _wethForMaintenance,
    uint256 _wethForCardinality
);

SwapGasCostMultiplierChanged

Emitted when the swap gas cost multiplier has been changed

event SwapGasCostMultiplierChanged(uint256 _swapGasCostMultiplier);

CardinalityJobSet

Emitted when the cardinality job is set

event CardinalityJobSet(ICardinalityJob _cardinalityJob);

MaintenanceGovernanceChanged

Emitted when the maintenance governance address has been changed

event MaintenanceGovernanceChanged(address _maintenanceGovernance);

WethForMaintenanceChanged

Emitted when the fees percentage of WETH for maintenance has been changed

event WethForMaintenanceChanged(uint256 _wethForMaintenance);

WethForCardinalityChanged

Emitted when the fees percentage of WETH for cardinality has been changed

event WethForCardinalityChanged(uint256 _wethForCardinality);

Migrated

Emitted when an old fee manager migrates to a new fee manager

event Migrated(address _poolManager, address _oldFeeManager, address _newFeeManager);

Errors

FeeManager_InvalidPoolManager

Thrown when we can't verify the pool manager

error FeeManager_InvalidPoolManager(IPoolManager _poolManager);

FeeManager_InvalidLockManager

Thrown when we can't verify the lock manager

error FeeManager_InvalidLockManager(ILockManager _lockManager);

FeeManager_InvalidOldFeeManager

Thrown when we can't verify the old fee manager

error FeeManager_InvalidOldFeeManager(IFeeManager _feeManager);

FeeManager_InvalidPoolManagerFactory

Thrown when we can't verify the pool manager factory

error FeeManager_InvalidPoolManagerFactory();

FeeManager_InvalidUniswapPool

Thrown when we can't verify the UniswapV3 pool

error FeeManager_InvalidUniswapPool(address _sender);

FeeManager_ExcessiveLiquidityLeft

Thrown when excess liquidity for the full range has been left over

error FeeManager_ExcessiveLiquidityLeft();

FeeManager_InvalidTokenLiquidity

Thrown when the liquidity provided of the token is incorrect

error FeeManager_InvalidTokenLiquidity();

FeeManager_SmallSwap

Thrown when the amount of ETH to get is less than the fees spent on the swap

error FeeManager_SmallSwap();

FeeManager_NotCardinalityJob

Thrown when the sender is not the cardinality job

error FeeManager_NotCardinalityJob();

FeeManager_CardinalityExceeded

Thrown when the cardinality is greater than the maximum

error FeeManager_CardinalityExceeded();

FeeManager_NonZeroCardinality

Thrown when trying to migrate fee managers, but cardinality of the pool was already initialized

error FeeManager_NonZeroCardinality();

FeeManager_NonZeroPoolDeposits

Thrown when trying to migrate fee managers, but the pool manager deposits were already initialized

error FeeManager_NonZeroPoolDeposits();

FeeManager_InitializedPoolDistribution

Thrown when trying to migrate fee managers, but pool manager distribution was already initialized

error FeeManager_InitializedPoolDistribution();

FeeManager_WethForMaintenanceExceeded

Thrown when the WETH for maintenance is greater than the maximum

error FeeManager_WethForMaintenanceExceeded();

FeeManager_WethForCardinalityExceeded

Thrown when the WETH for cardinality is greater than the maximum

error FeeManager_WethForCardinalityExceeded();

Structs

FeeStore

Total fees deposited by a pool manager

struct FeeStore {
    uint256 wethForFullRange;
    uint256 tokenForFullRange;
}

PoolCardinality

The values intended for cardinality incrementation

struct PoolCardinality {
    uint256 weth;
    uint16 currentMax;
    uint16 customMax;
}

PoolDistributionFees

The percentages of the fees directed to the maintenance and increasing cardinality

struct PoolDistributionFees {
    uint256 wethForMaintenance;
    uint256 wethForCardinality;
    bool isInitialized;
}

ILockManager

Git Source

Inherits: IERC20, ILockManagerGovernor

This contract allows users to lock WETH and claim fees from the concentrated positions.

Functions

WETH

Returns the WETH contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

poolRewards

Returns the status of a corresponding pool manager

function poolRewards() external view returns (uint256 wethPerLockedWeth, uint256 tokenPerLockedWeth);

Returns

NameTypeDescription
wethPerLockedWethuint256The value of the reward per WETH locked
tokenPerLockedWethuint256The value of the reward per Token locked

POOL

Returns the underlying uni v3 pool contract

function POOL() external view returns (IUniswapV3Pool _pool);

Returns

NameTypeDescription
_poolIUniswapV3PoolThe underlying uni v3 pool contract

POOL_MANAGER

Returns the pool manager contract

function POOL_MANAGER() external view returns (IPoolManager _poolManager);

Returns

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

IS_WETH_TOKEN0

Returns true if WETH token is the token0

function IS_WETH_TOKEN0() external view returns (bool _isWethToken0);

Returns

NameTypeDescription
_isWethToken0boolIf WETH is token0

userRewards

Returns the pending to the corresponding account

function userRewards(address _account)
    external
    view
    returns (uint256 wethPaid, uint256 tokenPaid, uint256 wethAvailable, uint256 tokenAvailable);

Parameters

NameTypeDescription
_accountaddressThe address of the account

Returns

NameTypeDescription
wethPaiduint256The amount of the claimed rewards in WETH
tokenPaiduint256The amount of the claimed rewards in non-WETH token
wethAvailableuint256The amount of the pending rewards in WETH
tokenAvailableuint256The amount of the pending rewards in non-WETH token

withdrawalData

Returns the withdrawal data

function withdrawalData() external view returns (bool withdrawalsEnabled, uint256 totalWeth, uint256 totalToken);

Returns

NameTypeDescription
withdrawalsEnabledboolTrue if lock manager is deprecated and all positions have been unwound
totalWethuint256The total amount of WETH to distribute between lockers
totalTokenuint256the total amount of non-WETH token to distribute between lockers

STRATEGY

Returns the strategy

function STRATEGY() external view returns (IStrategy _strategy);

Returns

NameTypeDescription
_strategyIStrategyThe strategy

FEE

Returns the fee of the pool manager

function FEE() external view returns (uint24 _fee);

Returns

NameTypeDescription
_feeuint24The fee

TOKEN

Returns the non-WETH token contract of the underlying pool

function TOKEN() external view returns (IERC20 _token);

Returns

NameTypeDescription
_tokenIERC20The non-WETH token contract of the underlying pool

concentratedWeth

Returns the total amount of WETH minted by this lock manager

function concentratedWeth() external view returns (uint256 _concentratedWeth);

Returns

NameTypeDescription
_concentratedWethuint256The total amount of WETH in use by this lock manager

claimable

Get the total WETH claimable for a given account and pool manager

This value is calculated by adding the balance and unclaimed rewards.

function claimable(address _account) external view returns (uint256 _wethClaimable, uint256 _tokenClaimable);

Parameters

NameTypeDescription
_accountaddressThe address of the account

Returns

NameTypeDescription
_wethClaimableuint256The amount of WETH claimable
_tokenClaimableuint256The amount of Token claimable

lock

Lock the amount of WETH token provided by the caller

Same amount of WETH lock token will be provided

function lock(uint256 _wethAmount) external;

Parameters

NameTypeDescription
_wethAmountuint256The amount of WETH tokens that the caller wants to provide

claimRewards

Returns the rewards generated by a caller in a specific pool manager

function claimRewards(address _to) external returns (uint256 _rewardWeth, uint256 _rewardToken);

Parameters

NameTypeDescription
_toaddressThe recipient of these rewards

Returns

NameTypeDescription
_rewardWethuint256The amount of rewards in WETH that have been claimed
_rewardTokenuint256The amount of rewards in non-WETH tokens that have been claimed

addRewards

Adds a donation as a reward to be distributed among the lockers.

function addRewards(uint256 _wethAmount, uint256 _tokenAmount) external;

Parameters

NameTypeDescription
_wethAmountuint256The amount of the donation in WETH sent to the lock manager
_tokenAmountuint256The amount of the donation in non-WETH tokens sent to the lock manager

getPositionsCount

Returns the number of concentrated positions in this lock manager

function getPositionsCount() external view returns (uint256 _positionsCount);

Returns

NameTypeDescription
_positionsCountuint256The number of concentrated positions

getPositionToMint

Get the the position that has to be minted

function getPositionToMint() external returns (IStrategy.LiquidityPosition memory _positionToMint);

Returns

NameTypeDescription
_positionToMintLiquidityPosition.IStrategyThe position that has to be minted

getPositionToBurn

Get the position to burn

function getPositionToBurn(IStrategy.Position calldata _position)
    external
    returns (IStrategy.LiquidityPosition memory _positionToBurn);

Parameters

NameTypeDescription
_positionPosition.IStrategyThe position to burn

Returns

NameTypeDescription
_positionToBurnLiquidityPosition.IStrategyThe position that has to be burned

mintPosition

Creates a concentrated WETH position

function mintPosition() external;

burnPosition

Burns a position that fell out of the active range

function burnPosition(IStrategy.Position calldata _position) external;

Parameters

NameTypeDescription
_positionPosition.IStrategyThe position to be burned

uniswapV3MintCallback

Callback that is called when calling the mint method in a UniswapV3 pool

It is only called in the creation of the full range and when positions need to be updated

function uniswapV3MintCallback(uint256 _amount0Owed, uint256 _amount1Owed, bytes calldata _data) external;

Parameters

NameTypeDescription
_amount0Oweduint256The amount of token0
_amount1Oweduint256The amount of token1
_databytesnot used

positionsList

Returns an array of positions

function positionsList(uint256 _startFrom, uint256 _amount)
    external
    view
    returns (IStrategy.LiquidityPosition[] memory _positions);

Parameters

NameTypeDescription
_startFromuint256Index from where to start the pagination
_amountuint256Maximum amount of positions to retrieve

Returns

NameTypeDescription
_positionsLiquidityPosition.IStrategy[]The positions

collectFees

Claims the fees from the UniswapV3 pool and stores them in the FeeManager

Collects all available fees by passing type(uint128).max as requested amounts

function collectFees(IStrategy.Position[] calldata _positions) external;

Parameters

NameTypeDescription
_positionsPosition.IStrategy[]The positions to claim the fees from

burn

Burn the amount of lockedWeth provided by the caller

function burn(uint256 _lockedWethAmount) external;

Parameters

NameTypeDescription
_lockedWethAmountuint256The amount of lockedWeth to be burned

withdraw

Withdraws the corresponding part of WETH and non-WETH token depending on the locked WETH balance of the user and burns the lockTokens

Only available if lockManager is deprecated and withdraws are enabled

function withdraw(address _receiver) external;

Parameters

NameTypeDescription
_receiveraddressThe receiver of the tokens

unwind

Unwinds a number of positions

lockManager must be deprecated

function unwind(uint256 _positions) external;

Parameters

NameTypeDescription
_positionsuint256The number of positions to unwind from last to first

Events

Locked

Emitted when a user locks WETH in a pool

event Locked(uint256 _wethAmount);

ClaimedRewards

Emitted when a user claims rewards

event ClaimedRewards(address _user, address _to, uint256 _wethAmount, uint256 _tokenAmount);

RewardsAdded

Emitted when a fee manager adds WETH rewards to a given pool manager

event RewardsAdded(uint256 _wethAmount, uint256 _tokenAmount);

FeesCollected

Emitted when we finish the fee-collecting process

event FeesCollected(uint256 _wethFees, uint256 _tokenFees);

Burned

Emitted when an amount of locked WETH is burned

event Burned(uint256 _wethAmount);

WithdrawalsEnabled

Emitted when withdrawals are enabled

event WithdrawalsEnabled();

PositionMinted

Emitted when a position was minted

event PositionMinted(IStrategy.LiquidityPosition _position, uint256 _amount0, uint256 _amount1);

PositionBurned

Emitted when a position was burned

event PositionBurned(IStrategy.LiquidityPosition _position, uint256 _amount0, uint256 _amount1);

Errors

LockManager_NoRewardsToClaim

Thrown when the user doesn't have rewards to claim

error LockManager_NoRewardsToClaim();

LockManager_ZeroAmount

Thrown when the amount is zero

error LockManager_ZeroAmount();

LockManager_ZeroAddress

Thrown when the provided address is zero

error LockManager_ZeroAddress();

LockManager_NoLockedWeth

Thrown when the lock manager has no locked WETH

error LockManager_NoLockedWeth();

LockManager_OnlyPool

Thrown when the UniswapV3 callback caller is not a valid pool

error LockManager_OnlyPool();

LockManager_OverLimitMint

Thrown when the amount of WETH minted by this lock manager exceeds the WETH supply

error LockManager_OverLimitMint(uint256 _totalSupply, uint256 _concentratedWeth);

LockManager_DeprecationRequired

Thrown when enabling withdraws without the lockManager being deprecated

error LockManager_DeprecationRequired();

LockManager_WithdrawalsNotEnabled

Thrown when trying to withdraw with the contract not marked as withdrawable

error LockManager_WithdrawalsNotEnabled();

LockManager_ZeroBalance

Thrown when trying to withdraw with zero lockedWeth

error LockManager_ZeroBalance();

LockManager_NotLockManager

Thrown when the caller is not the lock manager

error LockManager_NotLockManager();

LockManager_NoPositions

Thrown when trying to unwind, and there are no positions left

error LockManager_NoPositions();

LockManager_PoolManipulated

Thrown when the price oracle detects a manipulation

error LockManager_PoolManipulated();

LockManager_InvalidAddress

Thrown when trying to transfer to the same address

error LockManager_InvalidAddress();

LockManager_TransferFailed

Thrown when transfer or transferFrom fails

error LockManager_TransferFailed();

Structs

PoolRewards

Pool status for internal accountancy

struct PoolRewards {
    uint256 wethPerLockedWeth;
    uint256 tokenPerLockedWeth;
}

UserRewards

The amounts of paid and available rewards per user

struct UserRewards {
    uint256 wethPaid;
    uint256 tokenPaid;
    uint256 wethAvailable;
    uint256 tokenAvailable;
}

WithdrawalData

Withdrawal data for balance withdrawals for lockers

struct WithdrawalData {
    bool withdrawalsEnabled;
    uint256 totalWeth;
    uint256 totalToken;
}

ILockManagerFactory

Git Source

Functions

createLockManager

Creates a lock manager

function createLockManager(IPoolManager.LockManagerParams calldata _lockManagerParams)
    external
    returns (ILockManager _lockManager);

Parameters

NameTypeDescription
_lockManagerParamsLockManagerParams.IPoolManagerThe parameters to initialize the lock manager

Returns

NameTypeDescription
_lockManagerILockManagerThe created lock manager

Events

LockManagerCreated

Emitted when the lock manager is created

event LockManagerCreated(ILockManager _lockManager);

ILockManagerGovernor

Git Source

Inherits: IGovernorMiniBravo

This contract contains the data necessary for governance

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory contract

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

deprecated

Returns true if the lock manager is deprecated

function deprecated() external view returns (bool _deprecated);

Returns

NameTypeDescription
_deprecatedboolTrue if the lock manager is deprecated

acceptDeprecate

Votes yes on the proposal to deprecate the lockManager

function acceptDeprecate() external;

Errors

LockManager_ArithmeticUnderflow

Thrown when arithmetic underflow happens

error LockManager_ArithmeticUnderflow();

LockManager_Deprecated

Thrown when certain functions are called on a deprecated lock manager

error LockManager_Deprecated();

Enums

Methods

The methods that are available for governance

Always add new methods before LatestMethod

enum Methods {
    Deprecate,
    LatestMethod
}

IPoolManager

Git Source

Inherits: IPoolManagerGovernor

This contract manages the protocol owned positions of the associated uni v3 pool

Functions

WETH

Returns the WETH contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token

UNISWAP_V3_FACTORY

Returns the UniswapV3 factory contract

function UNISWAP_V3_FACTORY() external view returns (IUniswapV3Factory _uniswapV3Factory);

Returns

NameTypeDescription
_uniswapV3FactoryIUniswapV3FactoryThe UniswapV3 factory contract

POOL_BYTECODE_HASH

Returns the UniswapV3 pool bytecode hash

function POOL_BYTECODE_HASH() external view returns (bytes32 _poolBytecodeHash);

Returns

NameTypeDescription
_poolBytecodeHashbytes32The UniswapV3 pool bytecode hash

lockManager

Returns the lock manager contract

function lockManager() external view returns (ILockManager _lockManager);

Returns

NameTypeDescription
_lockManagerILockManagerThe lock manager

deprecatedLockManagers

Returns a deprecated lock manager contract at a specific index

function deprecatedLockManagers(uint256 _index) external view returns (ILockManager _deprecatedLockManagers);

Returns

NameTypeDescription
_deprecatedLockManagersILockManagerA deprecated lock manager

FEE

Returns the fee of the pool manager

function FEE() external view returns (uint24 _fee);

Returns

NameTypeDescription
_feeuint24The pool manager's fee

TOKEN

Returns the non-WETH token of the underlying pool

function TOKEN() external view returns (IERC20 _token);

Returns

NameTypeDescription
_tokenIERC20The non-WETH token of the underlying pool

POOL

Returns the underlying UniswapV3 pool contract

function POOL() external view returns (IUniswapV3Pool _pool);

Returns

NameTypeDescription
_poolIUniswapV3PoolThe underlying UniswapV3 pool contract

IS_WETH_TOKEN0

Returns true if WETH token is the token0

function IS_WETH_TOKEN0() external view returns (bool _isWethToken0);

Returns

NameTypeDescription
_isWethToken0boolIf WETH is token0

seederRewards

Returns the pending to the corresponding account

function seederRewards(address _account)
    external
    view
    returns (uint256 wethPaid, uint256 tokenPaid, uint256 wethAvailable, uint256 tokenAvailable);

Parameters

NameTypeDescription
_accountaddressThe address of the account

Returns

NameTypeDescription
wethPaiduint256The amount of claimed rewards in WETH
tokenPaiduint256The amount of claimed rewards in the non-WETH token
wethAvailableuint256The amount of pending rewards in WETH
tokenAvailableuint256The amount of pending rewards in the non-WETH token

poolRewards

Returns the status of a corresponding pool manager

function poolRewards() external view returns (uint256 wethPerSeededLiquidity, uint256 tokenPerSeededLiquidity);

Returns

NameTypeDescription
wethPerSeededLiquidityuint256The value of the reward per WETH locked
tokenPerSeededLiquidityuint256The value of the reward per non-WETH token locked

deprecateLockManager

Deprecates the current lock manager and deploys a new one

function deprecateLockManager() external;

mintLiquidityForFullRange

Mint liquidity for the full-range position

function mintLiquidityForFullRange(uint256 _wethAmount, uint256 _tokenAmount) external;

Parameters

NameTypeDescription
_wethAmountuint256The amount of WETH token to be inserted in the full-range position
_tokenAmountuint256The amount of non-WETH token to be inserted in the full-range position

burn

Burns an amount of liquidity provided by a seeder

The voting power for the user remains the same but they donate all rewards

function burn(uint256 _liquidity) external;

Parameters

NameTypeDescription
_liquidityuint256The amount of liquidity

uniswapV3MintCallback

Callback that is called when calling the mint method in a UniswapV3 pool

It is only called in the creation of the full range and when positions need to be updated

function uniswapV3MintCallback(uint256 _amount0Owed, uint256 _amount1Owed, bytes calldata _data) external;

Parameters

NameTypeDescription
_amount0Oweduint256The amount of token0
_amount1Oweduint256The amount of token1
_databytesThe data that differentiates through an address whether to mint or transfer from for the full range

increaseFullRangePosition

Increases the full-range position. The deposited tokens can not withdrawn and all of the generated fees with only benefit the pool itself

function increaseFullRangePosition(address _donor, uint128 _liquidity, uint160 _sqrtPriceX96) external;

Parameters

NameTypeDescription
_donoraddressThe user that will provide WETH and the other token
_liquidityuint128The liquidity that will be minted
_sqrtPriceX96uint160A sqrt price representing the current pool prices

increaseFullRangePosition

Increases the full-range position with a given liquidity

Pool manager will make a callback to the fee manager, who will provide the liquidity

function increaseFullRangePosition(uint256 _wethAmount, uint256 _tokenAmount)
    external
    returns (uint256 __amountWeth, uint256 __amountToken);

Parameters

NameTypeDescription
_wethAmountuint256The amount of WETH token to be inserted in the full-range position
_tokenAmountuint256The amount of non-WETH to be inserted in the full-range position

Returns

NameTypeDescription
__amountWethuint256The amount in WETH added to the full range
__amountTokenuint256The amount in non-WETH token added to the full range

collectFees

Claims the fees from the UniswapV3 pool and stores them in the FeeManager

function collectFees() external;

claimRewards

Returns the rewards generated by a caller

function claimRewards(address _to) external returns (uint256 _rewardWeth, uint256 _rewardToken);

Parameters

NameTypeDescription
_toaddressThe recipient the rewards

Returns

NameTypeDescription
_rewardWethuint256The amount of rewards in WETH that were claimed
_rewardTokenuint256The amount of rewards in non-WETH token that were claimed

claimable

Returns the total amount of WETH claimable for a given account

function claimable(address _account) external view returns (uint256 _wethClaimable, uint256 _tokenClaimable);

Parameters

NameTypeDescription
_accountaddressThe address of the account

Returns

NameTypeDescription
_wethClaimableuint256The amount of WETH claimable
_tokenClaimableuint256The amount of non-WETH token claimable

burn1

Burns a little bit of liquidity in the pool to produce a new observation

The oracle corrections require at least 2 post-manipulation observations to work properly When there is no new observations after a manipulation, the oracle will make then with this function

function burn1() external;

Events

SeederLiquidityBurned

Emitted when a seeder burns liquidity

event SeederLiquidityBurned(uint256 _liquidity);

LockManagerDeprecated

Emitted when a lock manager is deprecated

event LockManagerDeprecated(ILockManager _oldLockManager, ILockManager _newLockManager);

FeesCollected

Emitted when fees are collected

event FeesCollected(uint256 _totalFeeWeth, uint256 _totalFeeToken);

RewardsAdded

Emitted when rewards are added to a pool manager

event RewardsAdded(uint256 _wethAmount, uint256 _tokenAmount);

ClaimedRewards

Emitted when a seeder claims their rewards

event ClaimedRewards(address _user, address _to, uint256 _wethAmount, uint256 _tokenAmount);

Errors

PoolManager_OnlyFactory

Thrown when someone other than the factory tries to call the method

error PoolManager_OnlyFactory();

PoolManager_OnlyPool

Thrown when someone other than the pool tries to call the method

error PoolManager_OnlyPool();

PoolManager_ActiveLockManager

Thrown when someone tries to deploy a new lock manager while the old one is still not deprecated

error PoolManager_ActiveLockManager();

PoolManager_ZeroAmount

Thrown when the amount is zero

error PoolManager_ZeroAmount();

PoolManager_ZeroAddress

Thrown when the provided address is zero

error PoolManager_ZeroAddress();

PoolManager_NoRewardsToClaim

Thrown when the user doesn't have rewards to claim

error PoolManager_NoRewardsToClaim();

PoolManager_PoolManipulated

Thrown when the price oracle detects a manipulation

error PoolManager_PoolManipulated();

PoolManager_InvalidFeeManager

Thrown when the FeeManager provided is incorrect

error PoolManager_InvalidFeeManager();

PoolManager_InvalidPriceOracle

Thrown when the caller of the burn1 function is not the current oracle

error PoolManager_InvalidPriceOracle();

Structs

SeederRewards

The amounts of paid and available rewards per seeder

struct SeederRewards {
    uint256 wethPaid;
    uint256 tokenPaid;
    uint256 wethAvailable;
    uint256 tokenAvailable;
}

PoolRewards

Pool status for internal accountancy

struct PoolRewards {
    uint256 wethPerSeededLiquidity;
    uint256 tokenPerSeededLiquidity;
}

LockManagerParams

The parameters for the lock manager

struct LockManagerParams {
    IPoolManagerFactory factory;
    IStrategy strategy;
    IERC20 token;
    IERC20 weth;
    IUniswapV3Pool pool;
    bool isWethToken0;
    uint24 fee;
    address governance;
    uint256 index;
}

Position

UniswapV3 pool position

struct Position {
    int24 lowerTick;
    int24 upperTick;
}

IPoolManagerDeployer

Git Source

Deployer of pool managers

This contract is needed to reduce the size of the pool manager factory contract

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

deployPoolManager

Deploys a new pool manager for a given UniswapV3 pool

function deployPoolManager(IUniswapV3Pool _pool) external returns (IPoolManager _poolManager);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe UniswapV3 pool

Returns

NameTypeDescription
_poolManagerIPoolManagerThe newly deployed pool manager

Errors

PoolManagerDeployer_OnlyPoolManagerFactory

Thrown when someone other than the pool manager factory tries to call the method

error PoolManagerDeployer_OnlyPoolManagerFactory();

IPoolManagerFactory

Git Source

Creates a new pool manager associated with a defined UniswapV3 pool

The UniswapV3 pool needs to be a pool deployed by the current UniswapV3 factory. The pool might or might not already exist (the correct deterministic address is checked but not called).

Functions

UNISWAP_V3_FACTORY

Returns the UniswapV3 factory contract

function UNISWAP_V3_FACTORY() external view returns (IUniswapV3Factory _uniswapV3Factory);

Returns

NameTypeDescription
_uniswapV3FactoryIUniswapV3FactoryThe UniswapV3 factory contract

POOL_BYTECODE_HASH

Returns the UniswapV3 pool bytecode hash

function POOL_BYTECODE_HASH() external view returns (bytes32 _poolBytecodeHash);

Returns

NameTypeDescription
_poolBytecodeHashbytes32The UniswapV3 pool bytecode hash

STRATEGY_SETTER_ROLE

The role that allows changing the Strategy

function STRATEGY_SETTER_ROLE() external view returns (bytes32);

FACTORY_SETTER_ROLE

The role that allows changing the lock manager factory

function FACTORY_SETTER_ROLE() external view returns (bytes32);

MIGRATOR_SETTER_ROLE

The role that allows changing the pool manager migrator address

function MIGRATOR_SETTER_ROLE() external view returns (bytes32);

PRICE_ORACLE_SETTER_ROLE

The role that allows changing the price oracle address

function PRICE_ORACLE_SETTER_ROLE() external view returns (bytes32);

FEE_MANAGER_SETTER_ROLE

The role that allows changing the fee manager address

function FEE_MANAGER_SETTER_ROLE() external view returns (bytes32);

FEE_COLLECTOR_SETTER_ROLE

The role that allows changing the fee collector job

function FEE_COLLECTOR_SETTER_ROLE() external view returns (bytes32);

MIN_ETH_AMOUNT_SETTER_ROLE

The role that allows changing the min ETH amount to create a PoolManager

function MIN_ETH_AMOUNT_SETTER_ROLE() external view returns (bytes32);

WETH

Returns the WETH token contract

function WETH() external view returns (IERC20 _weth);

Returns

NameTypeDescription
_wethIERC20The WETH token contract

strategy

Returns the strategy registry

function strategy() external view returns (IStrategy _strategy);

Returns

NameTypeDescription
_strategyIStrategyThe strategy registry

feeManager

Returns the fee manager

function feeManager() external view returns (IFeeManager _feeManager);

Returns

NameTypeDescription
_feeManagerIFeeManagerThe fee manager

childrenCount

Returns the total number of pool managers that this factory has deployed

function childrenCount() external view returns (uint256 _childrenCount);

Returns

NameTypeDescription
_childrenCountuint256The total amount of pool managers created by this factory

feeCollectorJob

Returns the fee collector job

function feeCollectorJob() external view returns (IFeeCollectorJob _feeCollectorJob);

Returns

NameTypeDescription
_feeCollectorJobIFeeCollectorJobThe fee collector job

lockManagerFactory

Returns the lock manager factory

function lockManagerFactory() external view returns (ILockManagerFactory _lockManagerFactory);

Returns

NameTypeDescription
_lockManagerFactoryILockManagerFactoryThe lock manager factory

POOL_MANAGER_DEPLOYER

Returns the pool manager deployer

function POOL_MANAGER_DEPLOYER() external view returns (IPoolManagerDeployer _poolManagerDeployer);

Returns

NameTypeDescription
_poolManagerDeployerIPoolManagerDeployerThe pool manager deployer

poolManagerMigrator

Returns the pool manager migrator contract

function poolManagerMigrator() external view returns (address _poolManagerMigrator);

Returns

NameTypeDescription
_poolManagerMigratoraddressThe pool manager migrator contract

priceOracle

Returns the price oracle

function priceOracle() external view returns (IPriceOracle _priceOracle);

Returns

NameTypeDescription
_priceOracleIPriceOracleThe price oracle

minEthAmount

Returns the minimum amount of ETH to create a PoolManager

function minEthAmount() external view returns (uint256 _minEthAmount);

Returns

NameTypeDescription
_minEthAmountuint256The minimum amount of ETH

constructorArguments

Getter for a pool manager params public variable used to initialize a new pool manager factory

This method is called by the pool manager constructor (no parameters are passed not to influence the deterministic address)

function constructorArguments()
    external
    view
    returns (
        IUniswapV3Factory uniswapV3Factory,
        bytes32 poolBytecodeHash,
        IERC20 weth,
        IERC20 otherToken,
        IFeeManager feeManager,
        IPriceOracle priceOracle,
        address owner,
        uint24 fee,
        uint160 sqrtPriceX96
    );

Returns

NameTypeDescription
uniswapV3FactoryIUniswapV3FactoryAddress of the UniswapV3 factory
poolBytecodeHashbytes32Bytecode hash of the UniswapV3 pool
wethIERC20The WETH token
otherTokenIERC20The non-WETH token in the UniswapV3 pool address
feeManagerIFeeManagerThe fee manager contract
priceOracleIPriceOracleThe price oracle contract
owneraddressThe contracts owner
feeuint24The UniswapV3 fee tier, as a 10000th of %
sqrtPriceX96uint160A sqrt price representing the current pool prices

isChild

Returns true if this factory deployed the given pool manager

function isChild(IPoolManager _poolManager) external view returns (bool _isChild);

Parameters

NameTypeDescription
_poolManagerIPoolManagerThe pool manager to be checked

Returns

NameTypeDescription
_isChildboolWhether the given pool manager was deployed by this factory

poolManagers

Returns the address of the pool manager for a given pool, the zero address if there is no pool manager

function poolManagers(IUniswapV3Pool _pool) external view returns (IPoolManager _poolManager);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe address of the Uniswap V3 pool

Returns

NameTypeDescription
_poolManagerIPoolManagerThe address of the pool manager for a given pool

children

Returns the list of all the pool managers deployed by this factory

function children(uint256 _index) external view returns (IPoolManager _poolManager);

Parameters

NameTypeDescription
_indexuint256The index of the pool manager

Returns

NameTypeDescription
_poolManagerIPoolManagerThe pool manager

isSupportedPool

Returns true if the pool has a valid pool manager

function isSupportedPool(IUniswapV3Pool _pool) external view returns (bool _isSupportedPool);

Parameters

NameTypeDescription
_poolIUniswapV3PoolThe address of the Uniswap V3 pool

Returns

NameTypeDescription
_isSupportedPoolboolTrue if the pool has a pool manager

isSupportedToken

Returns true if the token has a pool paired with WETH

function isSupportedToken(IERC20 _token) external view returns (bool _isValid);

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH

Returns

NameTypeDescription
_isValidboolTrue if the token has a pool paired with WETH

isSupportedTokenPair

Returns if a specific pair supports routing through WETH

function isSupportedTokenPair(IERC20 _tokenA, IERC20 _tokenB) external view returns (bool _isSupported);

Parameters

NameTypeDescription
_tokenAIERC20The tokenA to check paired with tokenB
_tokenBIERC20The tokenB to check paired with tokenA

Returns

NameTypeDescription
_isSupportedboolTrue if the pair is supported

defaultTokenFee

Returns the default fee to be used for a specific non-WETH token paired with WETH

function defaultTokenFee(IERC20 _token) external view returns (uint24 _fee);

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH

Returns

NameTypeDescription
_feeuint24The default fee for the non-WETH token on the WETH/TOKEN pool

tokenFees

Returns the fee tiers for a specific non-WETH token paired with WETH

function tokenFees(IERC20 _token) external view returns (uint24[] memory _fees);

Parameters

NameTypeDescription
_tokenIERC20The token paired with WETH

Returns

NameTypeDescription
_feesuint24[]The fee tiers the non-WETH token on the WETH/TOKEN pool

owner

Returns owner of the contract

function owner() external view returns (address _owner);

Returns

NameTypeDescription
_owneraddressThe owner of the contract

pendingOwner

Returns the pending owner

function pendingOwner() external view returns (address _pendingOwner);

Returns

NameTypeDescription
_pendingOwneraddressThe pending owner of the contract

POOL_MANAGER_BYTECODE_HASH

Returns the pool manager bytecode hash for deterministic addresses

function POOL_MANAGER_BYTECODE_HASH() external view returns (bytes32 _poolManagerBytecodeHash);

Returns

NameTypeDescription
_poolManagerBytecodeHashbytes32The pool manager bytecode hash

createPoolManager

Deploys a new pool manager for a given UniswapV3 pool if it does not exist yet

function createPoolManager(IERC20 _token, uint24 _fee, uint128 _liquidity, uint160 _sqrtPriceX96)
    external
    returns (IPoolManager _poolManager);

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the given pool
_feeuint24The UniswapV3 pool fee tier, as a 10000th of %
_liquidityuint128The liquidity to create the pool manager
_sqrtPriceX96uint160The sqrt price in base 96

Returns

NameTypeDescription
_poolManagerIPoolManagerThe pool manager newly deployed

listChildren

Returns pagination of the pool managers deployed by this factory

function listChildren(uint256 _startFrom, uint256 _amount) external view returns (IPoolManager[] memory _list);

Parameters

NameTypeDescription
_startFromuint256Index from where to start the pagination
_amountuint256Maximum amount of pool managers to retrieve

Returns

NameTypeDescription
_listIPoolManager[]Paginated pool managers deployed by this factory

getPoolManagerAddress

Computes the deterministic address of a given pool manager, a non-WETH token, and the fee

function getPoolManagerAddress(IERC20 _token, uint24 _fee)
    external
    view
    returns (IPoolManager _theoreticalPoolManagerAddress);

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the pool
_feeuint24The UniswapV3 fee tier

Returns

NameTypeDescription
_theoreticalPoolManagerAddressIPoolManagerThe theoretical address of the pool manager

getWethPoolAddress

Computes the deterministic address of a UniswapV3 pool with WETH, given the non-WETH token and its fee tier.

function getWethPoolAddress(IERC20 _token, uint24 _fee)
    external
    view
    returns (IUniswapV3Pool _theoreticalAddress, bool _isWethToken0);

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the pool
_feeuint24The UniswapV3 fee tier

Returns

NameTypeDescription
_theoreticalAddressIUniswapV3PoolAddress of the theoretical address of the UniswapV3 pool
_isWethToken0boolDefines if WETH is the token0 of the UniswapV3 pool

getPoolManagers

Lists the existing pool managers for a given token

function getPoolManagers(IERC20 _token, uint24[] memory _feeTiers)
    external
    view
    returns (address[] memory _poolManagerAddresses);

Parameters

NameTypeDescription
_tokenIERC20The address of the token
_feeTiersuint24[]The fee tiers to check

Returns

NameTypeDescription
_poolManagerAddressesaddress[]The available pool managers

setDefaultTokenFee

Sets the default fee for the pool of non-WETH/WETH

function setDefaultTokenFee(IERC20 _token, uint24 _fee) external;

Parameters

NameTypeDescription
_tokenIERC20The non-WETH token paired with WETH in the pool
_feeuint24The UniswapV3 fee tier to use

setStrategy

Sets the new strategy address

function setStrategy(IStrategy _strategy) external;

Parameters

NameTypeDescription
_strategyIStrategyThe new strategy address

setLockManagerFactory

Sets the new lock manager factory address

function setLockManagerFactory(ILockManagerFactory _lockManagerFactory) external;

Parameters

NameTypeDescription
_lockManagerFactoryILockManagerFactoryThe new lock manager factory address

nominateOwner

Nominates the new owner of the contract

function nominateOwner(address _newOwner) external;

Parameters

NameTypeDescription
_newOwneraddressThe new owner

acceptOwnership

Sets a new owner and grants all roles needed to manage the contract

function acceptOwnership() external;

setPoolManagerMigrator

Sets the contract address responsible for migrating

function setPoolManagerMigrator(address _poolManagerMigrator) external;

Parameters

NameTypeDescription
_poolManagerMigratoraddressThe new pool manager migrator

setPriceOracle

Sets price oracle contract

function setPriceOracle(IPriceOracle _priceOracle) external;

Parameters

NameTypeDescription
_priceOracleIPriceOracleThe new price oracle

setFeeManager

Sets the fee manager contract

function setFeeManager(IFeeManager _feeManager) external;

Parameters

NameTypeDescription
_feeManagerIFeeManagerThe new fee manager

setFeeCollectorJob

Sets the fee collector job

function setFeeCollectorJob(IFeeCollectorJob _feeCollectorJob) external;

Parameters

NameTypeDescription
_feeCollectorJobIFeeCollectorJobThe new fee collector job

setMinEthAmount

Sets the minimum ETH amount

function setMinEthAmount(uint256 _minEthAmount) external;

Parameters

NameTypeDescription
_minEthAmountuint256The new minimum ETH amount

Events

LockManagerFactoryChanged

Emitted when the lock manager factory changes

event LockManagerFactoryChanged(ILockManagerFactory _lockManagerFactory);

StrategyChanged

Emitted when the strategy changes

event StrategyChanged(IStrategy _strategy);

OwnerNominated

Emitted when a new owner is nominated

event OwnerNominated(address _owner);

OwnerChanged

Emitted when the owner changes

event OwnerChanged(address _owner);

PoolManagerMigratorChanged

Emitted when the migrator address changes

event PoolManagerMigratorChanged(address _poolManagerMigrator);

FeeManagerChanged

Emitted when the fee manager address changes

event FeeManagerChanged(IFeeManager _feeManager);

PriceOracleChanged

Emitted when the price oracle address changes

event PriceOracleChanged(IPriceOracle _priceOracle);

FeeCollectorJobChanged

Emitted when the fee collector job changes

event FeeCollectorJobChanged(IFeeCollectorJob _feeCollectorJob);

PoolManagerCreated

Emitted when the pool manager is created

event PoolManagerCreated(IPoolManager _poolManager);

MinEthAmountChanged

Emitted when the min ETH amount changes

event MinEthAmountChanged(uint256 _minEthAmount);

Errors

PoolManagerFactory_InvalidPool

Thrown when changing the default fee to a nonexistent pool

error PoolManagerFactory_InvalidPool();

PoolManagerFactory_ExistingPoolManager

Thrown when trying to create a pool manager that was already created

error PoolManagerFactory_ExistingPoolManager();

PoolManagerFactory_ZeroAddress

Thrown when zero address was supplied to a function

error PoolManagerFactory_ZeroAddress();

PoolManagerFactory_InvalidPendingOwner

Thrown when an invalid account tries to accept ownership of the contract

error PoolManagerFactory_InvalidPendingOwner();

PoolManagerFactory_SmallAmount

Thrown when creating a PoolManager with less than the min ETH amount

error PoolManagerFactory_SmallAmount();

PoolManagerFactory_InvalidMinEthAmount

Thrown when trying to set min ETH amount to 0

error PoolManagerFactory_InvalidMinEthAmount();

Structs

PoolManagerParams

Used to pass constructor arguments when deploying new pool (will call msg.sender.constructorArguments()), to avoid having to retrieve them when checking if the sender is a valid pool manager address

struct PoolManagerParams {
    IUniswapV3Factory uniswapV3Factory;
    bytes32 poolBytecodeHash;
    IERC20 weth;
    IERC20 otherToken;
    IFeeManager feeManager;
    IPriceOracle priceOracle;
    address owner;
    uint24 fee;
    uint160 sqrtPriceX96;
}

IPoolManagerGovernor

Git Source

Inherits: IGovernorMiniBravo

This contract contains the data and logic necessary for the pool manager governance

Functions

POOL_MANAGER_FACTORY

Returns the pool manager factory contract

function POOL_MANAGER_FACTORY() external view returns (IPoolManagerFactory _poolManagerFactory);

Returns

NameTypeDescription
_poolManagerFactoryIPoolManagerFactoryThe pool manager factory

feeManager

Returns the fee manager

function feeManager() external view returns (IFeeManager _feeManager);

Returns

NameTypeDescription
_feeManagerIFeeManagerThe fee manager

poolLiquidity

Returns the pool liquidity

function poolLiquidity() external view returns (uint256 _poolLiquidity);

Returns

NameTypeDescription
_poolLiquidityuint256The pool liquidity

seederBalance

Returns the liquidity seeded by the given donor

function seederBalance(address _donor) external view returns (uint256 _seederBalance);

Parameters

NameTypeDescription
_donoraddressThe donor's address

Returns

NameTypeDescription
_seederBalanceuint256The amount of liquidity seeded by the donor

seederBurned

Returns the liquidity seeded by the given donor that they burned

function seederBurned(address _donor) external view returns (uint256 _seederBurned);

Parameters

NameTypeDescription
_donoraddressThe donor's address

Returns

NameTypeDescription
_seederBurneduint256The amount of liquidity seeded by the donor that they burned

priceOracle

Returns the price oracle

function priceOracle() external view returns (IPriceOracle _priceOracle);

Returns

NameTypeDescription
_priceOracleIPriceOracleThe price oracle

proposeFeeManagerChange

Creates a proposal to change the fee manager

_newFeeManager must be equal to the current fee manager on the pool manager factory and different from the current fee manager

function proposeFeeManagerChange(IFeeManager _newFeeManager) external;

Parameters

NameTypeDescription
_newFeeManagerIFeeManagerThe new fee manager to be set up

acceptFeeManagerChange

Votes yes on the proposal to change the fee manager

function acceptFeeManagerChange(IFeeManager _newFeeManager) external;

Parameters

NameTypeDescription
_newFeeManagerIFeeManagerThe new fee manager to be set up

proposeMigrate

Creates a proposal to migrate

_migrationContract must be equal to the current migration contract on the pool manager factory and different from the current migration contract

function proposeMigrate(address _migrationContract) external;

Parameters

NameTypeDescription
_migrationContractaddressThe migration contract

acceptMigrate

Votes yes on the proposal to migrate

function acceptMigrate(address _migrationContract) external;

Parameters

NameTypeDescription
_migrationContractaddressThe migration contract

proposePriceOracleChange

Creates a proposal to change the price's oracle

_newPriceOracle must be equal to the current price oracle on the pool manager factory and different from the current price's oracle

function proposePriceOracleChange(IPriceOracle _newPriceOracle) external;

Parameters

NameTypeDescription
_newPriceOracleIPriceOracleThe new price oracle to be set up

acceptPriceOracleChange

Votes yes on the proposal to change the prices oracle

function acceptPriceOracleChange(IPriceOracle _newPriceOracle) external;

Parameters

NameTypeDescription
_newPriceOracleIPriceOracleThe new price oracle to be set up

Events

FeeManagerMigrated

Emitted when an old fee manager migrates to a new fee manager

event FeeManagerMigrated(IFeeManager _newFeeManager);

PriceOracleSet

Emitted when the price oracle is set

event PriceOracleSet(IPriceOracle _newPriceOracle);

Errors

PoolManager_FeeManagerMismatch

Thrown when the fee manager does not match the pool manager factory fee manager

error PoolManager_FeeManagerMismatch(IFeeManager _expected, IFeeManager _actual);

PoolManager_FeeManagerAlreadySet

Thrown when trying to set an already set fee manager

error PoolManager_FeeManagerAlreadySet();

PoolManager_PriceOracleMismatch

Thrown when the price oracle inputted does not match the poolManagerFactory priceOracle

error PoolManager_PriceOracleMismatch(IPriceOracle _expected, IPriceOracle _actual);

PoolManager_PriceOracleAlreadySet

Thrown when trying to set an already set price oracle

error PoolManager_PriceOracleAlreadySet();

PoolManager_MigrationContractMismatch

Thrown when the migration contract inputted does not match the poolManagerFactory migration contract

error PoolManager_MigrationContractMismatch(address _expected, address _actual);

PoolManager_MigrationFailed

Thrown when trying to migrate to a new PoolManager unsuccessful

error PoolManager_MigrationFailed();

Enums

Methods

The methods that are available for governance

enum Methods {
    Migrate,
    FeeManagerChange,
    PriceOracleChange
}