# Hedge: Redefining Asset Protection in Decentralized Finance

**Hedge** is a decentralized finance (DeFi) platform that brings sophisticated tools that are fundamental to the finance space to DeFi, in a fully transparent, open and permissionless way, allowing for the creation of arbitrary hedging tools using fully collateralized options to move away from pure speculation to real tools which allow not just crypto hedging but for access for anyone to hedge any assets they want in a non-custodial, transparent, permissionless and fully collateralized way. \
\
We combine the flexbility of being able to create options for arbitrary assets, on demand yet using a straightforward approach to hedging financial assets onchain. It utilizes fully onchain tools to allow users to create and utilize PUT options, providing a mechanism for both securing assets against potential price declines and enabling profitable opportunities for option creators in bullish markets. You can create a Hedge for any asset you want from Crypto to commodities to fiat while benefitting from fully onchain collateralization for transparency and counterparty risk management! Use any API, choose your expiry and tokenize positions for  completely liquid positions.

#### Key Features at a Glance:

* **Effortless PUT Creation**: Customize a hedge option on your chosen asset, defining your terms for expiry and collateral.
* **Leverage Support**: Utilize leverage on your PUT, particularly beneficial for assets with low volatility.
* **Flexible Collateral**: While it initially accommodates stablecoins (like USDC), the protocol is built to handle various forms of collateral.
* **Your Choice of Price Source**: Select the API that will source your strike price.
* **Delta Payouts**: Receive the Delta (difference) between the strike and current price at expiry. PUT sellers can redeem collateral, less the Delta, at expiry.
* **Tokenization**: PUTs can be sold on any decentralized exchange (DEX) you prefer, allowing for liquidity.

### **How Hedge Works**

1. **Minting PUT Options:**
   * **Sellers**: Those bullish on a particular asset can mint PUT options by selecting a target price (strike price) and providing collateral in a stablecoin (e.g., USDC). They then create a contract that can be held until a specific expiration time (e.g., 1 year).
   * **Earning Premiums**: The minted PUT options can be sold to buyers, earning the sellers premiums under the assumption that the asset’s price will rise.
2. **Utilizing PUT Options:**
   * **Buyers**: Investors seeking to hedge against potential losses can purchase these PUT options.
   * **Exercising Options**: If, at expiry, the asset's price is below the strike price, buyers can exercise the options, receiving the difference between the strike price and the asset's current price, thereby mitigating losses.
   * **No Exercise**: If the price is above the strike price, the option is not exercised, and sellers redeem their full collateral, keeping the earned premiums as profit.
3. **Trading PUT Options:**
   * The minted PUT options can be traded on decentralized exchanges like Uniswap, providing liquidity and enabling buyers to hedge against various assets and establish free and liquid markets.

### Uses

* **Risk Mitigation for Asset Holders:**
  * Hedge provides a mechanism for asset holders to protect themselves against unfavorable price movements, ensuring that they can hedge their investments against downturns in the market.
* **Profit Opportunities for Option Sellers:**
  * For those confident in the upward trajectory of an asset, Hedge provides a way to profit from this belief by allowing them to earn premiums from selling PUT options. If their belief holds and the asset price is above the strike at expiry, they also reclaim their collateral, making it a profitable venture.
* **Enhanced Market Dynamics:**
  * By enabling a decentralized mechanism for hedging, Hedge potentially stabilizes the market dynamics by providing a structured way for investors to safeguard against price movements.
* **Accessibility and Inclusivity:**
  * Hedge democratizes financial protection by providing an open platform where anyone can hedge their assets without the need for traditional financial intermediaries, thereby opening up sophisticated financial instruments to a wider array of investors, while maintaining full collateralization.

Hedge endeavors to provide a balanced and robust platform where users, regardless of their market outlook, can find tools to either protect their investments or leverage their market predictions in a secure and decentralized manner.


# Hedge 101

Understanding Hedge: Exercising Options and Exploring Profit & Loss Scenarios

Welcome to the innovative world of Hedge, a decentralized finance (DeFi) platform where the mechanisms of traditional finance are reimagined. In this guide, we will explore the aspect of exercising options and understanding the possible scenarios of profit and loss, providing a detailed yet friendly exploration of Hedge.

### Exercising Options: A Clear Explanation

#### Demystifying Option Exercise

Consider an option as a specialized ticket. This ticket grants you the right, without obligation, to buy or sell an asset at a pre-agreed price, known as the "strike price." To exercise an option means to use this ticket, deciding to trade the underlying asset at the strike price instead of the prevailing market price. These are are **Hedges**.

#### The Vision Behind Hedge

