Xeon Protocol Docs
  • Quick Links
  • Welcome to Xeon Protocol
    • Introduction
    • Proposition
    • TAM
    • Mission
  • Ecosystem
    • Overview
    • Products
    • Mindmap
    • Core Engineering
  • OTC Tools
    • Lending
    • Call Options
    • Put Options
    • Equity Swaps
    • USPs
  • How It Works
    • Use Cases
    • Scenarios
    • Quick Guide
    • DynamicPacts
    • P/L Calculations
  • Staking XEON
    • How to Stake
    • Assignments
    • Rewards
  • 🌾Real Yield
    • Protocol Income
    • Farming Pools
    • Native Hedge Liquidity
    • Native Loan Collateral
    • Yield Farming
  • 👨‍🌾EARN WITH US
    • How to Earn
    • Hedge Mining
  • ☄️Fees
    • Model
    • Cashier Fees
    • Settlement Fees
  • ⚡Costing and Valuation
    • Highlights
    • Value in Pair Currency
    • Underlying Value
  • 💸ERC20 Hedging
    • Traditional Hedging
    • Neon Hedging Model
    • Traditional Costing Models
      • Binomial VS Monte Carlo
      • Binomial Model
      • Costing Example
      • Conclusion
    • Neon Costing Model
    • Writing Approach
    • Deleting a Hedge
    • Settlement
  • 🪶ERC20 Lending
    • Crypto Lending
    • Neon Lending Model
    • Neon Valuation Model
    • Writing Approach
    • Settlement
  • ⚙️Mechanics
    • ERC20 Vault Model
    • ERC20 Deposit/Withdraw
    • getPairAddress
    • Underlying Value
    • Write
    • Buy
    • Topup
    • Zap
    • Settlement
    • Mining
    • LockedInUse
    • 🧑‍🚀Development
      • Dev Format
      • GitHub
      • Deployments
      • Testnet
      • Security Audits
  • Brand Policy
Powered by GitBook
LogoLogo

Xeon Protocol © 2024

On this page
  • Types of deals to buy:
  • Buying conditions:
  • buyHedge Function

Was this helpful?

Export as PDF
  1. Mechanics

Buy

Taking a OTC deal using deposited token balance.

PreviousWriteNextTopup

Last updated 1 year ago

Was this helpful?

To buy a hedge the msg.sender must have a sufficient balance of the tokens being hedged, under the userBalanceMap[msg.sender] storage.

All deals on our platform are collateralized fully by both parties, amounts and type of collateral to be put up for each deal depend on the parties.

Types of deals to buy:

  • Call Option

  • Put Option

  • Equity Swap

  • Loan

Buying a deal (hedge or loan) utilizes the lockedinuse storage under userBalanceMap[msg.sender] as described in the below topic.

Buying conditions:

  • A deal can be taken as long as its listed and available or unexpired.

  • Only the paired currency of the underlying assets or tokens can be used to purchase a hedge.

  • For loaning, the requested token is not strict but determined by the writer.

  • Buyer must have enough sufficient balance of the required token deposited to Vault.

  • Hedge writer always has to provide collateral, thus the payoff (if any) to the taker is always in underlying assets.

  • Hedge taker collateral type is determined by the type of deal. Options taker collateral is asked in the form of underlying tokens paired currency. Swap taker collateral is asked in the form of underlying tokens being hedged.

buyHedge Function

This function is unified to handle the taking of all hedge types (options and swaps) and will also handle loans.

All deals taken will have their storage structs, under the mapping hedgeMap updated. hedge.status is updated from 0 (available) to 1 (taken), hedge.taker is wallet address of signer or msg.sender.

// For Call and Put Options cost is premium, lockedinuse here but paid out on settlement
// For Equity Swaps cost is equal to underlying value as 100% collateral is required. There is no premium

Two helper functions are used in the process getUserTokenBalances to check if taker has sufficient balance, and getUnderlyingValue to determine the startValue of the deal in its paired currency.

The global hedge taken arrays are updated with the ID of the hedge to help with filtering. myoptionsTaken stores wallet specific trades taken. We then update the protocol volume storage hedgesTakenVolume.

The takers collateral, or available balance is then added to lockedInUse. Depending on type of deal it can be credited to the writer immediately or only handled on settlement.

All inputs should meet requirement and if successful, a hedgePurchased event is emitted to signify the writing of the deal.

⚙️
LockedInUse