Skip to main content

Store

Store#

Functions#

constructor(struct FixedPoint.Unsigned _fixedOracleFeePerSecondPerPfc, struct FixedPoint.Unsigned _weeklyDelayFeePerSecondPerPfc, address _timerAddress) (public)

Construct the Store contract.

payOracleFees() (external)

Pays Oracle fees in ETH to the store.

To be used by contracts whose margin currency is ETH.

payOracleFeesErc20(address erc20Address, struct FixedPoint.Unsigned amount) (external)

Pays oracle fees in the margin currency, erc20Address, to the store.

To be used if the margin currency is an ERC20 token rather than ETH.

Parameters:#

  • erc20Address: address of the ERC20 token used to pay the fee.
  • amount: number of tokens to transfer. An approval for at least this amount must exist.
computeRegularFee(uint256 startTime, uint256 endTime, struct FixedPoint.Unsigned pfc) โ†’ struct FixedPoint.Unsigned regularFee, struct FixedPoint.Unsigned latePenalty (external)

Computes the regular oracle fees that a contract should pay for a period.

The late penalty is similar to the regular fee in that is is charged per second over the period between startTime and endTime.

The late penalty percentage increases over time as follows:

  • 0-1 week since startTime: no late penalty

  • 1-2 weeks since startTime: 1x late penalty percentage is applied

  • 2-3 weeks since startTime: 2x late penalty percentage is applied

  • ...

Parameters:#

  • startTime: defines the beginning time from which the fee is paid.
  • endTime: end time until which the fee is paid.
  • pfc: "profit from corruption", or the maximum amount of margin currency that a token sponsor could extract from the contract through corrupting the price feed in their favor.
computeFinalFee(address currency) โ†’ struct FixedPoint.Unsigned (external)

Computes the final oracle fees that a contract should pay at settlement.

Parameters:#

  • currency: token used to pay the final fee.
setFixedOracleFeePerSecondPerPfc(struct FixedPoint.Unsigned newFixedOracleFeePerSecondPerPfc) (public)

Sets a new oracle fee per second.

Parameters:#

  • newFixedOracleFeePerSecondPerPfc: new fee per second charged to use the oracle.
setWeeklyDelayFeePerSecondPerPfc(struct FixedPoint.Unsigned newWeeklyDelayFeePerSecondPerPfc) (public)

Sets a new weekly delay fee.

Parameters:#

  • newWeeklyDelayFeePerSecondPerPfc: fee escalation per week of late fee payment.
setFinalFee(address currency, struct FixedPoint.Unsigned newFinalFee) (public)

Sets a new final fee for a particular currency.

Parameters:#

  • currency: defines the token currency used to pay the final fee.
  • newFinalFee: final fee amount.
setCurrentTime(uint256 time) (external)

Sets the current time.

Will revert if not running in test mode.

Parameters:#

  • time: timestamp to set current Testable time to.
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.

withdraw(uint256 amount) (external)

Withdraws ETH from the contract.

withdrawErc20(address erc20Address, uint256 amount) (external)

Withdraws ERC20 tokens from the contract.

Parameters:#

  • erc20Address: ERC20 token to withdraw.
  • amount: amount of tokens to withdraw.
_createWithdrawRole(uint256 newRoleId, uint256 managingRoleId, address withdrawerAddress) (internal)

Internal method that allows derived contracts to create a role for withdrawal.

Either this method or _setWithdrawRole must be called by the derived class for this contract to function properly.

Parameters:#

  • newRoleId: ID corresponding to role whose members can withdraw.
  • managingRoleId: ID corresponding to managing role who can modify the withdrawable role's membership.
  • withdrawerAddress: new manager of withdrawable role.
_setWithdrawRole(uint256 setRoleId) (internal)

Internal method that allows derived contracts to choose the role for withdrawal.

The role setRoleId must exist. Either this method or _createWithdrawRole must be called by the derived class for this contract to function properly.

Parameters:#

  • setRoleId: ID corresponding to role whose members can withdraw.
holdsRole(uint256 roleId, address memberToCheck) โ†’ bool (public)

Whether memberToCheck is a member of roleId.

Reverts if roleId does not correspond to an initialized role.

Parameters:#

  • roleId: the Role to check.
  • memberToCheck: the address to check.
resetMember(uint256 roleId, address newMember) (public)

Changes the exclusive role holder of roleId to newMember.

Reverts if the caller is not a member of the managing role for roleId or if roleId is not an initialized, ExclusiveRole.

Parameters:#

  • roleId: the ExclusiveRole membership to modify.
  • newMember: the new ExclusiveRole member.
getMember(uint256 roleId) โ†’ address (public)

Gets the current holder of the exclusive role, roleId.

Reverts if roleId does not represent an initialized, exclusive role.

Parameters:#

  • roleId: the ExclusiveRole membership to check.
addMember(uint256 roleId, address newMember) (public)

Adds newMember to the shared role, roleId.

Reverts if roleId does not represent an initialized, SharedRole or if the caller is not a member of the managing role for roleId.

Parameters:#

  • roleId: the SharedRole membership to modify.
  • newMember: the new SharedRole member.
removeMember(uint256 roleId, address memberToRemove) (public)

Removes memberToRemove from the shared role, roleId.

Reverts if roleId does not represent an initialized, SharedRole or if the caller is not a member of the managing role for roleId.

Parameters:#

  • roleId: the SharedRole membership to modify.
  • memberToRemove: the current SharedRole member to remove.
renounceMembership(uint256 roleId) (public)

Removes caller from the role, roleId.

Reverts if the caller is not a member of the role for roleId or if roleId is not an initialized, SharedRole.

Parameters:#

  • roleId: the SharedRole membership to modify.
_createSharedRole(uint256 roleId, uint256 managingRoleId, address[] initialMembers) (internal)

Internal method to initialize a shared role, roleId, which will be managed by managingRoleId. initialMembers will be immediately added to the role.

Should be called by derived contracts, usually at construction time. Will revert if the role is already initialized.

_createExclusiveRole(uint256 roleId, uint256 managingRoleId, address initialMember) (internal)

Internal method to initialize an exclusive role, roleId, which will be managed by managingRoleId. initialMember will be immediately added to the role.

Should be called by derived contracts, usually at construction time. Will revert if the role is already initialized.

Events#

NewFixedOracleFeePerSecondPerPfc(struct FixedPoint.Unsigned newOracleFee)
NewWeeklyDelayFeePerSecondPerPfc(struct FixedPoint.Unsigned newWeeklyDelayFeePerSecondPerPfc)
NewFinalFee(struct FixedPoint.Unsigned newFinalFee)
ResetExclusiveMember(uint256 roleId, address newMember, address manager)
AddedSharedMember(uint256 roleId, address newMember, address manager)
RemovedSharedMember(uint256 roleId, address oldMember, address manager)

Modifiers#

onlyIfTest()

Reverts if not running in test mode.

onlyRoleHolder(uint256 roleId)

Reverts unless the caller is a member of the specified roleId.

onlyRoleManager(uint256 roleId)

Reverts unless the caller is a member of the manager role for the specified roleId.

onlyExclusive(uint256 roleId)

Reverts unless the roleId represents an initialized, exclusive roleId.

onlyShared(uint256 roleId)

Reverts unless the roleId represents an initialized, shared roleId.

onlyValidRole(uint256 roleId)

Reverts if roleId is not initialized.

onlyInvalidRole(uint256 roleId)

Reverts if roleId is initialized.