Skip to content

Latest commit

 

History

History
521 lines (405 loc) · 15.5 KB

IStabilityPool.md

File metadata and controls

521 lines (405 loc) · 15.5 KB

IStabilityPool.sol

View Source: contracts/Interfaces/IStabilityPool.sol

↘ Derived Contracts: StabilityPool

IStabilityPool

Events

event StabilityPoolETHBalanceUpdated(uint256  _newBalance);
event StabilityPoolZUSDBalanceUpdated(uint256  _newBalance);
event BorrowerOperationsAddressChanged(address  _newBorrowerOperationsAddress);
event TroveManagerAddressChanged(address  _newTroveManagerAddress);
event ActivePoolAddressChanged(address  _newActivePoolAddress);
event DefaultPoolAddressChanged(address  _newDefaultPoolAddress);
event ZUSDTokenAddressChanged(address  _newZUSDTokenAddress);
event SortedTrovesAddressChanged(address  _newSortedTrovesAddress);
event PriceFeedAddressChanged(address  _newPriceFeedAddress);
event CommunityIssuanceAddressChanged(address  _newCommunityIssuanceAddress);
event P_Updated(uint256  _P);
event S_Updated(uint256  _S, uint128  _epoch, uint128  _scale);
event G_Updated(uint256  _G, uint128  _epoch, uint128  _scale);
event EpochUpdated(uint128  _currentEpoch);
event ScaleUpdated(uint128  _currentScale);
event FrontEndRegistered(address indexed _frontEnd, uint256  _kickbackRate);
event FrontEndTagSet(address indexed _depositor, address indexed _frontEnd);
event DepositSnapshotUpdated(address indexed _depositor, uint256  _P, uint256  _S, uint256  _G);
event FrontEndSnapshotUpdated(address indexed _frontEnd, uint256  _P, uint256  _G);
event UserDepositChanged(address indexed _depositor, uint256  _newDeposit);
event FrontEndStakeChanged(address indexed _frontEnd, uint256  _newFrontEndStake, address  _depositor);
event ETHGainWithdrawn(address indexed _depositor, uint256  _ETH, uint256  _ZUSDLoss);
event ZEROPaidToDepositor(address indexed _depositor, uint256  _ZERO);
event ZEROPaidToFrontEnd(address indexed _frontEnd, uint256  _ZERO);
event EtherSent(address  _to, uint256  _amount);

Functions


setAddresses

Called only once on init, to set addresses of other Liquity contracts. Callable only by owner

function setAddresses(address _liquityBaseParamsAddress, address _borrowerOperationsAddress, address _troveManagerAddress, address _activePoolAddress, address _zusdTokenAddress, address _sortedTrovesAddress, address _priceFeedAddress, address _communityIssuanceAddress) external nonpayable

Arguments

Name Type Description
_liquityBaseParamsAddress address LiquidityBaseParams contract address
_borrowerOperationsAddress address BorrowerOperations contract address
_troveManagerAddress address TroveManager contract address
_activePoolAddress address ActivePool contract address
_zusdTokenAddress address ZUSDToken contract address
_sortedTrovesAddress address SortedTroves contract address
_priceFeedAddress address PriceFeed contract address
_communityIssuanceAddress address CommunityIssuanceAddress
Source Code
function setAddresses(
        address _liquityBaseParamsAddress,
        address _borrowerOperationsAddress,
        address _troveManagerAddress,
        address _activePoolAddress,
        address _zusdTokenAddress,
        address _sortedTrovesAddress,
        address _priceFeedAddress,
        address _communityIssuanceAddress
    ) external;

provideToSP

Initial checks:

  • Frontend is registered or zero address
  • Sender is not a registered frontend
  • _amount is not zero

  • Triggers a ZERO issuance, based on time passed since the last issuance. The ZERO issuance is shared between all depositors and front ends
  • Tags the deposit with the provided front end tag param, if it's a new deposit
  • Sends depositor's accumulated gains (ZERO, ETH) to depositor
  • Sends the tagged front end's accumulated ZERO gains to the tagged front end
  • Increases deposit and tagged front end's stake, and takes new snapshots for each.
function provideToSP(uint256 _amount, address _frontEndTag) external nonpayable

Arguments

Name Type Description
_amount uint256 amount to provide
_frontEndTag address frontend address to receive accumulated ZERO gains
Source Code
function provideToSP(uint _amount, address _frontEndTag) external;

withdrawFromSP

