Gains Network
  • 📚Home
  • Gains Network
    • 🔎Overview
    • 🍏GNS Token
    • 📔Contract Addresses
      • Apechain Mainnet
      • Arbitrum Mainnet
      • Base Mainnet
      • Polygon Mainnet
  • gTrade (Leveraged Trading)
    • 🔎Overview
    • 🎛️Setting up to trade
      • 🟣Polygon Network Setup
      • 🔵Arbitrum Network Setup
    • 🏦Opening / Closing trades
    • 💲Trade Collaterals
      • Spotlight: WETH
    • 📖Asset classes
      • 🪙Cryptocurrencies
      • 💵Forex
      • 🛢️Commodities
    • 🎫Fees & Spread
    • 📰Pair List
    • 🧒How to use Practice Mode
    • ⚡One-Click Trading (1CT)
    • 🌌gTrade Solana
    • 📺Video tutorials
  • Loyalty Programs
    • Prime Trader
    • gTrade Credits
  • Community
    • gTrade Guardians
    • Governance forum
  • Reward Pools
    • 💚GNS Staking
    • 👛gToken Vaults
      • 👷Staker Functions
      • ❔Staker FAQ
      • ⏳Upgrades, updates, and timelocks
    • 🔼Active Pools & Incentives
  • Help
    • ❓FAQ
    • ⏳Chain congestion
  • Bridges
    • 🪐Arbitrum <-> Polygon Bridge
    • 🪐ERC20 Bridge (Polygon)
    • 🪐NFT Bridge (Polygon)
  • Developer
    • Integrators
      • Trading Contracts
      • Backend
      • Price Feed
      • Guides
        • v9 migration
        • Calculating borrowing fees
        • Calculating liquidation price
    • Technical Reference
      • Contracts
        • Changelogs
          • v9.2.1 Update
          • v9.1 Update
          • v9.1.1 Update
          • v9 Update
        • Core
          • Abstract
            • GNSAddressStore
            • GNSDiamondCut
            • GNSDiamondLoupe
            • GNSDiamondStorage
          • Facets
            • GNSBorrowingFees
            • GNSOtc
            • GNSPriceAggregator
            • GNSTradingInteractions
            • GNSTriggerRewards
            • GNSFeeTiers
            • GNSPairsStorage
            • GNSPriceImpact
            • GNSReferrals
            • GNSTradingCallbacks
            • GNSTradingStorage
          • GNSMultiCollatDiamond
          • GNSStaking
          • GToken
          • GTokenOpenPnlFeed
        • Interfaces
          • Libraries
            • IBorrowingFeesUtils
            • IOtcUtils
            • IPriceAggregatorUtils
            • ITriggerRewardsUtils
            • IFeeTiersUtils
            • IPairsStorageUtils
            • IPriceImpactUtils
            • IReferralsUtils
            • ITradingCallbacksUtils
            • ITradingCommonUtils
            • ITradingInteractionsUtils
            • ITradingStorageUtils
            • IUpdateLeverageUtils
            • IUpdatePositionSizeUtils
          • Types
            • IAddressStore
            • IBorrowingFees
            • IDiamondStorage
            • IOtc
            • IPriceAggregator
            • ITradingStorage
            • ITradingInteractions
            • ITriggerRewards
            • ITypes
            • IUpdateLeverage
            • IPairsStorage
            • IFeeTiers
            • IPriceImpact
            • IReferrals
            • ITradingCallbacks
            • IUpdatePositionSize
          • IChainlinkFeed
          • IArbSys
          • IChainlinkOracle
          • IERC20
          • IERC721
          • IERC721Design
          • IGeneralErrors
          • IGNSAddressStore
          • IGNSDiamond
          • IGNSDiamondCut
          • IGNSMultiCollatDiamond
          • IGNSDiamondLoupe
          • IGNSStaking
          • IGToken
          • IGTokenLockedDepositNft
          • IGTokenOpenPnlFeed
          • IGTokenLockedDepositNftDesign
          • ILiquidityPool
          • IRateProvider
          • IOwnable
        • Libraries
          • updateLeverage
            • UpdateLeverageLifecycles
          • updatePositionSize
            • IncreasePositionSizeUtils
            • DecreasePositionSizeUtils
            • UpdatePositionSizeLifecycles
          • AddressStoreUtils
          • ChainlinkClientUtils
          • ChainUtils
          • ConstantsUtils
          • CollateralUtils
          • DiamondUtils
          • LiquidityPoolUtils
          • OtcUtils
          • PackingUtils
          • StorageUtils
          • TriggerRewardsUtils
          • ArrayGetters
          • BorrowingFeesUtils
          • FeeTiersUtils
          • PriceAggregatorUtils
          • PriceImpactUtils
          • ReferralsUtils
          • TradingCallbacksUtils
          • PairsStorageUtils
          • TradingCommonUtils
          • TradingStorageUtils
          • TradingInteractionsUtils
        • Misc
          • EpochBasedTokenClaim
          • GNSCompensationHandler
          • GTokenRateProvider
          • GTokenLockedDepositNftDesign
          • ManagerTimelock
          • OwnerTimelock
          • VotingDelegator
        • Tokens
          • GainsNetworkToken
          • GTokenLockedDepositNft
      • Backend
        • Backend Types
      • SDK
        • Client Types
  • Archived
    • 🖼️gFARM2 NFTs
