Git Product home page Git Product logo

stability-contracts's People

Contributors

0x6c71777172656474 avatar 0xhokugava avatar a17 avatar devtealeaf avatar hcrypto7 avatar iammrjude avatar jodsmigel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stability-contracts's Issues

[PROPOSED] DefiEdge Retro Boosted Merkl Farm

DRBMF | DefiEdge Retro Boosted Merkl Farm

Status: PROPOSED

Status will be changed soon.

Description

Earn Merkl rewards by DefiEdge vault with MerklVeBooster's boost.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase
  • #47

Adapters

  • UniswapV3Adapter

Skip false positive alerts

  • create detectors/rules list for checking
  • check each alert in Security tab and add //nosemgrep or/and // slither-disable-next-line detector to each false positive alert

Improve coverage

Let's improve the overall percentage of project test coverage.

Optimize the deployment process

  • implement platform.addBoostTokens(address[] memory allowedBoostRewardToken, address[] memory defaultBoostRewardToken);
  • refactor swapper.setThreshold to swapper.setThresholds(address[] memory tokenIn, uint[] memory thresholdAmount);
  • refactor factory.addFarm to factory.addFarms(Farm[] memory farms_);

[DONE] DefiEdge QuickSwap Merkl Farm

DQMF

Status: DONE

The strategy was developed.

Description

Earn MERKL rewards by DefiEdge strategy.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • AmmAdapterIdLib.ALGEBRA

[DEV] Steer QuickSwap Merkl Farm

SQMF

Status: DEV

Being developed.

Description

Earn MERKL rewards by Steer vault.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • AmmAdapterIdLib.ALGEBRA

ALM

Stability ALM

We need our own unique implementation of a universal Automatic Liquidity Manager for UniswapV3-based AMMs.
We started similar development in the fall of 2023 in the form of Active strategies #14 #48, which are ALMs, but the concept has changed. Previously, we intended to manage the provision of liquidity completely on-chain, and create a separate strategy for each liquidity management algorithm (Fill-Up/Follow/Swap), but now we decided to shift part of the work to the off-chain environment and transfer already calculated tick ranges to the strategy when rebalancing. In general, we are now following the path of most existing ALMs.

Unique features

  • Impermanent Loss tracking
  • All known rebalancing algorithms
  • Integrated reinvestment of farming rewards

Base strategy

  • ALM is a single base strategy contract for all rebalancing algorithms and all supported DeXes.

Liquidity can be provided and rebalanced in the form of a dynamic number of ranges.

The calculation of the new position for rebalancing will be done off-chain, but the type of algorithm and its specifics will be requested from this contract. This specificity and algorithm can be changed through Governance and Multisig.

Algos

Rebalancing algorithms that will be supported by Stability Server Pro.
Must be tested within this issue through the implemented methods of UniversalTest.

  • Fill-Up | Narrow, Wide (like Gamma)
  • Follow | Ultra Narrow (max farm APR, max IL), Very Narrow, Narrow
  • Swap | Custom range, custom rebalance trigger (USDC-USDT QuickSwap pool: 1 tickSpacing)

Implementations

  • ALMQuickSwapMerklFarm
  • ALMRetroMerklFarm

Core size optimization

Currently, the platform core contracts have redundant and unused functionality, the deployment of which in other networks will consume extra gas.

  • Platform
    • bridge, setupBridge, $.bridge
    • aprOracle, $.aprOracle
    • rebalancer, setupRebalancer, $.rebalancer
  • VaultBase
    • getApr
  • VaultManager
    • move to off-chain metadata with baseUri
  • StrategyLogic
    • move to off-chain metadata with baseUri

FarmingStrategyBase: stakingPool()

Need to implement IFarmingStrategy.stakingPool to StrategyBase and to final farming strategies with classic farm mechanics.
We need this address in UI etc.

[PROPOSED] Retro Static Boosted Merkl Farm

