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
  • Summary
  • Full Changelog
  • core/GNSStaking.sol (update)
  • core/abstract/GNSDiamondStorage.sol (update)
  • core/facets/GNSOtc.sol (new)
  • interfaces/IGNSMultiCollatDiamond.sol (update)
  • interfaces/IGNSStaking.sol (update)
  • interfaces/IGeneralErrors.sol (update)
  • interfaces/libraries/IOtcUtils.sol (new)
  • interfaces/types/IOtc.sol (new)
  • interfaces/types/IPriceAggregator.sol (update)
  • interfaces/types/ITypes.sol (update)
  • libraries/OtcUtils.sol (new)
  • libraries/StorageUtils.sol (update)
  • libraries/TradingCommonUtils.sol (update)

Was this helpful?

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

v9.1 Update

Summary

  • New features: GNS staking fees are all used to buy GNS, sends an adjustable % to treasury, burn, and GNS staking rewards and uses an adjustable price premium; new compound function in GNS staking

  • Other changes: There is a 100 seconds cooldown to wait before one can unstake after staking GNS to prevent flashloans (vests must be 100 seconds long at least too now)

Full Changelog

core/GNSStaking.sol (update)

  • New UNSTAKING_COOLDOWN_SECONDS constant (= 100 seconds)

  • New stakerInfos mapping to store each user's lastDepositTs

  • New notInCooldown modifier, used by unstakeGns, reverts if user deposited less than UNSTAKING_COOLDOWN_SECONDS ago

  • _harvestToken, _harvestFromUnlock, _harvestTokenFromUnlock, harvestToken, harvestTokenFromUnlock, harvestTokenAll now all return the pending token rewards (needed for compound function)

  • New compoundGnsRewards function: harvests pending regular rewards and vest rewards (accepts vests _ids as input) and stakes them in the same transaction

  • stakeGns: now public (called by compoundGnsRewards) and stores current timestamp in stakerInfos mapping for caller

  • unstakeGns: now uses notInCooldown modifier

  • createUnlockSchedule: now checks vest duration >= UNSTAKING_COOLDOWN_SECONDS instead of accepting any non-zero value

core/abstract/GNSDiamondStorage.sol (update)

  • Added otcStorage private state var for new GNSOtc facet

core/facets/GNSOtc.sol (new)

  • New facet which handles the collateral -> GNS OTC buying process and transfer to treasury, burn, and GNS staking rewards (adjustable percentages)

  • initializeOtc: infinite approval of GNS staking contract for GNS token and config initialization

  • updateOtcConfig: update treasury address and percentages

  • addOtcCollateralBalance: increases available collateral balance for OTC buying (used by GNSTradingCallbacks when distributing GNS staking fee)

  • sellGnsForCollateral: executes OTC transaction; diamond receives GNS and sender receives collateral tokens, available collateral balance for OTC decreases accordingly

  • getOtcConfig, getOtcBalance, getOtcRate getters

interfaces/IGNSMultiCollatDiamond.sol (update)

  • Now inherits IOtcUtils

interfaces/IGNSStaking.sol (update)

  • New StakerInfo struct (lastDepositTs and placeholder)

interfaces/IGeneralErrors.sol (update)

  • New InsufficientBalance() error

interfaces/libraries/IOtcUtils.sol (new)

  • Interface for new GNSOtc facet: contains all types, functions, events, and custom errors

interfaces/types/IOtc.sol (new)

  • Interface for new GNSOtc facet: contains all types

  • OtcStorage struct: collateralBalances mapping, otcConfig struct

  • OtcConfig struct: treasury address, percentages (treasury, GNS staking, burn), price premium

interfaces/types/IPriceAggregator.sol (update)

  • Fixed __gap array length, reduced from 41 to 39

interfaces/types/ITypes.sol (update)

  • Now inherits new facet types IOtc

libraries/OtcUtils.sol (new)

  • Internal library for new GNSOtc facet

libraries/StorageUtils.sol (update)

  • Added GLOBAL_OTC_SLOT constant for new GNSOtc facet

libraries/TradingCommonUtils.sol (update)

  • convertCollateralToGns, transferCollateralTo, and _getMultiCollatDiamond are now internal: allows not linking TradingCommonUtils to GNSOtc as internal functions are imported directly into the bytecode, should only make functions external when it becomes an issue for size

  • New transferGnsTo and transferGnsFrom helpers to handle simple GNS transfers between users and the diamond

  • distributeGnsStakingFeeCollateral now calls _getMultiCollatDiamond().addOtcCollateralBalance instead of gnsStaking.distributeReward

Previousv9.2.1 UpdateNextv9.1.1 Update

Last updated 8 months ago

Was this helpful?