Liquidatable

Liquidatable

The liquidation has a liveness period before expiring successfully, during which someone can "dispute" the liquidation, which sends a price request to the relevant Oracle to settle the final collateralization ratio based on a DVM price. The contract enforces dispute rewards in order to incentivize disputers to correctly dispute false liquidations and compensate position sponsors who had their position incorrectly liquidated. Importantly, a prospective disputer must deposit a dispute bond that they can lose in the case of an unsuccessful dispute.

onlyPreExpiryAndPreDispute(uint256 id, address sponsor) modifier

onlyPostExpiryOrPostDispute(uint256 id, address sponsor) modifier

onlyPendingDispute(uint256 id, address sponsor) modifier

onlyPreExpiration() modifier

onlyPostExpiration() modifier

onlyCollateralizedPosition(address sponsor) modifier

fees() modifier

modifier that calls payFees().

onlyIfTest() modifier

Reverts if not running in test mode.

constructor(struct Liquidatable.ConstructorParams params) public

createLiquidation(address sponsor, struct FixedPoint.Unsigned amountToLiquidate) → uint256 uuid external

Liquidates the sponsor’s position if the caller has enough synthetic tokens to retire the position’s outstanding tokens.

This method generates an ID that will uniquely identify liquidation for the sponsor.

Parameters:

  • sponsor: address to liquidate

  • amountToLiquidate: amount of liquidatedCollateral that liquidator wants to liquidate

dispute(uint256 id, address sponsor) external

Disputes a liquidation, if the caller has enough collateral to post a dispute bond and pay a fixed final fee charged on each price request.

Can only dispute a liquidation before the liquidation expires and if there are no other pending disputes.

Parameters:

  • id: of the disputed liquidation.

  • sponsor: the address of the sponsor who’s liquidation is being disputed.

settleDispute(uint256 id, address sponsor) external

After a liquidation has been disputed, it can be settled by any caller enabling withdrawal to occur.

This is only possible after the DVM has resolved a price. Callers should call hasPrice() on the DVM before calling this to ensure that the DVM has resolved a price. This method then calculates whether the dispute on the liquidation was successful using only the settlement price, tokens outstanding, locked collateral (post-pending withdrawals), and liquidation ratio

Parameters:

  • id: to uniquely identify the dispute to settle

  • sponsor: the address of the sponsor who’s dispute is being settled

withdrawLiquidation(uint256 id, address sponsor) → struct FixedPoint.Unsigned withdrawalAmount public

After a dispute has settled or after a non-disputed liquidation has expired, the sponsor, liquidator, and/or disputer can call this method to receive payments.

If the dispute SUCCEEDED: the sponsor, liquidator, and disputer are eligible for payment If the dispute FAILED: only the liquidator can receive payment Once all collateral is withdrawn, delete the liquidation data.

Parameters:

  • id: uniquely identifies the sponsor’s liquidation

  • sponsor: address of the sponsor associated with the liquidation

_getLiquidationData(address sponsor, uint256 uuid) → struct Liquidatable.LiquidationData liquidation internal

constructor(bool _isTest, uint256 _expirationTimestamp, uint256 _withdrawalLiveness, address _collateralAddress, address _finderAddress, bytes32 _priceFeedIdentifier, string _syntheticName, string _syntheticSymbol, address _tokenFactoryAddress) public

transfer(address newSponsorAddress) public

Transfers ownership of the caller’s current position to newSponsorAddress. The address newSponsorAddress isn’t allowed to have a position of their own before the transfer.

transfering positions can only occure if the recipiant does not already have a position.

Parameters:

  • newSponsorAddress: is the address to which the position will be transfered.

deposit(struct FixedPoint.Unsigned collateralAmount) public

Transfers collateralAmount of collateralCurrency into the calling sponsor’s position. Used to increase the collateralization level of a position.

Parameters:

  • collateralAmount: represents the total amount of tokens to be sent to the position for the sponsor.

withdraw(struct FixedPoint.Unsigned collateralAmount) public

Transfers collateralAmount of collateralCurrency from the calling sponsor’s position to the caller.

Reverts if the withdrawal puts this position’s collateralization ratio below the global collateralization ratio. In that case, use requestWithdrawawal.

Parameters:

  • collateralAmount: is the amount of collateral to withdraw

requestWithdrawal(struct FixedPoint.Unsigned collateralAmount) public

Starts a withdrawal request that, if passed, allows the sponsor to withdraw collateralAmount from their position.

The request will be pending for withdrawalLiveness, during which the position can be liquidated.

Parameters:

  • collateralAmount: the amount of collateral requested to withdraw

withdrawPassedRequest() external

After a passed withdrawal request (i.e., by a call to requestWithdrawal and waiting withdrawalLiveness), withdraws positionData.withdrawalRequestAmount of collateral currency.

