Javsphere Docs
Open AppJoin Trading Competition
  • Open Javsphere App
  • Welcome to Javsphere
  • Javsphere Stats
  • Fundamentals
    • Javsphere Set Up
      • Base Chain
      • Connect Wallet
      • Add Tokens
      • New to Crypto
    • Buy & add JAV
  • Products
    • LeverageX
      • Assets
        • Cryptocurrencies
        • Stocks
        • Forex
        • Commodities
      • Fees & Spread
      • Trader
        • Open Trade
        • Edit & Close Trade
      • Earn LLP Pool
        • Buy LLP
        • LLP Price & APY
      • xJAV Vault
        • FAQ
      • Limitations
      • Testing
      • Trading Competitions
      • Referral
    • StakeX
    • CryoVault
  • Trading Competitions
    • Current Competition
      • Create Profile
      • Create Community
      • Old competitions
        • Competition Vol. 3
        • Competition Vol. 2
        • Competition Vol. 1
        • Tournament
    • Zealy Campaign
      • Old Airdrops
        • Infinity Pass
        • CFR
        • UPT
        • DTL
        • RNG
        • DPM & Baby Dana
        • GRWV
    • Become a Sponsor
  • JAV Token
    • Utility
    • Whitepaper
      • Javsphere and JAV Token
        • JAV Token
          • Javsphere Fee Structure
          • Tokenomics
        • Added Value for Holders
        • Javsphere Technology
          • StakeX
          • CryoVault
          • LeverageX
      • Disclaimer
    • Governance
      • Onchain Proposals
      • Migration to Base
      • Offchain Proposals
      • Submit a Proposal
    • Base Migration
    • JAV Burn
  • JAVLIS
    • The Ultimate AI Agent
      • Ecosystem
      • USPs
      • Boost for LeverageX
      • Business Model
      • Roadmap
      • Virtuals as Infrastructure
      • More than a hype
      • Hiring
    • Buy JAVLIS
  • Engineering
    • Oracle System
    • Smart Contracts
      • LeverageX
        • JavBorrowingFees
        • JavFeeTiers
        • JavPairsStorage
        • JavPriceAggregator
        • JavPriceImpact
        • JavReferrals
        • JavTradingInteractions
        • JavTradingProcessing
        • JavTradingStorage
        • JavBorrowingProvider
        • LLPToken
        • Feeds
      • JavPriceAggregator
      • JavFreezer
      • JavStakeX
    • Github
    • Bug Bounty Program
  • Community & More
    • Content Library
      • Logos
      • UI Mockups
    • Social Content
    • Socials
      • Telegram Guidelines
  • LEGAL
    • Privacy Policy
    • Terms of Use
      • Excluded Jurisdictions
    • Migration Terms
    • Cookie Policy
    • Trading Competition Terms
    • Bug Bounty Terms
Powered by GitBook
On this page
  • General Description
  • Core Functionalities
  • initializeTradingStorage
  • updateTradingActivated
  • addCollateral
  • toggleCollateralActiveState
  • updateBorrowingProvider
  • updateCollateralApprove
  • storeTrade
  • updateTradeMaxClosingSlippageP
  • updateTradeCollateralAmount
  • updateTradePosition
  • updateOpenOrderDetails
  • updateTradeTp
  • updateTradeSl
  • closeTrade
  • getCollateral
  • isCollateralActive
  • isCollateralListed
  • getCollateralsCount
  • getCollaterals
  • getCollateralIndex
  • getTradingActivated
  • getTraderStored
  • getTraders
  • getTrade
  • getTrades
  • getAllTrades
  • getTradeInfo
  • getTradeInfos
  • getAllTradeInfos
  • getCounters
  • getTradeLiquidationParams
  • getTradesLiquidationParams
  • getAllTradesLiquidationParams
  • getBorrowingProvider

Was this helpful?

  1. Engineering
  2. Smart Contracts
  3. LeverageX

JavTradingStorage

General Description