Hedge isn’t just a platform; it's a pioneering concept designed to reshape our engagement with financial options. Imagine crafting a safety net (a hedge) for any asset, from commodities to cryptocurrencies, across various networks. Hedge seeks to make this vision tangible, enabling users to create a PUT option on any asset, using any price source, all within a mere 60 seconds.

#### How Hedge Works:

1. **Selling and Earning Premiums**: If you possess a bullish outlook on the asset, sell the PUT option, earning premiums and speculating that the asset’s price will ascend.
2. **Expiry and Exercise**: At expiry, if you hold a PUT, you can exercise it, claiming the discrepancy between the current asset price and the strike price.
3. **Redemption**: If the asset’s price at expiry eclipses the strike price, sellers can redeem their full collateral, earning the premium as profit.

### A Closer Look

Exercising an option refers to invoking the rights embedded in an option contract. In the context of PUT options, to exercise is to sell the underlying asset at the agreed-upon strike price. This is generally done when the market price of the asset is below the strike price, providing a hedge against descending prices.

### Navigating Profit & Loss Scenarios in PUT Options

#### For PUT Option Sellers:

* **Profit Scenario**:
  * If the asset’s price at expiry is above the strike price, you, the seller, retain the premium and recover all your collateral.
* **Loss Scenario**:
  * If the asset’s price at expiry falls below the strike price, you experience a loss: the Delta between the strike and the asset’s price at expiry, mitigated somewhat by the earned premium.

#### For PUT Option Holders:

* **Profit Scenario**:
  * If the asset’s price at expiry is beneath the strike price, you, the holder, can exercise the option, securing a payout equivalent to the Delta between the two prices.
* **Loss Scenario**:
  * If the asset’s price at expiry sails above the strike price, the option expires worthless, and your loss is confined to the premium paid.

### How to Redeem PUT Options with Hedge

* **Understanding Expiry:**
  * Every PUT option comes with an expiration date, after which the option can be exercised.
  * The holder of the PUT option has the right, but not the obligation, to exercise it.
* **Redemption Process:**
  * If the market price of the asset is below the agreed strike price at expiry, the holder may exercise the option. The holder receives the difference between the strike price and the current market price, providing a buffer against the asset's depreciation.
  * If the asset’s price is above the strike price at expiry, it is not financially prudent to exercise the option. The seller can redeem their full collateral, having earned the premium as profit.
* **Scenario:**
  * Consider a PUT option with a strike price of $100 and expiry in one month. If the market price drops to $80, the holder can exercise the option, selling the asset for the strike price of $100, thus safeguarding against a $20 loss per asset.
  * If the market price rises to $120, the holder will likely opt not to exercise the option, losing only the premium paid, while the seller reclaims their collateral.

### Why Buy Hedges?

**Risk Mitigation:**

* A hedge acts as an insurance policy, providing an avenue to offset potential losses in your investment portfolio. It allows you to limit your exposure to unwanted risks, particularly in volatile markets.

**Profit and Loss Management:**

* By strategically using hedges, investors can define the limits of their potential profit or loss. Even in a worst-case scenario, having a hedge in place ensures that losses do not exceed a predefined amount.

**Market Dynamics:**

* PUT options provide a counterbalance in the market. While buyers of the PUT options safeguard themselves against price drops, sellers of the PUTs (typically bullish investors) can earn premiums, providing a win-win scenario in the market.

**Strategic Investment:**

* For seasoned traders and investors, hedges can serve as a strategic tool, enabling them to navigate through the financial markets, manage risks effectively, and secure profits amidst the ebb and flow of asset prices.

**Premium Earnings for Sellers:**

* Sellers of PUT options earn premiums and, if the market price of the asset stays above the strike price, they reclaim their collateral, effectively earning free premiums.

**Flexible Financial Instrument:**

* Hedge allows the creation of PUT options for a myriad of assets, providing flexibility and a wide array of options for investors to safeguard their various investments and take on new opportunities.

Hedge provides a robust and flexible platform, enabling users to navigate through financial markets with an added layer of security and strategic depth. The platform's ability to create and utilize PUT options for various assets provides a decentralized, secure, and transparent mechanism to hedge against risks and earn premiums, thus enriching the DeFi ecosystem. Always remember: while hedging protects your assets to an extent, it is crucial to understand the underlying mechanisms and to invest responsibly.


# Creating Your Own Option

### Step 1: Creating your own Option&#x20;

Navigate to&#x20;

<http://hedge.markets/>

\
Click on **create option**, then fill in the following&#x20;

name: The name of the new token.&#x20;

symbol: The symbol of the new token.

oracle: An oracle that provide price data. For example, you can use the address Scry oracle

0x0000000000071821e8033345a7be174647be0706.