cancelWithdrawal() external

Cancels a pending withdrawal request.

create(struct FixedPoint.Unsigned collateralAmount, struct FixedPoint.Unsigned numTokens) public

Pulls collateralAmount into the sponsor’s position and mints numTokens of tokenCurrency.

Reverts if the minting these tokens would put the position’s collateralization ratio below the global collateralization ratio.

Parameters:

  • collateralAmount: is the number of collateral tokens to collateralize the position with

  • numTokens: is the number of tokens to mint from the position.

redeem(struct FixedPoint.Unsigned numTokens) public

Burns numTokens of tokenCurrency and sends back the proportional amount of collateralCurrency.

payFees() → struct FixedPoint.Unsigned totalPaid public

This overrides payFees() so the PricelessPositionManager can update its internal bookkeeping to account for the fees.,@notice Pays UMA DVM regular fees to the Store contract. These must be paid periodically for the life of the contract.

expire() external

After expiration of the contract the DVM is asked what for the prevailing price at the time of expiration. In addition, pay the final fee at this time. Once this has been resolved token holders can withdraw.

settleExpired() external

After a contract has passed maturity all token holders can redeem their tokens for underlying at the prevailing price defined by the DVM from the expire function.

This Burns all tokens from the caller of tokenCurrency and sends back the proportional amount of collateralCurrency.

getCollateral(address sponsor) → struct FixedPoint.Unsigned external

Accessor method for a sponsor’s collateral.

This is necessary because the struct returned by the positions() method shows rawCollateral, which isn’t a user-readable value.

pfc() → struct FixedPoint.Unsigned public

This overrides pfc() so the PricelessPositionManager can report its profit from corruption.,@notice Gets the current profit from corruption for this contract in terms of the collateral currency. Derived contracts are expected to implement this function so the payFees() method can correctly compute the owed fees.

_deleteSponsorPosition(address sponsor) internal

_getPositionData(address sponsor) → struct PricelessPositionManager.PositionData internal

_getIdentifierWhitelist() → contract IdentifierWhitelistInterface internal

_getCollateral(struct PricelessPositionManager.PositionData positionData) → struct FixedPoint.Unsigned collateral internal

_removeCollateral(struct PricelessPositionManager.PositionData positionData, struct FixedPoint.Unsigned collateral) internal

_addCollateral(struct PricelessPositionManager.PositionData positionData, struct FixedPoint.Unsigned collateral) internal

_getOracle() → contract OracleInterface internal

_requestOraclePrice(uint256 requestedTime) internal

_getOraclePrice(uint256 requestedTime) → struct FixedPoint.Unsigned internal

_isPreExpiration() internal

These internal functions are supposed to act identically to modifiers, but re-used modifiers unneccessarily increase contract bytecode size source: https://blog.polymath.network/solidity-tips-and-tricks-to-save-gas-and-reduce-bytecode-size-c44580b218e6

_isPostExpiration() internal

_isCollateralizedPosition(address sponsor) internal

constructor(address collateralAddress, address finderAddress, bool _isTest) public

_payFinalFees(address payer) → struct FixedPoint.Unsigned totalPaid internal

Pays UMA DVM final fees to the Store contract. This is a flat fee charged for each price request.

_getStore() → contract StoreInterface internal

constructor(bool _isTest) internal

setCurrentTime(uint256 _time) external

Sets the current time.

Will revert if not running in test mode.

getCurrentTime() → uint256 public

Gets the current time. Will return the last time set in setCurrentTime if running in test mode. Otherwise, it will return the block timestamp.

LiquidationCreated(address sponsor, address liquidator, uint256 liquidationId, uint256 tokensOutstanding, uint256 lockedCollateral, uint256 liquidatedCollateral) event

LiquidationDisputed(address sponsor, address liquidator, address disputer, uint256 disputeId, uint256 disputeBondAmount) event

DisputeSettled(address caller, address sponsor, address liquidator, address disputer, uint256 disputeId, bool DisputeSucceeded) event

LiquidationWithdrawn(address caller) event

Transfer(address oldSponsor, address newSponsor) event

Deposit(address sponsor, uint256 collateralAmount) event

Withdrawal(address sponsor, uint256 collateralAmount) event

RequestWithdrawal(address sponsor, uint256 collateralAmount) event

RequestWithdrawalExecuted(address sponsor, uint256 collateralAmount) event

RequestWithdrawalCanceled(address sponsor, uint256 collateralAmount) event

PositionCreated(address sponsor, uint256 collateralAmount, uint256 tokenAmount) event

Redeem(address sponsor, uint256 collateralAmount, uint256 tokenAmount) event

ContractExpired(address caller) event

SettleExpiredPosition(address caller, uint256 collateralAmountReturned, uint256 tokensBurned) event

© UMA Project 2018-2019