RSBMF | Retro Static Boosted Merkl Farm

Status: PROPOSED

Status will be changed soon.

Description

Earn Merkl rewards by static liquidity position on Retro with MerklVeBooster's boost.

The idea of the strategy is that supplying liquidity to full range is suitable for many Retro pools due to the peculiarities of Mrekl rewarding parameters (example: 10% fee/45% asset0/45% asset1). I assume that such rewarding parameters in many of their pools are associated with the integration of Ichi for both assets of the pair.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase
  • #47

Adapters

  • UniswapV3Adapter

[OUTDATED, BLOCKED] UniswapV3 Active Swap

UniswapV3ActiveSwapStrategy

Status: OUTDATED, BLOCKED

The strategy cannot be implemented now until the base contracts and interfaces are implemented.

Description of strategy

Like #9 a good way to get acquainted with swap strategies is to read the thesis Providing Liquidity in Uniswap V3.

Basically, this strategy is needed to make money in stable pools with tickspacing 1 (0.01%). Moreover, unlike other strategies, this requires the presence of a sufficient amount of liquidity in the pool and in the network as a whole.

Since Uniswap v3 does not have farming, there is no need to use NFT (NonfungiblePositionManager) when developing the strategy. Working with UniswapV3Pool directly without minting NFTs will help reduce gas costs.

Base contracts

  • LPStrategyBase
  • ActiveStrategyBase #14

Adapters

  • AmmAdapterIdLib.UNISWAPV3

Zap

A zapping solution is required for deposits into vaults and withdrawals from vaults through any blue chip token.
The exchange of an input asset for vault assets upon deposit and the exchange of vault assets for an output token during withdrawal must be done by whitelisted dex aggregator routers.

Custom errors

Use custom errors instead reverts with strings.

There is no point in storing strings with errors in the blockchain; we will only store them in the code and ABI.

[DONE] Ichi QuickSwap Merkl Farm

IQMF

Status: DONE

Developed

Description

Earn MERKL rewards by ICHI vault.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • AmmAdapterIdLib.ALGEBRA

[DONE] Yearn

Y | Yearn

Status: DONE

Developed

Description

Hold Yearn V3 vault shares and emit APR.

Base contracts

  • #115
  • MultiStrategyBase

Adapters

No.

IRMF, GRMF upgrade: transmute oRETRO

Now Retro strategies are liquidating oRETRO rewards through the oRETRO/RETRO pool by Swapper. This is a flawed implementation. This method is neither profitable nor reliable, because there is practically no liquidity in this pool.
It is required to liquidate options similarly to the Transmutation contract, through flash loans.

[DONE] Curve Convex Farm

CCF | Curve Convex Farm

Status: DONE

Deployed

Description

Earn rewards by staking Curve LP to Convex.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • CurveAdapter

[DONE] Gamma Retro Merkl Farm

GRMF | Gamma Retro Merkl Farm

Status: DONE

Developed.

Description

Earn Merkl rewards by Gamma LP.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • UniswapV3Adapter

Active strategy

Description of base strategy

An active strategy is a dynamic position of liquidity burned and minted during rebalancing.

Rebalancing is performed by a server script, which can use various API services, have a rebalancing state for each strategy to implement delays and other rebalancing functionality.

Rebalancing may include swaps through dex aggregators. In this case, the strategy must inform the rebalancing script of the assets and amounts for swaps.

Bridge SC

Stability Bridge contracts meta issue

  • describe arch of bridging TOKEN lock -> ChildATOKEN mint -> burn -> ChildBTOKEN mint -> burn -> TOKEN unlock
  • #41
  • Integrate Bridge to Platform, add chain lib, change deployment flow
  • IInterChainAdapter protocols
  • TokenFactory, ChildERC20, ChildERC721
  • Bridge contract

SplitterVault

  • ISplitterVault
  • SplitterVault
  • AutomaticSplitterManager

[PROPOSED] Gyroscope Aura Farm

