Akropolis
  • 🕶️Introduction
  • 🧠Using Akropolis
  • 💸Products
    • 🌀Vortex
      • 💫Overview
      • 💻How it works
      • 🛣️Roadmap
      • ✍️Competitor Comparison
    • 🎆Yearn Integration
    • 💜AKRO staking
  • 🏛️Governance
    • 🟣AKRO token
    • 📋Governance process
  • 🏗️Developer documentation
    • 💫Vortex
      • 👓High-Level View
      • 🍭Contract Design
      • 🌾Key Function - harvest
      • 🧑‍💻🧑💻 Integration guide
      • ❗Risk Management
        • Position Buffer
        • remargin()
        • unwind()
        • emergencyExit()
        • Funding Rate Monitoring
    • 🚦Deployed Contracts
      • Vortex
        • Testnet contracts
    • 🐧Open Source Development
      • Amun Ra
      • Pensify
      • C2FC
      • AkropolisOS
      • Sparta
      • Delphi
      • Polkahub
      • Ethereum <-> Substrate bridge
      • Web3 Wallet Kit
      • Substrate Staking portal
  • 🔐Security
    • 🔮Audits
    • 🐞Bug Bounty
  • 📚Additional Resources
    • 📑FAQ
    • 💥Community Channels
    • 📓Basis Trading and Perpetual Contracts
Powered by GitBook
On this page
  1. Developer documentation
  2. Vortex
  3. Risk Management

unwind()

In historic crypto-market conditions the funding rate has consistently been positive, which is an assumption that this strategy relies on. The Managers of Vortex are constantly monitoring the funding rate and ensuring that it remains positive; if it stays negative for a prolonged amount of time then the Manager can unwind() the funds to prevent any further losses. This function can also be used to prevent a liquidation. The unwind() function is described below:

    /**
     * @notice  unwind the position in adverse funding rate scenarios, settle short position
     *          and pull funds from the margin account. Then converts the long position back
     *          to want.
     * @dev     only callable by the owner
     */
    function unwind() public onlyAuthorised {
        require(!isUnwind, "unwound");
        isUnwind = true;
        mcLiquidityPool.forceToSyncState();
        // swap long asset back to want
        _swap(IERC20(long).balanceOf(address(this)), long, want);
        // check if the perpetual is in settlement, if it is then settle it
        // otherwise unwind the fund as normal.
        if (!_settle()) {
            // close the short position
            _closeAllPerpPositions();
            // withdraw all cash in the margin account
            mcLiquidityPool.withdraw(
                perpetualIndex,
                address(this),
                getMargin()
            );
        }
        // reset positions
        positions.perpContracts = 0;
        positions.margin = getMargin();
        positions.unitAccumulativeFunding = getUnitAccumulativeFunding();
        emit StrategyUnwind(IERC20(want).balanceOf(address(this)));
    }

unwind() will close all long positions, then check if the MCDEX perpetual market has been settled. If it has been settled, then all funds will be withdrawn as all positions have already been closed by MCDEX. If the perpetual pool is not settled, then all short positions are closed and withdrawn from the margin account to the strategy contract.

Previousremargin()NextemergencyExit()

Last updated 3 years ago

🏗️
💫
❗