Functions readMaxValue and readMinValue need to be implemented

Open
#2 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
solidity
Domain
blockchain

Research direction

Start by locating readMaxValue and readMinValue in the Solidity contracts, then read the existing value-submission and history logic. Confirm how N and gamma are represented before implementing the described historical traversal and update behavior; done means both functions return the highest or lowest value from the N most recent stored averages.

Written by the indexing model from the issue text.

Description

enhancement

These two functions are important for protocols such as Djed Shu.

There are different ways in which we could implement them. Here is a reasonable and simple one:

  • We keep an array of historical average values.

  • When readMaxValue is called, we traverse the N most recent values from this array and return the highest average price found.

  • When readMinValue is called, we traverse the N most recent values from this array and return the lowest average price found.

  • Let t be the timestamp of the most recent entry in the history array. Whenever a new value is submitted at time a t' and t' > t + gamma, the new average should be pushed into the history array.

The reason for having a minimal interval gamma is that we want the maximum and minimum value to be values over a significant period of time.

(I have a simple idea to optimize the traversals by caching some results. But let's implement the non-optimized version first, which traverses the history on every call to read...Value . Later we can discuss the caching optimization.)

Dominant language
Solidity
Stars
3
Forks
3
Avg merge
15h 55m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StabilityNexus/OrbOracle-Solidity

All issues in StabilityNexus/OrbOracle-Solidity

Similar issues

More Blockchain issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.