The JavTradingStorage contract used for managing the trading system's storage and operations, including the handling of collateral, trades, and trade-related details. It allows for the initialization and configuration of the trading environment, such as setting up the supported collateral, adjusting trading activation status, and linking to a borrowing provider. The contract enables the storage, modification, and retrieval of trade data, including managing trade position parameters, stop loss, take profit, and slippage conditions. Additionally, it provides several functions to query and manipulate collateral data, such as activating/deactivating collaterals and adding new ones. The system also supports the management and retrieval of liquidation parameters and counters for individual traders.

Core Functionalities

initializeTradingStorage

  • Initializes the trading storage with essential configuration settings, such as rewards token, rewards distributor, borrowing provider, and supported collaterals.

  • Parameters:

    • _rewardsToken: Address of the rewards token.

    • _rewardsDistributor: Address of the rewards distributor contract.

    • _borrowingProvider: Address of the borrowing provider.

    • _collaterals: List of collateral addresses.

    • _collateralsIndexes: List of corresponding indexes for each collateral.

  • Access Control: External.

updateTradingActivated

  • Updates the trading activation state (whether trading is active or not).

  • Parameters:

    • _activated: The new trading activation state.

  • Access Control: External.

addCollateral

  • Adds a new collateral to the supported list of collaterals.

  • Parameters:

    • _collateral: Address of the new collateral.

    • _index: Index of the collateral in the supported list.

  • Access Control: External.

toggleCollateralActiveState

  • Toggles the active state of an existing collateral (enables or disables it for trading).

  • Parameters:

    • _collateralIndex: Index of the collateral to toggle.

  • Access Control: External.

updateBorrowingProvider

  • Updates the address of the borrowing provider.

  • Parameters:

    • _borrowingProvider: New borrowing provider address.

  • Access Control: External.

updateCollateralApprove

  • Updates the approval state for a specified collateral.

  • Parameters:

    • _collateralIndex: Index of the collateral to update approval for.

  • Access Control: External.

storeTrade

  • Stores a new trade, including details for trade, limit, or stop orders.

  • Parameters:

    • _trade: Trade data to be stored.

    • _tradeInfo: Additional trade info to be stored.

  • Returns: Trade – The stored trade.

  • Access Control: External.

updateTradeMaxClosingSlippageP

  • Updates the maximum closing slippage for a specified trade.

  • Parameters:

    • _tradeId: ID of the trade to update.

    • _maxSlippageP: New maximum slippage percentage (1e3 precision).

  • Access Control: External.

updateTradeCollateralAmount

  • Updates the collateral amount for an open trade.

  • Parameters:

    • _tradeId: ID of the trade to update.

    • _collateralAmount: New collateral amount (collateral precision).

  • Access Control: External.

updateTradePosition

  • Updates the position parameters of an open trade, including collateral, leverage, and open price.

  • Parameters:

    • _tradeId: ID of the trade to update.

    • _collateralAmount: New collateral amount.

    • _leverage: New leverage.

    • _openPrice: New open price.

    • _isPartialIncrease: If true, refreshes liquidation parameters.

  • Access Control: External.

updateOpenOrderDetails

  • Updates the details of an open order, including price, take profit (tp), stop loss (sl), and slippage.

  • Parameters:

    • _tradeId: ID of the trade to update.

    • _openPrice: New open price (1e10 precision).

    • _tp: New take profit price (1e10 precision).

    • _sl: New stop loss price (1e10 precision).

    • _maxSlippageP: New maximum slippage percentage (1e3 precision).

  • Access Control: External.

updateTradeTp

  • Updates the take profit (tp) of an open trade.

  • Parameters:

    • _tradeId: ID of the trade to update.

    • _newTp: New take profit price (1e10 precision).

  • Access Control: External.

updateTradeSl

  • Updates the stop loss (sl) of an open trade.

  • Parameters:

    • _tradeId: ID of the trade to update.

    • _newSl: New stop loss price (1e10 precision).

  • Access Control: External.

closeTrade

  • Marks an open trade, limit, or stop order as closed.

  • Parameters:

    • _tradeId: ID of the trade to close.

  • Access Control: External.