Powered by GitBook
On this page
  • BorrowingFeesStorage
  • BorrowingData
  • BorrowingPairGroup
  • OpenInterest
  • BorrowingInitialAccFees
  • BorrowingPairParams
  • BorrowingGroupParams
  • BorrowingFeeInput
  • LiqPriceInput
  • PendingBorrowingAccFeesInput

Was this helpful?

  1. Developer
  2. Technical Reference
  3. Contracts
  4. Interfaces
  5. Types

IBorrowingFees

Contains the types for the GNSBorrowingFees facet

BorrowingFeesStorage

struct BorrowingFeesStorage {
  mapping(uint8 => mapping(uint16 => struct IBorrowingFees.BorrowingData)) pairs;
  mapping(uint8 => mapping(uint16 => struct IBorrowingFees.BorrowingPairGroup[])) pairGroups;
  mapping(uint8 => mapping(uint16 => struct IBorrowingFees.OpenInterest)) pairOis;
  mapping(uint8 => mapping(uint16 => struct IBorrowingFees.BorrowingData)) groups;
  mapping(uint8 => mapping(uint16 => struct IBorrowingFees.OpenInterest)) groupOis;
  mapping(uint8 => mapping(address => mapping(uint32 => struct IBorrowingFees.BorrowingInitialAccFees))) initialAccFees;
  uint256[44] __gap;
}

BorrowingData

struct BorrowingData {
  uint32 feePerBlock;
  uint64 accFeeLong;
  uint64 accFeeShort;
  uint48 accLastUpdatedBlock;
  uint48 feeExponent;
}

BorrowingPairGroup

struct BorrowingPairGroup {
  uint16 groupIndex;
  uint48 block;
  uint64 initialAccFeeLong;
  uint64 initialAccFeeShort;
  uint64 prevGroupAccFeeLong;
  uint64 prevGroupAccFeeShort;
  uint64 pairAccFeeLong;
  uint64 pairAccFeeShort;
  uint64 __placeholder;
}

OpenInterest

struct OpenInterest {
  uint72 long;
  uint72 short;
  uint72 max;
  uint40 __placeholder;
}

BorrowingInitialAccFees

struct BorrowingInitialAccFees {
  uint64 accPairFee;
  uint64 accGroupFee;
  uint48 block;
  uint80 __placeholder;
}

BorrowingPairParams

struct BorrowingPairParams {
  uint16 groupIndex;
  uint32 feePerBlock;
  uint48 feeExponent;
  uint72 maxOi;
}

BorrowingGroupParams

struct BorrowingGroupParams {
  uint32 feePerBlock;
  uint72 maxOi;
  uint48 feeExponent;
}

BorrowingFeeInput

struct BorrowingFeeInput {
  uint8 collateralIndex;
  address trader;
  uint16 pairIndex;
  uint32 index;
  bool long;
  uint256 collateral;
  uint256 leverage;
}

LiqPriceInput

struct LiqPriceInput {
  uint8 collateralIndex;
  address trader;
  uint16 pairIndex;
  uint32 index;
  uint64 openPrice;
  bool long;
  uint256 collateral;
  uint256 leverage;
  bool useBorrowingFees;
  struct IPairsStorage.GroupLiquidationParams liquidationParams;
}

PendingBorrowingAccFeesInput

struct PendingBorrowingAccFeesInput {
  uint64 accFeeLong;
  uint64 accFeeShort;
  uint256 oiLong;
  uint256 oiShort;
  uint32 feePerBlock;
  uint256 currentBlock;
  uint256 accLastUpdatedBlock;
  uint72 maxOi;
  uint48 feeExponent;
  uint128 collateralPrecision;
}
PreviousIAddressStoreNextIDiamondStorage

Was this helpful?