---
# System prepended metadata

title: DeFiEdge Docs

---

# DeFiEdge Docs

- [Introduction](#Introduction)
- [Architecture](#Architecture)
    - [Share Distribution](#Share-Distribution)
    - [Rebalance](#Rebalance)
    - [Deposit](#Deposit)
    - [Withdraw](#Withdraw)
- [Strategy Creation](#Strategy-Creation)
- [External Interactions](#External-Interactions)
    - [Price Feeds Orcale](#Price-Feeds-Oracle)
- [Tokenomics](#Tokenomics1)
    - [$EDGE](#EDGE)
- [Security](#Security)
    - [Audit]()


# Introduction
DeFiEdge is an asset management protocol on top of [uniswap v3](https://docs.uniswap.org/protocol/introduction) pools that connects liquidity providers with different fund managers to streamline user’s investments. DeFiEdge is: 

**Permissionless**:  DeFiEdge Protocol’s permissionless factory smart contracts allows anyone to be a strategy manager. Users can invest in the strategies of their choice and can deposit or withdraw guns anytime without restriction.  

**Decentralized**: Users choose their preferred strategy manager based on parameters like manager profile, performance consistency, previously earned APYs and the like.

**Non-custodial**: Users at DeFiEdge Protocol hold full custody of their funds. 

# Architecture
### Share Distribution
Strategy shares are represented as ERC-20 tokens (symbol: DEshare) which are composable and fungible. Strategy shares represent the user’s liquidity and fees earned from uniswap v3 pool in a particular strategy.

Initial shares are minted in 1:1 ratio of the first deposit and later it uses uniswap’s TWAP oracle to do the share calculation. 

`formula here`

### Rebalance
Strategy managers can set multiple ranges and allocate the liquidity in percentage(%) to each range. Managers can also choose which token to be accepted from their users (primary range can be set according to that).

Our swapping and precision algorithm will effectively calculate the swap amount (if swap is required to deploy entered percentage of liquidity) based on the ranges provided. If manager swaps the required amount, precision algorithm will recalculate the percentage of liquidity deployment and the swapping algorithm will again tell if the swap is required (this is due to slippage) and this will continuously goes on loop until the manager is satisfied with percentage of liquidity deployment and skips the swap.

For example, let’s say manager wants to deploy 100% of strategy’s liquidity in ETH-DAI pool, and swapping algorithm calculates that manger has x amount of DAI less, it will show that, if you want to deploy 100% of the liquidity then swap 100 DAI to ETH. If the manager skips this swap then our precision algorithm will recalculate the liquidity deployment in such a way that it deploys what the strategy currently has (let’s say it will get deployed only 90%). But if the manager swaps 100 DAI to ETH then it will now show that 100% or slightly less than 100% will get deployed (provided the pool has enough liquidity present). Slightly less because slippage may incur.

### Deposit
On depositing the token(s), shares are minted and transferred to the depositor's account which represents the liquidity.

Deposit of token(s) is based on the primary range set by the strategy manager. If the primary range is a single-sided range (current price is out of the range) then the user has to deposit only one token out of two depending on the range. And if it is dual-sided (current price is within range) then both tokens should be deposited.

If the management and protocol fees are enabled, the shares are deducted based on percentage from the user's shares at the time of deposit.

### Withdraw
Shares (DEshare) can be withdrawn at any time and without any restrictions or limitations. When the user withdraws their share, it is transferred back to the protocol and the liquidity and fees earned till date is returned back to the user based on proportion.

# Strategy Creation
In order to create a strategy, the caller(any account) can call [`Factory.createStrategy()`](https://github.com/unbound-finance/defiedge-core/blob/main/contracts/DefiEdgeStrategyFactory.sol#L52). The steps taken by this function are:

1. Factory creates a new [`DefiEdgeStrategy`](https://github.com/unbound-finance/defiedge-core/blob/main/contracts/DefiEdgeStrategy.sol#L14) contract.
2. It sets the `pool` address and the initial ranges for that pool.

Ranges can can be set in such a way that either of the pool token(`token0` or `token1`) is accepted or both.

# External Interactions

### Price Feeds Oracle
`DefiEdgeStrategy` contract uses uniswap V3's TWAP(time weighted average price) oracle to get time weighted tick to calculate price and mint initial shares of particular strategy.

Docs: https://docs.uniswap.org/protocol/concepts/V3-overview/oracle

# Tokenomics

### $EDGE
$EDGE will be used as the governance token for DeFiEdge Protocol that will represent the ownership of the token holders in the protocol.

The token holders will be responsible for the future development of the protocol once the product and distribution is sufficiently decentralized. This includes decisions regarding future NFT launchpads for strategy managers and protocol fees.

# Security

### Audits
With a view to secure our platform from possible cyber attacks and maintain the integrity of user funds, DeFiEdge Protocol's smart contracts have been already audited once and the next audit is underway. 

The first audit has been conducted by Damian Rusinek, a well-respected auditor from [Securings](https://www.securing.pl/).

The second audit has been planned and is underway with Lucash- dev, a recipient of the [Whitehat Scholarship](https://immunefi.medium.com/immunefi-launches-whitehat-scholarship-f2a469c6a09d) at [Immunefi](https://immunefi.com/), one of the highest-paid bug bounty hunters at [Hackerone](https://www.hackerone.com/).