getCollateral

  • Returns collateral data for a specified index.

  • Parameters:

    • _index: Index of the collateral to retrieve.

  • Returns: Collateral – The collateral data.

  • Access Control: External.

isCollateralActive

  • Returns whether a specified collateral is active for trading.

  • Parameters:

    • _index: Index of the collateral.

  • Returns: bool – Whether the collateral is active.

  • Access Control: External.

isCollateralListed

  • Returns whether a specified collateral has been listed in the system.

  • Parameters:

    • _index: Index of the collateral.

  • Returns: bool – Whether the collateral is listed.

  • Access Control: External.

getCollateralsCount

  • Returns the count of supported collaterals in the system.

  • Returns: uint8 – Number of supported collaterals.

  • Access Control: External.

getCollaterals

  • Returns a list of all supported collaterals.

  • Returns: Collateral[] – List of collaterals.

  • Access Control: External.

getCollateralIndex

  • Returns the index of a specific collateral.

  • Parameters:

    • _collateral: Address of the collateral.

  • Returns: uint8 – Index of the collateral.

  • Access Control: External.

Trader & Trade Information Retrieval

getTradingActivated

  • Returns the current trading activation state.

  • Returns: TradingActivated – The current state.

  • Access Control: External.

getTraderStored

  • Checks if a trader is stored in the traders array.

  • Parameters:

    • _trader: Address of the trader to check.

  • Returns: bool – Whether the trader is stored.

  • Access Control: External.

getTraders

  • Retrieves a list of traders with open trades, using pagination.

  • Parameters:

    • _offset: Start index.

    • _limit: End index.

  • Returns: address[] – List of traders.

  • Access Control: External.

getTrade

  • Retrieves a specific trade for a trader.

  • Parameters:

    • _trader: Address of the trader.

    • _index: Index of the trade.

  • Returns: Trade – The trade data.

  • Access Control: External.

getTrades

  • Retrieves all trades for a specified trader.

  • Parameters:

    • _trader: Address of the trader.

  • Returns: Trade[] – List of trades.

  • Access Control: External.

getAllTrades

  • Retrieves all trades in the system using pagination.

  • Parameters:

    • _offset: Start index.

    • _limit: End index.

  • Returns: Trade[] – List of trades.

  • Access Control: External.

getTradeInfo

  • Retrieves trade info for a specified trader and trade index.

  • Parameters:

    • _trader: Address of the trader.

    • _index: Index of the trade.

  • Returns: TradeInfo – The trade info.

  • Access Control: External.

getTradeInfos

  • Retrieves all trade info for a specified trader.

  • Parameters:

    • _trader: Address of the trader.

  • Returns: TradeInfo[] – List of trade info.

  • Access Control: External.

getAllTradeInfos

  • Retrieves all trade info using pagination.

  • Parameters:

    • _offset: Start index.

    • _limit: End index.

  • Returns: TradeInfo[] – List of trade info.

  • Access Control: External.

getCounters

  • Returns the counters for a specified trader (open trades, trade infos, pending orders).

  • Parameters:

    • _trader: Address of the trader.

  • Returns: Counter – The trader's counters.

  • Access Control: External.

getTradeLiquidationParams

  • Retrieves liquidation parameters for a specific trade.

  • Parameters:

    • _trader: Address of the trader.

    • _index: Index of the trade.

  • Returns: GroupLiquidationParams – The liquidation parameters.

  • Access Control: External.

getTradesLiquidationParams

  • Retrieves liquidation parameters for all trades of a trader.

  • Parameters:

    • _trader: Address of the trader.

  • Returns: GroupLiquidationParams[] – List of liquidation parameters.

  • Access Control: External.

getAllTradesLiquidationParams

  • Retrieves all liquidation parameters using pagination.

  • Parameters:

    • _offset: Start index.

    • _limit: End index.

  • Returns: GroupLiquidationParams[] – List of liquidation parameters.

  • Access Control: External.

getBorrowingProvider

  • Returns the address of the liquidity provider.

  • Returns: address – Address of the borrowing provider.

  • Access Control: External.

Last updated 6 months ago

Was this helpful?