GAF | Gyroscope Aura Farm

Status: PROPOSED

Status will be changed soon.

Description

Earn rewards by staking ECLP to Aura.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

[DONE] QuickSwap Static Merkl Farm

QSMF | QuickSwap Static Merkl Farm

Status: DONE

Implemented

Description

Earn Merkl rewards and pool swap fees by static liquidity position on QuickSwap.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • AlgebraAdapter

[PROPOSED] Ichi Retro Boosted Merkl Farm

IRBMF | Ichi Retro Boosted Merkl Farm

Status: PROPOSED

Can be implemented with Boosted base strategy development.

Description

Earn Merkl rewards by Gamma LP.
Strategy need ability to create veNFT and increase lock time and amount.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase
  • #47

Adapters

  • UniswapV3Adapter

Strategies 2024

Implementations

Q1 2024

Q2 2024

Q3 2024

  • #127
  • ALMQuickSwap
  • ALMRetro
  • ALMUniswapV3
  • ALMCamelot
  • Charm
  • Range
  • NitroVault
  • ArrakisV2
  • Bunni
  • Brokkr

Q4 2024

  • BaseSwap
  • Aerodrome
  • Extra Finance
  • Sushi
  • Aave
  • Moonwell
  • Stargate
  • Balancer

Base

  • #87
    • IStrategy.isReadyForHardWork
    • IStrategy.isHardWorkOnDepositAllowed
    • IFarmingStrategy.farmMechanics
  • #124
  • #115
    • IStrategy.autoCompoundingByUnderlyingProtocol()
  • #106
  • #47

Adapters

[OUTDATED, BLOCKED] UniswapV3 Active Follow

UniswapV3ActiveFollowStrategy

Status: OUTDATED, BLOCKED

The strategy cannot be implemented now until the base contracts and interfaces are implemented.

Description of strategy

Strategy must working like Maverck's Mode Both.

Widths: 48%, 24%, 12%, 6%, 2%, 0.02%, 0.01%

Base contracts

  • LPStrategyBase
  • ActiveStrategyBase #14

Adapters

  • AmmAdapterIdLib.UNISWAPV3

ILPStrategy.clPosition

Liquidity providing strategies need common method for view concentrated position.
Position can be composed of few ranges.

For each range we need to know:

  • lowerTick, upperTick
  • liquidity
  • amount0, amount1

[DONE] Gamma QuickSwap Merkl Farm

GQMF

Status: DONE

Developed

Description

Earning MERKL rewards by Gamma LP on QuickSwapV3

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • AmmAdapterIdLib.ALGEBRA

Namespaced Storage

Scopes

  • @iammrjude #39

    • AppOracle
    • Factory
    • Platform
    • PriceReader
    • StrategyLogic
    • Swapper
    • VaultManager
  • @JodsMigel #40

    • VaultBase
    • RVaultBase
    • RMVault
    • StrategyBase
    • LPStrategyBase
    • QuickswapV3StaticFarmStrategy
    • FarmingStrategyBase
    • GammaQuickSwapFarmStrategy
    • CVault
    • RVault

Description

The storage of each core contract must be formed using the Namespaced Storage pattern.
Need to refactor the contract state variables (and getters) to get rid of gaps. This will make contract upgrades more convenient and safer.
Also, in any case, it is more profitable for us to form the state in structures, pointers to which can be passed to libraries in order to save space in the main contract.

ERC-7201

Previously, upgradeable contracts used to have a __gap variable in storage between inherited contracts in order to reserve space for supporting new variables added between upgrades. But, in this new version storage locations are namespaced using ERC-7201 so that variables can be added without compromising previously stored variables.
-- Introducing OpenZeppelin Contracts 5.0

Base ERC7201 contract cant be implemented at this time while solidity has no generics. Read more OpenZeppelin/openzeppelin-contracts#4696

Events

