DelegatedStaking

Contract for slashing and delegated staking

Modifiers

onlyAdmin

modifier onlyAdmin();

Throws if called by any account other than the contract admin.

Read-Only Functions

getUserInfo

function getUserInfo(address _user) public view returns (UserInfo);

Returns user info.

Parameter

Type

Description

_user

address

User's address

timelock

function timelock() public view returns (uint256);

Returns duration of withdrawal timelock.

BPS_DENOMINATOR

function BPS_DENOMINATOR() public view returns (uint256);

Returns basis points denominator.

minProfitSharingBPS

function minProfitSharingBPS() public view returns (uint256);

Returns minimum profit sharing basis points.

collaterals

function collaterals(address _collateral) public view returns (Collateral);

Parameter

Type

Description

_collateral

address

Collateral address

Returns collateral info.

collateralAddresses

function collateralAddresses() public view returns (address[]);

Returns collateral addresses.

accumulatedProtocolRewards

function accumulatedProtocolRewards(address _collateral)
public
view
returns (uint256);

Parameter

Type

Description

_collateral

address

Collateral address

Returns rewards accumulated from protocol.

strategies

function strategies(address _strategy) public view returns (Strategy);

Parameter

Type

Description

_strategy

address

Address of strategy

Returns strategy info.

strategyAddresses

function strategyAddresses() public view returns (address[]);

Returns strategy addresses.

priceConsumer

function priceConsumer() public view returns (IPriceConsumer);

Returns price consumer address.

getPricePerFullStrategyShare

function getPricePerFullStrategyShare(address _strategy, address _collateral)
external
view
returns (uint256);

Parameter

Type

Description

_strategy

address

Strategy address

_collateral

address

Collateral address

Returns price per full share of strategy.

getPricePerFullOracleShare

