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
  • setBorrowingPairParams
  • setBorrowingPairParamsArray
  • setBorrowingGroupParams
  • setBorrowingGroupParamsArray
  • handleTradeBorrowingCallback
  • resetTradeBorrowingFees
  • getBorrowingPairPendingAccFees
  • getBorrowingGroupPendingAccFees
  • getTradeBorrowingFee
  • getTradeLiquidationPrice
  • getPairOisCollateral
  • getBorrowingPairGroupIndex
  • getPairOiCollateral
  • withinMaxBorrowingGroupOi
  • getBorrowingGroup
  • getBorrowingPair
  • getBorrowingPairOi
  • getBorrowingPairGroups
  • getAllBorrowingPairs
  • getBorrowingGroups
  • getBorrowingInitialAccFees
  • getPairMaxOi
  • getPairMaxOiCollateral

Was this helpful?

  1. Engineering
  2. Smart Contracts
  3. LeverageX

JavBorrowingFees

General Description

The JavBorrowingFees contract used for managing borrowing fees, parameters, and related data in LeverageX.

Core Functionalities

setBorrowingPairParams

Updates the parameters of a borrowing pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

    • _value (BorrowingPairParams): New parameters.


setBorrowingPairParamsArray

Updates the parameters of multiple borrowing pairs.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _indices (uint16[]): Array of pair indices.

    • _values (BorrowingPairParams[]): Array of new parameters.


setBorrowingGroupParams

Updates the parameters of a borrowing group.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _groupIndex (uint16): Group index.

    • _value (BorrowingGroupParams): New parameters.


setBorrowingGroupParamsArray

Updates the parameters of multiple borrowing groups.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _indices (uint16[]): Array of group indices.

    • _values (BorrowingGroupParams[]): Array of new parameters.


handleTradeBorrowingCallback

Handles borrowing fees and open interests when a trade is opened or closed.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _trader (address): Trader's address.

    • _pairIndex (uint16): Pair index.

    • _index (uint32): Trade index.

    • _positionSizeCollateral (uint256): Trade position size in collateral tokens.

    • _open (bool): True if trade is opened.

    • _long (bool): True if trade is long.


resetTradeBorrowingFees

Resets borrowing fees for a trade.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _trader (address): Trader's address.

    • _pairIndex (uint16): Pair index.

    • _index (uint32): Trade index.

    • _long (bool): True if trade is long.


getBorrowingPairPendingAccFees

Returns pending accumulated borrowing fees for a pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

    • _currentBlock (uint256): Current block number.

  • Returns:

    • accFeeLong (uint64): Accumulated fees on the long side.

    • accFeeShort (uint64): Accumulated fees on the short side.

    • pairAccFeeDelta (uint64): Fee delta for the changed side.


getBorrowingGroupPendingAccFees

Returns pending accumulated borrowing fees for a group.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _groupIndex (uint16): Group index.

    • _currentBlock (uint256): Current block number.

  • Returns:

    • accFeeLong (uint64): Accumulated fees on the long side.

    • accFeeShort (uint64): Accumulated fees on the short side.

    • groupAccFeeDelta (uint64): Fee delta for the changed side.


getTradeBorrowingFee

Calculates borrowing fees for a trade.

  • Parameters:

    • _input (BorrowingFeeInput): Trade input data.

  • Returns:

    • feeAmountCollateral (uint256): Borrowing fee in collateral tokens.


getTradeLiquidationPrice

Calculates the liquidation price for a trade.

  • Parameters:

    • _input (LiqPriceInput): Trade input data.

  • Returns:

    • uint256: Liquidation price.


getPairOisCollateral

Gets open interests for a pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • longOi (uint256): Long open interest.

    • shortOi (uint256): Short open interest.


getBorrowingPairGroupIndex

Gets the borrowing group index for a pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • groupIndex (uint16): Group index.


getPairOiCollateral

Gets open interest for a pair on one side.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

    • _long (bool): True if long side.

  • Returns:

    • uint256: Open interest in collateral tokens.


withinMaxBorrowingGroupOi

Checks if a trade is within the max group borrowing open interest.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

    • _long (bool): True if long side.

    • _positionSizeCollateral (uint256): Position size in collateral tokens.

  • Returns:

    • bool: True if within max borrowing OI.


getBorrowingGroup

Gets data for a borrowing group.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _groupIndex (uint16): Group index.

  • Returns:

    • BorrowingData: Group data.


getBorrowingPair

Gets data for a borrowing pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • BorrowingData: Pair data.


getBorrowingPairOi

Gets open interest data for a borrowing pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • OpenInterest: Open interest data.


getBorrowingPairGroups

Gets groups data for a borrowing pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • BorrowingPairGroup[]: Groups data.


getAllBorrowingPairs

Gets all borrowing pair data, open interests, and group data.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

  • Returns:

    • BorrowingData[]: Pair data.

    • OpenInterest[]: Open interests.

    • BorrowingPairGroup[][]: Group data.


getBorrowingGroups

Gets borrowing groups’ data and open interest.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _indices (uint16[]): Group indices.

  • Returns:

    • BorrowingData[]: Group data.

    • OpenInterest[]: Open interests.


getBorrowingInitialAccFees

Gets initial accumulated borrowing fees for a trade.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _trader (address): Trader’s address.

    • _index (uint32): Trade index.

  • Returns:

    • BorrowingInitialAccFees: Initial fees data.


getPairMaxOi

Gets the max open interest for a pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • uint256: Max open interest.


getPairMaxOiCollateral

Gets the max open interest in collateral tokens for a pair.

  • Parameters:

    • _collateralIndex (uint8): Collateral index.

    • _pairIndex (uint16): Pair index.

  • Returns:

    • uint256: Max open interest in collateral tokens.

Last updated 5 months ago

Was this helpful?