To develop a subgraph, we need the most complete information about the operation of all parts of the system in the logs.
If the data is of interest to analytics and can be sent to logs, then it should be sent there.

Some required events are described in // todo comments in the code.

[REKT] Gamma Retro Boosted Merkl Farm

GRBMF | Gamma Retro Boosted Merkl Farm

Status: REKT

Rekt vault expected.

Description

Earn Merkl rewards by Gamma LP.
Strategy need ability to create veNFT and increase lock time and amount.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase
  • #47

Adapters

  • UniswapV3Adapter

[DONE] Ichi Retro Merkl Farm

IRMF | Ichi Retro Merkl Farm

Status: DONE

Deployed.

Description

Earn Merkl rewards by Ichi Yield IQ strategy.

Base contracts

  • LPStrategyBase
  • FarmingStrategyBase

Adapters

  • UniswapV3Adapter

Factory: initialGasReserve

When creating a vault, the gas reserve for hardworks and rebalances must be contributed by the creator.

RetroBooster & Boosted strategy

BoostedStrategyBase

The boosted strategy receives increased rewards when staking liquidity in Gauges or holding LPs with using veTOKEN power for boost.
This is implemented by staking/holding liquidity through single contract (is IBooster) to which the VE-boost power is delegated or holded veTOKEN management supported.

Such logic was implemented in Tetu V1 GaugeDepositor for Balancer DeX.

This base strategy must be universal.

RetroBooster

Booster can be implemented with linked ERC20 liquid staking token that represents shares of locked RETRO.

LiquidToken

Booster ownership liquid staking voting escrow token.

UI getters

UI getters enhancement

The view functions needs to be implemented and refactored to effectively integrate with the frontend (stability-ui).

  • IPlatform.getData
    • add bcAssets (for ZAP)
    • add dexAggregators
  • On-chain UI vault list: IVaultManager.vaults()
    • add totalApr
    • add strategyApr
    • add name
  • Vault info: implement IVaultManager.vaultInfo(address vault)
    • strategy address
    • strategy assets
    • strategy underlying
    • assetsWithApr, assetsAprs

Base vaults and strategies upgrade

  • IStrategy
    • isReadyForHardWork
    • isHardWorkOnDepositAllowed
  • StrategyBase
    • Swap rewards price impact tolerance = 7%
  • LPStrategyBase
    • Swap assets price impact tolerance = 4%
  • FarmingStrategyBase
    • remove getRewards
  • IFarmingStrategy
    • farmMechanics

[OUTDATED, BLOCKED] UniswapV3 Active Fill-Up

UniswapV3ActiveFillUpStrategy

Status: OUTDATED, BLOCKED

The strategy cannot be implemented now until the base contracts and interfaces are implemented.

Description of strategy

A good way to get acquainted with fill-up strategies is to read the thesis Providing Liquidity in Uniswap V3. Then it’s worth reading the implementation code, for example, in the Gamma's Hypervisor.sol.

While Gamma sets fill-up parameters during rebalancing in the parameters by its authorized address, in our implementation we must set the primary value of the fill-up liquidity proportion and direction, and rebalancing must be carried out entirely based on the on-chain logic of the strategy.

At the same time, we can use a highly rounded proportion of fill-up liquidity and its direction to uniqueize the vaults working with the current strategy.

Setting the initial values of the proportion and direction of the fill-up will be used when creating vaults, which are the underlying tokens of ve-tokens.

Base contracts

  • LPStrategyBase
  • ActiveStrategyBase #14

Adapters

  • AmmAdapterIdLib.UNISWAPV3

Update VaultBase

VaultBase + IVault

  • previewWithdraw
  • changeable single min TVL for free HardWork execution (if there is no MATIC on the vault contract balance)
  • check vault status on deposit
  • deposit address receiver param
  • implement IVault.uniqueInitParamLength() external view returns (uint uiniqueInitAddresses, uint uniqueInitNumvs)
  • decrease code size

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.