Staking

Contains all staking related interfaces and contracts.

Contracts

IStaking

import "@etherisc/gif-next/contracts/staking/IStaking.sol";
Functions
  • [initializeTokenHandler()]

  • [setSupportInfo(targetType, isSupported, allowNewTargets, allowCrossChain, minStakingAmount, maxStakingAmount, minLockingPeriod, maxLockingPeriod, minRewardRate, maxRewardRate)]

  • [setUpdateTriggers(tvlUpdatesTrigger, minTvlRatioTrigger)]

  • [setProtocolLockingPeriod(lockingPeriod)]

  • [setProtocolRewardRate(rewardRate)]

  • [setStakingRate(chainId, token, stakingRate)]

  • [setStakingService(release)]

  • [setStakingReader(stakingReader)]

  • [addToken(chainId, token)]

  • [approveTokenHandler(token, amount)]

  • [refillRewardReserves(targetNftId, dipAmount)]

  • [withdrawRewardReserves(targetNftId, dipAmount)]

  • [registerTarget(targetNftId, expectedObjectType, initialLockingPeriod, initialRewardRate)]

  • [setLockingPeriod(targetNftId, lockingPeriod)]

  • [setRewardRate(targetNftId, rewardRate)]

  • [setTargetLimits(targetNftId, marginAmount, limitAmount)]

  • [setMaxStakedAmount(targetNftId, stakeLimitAmount)]

  • [addTargetToken(targetNftId, token)]

  • [increaseTotalValueLocked(targetNftId, token, amount)]

  • [decreaseTotalValueLocked(targetNftId, token, amount)]

  • [updateRemoteTvl(targetNftId, token, amount)]

  • [refillRewardReservesByService(targetNftId, dipAmount, transferFrom)]

  • [withdrawRewardReservesByService(targetNftId, dipAmount, transferTo)]

  • [updateTargetLimit(targetNftId)]

  • [createStake(targetNftId, dipAmount, stakeOwner)]

  • [stake(stakeNftId, dipAmount)]

  • [unstake(stakeNftId)]

  • [restake(stakeNftId, newTargetNftId)]

  • [updateRewards(stakeNftId)]

  • [claimRewards(stakeNftId)]

  • [getTargetHandler()]

  • [getStakingStore()]

  • [getStakingReader()]

IVersionable
  • [initializeVersionable(activatedBy, activationData)]

  • [upgradeVersionable(upgradeData)]

  • [getVersion()]

IComponent
  • [getName()]

  • [getToken()]

  • [getTokenHandler()]

  • [getWallet()]

  • [isNftInterceptor()]

  • [isRegistered()]

  • [getComponentInfo()]

  • [getInitialComponentInfo()]

ITransferInterceptor
  • [nftTransferFrom(from, to, tokenId, operator)]

IRegisterable
  • [isActive()]

  • [getInitialInfo()]

IRelease
  • [getRelease()]

INftOwnable
  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

IRegistryLinked
  • [getRegistry()]

IERC165
  • [supportsInterface(interfaceId)]

IAccessManaged
  • [authority()]

  • [setAuthority()]

  • [isConsumingScheduledOp()]

