deBridge
Search…
DelegatedStaking
Contract for slashing and delegated staking

Modifiers

onlyAdmin

1
modifier onlyAdmin();
Copied!
Throws if called by any account other than the contract admin.

Read-Only Functions

getUserInfo

1
function getUserInfo(address _user) public view returns (UserInfo);
Copied!
Returns user info.
Parameter
Type
Description
_user
address
User's address

timelock

1
function timelock() public view returns (uint256);
Copied!
Returns duration of withdrawal timelock.

BPS_DENOMINATOR

1
function BPS_DENOMINATOR() public view returns (uint256);
Copied!
Returns basis points denominator.

minProfitSharingBPS

1
function minProfitSharingBPS() public view returns (uint256);
Copied!
Returns minimum profit sharing basis points.

collaterals

1
function collaterals(address _collateral) public view returns (Collateral);
Copied!
Parameter
Type
Description
_collateral
address
Collateral address
Returns collateral info.

collateralAddresses

1
function collateralAddresses() public view returns (address[]);
Copied!
Returns collateral addresses.

accumulatedProtocolRewards

1
function accumulatedProtocolRewards(address _collateral)
2
public
3
view
4
returns (uint256);
Copied!
Parameter
Type
Description
_collateral
address
Collateral address
Returns rewards accumulated from protocol.

strategies

1
function strategies(address _strategy) public view returns (Strategy);
Copied!
Parameter
Type
Description
_strategy
address
Address of strategy
Returns strategy info.

strategyAddresses

1
function strategyAddresses() public view returns (address[]);
Copied!
Returns strategy addresses.

priceConsumer

1
function priceConsumer() public view returns (IPriceConsumer);
Copied!
Returns price consumer address.

getPricePerFullStrategyShare

1
function getPricePerFullStrategyShare(address _strategy, address _collateral)
2
external
3
view
4
returns (uint256);
Copied!
Parameter
Type
Description
_strategy
address
Strategy address
_collateral
address
Collateral address
Returns price per full share of strategy.

getPricePerFullOracleShare