function getPricePerFullOracleShare(address _oracle, address _collateral)
external
view
returns (uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

Returns price per full share of oracle collateral.

getPoolUSDAmount

function getPoolUSDAmount(address _oracle, address _collateral)
public
view
returns (uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

Returns USD amount of oracle collateral.

getTotalUSDAmount

function getTotalUSDAmount(address _oracle) public view returns (uint256);

Parameter

Type

Description

_oracle

address

Oracle address

Returns total USD amount of oracle collateral.

getWithdrawalRequest

function getWithdrawalRequest(address _user, uint256 _withdrawalId)
public
view
returns (WithdrawalInfo memory);

Returns withdrawal request details.

Parameter

Type

Description

_user

address

User address

_withdrawalId

uint256

Withdrawal identifier

getOracleStaking

function getOracleStaking(address _oracle, address _collateral)
public
view
returns (uint256, uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

Returns amount staked by oracle and locked amount.

getDelegatorStakes

function getDelegatorStakes(address _oracle, address _delegator, address _collateral)
public
view
returns(bool, uint256, uint256, uint256, uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_delegator

address

Delegator address

_collateral

address

Collateral address

Returns whether delegator exists, amount staked to oracle by delegator and their share of oracle collateral, locked amount and passed rewards.

getRewards

function getUserRewards(address _user, address _collateral)
public
view
returns(uint256, uint256, uint256);

Parameter

Type

Description

_user

address

User address

_collateral

address

Collateral address

Returns rewards accumulated by user, collateral and protocol.

getDelegationInfo

function getTotalDelegation(address _oracle, address _collateral)
public
view
returns(uint256, uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

Returns total delegation amount to oracle, total oracle shares and delegator count.

getStrategyStakes

function getStrategyStakes(address _strategy)
public
view
returns(uint256, uint256, uint256);

Parameter

Type

Description

_strategy

address

Strategy address

Returns strategy total reserve amount, shares and rewards.

getTokensPerShare

function address _oracle, address _collateral, address _dependsCollateral)
external
view
returns(uint256, uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

_dependsCollateral

address

Depends collateral address

Returns accumulated and dependent tokens per share.

getStrategyDepositInfo

getStrategyDepositInfo(address _oracle, address _strategy)
external
view
returns(uint256, uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_strategy

address

Strategy address

Returns strategy deposit info for oracle.

getStrategyDepositInfo

getStrategyDepositInfo(address _oracle, address _delegator, address _strategy)
external
view
returns(uint256, uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_delegator

address

Delegator address

_strategy

address

Strategy address

Returns strategy deposit info for delegator to oracle.

State-Changing Functions

stake

function stake(address _oracle, address _collateral, uint256 _amount) external;

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

_amount

uint256

Amount of tokens to stake

Stakes collateral to oracle.

requestUnstake

function requestUnstake(
address _oracle,
address _collateral,
address _recipient,
uint256 _amount
) external;

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

_recipient

address

Recipient address

_amount

uint256

Amount of share to unstake

Withdraws user stake and pending share of rewards.

executeUnstake

function executeUnstake(address _user, uint256 _withdrawalId) external;

Parameter

Type

Description

_user

address

User address

_withdrawalId

uint256

Recipient address

Execute withdraw stake if called by the user admin.

cancelUnstake

function cancelUnstake(address _oracle, uint256 _withdrawalId) external;

Parameter

Type

Description

_oracle

address

Oracle address

_withdrawalId

uint256

Withdrawal identifier

Cancel unstake if called by oracle/delegator admin.

depositToStrategy

function depositToStrategy(
address _oracle,
uint256 _amount,
address _strategy
) external;

Parameter

Type

Description

_oracle

address

Oracle address

_amount

uint256

Amount to stake

_strategy

address

Strategy address

Stake token to strategies to earn rewards.

withdrawFromStrategy

function withdrawFromStrategy(
address _oracle,
uint256 _shares,
address _strategy
) external;

Parameter

Type

Description

_oracle

address

Oracle address

_shares

uint256

Number of shares to withdraw

_strategy

address

Strategy address

Withdraw collateral from strategy to claim rewards.

recoverFromEmergency

function recoverFromEmergency(
address _strategy,
address[] calldata _oracles
) external;

Parameter

Type

Description

_strategy

address

Strategy address

_oracles

address[]

Oracle addresses

Recovers user share of all funds emergency withdrawn from the strategy.

setProfitSharing

function setProfitSharing(address _oracle, uint256 _profitSharingBPS) external;

Parameter

Type

Description

_oracle

address

Oracle address

_profitSharingBPS

uint256

Basis points

Set basis points of profit sharing.

distributeRewards

function distributeRewards(
address _oracle,
address _collateral,
uint256 _amount
) external;

Parameter

Type

Description

_oracle

address

Oracle address

_collateral

address

Collateral address

_amount

uint256

Amount of collateral

Distributes oracle rewards to oracle/delegators.

emergencyWithdrawFromStrategy

function emergencyWithdrawFromStrategy(address _strategy) external onlyAdmin();

Parameter

Type

Description

_strategy

address

Strategy address

Withdraws all funds from the strategy.

setTimelock

function setTimelock(uint256 _newTimelock) external onlyAdmin();

Parameter

Type

Description

_newTimelock

uint256

New timelock

Change withdrawal timelock.

setMinProfitSharing

function setMinProfitSharing(uint256 _profitSharingBPS) external onlyAdmin();

Parameter

Type

Description

_profitSharingBPS

uint256

Minimum basis points

Set minimum basis points of profit sharing.

liquidate

function liquidate(address _oracle, uint256 _amount) external onlyAdmin();

Parameter

Type

Description

_oracle

address

Oracle address

_amount

uint256

Amount of tokens to confiscate

Confiscate stake.

withdrawFunds

function withdrawFunds(address _recipient, uint256 _amount) externa onlyAdmin();

Parameter

Type

Description

_recipient

address

Recipient address

_amount

uint256

Amount of tokens to withdraw

Withdraws confiscated tokens if called by contract admin.

addOracle

function addOracle(address _oracle, address _admin) external onlyAdmin();

Parameter

Type

Description

_oracle

address

Oracle address

_admin

address

Oracle admin address

Add new oracle if called by the contract admin.

addCollateral

function addCollateral(address _token, uint8 _decimals, bool _isUSDStable)
external onlyAdmin();

Parameter

Type

Description

_token

address

New collateral address

Add a new collateral.

updateCollateral

function updateCollateral(address _collateral, bool _isEnabled)
external onlyAdmin();

Parameter

Type

Description

_collateral

address

Collateral address

_isEnabled

bool

Collateral enabled boolean

Enable/disable collateral.

updateCollateral

function updateCollateral(address _collateral, uint256 _amount)
external onlyAdmin();

Parameter

Type

Description

_collateral

address

Collateral address

_amount

uint256

Max collateral amount

Update maximum collateral amount.

addStrategy

function addStrategy(address _strategy, address _stakeToken, address _rewardToken)
external onlyAdmin();

Parameter

Type

Description

_strategy

address

Strategy address

_stakeToken

address

Stake token address

_rewardToken

address

Reward token address

Add a new strategy.

updateStrategy

function updateStrategy(address _strategy, bool _isEnabled) external onlyAdmin();

Parameter

Type

Description

_strategy

address

Strategy address

_isEnabled

bool

Strategy enabled boolean

Enable/disable strategy.

pauseUnstake

function pauseUnstake(address _user) external onlyAdmin();

Parameter

Type

Description

_user

address

User address

Pause unstaking request.

resumeUnstake

function resumeUnstake(address _user) external onlyAdmin()

Parameter

Type

Description

_user

address

User address

Resume unstaking request.

setPriceConsumer

function setPriceConsumer(IPriceConsumer _priceConsumer) external onlyAdmin();

Parameter

Type

Description

_priceConsumer

IPriceConsumer

Price consumer address

Set price consumer.

_creditDelegatorRewards

function _creditDelegatorRewards(address _oracle, address _sender, address _collateral)
internal returns(uint256);

Parameter

Type

Description

_oracle

address

Oracle address

_sender

address

Sender address

_collateral

address

Collateral address

Credits delegator share of oracle rewards and updated passed rewards.

‚Äč