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
  • initializeOtc
  • updateOtcConfig
  • addOtcCollateralBalance
  • sellGnsForCollateral
  • getOtcConfig
  • getOtcBalance
  • getOtcRate
  • _getSlot
  • _getStorage
  • _getMultiCollatDiamond
  • _calculateGnsAmount
  • Parameters
  • _calculateGnsDistribution
  • Parameters
  • _distributeTreasuryGns
  • Parameters
  • _distributeStakingGns
  • Parameters
  • _burnGns
  • Parameters

Was this helpful?

  1. Developer
  2. Technical Reference
  3. Contracts
  4. Libraries

OtcUtils

OTC facet internal library

initializeOtc

function initializeOtc(struct IOtc.OtcConfig _config) internal

Check IOtcUtils interface for documentation

updateOtcConfig

function updateOtcConfig(struct IOtc.OtcConfig _config) internal

Check IOtcUtils interface for documentation

addOtcCollateralBalance

function addOtcCollateralBalance(uint8 _collateralIndex, uint256 _collateralAmount) internal

Check IOtcUtils interface for documentation

sellGnsForCollateral

function sellGnsForCollateral(uint8 _collateralIndex, uint256 _collateralAmount) internal

Check IOtcUtils interface for documentation

getOtcConfig

function getOtcConfig() internal view returns (struct IOtc.OtcConfig)

Check IOtcUtils interface for documentation

getOtcBalance

function getOtcBalance(uint8 _collateralIndex) internal view returns (uint256)

Check IOtcUtils interface for documentation

getOtcRate

function getOtcRate(uint8 _collateralIndex) internal view returns (uint256)

Check IOtcUtils interface for documentation

_getSlot

function _getSlot() internal pure returns (uint256)

Returns storage slot to use when fetching storage relevant to library

_getStorage

function _getStorage() internal pure returns (struct IOtc.OtcStorage s)

Returns storage pointer for storage struct in diamond contract, at defined slot

_getMultiCollatDiamond

function _getMultiCollatDiamond() internal view returns (contract IGNSMultiCollatDiamond)

Returns current address as multi-collateral diamond interface to call other facets functions.

_calculateGnsAmount

function _calculateGnsAmount(uint8 _collateralIndex, uint256 _collateralAmount, uint256 _gnsPriceCollateral) internal view returns (uint256)

Calculate GNS amount for given collateral amount

Parameters

Name
Type
Description

_collateralIndex

uint8

index of the collateral

_collateralAmount

uint256

amount of collateral (collateral precision)

_gnsPriceCollateral

uint256

price of GNS in collateral (1e10)

_calculateGnsDistribution

function _calculateGnsDistribution(uint256 _gnsAmount) internal view returns (uint256 treasuryAmountGns, uint256 stakingAmountGns, uint256 burnAmountGns)

Calculate GNS distribution for treasury, GNS staking and burn

Parameters

Name
Type
Description

_gnsAmount

uint256

amount of GNS tokens to distribute (1e18)

_distributeTreasuryGns

function _distributeTreasuryGns(uint256 _gnsAmount) internal

Distributes treasury rewards in GNS tokens

Parameters

Name
Type
Description

_gnsAmount

uint256

amount of GNS tokens to distribute (1e18)

_distributeStakingGns

function _distributeStakingGns(uint256 _gnsAmount) internal

Distributes staking rewards in GNS tokens

Parameters

Name
Type
Description

_gnsAmount

uint256

amount of GNS tokens to distribute (1e18)

_burnGns

function _burnGns(uint256 _gnsAmount) internal

Burns GNS tokens

Parameters

Name
Type
Description

_gnsAmount

uint256

amount of GNS tokens to burn (1e18)

PreviousLiquidityPoolUtilsNextPackingUtils

Was this helpful?