Events
  • [LogStakingStakingRateSet(chainId, token, newStakingRate, oldStakingRate, lastUpdateIn)]

  • [LogStakingStakingServiceSet(stakingService, release, oldStakingService)]

  • [LogStakingStakingReaderSet(stakingReader, oldStakingReader)]

  • [LogStakingTargetHandlerSet(targetManager, oldTargetHandler)]

  • [LogStakingTokenHandlerApproved(token, approvalAmount, oldApprovalAmount)]

  • [LogStakingTokenAdded(chainId, token)]

  • [LogStakingTargetTokenAdded(targetNftId, chainId, token)]

  • [LogStakingTvlIncreased(targetNftId, token, amount, newBalance, lastUpdateIn)]

  • [LogStakingTvlDecreased(targetNftId, token, amount, newBalance, lastUpdateIn)]

  • [LogStakingSupportInfoSet(objectType, isSupported, allowNewTargets, allowCrossChain, minStakingAmount, maxStakingAmount, minLockingPeriod, maxLockingPeriod, minRewardRate, maxRewardRate, lastUpdateIn)]

  • [LogStakingTargetCreated(targetNftId, objectType, lockingPeriod, rewardRate)]

  • [LogStakingLimitsSet(targetNftId, marginAmount, hardLimitAmount, lastUpdateIn)]

  • [LogStakingTargetLimitsUpdated(targetNftId, marginAmount, hardLimitAmount, lastUpdateIn)]

  • [LogStakingTargetLimitUpdated(targetNftId, limitAmount, hardLimitAmount, requiredStakeAmount, actualStakeAmount, lastUpdateIn)]

  • [LogStakingTargetLockingPeriodSet(targetNftId, oldLockingPeriod, lockingPeriod, lastUpdateIn)]

  • [LogStakingTargetRewardRateSet(targetNftId, rewardRate, oldRewardRate, lastUpdateIn)]

  • [LogStakingTargetMaxStakedAmountSet(targetNftId, stakeLimitAmount, lastUpdateIn)]

  • [LogStakingTargetLimitsSet(targetNftId, stakeLimitAmount, marginAmount, limitAmount)]

  • [LogStakingRewardReservesRefilled(targetNftId, dipAmount, targetOwner, reserveBalance, lastUpdateIn)]

  • [LogStakingRewardReservesWithdrawn(targetNftId, dipAmount, targetOwner, reserveBalance, lastUpdateIn)]

  • [LogStakingRewardReservesSpent(targetNftId, dipAmount, reserveBalance, lastUpdateIn)]

  • [LogStakingStakeCreated(stakeNftId, targetNftId, stakeAmount, lockedUntil, stakeOwner)]

  • [LogStakingStakeRewardsUpdated(stakeNftId, rewardIncrementAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingRewardsRestaked(stakeNftId, restakedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingStaked(stakeNftId, stakedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingUnstaked(stakeNftId, unstakedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingRewardsClaimed(stakeNftId, claimedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingStakeRestaked(stakeNftId, targetNftId, stakeAmount, owner, oldStakeNftId)]

IComponent
  • [LogComponentWalletAddressChanged(oldWallet, newWallet)]

  • [LogComponentWalletTokensTransferred(from, to, amount)]

  • [LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

initializeTokenHandler() external

setSupportInfo(ObjectType targetType, bool isSupported, bool allowNewTargets, bool allowCrossChain, Amount minStakingAmount, Amount maxStakingAmount, Seconds minLockingPeriod, Seconds maxLockingPeriod, UFixed minRewardRate, UFixed maxRewardRate) external

Enable/disable the staking support for the specified target type. Defines the degrees of freedom for creating staking targets per target type.

setUpdateTriggers(uint16 tvlUpdatesTrigger, UFixed minTvlRatioTrigger) external

Set the trigger values to determine when to update limit amount in TargetInfo. Changes in the TvlInfo may trigger an update of the limit amount in the TargetInfo based on these settings. The value tvlUpdatesTrigger suppresses any updates if the number of TVL updates is below this value. The value minTvlRatioTrigger defines the minimal TVL ratio above which the limit amount is updated. The ratio is calulated as current TVL / baseline TVL (or baseline TVL / current TVL).

setProtocolLockingPeriod(Seconds lockingPeriod) external

Set the stake locking period for protocol stakes to the specified duration.

setProtocolRewardRate(UFixed rewardRate) external

Set the protocol reward rate.

setStakingRate(ChainId chainId, address token, UFixed stakingRate) external

Set the staking rate for the specified chain and token. The staking rate defines the amount of staked dips required to back up 1 token of total value locked.

setStakingService(VersionPart release) external

Sets/updates the staking service contract to the staking service of the specified release.

setStakingReader(address stakingReader) external

Sets/updates the staking reader contract.

addToken(ChainId chainId, address token) external

Registers a token for recording staking rate and total value locked.

approveTokenHandler(contract IERC20Metadata token, Amount amount) external

Set the approval to the token handler. Defines the max allowance from the staking wallet to the token handler.

refillRewardReserves(NftId targetNftId, Amount dipAmount) → Amount newBalance external

(Re)fills the staking reward reserves for the specified target Unpermissioned: anybody may fill up staking reward reserves

withdrawRewardReserves(NftId targetNftId, Amount dipAmount) → Amount newBalance external

Defunds the staking reward reserves for the specified target Permissioned: only the owner may call this function

registerTarget(NftId targetNftId, ObjectType expectedObjectType, Seconds initialLockingPeriod, UFixed initialRewardRate) external

Register a new target for staking. Permissioned: only the staking service may call this function

setLockingPeriod(NftId targetNftId, Seconds lockingPeriod) external

Set the stake locking period to the specified duration. Permissioned: only the staking service may call this function

setRewardRate(NftId targetNftId, UFixed rewardRate) external

Update the target specific reward rate. Permissioned: only the staking service may call this function

setTargetLimits(NftId targetNftId, Amount marginAmount, Amount limitAmount) external

Set the staking limits for the specified target. The margin amount allows staker to stake over the current required stakes by this amount. The limit amount restricts stakers to ever stake more than this amount. Permissioned: only the target owner may call this function

setMaxStakedAmount(NftId targetNftId, Amount stakeLimitAmount) external

Set the maximum staked amount for the specified target. Permissioned: only the staking service may call this function

addTargetToken(NftId targetNftId, address token) external

Register a token for the specified target. Used for instance targets. Each product may introduce its own token. Permissioned: only the staking service may call this function

increaseTotalValueLocked(NftId targetNftId, address token, Amount amount) external

Increases the total value locked amount for the specified target by the provided token amount. function is called when a new policy is collateralized. function restricted to the pool service.

decreaseTotalValueLocked(NftId targetNftId, address token, Amount amount) external

Decreases the total value locked amount for the specified target by the provided token amount. function is called when a new policy is closed or payouts are executed. function restricted to the pool service.

updateRemoteTvl(NftId targetNftId, address token, Amount amount) external

refillRewardReservesByService(NftId targetNftId, Amount dipAmount, address transferFrom) → Amount newBalance external

(Re)fills the staking reward reserves for the specified target Unpermissioned: anybody may fill up staking reward reserves

withdrawRewardReservesByService(NftId targetNftId, Amount dipAmount, address transferTo) → Amount newBalance external

Defunds the staking reward reserves for the specified target Permissioned: only the owner may call this function

updateTargetLimit(NftId targetNftId) external

Updates the current limit amount for the specified target. The function takes into account the current TVL amount per token and the current staking rate for the token to calculate the required stake amount. Based on this required stake amount and the targets margin and hard limit (from LimitInfo) the function updates the target limit amount (in the target info)

createStake(NftId targetNftId, Amount dipAmount, address stakeOwner) → NftId stakeNftId external

Creates a new stake to the specified target over the given DIP amount. The stake owner is provided as an argument and becomes the stake NFT holder. This function is permissionless and may be called by any user.

stake(NftId stakeNftId, Amount dipAmount) → Amount newStakeBalance external

Increase the staked DIP by dipAmount for the specified stake. Staking rewards are updated and added to the staked DIP amount as well. The function returns the new total amount of staked dips.

unstake(NftId stakeNftId) → Amount unstakedAmount external

Pays the specified DIP amount to the holder of the stake NFT ID. permissioned: only staking service may call this function.

restake(NftId stakeNftId, NftId newTargetNftId) → NftId newStakeNftId, Amount newStakeBalance external

restakes the dips to a new target. the sum of the staked dips and the accumulated rewards will be restaked. permissioned: only staking service may call this function.

updateRewards(NftId stakeNftId) → Amount newRewardAmount external

update stake rewards for current time. may be called before an announement of a decrease of a reward rate reduction. calling this functions ensures that reward balance is updated using the current (higher) reward rate. unpermissioned.

claimRewards(NftId stakeNftId) → Amount rewardsClaimedAmount external

transfers all rewards accumulated so far to the holder of the specified stake nft. permissioned: only staking service may call this function.

getTargetHandler() → contract TargetHandler targetHandler external

getStakingStore() → contract StakingStore stakingStore external

getStakingReader() → contract StakingReader reader external

LogStakingStakingRateSet(ChainId chainId, address token, UFixed newStakingRate, UFixed oldStakingRate, Blocknumber lastUpdateIn) event

LogStakingStakingServiceSet(address stakingService, VersionPart release, address oldStakingService) event

LogStakingStakingReaderSet(address stakingReader, address oldStakingReader) event

LogStakingTargetHandlerSet(address targetManager, address oldTargetHandler) event

LogStakingTokenHandlerApproved(address token, Amount approvalAmount, Amount oldApprovalAmount) event

LogStakingTokenAdded(ChainId chainId, address token) event

LogStakingTargetTokenAdded(NftId targetNftId, ChainId chainId, address token) event

LogStakingTvlIncreased(NftId targetNftId, address token, Amount amount, Amount newBalance, Blocknumber lastUpdateIn) event

LogStakingTvlDecreased(NftId targetNftId, address token, Amount amount, Amount newBalance, Blocknumber lastUpdateIn) event

LogStakingSupportInfoSet(ObjectType objectType, bool isSupported, bool allowNewTargets, bool allowCrossChain, Amount minStakingAmount, Amount maxStakingAmount, Seconds minLockingPeriod, Seconds maxLockingPeriod, UFixed minRewardRate, UFixed maxRewardRate, Blocknumber lastUpdateIn) event

LogStakingTargetCreated(NftId targetNftId, ObjectType objectType, Seconds lockingPeriod, UFixed rewardRate) event

LogStakingLimitsSet(NftId targetNftId, Amount marginAmount, Amount hardLimitAmount, Blocknumber lastUpdateIn) event

LogStakingTargetLimitsUpdated(NftId targetNftId, Amount marginAmount, Amount hardLimitAmount, Blocknumber lastUpdateIn) event

LogStakingTargetLimitUpdated(NftId targetNftId, Amount limitAmount, Amount hardLimitAmount, Amount requiredStakeAmount, Amount actualStakeAmount, Blocknumber lastUpdateIn) event

LogStakingTargetLockingPeriodSet(NftId targetNftId, Seconds oldLockingPeriod, Seconds lockingPeriod, Blocknumber lastUpdateIn) event

LogStakingTargetRewardRateSet(NftId targetNftId, UFixed rewardRate, UFixed oldRewardRate, Blocknumber lastUpdateIn) event

LogStakingTargetMaxStakedAmountSet(NftId targetNftId, Amount stakeLimitAmount, Blocknumber lastUpdateIn) event

LogStakingTargetLimitsSet(NftId targetNftId, Amount stakeLimitAmount, Amount marginAmount, Amount limitAmount) event

LogStakingRewardReservesRefilled(NftId targetNftId, Amount dipAmount, address targetOwner, Amount reserveBalance, Blocknumber lastUpdateIn) event

LogStakingRewardReservesWithdrawn(NftId targetNftId, Amount dipAmount, address targetOwner, Amount reserveBalance, Blocknumber lastUpdateIn) event

LogStakingRewardReservesSpent(NftId targetNftId, Amount dipAmount, Amount reserveBalance, Blocknumber lastUpdateIn) event

LogStakingStakeCreated(NftId stakeNftId, NftId targetNftId, Amount stakeAmount, Timestamp lockedUntil, address stakeOwner) event

LogStakingStakeRewardsUpdated(NftId stakeNftId, Amount rewardIncrementAmount, Amount stakeBalance, Amount rewardBalance, Timestamp lockedUntil, Blocknumber lastUpdateIn) event

LogStakingRewardsRestaked(NftId stakeNftId, Amount restakedAmount, Amount stakeBalance, Amount rewardBalance, Timestamp lockedUntil, Blocknumber lastUpdateIn) event

LogStakingStaked(NftId stakeNftId, Amount stakedAmount, Amount stakeBalance, Amount rewardBalance, Timestamp lockedUntil, Blocknumber lastUpdateIn) event

LogStakingUnstaked(NftId stakeNftId, Amount unstakedAmount, Amount stakeBalance, Amount rewardBalance, Timestamp lockedUntil, Blocknumber lastUpdateIn) event

LogStakingRewardsClaimed(NftId stakeNftId, Amount claimedAmount, Amount stakeBalance, Amount rewardBalance, Timestamp lockedUntil, Blocknumber lastUpdateIn) event

LogStakingStakeRestaked(NftId stakeNftId, NftId targetNftId, Amount stakeAmount, address owner, NftId oldStakeNftId) event

IStakingService

import "@etherisc/gif-next/contracts/staking/IStakingService.sol";
Functions
  • [createInstanceTarget(targetNftId, initialLockingPeriod, initialRewardRate)]

  • [setInstanceLockingPeriod(instanceNftId, lockingPeriod)]

  • [setInstanceRewardRate(instanceNftId, rewardRate)]

  • [setInstanceMaxStakedAmount(instanceNftId, maxStakingAmount)]

  • [refillInstanceRewardReserves(instanceNftId, rewardProvider, dipAmount)]

  • [withdrawInstanceRewardReserves(instanceNftId, dipAmount)]

  • [setTotalValueLocked(targetNftId, token, amount)]

  • [createStakeObject(targetNftId, initialOwner)]

  • [pullDipToken(dipAmount, stakeOwner)]

  • [pushDipToken(dipAmount, stakeOwner)]

  • [approveTokenHandler(token, amount)]

  • [getDipToken()]

  • [getTokenHandler()]

  • [getStaking()]

IService
  • [getDomain()]

  • [getRoleId()]

IVersionable
  • [initializeVersionable(activatedBy, activationData)]

  • [upgradeVersionable(upgradeData)]

  • [getVersion()]

IRegisterable
  • [isActive()]

  • [getInitialInfo()]

IRelease
  • [getRelease()]

INftOwnable
  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

IRegistryLinked
  • [getRegistry()]

IERC165
  • [supportsInterface(interfaceId)]

IAccessManaged
  • [authority()]

  • [setAuthority()]

  • [isConsumingScheduledOp()]

Events
  • [LogStakingServiceProtocolTargetRegistered(protocolNftId)]

  • [LogStakingServiceInstanceTargetRegistered(instanceNftId, chainId)]

  • [LogStakingServiceLockingPeriodSet(targetNftId, oldLockingDuration, lockingDuration)]

  • [LogStakingServiceRewardRateSet(targetNftId, oldRewardRate, rewardRate)]

  • [LogStakingServiceRewardReservesIncreased(targetNftId, rewardProvider, dipAmount, newBalance)]

  • [LogStakingServiceRewardReservesDecreased(targetNftId, targetOwner, dipAmount, newBalance)]

  • [LogStakingServiceStakeObjectCreated(stakeNftId, targetNftId, stakeOwner)]

  • [LogStakingServiceStakeCreated(stakeNftId, targetNftId, owner, stakedAmount)]

  • [LogStakingServiceStakeIncreased(stakeNftId, owner, stakedAmount, stakeBalance)]

  • [LogStakingServiceUnstaked(stakeNftId, stakeOwner, totalAmount)]

  • [LogStakingServiceStakeRestaked(stakeOwner, stakeNftId, newStakeNftId, newTargetNftId, newStakeBalance)]

  • [LogStakingServiceRewardsUpdated(stakeNftId)]

  • [LogStakingServiceRewardsClaimed(stakeNftId, stakeOwner, rewardsClaimedAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

createInstanceTarget(NftId targetNftId, Seconds initialLockingPeriod, UFixed initialRewardRate) external

Creates/registers an on-chain instance staking target. Permissioned: Only instance service

setInstanceLockingPeriod(NftId instanceNftId, Seconds lockingPeriod) external

Set the instance stake locking period to the specified duration. Permissioned: Only instance service

setInstanceRewardRate(NftId instanceNftId, UFixed rewardRate) external

Set the instance reward rate to the specified value. Permissioned: Only instance service

setInstanceMaxStakedAmount(NftId instanceNftId, Amount maxStakingAmount) external

Set the instance max staked amount to the specified value. Permissioned: Only instance service

refillInstanceRewardReserves(NftId instanceNftId, address rewardProvider, Amount dipAmount) → Amount newBalance external

(Re)fills the staking reward reserves for the specified target using the dips provided by the reward provider. Permissioned: Only instance service

withdrawInstanceRewardReserves(NftId instanceNftId, Amount dipAmount) → Amount newBalance external

Defunds the staking reward reserves for the specified target Permissioned: Only instance service

setTotalValueLocked(NftId targetNftId, address token, Amount amount) external

Sets total value locked data for a target contract on a different chain. this is done via CCIP (cross chain communication)

createStakeObject(NftId targetNftId, address initialOwner) → NftId stakeNftId external

Creates a new stake object for the specified target via the registry service. Permissioned: only the staking component may call this function

pullDipToken(Amount dipAmount, address stakeOwner) external

Collect DIP token from stake owner. Permissioned: only the staking component may call this function

pushDipToken(Amount dipAmount, address stakeOwner) external

Transfer DIP token to stake owner. Permissioned: only the staking component may call this function

approveTokenHandler(contract IERC20Metadata token, Amount amount) external

Approves the staking token handler. Permissioned: only the staking component may call this function

getDipToken() → contract IERC20Metadata dip external

getTokenHandler() → contract TokenHandler tokenHandler external

getStaking() → contract IStaking staking external

LogStakingServiceProtocolTargetRegistered(NftId protocolNftId) event

LogStakingServiceInstanceTargetRegistered(NftId instanceNftId, uint256 chainId) event

LogStakingServiceLockingPeriodSet(NftId targetNftId, Seconds oldLockingDuration, Seconds lockingDuration) event

LogStakingServiceRewardRateSet(NftId targetNftId, UFixed oldRewardRate, UFixed rewardRate) event

LogStakingServiceRewardReservesIncreased(NftId targetNftId, address rewardProvider, Amount dipAmount, Amount newBalance) event

LogStakingServiceRewardReservesDecreased(NftId targetNftId, address targetOwner, Amount dipAmount, Amount newBalance) event

LogStakingServiceStakeObjectCreated(NftId stakeNftId, NftId targetNftId, address stakeOwner) event

LogStakingServiceStakeCreated(NftId stakeNftId, NftId targetNftId, address owner, Amount stakedAmount) event

LogStakingServiceStakeIncreased(NftId stakeNftId, address owner, Amount stakedAmount, Amount stakeBalance) event

LogStakingServiceUnstaked(NftId stakeNftId, address stakeOwner, Amount totalAmount) event

LogStakingServiceStakeRestaked(address stakeOwner, NftId indexed stakeNftId, NftId newStakeNftId, NftId indexed newTargetNftId, Amount indexed newStakeBalance) event

LogStakingServiceRewardsUpdated(NftId stakeNftId) event

LogStakingServiceRewardsClaimed(NftId stakeNftId, address stakeOwner, Amount rewardsClaimedAmount) event

Staking

import "@etherisc/gif-next/contracts/staking/Staking.sol";
Functions
  • [initializeTokenHandler()]

  • [setSupportInfo(targetType, isSupported, allowNewTargets, allowCrossChain, minStakingAmount, maxStakingAmount, minLockingPeriod, maxLockingPeriod, minRewardRate, maxRewardRate)]

  • [setUpdateTriggers(tvlUpdatesTrigger, minTvlRatioTrigger)]

  • [setProtocolLockingPeriod(newLockingPeriod)]

  • [setProtocolRewardRate(newRewardRate)]

  • [setStakingRate(chainId, token, stakingRate)]

  • [setStakingService(release)]

  • [setStakingReader(reader)]

  • [addToken(chainId, token)]

  • [approveTokenHandler(token, amount)]

  • [refillRewardReserves(targetNftId, dipAmount)]

  • [withdrawRewardReserves(targetNftId, dipAmount)]

  • [refillRewardReservesByService(targetNftId, dipAmount, transferFrom)]

  • [withdrawRewardReservesByService(targetNftId, dipAmount, transferTo)]

  • [registerTarget(targetNftId, expectedObjectType, initialLockingPeriod, initialRewardRate)]

  • [setLockingPeriod(targetNftId, lockingPeriod)]

  • [setRewardRate(targetNftId, rewardRate)]

  • [setMaxStakedAmount(targetNftId, stakeLimitAmount)]

  • [setTargetLimits(targetNftId, marginAmount, limitAmount)]

  • [addTargetToken(targetNftId, token)]

  • [increaseTotalValueLocked(targetNftId, token, amount)]

  • [decreaseTotalValueLocked(targetNftId, token, amount)]

  • [registerRemoteTarget(targetNftId, targetInfo)]

  • [updateRemoteTvl(targetNftId, token, amount)]

  • [updateTargetLimit(targetNftId)]

  • [createStake(targetNftId, stakeAmount, stakeOwner)]

  • [stake(stakeNftId, stakeAmount)]

  • [unstake(stakeNftId)]

  • [restake(stakeNftId, newTargetNftId)]

  • [updateRewards(stakeNftId)]

  • [claimRewards(stakeNftId)]

  • [getStakingReader()]

  • [getTargetHandler()]

  • [getStakingStore()]

  • [getTokenRegistryAddress()]

  • [getTokenHandler()]

  • [getRelease()]

  • [getVersion()]

  • [_refillRewardReserves(targetNftId, dipAmount, transferFrom)]

  • [_withdrawRewardReserves(targetNftId, dipAmount, transferTo)]

  • [_addToken($, chainId, token)]

  • [_initialize(owner, data)]

  • [_checkTypeAndOwner(nftId, expectedObjectType, checkOwner)]

Versionable
  • [initializeVersionable(activatedBy, data)]

  • [upgradeVersionable(data)]

  • [_upgrade(data)]

Component
  • [__Component_init(authority, registry, parentNftId, name, componentType, isInterceptor, initialOwner, registryData)]

  • [nftTransferFrom(from, to, tokenId, operator)]

  • [getWallet()]

  • [getToken()]

  • [getName()]

  • [getComponentInfo()]

  • [getInitialComponentInfo()]

  • [isNftInterceptor()]

  • [isRegistered()]

  • [_approveTokenHandler(token, amount)]

  • [_nftTransferFrom(from, to, tokenId, operator)]

  • [_setWallet(newWallet)]

  • [_setLocked(locked)]

  • [_getComponentInfo()]

  • [_getServiceAddress(domain)]

Registerable
  • [__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)]

  • [isActive()]

  • [getInitialInfo()]

NftOwnable
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

AccessManagedUpgradeable
  • [__AccessManaged_init(initialAuthority)]

  • [__AccessManaged_init_unchained(initialAuthority)]

  • [authority()]

  • [setAuthority(newAuthority)]

  • [isConsumingScheduledOp()]

  • [_setAuthority(newAuthority)]

  • [_checkCanCall(caller, data)]

ContextUpgradeable
  • [__Context_init()]

  • [__Context_init_unchained()]

  • [_msgSender()]

  • [_msgData()]

  • [_contextSuffixLength()]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
IStaking
  • [LogStakingStakingRateSet(chainId, token, newStakingRate, oldStakingRate, lastUpdateIn)]

  • [LogStakingStakingServiceSet(stakingService, release, oldStakingService)]

  • [LogStakingStakingReaderSet(stakingReader, oldStakingReader)]

  • [LogStakingTargetHandlerSet(targetManager, oldTargetHandler)]

  • [LogStakingTokenHandlerApproved(token, approvalAmount, oldApprovalAmount)]

  • [LogStakingTokenAdded(chainId, token)]

  • [LogStakingTargetTokenAdded(targetNftId, chainId, token)]

  • [LogStakingTvlIncreased(targetNftId, token, amount, newBalance, lastUpdateIn)]

  • [LogStakingTvlDecreased(targetNftId, token, amount, newBalance, lastUpdateIn)]

  • [LogStakingSupportInfoSet(objectType, isSupported, allowNewTargets, allowCrossChain, minStakingAmount, maxStakingAmount, minLockingPeriod, maxLockingPeriod, minRewardRate, maxRewardRate, lastUpdateIn)]

  • [LogStakingTargetCreated(targetNftId, objectType, lockingPeriod, rewardRate)]

  • [LogStakingLimitsSet(targetNftId, marginAmount, hardLimitAmount, lastUpdateIn)]

  • [LogStakingTargetLimitsUpdated(targetNftId, marginAmount, hardLimitAmount, lastUpdateIn)]

  • [LogStakingTargetLimitUpdated(targetNftId, limitAmount, hardLimitAmount, requiredStakeAmount, actualStakeAmount, lastUpdateIn)]

  • [LogStakingTargetLockingPeriodSet(targetNftId, oldLockingPeriod, lockingPeriod, lastUpdateIn)]

  • [LogStakingTargetRewardRateSet(targetNftId, rewardRate, oldRewardRate, lastUpdateIn)]

  • [LogStakingTargetMaxStakedAmountSet(targetNftId, stakeLimitAmount, lastUpdateIn)]

  • [LogStakingTargetLimitsSet(targetNftId, stakeLimitAmount, marginAmount, limitAmount)]

  • [LogStakingRewardReservesRefilled(targetNftId, dipAmount, targetOwner, reserveBalance, lastUpdateIn)]

  • [LogStakingRewardReservesWithdrawn(targetNftId, dipAmount, targetOwner, reserveBalance, lastUpdateIn)]

  • [LogStakingRewardReservesSpent(targetNftId, dipAmount, reserveBalance, lastUpdateIn)]

  • [LogStakingStakeCreated(stakeNftId, targetNftId, stakeAmount, lockedUntil, stakeOwner)]

  • [LogStakingStakeRewardsUpdated(stakeNftId, rewardIncrementAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingRewardsRestaked(stakeNftId, restakedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingStaked(stakeNftId, stakedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingUnstaked(stakeNftId, unstakedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingRewardsClaimed(stakeNftId, claimedAmount, stakeBalance, rewardBalance, lockedUntil, lastUpdateIn)]

  • [LogStakingStakeRestaked(stakeNftId, targetNftId, stakeAmount, owner, oldStakeNftId)]

IComponent
  • [LogComponentWalletAddressChanged(oldWallet, newWallet)]

  • [LogComponentWalletTokensTransferred(from, to, amount)]

  • [LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

onlyStakeOwner(NftId stakeNftId) modifier

onlyTarget(NftId targetNftId) modifier

onlyTargetOwner(NftId targetNftId) modifier

initializeTokenHandler() external

setSupportInfo(ObjectType targetType, bool isSupported, bool allowNewTargets, bool allowCrossChain, Amount minStakingAmount, Amount maxStakingAmount, Seconds minLockingPeriod, Seconds maxLockingPeriod, UFixed minRewardRate, UFixed maxRewardRate) external

Enable/disable the staking support for the specified target type. Defines the degrees of freedom for creating staking targets per target type.

setUpdateTriggers(uint16 tvlUpdatesTrigger, UFixed minTvlRatioTrigger) external

Set the trigger values to determine when to update limit amount in TargetInfo. Changes in the TvlInfo may trigger an update of the limit amount in the TargetInfo based on these settings. The value tvlUpdatesTrigger suppresses any updates if the number of TVL updates is below this value. The value minTvlRatioTrigger defines the minimal TVL ratio above which the limit amount is updated. The ratio is calulated as current TVL / baseline TVL (or baseline TVL / current TVL).

setProtocolLockingPeriod(Seconds newLockingPeriod) external

Set the stake locking period for protocol stakes to the specified duration.

setProtocolRewardRate(UFixed newRewardRate) external

Set the protocol reward rate.

setStakingRate(ChainId chainId, address token, UFixed stakingRate) external

Set the staking rate for the specified chain and token. The staking rate defines the amount of staked dips required to back up 1 token of total value locked.

setStakingService(VersionPart release) external

Sets/updates the staking service contract to the staking service of the specified release.

setStakingReader(address reader) external

Sets/updates the staking reader contract.

addToken(ChainId chainId, address token) external

Registers a token for recording staking rate and total value locked.

approveTokenHandler(contract IERC20Metadata token, Amount amount) public

Set the approval to the token handler. Defines the max allowance from the staking wallet to the token handler.

refillRewardReserves(NftId targetNftId, Amount dipAmount) → Amount newBalance external

(Re)fills the staking reward reserves for the specified target Unpermissioned: anybody may fill up staking reward reserves

withdrawRewardReserves(NftId targetNftId, Amount dipAmount) → Amount newBalance external

Defunds the staking reward reserves for the specified target Permissioned: only the owner may call this function

refillRewardReservesByService(NftId targetNftId, Amount dipAmount, address transferFrom) → Amount newBalance external

(Re)fills the staking reward reserves for the specified target Unpermissioned: anybody may fill up staking reward reserves

withdrawRewardReservesByService(NftId targetNftId, Amount dipAmount, address transferTo) → Amount newBalance external

Defunds the staking reward reserves for the specified target Permissioned: only the owner may call this function

registerTarget(NftId targetNftId, ObjectType expectedObjectType, Seconds initialLockingPeriod, UFixed initialRewardRate) external

Register a new target for staking. Permissioned: only the staking service may call this function

setLockingPeriod(NftId targetNftId, Seconds lockingPeriod) external

Set the stake locking period to the specified duration. Permissioned: only the staking service may call this function

setRewardRate(NftId targetNftId, UFixed rewardRate) external

Update the target specific reward rate. Permissioned: only the staking service may call this function

setMaxStakedAmount(NftId targetNftId, Amount stakeLimitAmount) external

Set the maximum staked amount for the specified target. Permissioned: only the staking service may call this function

setTargetLimits(NftId targetNftId, Amount marginAmount, Amount limitAmount) external

Set the staking limits for the specified target. The margin amount allows staker to stake over the current required stakes by this amount. The limit amount restricts stakers to ever stake more than this amount. Permissioned: only the target owner may call this function

addTargetToken(NftId targetNftId, address token) external

Register a token for the specified target. Used for instance targets. Each product may introduce its own token. Permissioned: only the staking service may call this function

increaseTotalValueLocked(NftId targetNftId, address token, Amount amount) external

Increases the total value locked amount for the specified target by the provided token amount. function is called when a new policy is collateralized. function restricted to the pool service.

decreaseTotalValueLocked(NftId targetNftId, address token, Amount amount) external

Decreases the total value locked amount for the specified target by the provided token amount. function is called when a new policy is closed or payouts are executed. function restricted to the pool service.

registerRemoteTarget(NftId targetNftId, struct IStaking.TargetInfo targetInfo) external

updateRemoteTvl(NftId targetNftId, address token, Amount amount) external

updateTargetLimit(NftId targetNftId) external

Updates the current limit amount for the specified target. The function takes into account the current TVL amount per token and the current staking rate for the token to calculate the required stake amount. Based on this required stake amount and the targets margin and hard limit (from LimitInfo) the function updates the target limit amount (in the target info)

createStake(NftId targetNftId, Amount stakeAmount, address stakeOwner) → NftId stakeNftId external

Creates a new stake to the specified target over the given DIP amount. The stake owner is provided as an argument and becomes the stake NFT holder. This function is permissionless and may be called by any user.

stake(NftId stakeNftId, Amount stakeAmount) → Amount newStakeBalance external

Increase the staked DIP by dipAmount for the specified stake. Staking rewards are updated and added to the staked DIP amount as well. The function returns the new total amount of staked dips.

unstake(NftId stakeNftId) → Amount unstakedAmount external

Pays the specified DIP amount to the holder of the stake NFT ID. permissioned: only staking service may call this function.

restake(NftId stakeNftId, NftId newTargetNftId) → NftId newStakeNftId, Amount newStakedAmount external

restakes the dips to a new target. the sum of the staked dips and the accumulated rewards will be restaked. permissioned: only staking service may call this function.

updateRewards(NftId stakeNftId) → Amount newRewardAmount external

update stake rewards for current time. may be called before an announement of a decrease of a reward rate reduction. calling this functions ensures that reward balance is updated using the current (higher) reward rate. unpermissioned.

claimRewards(NftId stakeNftId) → Amount claimedAmount external

transfers all rewards accumulated so far to the holder of the specified stake nft. permissioned: only staking service may call this function.

getStakingReader() → contract StakingReader reader public

getTargetHandler() → contract TargetHandler targetHandler external

getStakingStore() → contract StakingStore stakingStore external

getTokenRegistryAddress() → address tokenRegistry external

getTokenHandler() → contract TokenHandler tokenHandler public

getRelease() → VersionPart public

getVersion() → Version public

_refillRewardReserves(NftId targetNftId, Amount dipAmount, address transferFrom) → Amount newBalance internal

_withdrawRewardReserves(NftId targetNftId, Amount dipAmount, address transferTo) → Amount newBalance internal

_addToken(struct Staking.StakingStorage $, ChainId chainId, address token) internal

_initialize(address owner, bytes data) internal

top level initializer (upgradable contract)

_checkTypeAndOwner(NftId nftId, ObjectType expectedObjectType, bool checkOwner) internal

StakingStore

import "@etherisc/gif-next/contracts/staking/StakingStore.sol";
Functions
  • [constructor(registry, reader)]

  • [_createInitialSetup()]

  • [initialize(targetLimitHandler)]

  • [setStakingReader(reader)]

  • [setTargetLimitHandler(targetLimitHandler)]

  • [setSupportInfo(targetType, isSupported, allowNewTargets, allowCrossChain, minStakingAmount, maxStakingAmount, minLockingPeriod, maxLockingPeriod, minRewardRate, maxRewardRate)]

  • [getSupportInfo(targetType)]

  • [addToken(chainId, token)]

  • [setStakingRate(chainId, token, stakingRate)]

  • [createTarget(targetNftId, objectType, lockingPeriod, rewardRate)]

  • [setLockingPeriod(targetNftId, lockingPeriod)]

  • [setRewardRate(targetNftId, rewardRate)]

  • [setMaxStakedAmount(targetNftId, stakeLimitAmount)]

  • [setTargetLimits(targetNftId, marginAmount, hardLimitAmount)]

  • [addTargetToken(targetNftId, token)]

  • [refillRewardReserves(targetNftId, dipAmount)]

  • [withdrawRewardReserves(targetNftId, dipAmount)]

  • [increaseTotalValueLocked(targetNftId, token, amount)]

  • [decreaseTotalValueLocked(targetNftId, token, amount)]

  • [updateTargetLimit(targetNftId)]

  • [_checkAndUpdateTargetLimit(targetNftId, token, tvlInfo)]

  • [_updateTargetLimit(targetNftId)]

  • [createStake(stakeNftId, targetNftId, stakeOwner, stakeAmount)]

  • [stake(stakeNftId, updateRewards, restakeRewards, additionalLockingPeriod, stakeAmount)]

  • [unstake(stakeNftId, updateRewards, restakeRewards, maxUnstakeAmount)]

  • [updateRewards(stakeNftId)]

  • [restakeRewards(stakeNftId, updateRewards)]

  • [claimRewards(stakeNftId, updateRewards, maxClaimAmount)]

  • [getStakingReader()]

  • [getTargetManager()]

  • [exists(stakeNftId)]

  • [getRequiredStakeBalance(targetNftId, includeTargetTypeRequirements)]

  • [isStakeLocked(stakeNftId)]

  • [getStakeInfo(stakeNftId)]

  • [getStakeTarget(stakeNftId)]

  • [getTargetInfo(targetNftId)]

  • [getLimitInfo(targetNftId)]

  • [getTvlInfo(targetNftId, token)]

  • [getTokenInfo(chainId, token)]

  • [hasTokenInfo(chainId, token)]

  • [getTargetSet()]

  • [_updateRewards(stakeNftId, stakeInfo, targetInfo)]

  • [_restakeRewards(stakeNftId, stakeInfo, targetInfo)]

  • [_stake(stakeNftId, stakeInfo, targetInfo, maxAdditionalLockingPeriod, stakeAmount)]

  • [_claimRewards(stakeNftId, stakeInfo, targetInfo, maxClaimAmount)]

  • [_unstake(stakeNftId, stakeInfo, targetInfo, maxUnstakeAmount)]

  • [_setLastUpdatesToCurrent(stakeInfo, targetInfo)]

  • [_setStakeLastUpdatesToCurrent(stakeInfo)]

AccessManaged
  • [authority()]

  • [setAuthority(newAuthority)]

  • [isConsumingScheduledOp()]

  • [_setAuthority(newAuthority)]

  • [_checkCanCall(caller, data)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

constructor(contract IRegistry registry, contract StakingReader reader) public

_createInitialSetup() internal

initialize(address targetLimitHandler) external

setStakingReader(address reader) external

setTargetLimitHandler(address targetLimitHandler) external

setSupportInfo(ObjectType targetType, bool isSupported, bool allowNewTargets, bool allowCrossChain, Amount minStakingAmount, Amount maxStakingAmount, Seconds minLockingPeriod, Seconds maxLockingPeriod, UFixed minRewardRate, UFixed maxRewardRate) external

Generic setter for support info. Any change in any of the parameters requires to set all parameters.

getSupportInfo(ObjectType targetType) → struct IStaking.SupportInfo supportInfo external

Returns the support info for the specified target type.

addToken(ChainId chainId, address token) external

Registers a token for tvl management.

setStakingRate(ChainId chainId, address token, UFixed stakingRate) → UFixed oldStakingRate, Blocknumber lastUpdatedIn external

Sets the staking rate for the token.

createTarget(NftId targetNftId, ObjectType objectType, Seconds lockingPeriod, UFixed rewardRate) external

setLockingPeriod(NftId targetNftId, Seconds lockingPeriod) external

setRewardRate(NftId targetNftId, UFixed rewardRate) external

setMaxStakedAmount(NftId targetNftId, Amount stakeLimitAmount) → Amount oldLimitAmount, Blocknumber lastUpdatedIn external

setTargetLimits(NftId targetNftId, Amount marginAmount, Amount hardLimitAmount) external

addTargetToken(NftId targetNftId, address token) external

refillRewardReserves(NftId targetNftId, Amount dipAmount) → Amount newReserveBalance external

withdrawRewardReserves(NftId targetNftId, Amount dipAmount) → Amount newReserveBalance external

increaseTotalValueLocked(NftId targetNftId, address token, Amount amount) → Amount newBalance external

decreaseTotalValueLocked(NftId targetNftId, address token, Amount amount) → Amount newBalance external

updateTargetLimit(NftId targetNftId) → Amount stakeLimitAmount external

_checkAndUpdateTargetLimit(NftId targetNftId, address token, struct IStaking.TvlInfo tvlInfo) internal

_updateTargetLimit(NftId targetNftId) → Amount limitAmount internal

createStake(NftId stakeNftId, NftId targetNftId, address stakeOwner, Amount stakeAmount) → Timestamp lockedUntil external

stake(NftId stakeNftId, bool updateRewards, bool restakeRewards, Seconds additionalLockingPeriod, Amount stakeAmount) external

unstake(NftId stakeNftId, bool updateRewards, bool restakeRewards, Amount maxUnstakeAmount) → Amount unstakedAmount external

updateRewards(NftId stakeNftId) external

restakeRewards(NftId stakeNftId, bool updateRewards) external

claimRewards(NftId stakeNftId, bool updateRewards, Amount maxClaimAmount) → Amount claimedAmount external

getStakingReader() → contract StakingReader stakingReader external

getTargetManager() → contract ITargetLimitHandler targetLimitHandler external

exists(NftId stakeNftId) → bool external

getRequiredStakeBalance(NftId targetNftId, bool includeTargetTypeRequirements) → Amount requiredStakeAmount public

isStakeLocked(NftId stakeNftId) → bool public

Returns true iff current stake amount is still locked

getStakeInfo(NftId stakeNftId) → struct IStaking.StakeInfo stakeInfo external

Returns the stake infos for the specified stake.

getStakeTarget(NftId stakeNftId) → NftId targetNftId external

Returns the stake infos for the specified stake.

getTargetInfo(NftId targetNftId) → struct IStaking.TargetInfo targetInfo external

Returns the target infos for the specified target.

getLimitInfo(NftId targetNftId) → struct IStaking.LimitInfo limitInfo external

Returns the target limit infos for the specified target.

getTvlInfo(NftId targetNftId, address token) → struct IStaking.TvlInfo tvlInfo external

Returns the tvl infos for the specified target.

getTokenInfo(ChainId chainId, address token) → struct IStaking.TokenInfo tokenInfo external

Returns the tvl infos for the specified target.

hasTokenInfo(ChainId chainId, address token) → bool external

getTargetSet() → contract NftIdSet targetNftIdSet external

_updateRewards(NftId stakeNftId, struct IStaking.StakeInfo stakeInfo, struct IStaking.TargetInfo targetInfo) → Amount rewardIncreaseAmount internal

_restakeRewards(NftId stakeNftId, struct IStaking.StakeInfo stakeInfo, struct IStaking.TargetInfo targetInfo) → Amount restakeAmount internal

_stake(NftId stakeNftId, struct IStaking.StakeInfo stakeInfo, struct IStaking.TargetInfo targetInfo, Seconds maxAdditionalLockingPeriod, Amount stakeAmount) internal

_claimRewards(NftId stakeNftId, struct IStaking.StakeInfo stakeInfo, struct IStaking.TargetInfo targetInfo, Amount maxClaimAmount) → Amount claimAmount internal

_unstake(NftId stakeNftId, struct IStaking.StakeInfo stakeInfo, struct IStaking.TargetInfo targetInfo, Amount maxUnstakeAmount) → Amount unstakedAmount internal

_setLastUpdatesToCurrent(struct IStaking.StakeInfo stakeInfo, struct IStaking.TargetInfo targetInfo) → Blocknumber lastUpdateIn internal

_setStakeLastUpdatesToCurrent(struct IStaking.StakeInfo stakeInfo) → Blocknumber lastUpdateIn internal

StakingReader

import "@etherisc/gif-next/contracts/staking/StakingReader.sol";
Functions
  • [constructor(registry)]

  • [initialize(stakingAddress, stakingStoreAddress)]

  • [getRegistry()]

  • [getStaking()]

  • [getProtocolNftId()]

  • [isTarget(targetNftId)]

  • [targets()]

  • [getTargetNftId(idx)]

  • [getTargetNftId(stakeNftId)]

  • [getStakeInfo(stakeNftId)]

  • [getTargetInfo(targetNftId)]

  • [getLimitInfo(targetNftId)]

  • [getTvlInfo(targetNftId, token)]

  • [getTokenInfo(chainId, token)]

  • [isSupportedTargetType(targetType)]

  • [getSupportInfo(targetType)]

  • [getTargetLockingPeriod(stakeNftId)]

  • [getTargetRewardRate(stakeNftId)]

  • [getTargetMaxStakedAmount(targetNftId)]

  • [getLockingPeriod(targetNftId)]

  • [getRewardRate(targetNftId)]

  • [getReserveBalance(targetNftId)]

  • [getTotalValueLocked(targetNftId, token)]

  • [getRequiredStakeBalance(targetNftId)]

  • [getRequiredStakeBalance(targetNftId, includeTargetTypeRequirements)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
Initializable
  • [Initialized(version)]

constructor(contract IRegistry registry) public

initialize(address stakingAddress, address stakingStoreAddress) external

getRegistry() → contract IRegistry registry external

getStaking() → contract IStaking staking external

getProtocolNftId() → NftId protocolNftId external

isTarget(NftId targetNftId) → bool external

targets() → uint256 external

getTargetNftId(uint256 idx) → NftId external

getTargetNftId(NftId stakeNftId) → NftId targetNftId public

getStakeInfo(NftId stakeNftId) → struct IStaking.StakeInfo stakeInfo external

getTargetInfo(NftId targetNftId) → struct IStaking.TargetInfo info public

getLimitInfo(NftId targetNftId) → struct IStaking.LimitInfo info public

getTvlInfo(NftId targetNftId, address token) → struct IStaking.TvlInfo info public

getTokenInfo(ChainId chainId, address token) → struct IStaking.TokenInfo info public

isSupportedTargetType(ObjectType targetType) → bool public

getSupportInfo(ObjectType targetType) → struct IStaking.SupportInfo info public

getTargetLockingPeriod(NftId stakeNftId) → NftId targetNftId, Seconds lockingPeriod external

Get the locking period that applies to the specified stake NFT ID.

getTargetRewardRate(NftId stakeNftId) → NftId targetNftId, UFixed rewardRate external

Get the reward rate that applies to the specified stake NFT ID.

getTargetMaxStakedAmount(NftId targetNftId) → Amount maxStakedAmount external

Get the max staked amount allowed for the specified target NFT ID.

getLockingPeriod(NftId targetNftId) → Seconds lockingPeriod external

Get the reward rate for the specified target NFT ID.

getRewardRate(NftId targetNftId) → UFixed rewardRate external

Get the reward rate for the specified target NFT ID.

getReserveBalance(NftId targetNftId) → Amount rewardReserveBalance external

returns the current reward reserve balance for the specified target.

getTotalValueLocked(NftId targetNftId, address token) → Amount totalValueLocked external

getRequiredStakeBalance(NftId targetNftId) → Amount requiredStakedAmount external

getRequiredStakeBalance(NftId targetNftId, bool includeTargetTypeRequirements) → Amount requiredStakedAmount external

StakingService

import "@etherisc/gif-next/contracts/staking/StakingService.sol";
Modifiers
Functions
  • [createInstanceTarget(targetNftId, initialLockingPeriod, initialRewardRate)]

  • [setInstanceLockingPeriod(instanceNftId, lockingPeriod)]

  • [setInstanceRewardRate(instanceNftId, rewardRate)]

  • [setInstanceMaxStakedAmount(instanceNftId, maxStakingAmount)]

  • [refillInstanceRewardReserves(instanceNftId, rewardProvider, dipAmount)]

  • [withdrawInstanceRewardReserves(instanceNftId, dipAmount)]

  • [createStakeObject(targetNftId, stakeOwner)]

  • [pullDipToken(dipAmount, stakeOwner)]

  • [pushDipToken(dipAmount, stakeOwner)]

  • [approveTokenHandler(token, amount)]

  • [setTotalValueLocked(targetNftId, token, amount)]

  • [getDipToken()]

  • [getTokenHandler()]

  • [getStaking()]

  • [_initialize(owner, data)]

  • [_registerStaking(stakingAddress)]

  • [_getDomain()]

Service
  • [__Service_init(authority, registry, initialOwner)]

  • [getDomain()]

  • [getVersion()]

  • [getRoleId()]

  • [_getServiceAddress(domain)]

ReentrancyGuardUpgradeable
  • [__ReentrancyGuard_init()]

  • [__ReentrancyGuard_init_unchained()]

  • [_reentrancyGuardEntered()]

Versionable
  • [initializeVersionable(activatedBy, data)]

  • [upgradeVersionable(data)]

  • [_upgrade(data)]

Registerable
  • [__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)]

  • [isActive()]

  • [getRelease()]

  • [getInitialInfo()]

NftOwnable
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

AccessManagedUpgradeable
  • [__AccessManaged_init(initialAuthority)]

  • [__AccessManaged_init_unchained(initialAuthority)]

  • [authority()]

  • [setAuthority(newAuthority)]

  • [isConsumingScheduledOp()]

  • [_setAuthority(newAuthority)]

  • [_checkCanCall(caller, data)]

ContextUpgradeable
  • [__Context_init()]

  • [__Context_init_unchained()]

  • [_msgSender()]

  • [_msgData()]

  • [_contextSuffixLength()]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
IStakingService
  • [LogStakingServiceProtocolTargetRegistered(protocolNftId)]

  • [LogStakingServiceInstanceTargetRegistered(instanceNftId, chainId)]

  • [LogStakingServiceLockingPeriodSet(targetNftId, oldLockingDuration, lockingDuration)]

  • [LogStakingServiceRewardRateSet(targetNftId, oldRewardRate, rewardRate)]

  • [LogStakingServiceRewardReservesIncreased(targetNftId, rewardProvider, dipAmount, newBalance)]

  • [LogStakingServiceRewardReservesDecreased(targetNftId, targetOwner, dipAmount, newBalance)]

  • [LogStakingServiceStakeObjectCreated(stakeNftId, targetNftId, stakeOwner)]

  • [LogStakingServiceStakeCreated(stakeNftId, targetNftId, owner, stakedAmount)]

  • [LogStakingServiceStakeIncreased(stakeNftId, owner, stakedAmount, stakeBalance)]

  • [LogStakingServiceUnstaked(stakeNftId, stakeOwner, totalAmount)]

  • [LogStakingServiceStakeRestaked(stakeOwner, stakeNftId, newStakeNftId, newTargetNftId, newStakeBalance)]

  • [LogStakingServiceRewardsUpdated(stakeNftId)]

  • [LogStakingServiceRewardsClaimed(stakeNftId, stakeOwner, rewardsClaimedAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

onlyStaking() modifier

createInstanceTarget(NftId targetNftId, Seconds initialLockingPeriod, UFixed initialRewardRate) external

Creates/registers an on-chain instance staking target. Permissioned: Only instance service

setInstanceLockingPeriod(NftId instanceNftId, Seconds lockingPeriod) external

Set the instance stake locking period to the specified duration. Permissioned: Only instance service

setInstanceRewardRate(NftId instanceNftId, UFixed rewardRate) external

Set the instance reward rate to the specified value. Permissioned: Only instance service

setInstanceMaxStakedAmount(NftId instanceNftId, Amount maxStakingAmount) external

Set the instance max staked amount to the specified value. Permissioned: Only instance service

refillInstanceRewardReserves(NftId instanceNftId, address rewardProvider, Amount dipAmount) → Amount newBalance external

(Re)fills the staking reward reserves for the specified target using the dips provided by the reward provider. Permissioned: Only instance service

withdrawInstanceRewardReserves(NftId instanceNftId, Amount dipAmount) → Amount newBalance external

Defunds the staking reward reserves for the specified target Permissioned: Only instance service

createStakeObject(NftId targetNftId, address stakeOwner) → NftId stakeNftId external

Creates a new stake object for the specified target via the registry service. Permissioned: only the staking component may call this function

pullDipToken(Amount dipAmount, address stakeOwner) external

Collect DIP token from stake owner. Permissioned: only the staking component may call this function

pushDipToken(Amount dipAmount, address stakeOwner) external

Transfer DIP token to stake owner. Permissioned: only the staking component may call this function

approveTokenHandler(contract IERC20Metadata token, Amount amount) external

Approves the staking token handler. Permissioned: only the staking component may call this function

setTotalValueLocked(NftId targetNftId, address token, Amount amount) external

Sets total value locked data for a target contract on a different chain. this is done via CCIP (cross chain communication)

getDipToken() → contract IERC20Metadata dip external

getTokenHandler() → contract TokenHandler tokenHandler external

getStaking() → contract IStaking staking external

_initialize(address owner, bytes data) internal

_registerStaking(address stakingAddress) → contract IStaking staking internal

_getDomain() → ObjectType internal

StakingLib

import "@etherisc/gif-next/contracts/staking/StakingLib.sol";
Functions
  • [checkCreateParameters(stakingReader, targetNftId, dipAmount)]

  • [_checkCreateParameters(stakingReader, targetNftId, dipAmount)]

  • [checkStakeParameters(stakingReader, stakeNftId)]

  • [checkUnstakeParameters(stakingReader, stakeNftId)]

  • [checkTarget(stakingReader, targetNftId)]

  • [checkAndGetStakingService(registry, release)]

  • [checkDipAmount(stakingReader, targetNftId, dipAmount)]

  • [calculateRewardIncrease(stakingReader, stakeNftId, rewardRate)]

  • [calculateRewardAmount(rewardRate, duration, stakeAmount)]

  • [getYearFraction(duration)]

checkCreateParameters(contract StakingReader stakingReader, NftId targetNftId, Amount dipAmount) → Timestamp lockedUntil external

_checkCreateParameters(contract StakingReader stakingReader, NftId targetNftId, Amount dipAmount) → Timestamp lockedUntil internal

checkStakeParameters(contract StakingReader stakingReader, NftId stakeNftId) → UFixed rewardRate, Seconds lockingPeriod public

checkUnstakeParameters(contract StakingReader stakingReader, NftId stakeNftId) → Seconds lockingPeriod public

checkTarget(contract StakingReader stakingReader, NftId targetNftId) → Seconds lockingPeriod public

checkAndGetStakingService(contract IRegistry registry, VersionPart release) → contract IStakingService stakingService public

checkDipAmount(contract StakingReader stakingReader, NftId targetNftId, Amount dipAmount) public

calculateRewardIncrease(contract StakingReader stakingReader, NftId stakeNftId, UFixed rewardRate) → Amount rewardIncreaseAmount public

calculateRewardAmount(UFixed rewardRate, Seconds duration, Amount stakeAmount) → Amount rewardAmount public

getYearFraction(Seconds duration) → UFixed yearFraction public

TargetManagerLib

import "@etherisc/gif-next/contracts/staking/TargetManagerLib.sol";
Functions
  • [updateLockingPeriod(staking, targetNftId, lockingPeriod)]

  • [updateRewardRate(staking, targetNftId, rewardRate)]

  • [checkTargetParameters(registry, stakingReader, targetNftId, expectedObjectType, lockingPeriod, rewardRate)]

  • [checkLockingPeriod(reader, targetNftId, targetType, lockingPeriod)]

  • [checkRewardRate(reader, targetNftId, targetType, rewardRate)]

  • [calculateRequiredDipAmount(tokenAmount, stakingRate)]

  • [calculateStakingRate(dipToken, token, requiredDipPerToken)]

  • [getMaxLockingPeriod()]

  • [getDefaultLockingPeriod()]

  • [getMinimumLockingPeriod()]

  • [getMaxRewardRate()]

  • [getDefaultRewardRate()]

  • [toTargetKey(targetNftId)]

updateLockingPeriod(contract IStaking staking, NftId targetNftId, Seconds lockingPeriod) → Seconds oldLockingPeriod, struct IStaking.TargetInfo targetInfo external

updateRewardRate(contract IStaking staking, NftId targetNftId, UFixed rewardRate) → UFixed oldRewardRate, struct IStaking.TargetInfo targetInfo external

checkTargetParameters(contract IRegistry registry, contract StakingReader stakingReader, NftId targetNftId, ObjectType expectedObjectType, Seconds lockingPeriod, UFixed rewardRate) external

checkLockingPeriod(contract StakingReader reader, NftId targetNftId, ObjectType targetType, Seconds lockingPeriod) public

checkRewardRate(contract StakingReader reader, NftId targetNftId, ObjectType targetType, UFixed rewardRate) public

calculateRequiredDipAmount(Amount tokenAmount, UFixed stakingRate) → Amount dipAmount public

calculateStakingRate(contract IERC20Metadata dipToken, contract IERC20Metadata token, UFixed requiredDipPerToken) → UFixed stakingRate public

getMaxLockingPeriod() → Seconds maxLockingPeriod public

getDefaultLockingPeriod() → Seconds maxLockingPeriod public

getMinimumLockingPeriod() → Seconds minLockingPeriod public

the minimum locking period is 24 hours

getMaxRewardRate() → UFixed maxRewardRate public

getDefaultRewardRate() → UFixed defaultRewardRate public

toTargetKey(NftId targetNftId) → Key32 targetKey public

StakingManager

import "@etherisc/gif-next/contracts/staking/StakingManager.sol";
Functions
  • [constructor(registry, targetHandler, stakingStore, tokenRegistry, initialOwner, salt)]

  • [getStaking()]

ProxyManager
  • [initialize(registry, implementation, data, salt)]

  • [deploy(registry, initialImplementation, initializationData)]

  • [deployDetermenistic(registry, initialImplementation, initializationData, salt)]

  • [upgrade(newImplementation)]

  • [upgrade(newImplementation, upgradeData)]

  • [linkToProxy()]

  • [getDeployData(proxyOwner, deployData)]

  • [getUpgradeData(upgradeData)]

  • [getProxy()]

  • [getVersion()]

  • [getVersionCount()]

  • [getVersion(idx)]

  • [getVersionInfo(_version)]

NftOwnable
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
ProxyManager
  • [LogProxyManagerVersionableDeployed(proxy, initialImplementation)]

  • [LogProxyManagerVersionableUpgraded(proxy, upgradedImplementation)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

Initializable
  • [Initialized(version)]

constructor(address registry, address targetHandler, address stakingStore, address tokenRegistry, address initialOwner, bytes32 salt) public

initializes proxy manager with service implementation

getStaking() → contract Staking external

StakingServiceManager

import "@etherisc/gif-next/contracts/staking/StakingServiceManager.sol";
Functions
  • [constructor(authority, registry, salt)]

  • [getStakingService()]

ProxyManager
  • [initialize(registry, implementation, data, salt)]

  • [deploy(registry, initialImplementation, initializationData)]

  • [deployDetermenistic(registry, initialImplementation, initializationData, salt)]

  • [upgrade(newImplementation)]

  • [upgrade(newImplementation, upgradeData)]

  • [linkToProxy()]

  • [getDeployData(proxyOwner, deployData)]

  • [getUpgradeData(upgradeData)]

  • [getProxy()]

  • [getVersion()]

  • [getVersionCount()]

  • [getVersion(idx)]

  • [getVersionInfo(_version)]

NftOwnable
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
ProxyManager
  • [LogProxyManagerVersionableDeployed(proxy, initialImplementation)]

  • [LogProxyManagerVersionableUpgraded(proxy, upgradedImplementation)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

Initializable
  • [Initialized(version)]

constructor(address authority, address registry, bytes32 salt) public

initializes proxy manager with service implementation

getStakingService() → contract StakingService external