PricelessPositionManager

Financial contract with priceless position management.

onlyPreExpiration() modifier

MODIFIERS

==== onlyPostExpiration() modifier

==== onlyCollateralizedPosition(address sponsor) modifier

==== onlyOpenState() modifier

==== fees() modifier

MODIFIERS

onlyIfTest() modifier

Reverts if not running in test mode.

constructor(bool _isTest, uint256 _expirationTimestamp, uint256 _withdrawalLiveness, address _collateralAddress, address _finderAddress, bytes32 _priceIdentifier, string _syntheticName, string _syntheticSymbol, address _tokenFactoryAddress, struct FixedPoint.Unsigned _minSponsorTokens) public

Construct the PricelessPositionManager

Parameters:

  • _isTest: whether this contract is being constructed for the purpose of running tests.

  • _expirationTimestamp: unix timestamp of when the contract will expire.

  • _withdrawalLiveness: liveness delay, in seconds, for pending withdrawals.

  • _collateralAddress: ERC20 token used as collateral for all positions.

  • _finderAddress: UMA protocol Finder used to discover other protocol contracts.

  • _priceIdentifier: registered in the DVM for the synthetic.

  • _syntheticName: name for the token contract that will be deployed.

  • _syntheticSymbol: symbol for the token contract that will be deployed.

  • _tokenFactoryAddress: deployed UMA token factory to create the synthetic token.

transfer(address newSponsorAddress) public

Transfers ownership of the caller’s current position to newSponsorAddress.

Transferring positions can only occur if the recipient does not already have a position.

Parameters:

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

deposit(struct FixedPoint.Unsigned collateralAmount) public

Transfers collateralAmount of collateralCurrency into the sponsor’s position.

Increases the collateralization level of a position after creation.

Parameters:

  • collateralAmount: total amount of collateral tokens to be sent to the sponsor’s position.

withdraw(struct FixedPoint.Unsigned collateralAmount) public

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

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.

Can only be called by a token sponsor.

Parameters:

  • numTokens: is the number of tokens to be burnt for a commensurate amount of collateral.

settleExpired() external

After a contract has passed expiry 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.

expire() external

Locks contract state in expired and requests oracle price.

this function can only be called once the contract is expired and cant be re-called due to the state modifiers applied on it.

emergencyShutdown() external

Premature contract settlement under emergency circumstances.

Only the governor can call this function as they are permissioned within the FinancialContractAdmin. Upon emergency shutdown, the contract settlement time is set to the shutdown time. This enables withdrawal to occur via the standard settleExpired function. Contract state is set to ExpiredPriceRequested which prevents re-entry into this function or the expire function. No fees are paid when calling emergencyShutdown as the governor who would call the function would also receive the fees.

remargin() external

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.

Parameters:

  • sponsor: address whose collateral amount is retrieved.

totalPositionCollateral() → struct FixedPoint.Unsigned external

Accessor method for the total collateral stored within the PricelessPositionManager.

pfc() → struct FixedPoint.Unsigned public

This overrides pfc() so the PricelessPositionManager can report its profit from corruption.

_reduceSponsorPosition(address sponsor, struct FixedPoint.Unsigned tokensToRemove, struct FixedPoint.Unsigned collateralToRemove, struct FixedPoint.Unsigned withdrawalAmountToRemove) internal

INTERNAL FUNCTIONS

==== _deleteSponsorPosition(address sponsor) → struct FixedPoint.Unsigned internal

==== _getPositionData(address sponsor) → struct PricelessPositionManager.PositionData internal

==== _getIdentifierWhitelist() → contract IdentifierWhitelistInterface internal

==== _getOracle() → contract OracleInterface internal

==== _getStoreAddress() → address internal

==== _getFinancialContractsAdminAddress() → address internal

==== _requestOraclePrice(uint256 requestedTime) internal

==== _getOraclePrice(uint256 requestedTime) → struct FixedPoint.Unsigned internal

==== _onlyOpenState() internal

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

==== _onlyPreExpiration() internal

==== _onlyPostExpiration() internal

==== _onlyCollateralizedPosition(address sponsor) internal

==== payFees() → struct FixedPoint.Unsigned totalPaid public

Pays UMA DVM regular fees to the Store contract.

These must be paid periodically for the life of the contract. If the contract has not paid its regular fee in a week or mre then a late penalty is applied which is sent to the caller.

==== _payFinalFees(address payer, struct FixedPoint.Unsigned amount) internal

Pays UMA DVM final fees to the Store contract.

This is a flat fee charged for each price request.

Parameters:

  • payer: address of who is paying the fees.

  • amount: the amount of collateral to send as the final fee.

==== _getStore() → contract StoreInterface internal

INTERNAL FUNCTIONS

_computeFinalFees() → struct FixedPoint.Unsigned finalFees internal

_getCollateral(struct FixedPoint.Unsigned rawCollateral) → struct FixedPoint.Unsigned collateral internal

_convertCollateral(struct FixedPoint.Unsigned collateral) → struct FixedPoint.Unsigned rawCollateral internal

_removeCollateral(struct FixedPoint.Unsigned rawCollateral, struct FixedPoint.Unsigned collateralToRemove) → struct FixedPoint.Unsigned removedCollateral internal

_addCollateral(struct FixedPoint.Unsigned rawCollateral, struct FixedPoint.Unsigned collateralToAdd) → struct FixedPoint.Unsigned addedCollateral 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.

Transfer(address oldSponsor, address newSponsor) event

EVENTS

==== 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

==== NewSponsor(address sponsor) event

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

==== ContractExpired(address caller) event

==== SettleExpiredPosition(address caller, uint256 collateralReturned, uint256 tokensBurned) event

==== EmergencyShutdown(address caller, uint256 originalExpirationTimestamp, uint256 shutdownTimestamp) event

© UMA Project 2018-2019