Initial checks: - _amount is zero or there are no under collateralized troves left in the system - User has a non zero deposit --- - Triggers a ZERO issuance, based on time passed since the last issuance. The ZERO issuance is shared between all depositors and front ends - Removes the deposit's front end tag if it is a full withdrawal - Sends all depositor's accumulated gains (ZERO, ETH) to depositor - Sends the tagged front end's accumulated ZERO gains to the tagged front end - Decreases deposit and tagged front end's stake, and takes new snapshots for each.

If _amount > userDeposit, the user withdraws all of their compounded deposit.
function withdrawFromSP(uint256 _amount) external nonpayable

Arguments

Name Type Description
_amount uint256 amount to withdraw
Source Code
function withdrawFromSP(uint _amount) external;

withdrawETHGainToTrove

Initial checks: - User has a non zero deposit - User has an open trove - User has some ETH gain --- - Triggers a ZERO issuance, based on time passed since the last issuance. The ZERO issuance is shared between all depositors and front ends - Sends all depositor's ZERO gain to depositor - Sends all tagged front end's ZERO gain to the tagged front end - Transfers the depositor's entire ETH gain from the Stability Pool to the caller's trove - Leaves their compounded deposit in the Stability Pool - Updates snapshots for deposit and tagged front end stake

function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external nonpayable

Arguments

Name Type Description
_upperHint address upper trove id hint
_lowerHint address lower trove id hint
Source Code
function withdrawETHGainToTrove(address _upperHint, address _lowerHint) external;

registerFrontEnd

Initial checks: - Frontend (sender) not already registered - User (sender) has no deposit - _kickbackRate is in the range [0, 100%] --- Front end makes a one-time selection of kickback rate upon registering

function registerFrontEnd(uint256 _kickbackRate) external nonpayable

Arguments

Name Type Description
_kickbackRate uint256 kickback rate selected by frontend
Source Code
function registerFrontEnd(uint _kickbackRate) external;

offset

Initial checks: - Caller is TroveManager --- Cancels out the specified debt against the ZUSD contained in the Stability Pool (as far as possible) and transfers the Trove's ETH collateral from ActivePool to StabilityPool. Only called by liquidation functions in the TroveManager.

function offset(uint256 _debt, uint256 _coll) external nonpayable

Arguments

Name Type Description
_debt uint256 debt to cancel
_coll uint256 collateral to transfer
Source Code
function offset(uint _debt, uint _coll) external;

getETH

function getETH() external view
returns(uint256)
Source Code
function getETH() external view returns (uint);

getTotalZUSDDeposits

function getTotalZUSDDeposits() external view
returns(uint256)
Source Code
function getTotalZUSDDeposits() external view returns (uint);

getDepositorETHGain

Calculates the ETH gain earned by the deposit since its last snapshots were taken.

function getDepositorETHGain(address _depositor) external view
returns(uint256)

Arguments

Name Type Description
_depositor address address to calculate ETH gain

Returns

ETH gain from given depositor

Source Code
function getDepositorETHGain(address _depositor) external view returns (uint);

getDepositorZEROGain

Calculate the ZERO gain earned by a deposit since its last snapshots were taken. If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned. Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through which they made their deposit.

function getDepositorZEROGain(address _depositor) external view
returns(uint256)

Arguments

Name Type Description
_depositor address address to calculate ETH gain

Returns

ZERO gain from given depositor

Source Code
function getDepositorZEROGain(address _depositor) external view returns (uint);

getFrontEndZEROGain

function getFrontEndZEROGain(address _frontEnd) external view
returns(uint256)

Arguments

Name Type Description
_frontEnd address front end address

Returns

the ZERO gain earned by the front end.

Source Code
function getFrontEndZEROGain(address _frontEnd) external view returns (uint);

getCompoundedZUSDDeposit

function getCompoundedZUSDDeposit(address _depositor) external view
returns(uint256)

Arguments

Name Type Description
_depositor address depositor address

Returns

the user's compounded deposit.

Source Code
function getCompoundedZUSDDeposit(address _depositor) external view returns (uint);

getCompoundedFrontEndStake

The front end's compounded stake is equal to the sum of its depositors' compounded deposits.

function getCompoundedFrontEndStake(address _frontEnd) external view
returns(uint256)

Arguments

Name Type Description
_frontEnd address front end address

Returns

the front end's compounded stake.

Source Code
function getCompoundedFrontEndStake(address _frontEnd) external view returns (uint);

Contracts