1
function getPricePerFullOracleShare(address _oracle, address _collateral)
2
external
3
view
4
returns (uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
Returns price per full share of oracle collateral.

getPoolUSDAmount

1
function getPoolUSDAmount(address _oracle, address _collateral)
2
public
3
view
4
returns (uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
Returns USD amount of oracle collateral.

getTotalUSDAmount

1
function getTotalUSDAmount(address _oracle) public view returns (uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
Returns total USD amount of oracle collateral.

getWithdrawalRequest

1
function getWithdrawalRequest(address _user, uint256 _withdrawalId)
2
public
3
view
4
returns (WithdrawalInfo memory);
Copied!
Returns withdrawal request details.
Parameter
Type
Description
_user
address
User address
_withdrawalId
uint256
Withdrawal identifier

getOracleStaking

1
function getOracleStaking(address _oracle, address _collateral)
2
public
3
view
4
returns (uint256, uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
Returns amount staked by oracle and locked amount.

getDelegatorStakes

1
function getDelegatorStakes(address _oracle, address _delegator, address _collateral)
2
public
3
view
4
returns(bool, uint256, uint256, uint256, uint256);
Copied!
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

1
function getUserRewards(address _user, address _collateral)
2
public
3
view
4
returns(uint256, uint256, uint256);
Copied!
Parameter
Type
Description
_user
address
User address
_collateral
address
Collateral address
Returns rewards accumulated by user, collateral and protocol.

getDelegationInfo

1
function getTotalDelegation(address _oracle, address _collateral)
2
public
3
view
4
returns(uint256, uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
Returns total delegation amount to oracle, total oracle shares and delegator count.

getStrategyStakes

1
function getStrategyStakes(address _strategy)
2
public
3
view
4
returns(uint256, uint256, uint256);
Copied!
Parameter
Type
Description
_strategy
address
Strategy address
Returns strategy total reserve amount, shares and rewards.

getTokensPerShare

1
function address _oracle, address _collateral, address _dependsCollateral)
2
external
3
view
4
returns(uint256, uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
_dependsCollateral
address
Depends collateral address
Returns accumulated and dependent tokens per share.

getStrategyDepositInfo

1
getStrategyDepositInfo(address _oracle, address _strategy)
2
external
3
view
4
returns(uint256, uint256);
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_strategy
address
Strategy address
Returns strategy deposit info for oracle.

getStrategyDepositInfo

1
getStrategyDepositInfo(address _oracle, address _delegator, address _strategy)
2
external
3
view
4
returns(uint256, uint256);
Copied!
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

1
function stake(address _oracle, address _collateral, uint256 _amount) external;
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
_amount
uint256
Amount of tokens to stake
Stakes collateral to oracle.

requestUnstake

1
function requestUnstake(
2
address _oracle,
3
address _collateral,
4
address _recipient,
5
uint256 _amount
6
) external;
Copied!
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

1
function executeUnstake(address _user, uint256 _withdrawalId) external;
Copied!
Parameter
Type
Description
_user
address
User address
_withdrawalId
uint256
Recipient address
Execute withdraw stake if called by the user admin.

cancelUnstake

1
function cancelUnstake(address _oracle, uint256 _withdrawalId) external;
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_withdrawalId
uint256
Withdrawal identifier
Cancel unstake if called by oracle/delegator admin.

depositToStrategy

1
function depositToStrategy(
2
address _oracle,
3
uint256 _amount,
4
address _strategy
5
) external;
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_amount
uint256
Amount to stake
_strategy
address
Strategy address
Stake token to strategies to earn rewards.

withdrawFromStrategy

1
function withdrawFromStrategy(
2
address _oracle,
3
uint256 _shares,
4
address _strategy
5
) external;
Copied!
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

1
function recoverFromEmergency(
2
address _strategy,
3
address[] calldata _oracles
4
) external;
Copied!
Parameter
Type
Description
_strategy
address
Strategy address
_oracles
address[]
Oracle addresses
Recovers user share of all funds emergency withdrawn from the strategy.

setProfitSharing

1
function setProfitSharing(address _oracle, uint256 _profitSharingBPS) external;
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_profitSharingBPS
uint256
Basis points
Set basis points of profit sharing.

distributeRewards

1
function distributeRewards(
2
address _oracle,
3
address _collateral,
4
uint256 _amount
5
) external;
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_collateral
address
Collateral address
_amount
uint256
Amount of collateral
Distributes oracle rewards to oracle/delegators.

emergencyWithdrawFromStrategy

1
function emergencyWithdrawFromStrategy(address _strategy) external onlyAdmin();
Copied!
Parameter
Type
Description
_strategy
address
Strategy address
Withdraws all funds from the strategy.

setTimelock

1
function setTimelock(uint256 _newTimelock) external onlyAdmin();
Copied!
Parameter
Type
Description
_newTimelock
uint256
New timelock
Change withdrawal timelock.

setMinProfitSharing

1
function setMinProfitSharing(uint256 _profitSharingBPS) external onlyAdmin();
Copied!
Parameter
Type
Description
_profitSharingBPS
uint256
Minimum basis points
Set minimum basis points of profit sharing.

liquidate

1
function liquidate(address _oracle, uint256 _amount) external onlyAdmin();
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_amount
uint256
Amount of tokens to confiscate
Confiscate stake.

withdrawFunds

1
function withdrawFunds(address _recipient, uint256 _amount) externa onlyAdmin();
Copied!
Parameter
Type
Description
_recipient
address
Recipient address
_amount
uint256
Amount of tokens to withdraw
Withdraws confiscated tokens if called by contract admin.

addOracle

1
function addOracle(address _oracle, address _admin) external onlyAdmin();
Copied!
Parameter
Type
Description
_oracle
address
Oracle address
_admin
address
Oracle admin address
Add new oracle if called by the contract admin.

addCollateral

1
function addCollateral(address _token, uint8 _decimals, bool _isUSDStable)
2
external onlyAdmin();
Copied!
Parameter
Type
Description
_token
address
New collateral address
Add a new collateral.

updateCollateral

1
function updateCollateral(address _collateral, bool _isEnabled)
2
external onlyAdmin();
Copied!
Parameter
Type
Description
_collateral
address
Collateral address
_isEnabled
bool
Collateral enabled boolean
Enable/disable collateral.

updateCollateral

1
function updateCollateral(address _collateral, uint256 _amount)
2
external onlyAdmin();
Copied!
Parameter
Type
Description
_collateral
address
Collateral address
_amount
uint256
Max collateral amount
Update maximum collateral amount.

addStrategy

1
function addStrategy(address _strategy, address _stakeToken, address _rewardToken)
2
external onlyAdmin();
Copied!
Parameter
Type
Description
_strategy
address
Strategy address
_stakeToken
address
Stake token address
_rewardToken
address
Reward token address
Add a new strategy.

updateStrategy

1
function updateStrategy(address _strategy, bool _isEnabled) external onlyAdmin();
Copied!
Parameter
Type
Description
_strategy
address
Strategy address
_isEnabled
bool
Strategy enabled boolean
Enable/disable strategy.

pauseUnstake

1
function pauseUnstake(address _user) external onlyAdmin();
Copied!
Parameter
Type
Description
_user
address
User address
Pause unstaking request.

resumeUnstake

1
function resumeUnstake(address _user) external onlyAdmin()
Copied!
Parameter
Type
Description
_user
address
User address
Resume unstaking request.

setPriceConsumer

1
function setPriceConsumer(IPriceConsumer _priceConsumer) external onlyAdmin();
Copied!
Parameter
Type
Description
_priceConsumer
IPriceConsumer
Price consumer address
Set price consumer.

_creditDelegatorRewards

1
function _creditDelegatorRewards(address _oracle, address _sender, address _collateral)
2
internal returns(uint256);
Copied!
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.
Last modified 2mo ago