πŸ¦‰
Minerva
  • πŸ¦‰Introduction
  • πŸ“šGeneral Resources
    • 🦊How to?
    • πŸ•ŠοΈMigration
    • πŸ“—Contracts
      • πŸ”Access Control
        • ⏰TimeLock
        • πŸ› οΈUpgradeability
        • πŸ›‘οΈFlash Loan Attack Mitigations
      • πŸ—οΈVaults
      • πŸ“¨Router
      • 🏷️Price Feeds
    • πŸ“™Audit
    • ⚠️Risks
    • πŸ›£οΈRoadmap
  • πŸ”΄Tokenomics
    • πŸ—ΊοΈOverview
    • βšͺMINE
    • 🟠allMINE
    • 🟣MLP
      • Buying / Selling MLP
      • MLP Price
      • Transferring Staked MLP
  • πŸ…Core Features
    • πŸ”„Trading
      • Swap
      • Query Available Amounts
      • Opening / Increasing a Position
      • Closing / Decreasing a Position
      • Position List
    • πŸ“ˆFees
    • πŸ’°Rewards
    • πŸ†Weekly Competition
    • πŸ«‚Referall
    • πŸ›οΈGovernance
  • πŸ“„Terms and Services
    • πŸ–‹οΈTerms of Use
Powered by GitBook
On this page
  1. Core Features
  2. Trading

Opening / Increasing a Position

PreviousQuery Available AmountsNextClosing / Decreasing a Position

Last updated 2 years ago

To open or increase the size of an existing position:

  • Approve the PositionRouter as a Router plugin for your account

    • Router.approvePlugin(PositionRouter address)

  • Approve the Router contract for the token and amount you would deposit as collateral for the position

  • Call PositionRouter.createIncreasePosition with parameters:

    • _path: [collateralToken] or [tokenIn, collateralToken] if a swap is needed

    • _indexToken: the address of the token you want to long or short

    • _amountIn: the amount of tokenIn you want to deposit as collateral

    • _minOut: the min amount of collateralToken to swap for

    • _sizeDelta: the USD value of the change in position size

    • _isLong: whether to long or short

    • _acceptablePrice: the USD value of the max (for longs) or min (for shorts) index price acceptable when executing the request

    • _executionFee: can be set to PositionRouter.minExecutionFee

    • _referralCode: for affiliate rewards and rebates

    • _callbackTarget: an optional callback contract, this contract will be called on request execution or cancellation

  • After this transaction is sent a keeper will execute the request, the request will either be executed or cancelled

  • If the position cannot be increased for reasons such as the _acceptablePrice not being fulfillable or there being insufficient liquidity then the request will be cancelled and funds will be sent back to the msg.sender that called PositionRouter.createIncreasePosition

  • _minOut can be zero if no swap is required

  • USD values for _sizeDelta and _price are multiplied by (10 ** 30), so for example to open a long position of size 1000 USD, the value 1000 * (10 ** 30) should be used

πŸ…
πŸ”„
referral code