collateral token: The ERC20 token that will be used as collateral. You can use the DAI token which you can mint for free from [https://sepolia.etherscan.io/address/0x53844F9577C2334e541Aec7Df7174ECe5dF1fCf0#code…](https://t.co/hqI8o79n4q)&#x20;

expiry: The expiry time for the option contract in minutes from now.&#x20;

strikePrice: The strike price of the option contract.&#x20;

API: The API endpoint from which the oracle fetches the price data. For example, [https://api.exchange.coinbase.com/products/ETH-USD/stats/](https://t.co/GZEtsr61F4)

API Path: The specific path in the API where the relevant price data can be found. For the Coinbase API, you can use 'last'.&#x20;

decimals: The number of decimal places in the price data. For the Coinbase API, use 2.&#x20;

bounties: An bounty for the oracle. A suggestion 0.001 ETH.&#x20;

### Step 2. Wait for oracle to update, mint your option tokens, and manage them as per your strategy.&#x20;

You can refresh the oracle data using 'update feeds' and 'update price' functions, and after the expiry, refresh request using 'updateFeeds' and 'updatePrice' to be able to redeem. Remember, you can use any APIs or data sources for price data you prefer.&#x20;

You've now successfully created your own option for arbitrary assets! This allows for advanced financial strategies and interactions to be conducted fully on-chain, even where the asset is not tokenized or not on the network.&#x20;


# Demand-Focused Liquidity

Innovating Liquidity in DeFi: Demand-Focused Option Creation with Hedge

In traditional finance, liquidity is often a measure of market health, reflecting the ease with which assets can be traded. However, in the burgeoning space of DeFi, conventional liquidity pools sometimes fall short in addressing the dynamic needs of modern traders. Enter **Hedge** — redefining how we approach liquidity through on-demand, user-generated options facilitated by Uniswap V3's concentrated liquidity feature.

**Crafting Customized Options: A New Era of DeFi Flexibility**

Hedge's groundbreaking approach deviates from the "one-size-fits-all" liquidity pools that DeFi enthusiasts are accustomed to. Instead of pre-minting options, Hedge introduces a concept akin to bespoke tailoring in fashion:

1. **User-Driven Option Creation:**
   * Traders aren't limited to choosing from existing options; they conceptualize the option they desire, specifying the parameters that suit their strategic needs, including the asset, strike price, expiration date.
2. **Uniswap V3 Integration:**
   * Once the option parameters are set, the trader places a one-sided order on Uniswap V3 to buy the option amount. This isn't a typical trade — it's an expression of demand, setting the stage for a new option market.
3. **On-the-Fly Liquidity:**
   * Here’s where the magic happens: this demand doesn't just sit idle. It beckons liquidity providers. Anyone seeing the order can decide to mint the required option and sell it directly into the order, effectively fulfilling the buyer's request.

**Target Concept: Request-Based Liquidity**

The brilliance of Hedge lies in its demand-driven liquidity model, a departure from the monolithic liquidity pools common in DeFi. This model fosters a dynamic marketplace where the options only exist if there's demand, ensuring capital efficiency and reducing unnecessary market clutter.

1. **Efficiency and Dynamism:**
   * Liquidity is not spread thin across countless options, some of which might see little to no activity. Instead, it’s concentrated where there's actual demand, optimizing capital allocation and market responsiveness.
2. **Innovative Liquidity Provision:**
   * Liquidity providers aren't just passive market participants; they actively fulfill demand, minting options based on real-time market needs. This role is more proactive and engaging, offering potentially better rewards for aligning with market demand.
3. **User Empowerment:**
   * Traders are not at the mercy of existing market structures. They have the power to create their market, defining what options exist based on their trading strategies.
4. **Reduced Slippage, Improved Price Execution:**
   * With liquidity tailored to demand, price slippage is minimized, and both buyers and sellers experience improved price execution, making trading less costly and more predictable.

Hedge's innovative approach to liquidity provision and option creation represents a significant leap forward in the DeFi space. By aligning liquidity with trader demand, Hedge not only optimizes capital use but also empowers users, enhances market efficiency, and paves the way for the next generation of financial derivatives in decentralized finance. This user-focused, demand-driven model could very well be the blueprint for future DeFi innovations, setting a new standard that other platforms will aspire to emulate.


# For The 1337 Devs

### Smart Contract Overview: Delta

The `Delta` contract, an ERC20 token, is the core of the Hedge protocol. It enables users to mint, manage, and redeem options fully onchain with collateral management.

**State Variables**

* `morpheus`: An array of oracle addresses to fetch asset prices.
* `IDs`: An array of IDs corresponding to the oracles.
* `collateralToken`: Address of the ERC20 token used as collateral.
* `expiry`: Expiry time of the option contract.
* `strikePrice`: The price at which option can be exercised.
* `priceDec`: Decimals places for the price.
* `currentPrice`: Current price of the asset fetched from the oracle.
* `timestamp`: Latest timestamp of the price update.
* `collateral`: Mapping of address to collateral amount.
* `name`: Name of the token.
* `symbol`: Symbol of the token.

**Events**

* `Initialized`: Emitted when the contract is initialized.
* `Minted`: Emitted when new options are minted.
* `Delta`: Emitted when profit is calculated.
* `Unlocked`: Emitted when collateral is unlocked.
* `Redeemed`: Emitted when options are redeemed.
* `PriceUpdated`: Emitted when asset price is updated.

#### Core Functions

**Initialization**

```solidity
function init(
    string memory name_,
    string memory symbol_,
    address[] memory _morpheus,
    address _collateralToken,
    uint _expiry,
    uint _strikePrice,
    string memory APIendpoint,
    string memory APIendpointPath,
    uint256 dec
) public payable
```

Initialize the contract with specified parameters.

* **Inputs**:
  * `name_`: Name of the option token.
  * `symbol_`: Symbol of the option token.
  * `_morpheus`: Addresses of oracles.
  * `_collateralToken`: Address of the collateral token.
  * `_expiry`: Expiry time of options.
  * `_strikePrice`: Strike price for the option.
  * `APIendpoint`: API endpoint for fetching price.
  * `APIendpointPath`: Specific path for price data in the API response.
  * `dec`: Decimal places for price.
* **Revert**: The collateral token must not have been set previously.
* **Effects**: Sets state variables and requests feed from oracles to begin setup.

**Minting Options**

```solidity
function mint(address to, uint amount) public
```

Allows a user to mint options by depositing collateral.

* **Inputs**:
  * `to`: Address receiving the minted options.
  * `amount`: Amount of options to be minted.
* **Revert**: Must be called before the expiry time.
* **Effects**: Transfers collateral, updates collateral mapping, and mints the new options and assigns them to the **to** address.

**Calculating Profit**

```solidity
function getDelta() public view returns (uint profit)
```

Calculate the profit obtainable if the option is exercised for 1 option token.&#x20;

* **Outputs**:
  * `profit`: The difference between strike price and current price, if profitable.

**Unlocking Collateral**

```solidity
function unlock(uint amount) public
```

Allows the holder of an option thats also minter to unlock collateral by burning options. Allows for liquidity, minimization of opportunity cost risk.

* **Inputs**:
  * `amount`: Amount of **collateral** to unlock.
* **Effects**: Reduces collateral, burns options for corresponding amount, and transfers collateral back to the user.

**Redeeming Options**

```solidity
function redeem() public
```

The redeem function allows a holder of the options to redeem their options after the expiry date. The amount of collateral returned depends on the strike price, the current price, and the leverage. Also refunds collateral back to minters for strike - delta.

* **Requirements**: Must be called after the expiry time.
* **Effects**: Calculates payoff, burns options, and transfers payoff and/or collateral back to the holder.

**Updating Price**

```solidity
function updatePrice() external returns (uint value)
```

Update the current price of the asset using oracle.

* **Outputs**:
  * `value`: The updated price.
* **Requirements**: Must be called before expiry and reach a quorum.
* **Effects**: Updates `currentPrice` and `timestamp` state variables.
* `updateFeeds`: Allow updating of oracle feeds.
* `sort`: Sorts an array of integers.
* `quickSort`: A helper function for sorting.
* `decimals`: Overrides ERC20 decimals to return collateral token decimals.

#### Updating Oracle Feeds

```solidity
function updateFeeds() external payable
```

The `updateFeeds` function does not take any explicit inputs and must be sent Ether to operate, which is then distributed amongst the oracles in `morpheus` as bounties. The function cycles through each oracle in the `morpheus` array, assigning each oracle a task with an equal share of the total sent Ether as a bounty, ensuring that the oracles are incentivized to return the requested data. This is crucial for obtaining fresh and accurate data for the `updatePrice` function.

**Effects:**

* Iterates through the `morpheus` array, distributing the sent value (`msg.value`) evenly as bounties across the oracles.
* Invokes the `supportFeeds` function on each oracle, supplying the requisite ID and bounty.

#### Conclusion

**Hedge** allows the decentralized creation and management of PUT options, providing a mechanism for hedging assets and earning premiums in the DeFi space.&#x20;

#### Disclaimer

Engage with smart contracts and platforms understanding the associated risks.x


# Deployments

**Factory**\
<https://sepolia.etherscan.io/address/0xcA849DCfD993364dA80EC12046390ca9f1cdaa82>


# Info

### Twitter      <https://twitter.com/hedgemarkets>

### Github

### <https://github.com/ScryProtocol/dapp/tree/Hedge>

### dApp <http://hedge.markets/><br>


