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 lastDepositTsNew
notInCooldown
modifier, used byunstakeGns
, reverts if user deposited less thanUNSTAKING_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 transactionstakeGns
: now public (called bycompoundGnsRewards
) and stores current timestamp instakerInfos
mapping for callerunstakeGns
: now usesnotInCooldown
modifiercreateUnlockSchedule
: 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 newGNSOtc
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 initializationupdateOtcConfig
: update treasury address and percentagesaddOtcCollateralBalance
: increases available collateral balance for OTC buying (used byGNSTradingCallbacks
when distributing GNS staking fee)sellGnsForCollateral
: executes OTC transaction; diamond receives GNS and sender receives collateral tokens, available collateral balance for OTC decreases accordinglygetOtcConfig
,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 typesOtcStorage
struct:collateralBalances
mapping,otcConfig
structOtcConfig
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 newGNSOtc
facet
libraries/TradingCommonUtils.sol (update)
convertCollateralToGns
,transferCollateralTo
, and_getMultiCollatDiamond
are now internal: allows not linking TradingCommonUtils toGNSOtc
as internal functions are imported directly into the bytecode, should only make functions external when it becomes an issue for sizeNew
transferGnsTo
andtransferGnsFrom
helpers to handle simple GNS transfers between users and the diamonddistributeGnsStakingFeeCollateral
now calls_getMultiCollatDiamond().addOtcCollateralBalance
instead ofgnsStaking.distributeReward
Last updated